use App\Jobs\DownloadBase;
use App\Services\ScormCloud;
+use Cubist\Util\CommandLine\Rsync;
use Cubist\Util\Files\Files;
+use Cubist\Util\Text;
use Illuminate\Support\Facades\Log;
class Download extends DownloadBase
protected $version = 'online';
protected $type = 'Fluidbook';
- // __('Fluidbppl ":title" (#:nb) prêt au téléchargement')
+ // __('Fluidbook ":title" (#:nb) prêt au téléchargement')
protected $_subject = 'Fluidbook ":title" (#:nb) prêt au téléchargement';
+ // __('Fluidbook ":title" (#:nb) installé sur hosting')
+ protected $_installHostingSubject = 'Fluidbook ":title" (#:nb) installé sur hosting';
public function __construct($entry, $version, $action, $user)
{
$text = __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
}
} else if ($this->action === 'install_hosting') {
+ $dest = self::_cleanInstallDir($this->entry->install_online_hosting);
+ if (!$dest) {
+ throw new \Exception('No path defined for hosting installation');
+ }
+ $subject = __($this->_installHostingSubject, ['title' => $this->_title(), 'nb' => $this->_id()]);
$path = $this->_compileandpackage(false);
- dd($path);
+
+ $rsync = new Rsync($path, '/mnt/sshfs/fluidbook/data/fluidbook/hosting/' . $dest . '/');
+ $rsync->setMirror(false);
+ //$rsync->setDryRun(true);
+ $rsync->execute();
+ //$rsync->dd();
+
+ $actions = ['Voir sur hosting' => 'https://hosting.fluidbook.com/' . $dest . '/'];
+
} else if ($this->action === 'install_ftp') {
}
$this->sendNotification($subject, $text, $actions);
}
+ protected static function _cleanInstallDir($path)
+ {
+ $path = str_replace('/\.{2,}/', '', $path);
+ $path = preg_replace('/\/{2,}/', '/', $path);
+ $path = trim($path, '/');
+ $path = Text::str2URL($path, '-', true);
+ return $path;
+ }
+
protected function _compileandpackage($zip = true)
{
$packager = Packager::package($this->entry->id, $this->version, $zip);