public function processDefault()
 {
     _classInclude('sysutils|admin');
     if (!Admin::canAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     echo "Récupération des classeurs de classe sans casier\n";
     echo "----------------------------------------------------------------------\n\n";
     // Récupération des classeurs de classe sans casier
     $sql = 'SELECT DISTINCT module_classeur.id' . ' FROM kernel_mod_enabled, module_classeur' . ' LEFT JOIN module_classeur_dossier ON (module_classeur_dossier.module_classeur_id = module_classeur.id)' . ' WHERE module_classeur.id = kernel_mod_enabled.module_id' . ' AND kernel_mod_enabled.module_type = "MOD_CLASSEUR"' . ' AND kernel_mod_enabled.node_type = "BU_CLASSE"' . ' AND (module_classeur_dossier.id IS NULL' . ' OR module_classeur_dossier.id NOT IN (SELECT id FROM module_classeur_dossier WHERE casier = 1 AND module_classeur_id = module_classeur.id))';
     $results = _doQuery($sql);
     $dossierDAO = _ioDAO('classeur|classeurdossier');
     _classInclude('classeur|classeurService');
     echo count($results) . " casiers à créer.\n";
     foreach ($results as $result) {
         $casier = _record('classeur|classeurdossier');
         $casier->classeur_id = $result->id;
         $casier->parent_id = 0;
         $casier->nom = CopixI18N::get('classeur|classeur.casierNom');
         $casier->nb_dossiers = 0;
         $casier->nb_fichiers = 0;
         $casier->taille = 0;
         $casier->cle = classeurService::createKey();
         $casier->casier = 1;
         $casier->date_creation = date('Y-m-d H:i:s');
         $dossierDAO->insert($casier);
         echo "Casier du classeur {$result->id} créé avec succès !\n";
     }
     echo "\n\nFin de la tâche";
     return _arNone();
 }
 /**
  * Login SSO simulant une vraie connexion
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/12/08
  * @param integer $id_sso Id SSO
  * @param string $key Clé
  * @param string $node_type (option) Type du noeud à atteindre après connexion
  * @param integer $node_id (option) Id du noeud à atteindre après connexion
  * @param string $module_type (option) Type du module du noeud à atteindre (MOB_BLOG,...)
  * @return integer $id_sso Id SSO
  */
 public function login()
 {
     $id_sso = $this->getRequest('id_sso', null);
     $key = $this->getRequest('key', null);
     $node_type = $this->getRequest('node_type', null);
     $node_id = $this->getRequest('node_id', null);
     $module_type = $this->getRequest('module_type', null);
     $sql = "SELECT CHA.date, CHA.challenge, SSO.cle_privee, SSO.login FROM kernel_sso_challenges CHA, kernel_sso_users SSO, dbuser USER WHERE CHA.id_sso=SSO.id_sso AND SSO.login=USER.login_dbuser AND SSO.id_sso={$id_sso}";
     //Kernel::deb($sql);
     $sso = _doQuery($sql);
     //print_r($sso);
     if ($sso) {
         /*
         Kernel::deb($sso->challenge);
         Kernel::deb($sso->cle_privee);
         Kernel::deb('md5='.md5($sso->challenge.$sso->cle_privee));
         */
         if (md5($sso->challenge . $sso->cle_privee) == $key) {
             if (mktime() - $sso->date < CopixConfig::get('sso|in_challenge_delay')) {
                 // OK
                 //echo("OK!");
                 return CopixActionGroup::process('auth|log::in', array('login' => $sso->login, 'key' => $key, 'node_type' => $node_type, 'node_id' => $node_id, 'module_type' => $module_type));
             } else {
                 echo "-ERR REP: Le temps alloué pour la réponse est dépassé. Veuillez essayer une nouvelle connexion ou contacter votre administrateur pour lui signaler le problème.";
             }
         } else {
             echo "-ERR REP: Erreur (1) lors de la vérification d'identité. Veuillez essayer une nouvelle connexion ou contacter votre administrateur pour lui signaler le problème.";
         }
     } else {
         echo "-ERR REP: Erreur (2) lors de la vérification d'identité. Veuillez essayer une nouvelle connexion ou contacter votre administrateur pour lui signaler le problème.";
     }
     return new CopixActionReturn(COPIX_AR_NONE, 0);
 }
 /**
  * Commentaires d'une procedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/01/30
  * @param object $rFiche Recordset de la procedure
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $rFiche = $this->getParam('rFiche');
     $mondroit = $this->getParam('mondroit');
     $daoinfo =& _dao('infosupp');
     $sql = 'SELECT * FROM module_teleprocedure_infosupp WHERE idinter=' . $rFiche->idinter . '';
     $canCheckVisible = TeleproceduresService::canMakeInTelep('CHECK_VISIBLE', $mondroit);
     $canAddComment = TeleproceduresService::canMakeInTelep('ADD_COMMENT', $mondroit);
     if (!$canCheckVisible) {
         $sql .= " AND info_message!='' AND info_message IS NOT NULL";
     }
     $sql .= " ORDER BY dateinfo ASC, idinfo ASC";
     $results = _doQuery($sql);
     // Pour chaque message on cherche les infos de son auteur
     $list = array();
     foreach ($results as $r) {
         $userInfo = Kernel::getUserInfo("ID", $r->iduser);
         //var_dump($userInfo);
         $avatar = Prefs::get('prefs', 'avatar', $r->iduser);
         $userInfo['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         $r->user = $userInfo;
         $list[] = $r;
     }
     //print_r($rFiche);
     $tpl->assign('info_message_edition', CopixZone::process('kernel|edition', array('field' => 'info_message', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('info_commentaire_edition', CopixZone::process('kernel|edition', array('field' => 'info_commentaire', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('canCheckVisible', $canCheckVisible);
     $tpl->assign('canAddComment', $canAddComment);
     $tpl->assign('list', $list);
     $tpl->assign('rFiche', $rFiche);
     $toReturn = $tpl->fetch('fiche-comms-zone.tpl');
     return true;
 }
 /**
  * Retourne le nombre de mémos non signés d'un élève
  *
  * @param int $idEleve
  *
  * @return int
  */
 public function retrieveNombreMemosNonSignesParEleve($idEleve)
 {
     $results = array();
     $sql = 'SELECT COUNT(cahierdetextesmemo.id) as counter FROM module_cahierdetextes_memo AS cahierdetextesmemo' . ' LEFT JOIN module_cahierdetextes_memo2eleve ON (cahierdetextesmemo.id = module_cahierdetextes_memo2eleve.module_cahierdetextes_memo_id)' . ' WHERE module_cahierdetextes_memo2eleve.kernel_bu_eleve_idEleve=:idEleve' . ' AND cahierdetextesmemo.supprime = 0' . ' AND cahierdetextesmemo.avec_signature = 1' . ' AND module_cahierdetextes_memo2eleve.signe_le IS NULL';
     $results = _doQuery($sql, array(':idEleve' => $idEleve));
     return $results[0] ? $results[0]->counter : 0;
 }
 /**
  * Retourne les écoles d'une ville accessibles pour un utilisateur
  *
  * @param int   $cityId  Identifiant de la ville
  * @param array $groups  Groupes
  *
  * @return CopixDAORecordIterator
  */
 public function findByCityIdAndUserGroups($cityId, $groups)
 {
     $groupsIds = array('schoolsIds' => array(), 'classroomsIds' => array());
     foreach ($groups as $key => $group) {
         $id = substr($key, strrpos($key, '_') + 1);
         if (preg_match('/^administration_staff/', $key)) {
             $groupsIds['schoolsIds'][] = $id;
         } elseif (preg_match('/^principal/', $key)) {
             $groupsIds['schoolsIds'][] = $id;
         } elseif (preg_match('/^teacher_school/', $key)) {
             $groupsIds['schoolsIds'][] = $id;
         } elseif (preg_match('/^teacher/', $key)) {
             $groupsIds['classroomsIds'][] = $id;
         }
     }
     if (empty($groupsIds['schoolsIds']) && empty($groupsIds['classroomsIds'])) {
         return array();
     }
     $sql = $this->_selectQuery . ', kernel_bu_ecole_classe ' . 'WHERE kernel_bu_ecole.numero=kernel_bu_ecole_classe.ecole ' . 'AND kernel_bu_ecole.id_ville=' . $cityId;
     $conditions = array();
     if (!empty($groupsIds['schoolsIds'])) {
         $conditions[] = 'kernel_bu_ecole.numero IN (' . implode(',', $groupsIds['schoolsIds']) . ')';
     }
     if (!empty($groupsIds['classroomsIds'])) {
         $conditions[] = 'kernel_bu_ecole_classe.id IN (' . implode(',', $groupsIds['classroomsIds']) . ')';
     }
     $sql .= ' AND (' . implode('OR', $conditions) . ')';
     $sql .= ' GROUP BY kernel_bu_ecole.numero';
     $sql .= ' ORDER BY kernel_bu_ecole_classe.nom';
     return new CopixDAORecordIterator(_doQuery($sql), $this->getDAOId());
 }
 /**
  * Renvoie le premier message non lu d'une discussion par rapport à la dernière date de lecture par un utilisateur de cette discussion.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/03/09
  * @param integer $topic Id de la discussion
  * @param integer $user Id de l'utilisateur concerné
  * @param array $eleves Tableau avec les ids des élèves (en valeurs)
  * @return mixed Objet DAO ou NULL si l'utilisateur n'a jamais lu la discussion
  */
 public function getFirstUnreadMessage($topic, $user, $eleves)
 {
     //print_r($eleves);
     $sql = "SELECT MIN(FM.id) AS id FROM (module_carnet_messages FM, module_carnet_topics FT) LEFT JOIN module_carnet_tracking TRA ON (TRA.topic={$topic} AND TRA.utilisateur={$user} AND TRA.eleve IN (" . implode(", ", $eleves) . ")) WHERE FM.topic=FT.id AND FM.date>TRA.last_visite ORDER BY 1";
     //print_r($sql);
     return _doQuery($sql);
 }
 /**
  * Admins
  *
  * Affiche la liste des administrateurs
  *
  * @package	Comptes
  * @author	Frédéric Mossmann <*****@*****.**>
  */
 public function processDefault()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $roles = _request('role');
     $new_admin = _request('new_admins');
     if ($roles) {
         $sql = "\n                SELECT dbuser.*, kernel_link_bu2user.*\n                FROM dbuser\n                JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id\n                WHERE dbuser.id_dbuser IN (" . implode(',', array_keys($roles)) . ")\n            ";
         $admins_mod = _doQuery($sql);
         foreach ($admins_mod as $admins_mod_item) {
             $sql = "\n                    DELETE FROM kernel_link_user2node\n                    WHERE node_type='ROOT' AND node_id=0\n                    AND   user_type=:bu_type AND user_id=:bu_id\n                ";
             _doQuery($sql, array(':bu_type' => $admins_mod_item->bu_type, ':bu_id' => $admins_mod_item->bu_id));
             $sql = "\n                    DELETE FROM dbgroup_users\n                    WHERE id_dbgroup=:id_dbgroup AND userhandler_dbgroup=:userhandler_dbgroup AND user_dbgroup=:user_dbgroup";
             $params = array(':id_dbgroup' => 1, ':userhandler_dbgroup' => 'auth|dbuserhandler', ':user_dbgroup' => $admins_mod_item->id_dbuser);
             _doQuery($sql, $params);
             if ($roles[$admins_mod_item->id_dbuser]) {
                 $sql = "\n                        INSERT INTO kernel_link_user2node\n                            ( user_type,  user_id,  node_type,  node_id,  droit)\n                        VALUES\n                            (:user_type, :user_id, :node_type, :node_id, :droit)\n                        ";
                 $params = array(':user_type' => $admins_mod_item->bu_type, ':user_id' => $admins_mod_item->bu_id, ':node_type' => 'ROOT', ':node_id' => 0, ':droit' => $roles[$admins_mod_item->id_dbuser]);
                 _doQuery($sql, $params);
                 $sql = "\n                        INSERT INTO dbgroup_users\n                            ( id_dbgroup,  userhandler_dbgroup,  user_dbgroup)\n                        VALUES\n                            (:id_dbgroup, :userhandler_dbgroup, :user_dbgroup)\n                        ";
                 $params = array(':id_dbgroup' => 1, ':userhandler_dbgroup' => 'auth|dbuserhandler', ':user_dbgroup' => $admins_mod_item->id_dbuser);
                 _doQuery($sql, $params);
             }
         }
     }
     if ($new_admin) {
         $new_admin_array = split(',', $new_admin);
         $new_admin_array_clean = array_map('trim', $new_admin_array);
         $sql_newadmins = "OR dbuser.login_dbuser IN (";
         $first = true;
         foreach ($new_admin_array_clean as $new_admin_array_item) {
             $sql_newadmins .= (!$first ? ", " : "") . "'" . addslashes($new_admin_array_item) . "'";
             $first = false;
         }
         $sql_newadmins .= ")";
     } else {
         $sql_newadmins = '';
     }
     $sql = "\n            SELECT dbuser.*, kernel_link_bu2user.*, kernel_link_user2node.*\n            FROM dbuser\n            JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id\n            LEFT JOIN kernel_link_user2node ON kernel_link_bu2user.bu_type=kernel_link_user2node.user_type AND kernel_link_bu2user.bu_id=kernel_link_user2node.user_id AND kernel_link_user2node.node_type='ROOT' AND kernel_link_user2node.node_id=0\n            WHERE (node_type='ROOT' AND node_id=0)\n            " . $sql_newadmins . "\n            ORDER BY kernel_link_user2node.droit DESC,dbuser.login_dbuser\n        ";
     $admins = _doQuery($sql);
     foreach ($admins as &$admin) {
         $admin->user_infos = Kernel::getUserInfo($admin->bu_type, $admin->bu_id);
     }
     /*
     dbuser : id_dbuser 	login_dbuser 	password_dbuser 	email_dbuser 	enabled_dbuser
     kernel_link_bu2user : user_id 	bu_type 	bu_id
     kernel_link_user2node : user_type 	user_id 	node_type 	node_id 	droit 	debut 	fin
     */
     $tpl = new CopixTpl();
     $tplListe = new CopixTpl();
     $tplListe->assign("admins", $admins);
     $tplListe->assign("user_id", _currentUser()->getExtra('user_id'));
     $tplListe->assign("admin_fonctionnel", Kernel::isAdminFonctionnel());
     $main = $tplListe->fetch("admins-list.tpl");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.admins'));
     $tpl->assign('MAIN', $main);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Retourne le nombre d'élèves concernés par un memo
  *
  * @param int $idMemo
  *
  * @return int
  */
 public function retrieveNombreElevesConcernesParMemo($idMemo)
 {
     $results = array();
     $sql = 'SELECT COUNT(module_cahierdetextes_memo_id) as counter' . ' FROM module_cahierdetextes_memo2eleve' . ' WHERE module_cahierdetextes_memo_id = :idMemo';
     $results = _doQuery($sql, array(':idMemo' => $idMemo));
     return $results[0] ? $results[0]->counter : 0;
 }
 /**
  * Les groupes de villes qui englobent des villes
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2012/10/29
  * @param array $villesIds Tableau avec les ids des villes concernées
  * @return CopixDAORecordIterator
  */
 public function findByVilles($villesIds)
 {
     if (!$villesIds) {
         return array();
     }
     $sql = 'SELECT DISTINCT(gv.id_grv), gv.* FROM kernel_bu_groupe_villes gv, kernel_bu_ville v WHERE v.id_grville = gv.id_grv AND v.id_vi IN (' . implode(', ', $villesIds) . ')';
     return new CopixDAORecordIterator(_doQuery($sql), $this->getDAOId());
 }
 /**
  * @param
  * delete
  * @return
  */
 public function delete($id_blog)
 {
     // Delete item
     $sqlDelete = 'DELETE FROM module_blog WHERE id_blog=' . $id_blog;
     _doQuery($sqlDelete);
     // Delete item
     $sqlDelete = 'DELETE FROM module_blog_functions WHERE id_blog=' . $id_blog;
     _doQuery($sqlDelete);
 }
 /**
  * Retourne les identifiants des élèves concernés par un travail
  *
  * @param int $idTravail
  *
  * @return array
  */
 public function findEleveIdsParTravail($idTravail)
 {
     $toReturn = array();
     $sql = 'SELECT kernel_bu_eleve_idEleve as idEleve' . ' FROM module_cahierdetextes_travail2eleve' . ' WHERE module_cahierdetextes_travail_id = :idTravail' . ' GROUP BY idEleve';
     $resultats = _doQuery($sql, array(':idTravail' => $idTravail));
     foreach ($resultats as $resultat) {
         $toReturn[] = $resultat->idEleve;
     }
     return empty($toReturn) ? null : $toReturn;
 }
 /**
  * @param
  * countNbCommentForArticle
  * @return
  */
 public function countNbCommentForArticle($id_bact, $is_online = 1)
 {
     $sql = 'SELECT count(id_bacc) as nbComment FROM module_blog_articlecomment WHERE id_bact=' . $id_bact . ' AND is_online=' . $is_online . ' group by id_bact ';
     $result = _doQuery($sql);
     if ($result && $result[0]->nbComment > 0) {
         return $result[0]->nbComment;
     } else {
         return 0;
     }
 }
 public function findIdCategoryForArticle($id_bact)
 {
     $critere = ' SELECT DISTINCT artctg.id_bacg as id_bacg ' . ' FROM module_blog_article as art LEFT JOIN module_blog_article_blogarticlecategory as artctg ON art.id_bact = artctg.id_bact' . ' WHERE art.id_bact = ' . $id_bact;
     $res = _doQuery($critere);
     $resultat = array();
     foreach ($res as $ctg) {
         array_push($resultat, $ctg->id_bacg);
     }
     return $resultat;
 }
 /**
  * Statistiques du module groupes de travail
  *
  * Renvoie des éléments chiffrés relatifs aux groupes de travail et dédiés à un utilisateur système : nombre de groupes, de modules...
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/03/20
  * @return array Tableau dont les clefs représentent les libellés des stats et les valeurs les stats chiffrées. Clefs utilisées : ["nbMessages"] ["nbMessages24h"]
  */
 public function getStatsRoot()
 {
     $res = array();
     $sql = 'SELECT COUNT(id) AS nb FROM module_groupe_groupe';
     $a = _doQuery($sql);
     $res['nbGroupes'] = array('name' => CopixI18N::get('groupe|groupe.stats.nbGroupes', array($a[0]->nb)));
     $sql = "SELECT COUNT(user_id) AS nb FROM kernel_link_user2node WHERE node_type='CLUB' AND droit>=" . PROFILE_CCV_READ;
     $a = _doQuery($sql);
     $res['nbMembers'] = array('name' => CopixI18N::get('groupe|groupe.stats.nbMembers', array($a[0]->nb)));
     return $res;
 }
 /**
  * Statistiques du module liste
  *
  * Renvoie des éléments chiffrés relatifs aux listes de diffusion et dédiés à un utilisateur système : nombre de listes, messages envoyés...
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/03/20
  * @return array Tableau dont les clefs représentent les libellés des stats et les valeurs les stats chiffrées. Clefs utilisées : ["nbMalles"] ["nbFolders"] ["nbFiles"] ["size"]
  */
 public function getStatsRoot()
 {
     $res = array();
     $sql = 'SELECT COUNT(id) AS nb FROM module_liste_listes';
     $a = _doQuery($sql);
     $res['nbListes'] = array('name' => CopixI18N::get('liste|liste.stats.nbListes', array($a[0]->nb)));
     $sql = 'SELECT COUNT(id) AS nb FROM module_liste_messages';
     $a = _doQuery($sql);
     $res['nbMessages'] = array('name' => CopixI18N::get('liste|liste.stats.nbMessages', array($a[0]->nb)));
     return $res;
 }
 /**
  * Statistiques du module carnet
  *
  * Renvoie des éléments chiffrés relatifs aux carnets de correspondance et dédiés à un utilisateur système : nombre de messages...
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/03/20
  * @return array Tableau dont les clefs représentent les libellés des stats et les valeurs les stats chiffrées. Clefs utilisées : ["nbTopics"] ["nbMessages"]
  */
 public function getStatsRoot()
 {
     $res = array();
     $sql = 'SELECT COUNT(id) AS nb FROM module_carnet_topics';
     $a = _doQuery($sql);
     $res['nbTopics'] = array('name' => CopixI18N::get('carnet|carnet.stats.nbTopics', array($a[0]->nb)));
     $sql = 'SELECT COUNT(id) AS nb FROM module_carnet_messages';
     $a = _doQuery($sql);
     $res['nbMessages'] = array('name' => CopixI18N::get('carnet|carnet.stats.nbMessages', array($a[0]->nb)));
     return $res;
 }
 /**
  * Vérifie si un élève à des affectations dans une école donnée
  *
  * @param int $studentId Identifiant d'un élève
  * @param int $schoolId  Identifiant de l'école
  *
  * return int
  */
 public function countCurrentAffectInSchool($studentId, $schoolId)
 {
     $sql = 'SELECT count(kernel_bu_eleve_affectation.id) as count
           FROM `kernel_bu_eleve_affectation`
           INNER JOIN kernel_bu_ecole_classe ON (kernel_bu_ecole_classe.ecole = ' . $schoolId . ')
           WHERE kernel_bu_ecole_classe.id = kernel_bu_eleve_affectation.classe
           AND kernel_bu_eleve_affectation.eleve = ' . $studentId . '
           AND kernel_bu_eleve_affectation.current=1';
     $results = _doQuery($sql);
     return $results[0]->count;
 }
 /**
  * Statistiques du module minimail
  *
  * Renvoie des éléments chiffrés relatifs aux minimails et dédiés à un utilisateur système : nombre de messages...
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/03/20
  * @return array Tableau dont les clefs représentent les libellés des stats et les valeurs les stats chiffrées. Clefs utilisées : ["nbMessages"] ["nbMessages24h"]
  */
 public function getStatsRoot()
 {
     $res = array();
     $sql = 'SELECT MAX(id) AS nb FROM module_minimail_from';
     $a = _doQuery($sql);
     $res['nbMessages'] = array('name' => CopixI18N::get('minimail|minimail.stats.nbMessages', array(1 => $a[0]->nb)));
     $sql = 'SELECT COUNT(id) AS nb FROM module_minimail_from WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(date_send)<=60*60*24';
     $a = _doQuery($sql);
     $res['nbMessages24h'] = array('name' => CopixI18N::get('minimail|minimail.stats.nbMessages24h', array(1 => $a[0]->nb)));
     return $res;
 }
 /**
  * Vide la table des configurations sauf exceptions
  *
  * @author Frederic Mossmann <*****@*****.**>
  * @since 2007/01/19
  */
 public function clearConfDB()
 {
     $sauvegarde = array('kernel|jeuEssaiInstalled');
     $saved_data = array();
     reset($sauvegarde);
     foreach ($sauvegarde as $saved_key) {
         if (CopixConfig::exists($saved_key)) {
             $saved_data[$saved_key] = CopixConfig::get($saved_key);
         }
     }
     $sql = "DELETE FROM copixconfig";
     _doQuery($sql);
     foreach ($saved_data as $saved_key => $saved_val) {
         CopixConfig::set($saved_key, $saved_val);
     }
 }
 /**
  * Affiche la liste des blogs ayant au moins un article
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/03/23
  * @param string $kw Mot-clé pour la recherche (option)
  */
 public function _createContent(&$toReturn)
 {
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_fichesecoles.js');
     $kw = $this->getParam('kw', null);
     $tpl = new CopixTpl();
     $dao = _dao("blog|blog");
     if ($kw) {
         $critere = " SELECT * FROM module_blog WHERE is_public=1 AND name_blog LIKE '%" . addslashes($kw) . "%' ORDER BY name_blog";
     } else {
         $critere = " SELECT * FROM module_blog WHERE is_public=1 AND 1 ORDER BY name_blog";
     }
     $sql = _doQuery($critere);
     $list = array();
     //print_r($sql);
     foreach ($sql as $blog) {
         $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
         if ($parent) {
             $blog->parent = $parent['nom'];
             switch ($parent['type']) {
                 case 'CLUB':
                     $blog->type = CopixI18N::get('public.blog.typeClub');
                     break;
                 case 'BU_CLASSE':
                     $blog->type = CopixI18N::get('public.blog.typeClasse');
                     break;
                 case 'BU_ECOLE':
                     $blog->type = CopixI18N::get('public.blog.typeEcole');
                     break;
                 case 'BU_VILLE':
                     $blog->type = CopixI18N::get('public.blog.typeVille');
                     break;
                 default:
                     $blog->type = $parent['type'];
                     break;
             }
         }
         $blog->stats = KernelBlog::getStats($blog->id_blog);
         //print_r($blog);
         if ($blog->stats['nbArticles']['value'] > 0) {
             $list[] = $blog;
         }
     }
     usort($list, "order_tab_blogs");
     $tpl->assign('list', $list);
     $toReturn = $tpl->fetch('getlistblogszone.tpl');
     return true;
 }
 /**
  * Test les droits grace a une requete
  * nom|sousnom
  *
  * @param string $pName Nom principal du droit
  * @param string $pValue Sous nom du droit
  * @return boolean Le droit
  */
 public function test($pName, $pValue)
 {
     //echo "[".$pName."][".$pValue."][".$this->_group."][".$this->_groupHandler.']<br />';
     $arValue = array();
     $query = "select * from dynamiccredentials dc, dynamiccredentialsgroups dcg";
     if ($pValue !== null) {
         $query .= ", dynamiccredentialsvalues dcv1, dynamiccredentialsvalues dcv2";
     }
     $query .= " where dc.id_dc = dcg.id_dc\n                        and dc.name_dc = :name\n                        and dcg.id_group = :id_group\n                        and dcg.handler_group = :handler_group\n                        ";
     $arValue[':name'] = $pName;
     $arValue[':id_group'] = $this->_group;
     $arValue[':handler_group'] = $this->_groupHandler;
     if ($pValue !== null) {
         $query .= "\n                        and dcv2.id_dcv = dcg.id_dcv\n                          and dcv1.id_dc = dc.id_dc\n                          and dcv1.value_dcv = :value\n                          and ((dcv2.level_dcv > dcv1.level_dcv and dcv1.level_dcv is not null) or dcv2.value_dcv = dcv1.value_dcv)";
         $arValue[':value'] = $pValue;
     }
     return count(_doQuery($query, $arValue)) > 0;
 }
 /**
  * Test si l'utilisateur a le credential requis
  *
  * @param string name
  * @param string value
  * @param string group
  * @param string module
  */
 private function _hasCredential($name, $value, $group, $module = null)
 {
     $arValues = array(':name' => $name, ':group' => $group, ':handler_group' => 'auth|dbgrouphandler');
     $sql = 'SELECT * ' . 'FROM modulecredentials mc, dbgroup, modulecredentialsgroups mcg ';
     if ($value != '') {
         $sql .= ', modulecredentialsvalues mcv1, modulecredentialsvalues mcv2 ';
     }
     $sql .= 'WHERE mc.id_mc = mcg.id_mc ' . 'AND mc.name_mc = :name ' . 'AND mcg.id_group = dbgroup.id_dbgroup AND dbgroup.caption_dbgroup = :group ' . 'AND mcg.handler_group = :handler_group ';
     if ($value != '') {
         $sql .= 'AND mcv2.id_mcv = mcg.id_mcv ' . 'AND mcv1.id_mc = mc.id_mc ' . 'AND mcv1.value_mcv = :value ' . 'AND ((mcv2.level_mcv > mcv1.level_mcv AND mcv1.level_mcv IS NOT NULL) OR mcv2.value_mcv = mcv1.value_mcv)';
         $arValues[':value'] = $value;
     }
     if (!is_null($module)) {
         $sql .= ' AND mc.module_mc = :module';
         $arValues[':module'] = $module;
     } else {
         $sql .= ' AND mc.module_mc is null';
     }
     return count(_doQuery($sql, $arValues)) > 0;
 }
 /**
  * Retourne tous les niveaux disponibles dans une école
  *
  * @param int   $schoolId   Identifiant de l'école
  * @param array $groups     Groupes
  * @param int   $gradeId    Année scolaire
  *
  * @return CopixDAORecordIterator
  */
 public function findBySchoolIdAndUserGroups($schoolId, $groups, $gradeId = null)
 {
     $groupsIds = array();
     foreach ($groups as $key => $group) {
         $id = substr($key, strrpos($key, '_') + 1);
         if (preg_match('/^teacher/', $key)) {
             $groupsIds[] = $id;
         } elseif (preg_match('/^schools_group_animator/', $key)) {
             $groupsIds[] = $id;
         } elseif (preg_match('/^cities_group_animator/', $key)) {
             $groupsIds[] = $id;
         }
     }
     $sql = $this->_selectQuery . ' , kernel_bu_ecole_classe_niveau, kernel_bu_ecole_classe ' . 'WHERE kernel_bu_classe_niveau.id_n=kernel_bu_ecole_classe_niveau.niveau ' . 'AND kernel_bu_ecole_classe_niveau.classe=kernel_bu_ecole_classe.id ' . 'AND kernel_bu_ecole_classe.ecole=:schoolId ' . 'AND kernel_bu_ecole_classe.id IN (' . implode(',', $groupsIds) . ')';
     if (!is_null($gradeId)) {
         $sql .= ' AND kernel_bu_ecole_classe.annee_scol = ' . $gradeId;
     }
     $sql .= ' GROUP BY kernel_bu_classe_niveau.id_n ' . 'ORDER BY kernel_bu_classe_niveau.id_n';
     return new CopixDAORecordIterator(_doQuery($sql, array(':schoolId' => $schoolId)), $this->getDAOId());
 }
 /**
  * Affiche la liste des groupes de l'utilisateur courant
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/03/23
  * @param string $kw Mot-clé pour la recherche (option)
  */
 public function _createContent(&$toReturn)
 {
     $toReturn = '';
     $tpl = new CopixTpl();
     if (CopixConfig::exists('|conf_ModConcerto') && CopixConfig::get('|conf_ModConcerto') && _currentUser()->getExtra('type') == 'USER_RES') {
         $new_module = null;
         $sql = 'SELECT id,login,password FROM kernel_bu_auth WHERE node_type=\'responsable\' AND node_id=' . _currentUser()->getExtra('id') . ' AND service=\'concerto\'';
         $concerto = _doQuery($sql);
         if ($concerto) {
             $new_module = _record("kernel|kernel_mod_enabled");
             $new_module->node_type = _currentUser()->getExtra('type');
             $new_module->node_id = _currentUser()->getExtra('id');
             $new_module->module_type = "MOD_CONCERTO";
             $new_module->module_id = 0;
             $modules[] = $new_module;
             $tpl->assign('concerto', $new_module);
             $tpl->assign('concerto_data', $concerto);
             $toReturn = $tpl->fetch('concerto|concerto-home.tpl');
         }
     }
     return true;
 }
 public function getObjet($action, $id_objet)
 {
     if (!$id_objet) {
         return;
     }
     switch ($action) {
         case "showArticle":
             $sql = 'SELECT id_bact AS id, name_bact AS name FROM module_blog_article WHERE id_bact=' . $id_objet;
             break;
         case "showPage":
             $sql = 'SELECT id_bpge AS id, name_bpge AS name FROM module_blog_page WHERE id_bpge=' . $id_objet;
             break;
     }
     if ($sql) {
         $first = _doQuery($sql);
         if (count($first)) {
             return $first[0];
         } else {
             return false;
         }
     }
 }
 /**
  * Renvoie les stats sur une action module (pour trouver les articles les plus cliqués par ex)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/06/14
  * @param array $params Tous les paramètres nécessaires (module_type, module_id, action, date_debut, date_fin...)
  * @return array $stats Statistiques
  */
 public function getStatsModuleAction($params)
 {
     //print_r($params);
     $stats = array();
     $query = "SELECT COUNT(id) AS nb, objet_a FROM module_stats_logs WHERE";
     $query .= " module_type='" . $params['module_type'] . "'";
     $query .= " AND module_id=" . $params['module_id'] . "";
     $query .= " AND action='" . $params['action'] . "'";
     if ($params['date_debut']) {
         $query .= " AND DATE_FORMAT(date, '%Y-%m-%d')>='" . $params['date_debut'] . "'";
     }
     if ($params['date_fin']) {
         $query .= " AND DATE_FORMAT(date, '%Y-%m-%d')<='" . $params['date_fin'] . "'";
     }
     $query .= " GROUP BY objet_a ORDER BY nb DESC";
     //Kernel::deb($query);
     $result = _doQuery($query);
     foreach ($result as $r) {
         $stats[] = $r;
     }
     return $stats;
 }
 /**
  * Statistiques du module annuaire
  *
  * Renvoie des éléments chiffrés relatifs à l'annuaire et dédiés à un utilisateur système : nombre de messages...
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/03/20
  * @return array Tableau dont les clefs représentent les libellés des stats et les valeurs les stats chiffrées. Clefs utilisées : ["nbEcoles"] ["nbClasses"] ["nbEleves"] ["nbPersonnel"] ["nbParents"] ["nbUsers"]
  */
 public function getStatsRoot()
 {
     $res = array();
     $sql = 'SELECT COUNT(numero) AS nb FROM kernel_bu_ecole';
     $a = _doQuery($sql);
     $res['nbEcoles'] = array('name' => CopixI18N::get('annuaire|annuaire.stats.nbEcoles', array($a[0]->nb)));
     $sql = 'SELECT COUNT(id) AS nb FROM kernel_bu_ecole_classe';
     $a = _doQuery($sql);
     $res['nbClasses'] = array('name' => CopixI18N::get('annuaire|annuaire.stats.nbClasses', array($a[0]->nb)));
     $sql = 'SELECT COUNT(numero) AS nb FROM kernel_bu_eleve';
     $a = _doQuery($sql);
     $res['nbEleves'] = array('name' => CopixI18N::get('annuaire|annuaire.stats.nbEleves', array($a[0]->nb)));
     $sql = 'SELECT COUNT(numero) AS nb FROM kernel_bu_personnel';
     $a = _doQuery($sql);
     $res['nbPersonnel'] = array('name' => CopixI18N::get('annuaire|annuaire.stats.nbPersonnel', array($a[0]->nb)));
     $sql = 'SELECT COUNT(numero) AS nb FROM kernel_bu_responsable';
     $a = _doQuery($sql);
     $res['nbParents'] = array('name' => CopixI18N::get('annuaire|annuaire.stats.nbParents', array($a[0]->nb)));
     $sql = 'SELECT COUNT(id_dbuser) AS nb FROM dbuser';
     $a = _doQuery($sql);
     $res['nbUsers'] = array('name' => CopixI18N::get('annuaire|annuaire.stats.nbUsers', array($a[0]->nb)));
     return $res;
 }
 public function getStatsRoot()
 {
     $res = array();
     /*
      * Nombre de quizs
      */
     $sql = '
         SELECT COUNT(id) AS nb
         FROM module_quiz_quiz';
     $a = _doQuery($sql);
     $res['nbQuizs'] = array('name' => CopixI18N::get('quiz|quiz.stats.nbQuizs', array($a[0]->nb)));
     /*
      * Nombre de questions
      */
     $sql = '
         SELECT COUNT(id) AS nb
         FROM module_quiz_questions';
     $a = _doQuery($sql);
     $res['nbQuestions'] = array('name' => CopixI18N::get('quiz|quiz.stats.nbQuestions', array($a[0]->nb)));
     /*
      * Nombre de choix
      */
     $sql = '
         SELECT COUNT(id) AS nb
         FROM module_quiz_choices';
     $a = _doQuery($sql);
     $res['size'] = array('name' => CopixI18N::get('quiz|quiz.stats.nbChoices', array($a[0]->nb)));
     /*
      * Nombre de réponses
      */
     $sql = '
         SELECT COUNT(id) AS nb
         FROM module_quiz_responses';
     $a = _doQuery($sql);
     $res['nbReponses'] = array('name' => CopixI18N::get('quiz|quiz.stats.nbResponses', array($a[0]->nb)));
     return $res;
 }
 /**
  * Test les droits grace a une requete
  * nom|sousnom@module
  *
  * @param string $pModule Le module
  * @param string $pName Nom principal du droit
  * @param string $pValue Sous nom du droit
  * @return boolean Le droit
  */
 public function test($pModule, $pName, $pValue)
 {
     //echo "[".$pModule."][".$pName."][".$pValue."][".$this->_group."][".$this->_groupHandler.']<br />';
     $arValue = array();
     $query = "select * from modulecredentials mc, modulecredentialsgroups mcg";
     if ($pValue !== null) {
         $query .= ", modulecredentialsvalues mcv1, modulecredentialsvalues mcv2";
     }
     $query .= " where mc.id_mc = mcg.id_mc\n                        and mc.name_mc = :name\n                        and mcg.id_group = :id_group\n                        and mcg.handler_group = :handler_group\n                        ";
     $arValue[':name'] = $pName;
     $arValue[':id_group'] = $this->_group;
     $arValue[':handler_group'] = $this->_groupHandler;
     if ($pValue !== null) {
         $query .= "\n                        and mcv2.id_mcv = mcg.id_mcv\n                          and mcv1.id_mc = mc.id_mc\n                          and mcv1.value_mcv = :value\n                          and ((mcv2.level_mcv > mcv1.level_mcv and mcv1.level_mcv is not null) or mcv2.value_mcv = mcv1.value_mcv)";
         $arValue[':value'] = $pValue;
     }
     if ($pModule !== null) {
         $query .= " and mc.module_mc = :module ";
         $arValue[':module'] = $pModule;
     } else {
         $query .= " and mc.module_mc is null ";
     }
     return count(_doQuery($query, $arValue)) > 0;
 }
 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');
 }