/**
  * go
  *
  * Appel automatique, avec détection du noeud à afficher.
  * @author	Frédéric Mossmann
  * @since	10.03.2009
  *
  */
 public function go()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login')));
     }
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_concerto.js');
     if (!_request("id") || !ereg('^[0-9]+$', _request("id"))) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('kernel||getNodes'));
     }
     $sql = 'SELECT login,password FROM kernel_bu_auth WHERE node_type=\'responsable\' AND node_id=' . _currentUser()->getExtra('id') . ' AND id=\'' . addslashes(_request("id")) . '\' AND service=\'concerto\'';
     $concerto = _doQuery($sql);
     if (!$concerto) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('kernel||getNodes'));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('concerto|concerto.title'));
     // $tpl->assign ('MENU', '<a href="'.CopixUrl::get ('groupe||getListPublic').'">'.CopixI18N::get ('groupe|groupe.annuaire').'</a> :: <a href="'.CopixUrl::get ('groupe||getListMy').'">'.CopixI18N::get ('groupe|groupe.my').'</a>');
     $tplListe = new CopixTpl();
     $tplListe->assign('login', $concerto[0]->login);
     $tplListe->assign('password', $concerto[0]->password);
     $result = $tplListe->fetch("concerto-form.tpl");
     $tpl->assign("MAIN", $result);
     $tpl->assign('BODY_ON_LOAD', 'concerto_redirect();');
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function beforeAction()
 {
     _currentUser()->assertCredential('group:[current_user]');
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login')));
     }
 }
 /**
  * Affichage de la fiche d'une ecole
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/09/03
  * @param integer $id Id de l'ecole
  * @param integer $popup 1 pour afficher la fiche en popup Fancybox
  */
 public function fiche()
 {
     $id = $this->getRequest('id', null);
     $iPopup = CopixRequest::getInt('popup');
     $ecoleDAO = CopixDAOFactory::create('kernel|kernel_bu_ecole');
     $ficheDAO = CopixDAOFactory::create("fiches_ecoles");
     $criticErrors = array();
     if (!($rEcole = $ecoleDAO->get($id))) {
         $criticErrors[] = CopixI18N::get('fichesecoles.error.param');
     } elseif (!FichesEcolesService::canMakeInFicheEcole($id, 'VIEW')) {
         $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('annuaire||')));
     }
     $rFiche = $ficheDAO->get($id);
     $tpl = new CopixTpl();
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_fichesecoles.js');
     $fiche = CopixZone::process('fiche', array('rEcole' => $rEcole, 'rFiche' => $rFiche));
     $main = $fiche;
     $title = $rEcole->nom;
     if ($rEcole->type) {
         $title .= ' (' . $rEcole->type . ')';
     }
     $tpl->assign('TITLE_PAGE', $title);
     // Get vocabulary catalog to use
     $nodeVocabularyCatalogDAO = _ioDAO('kernel|kernel_i18n_node_vocabularycatalog');
     $vocabularyCatalog = $nodeVocabularyCatalogDAO->getCatalogForNode('BU_ECOLE', $rEcole->numero);
     if (strtolower($rEcole->type) == 'crèche') {
         $tpl->assign('TITLE_CONTEXT', CopixI18N::get('kernel|kernel.codes.mod_fichesecoles_creche'));
     } else {
         $tpl->assign('TITLE_CONTEXT', CopixCustomI18N::get('kernel|kernel.codes.mod_fiche%%structure%%', array('catalog' => $vocabularyCatalog->id_vc)));
     }
     $menu = array();
     $menu[] = array('url' => CopixUrl::get('public||getListBlogs'), 'txt' => CopixCustomI18N::get('public|public.blog.annuaire.%%structures%%', array('catalog' => $vocabularyCatalog->id_vc)));
     if (Kernel::is_connected()) {
         $menu[] = array('url' => CopixUrl::get('annuaire||getAnnuaireEcole', array('ecole' => $rEcole->numero)), 'txt' => CopixCustomI18N::get('annuaire|annuaire.back%%structure%%', array('catalog' => $vocabularyCatalog->id_vc)));
     }
     if (CopixConfig::exists('|can_annuaire_menu') && !CopixConfig::get('|can_annuaire_menu')) {
         $menu = array();
     }
     $tpl->assign('MENU', $menu);
     $tpl->assign("MAIN", $main);
     if ($iPopup) {
         $ppo = new CopixPPO();
         $ppo->fiche = $fiche;
         $ppo->TITLE = $title;
         return _arPPO($ppo, array('template' => 'fiche_popup.tpl', 'mainTemplate' => 'main|main_fancy.php'));
     }
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processGo()
 {
     $ppo = new CopixPPO();
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login')));
     }
     $user = _currentUser();
     $ppo->ceriseprim_url = '';
     $ppo->ceriseprim_admin = '';
     if (preg_match("/^(?P<node_type>[\\w_]+)-(?P<node_id>\\d+)\$/", _request("id"), $regs)) {
         if ($regs['node_type'] == "BU_ECOLE" || $regs['node_type'] == "BU_CLASSE") {
             if ($regs['node_type'] == "BU_ECOLE") {
                 $sql = "\n                        SELECT *\n                        FROM kernel_bu_ecole\n                        WHERE numero=:id\n                    ";
                 $params = array(':id' => $regs['node_id']);
             }
             if ($regs['node_type'] == "BU_CLASSE") {
                 $sql = "\n                        SELECT kernel_bu_ecole.RNE\n                        FROM kernel_bu_ecole\n                        JOIN kernel_bu_ecole_classe ON kernel_bu_ecole.numero=kernel_bu_ecole_classe.ecole\n                        WHERE kernel_bu_ecole_classe.id=:id\n                    ";
                 $params = array(':id' => $regs['node_id']);
             }
             $ecoles_list = _doQuery($sql, $params);
             if (count($ecoles_list)) {
                 $url = CopixConfig::get('default|conf_Ceriseprim_url') . "/" . $ecoles_list[0]->RNE . "/ico.php?user=personnel-" . $user->getExtra('id') . "&date=" . date('Y-m-d') . "&key=" . md5($ecoles_list[0]->RNE . "personnel-" . $user->getExtra('id') . date('Y-m-d') . CopixConfig::get('default|conf_Ceriseprim_secret'));
                 $ppo->ceriseprim_url = $url;
                 if ($regs['node_type'] == "BU_ECOLE") {
                     $mynodes = Kernel::getMyNodes();
                     foreach ($mynodes as $node) {
                         if ($node->type == $regs['node_type'] && $node->id == $regs['node_id'] && $node->droit >= 70) {
                             $ppo->ceriseprim_admin = CopixConfig::get('default|conf_Ceriseprim_url') . "/support/iconito/updateIconito.php?rne=" . $ecoles_list[0]->RNE;
                         }
                     }
                 }
             }
         }
     }
     return _arPPO($ppo, 'default.tpl');
 }
 public function getUserInfo($type = "ME", $id = 0, $options = array())
 {
     //Kernel::deb("getUserInfo / type=$type / id=$id");
     $user = $users = array();
     switch ($type) {
         case "ID":
             $user_dao = _dao("kernel|kernel_bu2user");
             $users = $user_dao->getByUserID($id);
             break;
         case "LOGIN":
             $user_dao = _dao("kernel|kernel_bu2user");
             $users = $user_dao->getByLogin($id);
             break;
         case "ME":
             if (Kernel::is_connected()) {
                 return Kernel::getUserInfo(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
             }
         default:
             $user_dao = _dao("kernel|kernel_bu2user");
             $users = $user_dao->getByBUID($type, $id);
             if (count($users)) {
                 $users[0]->bu_type = $type;
                 $users[0]->bu_id = $id;
             } else {
                 if (!isset($options['strict']) || $options['strict']) {
                     // Si pas strict
                     $record = _record("kernel|kernel_bu2user");
                     $record->bu_type = $type;
                     $record->bu_id = $id;
                     $record->user_id = '';
                     $record->user_login = '';
                     $users = array();
                     $users[0] = $record;
                 }
             }
             break;
     }
     if (!sizeof($users)) {
         if (isset($options['strict']) && $options['strict']) {
             return false;
         }
         return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $type . ' ' . $id, 'login' => '', 'ALL' => null));
     } else {
         $userval = $users[0];
         $user["type"] = $users[0]->bu_type;
         $user["id"] = $users[0]->bu_id;
         if (isset($users[0]->user_id)) {
             $user["user_id"] = $users[0]->user_id;
         }
         if (isset($users[0]->user_login)) {
             $user["login"] = $users[0]->user_login;
         }
         switch ($userval->bu_type) {
             case "USER_VIL":
             case "USER_ENS":
             case "USER_ADM":
                 $pers_dao = _dao("kernel|kernel_bu_personnel");
                 $personne = $pers_dao->get($userval->bu_id);
                 if (!$personne) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $personne->pers_nom;
                 $user["prenom"] = $personne->pers_prenom1;
                 $user["civilite"] = $personne->pers_civilite;
                 $user["sexe"] = $personne->pers_id_sexe;
                 $user["cle_privee"] = $personne->pers_cle_privee;
                 $user["ALL"] = $personne;
                 $pers_entite_dao = _dao("kernel|kernel_bu_personnel_entite");
                 $pers_entites = $pers_entite_dao->getById($userval->bu_id);
                 foreach ($pers_entites as $key => $value) {
                     switch ($value->pers_entite_type_ref) {
                         case "VILLE":
                             $user["link"]->ville[$value->pers_entite_reference] = $value->pers_entite_role;
                             break;
                         case "ECOLE":
                             $user["link"]->ecole[$value->pers_entite_reference] = $value->pers_entite_role;
                             break;
                         case "CLASSE":
                             $user["link"]->classe[$value->pers_entite_reference] = $value->pers_entite_role;
                             break;
                     }
                 }
                 break;
             case "USER_ELE":
                 $ele_dao = _dao("kernel|kernel_bu_ele");
                 $eleve = $ele_dao->get($userval->bu_id);
                 if (!$eleve) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $eleve->ele_nom;
                 $user["prenom"] = $eleve->ele_prenom1;
                 $user["civilite"] = $eleve->ele_civilite;
                 $user["sexe"] = $eleve->ele_id_sexe;
                 $user["ALL"] = $eleve;
                 $parents = Kernel::getNodeParents("USER_ELE", $userval->bu_id);
                 foreach ($parents as $key => $value) {
                     switch ($value['type']) {
                         case "BU_CLASSE":
                             $user["link"]->classe[$value['id']] = 1;
                             if (isset($value['ALL'])) {
                                 $user["link"]->ecole[$value['ALL']->cla_ecole] = 1;
                                 $user["link"]->ville[$value['ALL']->eco_id_ville] = 1;
                             }
                             if (isset($options['link_data']) && $options['link_data']) {
                                 $user["link_data"]->classe[$value['id']] = Kernel::getNodeInfo("BU_CLASSE", $value['id'], true);
                             }
                             break;
                     }
                 }
                 break;
             case "USER_RES":
                 $res_dao = _dao("kernel|kernel_bu_res");
                 $reponsable = $res_dao->get($userval->bu_id);
                 if (!$reponsable) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $reponsable->res_nom;
                 $user["prenom"] = $reponsable->res_prenom1;
                 $user["civilite"] = $reponsable->res_civilite;
                 $user["sexe"] = $reponsable->res_id_sexe;
                 $user["ALL"] = $reponsable;
                 $user['link'] = array();
                 $parents = Kernel::getNodeParents("USER_RES", $userval->bu_id);
                 foreach ($parents as $parent) {
                     switch ($parent['type']) {
                         case "USER_ELE":
                             if (isset($parent['link'])) {
                                 foreach ($parent['link'] as $nodeType => $nodeValue) {
                                     if (!isset($user['link'][$nodeType])) {
                                         $user['link'][$nodeType] = array();
                                     }
                                     foreach ($nodeValue as $id => $value) {
                                         $user['link'][$nodeType][$id] = $value;
                                     }
                                 }
                             }
                             break;
                     }
                 }
                 break;
             case "USER_EXT":
                 $ext_dao = _dao("kernel|kernel_ext_user");
                 $extuser = $ext_dao->get($userval->bu_id);
                 if (!$extuser) {
                     return array_merge($user, array('nom' => 'Utilisateur inconnu', 'prenom' => $userval->bu_type . ' ' . $userval->bu_id, 'ALL' => null));
                 }
                 $user["nom"] = $extuser->ext_nom;
                 $user["prenom"] = $extuser->ext_prenom;
                 $user["ALL"] = $extuser;
                 $user['link'] = array();
                 $parents = Kernel::getNodeParents("USER_EXT", $userval->bu_id);
                 foreach ($parents as $parent) {
                     if (!isset($user['link'][$parent['type']])) {
                         $user['link'][$parent['type']] = array();
                     }
                     $user['link'][$parent['type']][$parent['id']] = $parent['droit'];
                 }
                 break;
             default:
                 break;
         }
         // switch( $userval->bu_type )
         // } // foreach( $users as $key => $userval )
     }
     // if( sizeof( $users ) )
     return $user;
 }
 /**
  * Affichage de l'annuaire en version popup
  *
  * Affiche les discussions d'un forum et les informations sur les discussions (titre, dernier message...), avec un lien pour lire chaque discussion.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/18
  */
 public function getPopup()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('annuaire|annuaire.error.noLogged'), 'back' => CopixUrl::get('||')));
     }
     CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire_popup.js"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.tablesorter.min.js"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.metadata.js"));
     CopixHTMLHeader::addCSSLink(_resource("js/jquery/css/jquery.tablesorter.css"));
     $grville = _request('grville') ? _request('grville') : NULL;
     $ville = _request('ville') ? _request('ville') : NULL;
     $ecole = _request('ecole') ? _request('ecole') : NULL;
     $classe = _request('classe') ? _request('classe') : NULL;
     $field = _request('field') ? _request('field') : '';
     $profils = _request('profils') ? _request('profils') : array();
     $profil = $this->getRequest('profil');
     // Si on force sur un profil unique a afficher
     $ALL = CopixConfig::get('annuaire|annu_combo_all');
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     // Annuaire par défaut, on regarde sa session
     if (!$classe && !$ecole && !$ville) {
         $home = $annuaireService->getAnnuaireHome();
         //print_r($home);
         switch ($home['type']) {
             case 'BU_GRVILLE':
                 $grville = $home['id'];
                 $ville = $ALL;
                 $ecole = $ALL;
                 $classe = $ALL;
                 break;
             case 'BU_VILLE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 if ($info) {
                     $grville = $info['ALL']->vil_id_grville;
                 }
                 $ville = $home['id'];
                 $ecole = $ALL;
                 $classe = $ALL;
                 break;
             case 'BU_ECOLE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 if ($info) {
                     $grville = $info['ALL']->vil_id_grville;
                     $ville = $info['ALL']->eco_id_ville;
                 }
                 $ecole = $home['id'];
                 $classe = $ALL;
                 break;
             case 'BU_CLASSE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 //_dump($info);
                 if ($info) {
                     $grville = $info['parent']['ALL']->vil_id_grville;
                     $ville = $info['parent']['ALL']->eco_id_ville;
                     $ecole = $info['parent']['id'];
                 }
                 $classe = $home['id'];
                 //echo "grville=$grville / ville=$ville / ecole=$ecole / classe=$classe";
                 break;
         }
     }
     $comboEcoles = $comboClasses = true;
     // On force les valeurs des combos
     if ($profil) {
         switch ($profil) {
             case 'USER_VIL':
                 $comboEcoles = $comboClasses = false;
                 $ecole = $classe = $ALL;
                 break;
         }
     }
     $matrix =& enic::get('matrixCache');
     $helper =& enic::get('matrixHelpers');
     $right = _request('right', 'voir');
     // voir ou communiquer
     $iCan = 'communiquer' == $right ? 'iCanTalkToThisType' : 'iCanSeeThisType';
     $tplListe = new CopixTpl();
     $visib = array('USER_ELE' => $helper->{$iCan}('USER_ELE'), 'USER_ENS' => $helper->{$iCan}('USER_ENS') || $helper->{$iCan}('USER_DIR'), 'USER_RES' => $helper->{$iCan}('USER_RES'), 'USER_EXT' => $helper->{$iCan}('USER_EXT'), 'USER_ADM' => $helper->{$iCan}('USER_ADM'), 'USER_VIL' => $helper->{$iCan}('USER_VIL'));
     //_dump($visib);
     $debug = false;
     $start = microtime(true);
     $tplListe->assign('combogrvilles', CopixZone::process('annuaire|combogrvilles', array('droit' => $right, 'value' => $grville, 'fieldName' => 'grville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_grville(this,this.form);"', 'linesSup' => array())));
     if ($debug) {
         echo "combogrvilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
     }
     $start = microtime(true);
     $tplListe->assign('combovilles', CopixZone::process('annuaire|combovilles', array('droit' => $right, 'grville' => $grville, 'value' => $ville, 'fieldName' => 'ville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ville(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllVilles'))))));
     if ($debug) {
         echo "combovilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
     }
     $start = microtime(true);
     if ($ville == $ALL && $comboEcoles) {
         $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles'))))));
         if ($debug) {
             echo "comboecolesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($comboEcoles) {
         $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesinville', array('droit' => $right, 'ville' => $ville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles'))))));
         if ($debug) {
             echo "comboecolesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     }
     $start = microtime(true);
     if ($ville == $ALL && $ecole == $ALL && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($ecole == $ALL && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinville', array('droit' => $right, 'ville' => $ville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($ecole && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinecole', array('droit' => $right, 'ecole' => $ecole, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesinecole " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboempty', array('fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"')));
         if ($debug) {
             echo "comboempty " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     }
     if ($ville_as_array = Kernel::getKernelLimits('ville_as_array')) {
         // Limitation par URL, on verifie les parametres
         if ($ville && $ville != $ALL && !in_array($ville, $ville_as_array)) {
             $ville = 0;
         }
         if ($ecole && $ecole != $ALL && ($rEcole = Kernel::getNodeInfo('BU_ECOLE', $ecole, false)) && !in_array($rEcole['ALL']->vil_id_grville, $ville_as_array)) {
             $ecole = 0;
         }
         if ($classe && $classe != $ALL && ($rClasse = Kernel::getNodeInfo('BU_CLASSE', $classe, false)) && !in_array($rClasse['ALL']->eco_id_ville, $ville_as_array)) {
             $classe = 0;
         }
     }
     //kernel::myDebug ("grville=$grville / ville=$ville / ecole=$ecole / classe=$classe");
     //kernel::myDebug ($profils);
     if ($classe && $classe !== $ALL) {
         // Une classe précise
         $visib['USER_ELE'] = $matrix->classe($classe)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->classe($classe)->_right->USER_ENS->{$right} || $matrix->classe($classe)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->classe($classe)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->classe($classe)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->classe($classe)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->classe($classe)->_right->USER_VIL->{$right};
     } elseif ($ecole && $classe == $ALL && $ecole !== $ALL) {
         // Une école
         $visib['USER_ELE'] = $matrix->ecole($ecole)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->ecole($ecole)->_right->USER_ENS->{$right} || $matrix->ecole($ecole)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->ecole($ecole)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->ecole($ecole)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->ecole($ecole)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->ecole($ecole)->_right->USER_VIL->{$right};
     } elseif ($ville && $classe == $ALL && $ecole == $ALL && $ville !== $ALL) {
         // Une ville
         $visib['USER_ELE'] = $matrix->ville($ville)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->ville($ville)->_right->USER_ENS->{$right} || $matrix->ville($ville)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->ville($ville)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->ville($ville)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->ville($ville)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->ville($ville)->_right->USER_VIL->{$right};
     } elseif ($grville && $classe == $ALL && $ecole == $ALL && $ville == $ALL) {
         // Un groupe de villes
         $visib['USER_ELE'] = $matrix->grville($grville)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->grville($grville)->_right->USER_ENS->{$right} || $matrix->grville($grville)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->grville($grville)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->grville($grville)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->grville($grville)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->grville($grville)->_right->USER_VIL->{$right};
     }
     //_dump($visib);
     // Si on restreint a un profil
     if ($profil && $visib[$profil]) {
         switch ($profil) {
             case 'USER_VIL':
                 $profils = array();
                 $profils['VIL'] = 1;
                 break;
         }
     }
     if (!$profils && $visib['USER_ELE']) {
         $profils['ELE'] = 1;
     } elseif (!$profils && $visib['USER_ENS']) {
         $profils['PEC'] = 1;
     } elseif (!$profils && $visib['USER_RES']) {
         $profils['PAR'] = 1;
     } elseif (!$profils && $visib['USER_EXT']) {
         $profils['EXT'] = 1;
     } elseif (!$profils && $visib['USER_ADM']) {
         $profils['ADM'] = 1;
     } elseif (!$profils && $visib['USER_VIL']) {
         $profils['VIL'] = 1;
     }
     //kernel::myDebug($visib);
     // =============== ELEVES =========================
     $eleves = array();
     if (isset($profils['ELE']) && $grville && $ville && $ecole && $classe && $visib['USER_ELE']) {
         if ($classe != $ALL) {
             // Une classe précise
             $eleves = $annuaireService->getEleves('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les eleves d'une école
             $eleves = $annuaireService->getEleves('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les eleves d'une ville
             $eleves = $annuaireService->getEleves('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les eleves d'un groupe de villes
             $eleves = $annuaireService->getEleves('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL =========================
     $personnel = array();
     if (isset($profils['PEC']) && $grville && $ville && $ecole && $classe && $visib['USER_ENS']) {
         if ($classe != $ALL) {
             // Une classe précise
             $personnel = $annuaireService->getPersonnel('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les classes d'une école
             $personnel = $annuaireService->getPersonnel('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $personnel = $annuaireService->getPersonnel('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $personnel = $annuaireService->getPersonnel('BU_GRVILLE', $grville);
         }
     }
     // =============== PARENTS =========================
     $parents = array();
     if (isset($profils['PAR']) && $grville && $ville && $ecole && $classe && $visib['USER_RES']) {
         if ($classe != $ALL) {
             // Une classe précise
             $parents = $annuaireService->getParents('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les classes d'une école
             $parents = $annuaireService->getParents('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $parents = $annuaireService->getParents('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $parents = $annuaireService->getParents('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL ADMINISTRATIF =========================
     $adm = array();
     if (isset($profils['ADM']) && $grville && $ville && $ecole && $classe && $visib['USER_ADM']) {
         if (($classe != $ALL || $classe == $ALL) && $ecole != $ALL) {
             // Les classes d'une école
             $adm = $annuaireService->getPersonnelAdm('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $adm = $annuaireService->getPersonnelAdm('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $adm = $annuaireService->getPersonnelAdm('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL EXTERIEUR =========================
     $ext = array();
     if (isset($profils['EXT']) && $grville && $ville && $ecole && $classe && $visib['USER_EXT']) {
         $ext = $annuaireService->getPersonnelExt('ROOT', 0);
     }
     // =============== PERSONNEL VILLE =========================
     $vil = array();
     if (isset($profils['VIL']) && $grville && $ville && $visib['USER_VIL']) {
         if ($ville != $ALL) {
             // Dans une ville
             $vil = $annuaireService->getPersonnelVil('BU_VILLE', $ville);
         } elseif ($ville == $ALL) {
             // Dans un groupe de villes
             $vil = $annuaireService->getPersonnelVil('BU_GRVILLE', $grville);
         }
     }
     $droits = array('checkAll' => $annuaireService->canMakeInAnnuaire('POPUP_CHECK_ALL'));
     $users = array();
     foreach ($eleves as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($parents as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($personnel as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($adm as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($vil as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($ext as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     //_dump($eleves);
     /*
     if ('communiquer' === $right) {
         foreach ($users as $k => $user) {
             //print_r($user);
             //$matrix->communiquer();
         }
     }
     */
     usort($users, array('ActionGroupAnnuaire', '_usortPopup'));
     $tplListe->assign('field', $field);
     $tplListe->assign('grville', $grville);
     $tplListe->assign('eleves', $eleves);
     $tplListe->assign('personnel', $personnel);
     $tplListe->assign('parents', $parents);
     $tplListe->assign('ext', $ext);
     $tplListe->assign('adm', $adm);
     $tplListe->assign('vil', $vil);
     $tplListe->assign('profils', $profils);
     $tplListe->assign('droits', $droits);
     $tplListe->assign('ville', $ville);
     $tplListe->assign('ecole', $ecole);
     $tplListe->assign('classe', $classe);
     $tplListe->assign('visib', $visib);
     $tplListe->assign('profil', $profil);
     $tplListe->assign('users', $users);
     $tplListe->assign('right', $right);
     $result = $tplListe->fetch('getpopup.tpl');
     $ppo = new CopixPPO();
     $ppo->result = $result;
     $ppo->TITLE_PAGE = CopixI18N::get('annuaire|annuaire.moduleDescription');
     CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire.js"));
     return _arPPO($ppo, array('template' => 'getpopup_ppo.tpl', 'mainTemplate' => 'default|main_popup.php'));
 }
 /**
  * Gestion des droits dans un blog
  *
  * Teste si l'usager peut effectuer une certaine opération par rapport à son droit. Le droit sur le blog est calculé ou récupéré de la session dans la fonction
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/05/31
  * @param string $action Action pour laquelle on veut tester le droit
  * @param object $r L'objet sur lequel on teste le droit
  * @return bool true s'il a le droit d'effectuer l'action, false sinon
  */
 public function canMakeInBlog($action, $r)
 {
     $can = false;
     if (!$r) {
         return false;
     }
     $userInfos = BlogAuth::getUserInfos($r->id_blog);
     //print_r($userInfos);
     $droit = $userInfos->right;
     // Kernel::deb("action=$action / droit=$droit / privacy=".$r->privacy);
     switch ($action) {
         case "READ":
             $can = $droit >= $r->privacy;
             if ($r->privacy == 10 && Kernel::is_connected()) {
                 $can = true;
             }
             break;
         case "ACCESS_ADMIN":
         case "ADMIN_ARTICLES":
         case "ADMIN_PHOTOS":
         case "ADMIN_DOCUMENTS":
             $can = $droit >= PROFILE_CCV_VALID;
             break;
         case "ADMIN_CATEGORIES":
         case "ADMIN_COMMENTS":
         case "ADMIN_LIENS":
         case "ADMIN_PAGES":
         case "ADMIN_RSS":
         case "ADMIN_ARTICLE_MAKE_ONLINE":
         case "ADMIN_ARTICLE_DELETE":
             $can = $droit >= PROFILE_CCV_MODERATE;
             //$can = false;
             break;
         case "ADMIN_OPTIONS":
         case "ADMIN_DROITS":
         case "ADMIN_STATS":
             $can = $droit >= PROFILE_CCV_ADMIN;
             break;
     }
     return $can;
 }
 /**
  * Effectue une demande d'inscription � un groupe pour l'utilisateur courant
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/16
  * @param integer $id Id du groupe
  */
 public function doJoin()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login')));
     }
     $dao = CopixDAOFactory::create("groupe");
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     $minimail_service =& CopixClassesFactory::Create('minimail|minimailservice');
     $groupeService =& CopixClassesFactory::Create('groupe|groupeService');
     $id = $this->getRequest('id', null);
     $errors = $oks = array();
     $groupe = $dao->getGroupe($id);
     if (!$groupe) {
         $errors[] = CopixI18N::get('groupe|groupe.error.noGroup');
     } elseif (!$groupe[0]->is_open) {
         $errors[] = CopixI18N::get('groupe|groupe.error.private');
     }
     $mondroit = $kernel_service->getLevel("CLUB", $id);
     if ($mondroit) {
         $errors[] = CopixI18N::get('groupe|groupe.error.alreadyMember');
     }
     if ($errors) {
         if (!CopixConfig::exists('|can_group_showlist') || CopixConfig::get('|can_group_showlist')) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('groupe||getListPublic')));
         } else {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('||')));
         }
     } else {
         $kernel_service->setLevel("CLUB", $id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'), PROFILE_CCV_SHOW);
         CopixCache::clear(_currentUser()->getExtra('type') . '-' . _currentUser()->getExtra('id'), 'getnodeparents');
         CopixCache::clear(_currentUser()->getExtra('type') . '-' . _currentUser()->getExtra('id'), 'getmynodes');
         // On r�cup�re le propri�taire, afin de lui envoyer un message
         $childs = $kernel_service->getNodeChilds("CLUB", $id);
         $trouve = false;
         foreach ($childs as $child) {
             if ($trouve) {
                 continue;
             }
             if ($groupeService->canMakeInGroupe('ADMIN', $child["droit"])) {
                 // Propri�taire trouv� !
                 $trouve = $child;
             }
         }
         //var_dump($trouve);
         /*
         while (!$trouve && list(,$child)=each($childs)) {
         if ($groupeService->canMakeInGroupe('ADMIN',$child["droit"])) // Propri�taire trouv� !
         $trouve = $child;
         }
         */
         if ($trouve) {
             $userInfo = $kernel_service->getUserInfo($trouve["type"], $trouve["id"]);
             //print_r2($userInfo);
             if ($userInfo && $userInfo["user_id"]) {
                 $his_nom = _currentUser()->getExtra('prenom') . " " . _currentUser()->getExtra('nom') . " (" . _currentUser()->getExtra('type') . ")";
                 $msg_from_login = _currentUser()->getLogin();
                 $msg_title = CopixI18N::get('groupe|groupe.msgJoin.title', array($groupe[0]->titre));
                 $format = CopixConfig::get('minimail|default_format');
                 if ($format == 'dokuwiki' || $format == 'wiki') {
                     $msg_body = CopixI18N::get('groupe|groupe.msgJoin.body', array(CopixUrl::get('groupe||getHomeAdminMembers', array("id" => $id)), $his_nom));
                     $msg_body = str_replace("\\n", "\n", $msg_body);
                 } else {
                     $msg_body = CopixI18N::get('groupe|groupe.msgJoin.bodyHtml', array(CopixUrl::get('groupe||getHomeAdminMembers', array("id" => $id)), $his_nom));
                 }
                 //print_r($msg_body);
                 //die();
                 $msg_from_id = _currentUser()->getId();
                 $msg_destin = array($userInfo["user_id"] => 1);
                 $send = $minimail_service->sendMinimail($msg_title, $msg_body, $msg_from_id, $msg_destin, $format);
                 if ($send) {
                     $oks[] = CopixI18N::get('groupe|groupe.msgJoin.Ok');
                 } else {
                     $errors[] = CopixI18N::get('groupe|groupe.error.sendJoin');
                 }
             } else {
                 $errors[] = CopixI18N::get('groupe|groupe.error.owner');
             }
         } else {
             // Pas de proprio, c'est pas normal
             $errors[] = CopixI18N::get('groupe|groupe.error.noOwner');
         }
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $groupe[0]->titre);
         // $tpl->assign ('MENU', '<a href="'.CopixUrl::get ('groupe||getListPublic').'">'.CopixI18N::get ('groupe|groupe.annuaire').'</a> :: <a href="'.CopixUrl::get ('groupe||getListMy').'">'.CopixI18N::get ('groupe|groupe.my').'</a>');
         $tplHome = new CopixTpl();
         $tplHome->assign('groupe', $groupe[0]);
         $tplHome->assign('errors', $errors);
         $tplHome->assign('oks', $oks);
         if (!CopixConfig::exists('|can_group_showlist') || CopixConfig::get('|can_group_showlist')) {
             $tplHome->assign('can_group_showlist', 1);
         } else {
             $tplHome->assign('can_group_showlist', 0);
         }
         $result = $tplHome->fetch('dojoin.tpl');
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }