From: vincent@cubedesigners.com Date: Tue, 25 Aug 2020 17:31:41 +0000 (+0000) Subject: wip #3853 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=021ee18fe5e7fde744b490f12e1117e791199509;p=cubeextranet.git wip #3853 @0.5 --- diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index d5c353c0b..2ece9e6ea 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -207,7 +207,7 @@ class wsAjax extends cubeAjax $dao = new wsDAOBook($core->con); if ($_POST['book'] != '') { $book = $dao->duplicate($_POST['book'], $core->user->utilisateur_id, $_POST['title'], isset($_POST['pages'])); - wsMaintenance::copyLinks([$_POST['book'],$book->book_id]); + wsMaintenance::copyLinks([$_POST['book'], $book->book_id]); } else { $book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang, $_POST['title']); } @@ -492,6 +492,8 @@ class wsAjax extends cubeAjax public static function demandeDevis($args, &$x) { + CubeIT_Util_PHP::neverStop(); + global $core; $defaults = array('adresse' => '', diff --git a/inc/ws/Controlleur/class.ws.users.tree.php b/inc/ws/Controlleur/class.ws.users.tree.php index 69a0054c8..e3f8066e4 100644 --- a/inc/ws/Controlleur/class.ws.users.tree.php +++ b/inc/ws/Controlleur/class.ws.users.tree.php @@ -1,162 +1,172 @@ con = $con; - } - - public function refreshWSUsersTree() { - $this->con->execute('TRUNCATE TABLE ws_users_tree'); - $this->con->execute('TRUNCATE TABLE ws_entreprises_tree'); - - $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]); - } - - $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) { - $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) { - $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; - } - - 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; - } +class wsUsersTree +{ + + protected $users; + protected $admins; + protected $grades; + protected $facturables; + protected $rights; + protected $entreprises; + protected $entreprises_tree; + protected $con; + + public function __construct(&$con) + { + $this->con = $con; + } + + public function refreshWSUsersTree() + { + $this->con->execute('TRUNCATE TABLE ws_users_tree'); + $this->con->execute('TRUNCATE TABLE ws_entreprises_tree'); + + $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]); + } + + $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) { + $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/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index b21b1e0e9..ef238a552 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -2123,7 +2123,7 @@ class zoomLink extends normalLink $both = $leftfile; } - if ($attributes['border'] > 0) { + if (isset($attributes['border']) && $attributes['border'] > 0) { $tmp = CubeIT_Files::tempnam() . '.jpg'; CubeIT_CommandLine_Imagemagick::addBorder($both, $tmp, $attributes['border'], $attributes['borderColor']); $compiler->vdir->addTemp($both);