/** * Défini le mode superuser */ function section_security($page, $params) { $mdl = new Modele('user_sections'); if (!$_SESSION['user'] || !isset($params['section'])) { return false; } $mdl->find(array('us_user' => $_SESSION['user']['user_id'], 'us_section' => $params['section'], 'us_type' => 'manager')); if ($mdl->count()) { return ACL_SUPERUSER; } return false; }
/** * Gestion des événements * Ce controleur permet de gérer les différents événements. * @package Epicenote */ function event_security($page, $params) { $us = new Modele('user_sections'); $event = new Modele('events'); if (!isset($params['event'])) { return false; } $event->fetch($params['event']); if (!$_SESSION['user']) { return false; } // Rattrapage manager de l'event $us->find(array('us_user' => $_SESSION['user']['user_id'], 'us_section' => $event->event_section->section_id, 'us_type' => 'manager')); if ($us->count()) { return ACL_SUPERUSER; } // Rattrapage manager de section event if (preg_match('`^staff(|_.*)$`', $page)) { $us->find(array('us_user' => $_SESSION['user']['user_id'], 'us_section' => $params['section'], 'us_type' => 'manager')); if ($us->count()) { return ACL_SUPERUSER; } } }
function developer_security($page, $params) { $mdl = new Modele('api_clients'); if (!$_SESSION['user'] || !isset($params['section'])) { return false; } $pages = array('view'); if (!in_array($pages, $page)) { return false; } $mdl->find(array('ac_owner' => $_SESSION['user']['user_id'], 'ac_id' => $params['apli'])); if ($mdl->count()) { return ACL_SUPERUSER; } return false; }
function user_add_mandate($user, $mandate) { $usr = new Modele('users'); $mdt = new Modele('mandate'); $lnk = new Modele('user_mandate'); if (preg_match('/^9([0-9]{4})([0-9]{7})[0-9]$/', $user, $matchs)) { $user = $matchs[2]; $mandate = $matchs[1]; } $usr->fetch($user); $mdt->fetch($mandate); if ($lnk->find(array('um_user' => $usr->getKey(), 'um_mandate' => $mdt->getKey())) && $lnk->count() > 0) { return 'L\'utilisateur a déjà un mandat, changez ces privilèges manuellement'; } $succ = $lnk->addFrom(array('um_user' => $usr->getKey(), 'um_mandate' => $mdt->getKey())); if ($succ && aclFromText($usr->raw_user_role) < ACL_USER) { $usr->user_role = ACL_USER; } return $succ; }
/** * Insert ACL if not exists * * @param str $action Action * @param str $page Page * @param str $acl Default ACL * @return boolean */ private function _insertAcl($action, $page, $acl) { $mdl = new Modele('acces'); $obj = array('acl_page' => $page, 'acl_action' => $action); $mdl->find($obj); if ($mdl->count() > 0) { return true; } $add = new Modele('acces'); $obj['acl_acces'] = $acl; return $add->addFrom($obj); }
function tripusr_step3() { global $tpl; $ufile = _tripusr_load(); if ($ufile->tu_step != 3) { redirect('tripusr', 'continue', array('file' => $ufile->getKey())); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $valid = true; foreach ($_POST['opt'] as $answer) { $tou = new Modele('trip_option_userfile'); $valid = $valid && $tou->addFrom(array('tou_option' => $answer, 'too_userfiles' => $ufile->getKey())); } if ($valid) { $ufile->tu_step = 4; redirect('tripusr', 'step4', array('file' => $ufile->getKey())); } $tpl->assign('hsuccess', false); } $optlist = array(); $questions = new Modele('trip_options'); $questions->find(array('topt_trip' => $ufile->raw_tu_trip)); // Pas de complements, go etape 4 if ($questions->count() == 0) { $ufile->tu_step = 4; redirect('tripusr', 'step4', array('file' => $ufile->getKey())); } while ($questions->next()) { if (!isset($optlist[$questions->topt_group])) { $optlist[$questions->topt_group] = array(); } $qinfo = array('question' => new Modele($questions), 'options' => array()); $opts = new Modele('trip_option_options'); $opts->find(array('too_option' => $questions->getKey())); while ($opts->next()) { $qinfo['options'][] = new Modele($opts); } $optlist[$questions->topt_group][] = $qinfo; } $tpl->assign('groups', $optlist); display(); }