public function getRessources($id)
 {
     // $id = id de l'école
     if (!$this->testAccess()) {
         return '';
     }
     //connect to soap service
     $client = new SoapClient("http://www.kiosque-edu.com/knewebservice2/knews.asmx?WSDL", array('exceptions' => FALSE));
     //get school infos (for RNE)
     $school = $this->db->query('SELECT * FROM kernel_bu_ecole WHERE numero = ' . (int) $id)->toArray1();
     if (empty($school) || empty($school['RNE'])) {
         return '';
     }
     $params->RNE = $school['RNE'];
     $params->Profil = utf8_encode($this->user->type == 'USER_ELE' ? 'Elève' : $this->user->type == 'USER_DIR' ? 'Direction' : $this->user->type == 'USER_ENS' ? 'Enseignant' : 'Demo');
     // DEBUG: on force à élève
     // $params->Profil = utf8_encode('Elève');
     //get all user parent's nodes (for classe)
     $userNode = Kernel::getNodeParents($this->user->type, $this->user->idEn);
     $classId = null;
     foreach ($userNode as $node) {
         if ($node['type'] == 'BU_CLASSE') {
             $classId = (int) $node['id'];
             break;
         }
     }
     if (empty($classId)) {
         return '';
     }
     $params->Classe = $classId;
     $params->IDUser = $this->user->idEn . '@' . $params->RNE;
     $params->hash = md5($params->IDUser . $params->RNE . 'ENT');
     $result = $client->AccesENT($params);
     // _dump($result);
     if (is_a($result, 'SoapFault')) {
         return 'confError';
     }
     if (0 == count($result->AccesENTResult)) {
         return 'confError';
     }
     $ressources = array();
     if (isset($result->AccesENTResult->InfoRessource)) {
         if (is_object($result->AccesENTResult->InfoRessource)) {
             $ressources[] = $result->AccesENTResult->InfoRessource;
         } else {
             foreach ($result->AccesENTResult->InfoRessource as $ressource) {
                 $ressources[] = $ressource;
             }
         }
     }
     return $ressources;
 }
 public function processDefault()
 {
     $ppo = new CopixPPO();
     // Le KNE est activé sur une classe, il nous faut son école
     $classId = (int) $this->request('id_classe');
     $parent = Kernel::getNodeParents('BU_CLASSE', $classId);
     if ($parent[0] && $parent[0]['type'] == 'BU_ECOLE') {
         $schoolId = (int) $parent[0]['id'];
     } else {
         $schoolId = null;
     }
     $KneRessources = $this->service('KneService')->getRessources($schoolId);
     $ppo->ressources = $KneRessources;
     return _arPPO($ppo, 'default.tpl');
 }
 /**
  * Met à jour les données de la base. Complete les parents pour les modules dont ils ne sont pas renseignes
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/06/12
  * @return mixed TODO
  */
 public function updateCron()
 {
     // On prend les modules orphelins
     $sql = "SELECT DISTINCT(module_type) AS module_type, module_id FROM module_stats_logs WHERE (parent_type IS NULL OR parent_id IS NULL) AND module_type IN ('MOD_GROUPE')";
     //Kernel::deb ($sql);
     $list = _doQuery($sql);
     $i = 0;
     foreach ($list as $e) {
         if ($e->module_type == 'MOD_GROUPE') {
             $mod = 'CLUB';
         } else {
             $mod = $e->module_type;
         }
         $parent = Kernel::getNodeParents($mod, $e->module_id);
         if ($parent) {
             //Kernel::deb ($sql);
             $sql = "UPDATE module_stats_logs SET parent_type=:parent_type, parent_id=:parent_id WHERE module_type=:module_type AND module_id=:module_id";
             _doQuery($sql, array(':parent_type' => $parent[0]['type'], ':parent_id' => $parent[0]['id'], ':module_type' => $e->module_type, ':module_id' => $e->module_id));
         }
         //print_r($parent);
         $i++;
     }
     Kernel::deb("{$i} mises à jour");
 }
 public function whereAmI($node_type = false, $node_id = false)
 {
     // Patch EN2010
     return array();
     $where = array();
     if ($node_type == 'BU_CLASSE') {
         $where['BU_CLASSE']['type'] = $node_type;
         $where['BU_CLASSE']['id'] = $node_id;
         $infos = Kernel::getNodeInfo($node_type, $node_id);
         $where['BU_CLASSE']['nom'] = $infos['nom'];
         $parents = Kernel::getNodeParents($node_type, $node_id);
         $parent = Kernel::filterNodeList($parents, 'BU_ECOLE');
         $node_type = $parent[0]["type"];
         $node_id = $parent[0]["id"];
     }
     if ($node_type == 'BU_ECOLE') {
         $where['BU_ECOLE']['type'] = $node_type;
         $where['BU_ECOLE']['id'] = $node_id;
         $infos = Kernel::getNodeInfo($node_type, $node_id);
         $where['BU_ECOLE']['nom'] = $infos['nom'];
         $parents = Kernel::getNodeParents($node_type, $node_id);
         $parent = Kernel::filterNodeList($parents, 'BU_VILLE');
         $node_type = $parent[0]["type"];
         $node_id = $parent[0]["id"];
     }
     if ($node_type == 'BU_VILLE') {
         $where['BU_VILLE']['type'] = $node_type;
         $where['BU_VILLE']['id'] = $node_id;
         $infos = Kernel::getNodeInfo($node_type, $node_id);
         $where['BU_VILLE']['nom'] = $infos['nom'];
         $parents = Kernel::getNodeParents($node_type, $node_id);
         $parent = Kernel::filterNodeList($parents, 'BU_GRVILLE');
         $node_type = $parent[0]["type"];
         $node_id = $parent[0]["id"];
     }
     if ($node_type == 'BU_GRVILLE') {
         $where['BU_GRVILLE']['type'] = $node_type;
         $where['BU_GRVILLE']['id'] = $node_id;
         $infos = Kernel::getNodeInfo($node_type, $node_id);
         $where['BU_GRVILLE']['nom'] = $infos['nom'];
     }
     return $where;
 }
 /**
  * Affichage d'un annuaire de classe
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/18
  * @param integer $classe Id de la classe
  */
 public function getAnnuaireClasse()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('annuaire|annuaire.error.noLogged'), 'back' => CopixUrl::get('||')));
     }
     $classe = _request("classe") ? _request("classe") : NULL;
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     $criticErrors = array();
     $rClasse = Kernel::getNodeInfo('BU_CLASSE', $classe, false);
     $matrix =& enic::get('matrixCache');
     if (!$rClasse) {
         $criticErrors[] = CopixI18N::get('annuaire|annuaire.error.noClasse');
     } elseif (!$matrix->classe($classe)->_right->count->voir > 0) {
         $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('annuaire||')));
     }
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_fichesecoles.js');
     // Si c'est le détail d'une classe, on en déduit l'école
     $parent = Kernel::getNodeParents('BU_CLASSE', $classe);
     if ($parent[0]['type'] == 'BU_ECOLE') {
         $ecole = $parent[0]['id'];
     }
     $rEcole = Kernel::getNodeInfo('BU_ECOLE', $ecole, false);
     // Blog de l'école
     $blog = getNodeBlog('BU_ECOLE', $ecole, array('is_public' => 1));
     if ($blog) {
         $rEcole['blog'] = CopixUrl::get('blog||', array('blog' => $blog->url_blog));
     }
     $tplListe = new CopixTpl();
     $tplListe->assign('infosecole', CopixZone::process('annuaire|infosecole', array('rEcole' => $rEcole)));
     $tplListe->assign('infosclasse', CopixZone::process('annuaire|infosclasse', array('rClasse' => $rClasse)));
     $tplListe->assign('classe', $rClasse);
     $result = $tplListe->fetch('getannuaireclasse.tpl');
     //print_r($rEcole);
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', $rClasse["nom"]);
     $menu = array();
     if (!CopixConfig::exists('|can_group_showlist') || CopixConfig::get('|can_group_showlist')) {
         $menu[] = array('txt' => CopixI18N::get('groupe|groupe.annuaire'), 'url' => CopixUrl::get('groupe||getListPublic'), 'size' => '110');
     }
     $menu[] = array('txt' => CopixI18N::get('public|public.blog.annuaire'), 'url' => CopixUrl::get('public||getListBlogs'));
     $menu[] = array('txt' => CopixI18N::get('annuaire|annuaire.backEcole'), 'url' => CopixUrl::get('|getAnnuaireEcole', array('ecole' => $ecole)));
     $menu[] = array('txt' => CopixI18N::get('annuaire|annuaire.backVille'), 'url' => CopixUrl::get('|getAnnuaireVille', array('ville' => $rEcole['ALL']->vil_id_vi)));
     if (CopixConfig::exists('|can_annuaire_menu') && !CopixConfig::get('|can_annuaire_menu')) {
         $menu = array();
     }
     $tpl->assign('MENU', $menu);
     $tpl->assign('MAIN', $result);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * getNode
  *
  * Affiche les informations d'un noeud et les utilisateurs qui y sont attachés.
  * @author	Frédéric Mossmann
  * @since	09.02.2006
  *
  */
 public function getNode()
 {
     if (CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled')) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('gestionautonome|default|showTree', array('type' => 'ROOT')));
     }
     $tpl = new CopixTpl();
     $tplGetNode = new CopixTpl();
     $pType = _request("type", 'ROOT');
     $pId = _request("id");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getnode'));
     $petitpoucet = array();
     $droit = 0 + Kernel::getLevel($pType, $pId);
     switch ($pType) {
         case 'ROOT':
             $pId = 0;
             // ROOT
             $petitpoucet[] = array('txt' => 'Root');
             $childs = Kernel::getNodeChilds($pType, $pId);
             $childs = Kernel::filterNodeList($childs, 'USER_*');
             break;
         case 'BU_GRVILLE':
             $infos = Kernel::getNodeInfo($pType, $pId, false);
             // ROOT
             $petitpoucet[] = array('txt' => 'Root', 'url' => CopixUrl::get('comptes||getNode', array('type' => 'ROOT')));
             // BU_GRVILLE
             $petitpoucet[] = array('txt' => $infos['nom']);
             // Liste des "BU_VILLE"
             $childs = Kernel::getNodeChilds($pType, $pId);
             $childs = Kernel::filterNodeList($childs, 'USER_*');
             $droit = max($droit, Kernel::getLevel('ROOT', 0));
             break;
         case 'BU_VILLE':
             $infos = Kernel::getNodeInfo($pType, $pId, false);
             // Recherche des parents
             $parents = Kernel::getNodeParents($pType, $pId);
             $parent_grville = Kernel::filterNodeList($parents, 'BU_GRVILLE');
             // ROOT
             $petitpoucet[] = array('txt' => 'Root', 'url' => CopixUrl::get('comptes||getNode', array('type' => 'ROOT')));
             // BU_GRVILLE
             $petitpoucet[] = array('txt' => $parent_grville[0]['nom'], 'url' => CopixUrl::get('comptes||getNode', array('type' => $parent_grville[0]['type'], 'id' => $parent_grville[0]['id'])));
             // BU_VILLE
             $petitpoucet[] = array('txt' => $infos['nom']);
             // Liste des "BU_VILLE"
             $childs = Kernel::getNodeChilds($pType, $pId);
             $childs = Kernel::filterNodeList($childs, 'USER_*');
             $droit = max($droit, Kernel::getLevel('BU_GRVILLE', $parent_grville[0]["id"]));
             $droit = max($droit, Kernel::getLevel('ROOT', 0));
             break;
         case 'BU_ECOLE':
             $infos = Kernel::getNodeInfo($pType, $pId, false);
             // Recherche des parents
             $parents = Kernel::getNodeParents($pType, $pId);
             $parent_ville = Kernel::filterNodeList($parents, 'BU_VILLE');
             $parents = Kernel::getNodeParents($parent_ville[0]["type"], $parent_ville[0]["id"]);
             $parent_grville = Kernel::filterNodeList($parents, 'BU_GRVILLE');
             // ROOT
             $petitpoucet[] = array('txt' => 'Root', 'url' => CopixUrl::get('comptes||getNode', array('type' => 'ROOT')));
             // BU_GRVILLE
             $petitpoucet[] = array('txt' => $parent_grville[0]['nom'], 'url' => CopixUrl::get('comptes||getNode', array('type' => $parent_grville[0]['type'], 'id' => $parent_grville[0]['id'])));
             // BU_VILLE
             $petitpoucet[] = array('txt' => $parent_ville[0]['nom'], 'url' => CopixUrl::get('comptes||getNode', array('type' => $parent_ville[0]['type'], 'id' => $parent_ville[0]['id'])));
             // BU_ECOLE
             $petitpoucet[] = array('txt' => $infos['nom']);
             // Liste des "BU_VILLE"
             $childs = Kernel::getNodeChilds($pType, $pId);
             $childs = Kernel::filterNodeList($childs, 'USER_*');
             $droit = max($droit, Kernel::getLevel('BU_VILLE', $parent_ville[0]["id"]));
             $droit = max($droit, Kernel::getLevel('BU_GRVILLE', $parent_grville[0]["id"]));
             $droit = max($droit, Kernel::getLevel('ROOT', 0));
             break;
         case 'BU_CLASSE':
             $infos = Kernel::getNodeInfo($pType, $pId, false);
             // Recherche des parents
             $parents = Kernel::getNodeParents($pType, $pId);
             $parent_ecole = Kernel::filterNodeList($parents, 'BU_ECOLE');
             $parents = Kernel::getNodeParents($parent_ecole[0]["type"], $parent_ecole[0]["id"]);
             $parent_ville = Kernel::filterNodeList($parents, 'BU_VILLE');
             $parents = Kernel::getNodeParents($parent_ville[0]["type"], $parent_ville[0]["id"]);
             $parent_grville = Kernel::filterNodeList($parents, 'BU_GRVILLE');
             // ROOT
             $petitpoucet[] = array('txt' => 'Root', 'url' => CopixUrl::get('comptes||getNode', array('type' => 'ROOT')));
             // BU_GRVILLE
             $petitpoucet[] = array('txt' => $parent_grville[0]['nom'], 'url' => CopixUrl::get('comptes||getNode', array('type' => $parent_grville[0]['type'], 'id' => $parent_grville[0]['id'])));
             // BU_VILLE
             $petitpoucet[] = array('txt' => $parent_ville[0]['nom'], 'url' => CopixUrl::get('comptes||getNode', array('type' => $parent_ville[0]['type'], 'id' => $parent_ville[0]['id'])));
             // BU_ECOLE
             $petitpoucet[] = array('txt' => $parent_ecole[0]['nom'], 'url' => CopixUrl::get('comptes||getNode', array('type' => $parent_ecole[0]['type'], 'id' => $parent_ecole[0]['id'])));
             // BU_CLASSE
             $petitpoucet[] = array('txt' => $infos['nom']);
             // Liste des "BU_VILLE"
             $childs = Kernel::getNodeChilds($pType, $pId);
             //print_r($childs);
             $eleves = Kernel::filterNodeList($childs, 'USER_ELE');
             foreach ($eleves as $eleve) {
                 $parents = Kernel::getNodeChilds($eleve['type'], $eleve['id']);
                 $parents = Kernel::filterNodeList($parents, 'USER_RES');
                 foreach ($parents as $parent) {
                     $childs[] = $parent;
                 }
             }
             $childs = Kernel::filterNodeList($childs, 'USER_*');
             $droit = max($droit, Kernel::getLevel('BU_ECOLE', $parent_ecole[0]["id"]));
             $droit = max($droit, Kernel::getLevel('ROOT', 0));
             break;
         default:
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('comptes.error.badnodetype'), 'back' => CopixUrl::get('||')));
             break;
     }
     // Tri par type de noeud
     // $childs = Kernel::sortNodeList( $childs, 'type', array('USER_VIL','USER_ENS','USER_ADM','USER_ELE','USER_RES','USER_EXT') );
     $childs = Kernel::sortNodeList($childs, 'comptes');
     $childs = Kernel::uniqNodeList($childs);
     // Ajoute le type d'utilisateur en toute lettres.
     foreach ($childs as $child_key => $child_val) {
         $childs[$child_key]['type_nom'] = Kernel::Code2Name($child_val['type']);
     }
     if (isset($petitpoucet)) {
         $tplGetNode->assign('PETITPOUCET', Kernel::PetitPoucet($petitpoucet, " &raquo; "));
     }
     $tplGetNode->assign('NAVIGATION', CopixZone::process('comptes|navigation'));
     if ($droit >= 70) {
         $tplGetNode->assign('MAIN', CopixZone::process('comptes|userlist', array('childs' => $childs, 'type' => $pType, 'id' => $pId)));
     } else {
         $tplGetNode->assign('MAIN', CopixI18N::get('comptes.error.badrights'));
     }
     $result = $tplGetNode->fetch("getnode.tpl");
     $menu = array();
     $session = _sessionGet('modules|comptes|doLoginCreate|success');
     if ($session && is_array($session) && sizeof($session)) {
         $menu[] = array('txt' => CopixI18N::get('comptes.strings.showloginresult', sizeof($session)), 'url' => CopixUrl::get('comptes||getLoginResult'), 'size' => 160);
     }
     /*if( Kernel::getLevel( 'ROOT', 0 ) >= PROFILE_CCV_ADMIN ) {
           $menu[] = array( 'txt' => CopixI18N::get('comptes.strings.getext'), 'url' => CopixUrl::get ('comptes||getUserExt'), 'size'=>160 );
           $menu[] = array( 'txt' => CopixI18N::get('comptes.strings.getanim'), 'url' => CopixUrl::get ('comptes|animateurs|list'), 'size'=>120 );
       }
       if( count($menu) ) $tpl->assign ('MENU', $menu );*/
     $tpl->assign('MENU', $this->menu);
     $tpl->assign('MAIN', $result);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * 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;
 }
 public static function completeUp($type, $id, $first = true)
 {
     //get the actual matrix:
     $matrix =& enic::get('matrix');
     //get users infos:
     $user =& enic::get('user');
     //get kernel
     $kernel = new Kernel();
     switch ($user->type) {
         //for parent user, get the children nodes
         case 'USER_RES':
             $userNodes = rightMatrixHelpers::getUserResParentNodes($type, $id);
             break;
         default:
             $userNodes = $kernel->getNodeParents($type, $id);
             break;
     }
     if (empty($userNodes)) {
         $userNodes = array(array('type' => 'ROOT', 'id' => 0, 'droit' => 0));
     }
     //list parents and add each at the tree
     foreach ($userNodes as $userNode) {
         //get the node type :
         $nodeType = $userNode['type'];
         $node = $matrix->{$nodeType}();
         $idNode = '_' . $userNode['id'];
         //if already exists : pass the loading
         if (!isset($node->{$idNode})) {
             $node->loadOnce('nodeMatrix', $idNode);
             $node->{$idNode}->nom = isset($userNode['nom']) ? $userNode['nom'] : null;
             $node->{$idNode}->type = $userNode['type'];
             $node->{$idNode}->id = $userNode['id'];
         }
         //detect 'nd apply rigth
         if (isset($userNode['droit']) && $userNode['droit'] > 60) {
             $node->{$idNode}->admin_of = true;
             //if user is director
             if ($userNode['type'] == 'BU_ECOLE') {
                 $node->{$idNode}->director_of = true;
                 $user->director[] = $userNode['id'];
                 $node->setDatasArray('userDirector', $userNode['id']);
             }
             //SuperAdmin case :
             if ($userNode['type'] == 'ROOT') {
                 $node->{$idNode}->root = true;
                 $user->root = true;
                 $node->setDatas('userRoot', true);
             }
         }
         //if the member is direct member
         if ($first) {
             //in all case : user is member
             $node->{$idNode}->member_of = true;
         } else {
             $node->{$idNode}->descendant_of = true;
         }
         //reccursive
         if ($userNode['type'] != 'ROOT') {
             self::completeUp($userNode['type'], $userNode['id'], false);
         }
     }
 }
 public function processDefault()
 {
     ini_set('max_execution_time', 0);
     $classeurservice =& CopixClassesFactory::Create('classeur|classeurservice');
     /* DEBUG
        if (!Admin::canAdmin())
            return CopixActionGroup::process ('genericTools|Messages::getError', array ('message'=>CopixI18N::get ('kernel|kernel.error.noRights'), 'back'=>CopixUrl::get ()));
        */
     $tpl = new CopixTpl();
     // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('sysutils|admin.menu.cache'));
     // $tpl->assign ('MENU', Admin::getMenu('cache'));
     ///////////////
     //// ALBUM ////
     ///////////////
     $sql = "\n            SELECT\n                A.id AS album_id, A.nom AS album_nom, A.prefs AS album_prefs, A.date AS album_date, A.cle AS album_cle, A.public AS album_public\n            FROM module_album_albums A\n            ORDER BY A.id\n        ";
     $album_list = _doQuery($sql);
     $album_tree = array();
     foreach ($album_list as $album_item) {
         if (!isset($album_tree[$album_item->album_id])) {
             $album_tree[$album_item->album_id] = new CopixPPO();
             $album_tree[$album_item->album_id]->info = $album_item;
             $parent = Kernel::getModParent("MOD_ALBUM", $album_item->album_id);
             if (!$parent) {
                 unset($album_tree[$album_item->album_id]);
                 continue;
             }
             $album_tree[$album_item->album_id]->parent = $parent[0];
             $album_tree[$album_item->album_id]->dossier = array();
             $album_tree[$album_item->album_id]->photo = array();
         }
         $root = $this->albumScanFolder($album_item->album_id, 0);
         $album_tree[$album_item->album_id]->dossier = $root->dossier;
         $album_tree[$album_item->album_id]->photo = $root->photo;
     }
     // module_malle_malles : id 	titre 	date_creation 	cle
     // module_malle_folders : id malle parent nom nb_folders nb_files taille date_creation
     // module_malle_files : id 	malle 	folder 	nom 	fichier 	taille 	type 	cle 	date_upload
     ///////////////
     //// MALLE ////
     ///////////////
     $sql = "\n            SELECT\n                id, titre, date_creation, cle\n            FROM module_malle_malles\n            ORDER BY id\n        ";
     $malle_list = _doQuery($sql);
     $malle_tree = array();
     foreach ($malle_list as $malle_item) {
         if (!isset($malle_tree[$malle_item->id])) {
             $malle_tree[$malle_item->id] = new CopixPPO();
             $malle_tree[$malle_item->id]->info = $malle_item;
             $parent = Kernel::getModParent("MOD_MALLE", $malle_item->id);
             if (!$parent) {
                 unset($malle_tree[$malle_item->id]);
                 continue;
             }
             $malle_tree[$malle_item->id]->parent = $parent[0];
             $user_parents = Kernel::getNodeParents($parent[0]->node_type, $parent[0]->node_id);
             $malle_tree[$malle_item->id]->user_parents = $user_parents;
             $malle_tree[$malle_item->id]->dossier = array();
             $malle_tree[$malle_item->id]->docs = array();
         }
         $root = $this->malleScanFolder($malle_item->id, 0);
         $malle_tree[$malle_item->id]->dossier = $root->dossier;
         $malle_tree[$malle_item->id]->docs = $root->docs;
     }
     /////////////////////////////////////
     /////////////////////////////////////
     // kernel_mod_enabled : node_type 	node_id 	module_type 	module_id
     // module_classeur : id 	titre 	cle 	date_creation 	date_publication 	public
     // module_classeur_dossier : id 	module_classeur_id 	parent_id 	nom 	nb_dossiers 	nb_fichiers 	taille 	cle 	date_creation 	user_type 	user_id 	date_publication 	public
     // module_classeur_fichier : id 	module_classeur_id 	module_classeur_dossier_id 	titre 	commentaire 	fichier 	taille 	type 	cle 	date_upload 	user_type 	user_id
     // IMPORT ALBUMS
     if (1) {
         foreach ($album_tree as $album_item) {
             if (!isset($album_item->parent->node_type)) {
                 continue;
             }
             //// RECHERCHE D'UN CLASSEUR EXISTANT
             $sql = "\n                SELECT module_id\n                FROM kernel_mod_enabled\n                WHERE node_type=:node_type AND node_id=:node_id AND module_type=:module_type\n            ";
             $param = array('node_type' => $album_item->parent->node_type, 'node_id' => $album_item->parent->node_id, 'module_type' => 'MOD_CLASSEUR');
             $mod_classeur = _doQuery($sql, $param);
             if (!isset($mod_classeur[0])) {
                 $node_infos = $this->getNodeInfos($album_item->parent->node_type, $album_item->parent->node_id);
                 $file =& CopixSelectorFactory::create("classeur|classeur");
                 $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                 $modservice =& CopixClassesFactory::Create('classeur|kernelclasseur');
                 if (method_exists($modservice, "create")) {
                     $modid = $modservice->create(array('title' => $node_infos->nom, 'subtitle' => '', 'node_type' => $album_item->parent->node_type, 'node_id' => $album_item->parent->node_id));
                     if ($modid != null) {
                         Kernel::registerModule('MOD_CLASSEUR', $modid, $album_item->parent->node_type, $album_item->parent->node_id);
                     }
                 }
                 $classeur_id = $modid;
             } else {
                 $classeur_id = $mod_classeur[0]->module_id;
             }
             $classeurDAO = _ioDAO('classeur|classeur');
             $classeur = $classeurDAO->get($classeur_id);
             $new_dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/';
             if (!file_exists($new_dir)) {
                 mkdir($new_dir, 0755, true);
             }
             //// CREATION D'UN DOSSIER D'IMPORT
             $dossierDAO = _ioDAO('classeur|classeurdossier');
             $dossier = _record('classeur|classeurdossier');
             $dossier->classeur_id = $classeur_id;
             $dossier->parent_id = 0;
             $dossier->nom = "Import Album " . $album_item->info->album_id;
             $dossier->cle = $album_item->info->album_cle;
             $dossier->date_creation = $album_item->info->album_date;
             $dossier->user_type = "";
             $dossier->user_id = "";
             $dossier->nb_dossiers = 0;
             $dossier->nb_fichiers = 0;
             $dossier->taille = 0;
             $dossier->casier = 0;
             $dossierDAO->insert($dossier);
             // $dossier->id
             $this->albumImport($album_item, $dossier);
             $classeurservice->updateFolderInfosWithDescendants($dossier);
         }
     }
     // IMPORT MALLES
     if (1) {
         foreach ($malle_tree as $malle_item) {
             if (!isset($malle_item->parent->node_type)) {
                 continue;
             }
             //// RECHERCHE D'UN CLASSEUR EXISTANT
             $sql = "\n                SELECT module_id\n                FROM kernel_mod_enabled\n                WHERE node_type=:node_type AND node_id=:node_id AND module_type=:module_type\n            ";
             $param = array('node_type' => $malle_item->parent->node_type, 'node_id' => $malle_item->parent->node_id, 'module_type' => 'MOD_CLASSEUR');
             $mod_classeur = _doQuery($sql, $param);
             if (!isset($mod_classeur[0])) {
                 $node_infos = $this->getNodeInfos($malle_item->parent->node_type, $malle_item->parent->node_id);
                 $file =& CopixSelectorFactory::create("classeur|classeur");
                 $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                 $modservice =& CopixClassesFactory::Create('classeur|kernelclasseur');
                 if (method_exists($modservice, "create")) {
                     $modid = $modservice->create(array('title' => $node_infos->nom, 'subtitle' => '', 'node_type' => $malle_item->parent->node_type, 'node_id' => $malle_item->parent->node_id));
                     if ($modid != null) {
                         Kernel::registerModule('MOD_CLASSEUR', $modid, $malle_item->parent->node_type, $malle_item->parent->node_id);
                     }
                 }
                 $classeur_id = $modid;
             } else {
                 $classeur_id = $mod_classeur[0]->module_id;
             }
             $classeurDAO = _ioDAO('classeur|classeur');
             $classeur = $classeurDAO->get($classeur_id);
             $new_dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/';
             if (!file_exists($new_dir)) {
                 mkdir($new_dir, 0755, true);
             }
             //// CREATION D'UN DOSSIER D'IMPORT
             $dossierDAO = _ioDAO('classeur|classeurdossier');
             $dossier = _record('classeur|classeurdossier');
             $dossier->classeur_id = $classeur_id;
             $dossier->parent_id = 0;
             $dossier->nom = "Import documents " . $malle_item->info->id;
             $dossier->cle = $malle_item->info->cle;
             $dossier->date_creation = $malle_item->info->date_creation;
             $dossier->user_type = "";
             $dossier->user_id = "";
             $dossier->nb_dossiers = 0;
             $dossier->nb_fichiers = 0;
             $dossier->taille = 0;
             $dossierDAO->insert($dossier);
             // $dossier->id
             $this->malleImport($malle_item, $dossier);
             $classeurservice->updateFolderInfosWithDescendants($dossier);
         }
     }
     $sql = "\n            UPDATE kernel_mod_available\n            SET node = CONCAT(node, '_OFF')\n            WHERE module = 'MOD_MALLE' OR module = 'MOD_ALBUM'";
     _doQuery($sql);
     $sql = "\n            UPDATE kernel_mod_enabled\n            SET node_type = CONCAT(node_type, '_OFF')\n            WHERE module_type = 'MOD_MALLE' OR module_type = 'MOD_ALBUM' AND node_type != 'MOD_TELEPROCEDURES'";
     _doQuery($sql);
     echo "<h1>Fin</h1>";
     echo "<pre>";
     print_r($album_tree);
     print_r($malle_tree);
     die;
 }
 /**
  * Renvoie la ville d'un groupe
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/09/25
  * @param integer $pGroupe	Id du groupe
  * @param array $pParent (option) Parent(s) du groupe. Si null ou pas passe, se charge de le chercher en base. Si passe, doit provenir de la fonction getNodeParents
  * @return integer Id de la ville, ou 0 si aucune
  */
 public function getGroupeVille($pGroupe, $pParent = null)
 {
     $ville = 0;
     $parent = $pParent == null ? Kernel::getNodeParents('CLUB', $pGroupe) : $pParent;
     //var_dump($parent);
     if ($parent && $parent[0]['type'] == 'BU_VILLE') {
         $ville = $parent[0]['id'];
     } elseif ($parent && $parent[0]['type'] == 'BU_CLASSE') {
         $ville = $parent[0]['ALL']->eco_id_ville;
     } elseif ($parent && $parent[0]['type'] == 'BU_ECOLE') {
         $ville = $parent[0]['ALL']->vil_id_vi;
     }
     return $ville;
 }
 public function processDefault()
 {
     $tpl = new CopixTpl();
     $tplModule = new CopixTpl();
     if (!$this->user->connected) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('welcome|default|'));
     }
     $tpl->assign('TITLE_PAGE', CopixI18N::get('kernel.title.accueilsimple'));
     $nodes_all = Kernel::getNodeParents($this->user->type, $this->user->idEn);
     $nodes_all = Kernel::sortNodeList($nodes_all);
     // _dump($nodes_all);
     $nodes = array();
     foreach ($nodes_all as $node) {
         if ($node['type'] == 'CLUB' && CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance')) && $node['id'] == $groupeAssistance) {
             continue;
         }
         if ($node['type'] == 'CLUB' && $node['droit'] < 20) {
             continue;
         }
         if (!isset($nodes[$node['type']])) {
             $nodes[$node['type']] = array();
         }
         //module not initialized : loaded into inconito
         if (!isset($nodes[$node['type']][$node['id']])) {
             $nodes[$node['type']][$node['id']] = $node;
             Kernel::createMissingModules($node['type'], $node['id']);
             $nodes[$node['type']][$node['id']]['modules'] = Kernel::getModEnabled($node['type'], $node['id'], $this->user->type, $this->user->idEn, 0, count($nodes_all) > $this->conf_notification_maxnodes ? 0 : 1);
             // Cas des groupes : on ajoute les membres et admin, selon les droits
             if ($node['type'] == 'CLUB') {
                 $addModule = new CopixPPO();
                 $addModule->node_type = $node['type'];
                 $addModule->node_id = $node['id'];
                 $addModule->module_type = 'MOD_ADMIN';
                 $addModule->module_id = 0;
                 $addModule->module_nom = CopixI18N::get('groupe|groupe.group.admin');
                 $nodes[$node['type']][$node['id']]['modules'][] = $addModule;
             }
             /*
              * ===== CONTENT GENERATION =====
              *
              */
             //cas parent élève
             if ($node['type'] == 'USER_ELE') {
                 $contentNode = Kernel::getNodeParents($node['type'], $node['id']);
                 $contentNode = Kernel::filterNodeList($contentNode, 'BU_CLASSE');
                 if (empty($contentNode)) {
                     continue;
                 }
                 $contentNode = $contentNode[0];
             } else {
                 $contentNode = $node;
             }
             //get content from db :
             $content = $this->db->query('SELECT * FROM module_admindash WHERE id_zone = ' . $contentNode['id'] . ' AND type_zone = "' . $contentNode['type'] . '"')->toArray1();
             // Get vocabulary catalog to use
             $nodeVocabularyCatalogDAO = _ioDAO('kernel|kernel_i18n_node_vocabularycatalog');
             $vocabularyCatalog = $nodeVocabularyCatalogDAO->getCatalogForNode($contentNode['type'], $contentNode['id']);
             //if no content : get default content
             if (empty($content['content'])) {
                 switch ($contentNode['type']) {
                     case 'BU_CLASSE':
                     case 'USER_ELE':
                         $content['content'] = CopixZone::process('kernel|dashboardClasse', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'BU_ECOLE':
                         $content['content'] = CopixZone::process('kernel|dashboardEcole', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'BU_VILLE':
                         $content['content'] = CopixZone::process('kernel|dashboardVille', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'CLUB':
                         $content['content'] = CopixZone::process('kernel|dashboardGrTravail', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'ROOT':
                         if ($contentNode['droit'] >= 60) {
                             $contentTpl = new CopixTpl();
                             $content['content'] = $contentTpl->fetch('zone.dashboard.root.tpl');
                         } else {
                             $contentTpl = new CopixTpl();
                             $content['content'] = $contentTpl->fetch('zone.dashboard.userext.tpl');
                         }
                         break;
                     default:
                         $content['content'] = '';
                         break;
                 }
             }
             //twitter integration
             $twitterSrc = '';
             if (!empty($content['social_stream'])) {
                 enic::to_load('social');
                 $twitter = new enicSocialTwitter();
                 $twitterSrc = $content['social_stream'];
             }
             //is admin :
             $is_admin = $contentNode['droit'] >= 60;
             //build html content
             $content_tpl = new CopixTpl();
             $content_tpl->assign('content', $content['content']);
             if (!empty($content['picture'])) {
                 $content_tpl->assign('picture', $content['picture']);
                 $content_tpl->assign('picturePath', $this->picturesPath);
             }
             $content_tpl->assign('twitter', $twitterSrc);
             $content_tpl->assign('is_admin', $is_admin);
             $content_tpl->assign('id', $contentNode['id']);
             $content_tpl->assign('type', $contentNode['type']);
             $content_tpl->assign('catalog', $vocabularyCatalog->id_vc);
             if ($contentNode['type'] == "BU_ECOLE") {
                 $content_tpl->assign('idZone', $contentNode['id']);
             }
             $content = $content_tpl->fetch('dashboard.nodes.tpl');
             //add css
             $this->addCss('styles/dashboard_zone.css');
             //free memory
             unset($content_tpl);
             /*
              *  ===== END CONTENT GENERATION =====
              */
             $nodes[$node['type']][$node['id']]['content'] = $content;
         } elseif ($nodes[$node['type']][$node['id']]['droit'] < $node['droit']) {
             $nodes[$node['type']][$node['id']] = $node;
         }
     }
     if (CopixConfig::exists('|use_class_validity') && CopixConfig::get('|use_class_validity')) {
         $tplModule->assign("use_class_validity", 1);
         if (isset($nodes['BU_CLASSE'])) {
             foreach ($nodes['BU_CLASSE'] as $classe_id => $classe_data) {
                 $validity_timestamp = Kernel::getValidityDateForClass($classe_data['id']);
                 if ($validity_timestamp) {
                     $nodes['BU_CLASSE'][$classe_id]['validity_timestamp'] = $validity_timestamp;
                     $nodes['BU_CLASSE'][$classe_id]['validity_date'] = date('d/m/Y', $validity_timestamp);
                     // Si l'école existe : mémoriser max validity
                     if (isset($nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole])) {
                         if (!isset($nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_timestamp']) || $nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_timestamp'] < $validity_timestamp) {
                             $nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_timestamp'] = $validity_timestamp;
                             $nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_date'] = date('d/m/Y', $validity_timestamp);
                         }
                     }
                 }
             }
         }
         $count_validity_ok = 0;
         $count_validity_bad = 0;
         foreach ($nodes as $node_type => $node_type_list) {
             foreach ($node_type_list as $node_id => $node) {
                 if (isset($nodes[$node_type][$node_id]['validity_timestamp'])) {
                     if ($nodes[$node_type][$node_id]['validity_timestamp'] < time()) {
                         unset($nodes[$node_type][$node_id]);
                         $count_validity_bad++;
                     } else {
                         $count_validity_ok++;
                     }
                 }
             }
         }
     } else {
         $tplModule->assign("use_class_validity", 0);
     }
     /* DRAFT WORKING */
     // _dump($nodes);
     /* $rClasse = Kernel::getNodeInfo ('BU_CLASSE', $nodes['BU_CLASSE'][1]['id'], false);
        CopixZone::process ('annuaire|infosclasse', array('rClasse'=>$rClasse)); */
     //echo $this->matrix->display();
     // _dump($nodes);
     $tplModule->assign("nodes", $nodes);
     if (count($nodes) == 0) {
         $result = $tplModule->fetch("dashboard-empty.tpl");
     } else {
         $result = $tplModule->fetch("dashboard.tpl");
     }
     $tpl->assign('MAIN', $result);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Liste de groupes
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/08
  * @param integer $forum Id du forum
  * @return array Tableau avec les groupes
  */
 public function getListPublic($offset, $count, $kw = null)
 {
     $criteres = _daoSp();
     $criteres->addCondition('is_open', '=', 1);
     if (CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance'))) {
         $criteres->addCondition('id', '!=', $groupeAssistance);
     }
     // D�coupage du pattern
     if ($kw) {
         $testpattern = str_replace(array(" ", "%20"), "%20", $kw);
         $temp = split("%20", $testpattern);
         $criteres->startGroup();
         foreach ($temp as $word) {
             if ($word != "") {
                 $criteres->addCondition('titre', 'LIKE', "%{$word}%", 'or');
                 $criteres->addCondition('description', 'LIKE', "%{$word}%", 'or');
             }
         }
         $criteres->endGroup();
     }
     if ($offset) {
         $criteres->setOffset($offset);
     }
     if ($count) {
         $criteres->setCount($count);
     }
     $criteres->orderBy(array('date_creation', 'desc'));
     $list = _ioDao('groupe|groupe')->findBy($criteres);
     //search tags by Id or Name
     $listTag = new CopixDAORecordIterator(_doQuery('SELECT g.id AS id, g.titre AS titre, g.description AS description, g.is_open AS is_open, g.createur AS createur, g.date_creation AS date_creation FROM module_groupe_groupe AS g JOIN module_tags_groups AS tg ON tg.id_group = g.id JOIN module_tags AS t ON tg.id_tag = t.id WHERE g.is_open=1 AND t.name LIKE "%' . $kw . '%" OR t.id = ' . (int) $kw), $this->getDAOId());
     //merge records
     $listGroupFinal = array();
     foreach ($list as $l) {
         $listGroupFinal[] = $l;
     }
     foreach ($listTag as $l) {
         $listGroupFinal[] = $l;
     }
     $list = $listGroupFinal;
     $arGroupes = array();
     $groupListId = array();
     foreach ($list as $groupe) {
         if (in_array($groupe->id, $groupListId)) {
             continue;
         }
         $groupListId[] = $groupe->id;
         $parent = Kernel::getNodeParents("CLUB", $groupe->id);
         $ok = true;
         if (Kernel::getKernelLimits('ville')) {
             if ($parent) {
                 $ville = GroupeService::getGroupeVille($groupe->id, $parent);
                 if (!in_array($ville, Kernel::getKernelLimits('ville_as_array'))) {
                     $ok = false;
                 }
             } else {
                 $ok = false;
             }
         }
         if ($ok) {
             $groupe->parent = $parent;
             $arGroupes[] = $groupe;
         }
     }
     $results = $arGroupes;
     return $results;
 }
 /**
  * walk
  *
  * DEBUG: Affichage des parents et enfants d'un noeud, pour valider le
  * fonctionnement des fonctions getNodeParents et getNodeChilds.
  * @author	Frédéric Mossmann <*****@*****.**>
  * @see getNodeParents( $type, $id )
  * @see getNodeChilds( $type, $id )
  */
 public function processWalk()
 {
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', "Walk");
     $return_left = "";
     $return_center = "";
     $return_right = "";
     if (_request("type")) {
         $type = _request("type");
         $id = _request("id");
     } else {
         if (_currentUser()->getExtra('type') && _currentUser()->getExtra('id')) {
             $type = _currentUser()->getExtra('type');
             $id = _currentUser()->getExtra('id');
         } else {
             $type = "USER_ELE";
             $id = 3777;
         }
     }
     $result = Kernel::getNodeParents($type, $id);
     foreach ($result as $key => $value) {
         $return_left .= '<a href="' . CopixUrl::get('kernel||walk', array("type" => $value["type"], "id" => $value["id"])) . '">';
         $return_left .= $value["type"] . "/" . $value["id"];
         if (isset($value["droit"]) && $value["droit"]) {
             $return_left .= ' (' . $value["droit"] . ')';
         }
         $return_left .= '</a>';
         // $tmp = Kernel::getNodeChilds( $value["type"], $value["id"] );
         // if( sizeof($tmp) ) $return_left .= " (".sizeof($tmp).")";
         $return_left .= '<br />';
     }
     $result = Kernel::getNodeChilds($type, $id);
     foreach ($result as $key => $value) {
         // $tmp = Kernel::getNodeChilds( $value["type"], $value["id"] );
         // if( sizeof($tmp) ) $return_right .= "(".sizeof($tmp).") ";
         $return_right .= '<a href="' . CopixUrl::get('kernel||walk', array("type" => $value["type"], "id" => $value["id"])) . '">';
         $return_right .= $value["type"] . "/" . $value["id"];
         if (isset($value["droit"]) && $value["droit"]) {
             $return_right .= ' (' . $value["droit"] . ')';
         }
         $return_right .= '</a>';
         $return_right .= '<br />';
     }
     $return_center .= $type . "/" . $id;
     if (ereg("^USER_", $type)) {
         $user_infos = Kernel::getUserInfo($type, $id);
         if (isset($user_infos["login"])) {
             $return_center .= "<br />Login: "******"login"];
         }
         if (isset($user_infos["nom"]) && isset($user_infos["prenom"])) {
             $return_center .= "<br />(";
             $return_center .= $user_infos["prenom"] . " " . $user_infos["nom"];
             $return_center .= ")";
         }
     } else {
         $node_infos = Kernel::getNodeInfo($type, $id, false);
         if (isset($node_infos["nom"])) {
             $return_center .= "<br />" . $node_infos["nom"];
         }
         if (isset($node_infos["desc"])) {
             $return_center .= "<br />(";
             if (strlen($node_infos["desc"]) > 45) {
                 $return_center .= substr($node_infos["desc"], 0, 40) . "...";
             } else {
                 $return_center .= $node_infos["desc"];
             }
             $return_center .= ")";
         }
     }
     $return_str = '<center><h3>' . $return_center . '</h3></center>';
     $return_str .= '<table width="100%"><tr><td valign="top" align="left"><strong>Parents</strong></td><td valign="top" align="right"><strong>Childs</strong></td></tr>';
     $return_str .= '<tr><td valign="top" align="left">' . $return_left . '</td><td valign="top" align="right">' . $return_right . '</td></tr></table>';
     $tpl->assign('MAIN', "<pre>" . $return_str . "</pre>");
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Formulaire de cr�ation / modification d'un groupe
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/15
  * @param integer $id Id du groupe qu'on modifie, ou NULL si cr�ation d'un nouveau groupe
  * @param string $titre (si formulaire soumis) Titre du groupe
  * @param string $description (si formulaire soumis) Sa description
  * @param integer $is_open (si formulaire soumis) 1 si le groupe est public, 0 s'il est priv�
  * @param string $membres (si formulaire soumis) La liste des logins des membres � ajouter (s�par�s par des virgules �ventuellement)
  * @param array $his_modules (si formulaire soumis) Les modules � rattacher au groupe
  * @param array $errors (option) Erreurs rencontr�es
  */
 public function processGetEdit()
 {
     //$messages = $dao->getList();
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     $groupeService =& CopixClassesFactory::Create('groupe|groupeService');
     $dao = CopixDAOFactory::create("groupe");
     $tagService = $this->service('tagService');
     $tpl = new CopixTpl();
     $id = $this->getRequest('id', null);
     $titre = $description = $membres = NULL;
     $is_open = 1;
     $errors = array();
     $nodes = array();
     $tags = '';
     if ($id) {
         // Modification
         $tplTitle = CopixI18N::get('groupe|groupe.modify');
         $groupe = $dao->getGroupe($id);
         if ($groupe) {
             $mondroit = $kernel_service->getLevel("CLUB", $id);
             if (!$groupeService->canMakeInGroupe('ADMIN', $mondroit)) {
                 $errors[] = CopixI18N::get('kernel|kernel.error.noRights');
             } else {
                 $tags = $tagService->createTagsString($tagService->getTagsByGroup($id));
                 $titre = $groupe[0]->titre;
                 $description = $groupe[0]->description;
                 $is_open = $groupe[0]->is_open;
                 $parentClass = $parentRef = null;
             }
         } else {
             $errors[] = CopixI18N::get('groupe|groupe.error.noGroup');
         }
     } else {
         $tplTitle = CopixI18N::get('groupe|groupe.new');
         if (!$groupeService->canMakeInGroupe('ADD_GROUP', NULL)) {
             $errors[] = CopixI18N::get('kernel|kernel.error.noRights');
         }
         // On regarde a quoi on pourrait rattacher le groupe
         $nodes_all = Kernel::getNodeParents(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($nodes_all as $node) {
             if ($node['type'] == 'CLUB' && CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance')) && $node['id'] == $groupeAssistance) {
                 continue;
             }
             if ($node['type'] == 'BU_CLASSE' || $node['type'] == 'BU_ECOLE' || $node['type'] == 'BU_VILLE') {
                 $nodes[] = $node;
             }
         }
         $nbNodes = count($nodes);
         if ($nbNodes == 1) {
             $parentClass = $nodes[0]['type'];
             $parentRef = $nodes[0]['id'];
         } elseif ($nbNodes == 0) {
             // Pas de parent pour la creation d'un groupe -> attache a ROOT/0  (FM 14/11/2008)
             $parentClass = "ROOT";
             $parentRef = 0;
         } else {
             // Plus d'un noeud, on proposera le choix
             $parentClass = $parentRef = '';
         }
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('groupe||')));
     } else {
         $titre = $this->getRequest('titre', $titre);
         $tags = $this->getRequest('tags', $tags);
         $description = $this->getRequest('description', $description);
         $is_open = $this->getRequest('is_open', $is_open);
         $membres = $this->getRequest('membres', $membres);
         $his_modules = $this->getRequest('his_modules', array());
         $parent = _request('parent');
         if ($id) {
             // Modif d'un groupe, on cherche ses modules
             $his_modules = array();
             $modEnabled = $kernel_service->getModEnabled("club", $id);
             //print_r($modEnabled);
             foreach ($modEnabled as $tmp) {
                 $his_modules[$tmp->module_type] = 1;
             }
         }
         $errors = $this->getRequest('errors', array());
         $kernel_service = CopixClassesFactory::create("kernel|Kernel");
         $modules = $kernel_service->getModAvailable("club");
         foreach ($modules as $k => $tmp) {
             if ($tmp->module_type == 'MOD_MAGICMAIL') {
                 unset($modules[$k]);
                 continue;
             }
             $modules[$k]->module_name = Kernel::Code2Name($tmp->module_type);
             $modules[$k]->module_desc = Kernel::Code2Desc($tmp->module_type);
         }
         $tpl->assign('TITLE_PAGE', $tplTitle);
         $menu = array();
         if (0 && !$id) {
             if ($groupeService->canMakeInGroupe('ADD_GROUP', NULL)) {
                 $menu[] = array('url' => CopixUrl::get('groupe||getEdit'), 'txt' => CopixI18N::get('groupe|groupe.btn.addGroup'), 'size' => 140, 'type' => 'create', 'current' => true);
             }
             $menu[] = array('url' => CopixUrl::get('groupe||getListPublic'), 'txt' => CopixI18N::get('groupe|groupe.annuaire'));
         }
         $tpl->assign('MENU', $menu);
         $tplForm = new CopixTpl();
         $tplForm->assign("id", $id);
         $tplForm->assign("titre", $titre);
         $tplForm->assign("description", $description);
         $tplForm->assign("is_open", $is_open);
         $tplForm->assign("membres", $membres);
         $tplForm->assign("modules", $modules);
         $tplForm->assign("parentClass", $parentClass);
         $tplForm->assign("parentRef", $parentRef);
         $tplForm->assign("his_modules", $his_modules);
         $tplForm->assign('linkpopup', CopixZone::process('annuaire|linkpopup', array('field' => 'membres')));
         $tplForm->assign("errors", $errors);
         $tplForm->assign("nodes", $nodes);
         $tplForm->assign("parent", $parent);
         $tplForm->assign("tags", $tags);
         if (!CopixConfig::exists('|can_group_createpublic') || CopixConfig::get('|can_group_createpublic')) {
             $tplForm->assign("can_group_createpublic", 1);
         } else {
             $tplForm->assign("can_group_createpublic", 0);
         }
         $result = $tplForm->fetch("formedit.tpl");
         $tpl->assign("MAIN", $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }