Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add share_button_visible option #403

Merged
merged 9 commits into from
Dec 23, 2019
18 changes: 18 additions & 0 deletions app/Album.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @property int $full_photo
* @property int $visible_hidden
* @property int $downloadable
* @property int $share_button_visible
* @property string|null $password
* @property string $license
* @property Carbon|null $created_at
Expand All @@ -44,6 +45,7 @@
* @method static Builder|Album whereCreatedAt($value)
* @method static Builder|Album whereDescription($value)
* @method static Builder|Album whereDownloadable($value)
* @method static Builder|Album whereShareButtonVisible($value)
* @method static Builder|Album whereId($value)
* @method static Builder|Album whereLicense($value)
* @method static Builder|Album whereMaxTakestamp($value)
Expand Down Expand Up @@ -74,6 +76,7 @@ class Album extends Model
'public' => 'int',
'visible_hidden' => 'int',
'downloadable' => 'int',
'share_button_visible' => 'int',
];

/**
Expand Down Expand Up @@ -156,6 +159,20 @@ public function is_downloadable()
}
}

/**
* Return whether or not display share button.
*
* @return bool
*/
public function is_share_button_visible()
{
if ($this->public) {
return $this->share_button_visible == 1;
} else {
return Configs::get_value('share_button_visible', '0') === '1';
}
}

