--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Fluidbook\Farm;
+use Cubedesigners\UserDatabase\Permissions;
+use Cubist\Backpack\Console\Commands\CubistCommand;
+
+class ToolboxPrecache extends CubistCommand
+{
+ protected $signature = 'toolbox:precache';
+ protected $description = 'Precache Toolbox';
+
+ public function handle()
+ {
+ // Users tree
+ Permissions::_getData(true);
+ }
+}
$schedule->command('fluidbook:farm:ping')->everyMinute();
$schedule->command('cubist:magic:precache')->everyFiveMinutes();
+ $schedule->command('toolbox:precache')->everyThirtyMinutes();
}
/**
}
$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);
--- /dev/null
+<?php
+
+namespace App\Jobs;
+
+use Cubedesigners\UserDatabase\Permissions;
+
+class RefreshUsersTree extends Base
+{
+ public function handle()
+ {
+ Permissions::_getData(true);
+ }
+}
+++ /dev/null
-<?php
-
-namespace App\Jobs;
-
-class UsersTree extends Base
-{
- protected $jobName = 'userstree';
-
- protected $users=[];
- protected $admins=[];
- protected $grades=[];
- protected $facturables=[];
- protected $rights=[];
- protected $entreprises=[];
-
- public function handle()
- {
-
-
- $this->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;
- }
-
-}
'column_escape' => false,
'attribute' => 'companyWithName',
'default' => Auth::id(),
- 'non_default_tracking' => false,
+ 'non_default_tracking' => true,
];
$this->addField(array_merge($fieldSettings, $options));
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' => '<i class="las la-file-alt" title="' . __('') . '"></i>',
+ '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']);
$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' => '<i class="las la-chart-area" title="Compteur de visites du lien de préview"></i>', 'searchLogic' => false]);
+ $this->addField('visits_counter', Integer::class, 'Compteur de visites', ['read_only' => true, 'default' => 0, 'column' => true, 'column_label' => '<i class="las la-chart-area" title="' . __('Compteur de visites du lien de préview') . '"></i>', '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]);
$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
$this->invoicable_company = '';
$this->extranet_project = '';
$this->c_title = $this->title;
+ $this->c_pages = count($this->composition);
}
public function __($str)
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