public function beforeAction()
 {
     _currentUser()->assertCredential('module:*||access|@gestionautonome');
     $this->menu = array();
     switch (_request('action')) {
         case 'createGrade':
         case 'validateGradeCreation':
         case 'manageGrades':
             $current = 'manageGrades';
             break;
         default:
             $current = 'showTree';
     }
     if (Kernel::isAdmin() || _currentUser()->hasAssistance('can_comptes')) {
         if (CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled')) {
             $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get('gestionautonome||showTree'), 'type' => 'users', 'current' => $current == 'showTree' ? 'current' : '');
         } else {
             $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get('comptes||'), 'type' => 'users');
         }
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getExt'), 'url' => CopixUrl::get('comptes||getUserExt'), 'type' => 'acl', 'current' => $current == 'getUsersExt' ? 'current' : '');
     }
     if (Kernel::isAdmin()) {
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getRoles'), 'url' => CopixUrl::get('comptes||getRoles'), 'type' => 'acl', 'current' => $current == 'list' ? 'current' : '');
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.manageGrades'), 'url' => CopixUrl::get('gestionautonome||manageGrades'), 'type' => 'agendalist', 'current' => $current == 'manageGrades' ? 'current' : '');
     }
     $session = _sessionGet('modules|comptes|doLoginCreate|success');
     if ($session && is_array($session) && sizeof($session)) {
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.strings.showloginresult', sizeof($session)), 'url' => CopixUrl::get('comptes||getLoginResult'), 'size' => 145);
     }
     $this->addJs('js/iconito/module_gestionautonome.js');
 }
