From a91b606a65edae77fee0621ec5ac26a6ab4d00e4 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 10 Aug 2011 10:27:07 +0000 Subject: [PATCH] --- inc/commons/class.common.url.php | 125 +++++++++++++------------------ 1 file changed, 54 insertions(+), 71 deletions(-) diff --git a/inc/commons/class.common.url.php b/inc/commons/class.common.url.php index d6fc05d08..d673ca050 100644 --- a/inc/commons/class.common.url.php +++ b/inc/commons/class.common.url.php @@ -1,7 +1,8 @@ $url) { + foreach ($nav as $titre => $url) { $args = array($url); break; } @@ -32,7 +33,7 @@ class commonUrl { echo commonPage::header($args); - foreach($classes as $class) { + foreach ($classes as $class) { $cb = array($class, $f); if (is_callable($cb)) { echo call_user_func($cb, $args); @@ -42,8 +43,7 @@ class commonUrl { echo commonPage::footer(); } - public static function login($args) - { + public static function login($args) { global $core; $tentative = isset($_SESSION['errorLogin']) && $_SESSION['errorLogin']; @@ -51,7 +51,7 @@ class commonUrl { $_SESSION['errorLogin'] = false; } - $message = $tentative?'


' . __('Identifiants incorrects') . '

':''; + $message = $tentative ? '


' . __('Identifiants incorrects') . '

' : ''; $res = commonPage::barre(); $res .= commonPage::tMain(); @@ -73,8 +73,7 @@ class commonUrl { return $res; } - public static function logout($args) - { + public static function logout($args) { if (isset($_SESSION['user_email'])) { unset($_SESSION['user_email']); } @@ -84,13 +83,11 @@ class commonUrl { http::redirect(SITE_PATH); } - public static function motdepasseOublie($args) - { + public static function motdepasseOublie($args) { return '' . __('Entrez votre e-mail') . ' : ' . form::field('email', 30, 128) . ''; } - public static function mesParametres($args) - { + public static function mesParametres($args) { global $core; $utilisateur = $core->user; @@ -117,8 +114,7 @@ class commonUrl { return $res; } - public static function changeMotdepasse() - { + public static function changeMotdepasse() { $res = '' . __('Votre mot de passe doit comprendre en 6 et 10 caractères') . ''; $res .= '' . __('Tapez votre mot de passe actuel') . ' : ' . form::password('actuel', 20, 10) . ''; $res .= '' . __('Tapez votre nouveau mot de passe') . ' : ' . form::password('nouveau', 20, 10) . ''; @@ -126,27 +122,25 @@ class commonUrl { return $res; } - public static function orderby($label, $field, $settings, $function) - { + public static function orderby($label, $field, $settings, $function) { $res = ''; $res .= $label; if ($settings['orderby'] == $field) { - $puce = ($settings['sens'] == 'DESC')?'down':'up'; + $puce = ($settings['sens'] == 'DESC') ? 'down' : 'up'; $res .= ' ' . cubeMedia::image(IMG . '/' . $puce . '.png'); } $res .= ''; return $res; } - public static function formParPage($action, $value, $nom = 'éléments', $all = true) - { + public static function formParPage($action, $value, $nom = 'éléments', $all = true) { $values = array(2, 5, 10, 15, 25, 50, 100); if ($all) { $datas = array(__('Tous les ') . $nom => 0); } else { $datas = array(); } - foreach($values as $v) { + foreach ($values as $v) { $datas[$v . ' ' . $nom] = $v; } @@ -157,8 +151,7 @@ class commonUrl { return $res; } - public static function autocomplete($args) - { + public static function autocomplete($args) { global $core; if (isset($_GET['q'])) { @@ -170,35 +163,35 @@ class commonUrl { $dao = new commonDAOClient($core->con); $dao->setSearch($q, true); $clients = $dao->getListe(); - foreach($clients as $client) { + foreach ($clients as $client) { $suggestions[] = $client->utilisateur_id . ' - ' . $client->rs . ' (' . $client->prenom . ' ' . $client->nom . ')'; } } elseif ($args[1] == 'projet') { $dao = new extranetDAOProjet($core->con); $dao->setSearch($q, true); $projets = $dao->getListe(); - foreach($projets as $projet) { + foreach ($projets as $projet) { $suggestions[] = $projet->projet_id . ' - ' . $projet->nom . ' (' . $projet->client . ')'; } } elseif ($args[1] == 'book') { $dao = new wsDAOBook($core->con); $dao->setSearch($q, true); $books = $dao->getListe('date', 'DESC', 15, $core->user); - foreach($books as $book) { + foreach ($books as $book) { $suggestions[] = $book->book_id . ' - ' . $book->nom; } } elseif ($args[1] == 'wsuser') { $dao = new commonDAOUtilisateur($core->con); $dao->setSearch($q, true); $clients = $dao->getListe('utilisateur_id', 'ASC', null, ' AND ws_grade>0', $core->user); - foreach($clients as $client) { + foreach ($clients as $client) { $suggestions[] = $client->utilisateur_id . ' - ' . $client->rs . ' (' . $client->prenom . ' ' . $client->nom . ')'; } } elseif ($args[1] == 'wsadmin') { $dao = new commonDAOUtilisateur($core->con); $dao->setSearch($q, true); $clients = $dao->getListe('utilisateur_id', 'ASC', null, 'AND ws_grade>2', $core->user); - foreach($clients as $client) { + foreach ($clients as $client) { $suggestions[] = $client->utilisateur_id . ' - ' . $client->rs . ' (' . $client->prenom . ' ' . $client->nom . ')'; } } @@ -206,8 +199,7 @@ class commonUrl { exit; } - public static function dashboard($args) - { + public static function dashboard($args) { commonDroits::dashboard(); cubePage::ui('Sortable'); @@ -218,8 +210,7 @@ class commonUrl { return $res; } - public static function listeDashboard($args) - { + 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'); @@ -232,14 +223,13 @@ class commonUrl { return $res; } - public static function displayDashboard($r) - { + public static function displayDashboard($r) { commonDroits::dashboard(); global $core; $res = '
' . $core->typo->OngletBlanc($r->nom); - $close = ($r->state == '0')?' close':''; - $hide = ($r->state == '0')?' class="close"':''; + $close = ($r->state == '0') ? ' close' : ''; + $hide = ($r->state == '0') ? ' class="close"' : ''; $res .= '' . cubeMedia::spacer(18, 10) . ''; $res .= '' . cubeMedia::image(IMG . '/edit.png') . ''; @@ -260,6 +250,8 @@ class commonUrl { $res .= extranetUrl::listeTimereport($r->dashboard_id, self::getDashboardSettings($r->settings)); } elseif ($r->rubrique == 'demandes') { $res .= wsUrl::listeDemandes($r->dashboard_id, self::getDashboardSettings($r->settings)); + } elseif ($r->rubrique == 'books') { + $res .= wsUrl::listeBooks($r->dashboard_id, self::getDashboardSettings($r->settings)); } $res .= '
'; $res .= commonPage::bf(); @@ -267,8 +259,7 @@ class commonUrl { return $res; } - public static function getDashboardSettings($s) - { + public static function getDashboardSettings($s) { commonDroits::dashboard(); $s = unserialize($s); if (isset($s['filtres']['annee'])) { @@ -277,12 +268,11 @@ class commonUrl { return $s; } - public static function formDashboard($args) - { + public static function formDashboard($args) { commonDroits::dashboard(); global $core; $rub = $args[1]; - $dashboard_id = isset($args[2])?$args[2]:'new'; + $dashboard_id = isset($args[2]) ? $args[2] : 'new'; if ($dashboard_id == 'new') { $res = 'Titre de la liste' . form::field('nom', 20, 128, false) . form::hidden('rubrique', $rub) . form::hidden('dashboard_id', $dashboard_id) . ''; @@ -294,8 +284,7 @@ class commonUrl { return $res; } - public static function fichiers($args) - { + public static function fichiers($args) { global $core; commonDroits::min(array('extranet' => 0, 'ws' => 1)); @@ -332,8 +321,7 @@ class commonUrl { return $res; } - public static function formFichier($for = 'client') - { + public static function formFichier($for = 'client') { global $core; if ($for == 'client') { @@ -372,8 +360,7 @@ class commonUrl { return $res; } - public static function listeFichiers($settings = null) - { + public static function listeFichiers($settings = null) { commonDroits::min(array('extranet' => 0, 'ws' => 1)); global $core; @@ -383,7 +370,7 @@ class commonUrl { $entreprise = $_SESSION['entreprise_fichiers']; } - $settings = is_null($settings)?$core->user->getSettings('fichiers'):$settings; + $settings = is_null($settings) ? $core->user->getSettings('fichiers') : $settings; $dao = new commonDAOFichier($core->con); $change = 'Fichiers'; $dao->entreprise_id = $entreprise; @@ -401,8 +388,8 @@ class commonUrl { $res .= '' . commonUrl::orderby(__('Destiné à'), 'destinataire', $settings, 'sort' . $change) . ''; $res .= ''; $i = 0; - foreach($liste as $fichier) { - $odd = cubeMath::isOdd($i)?' class="odd"':''; + foreach ($liste as $fichier) { + $odd = cubeMath::isOdd($i) ? ' class="odd"' : ''; $res .= ''; $res .= '' . $fichier->nom . ''; $res .= '' . $fichier->type . ''; @@ -420,9 +407,9 @@ class commonUrl { $i++; } if (!isset($settings['search']) || is_null($settings['search'])) { - $odd = cubeMath::isOdd($i)?' class="odd"':''; - $res .= '' ; - $res .= commonPage::pager($settings['page'], $dao->count() , $settings['par_page'], 'page' . $change . '/%d'); + $odd = cubeMath::isOdd($i) ? ' class="odd"' : ''; + $res .= ''; + $res .= commonPage::pager($settings['page'], $dao->count(), $settings['par_page'], 'page' . $change . '/%d'); $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('fichiers')); $res .= ''; } @@ -430,8 +417,7 @@ class commonUrl { return $res; } - public static function telecharger($args) - { + public static function telecharger($args) { commonDroits::min(array('extranet' => 0, 'ws' => 1)); array_shift($args); @@ -446,8 +432,7 @@ class commonUrl { http::redirect(WEBROOT . '/cache/download/' . $dir . '/' . $nom); } - public static function upload($args) - { + public static function upload($args) { global $core; commonDroits::min(array('extranet' => 0, 'ws' => 1)); @@ -471,7 +456,7 @@ class commonUrl { if (!isset($_SESSION['files_uploaded'])) { $_SESSION['files_uploaded'] = array(); } - foreach($_FILES as $f) { + foreach ($_FILES as $f) { if ($f['error']) { continue; } @@ -496,7 +481,7 @@ class commonUrl { $mail->subject = '[' . EMAIL_SUBJECT . '] Nouveaux fichiers uploadés par ' . $core->user->prenom . ' ' . $core->user->nom; $body = 'Tous les fichiers de ' . $core->user->prenom . ' ' . $core->user->nom . ' : http://' . $_SERVER['HTTP_HOST'] . '/fichiers/' . $core->user->utilisateur_id . "\n\n"; $body .= 'Fichiers chargés : ' . "\n"; - foreach($_SESSION['files_uploaded'] as $f) { + foreach ($_SESSION['files_uploaded'] as $f) { $body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $f . "\n"; } } else { @@ -508,7 +493,7 @@ class commonUrl { $body = 'Tous les fichiers de ' . $client->prenom . ' ' . $client->nom . ' : http://' . $_SERVER['HTTP_HOST'] . '/fichiers/' . $client->utilisateur_id . "\n\n"; $body .= 'Fichiers chargés : ' . "\n"; - foreach($_SESSION['files_uploaded'] as $f) { + foreach ($_SESSION['files_uploaded'] as $f) { $body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $f . "\n"; } $body .= "\n" . RAPPEL . " : \n"; @@ -526,38 +511,35 @@ class commonUrl { exit; } - public static function cleanDownload($args) - { + public static function cleanDownload($args) { $root = ROOT . '/cache/download/'; cubeFiles::scanRecursiveDir($root, $files); - $limit = TIME-7200; - foreach($files as $f) { + $limit = TIME - 7200; + foreach ($files as $f) { if (filemtime($f) < $limit) { unlink($f); } } $files = cubeFiles::scandir($root, true); - foreach($files as $f) { + foreach ($files as $f) { if (cubeFiles::isEmpty($f)) { @rmdir($f); } } } - public static function deleteOldFilesFromFTP($args) - { + public static function deleteOldFilesFromFTP($args) { global $core; cubePHP::neverStop(); - + $dao = new commonDAOFichier($core->con); $dao->deleteOldFiles(); - + cubeFiles::deleteFilesOlderThan('/home/ws/ftp', 60); cubeFiles::deleteFilesOlderThan('/home/ws/www/getpdf', 60); } - public static function adresse($utilisateur_id = null, $projet_id = null, $display = 'devis', $adresse = '') - { + public static function adresse($utilisateur_id = null, $projet_id = null, $display = 'devis', $adresse = '') { global $core; $dao = new commonDAOClient($core->con); if (!is_null($utilisateur_id)) { @@ -593,6 +575,7 @@ class commonUrl { $a .= '' . cubeMedia::image(IMG . '/edit.png') . ''; return $a; } + } ?> \ No newline at end of file -- 2.39.5