From: vincent@cubedesigners.com Date: Tue, 18 Jan 2011 15:05:42 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e1a7cf157a469051f47bdb37a50ff94cad8f0acc;p=cubeextranet.git --- diff --git a/importWs.php b/importWs.php index b661fb96d..470965ba7 100644 --- a/importWs.php +++ b/importWs.php @@ -153,6 +153,34 @@ try { $utilisateur_id++; } } + + $lastuid = 1; + + for($i = 4;$i >= 1;$i--) { + $c = $core->con->openCursor('entreprises'); + $c->nom = 'Entreprise Test - Grade ' . $i; + $c->ws_grade = $i; + $c->ws_admin = $lastuid; + $c->entreprise_id = $entreprise_id; + $c->pays = 'FR'; + $c->insert(); + + $c = $core->con->openCursor('utilisateurs'); + $c->prenom = 'Utilisateur Test'; + $c->nom = 'Grade ' . $i; + $c->email = 'grade' . $i . "@fluidbook.com"; + $c->password = 'atacama'; + $c->utilisateur_id = $utilisateur_id; + $c->entreprise = $entreprise_id; + + $c->lang = 'fr'; + $c->insert(); + + $lastuid = $utilisateur_id; + + $entreprise_id++; + $utilisateur_id++; + } // Mets à jour les utilisateurs reliés à l'extranet $r = $core->con->select('SELECT * FROM ws.user WHERE extranet!=0'); while ($r->fetch()) { @@ -188,7 +216,6 @@ try { } // Set cubedesigners AS admin $core->con->execute('UPDATE entreprises SET ws_grade=5, ws_admin=1 WHERE entreprise_id=7'); - // Some entreprises are themeselves revendeurs. It's not normal $core->con->execute('UPDATE entreprises e SET ws_admin=1 WHERE ws_admin IN (SELECT utilisateur_id FROM utilisateurs u WHERE e.entreprise_id=u.entreprise)'); } else { @@ -340,12 +367,18 @@ try { $parametres = new wsBookParametres(new stdClass()); $r->signature = $signatures[$r->tid]; $parametres->fromRecord($r); - $parametres->fromXML(simplexml_load_string('' . $r->extras . '')); + + $xml = @simplexml_load_string('' . $r->extras . ''); + if ($xml !== false) { + $parametres->fromXML($xml); + } else { + fb('error on extras (Fluidbook # ' . $r->bid); + } $c->parametres = serialize($parametres); $c->insert(); } // Importe les pages des fluidbooks - $r = $core->con->select('SELECT * FROM ws.book_pages ORDER BY bid,bpid'); + $r = $core->con->select('SELECT bid,did FROM ws.book_pages GROUP BY did'); while ($r->fetch()) { if (!isset($docs[$r->did])) { $c = $core->con->openCursor('documents'); @@ -354,14 +387,9 @@ try { $c->insert(); $docs[$r->did] = true; } - - $c = $core->con->openCursor('book_pages'); - $c->book_id = $r->bid; - $c->document_id = $r->did; - $c->book_page = $r->bpid; - $c->document_page = $r->dpid; - $c->insert(); } + + $core->con->execute('INSERT INTO book_pages (book_id,book_page,document_id,document_page) SELECT bid,bpid,did,dpid FROM ws.book_pages'); } foreach($tables as $t) { diff --git a/inc/commons/class.common.droits.php b/inc/commons/class.common.droits.php index c1d440535..4c5b38459 100644 --- a/inc/commons/class.common.droits.php +++ b/inc/commons/class.common.droits.php @@ -21,6 +21,16 @@ class commonDroits { } } + public static function dashboard($error = true) + { + if (MODE == 'extranet') { + $grade = 1; + } elseif (MODE == 'ws') { + $grade = 5; + } + return commonDroits::min($grade, $error); + } + public static function recherche($page) { global $core; diff --git a/inc/commons/class.common.page.php b/inc/commons/class.common.page.php index 756998b7a..80d3401b4 100644 --- a/inc/commons/class.common.page.php +++ b/inc/commons/class.common.page.php @@ -78,7 +78,7 @@ class commonPage { foreach($onglets as $titre => $url) { // Si cet onglet correspond à la page active, on le place actif $active = ($args[0] == $url)?' class="active"':''; - $res.=''.cubeMedia::cssRollover($core->typo->Onglet($titre,'',false)).''; + $res .= '' . cubeMedia::cssRollover($core->typo->Onglet($titre, '', false)) . ''; } $res .= ''; return $res; @@ -107,7 +107,11 @@ class commonPage { } } if ($hasRealFilters) { - $res .= '
' . __('Effacer les filtres') . '
' . __('Ajouter à mon tableau de bord') . '
'; + $res .= '
' . __('Effacer les filtres') . ''; + if (commonDroits::dashboard(false)) { + $res .= '
' . __('Ajouter à mon tableau de bord') . ''; + } + $res .= '
'; } $res .= ''; } @@ -147,16 +151,16 @@ class commonPage { return $res; } - public static function bf($max=false) + public static function bf($max = false) { $res = ''; $res .= ''; $res .= ''; $res .= ''; - if($max){ - $res.=cubeMedia::spacer(960,1); + if ($max) { + $res .= cubeMedia::spacer(960, 1); } - $res.=''; + $res .= ''; $res .= ''; $res .= ''; return $res; diff --git a/inc/commons/class.common.url.php b/inc/commons/class.common.url.php index 625df3bcd..32377e3c5 100644 --- a/inc/commons/class.common.url.php +++ b/inc/commons/class.common.url.php @@ -111,7 +111,7 @@ class commonUrl { $res .= '' . __('Numéro de mobile') . ' : ' . $utilisateur->mobile . ''; $res .= '' . __('Numéro de fax') . ' : ' . $utilisateur->fax . ''; $res .= '' . __('Numéro de TVA intracommunautaire') . ' : ' . $utilisateur->tva_intra . ''; - $res .= '' . __('Si les informations ci-dessus sont incomplètes ou erronées, veuillez nous
en informer en nous écrivant à ') . 'contact@cubedesigners.com
'; + $res .= '' . __('Si les informations ci-dessus sont incomplètes ou erronées, veuillez nous
en informer en nous écrivant à ') . ''.FROM_EMAIL.'
'; } return $res; @@ -208,6 +208,8 @@ class commonUrl { public static function dashboard($args) { + commonDroits::dashboard(); + cubePage::ui('Sortable'); $res = commonPage::barre(); $res .= commonPage::tMain('dash'); @@ -218,6 +220,7 @@ class commonUrl { public static function listeDashboard($args) { + commonDroits::dashboard(); global $core; $r = $core->con->select('SELECT * FROM dashboard WHERE equipier=\'' . $core->user->utilisateur_id . '\' AND site=\'' . MODE . '\' ORDER BY sort'); $res = ''; @@ -231,6 +234,7 @@ class commonUrl { public static function displayDashboard($r) { + commonDroits::dashboard(); global $core; $res = '
' . $core->typo->OngletBlanc($r->nom); @@ -263,6 +267,7 @@ class commonUrl { public static function getDashboardSettings($s) { + commonDroits::dashboard(); $s = unserialize($s); if (isset($s['filtres']['annee'])) { $s['filtres']['annee'] = range(2006, date('Y'), 1); @@ -272,6 +277,7 @@ class commonUrl { public static function formDashboard($args) { + commonDroits::dashboard(); global $core; $rub = $args[1]; $dashboard_id = isset($args[2])?$args[2]:'new'; diff --git a/inc/prepend.php b/inc/prepend.php index b5dd8f0e4..e5b976500 100644 --- a/inc/prepend.php +++ b/inc/prepend.php @@ -10,7 +10,7 @@ if ($ws) { define('GA', 'UA-4339912-5'); define('TITLE', 'Fuidbook Workshop'); - define('FROM_EMAIL', 'workshop@fluidbook.com'); + define('FROM_EMAIL', 'contact@fluidbook.com'); define('FROM_NAME', 'Fluidbook Workshop'); define('EMAIL_SUBJECT', 'Fluidbook Workshop'); define('TEAM_EMAIL', 'team@fluidbook.com'); @@ -21,7 +21,7 @@ if ($ws) { define('GA', 'UA-4339912-4'); define('TITLE', 'Extranet Cubedesigners'); - define('FROM_EMAIL', 'extranet@cubedesigners.com'); + define('FROM_EMAIL', 'contact@cubedesigners.com'); define('FROM_NAME', 'Extranet Cubedesigners'); define('EMAIL_SUBJECT', 'Extranet Cubedesigners'); define('TEAM_EMAIL', 'team@cubedesigners.com'); diff --git a/inc/ws/Controlleur/class.ws.droits.php b/inc/ws/Controlleur/class.ws.droits.php index 79246d1ef..e0e9c2075 100644 --- a/inc/ws/Controlleur/class.ws.droits.php +++ b/inc/ws/Controlleur/class.ws.droits.php @@ -1,5 +1,9 @@ creation = self::creation(false); + $res->revendeur = self::revendeur(false); + $res->admin = self::admin(false); + return $res; + } + + public static function creation($error = false) + { + return self::gradeIn(self::$creation, $error); + } + + public static function revendeur($error = false) + { + return commonDroits::min(self::$revendeur, $error); + } + + public static function admin($error = false) + { + return commonDroits::min(self::$admin, $error); + } + + protected static function gradeIn($list, $error = false) + { + global $core; + if (!in_array($core->user->grade, $list)) { + if ($error) { + commonDroits::error(); + } + return false; + } + return true; + } + public static function getSignatures() { global $core; diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index ea149617c..0fe3fb0c1 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -7,7 +7,9 @@ class wsUrl { $settings = $core->user->getSettings('books'); $shortcuts = array(); - $shortcuts[] = '' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . ''; + if (wsDroits::creation()) { + $shortcuts[] = '' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . ''; + } $filtres = array(); $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']); @@ -29,6 +31,8 @@ class wsUrl { cubePage::truePopup(); cubePage::autocomplete(); + $creation = wsDroits::creation(); + commonDroits::min(1); $settings = is_null($settings)?$core->user->getSettings('books'):$settings; $change = is_null($dashboard)?'Books':'Dashboard/' . $dashboard; @@ -51,10 +55,14 @@ class wsUrl { $i = 0; $btVoir = cubeMedia::cssRollover($core->typo->Voir('voir', '', false)); - $btEdit = cubeMedia::cssRollover($core->typo->Editer('éditer', '', false)); + if ($creation) { + $btEdit = cubeMedia::cssRollover($core->typo->Editer('éditer', '', false)); + } $btStats = cubeMedia::cssRollover($core->typo->Stats('stats', '', false)); $btDownload = cubeMedia::cssRollover($core->typo->Telecharger('télécharger', '', false)); - $btDel = cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)); + if ($creation) { + $btDel = cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)); + } foreach($liste as $id => $book) { $odd = cubeMath::isOdd($i)?' class="odd"':''; @@ -68,10 +76,14 @@ class wsUrl { $res .= '' ./* $f .*/ ''; $res .= '' . $core->books_status[$book->status] . ''; $res .= '' . $btVoir . ''; - $res .= '' . $btEdit . ''; + if ($creation) { + $res .= '' . $btEdit . ''; + } $res .= '' . $btStats . ''; $res .= '' . $btDownload . ''; - $res .= '' . $btDel . ''; + if ($creation) { + $res .= '' . $btDel . ''; + } $res .= ''; $i++; }