/**
* Returns album-attributes into a front-end friendly format. Note that some attributes remain unchanged.
*
Expand All @@ -178,6 +195,7 @@ public function prepareData()
// Only part of $album when available
$album['description'] = strval($this->description);
$album['downloadable'] = $this->is_downloadable() ? '1' : '0';
$album['share_button_visible'] = $this->is_share_button_visible() ? '1' : '0';

// Parse date
$album['sysdate'] = $this->created_at->format('F Y');
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ public function get(Request $request)
}
$return['public'] = '1';
$return['downloadable'] = Configs::get_value('downloadable', '0');
$return['share_button_visible'] = Configs::get_value('share_button_visible', '0');
$photos_sql = Photo::select_stars(Photo::whereIn('album_id', $this->albumFunctions->getPublicAlbums()));
break;
case 's':
$return['public'] = '0';
$return['downloadable'] = '1';
$return['share_button_visible'] = '0';
$photos_sql = Photo::select_public(Photo::OwnedBy($UserId));
break;
case 'r':
Expand All @@ -119,11 +121,13 @@ public function get(Request $request)
}
$return['public'] = '1';
$return['downloadable'] = Configs::get_value('downloadable', '0');
$return['share_button_visible'] = Configs::get_value('share_button_visible', '0');
$photos_sql = Photo::select_recent(Photo::whereIn('album_id', $this->albumFunctions->getPublicAlbums()));
break;
case '0':
$return['public'] = '0';
$return['downloadable'] = '1';
$return['share_button_visible'] = '0';
$photos_sql = Photo::select_unsorted(Photo::OwnedBy($UserId));
break;
default:
Expand Down Expand Up @@ -333,6 +337,7 @@ public function setPublic(Request $request)
'public' => 'integer|required',
'visible' => 'integer|required',
'downloadable' => 'integer|required',
'share_button_visible' => 'integer|required',
'full_photo' => 'integer|required',
]);

Expand All @@ -349,6 +354,7 @@ public function setPublic(Request $request)
$album->public = ($request['public'] === '1' ? 1 : 0);
$album->visible_hidden = ($request['visible'] === '1' ? 1 : 0);
$album->downloadable = ($request['downloadable'] === '1' ? 1 : 0);
$album->share_button_visible = ($request['share_button_visible'] === '1' ? 1 : 0);

// Set public
if (!$album->save()) {
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ public function get(Request $request)
$photo->downgrade($return);
}
$return['downloadable'] = $album->is_downloadable() ? '1' : '0';
$return['share_button_visible'] = $album->is_share_button_visible() ? '1' : '0';
} else { // Unsorted
if (Configs::get_value('full_photo', '1') != '1') {
$photo->downgrade($return);
}
$return['downloadable'] = Configs::get_value('downloadable', '0');
$return['share_button_visible'] = Configs::get_value('share_button_visible', '0');
}
} else {
$return['downloadable'] = '1';
$return['share_button_visible'] = '1';
}

return $return;
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/ChineseSimplified.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => '只有使用外链才能查看。',
'ALBUM_DOWNLOADABLE' => '下载',
'ALBUM_DOWNLOADABLE_EXPL' => '访客可以下载该相册。',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => '密码',
'ALBUM_PASSWORD_PROT' => '密码保护',
'ALBUM_PASSWORD_PROT_EXPL' => '只有使用正确的密码才可以访问相册。',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Only people with the direct link can view this photo.',
'PHOTO_DOWNLOADABLE' => 'Downloadable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this photo.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Password protected',
'PHOTO_PASSWORD_PROT_EXPL' => 'Photo only accessible with a valid password.',
'PHOTO_EDIT_SHARING_TEXT' => 'The sharing properties of this photo will be changed to the following:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/Czech.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Pouze pro návštěvníky s přímým odkazem alba.',
'ALBUM_DOWNLOADABLE' => 'Stažitelné',
'ALBUM_DOWNLOADABLE_EXPL' => 'Album mouhou stáhnout pouze jeho návštěvníci.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Heslo',
'ALBUM_PASSWORD_PROT' => 'Chráněné heslem',
'ALBUM_PASSWORD_PROT_EXPL' => 'Přístup do alba pouze s platným heslem.',
Expand Down Expand Up @@ -233,6 +235,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Fotografii mohou zobrazit jen návštěvnící z přímého odkazu.',
'PHOTO_DOWNLOADABLE' => 'Stažitelná',
'PHOTO_DOWNLOADABLE_EXPL' => 'Fotografii mohou stáhnout pouze návštěvnící alba.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Zabezpečená heslem',
'PHOTO_PASSWORD_PROT_EXPL' => 'Přístup k fotografii pouze s platným heslem.',
'PHOTO_EDIT_SHARING_TEXT' => 'Vlastnosti sdílení fotografie budou změněny takto:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/Dutch.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Alleen mensen met een link kunnen dit album bekjiken.',
'ALBUM_DOWNLOADABLE' => 'Downloadbaar',
'ALBUM_DOWNLOADABLE_EXPL' => 'Bezoekers van jouw Lychee kunnen dit album downloaden.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Wachtwoord',
'ALBUM_PASSWORD_PROT' => 'Met wachtwoord beschermt',
'ALBUM_PASSWORD_PROT_EXPL' => 'Album alleen beschikbaar met een geldig wachtwoord.',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Only people with the direct link can view this photo.',
'PHOTO_DOWNLOADABLE' => 'Downloadable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this photo.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Password protected',
'PHOTO_PASSWORD_PROT_EXPL' => 'Photo only accessible with a valid password.',
'PHOTO_EDIT_SHARING_TEXT' => 'The sharing properties of this photo will be changed to the following:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/English.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Only people with the direct link can view this album.',
'ALBUM_DOWNLOADABLE' => 'Downloadable',
'ALBUM_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this album.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Password',
'ALBUM_PASSWORD_PROT' => 'Password protected',
'ALBUM_PASSWORD_PROT_EXPL' => 'Album only accessible with a valid password.',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Only people with the direct link can view this photo.',
'PHOTO_DOWNLOADABLE' => 'Downloadable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this photo.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Password protected',
'PHOTO_PASSWORD_PROT_EXPL' => 'Photo only accessible with a valid password.',
'PHOTO_EDIT_SHARING_TEXT' => 'The sharing properties of this photo will be changed to the following:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/French.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Seules les personnes avec le lien peuvent voir cet album.',
'ALBUM_DOWNLOADABLE' => 'Téléchargeable',
'ALBUM_DOWNLOADABLE_EXPL' => 'Les visiteurs peuvent télécharger cet album.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Mot de passe',
'ALBUM_PASSWORD_PROT' => 'Protéger par un mot de passe.',
'ALBUM_PASSWORD_PROT_EXPL' => 'Cet album est accessible avec un mot de passe.',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Only people with the direct link can view this photo.',
'PHOTO_DOWNLOADABLE' => 'Downloadable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this photo.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Password protected',
'PHOTO_PASSWORD_PROT_EXPL' => 'Photo only accessible with a valid password.',
'PHOTO_EDIT_SHARING_TEXT' => 'The sharing properties of this photo will be changed to the following:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/German.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Nur Personen mit dem direkten Link können dieses Album ansehen.',
'ALBUM_DOWNLOADABLE' => 'Zum Herunterladen',
'ALBUM_DOWNLOADABLE_EXPL' => 'Besucher können dieses Album herunterladen.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Kennwort',
'ALBUM_PASSWORD_PROT' => 'Kennwortgeschützt',
'ALBUM_PASSWORD_PROT_EXPL' => 'Album nur einsehbar mit gültigem Kennwort.',
Expand Down Expand Up @@ -233,6 +235,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Nur Besucher mit dem direkten Link können dieses Foto sehen.',
'PHOTO_DOWNLOADABLE' => 'Herunterladbar',
'PHOTO_DOWNLOADABLE_EXPL' => 'Besucher der Gallerie können dieses Foto herunterladen.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Passwortgeschützt',
'PHOTO_PASSWORD_PROT_EXPL' => 'Foto nur mit gültigen Passwort verfügbar.',
'PHOTO_EDIT_SHARING_TEXT' => 'Die Einstellungen zum Teilen des Foto werden wie folgt angepasst:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/Greek.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Μόνο άτομα με τον απευθείας σύνδεσμο μπορούν να δουν αυτό το λεύκωμα.',
'ALBUM_DOWNLOADABLE' => 'Δυνατότητα Λήψης',
'ALBUM_DOWNLOADABLE_EXPL' => 'Οι επισκέπτες της γκαλερί μπορούν να κατεβάσουν αυτό το λεύκωμα.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Κωδικός Πρόσβασης',
'ALBUM_PASSWORD_PROT' => 'Προστατεύεται με κωδικό πρόσβασης',
'ALBUM_PASSWORD_PROT_EXPL' => 'Αυτό το λεύκωμα είναι μόνο προσβάσιμο με έναν έγκυρο κωδικό πρόσβασης.',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Μόνο άτομα με τον απευθείας σύνδεσμο μπορούν να δουν αυτή τη φωτογραφία.',
'PHOTO_DOWNLOADABLE' => 'Δυνατότητα Λήψης',
'PHOTO_DOWNLOADABLE_EXPL' => 'Οι επισκέπτες της γκαλερί μπορούν να κατεβάσουν αυτή τη φωτογραφία.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Προστατεύεται με κωδικό πρόσβασης',
'PHOTO_PASSWORD_PROT_EXPL' => 'Αυτή η φωτογραφία είναι μόνο προσβάσιμη με έναν έγκυρο κωδικό πρόσβασης.',
'PHOTO_EDIT_SHARING_TEXT' => 'Οι ιδιότητες κοινής χρήσης αυτής της φωτογραφίας θα αλλάξουν στις ακόλουθες:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/Italian.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Solo le persone con il link diretto possono vedere questo album.',
'ALBUM_DOWNLOADABLE' => 'Scaricabile',
'ALBUM_DOWNLOADABLE_EXPL' => 'I visitatori del tuo Lychee possono scaricare questo album.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Password',
'ALBUM_PASSWORD_PROT' => 'Password protetta',
'ALBUM_PASSWORD_PROT_EXPL' => 'L\'album è accessibile soltanto con una password valida.',
Expand Down Expand Up @@ -234,6 +236,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Only people with the direct link can view this photo.',
'PHOTO_DOWNLOADABLE' => 'Downloadable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this photo.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Password protected',
'PHOTO_PASSWORD_PROT_EXPL' => 'Photo only accessible with a valid password.',
'PHOTO_EDIT_SHARING_TEXT' => 'The sharing properties of this photo will be changed to the following:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/Spanish.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Solo las personas con el enlace directo pueden ver este álbum.',
'ALBUM_DOWNLOADABLE' => 'Descargable',
'ALBUM_DOWNLOADABLE_EXPL' => 'Los visitantes de su Lychee pueden descargar este álbum.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Contraseña',
'ALBUM_PASSWORD_PROT' => 'Contraseña protegida',
'ALBUM_PASSWORD_PROT_EXPL' => 'Álbum solo accesible con una contraseña válida',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Solo las personas con el enlace directo pueden ver esta foto',
'PHOTO_DOWNLOADABLE' => 'Descargable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Los visitantes de su galería pueden descargar esta foto',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Contraseña protegida',
'PHOTO_PASSWORD_PROT_EXPL' => 'Foto solo accesible con una contraseña válida',
'PHOTO_EDIT_SHARING_TEXT' => 'Las propiedades para compartir de esta foto se cambiarán a lo siguiente:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/Swedish.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Bara personer med korrekt länk kan se detta album.',
'ALBUM_DOWNLOADABLE' => 'Nedladdningsbart',
'ALBUM_DOWNLOADABLE_EXPL' => 'Besökare till din Lychee kan ladda ner detta album.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Lösenord',
'ALBUM_PASSWORD_PROT' => 'Lösenordsskyddad',
'ALBUM_PASSWORD_PROT_EXPL' => 'Albumet kan bara ses med giltigt lösenord.',
Expand Down Expand Up @@ -231,6 +233,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Only people with the direct link can view this photo.',
'PHOTO_DOWNLOADABLE' => 'Downloadable',
'PHOTO_DOWNLOADABLE_EXPL' => 'Visitors of your gallery can download this photo.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Password protected',
'PHOTO_PASSWORD_PROT_EXPL' => 'Photo only accessible with a valid password.',
'PHOTO_EDIT_SHARING_TEXT' => 'The sharing properties of this photo will be changed to the following:',
Expand Down
4 changes: 4 additions & 0 deletions app/Locale/slovak.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static function get_locale()
'ALBUM_HIDDEN_EXPL' => 'Album viditeľný len cez priamy link.',
'ALBUM_DOWNLOADABLE' => 'Stiahnuteľný',
'ALBUM_DOWNLOADABLE_EXPL' => 'Návštevníci môžu album stiahnuť.',
'ALBUM_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'ALBUM_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'ALBUM_PASSWORD' => 'Heslo',
'ALBUM_PASSWORD_PROT' => 'Chránené heslom',
'ALBUM_PASSWORD_PROT_EXPL' => 'Album viditeľný len s platným heslom.',
Expand Down Expand Up @@ -233,6 +235,8 @@ public static function get_locale()
'PHOTO_HIDDEN_EXPL' => 'Obrázok viditeľný len pomocou priameho linku.',
'PHOTO_DOWNLOADABLE' => 'Stiahnuteľný',
'PHOTO_DOWNLOADABLE_EXPL' => 'Návšetvníci vašej galérie môžu tento obrázok stiahnuť.',
'PHOTO_SHARE_BUTTON_VISIBLE' => 'Share button is visible',
'PHOTO_SHARE_BUTTON_VISIBLE_EXPL' => 'Display social media sharing links.',
'PHOTO_PASSWORD_PROT' => 'Chránené heslom',
'PHOTO_PASSWORD_PROT_EXPL' => 'Obrázok dostupný len s platným heslom.',
'PHOTO_EDIT_SHARING_TEXT' => 'Vlastnosti zdieľania tejto fotografie sa zmenia na nasledujúce:',
Expand Down
1 change: 1 addition & 0 deletions app/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Photo extends Model
'public' => 'int',
'star' => 'int',
'downloadable' => 'int',
'share_button_visible' => 'int',
];

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

use App\Album;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddShareButtonVisibleOption extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('albums') && !Schema::hasColumn('albums', 'share_button_visible')) {
Schema::table('albums', function (Blueprint $table) {
$table->boolean('share_button_visible')->after('downloadable')->default(false);
});

Album::where('id', '>', 1)
->where('public', '=', 1)
->update([
'share_button_visible' => true,
]);
}

if (!DB::table('configs')->where('key', 'share_button_visible')->exists()) {
if (!defined('BOOL')) {
define('BOOL', '0|1');
}

DB::table('configs')->insert([
'key' => 'share_button_visible',
'value' => '0',
'cat' => 'config',
'type_range' => BOOL,
'confidentiality' => '0',
]);
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (Schema::hasTable('albums')) {
Schema::table('albums', function (Blueprint $table) {
$table->dropColumn('share_button_visible');
});
}

if (DB::table('configs')->where('key', 'share_button_visible')->exists()) {
DB::table('configs')->where('key', 'share_button_visible')->delete();
}
}
}
Loading