From: Vincent Vanwaelscappel Date: Mon, 27 Feb 2023 14:21:13 +0000 (+0100) Subject: wip #5755 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f49662e8107c4bd9cc151d7cd7f6f7eca3f9a9de;p=fluidbook-toolbox.git wip #5755 @1 --- diff --git a/app/Console/Commands/ToolboxPrecache.php b/app/Console/Commands/ToolboxPrecache.php new file mode 100644 index 000000000..14016e88a --- /dev/null +++ b/app/Console/Commands/ToolboxPrecache.php @@ -0,0 +1,19 @@ +command('fluidbook:farm:ping')->everyMinute(); $schedule->command('cubist:magic:precache')->everyFiveMinutes(); + $schedule->command('toolbox:precache')->everyThirtyMinutes(); } /** diff --git a/app/Fluidbook/Packager/WindowsZIP.php b/app/Fluidbook/Packager/WindowsZIP.php index 726c632ee..8cb62ac8a 100644 --- a/app/Fluidbook/Packager/WindowsZIP.php +++ b/app/Fluidbook/Packager/WindowsZIP.php @@ -143,7 +143,7 @@ class WindowsZIP extends Packager } $cli = new CommandLine('C:/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64/signtool.exe'); - $cli->setManualArg("sign /f C:/Users/vince/Documents/Cubedesigners.cer /csp \"eToken Base Cryptographic Provider\" /k \"[SafeNet Token JC 0{{TYWjZacq%hAH98}}]=54C3F1B91759268A\" /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /a C:/Sign/$rand"); + $cli->setManualArg("sign /f C:/Users/vince/Documents/Cubedesigners.cer /csp \"eToken Base Cryptographic Provider\" /k \"[SafeNet Token JC 0{{TYWjZacq%hAH98}}]=54C3F1B91759268A\" /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /a $remote"); $cli->execute($ssh); if (!stristr($cli->getOutput(), 'Successfully signed')) { $ssh->unlink($remote); diff --git a/app/Jobs/RefreshUsersTree.php b/app/Jobs/RefreshUsersTree.php new file mode 100644 index 000000000..850ccc131 --- /dev/null +++ b/app/Jobs/RefreshUsersTree.php @@ -0,0 +1,13 @@ +users = array(); - $this->admins = array(); - $this->grades = array(); - $this->entreprises = array(); - $this->domains = array(); - - $this->rights = array(); - - $r = $this->con->select('SELECT * FROM e2_u u LEFT JOIN e2_c e ON u.entreprise=e.entreprise_id WHERE e.ws_grade>0 ORDER BY e.ws_grade ASC'); - while ($r->fetch()) { - $this->entreprises[$r->utilisateur_id] = $r->entreprise_id; - $this->users[$r->utilisateur_id] = $r->ws_admin; - $this->grades[$r->utilisateur_id] = $r->ws_grade; - if (!isset($this->admins[$r->ws_admin])) { - $this->admins[$r->ws_admin] = array(); - } - if (!isset($this->admins[$r->utilisateur_id])) { - $this->admins[$r->utilisateur_id] = array(); - } - $this->admins[$r->ws_admin][] = $r->utilisateur_id; - $d = explode('@', $r->email); - $this->domains[$r->utilisateur_id] = mb_strtolower($d[1]); - } - - $daoBook = new wsDAOBook($this->con); - $books = $daoBook->selectAll(); - $owners = []; - foreach ($books as $book) { - if (!isset($owners[$book->proprietaire_id])) { - $owners[$book->proprietaire_id] = 0; - } - $owners[$book->proprietaire_id]++; - } - - $this->facturables = $this->getFacturables(); - // Fabrication de l'arbre - $c = $this->con->openCursor('ws_users_tree'); - $ce = $this->con->openCursor('ws_entreprises_tree'); - - $evu = array(); - - foreach ($this->users as $utilisateur_id => $admin) { - $facturable_id = $administrateur_id = 0; - $this->getFacturableOf($utilisateur_id, $facturable_id, $administrateur_id, 1); - - if (!isset($this->entreprises[$facturable_id]) || is_null($this->entreprises[$facturable_id])) { - //$this->entreprises[$facturable_id]=$this->entreprises[$utilisateur_id]; - } - - $c->utilisateur_id = $utilisateur_id; - $ce->entreprise_id = $c->entreprise_id = $this->entreprises[$utilisateur_id]; - $c->facturable_id = $facturable_id; - $ce->facturable_entreprise_id = $c->facturable_entreprise_id = $this->entreprises[$facturable_id]; - $ce->administrateur_id = $c->administrateur_id = $administrateur_id; - try { - $c->insert(); - } catch (Exception $e) { - fb($e); - } - if (isset($evu[$c->entreprise_id])) { - continue; - } - try { - $ce->insert(); - } catch (Exception $e) { - fb($e); - } - $evu[$c->entreprise_id] = true; - } - // Fabrication de la liste des droits à partir de l'arbre - $j = 0; - for ($i = 1; $i <= 5; $i++) { - foreach ($this->admins as $admin_id => $list) { - $newlist = $list; - foreach ($list as $uid) { - if ($uid != $admin_id && isset($this->admins[$uid])) { - $newlist = array_merge($this->admins[$uid], $newlist); - } - } - $this->admins[$admin_id] = array_unique($newlist); - } - } - // Ajout des droits personnels - foreach ($this->users as $uid => $admin) { - $this->admins[$uid][] = $uid; - } - // Echange des droits entre collègues - foreach ($this->admins as $admin_id => $list) { - if (!isset($this->entreprises[$admin_id])) { - continue; - } - $e = $this->entreprises[$admin_id]; - $collegues = array_keys($this->entreprises, $e); - $newlist = $this->admins[$admin_id]; - foreach ($collegues as $c) { - $newlist = array_merge($newlist, $this->admins[$c]); - } - $newlist = array_unique($newlist); - $this->admins[$admin_id] = $newlist; - foreach ($collegues as $c) { - $this->admins[$c] = $newlist; - } - } - - $adom = array(); - - foreach ($this->admins as $admin => $list) { - $this->admins[$admin] = array_unique($list); - sort($this->admins[$admin]); - - $adom[$admin] = array(); - foreach ($list as $id) { - $adom[$admin][] = $this->domains[$id]; - } - $adom[$admin] = array_unique($adom[$admin]); - } - - $c = $this->con->openCursor('extranet_users.user'); - foreach ($this->admins as $admin => $list) { - $wscount = 0; - foreach ($list as $item) { - $wscount += $owners[$item]; - } - $c->e1_ws_count = $wscount; - $c->e1_ws_rights = implode(',', $list); - $c->e1_ws_domains = implode(',', $adom[$admin]); - $c->update('WHERE id=\'' . $this->con->escape($admin) . '\''); - } - } - - protected function getFacturableOf($utilisateur_id, &$facturable_id, &$administrateur_id, $level) - { - if (in_array($utilisateur_id, $this->facturables)) { - $facturable_id = $utilisateur_id; - $administrateur_id = $this->users[$utilisateur_id]; - return; - } - if ($level > 10) { - $facturable_id = -1; - $administrateur_id = -1; - return; - } - if (!$utilisateur_id || !isset($this->users[$utilisateur_id])) { - return; - } - - return $this->getFacturableOf($this->users[$utilisateur_id], $facturable_id, $administrateur_id, $level + 1); - } - - protected function getFacturables() - { - $res = array(); - foreach ($this->users as $utilisateur_id => $admin) { - if ($this->grades[$admin] == 5) { - $res[] = $utilisateur_id; - } - } - sort($res); - return $res; - } - -} diff --git a/app/Models/Base/ToolboxModel.php b/app/Models/Base/ToolboxModel.php index 95d81fb84..ac5db553b 100644 --- a/app/Models/Base/ToolboxModel.php +++ b/app/Models/Base/ToolboxModel.php @@ -70,7 +70,7 @@ class ToolboxModel extends CubistMagicAbstractModel 'column_escape' => false, 'attribute' => 'companyWithName', 'default' => Auth::id(), - 'non_default_tracking' => false, + 'non_default_tracking' => true, ]; $this->addField(array_merge($fieldSettings, $options)); diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index f8f5ff62d..d325cfce0 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -67,7 +67,57 @@ class FluidbookPublication extends ToolboxSettingsModel parent::setFields(); - $this->addOwnerField(); + $this->addField('hash', Hidden::class); + $this->addField('cid', Hidden::class); + + $this->addField('extranet_task', Hidden::class, __('Tâche de l\'extranet')); + $this->addField('export_data', Hidden::class, __('Paramètres d\'export')); + // Composed fields + $composed = [ + 'c_title' => [ + 'label' => __('Titre'), + 'type' => Hidden::class, + 'read_only' => true, + 'column' => true, + 'column_move_after' => 'id', + ], + 'c_pages' => [ + 'label' => __('Pages'), + 'column_label' => '', + 'read_only' => true, + 'column' => true, + 'column_move_after' => 'c_title', + ], + 'admin' => [ + 'label' => __('Administrateur'), + 'read_only' => true, + 'type' => User::class, + 'hidden' => true, + 'column' => true, + 'can' => 'fluidbook-publication:admin', + 'column_attribute' => 'companyWithNameOnTwoLines', + 'column_move_after' => 'owner', + 'attribute' => 'companyWithName', + ], + 'super_admin' => __('Super administrateur'), + 'owner_company_name' => __('Propriétaire'), + 'owner_name' => __('Propriétaire'), + 'invoicable' => __('Utilisateur facturable'), + 'invoicable_company' => __('Facturation'), + 'extranet_project' => __('Project extranet'), + ]; + + foreach ($composed as $name => $label) { + $defaultAttributes = ['name' => $name, 'type' => Hidden::class, 'read_only' => true]; + if (is_string($label)) { + $attributes = array_merge($defaultAttributes, ['label' => $label]); + } else if (is_array($label)) { + $attributes = array_merge($defaultAttributes, $label); + } + $this->addField($attributes); + } + + $this->addOwnerField(['column_attribute' => 'allTreeInfos']); $this->addField('region', SelectFromArray::class, __('Région d\'hébergement des données'), ['options' => ['UE' => __('Union européenne'), 'US' => 'USA'], 'default' => 'UE', 'allows_null' => false, 'databaseDefault' => 'UE']); @@ -105,7 +155,7 @@ class FluidbookPublication extends ToolboxSettingsModel $this->addField('section_infos', FormBigSection::class, __('Administration')); - $this->addField('visits_counter', Integer::class, 'Compteur de visites', ['read_only' => true, 'default' => 0, 'column' => true, 'column_label' => '', 'searchLogic' => false]); + $this->addField('visits_counter', Integer::class, 'Compteur de visites', ['read_only' => true, 'default' => 0, 'column' => true, 'column_label' => '', 'searchLogic' => false]); $this->addField(self::CREATED_AT, Datetime::class, __('Crée'), ['column' => true, 'column_type' => 'datetime', 'column_format' => 'YYYY-MM-DD', 'filter' => true, 'read_only' => true, 'searchLogic' => false]); $this->addField(self::UPDATED_AT, Datetime::class, __('Mis à jour'), ['column' => true, 'column_format' => 'YYYY-MM-DD', 'filter' => true, 'read_only' => true, 'searchLogic' => false]); @@ -113,45 +163,7 @@ class FluidbookPublication extends ToolboxSettingsModel $this->addField('composition_updated_at', Datetime::class, __('Dernière modification de la composition'), ['read_only' => true]); $this->addField('status_date', Datetime::class, __('Date de changement de status'), ['read_only' => true]); - $this->addField('hash', Hidden::class); - $this->addField('cid', Hidden::class); - $this->addField('extranet_task', Hidden::class, __('Tâche de l\'extranet')); - $this->addField('export_data', Hidden::class, __('Paramètres d\'export')); - // Composed fields - $composed = ['admin' => [ - 'label' => __('Administrateur'), - 'read_only' => true, - 'type' => User::class, - 'column' => true, - 'can' => 'fluidbook-publication:admin', - 'column_attribute' => 'companyWithNameOnTwoLines', - 'column_move_after' => 'owner', - 'attribute' => 'companyWithName', - ], - 'super_admin' => __('Super administrateur'), - 'owner_company_name' => __('Propriétaire'), - 'owner_name' => __('Propriétaire'), - 'invoicable' => __('Utilisateur facturable'), - 'invoicable_company' => __('Facturation'), - 'extranet_project' => __('Project extranet'), - 'c_title' => [ - 'label' => __('Titre'), - 'read_only' => true, - 'column' => true, - 'column_move_after' => 'id', - ] - ]; - - foreach ($composed as $name => $label) { - $defaultAttributes = ['name' => $name, 'type' => Hidden::class]; - if (is_string($label)) { - $attributes = array_merge($defaultAttributes, ['label' => $label]); - } else if (is_array($label)) { - $attributes = array_merge($defaultAttributes, $label); - } - $this->addField($attributes); - } } public function onSaving(): bool @@ -205,6 +217,7 @@ class FluidbookPublication extends ToolboxSettingsModel $this->invoicable_company = ''; $this->extranet_project = ''; $this->c_title = $this->title; + $this->c_pages = count($this->composition); } public function __($str) diff --git a/scripts/update b/scripts/update index bc1164e91..cebdac1c4 100644 --- a/scripts/update +++ b/scripts/update @@ -19,6 +19,7 @@ sudo chown -R 1001:33 /application/storage/framework sudo chown -R 1001:33 /application/storage/framework php artisan optimize:clear php artisan cubist:magic:precache +php artisan toolbox:precache sudo chown -R 1001:33 /application/storage/framework sudo chown -R 1001:33 /application/vendor sudo chown -R 0:0 /etc/sudoers.d/toolbox