Пример #2
0
 /**
  * Détermine si l'usager courant peut accéder à la rubrique d'administration
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/12/05
  * @return boolean True s'il peut, false sinon
  */
 public function canAdmin()
 {
     if (Kernel::isAdmin()) {
         return true;
     } else {
         return false;
     }
     // return (_currentUser()->getExtra('type') == 'USER_EXT' && _currentUser()->getExtra('id')==1);
 }
 public function home()
 {
     if (!Kernel::isAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $tplHome = new CopixTpl();
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|admin.moduleDescription'));
     $tpl->assign('MENU', Admin::getMenu('sysutils'));
     $tplHome->assign('superadmin', Kernel::isSuperAdmin());
     $tplHome->assign('adminfonctionnel', Kernel::isAdminFonctionnel());
     $tpl->assign('MAIN', $tplHome->fetch('sysutils|home.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
Пример #4
0
 public function _createContent(&$toReturn)
 {
     if (!$this->service('rssMixService')->getRssIsNotEmpty() && !$this->user->root) {
         $toReturn = '';
         return true;
     }
     $tpl = new CopixTpl();
     $tpl->assign('urladmin', $this->url('kernel|default|go', array('ntype' => 'ROOT', 'nid' => 0, 'mtype' => 'rssmix')));
     $tpl->assign('userIsAdmin', Kernel::isAdmin());
     $tpl->assign('urlRssMix', $this->url('rssmix|default|GetRssFeedAjax'));
     $toReturn = $tpl->fetch('rssmix|zone.tpl');
     $this->addJs('js/jcarousellite/jcarousellite.js');
     $this->addCss('styles/module_rssmix.css');
     return true;
 }
 public function processAdminAction()
 {
     //check if the user is admin :
     if (!Kernel::isAdmin()) {
         return $this->error('charte.noRight');
     }
     //get action
     $action = $this->request('typeaction');
     //get the targeted items
     $target = $this->request('target');
     //security : force user type
     $userType = array('children', 'adults', 'all');
     //security
     if (empty($target) || !in_array($target, $userType)) {
         return $this->error('charte.badArgs');
     }
     //build array datas of users type
     $user_children = array('USER_ELE');
     $user_adults = array('USER_EXT', 'USER_VIL', 'USER_RES', 'USER_ENS');
     $user_all = array('USER_ALL');
     //foreach action :
     switch ($action) {
         case 'suppr_validation':
             $this->service('CharteService')->deleteUserValidation(${'user_' . $target});
             $this->flash->success = $this->i18n('charte.successSupprValid');
             break;
         case 'suppr_charte':
             $this->service('CharteService')->delCharte(${'user_' . $target});
             $this->flash->success = $this->i18n('charte.successSupprChart');
             break;
         case 'new_charte':
             $url = $this->request('ca-file_url');
             $active = $this->request('ca-activate');
             if (empty($url)) {
                 $this->flash->errors = array($target => $this->i18n('charte.noUrl'));
                 break;
             }
             $this->service('CharteService')->addCharte(${'user_' . $target}, $url, 1, $active);
             $this->flash->success = $this->i18n('charte.successAddChart');
             break;
             //if default : bad argument
         //if default : bad argument
         default:
             return $this->error('charte.badArgs');
             break;
     }
     return $this->go('charte|charte|admin');
 }
 public function getHomePage()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $tpl = new CopixTpl();
     $tplRegroupements = new CopixTpl();
     // CopixHTMLHeader::addCSSLink (_resource("styles/module_grvilles.css"));
     // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('grvilles|grvilles.module.titre'));
     $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles");
     $grvilles = $dao_grvilles->findAll();
     $tplRegroupements->assign('GRVILLES', count($grvilles));
     $dao_grecoles = CopixDAOFactory::create("regroupements|grecoles");
     $grecoles = $dao_grecoles->findAll();
     $tplRegroupements->assign('GRECOLES', count($grecoles));
     $main = $tplRegroupements->fetch('default.tpl');
     $tpl->assign('MAIN', $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function getGroup()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $tpl = new CopixTpl();
     $tplGrVilles = new CopixTpl();
     CopixHTMLHeader::addCSSLink(_resource("styles/module_regroupements.css"));
     $regroupements_service =& CopixClassesFactory::Create('regroupements|regroupements');
     $tpl->assign('TITLE_PAGE', CopixI18N::get('regroupements|regroupements.villes.titre'));
     $tpl->assign('MENU', $regroupements_service->getMenu());
     $dao_grvilles_gr2ville = CopixDAOFactory::create("regroupements|grvilles_gr2ville");
     $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles");
     $dao_villes = CopixDAOFactory::create("kernel|kernel_tree_vil");
     $villes = $dao_villes->findAll();
     $tplGrVilles->assign('villes', $villes);
     if (_request("delete")) {
         $dao_grvilles->delete(_request("delete"));
         $dao_grvilles_gr2ville->deleteByGroupe(_request("delete"));
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|'));
     }
     if (_request("save") && _request("save") == 1) {
         $date = date("Y-m-d H:i:s");
         $user = Kernel::getUserInfo();
         if (_request("form_id") > 0) {
             $grvilles_infos = $dao_grvilles->get(_request("form_id"));
             $grvilles_infos->nom = _request("form_nom");
             $grvilles_infos->updated_at = $date;
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->update($grvilles_infos);
             $dao_grvilles_gr2ville->deleteByGroupe(_request("form_id"));
         } else {
             $grvilles_infos = CopixDAOFactory::createRecord("regroupements|grvilles");
             $grvilles_infos->nom = _request("form_nom");
             if ($grvilles_infos->nom == '') {
                 $grvilles_infos->nom = 'Sans nom';
             }
             $grvilles_infos->updated_at = date("Y-m-d H:i:s");
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->insert($grvilles_infos);
         }
         $grvilles_gr2ville = _record("regroupements|grvilles_gr2ville");
         $grvilles_gr2ville->id_groupe = $grvilles_infos->id;
         $grvilles_gr2ville->updated_at = $date;
         $grvilles_gr2ville->updated_by = $user['login'];
         foreach ($villes as $ville) {
             if (_request("ville_" . $ville->vil_id_vi) == 1) {
                 $grvilles_gr2ville->id_ville = $ville->vil_id_vi;
                 _dao("regroupements|grvilles_gr2ville")->insert($grvilles_gr2ville);
             }
         }
         if (_request("form_id") == 0) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|', array('groupe' => $grvilles_infos->id)));
         }
     }
     if (_request("groupe")) {
         $tplGrVilles->assign('grvilles_id', _request("groupe"));
         $tplGrVilles->assign('grvilles_form', true);
         if (_request("groupe") > 0) {
             // Edition d'un groupe
             $grvilles_infos = $dao_grvilles->get(_request("groupe"));
             $grvilles_villes_raw = $dao_grvilles_gr2ville->findByGroupe(_request("groupe"));
             // Tableau indexé par id de ville
             $grvilles_villes = array();
             foreach ($grvilles_villes_raw as $grvilles_villes_item) {
                 $grvilles_villes[$grvilles_villes_item->id_ville] = $grvilles_villes_item;
             }
             $tplGrVilles->assign('grvilles_infos', $grvilles_infos);
             $tplGrVilles->assign('grvilles_villes', $grvilles_villes);
         } else {
             // Création d'un nouveau groupe
         }
     }
     $grvilles_list = $dao_grvilles->findAll();
     // print_r($grvilles_list);
     $tplGrVilles->assign('grvilles_list', $grvilles_list);
     $main = $tplGrVilles->fetch('getgrvilles.tpl');
     $tpl->assign('MAIN', $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Nodes : Retourne les noeuds parents (ecole->ville)
  * INPUT  : noeud (type+id)
  * OUTPUT : noeuds (array type+id)
  */
 public function getNodeParents($type, $id)
 {
     if (DEBUG) {
         $backtrace = debug_backtrace();
         $backtrace_array = array();
         $continue = true;
         foreach ($backtrace as $backtrace_item) {
             $backtrace_array[] = $backtrace_item['class'] . "::" . $backtrace_item['function'];
             if ($backtrace_item['class'] != 'Kernel') {
                 break;
             }
         }
         file_put_contents('/tmp/iconito.log', date("Y-m-d H:i:s -- ") . implode(" >> ", array_reverse($backtrace_array)) . " ({$type}, {$id})" . "\n", FILE_APPEND);
     }
     // if(DEBUG) file_put_contents('/tmp/iconito.log', "getNodeParents($type, $id)\n", FILE_APPEND );
     //print_r ("getNodeParents( $type, $id )<br>");
     //die();
     if (1) {
         //La donnee níest pas en cache, on traite la demande.
         $return = array();
         switch ($type) {
             case "BU_GRVILLE":
                 $return[] = array("type" => "ROOT", "id" => 0);
                 break;
             case "BU_VILLE":
                 // Ville --(1)--> Groupe de ville
                 $vil_dao = _dao("kernel|kernel_tree_vil");
                 if ($ville = $vil_dao->get($id)) {
                     $return[] = array("type" => "BU_GRVILLE", "id" => $ville->vil_id_grville);
                 }
                 break;
             case "BU_ECOLE":
                 // Ecole --(1)--> Ville
                 $eco_dao = _dao("kernel|kernel_tree_eco");
                 if ($ecole = $eco_dao->get($id)) {
                     $return[] = array("type" => "BU_VILLE", "id" => $ecole->eco_id_ville);
                 }
                 break;
             case "BU_CLASSE":
                 // Classe --(1)--> Ecole
                 $cla_dao = _dao("kernel|kernel_tree_cla");
                 if ($classe = $cla_dao->get($id)) {
                     $return[] = array("type" => "BU_ECOLE", "id" => $classe->cla_ecole);
                 }
                 break;
             case "CLUB":
                 // Voir la table des nodes
                 // Groupe de travail --(1)--> Noeud (classe, ecole, etc.)
                 $dao = _dao("kernel|kernel_link_groupe2node");
                 if ($res = $dao->get($id)) {
                     $return[] = array("type" => $res->node_type, "id" => $res->node_id);
                 }
                 break;
             case "USER_ENS":
                 // Enseignant --(n)--> Classes/Ecoles
             // Enseignant --(n)--> Classes/Ecoles
             case "USER_VIL":
                 // Agent de ville --(1?)--> Ville
             // Agent de ville --(1?)--> Ville
             case "USER_ADM":
                 // Administratif ecole --(n)--> Ecoles
                 $dao = _dao("kernel|kernel_bu_personnel_entite");
                 $res = $dao->getById($id);
                 foreach ($res as $key => $val) {
                     switch ($val->pers_entite_type_ref) {
                         case "ECOLE":
                             // Enseignant --(n)--> Ecoles (directeur)
                             $role2droit = array(1 => PROFILE_CCV_WRITE, 2 => PROFILE_CCV_ADMIN, 3 => PROFILE_CCV_WRITE);
                             $return[] = array("type" => "BU_ECOLE", "id" => $val->pers_entite_reference, "droit" => $role2droit[$val->pers_entite_role]);
                             // Patch pour acces directeur dans les classes
                             if (CopixConfig::exists('|conf_DirClasse') && CopixConfig::get('|conf_DirClasse')) {
                                 // Enseignant --(n)--> Classes (directeur)
                                 $node_list = Kernel::getNodeChilds("BU_ECOLE", $val->pers_entite_reference);
                                 $classe_list = Kernel::filterNodeList($node_list, "BU_CLASSE");
                                 if (sizeof($classe_list)) {
                                     foreach ($classe_list as $classe) {
                                         $return[] = array("type" => "BU_CLASSE", "id" => $classe['id'], "droit" => PROFILE_CCV_ADMIN);
                                     }
                                 }
                             }
                             break;
                         case "CLASSE":
                             // Enseignant --(n)--> Classes
                             $role2droit = array(1 => PROFILE_CCV_ADMIN, 2 => PROFILE_CCV_ADMIN);
                             $return[] = array("type" => "BU_CLASSE", "id" => $val->pers_entite_reference, "droit" => $role2droit[$val->pers_entite_role]);
                             break;
                         case "VILLE":
                             $role2droit = array(4 => PROFILE_CCV_ADMIN);
                             $return[] = array("type" => "BU_VILLE", "id" => $val->pers_entite_reference, "droit" => $role2droit[$val->pers_entite_role]);
                             break;
                         case "GVILLE":
                             $role2droit = array(5 => PROFILE_CCV_ADMIN);
                             $return[] = array("type" => "BU_GRVILLE", "id" => $val->pers_entite_reference, "droit" => $role2droit[$val->pers_entite_role]);
                             break;
                     }
                 }
                 break;
             case "USER_ELE":
                 // Eleve --(n)--> Classes
                 $dao = _dao("kernel|kernel_bu_ele_affect");
                 $res = $dao->getByEleve($id);
                 foreach ($res as $key => $val) {
                     $return[] = array("type" => "BU_CLASSE", "id" => $val->affect_classe, "droit" => PROFILE_CCV_WRITE);
                 }
                 // Ecole (lecture) ?
                 // ? Pour toutes les classes, ajouter les parents de "USER_ELE_CLASSE,X"
                 break;
                 // Utilisateurs locaux (hors BU) --(n)--> Noeuds (ecoles, classes, clubs, etc.)
             // Utilisateurs locaux (hors BU) --(n)--> Noeuds (ecoles, classes, clubs, etc.)
             case "USER_EXT":
                 $alreadyOnRoot = false;
                 $dao = _dao("kernel|kernel_link_user2node");
                 $res = $dao->getByUser($type, $id);
                 foreach ($res as $key => $val) {
                     if (preg_match("/^BU_(.+)\$/", $val->node_type, $regs)) {
                         $return[] = array("type" => $val->node_type, "id" => $val->node_id, "droit" => $val->droit);
                     }
                 }
                 break;
             default:
                 break;
         }
         // Responsable --(n)--> BÈnÈficiaire (limitÈ ‡ parent --> enfants)
         if ($type == "USER_RES") {
             $dao = _dao("kernel|kernel_bu_res2ele");
             $res = $dao->getByResponsable('responsable', $id);
             foreach ($res as $key => $val) {
                 if ($val->res2ele_type_beneficiaire != "eleve") {
                     continue;
                 }
                 $parents = Kernel::getNodeParents('USER_ELE', $val->res2ele_id_beneficiaire);
                 $parent = Kernel::filterNodeList($parents, "BU_CLASSE");
                 $nom_classe = '';
                 if (count($parent)) {
                     if (!isset($parent[0]['nom'])) {
                         continue;
                     }
                     $nom_classe = $parent[0]['nom'];
                 }
                 $return[] = array("type" => "USER_ELE", "id" => $val->res2ele_id_beneficiaire, "droit" => $val->res2ele_auth_parentale ? PROFILE_CCV_ADMIN : PROFILE_CCV_READ, "res2ele_type" => $val->res2ele_type_beneficiaire, "res2ele_auth_parentale" => $val->res2ele_auth_parentale, "nom_classe" => $nom_classe);
             }
         }
         if (preg_match("/^USER_(.+)\$/", $type)) {
             $dao = _dao("kernel|kernel_link_user2node");
             $res = $dao->getByUser($type, $id);
             foreach ($res as $key => $val) {
                 // Utilisateurs --(n)--> Groupes de travail (clubs)
                 if ($val->node_type == "CLUB") {
                     $ok = true;
                     if ($val->debut && $val->debut > date("Ymd")) {
                         $ok = false;
                     }
                     if ($val->fin && $val->fin < date("Ymd")) {
                         $ok = false;
                     }
                     $droit = $ok ? $val->droit : 19;
                     // CB Remplacer 30 par constante
                     $return[] = array("type" => $val->node_type, "id" => $val->node_id, "droit" => $droit);
                 } elseif ($val->node_type == "ROOT") {
                     $return[] = array("type" => $val->node_type, "id" => 0, "droit" => $val->droit);
                 } elseif (preg_match("/^BU_(.+)\$/", $val->node_type)) {
                     $ok = true;
                     if ($val->debut && $val->debut > date("Ymd")) {
                         $ok = false;
                     }
                     if ($val->fin && $val->fin < date("Ymd")) {
                         $ok = false;
                     }
                     if ($ok) {
                         $return[] = array("type" => $val->node_type, "id" => $val->node_id, "droit" => $val->droit);
                     }
                 }
                 // Utilisateurs --(n)--> Modules
                 /*
                 if( ereg( "^MOD_(.+)$", $val->node_type ) ) {
                 $ok = true;
                 if ($val->debut && $val->debut>date("Ymd")) $ok = false;
                 if ($val->fin   && $val->fin  <date("Ymd")) $ok = false;
                 $droit = ($ok) ? $val->droit : 0; // CB Remplacer 30 par constante
                 $return[]=array("type"=>$val->node_type, "id"=>$val->node_id,"droit"=>$droit);
                 }
                 */
             }
             // Rustine CB 25/08/2010 On ajoute un droit de lecture sur le groupe d'assistance
             if ($type == _currentUser()->getExtra('type') && $id == _currentUser()->getExtra('id') && CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance'))) {
                 $return[] = array("type" => 'CLUB', "id" => $groupeAssistance, "droit" => PROFILE_CCV_READ);
                 //print_r($return);
             }
             //// Ajoute le club Edito aux admins et admins fonctionnels
             //
             // Si on est admin (fonctionnel ou super-admin)
             if ($type == _currentUser()->getExtra('type') && $id == _currentUser()->getExtra('id') && Kernel::isAdmin()) {
                 $conf_Edito_type = null;
                 if (CopixConfig::exists('default|conf_Edito_type')) {
                     $conf_Edito_type = CopixConfig::get('default|conf_Edito_type');
                 }
                 $conf_Edito_id = null;
                 if (CopixConfig::exists('default|conf_Edito_id')) {
                     $conf_Edito_id = CopixConfig::get('default|conf_Edito_id');
                 }
                 // Si l'édito est configuré dans le module.xml
                 if ($conf_Edito_type && $conf_Edito_id) {
                     $edito_found = false;
                     // On vérifie si l'édito est déjà dans la liste...
                     foreach ($return as $key => $val) {
                         if ($val['type'] == $conf_Edito_type && $val['id'] == $conf_Edito_id) {
                             // ...si oui, on garde le droit le plus élevé
                             $return[$key]['droit'] = max(PROFILE_CCV_ADMIN, $val['droit']);
                             $edito_found = true;
                         }
                     }
                     // ...sinon on l'ajoute
                     if (!$edito_found) {
                         $return[] = array("type" => $conf_Edito_type, "id" => $conf_Edito_id, "droit" => PROFILE_CCV_ADMIN);
                     }
                 }
             }
             // echo "<pre>"; print_r($return); die();
         }
         // Ajoute les infos aux donnÈes sur les enfants
         foreach ($return as $key => $val) {
             $infos = Kernel::getNodeInfo($val['type'], $val['id'], false);
             if ($infos) {
                 // VÈrifie qu'il y a des infos...
                 foreach ($infos as $info_key => $info_val) {
                     if (!isset($return[$key][$info_key])) {
                         // Evite les effacements...
                         $return[$key][$info_key] = $info_val;
                     }
                 }
             }
         }
     }
     // Suppression des classes dans les annees scolaires passees...
     foreach ($return as $key => $val) {
         if ($val['type'] == 'BU_CLASSE' && isset($val['ALL'])) {
             if (!$val['ALL']->annee_current || !$val['ALL']->cla_is_validee || $val['ALL']->cla_is_supprimee) {
                 unset($return[$key]);
             }
         }
     }
     // _dump($return);
     reset($return);
     return $return;
 }
 /**
  * Admins : ajouter des admins
  *
  * Propose l'ajout de personnes comme animateur
  *
  * @package	Comptes
  * @author	Frédéric Mossmann <*****@*****.**>
  */
 public function processNew()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $tpl = new CopixTpl();
     $tplListe = new CopixTpl();
     $tplListe->assign('linkpopup', CopixZone::process('annuaire|linkpopup', array('field' => 'new_admins')));
     $main = $tplListe->fetch("admins-new.tpl");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.admins'));
     $tpl->assign('MAIN', $main);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processDefault()
 {
     if (!Kernel::isAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $ppo = new CopixPPO();
     $ppo->from = array('USER_VIL', 'USER_DIR', 'USER_ENS', 'USER_RES', 'USER_ELE', 'USER_ATI', 'USER_EXT', 'USER_ADM');
     $ppo->to = array('USER_VIL', 'USER_DIR', 'USER_ENS', 'USER_RES', 'USER_ELE', 'USER_ATI', 'USER_EXT', 'USER_ADM');
     $ppo->where = array('NOWHERE', 'BU_CLASSE', 'BU_ECOLE', 'BU_VILLE', 'BU_GRVILLE', 'ROOT');
     $ppo->do = array('VOIR', 'COMM');
     $ppo->trad = array('USER_VIL' => "Agent ville", 'USER_DIR' => "Directeur", 'USER_ENS' => "Enseignant", 'USER_RES' => "Parent", 'USER_ELE' => "Elève", 'USER_ADM' => "Admin", 'USER_ATI' => "Anim TICE", 'USER_EXT' => "Personne ext", 'NOWHERE' => "Interdit", 'BU_CLASSE' => "Même classe", 'BU_ECOLE' => "Même école", 'BU_VILLE' => "Même ville", 'BU_GRVILLE' => "Même groupe<br/>de ville", 'ROOT' => "Partout", 'VOIR' => "Voir", 'COMM' => "Ecrire");
     if (_request("save", 0) == 1) {
         // echo "<pre>"; print_r($_POST); die();
         // Clear matrix
         _doQuery('DELETE FROM module_rightmatrix');
         /* Mode checkbox
         			foreach( $ppo->from AS $cpt_from ) {
         				foreach( $ppo->to AS $cpt_to ) {
         					foreach( $ppo->do AS $cpt_do ) {
         						// Retournement de la Matrice pour écrire dans le domaine le plus large (uniquement)
         						foreach( array_reverse($ppo->where) AS $cpt_where ) {
         							$droit = _request("right_".$cpt_from."_".$cpt_to."_".$cpt_where."_".$cpt_do);
         							// if($droit) echo "<li>[$cpt_from][$cpt_to][$cpt_where][$cpt_do] = ".($droit?"OUI":"non")."</li>";
         							// if($droit) echo "<li>[$cpt_from][$cpt_to][$cpt_where][$cpt_do] = ".($droit?"OUI":"non")."</li>";
         							if($droit) _doQuery('INSERT INTO module_rightmatrix (user_type_in, user_type_out, node_type, `right`) VALUES (:user_type_in, :user_type_out, :node_type, :right)', array( ':user_type_in'=> $cpt_from, ':user_type_out' => $cpt_to, ':node_type' => $cpt_where, ':right' => $cpt_do ));
         							if($droit) break;
         						}
         					}
         				}
         			}
         			*/
         foreach ($ppo->from as $cpt_from) {
             foreach ($ppo->to as $cpt_to) {
                 foreach ($ppo->do as $cpt_do) {
                     $droit = _request("right_" . $cpt_from . "_" . $cpt_to . "_" . $cpt_do);
                     if ($droit != "NOWHERE") {
                         _doQuery('INSERT INTO module_rightmatrix (user_type_in, user_type_out, node_type, `right`) VALUES (:user_type_in, :user_type_out, :node_type, :right)', array(':user_type_in' => $cpt_from, ':user_type_out' => $cpt_to, ':node_type' => $droit, ':right' => $cpt_do));
                     }
                 }
             }
         }
         // die('save');
     }
     // Initialisation de la matrice
     $ppo->right = array();
     foreach ($ppo->from as $cpt_from) {
         $ppo->right[$cpt_from] = array();
         foreach ($ppo->to as $cpt_to) {
             $ppo->right[$cpt_from][$cpt_to] = array();
             foreach ($ppo->where as $cpt_where) {
                 $ppo->right[$cpt_from][$cpt_to][$cpt_where] = array();
                 foreach ($ppo->do as $cpt_do) {
                     $ppo->right[$cpt_from][$cpt_to][$cpt_where][$cpt_do] = false;
                 }
             }
         }
     }
     // Récupération des information de la matrice en base de données
     $tmp_right = _doQuery('SELECT * FROM module_rightmatrix');
     foreach ($tmp_right as $tmp_right_item) {
         $ppo->right[$tmp_right_item->user_type_in][$tmp_right_item->user_type_out][$tmp_right_item->node_type][$tmp_right_item->right] = true;
     }
     return _arPPO($ppo, 'matrix-display.tpl');
 }
 public function getDelete()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $pUserType = _request('user_type');
     $pUserId = _request('user_id');
     if (!$pUserType || !$pUserId) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes|animateurs|list'));
     }
     $animateurs_dao =& CopixDAOFactory::create("kernel|kernel_animateurs");
     // $animateurs2grville_dao = & CopixDAOFactory::create("kernel|kernel_animateurs2grville");
     $animateurs2regroupements_dao =& CopixDAOFactory::create("kernel|kernel_animateurs2regroupements");
     $animateurs_dao->delete($pUserType, $pUserId);
     // $animateurs2grville_dao->deleteByUser($pUserType, $pUserId);
     $animateurs2regroupements_dao->deleteByUser($pUserType, $pUserId);
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes|animateurs|list'));
 }
 /**
  * getRoles
  *
  * Affiche le menu des rôles d'utilisateurs
  *
  * @package	Comptes
  * @author	Frédéric Mossmann <*****@*****.**>
  */
 public function getRoles()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $this->menu = array();
     if (Kernel::isAdmin() || _currentUser()->hasAssistance('can_comptes')) {
         if (CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled')) {
             $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get('gestionautonome||showTree'), 'type' => 'users');
         } else {
             $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get('comptes||'), 'type' => 'users');
         }
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getExt'), 'url' => CopixUrl::get('comptes||getUserExt'), 'type' => 'acl');
     }
     if (Kernel::isAdmin()) {
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getRoles'), 'url' => CopixUrl::get('comptes||getRoles'), 'type' => 'acl', 'current' => 'current');
         $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.manageGrades'), 'url' => CopixUrl::get('gestionautonome||manageGrades'), 'type' => 'agendalist');
     }
     $tpl = new CopixTpl();
     $tplRegroupements = new CopixTpl();
     // CopixHTMLHeader::addCSSLink (_resource("styles/module_grvilles.css"));
     // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('grvilles|grvilles.module.titre'));
     $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles");
     $grvilles = $dao_grvilles->findAll();
     $tplRegroupements->assign('GRVILLES', count($grvilles));
     $dao_grecoles = CopixDAOFactory::create("regroupements|grecoles");
     $grecoles = $dao_grecoles->findAll();
     $tplRegroupements->assign('GRECOLES', count($grecoles));
     $main = $tplRegroupements->fetch('roles-default.tpl');
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.roles'));
     $tpl->assign('MAIN', $main);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processDeleteImage()
 {
     if (!Kernel::isAdmin()) {
         return $this->error('rssmix.noRight', true, '||');
     }
     if (!$this->istyreq('id')) {
         return $this->error('rssmix.error');
     }
     $id = (int) $this->request('id');
     $this->service->deleteImage($id);
     $this->flash->success = $this->i18n('rssmix.image.success');
     return $this->redirect('rssmix|default|update', array('id' => $this->request('id')));
 }
 /**
  * Renvoie l'entree de l'annuaire pour l'usager courant. Pour les parents, prends le home d'un des enfants. S'il n'y a pas d'enfant ou que le compte n'est rattache a rien, on l'envoie dans la 1e ville.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/12/20
  * @return array Tableau avec [type] et [id] du noeud (BU_CLASSE, BU_ECOLE, BU_VILLE, BU_GVILLE)
  */
 public function getAnnuaireHome()
 {
     // Recuperation de ses blocs, comme dans le dashboard
     $nodes_all = Kernel::getNodeParents($this->user->type, $this->user->idEn);
     $nodes_all = Kernel::sortNodeList($nodes_all);
     //_dump($nodes_all);
     $home = null;
     foreach ($nodes_all as $node) {
         if ($node['type'] == 'BU_CLASSE' || $node['type'] == 'BU_ECOLE' || $node['type'] == 'BU_VILLE' || $node['type'] == 'BU_GVILLE') {
             $home = array('type' => $node['type'], 'id' => $node['id']);
             break;
         }
     }
     //_dump($home);
     if (!$home && Kernel::isParent()) {
         // Cas du parent d'�l�ve
         $enfants = Kernel::getNodeParents(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         while (list($k, $v) = each($enfants)) {
             if ($v["type"] != "USER_ELE") {
                 continue;
             }
             // Pour chaque enfant...
             //print_r($v);
             if (is_array($v['link']->classe) && ($id = array_shift(array_keys($v['link']->classe)))) {
                 $home = array('type' => 'BU_CLASSE', 'id' => $id);
             } elseif (is_array($v['link']->ecole) && ($id = array_shift(array_keys($v['link']->ecole)))) {
                 $home = array('type' => 'BU_ECOLE', 'id' => $id);
             } elseif (is_array($v['link']->ville) && ($id = array_shift(array_keys($v['link']->ville)))) {
                 $home = array('type' => 'BU_VILLE', 'id' => $id);
             }
             if ($home) {
                 break;
             }
         }
     }
     if (!$home || Kernel::isAdmin()) {
         // Si rattache a rien, on l'envoie dans la 1e ville
         $sql = "SELECT MIN(id_vi) AS ville FROM kernel_bu_ville LIMIT 1";
         $v = _doQuery($sql);
         $home = array('type' => 'BU_VILLE', 'id' => $v[0]->ville);
     }
     //print_r($home);
     return $home;
 }
 /**
  * Gestion des droits dans un groupe
  *
  * Teste si l'usager peut effectuer une certaine opération par rapport à son droit. Le droit sur le groupe nécessite d'être connu, renvoyé par le kernel avant l'entrée dans cette fonction.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/02
  * @param string $action Action pour laquelle on veut tester le droit
  * @param integer $droit Le droit de l'usager
  * @return bool true s'il a le droit d'effectuer l'action, false sinon
  * @todo Limiter ADD_GROUP aux adultes
  */
 public function canMakeInGroupe($action, $droit)
 {
     $can = false;
     switch ($action) {
         case "VIEW_HOME":
             // Accueil d'un groupe
             $can = $droit >= PROFILE_CCV_READ;
             break;
         case "ADMIN":
             // Accueil de l'admin d'un groupe
             $can = $droit >= PROFILE_CCV_ADMIN;
             break;
         case "UNSUBSCRIBE_HIMSELF":
             // Se désinscrire (soi-même)
             $can = $droit >= PROFILE_CCV_READ && $droit < PROFILE_CCV_ADMIN;
             break;
         case "ADD_GROUP":
             // Création d'un groupe, ne dépend pas du droit sur un groupe mais du profil de l'usager
             $can = Kernel::isEnseignant() || Kernel::isAgentVille() || Kernel::isPersonnelAdministratif() || Kernel::isAnimateur() || Kernel::isAdmin();
             break;
     }
     return $can;
 }
 public function processAdd_Admin()
 {
     if (!Kernel::isAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $groupe_id = _request("groupe");
     $tplHome = new CopixTpl();
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|admin.moduleDescription'));
     $tpl->assign('MENU', Admin::getMenu('groupes'));
     $tplHome->assign('groupe_id', $groupe_id);
     $new_admin_check = array();
     if (_request('save', 0)) {
         $new_admins = _request('new_admins');
         $new_admins = preg_split("/[\\s,]+/", $new_admins);
         foreach ($new_admins as $new_admin) {
             if (trim($new_admin) == '') {
                 continue;
             }
             $sql = "\n                    SELECT\n                        dbuser.id_dbuser, dbuser.login_dbuser,\n                        kernel_link_bu2user.bu_type, kernel_link_bu2user.bu_id,\n                        kernel_link_user2node.droit, kernel_link_user2node.debut, kernel_link_user2node.fin\n                    FROM dbuser\n                    JOIN kernel_link_bu2user ON kernel_link_bu2user.user_id=dbuser.id_dbuser\n                    LEFT JOIN kernel_link_user2node ON kernel_link_user2node.user_type=kernel_link_bu2user.bu_type AND kernel_link_user2node.user_id=kernel_link_bu2user.bu_id AND kernel_link_user2node.node_type='CLUB' AND kernel_link_user2node.node_id=:node_id\n                    WHERE dbuser.login_dbuser=:login_dbuser\n                ";
             $new_admin_check[$new_admin] = _doQuery($sql, array(':login_dbuser' => $new_admin, ':node_id' => $groupe_id));
             if (!count($new_admin_check[$new_admin])) {
                 // login inconnu
                 // NE RIEN FAIRE !!!
             } elseif (!$new_admin_check[$new_admin][0]->bu_type) {
                 // login non rattaché
                 // NE RIEN FAIRE !!!
             } elseif ($new_admin_check[$new_admin][0]->droit) {
                 // déjà inscrit
                 // Modifier le droit actuel -> admin
                 $sql = "DELETE FROM kernel_link_user2node WHERE user_type=:user_type AND user_id=:user_id AND node_type=:node_type AND node_id=:node_id";
                 _doQuery($sql, array(':user_type' => $new_admin_check[$new_admin][0]->bu_type, ':user_id' => $new_admin_check[$new_admin][0]->bu_id, ':node_type' => 'CLUB', ':node_id' => $groupe_id));
                 $sql = "\n                        INSERT INTO kernel_link_user2node ( user_type,  user_id,  node_type,  node_id,  droit)\n                        VALUES                            (:user_type, :user_id, :node_type, :node_id, :droit)";
                 _doQuery($sql, array(':user_type' => $new_admin_check[$new_admin][0]->bu_type, ':user_id' => $new_admin_check[$new_admin][0]->bu_id, ':node_type' => 'CLUB', ':node_id' => $groupe_id, ':droit' => 70));
             } else {
                 // Ajouter le droit -> admin
                 $sql = "\n                        INSERT INTO kernel_link_user2node ( user_type,  user_id,  node_type,  node_id,  droit)\n                        VALUES                            (:user_type, :user_id, :node_type, :node_id, :droit)";
                 _doQuery($sql, array(':user_type' => $new_admin_check[$new_admin][0]->bu_type, ':user_id' => $new_admin_check[$new_admin][0]->bu_id, ':node_type' => 'CLUB', ':node_id' => $groupe_id, ':droit' => 70));
             }
         }
         $this->flash->new_admin_check = $new_admin_check;
         $tplHome->assign('new_admin_check', $new_admin_check);
         // echo "<pre>"; print_r($new_admin_check); echo "</pre>";
         return _arRedirect(_url('sysutils|groupes|'));
         $tpl->assign('MAIN', $tplHome->fetch('sysutils|groupes-addadmin-do.tpl'));
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
     $sql = "SELECT * FROM module_groupe_groupe WHERE id=:id";
     $groupe_infos = _doQuery($sql, array(':id' => $groupe_id));
     if (!$groupe_infos) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $tplHome->assign('groupe_id', $groupe_id);
     $tplHome->assign('groupe_infos', $groupe_infos);
     $tpl->assign('MAIN', $tplHome->fetch('sysutils|groupes-addadmin.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }