public function setPrefs($module, $data)
 {
     // Traiter passwd1 et passwd2
     if ($data['passwd1'] == $data['passwd2'] && strlen($data['passwd1']) > 0) {
         $bu = Kernel::getSessionBU();
         $dao = _dao('kernel|kernel_copixuser');
         $user = $dao->get($bu['user_id']);
         $user->password_dbuser = md5($data['passwd1']);
         $dao->update($user);
     }
     unset($data['passwd1']);
     unset($data['passwd2']);
     // Traiter l'effacement d'un avatar
     if (isset($data['avatar_delete']) && $data['avatar_delete'] == '1') {
         $path2data = realpath("static");
         $path2prefs = $path2data . "/prefs";
         $path2avatars = $path2prefs . "/avatar";
         if ($avatar_old = Prefs::get('prefs', 'avatar')) {
             @unlink($path2avatars . '/' . $avatar_old);
             Prefs::del('prefs', 'avatar');
         }
     }
     // Traiter l'ajout d'un avatar
     if (ereg("^image/(.+)\$", $_FILES['prefs_avatar_upload']['type'], $regs)) {
         if (in_array($regs[1], array('jpeg', 'gif', 'png'))) {
             $path2data = realpath("static");
             $path2prefs = $path2data . "/prefs";
             // if( !is_dir($path2prefs) ) mkdir($path2prefs);
             $path2avatars = $path2prefs . "/avatar";
             // if( !is_dir($path2avatars) ) mkdir($path2avatars);
             if ($avatar_old = Prefs::get('prefs', 'avatar')) {
                 @unlink($path2avatars . '/' . $avatar_old);
             }
             $avatar_file = $path2avatars . "/" . _currentUser()->getLogin() . '.' . $regs[1];
             move_uploaded_file($_FILES['prefs_avatar_upload']['tmp_name'], $avatar_file);
             $data['avatar'] = _currentUser()->getLogin() . '.' . $regs[1];
         }
     }
     if (!isset($data['assistance'])) {
         $data['assistance'] = 0;
     }
     if (!isset($data['assistance_ien'])) {
         $data['assistance_ien'] = 0;
     }
     /*
     if( !isset($data['alerte_mail_active']) ) $data['alerte_mail_active']=0;
     */
     // Enregistrement du reste dans la base principale
     $pref_service =& CopixClassesFactory::Create('prefs|prefs');
     $pref_service->setPrefs($module, $data);
 }
 public function canSsoGael()
 {
     if (!Kernel::isEnseignant() && !Kernel::isAgentVille()) {
         return false;
     }
     if (!CopixConfig::exists('|urlGael') || trim(CopixConfig::get('|urlGael')) == '') {
         return false;
     }
     $mysession = Kernel::getSessionBU();
     if (trim($mysession['cle_privee']) == '') {
         return false;
     }
     return true;
 }
 /**
  * Determine si l'usager peut afficher ou modifier la fiche d'une ecole
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/08/04
  * @param integer $pId Id de l'ecole
  * @param string $pAction Indication eventuelle sur une action precise.
  * @return boolean True s'il a le droit, false sinon
  */
 public function canMakeInFicheEcole($pId, $pAction)
 {
     $can = false;
     //echo "canMakeInFicheEcole ($pId, $pAction)";
     $session = Kernel::getSessionBU();
     $myNodes = Kernel::getMyNodes();
     if ($pAction == "VIEW") {
         return true;
     }
     //var_dump($myNodes);
     //var_dump($session);
     switch ($session['type']) {
         case 'USER_ENS':
             foreach ($myNodes as $node) {
                 if ($node->type == 'BU_ECOLE' && $node->id == $pId && $node->droit >= 70) {
                     if ($pAction == 'MODIFY') {
                         $can = true;
                     }
                 }
             }
             break;
         case 'USER_VIL':
             if ($pAction == 'MODIFY_VILLE') {
                 // Court-circuite du reste, canMakeInFicheEcole(MODIFY) ayant forcement ete fait avant
                 return true;
             }
             foreach ($myNodes as $node) {
                 if ($node->type == 'BU_ECOLE' && $node->id == $pId && $node->droit >= 70) {
                     $can = true;
                 }
             }
             if (!$can) {
                 // On verifie si l'ecole est dans sa ville
                 $rEcole = Kernel::getNodeInfo('BU_ECOLE', $pId, false);
                 reset($myNodes);
                 //var_dump($myNodes);
                 //var_dump($rEcole['ALL']);
                 foreach ($myNodes as $node) {
                     if ($node->type == 'BU_VILLE' && $node->id == $rEcole['ALL']->vil_id_vi && $node->droit >= 70) {
                         $can = true;
                     }
                 }
             }
             break;
     }
     return $can;
 }
 public function user()
 {
     if (Kernel::is_connected()) {
         $session = Kernel::getSessionBU();
         $this->userId = $session['user_id'];
         $this->name = trim($session['prenom'] . ' ' . $session['nom']);
         $this->email = '';
         $this->web = '';
         $this->isConnected = true;
     } else {
         $this->name = '';
         $this->userId = 0;
         $this->email = '';
         $this->web = '';
         $this->isConnected = false;
     }
 }
Пример #5
0
 public function set($data = null)
 {
     $dao = _dao("logs|logs");
     $nouveau = _record("logs|logs");
     $types = array('ERROR', 'DEBUG', 'INFO', 'ALERT', 'LOG', 'AUTO', 'GO');
     if (isset($data['type']) && in_array($data['type'], $types)) {
         $nouveau->logs_type = $data['type'];
     } else {
         $nouveau->logs_type = 'UNKNOWN';
     }
     if (isset($data['message'])) {
         $nouveau->logs_message = $data['message'];
     }
     $module = CopixRequest::get('module', 'kernel');
     $action = CopixRequest::get('action', 'default');
     $nouveau->logs_mod_name = $module;
     $nouveau->logs_mod_action = $action;
     $user = Kernel::getSessionBU();
     if (sizeof($user) && isset($user['id'])) {
         $nouveau->logs_user_id = $user['id'];
         $nouveau->logs_user_login = $user['login'];
     }
     // Node
     $nouveau->logs_date = date("Y-m-j H:i:s", time());
     $nouveau->logs_user_ip = $_SERVER['REMOTE_ADDR'];
     $nouveau->logs_url = $_SERVER['QUERY_STRING'];
     // Kernel::MyDebug( $nouveau );
     if (isset($data['node_type'])) {
         $nouveau->logs_node_type = $data['node_type'];
     }
     if (isset($data['node_id'])) {
         $nouveau->logs_node_id = $data['node_id'];
     }
     if (isset($data['module_type'])) {
         $nouveau->logs_module_type = $data['module_type'];
     }
     if (isset($data['module_id'])) {
         $nouveau->logs_module_id = $data['module_id'];
     }
     $dao->insert($nouveau);
 }
 /**
  * Ajout d'une info supplementaire dans une intervention. Le message est ajoute avec l'utilisateur courante, a la date du moment
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/03/04
  * @param string $info_message Champ message
  * @param string $info_message Champ commentaire
  * @return integer Id de l'info ajoutee
  */
 public function insertInfoSupp($info_message, $info_commentaire)
 {
     $daoInfoSupp = _dao("teleprocedures|infosupp");
     $daoIntervention = _dao("teleprocedures|intervention");
     $rForm = _record('teleprocedures|infosupp');
     //var_dump($this);
     $session = Kernel::getSessionBU();
     $rForm->idinter = $this->idinter;
     $rForm->iduser = $session['user_id'];
     $rForm->dateinfo = date('Y-m-d H:i:s');
     if ($info_message && trim($info_message) != '<br />') {
         $rForm->info_message = $info_message;
     }
     if ($info_commentaire && trim($info_commentaire) != '<br />') {
         $rForm->info_commentaire = $info_commentaire;
     }
     $daoInfoSupp->insert($rForm);
     if ($rForm->idinfo > 0 && $rForm->info_message) {
         // MAJ uniquement si echange
         $this->datederniere = $rForm->dateinfo;
         $daoIntervention->update($this);
     }
     return $rForm->idinfo;
 }
Пример #7
0
 public function del($module, $code, $user = -1)
 {
     $dao = _dao('prefs|prefs');
     if ($user == -1) {
         $bu = Kernel::getSessionBU();
         if (isset($bu['user_id'])) {
             $user = $bu['user_id'];
         }
     }
     if ($pref = $dao->get($user, $module, $code)) {
         $dao->delete($user, $module, $code);
     }
 }
 /**
  * Insertion d'une teleprocedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/01/30
  * @param integer $ecole Id de l'ecole
  * @param integer $idtype Type de la teleprocedure
  */
 public function insert()
 {
     $save = _request("save") ? _request("save") : NULL;
     $idtype = _request("idtype") ? _request("idtype") : NULL;
     $idstatu = _request("idstatu") ? _request("idstatu") : NULL;
     $objet = _request("objet") ? _request("objet") : NULL;
     $detail = _request("detail") ? _request("detail") : NULL;
     $criticErrors = $errors = array();
     $daoType =& CopixDAOFactory::create('teleprocedures|type');
     if ($idtype) {
         if ($rType = $daoType->get($idtype)) {
             $mondroit = Kernel::getLevel("MOD_TELEPROCEDURES", $rType->teleprocedure);
             if (!TeleproceduresService::canMakeInTelep('ADD_INTERVENTION', $mondroit)) {
                 $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
             }
         } else {
             $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.noParameter');
         }
         $rEcole = Kernel::getNodeInfo('BU_ECOLE', TeleproceduresService::getTelepEcole(), false);
         if (!$rEcole) {
             $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.prob.ecole');
         }
     } else {
         $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.noParameter');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('teleprocedures||')));
     }
     $title = $rEcole["nom"] . ($rEcole["desc"] ? " (" . $rEcole["desc"] . ")" : "");
     $rForm = CopixDAOFactory::createRecord('intervention');
     if ($save == 1) {
         if (!$objet) {
             $errors[] = CopixI18N::get('teleprocedures.error.objet.manquant');
         }
         if (!$detail || $detail == html_entity_decode(CopixI18N::get('teleprocedures.interv.default.detail'))) {
             $errors[] = CopixI18N::get('teleprocedures.error.detail.manquant');
         }
         $rForm->idtype = $idtype;
         $rForm->format = $rType->format;
         //$rForm->idstatu = $idstatu;
         $rForm->idstatu = CopixConfig::get('teleprocedures|statutNouveau');
         $rForm->objet = $objet;
         $rForm->detail = $detail;
         if (!count($errors)) {
             $daoIntervention = CopixDAOFactory::create("intervention");
             $session = Kernel::getSessionBU();
             $rForm->iduser = $session['user_id'];
             $rForm->dateinter = date('Ymd');
             $rForm->idetabliss = $rEcole["id"];
             //$rForm->datederniere = 0;
             $rForm->datederniere = date('Y-m-d H:i:s');
             $rForm->responsables = $rType->responsables;
             $rForm->lecteurs = $rType->lecteurs;
             $rForm->mail_from = $rType->mail_from;
             $rForm->mail_to = $rType->mail_to;
             $rForm->mail_cc = $rType->mail_cc;
             $rForm->mail_message = $rType->mail_message;
             //print_r($rForm);
             $daoIntervention->insert($rForm);
             if ($rForm->idinter) {
                 $droits = TeleproceduresService::copyDroitFromTypeToInter($rForm);
                 TeleproceduresService::alertResponsables($rForm, $droits);
                 TeleproceduresService::userReadIntervention($rForm->idinter, $session['user_id']);
             }
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('|listTeleprocedures', array('id' => $rType->teleprocedure)));
         }
     } else {
         $rForm->objet = $rType->nom;
         $rForm->idtype = $idtype;
         $rForm->format = $rType->format;
         $rForm->detail = $rType->texte_defaut ? $rType->texte_defaut : html_entity_decode(CopixI18N::get('teleprocedures.interv.default.detail'));
     }
     $tplForm = new CopixTpl();
     $tplForm->assign('detail_edition', CopixZone::process('kernel|edition', array('field' => 'detail', 'format' => $rForm->format, 'content' => $rForm->detail, 'height' => 450)));
     $tplForm->assign('date', date("Y-m-d"));
     $tplForm->assign('rEcole', $rEcole);
     $tplForm->assign('rForm', $rForm);
     $tplForm->assign('rType', $rType);
     $tplForm->assign('errors', $errors);
     //var_dump($rEcole);
     $daoStat =& CopixDAOFactory::create('teleprocedures|statu');
     $tplForm->assign('arStat', $daoStat->findAll());
     $daoType =& CopixDAOFactory::create('teleprocedures|type');
     $tplForm->assign('arType', $daoType->findAll());
     $main = $tplForm->fetch('insert.tpl');
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('teleprocedures.title.newTelep'));
     $tpl->assign("MAIN", $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Le profil de l'usager courante dans les teleprocedures : directeur, agent de ville ou root ville
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/01/19
  * @return string Le type de profil : DIRECTEUR / AGENT_VILLE / ROOT_VILLE
  */
 public function getTelepProfil()
 {
     $res = '';
     $session = Kernel::getSessionBU();
     switch ($session['type']) {
         case 'USER_ENS':
             $res = 'DIRECTEUR';
             break;
         case 'USER_ADM':
             if (CopixConfig::exists('teleprocedures|USER_ADM_as_USER_ENS') && CopixConfig::get('teleprocedures|USER_ADM_as_USER_ENS')) {
                 $res = 'DIRECTEUR';
             }
             break;
         case 'USER_VIL':
             $res = 'AGENT_VILLE';
             break;
         case 'ROOT_VIL':
             $res = 'ROOT_VILLE';
             break;
             // TODO
     }
     return $res;
 }
 /**
  * Affiche une discussion d'un cahier de correspondance
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/16
  * @param integer $id Id de la discussion
  * @param integer $eleve (option) Id de l'élève
  * @param integer $print (option, 0 par défaut) Si 1, affiche la discussion au format imprimable
  * @param string $go (option) Si vaut "new", redirige sur le premier message non lu de la discussion
  */
 public function getTopic()
 {
     $dao = CopixDAOFactory::create("carnet_topics");
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     $carnet_service =& CopixClassesFactory::Create('carnet|CarnetService');
     $id = $this->getRequest('id', null);
     $eleve = $this->getRequest('eleve', null);
     $print = $this->getRequest('print', 0);
     $go = $this->getRequest('go', null);
     $session = Kernel::getSessionBU();
     $criticErrors = array();
     if ($go == "new") {
         $daoTracking = CopixDAOFactory::create("carnet|carnet_tracking2");
         if ($eleve && $eleve != 'CLASSE') {
             $idEleves = array($eleve);
         } else {
             $to = $dao->getElevesForTopic($id);
             $idEleves = array();
             foreach ($to as $item) {
                 $idEleves[] = $item->eleve;
             }
         }
         //print_r($idEleves);
         //die();
         $unread = $daoTracking->getFirstUnreadMessage($id, $session['user_id'], $idEleves);
         //_dump($unread[0]);
         if ($unread[0]->id) {
             // Il est déjà passé dans le topic
             $urlReturn = CopixUrl::get('|getTopic', array('id' => $id, 'eleve' => $eleve)) . '#m' . $unread[0]->id;
         } else {
             // Jamais passé, on le renvoie au début du topic
             $urlReturn = CopixUrl::get('|getTopic', array('id' => $id, 'eleve' => $eleve));
         }
         //die($urlReturn);
         return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
     }
     $topic = $dao->get($id);
     $classe = $topic->classe;
     $ppo = new CopixPPO();
     if (!$topic) {
         $criticErrors[] = CopixI18N::get('carnet|carnet.error.noTopic');
     }
     $matrix =& enic::get('matrixCache');
     $ppo->canView_USER_RES = $matrix->classe($classe)->_right->USER_RES->voir;
     $ppo->canView_USER_ENS = $matrix->classe($classe)->_right->USER_ENS->voir;
     $ppo->canView_USER_ELE = $matrix->classe($classe)->_right->USER_ELE->voir;
     //_dump($canWrite_USER_RES);
     $mondroit = $carnet_service->getUserDroitInCarnet(array("classe" => $classe, "eleve" => $eleve));
     //print_r("mondroit=$mondroit");
     if (!$mondroit) {
         $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('carnet||getCarnet', array())));
     }
     if (0) {
     } else {
         //			print_r2($topic);
         // 1. Infos sur le topic
         $userInfo = $kernel_service->getUserInfo("ID", $topic->createur);
         $topic->createur_nom = $userInfo["prenom"] . " " . $userInfo["nom"];
         $topic->createur_infos = $userInfo;
         $to = $dao->getElevesForTopic($topic->id);
         while (list($k, ) = each($to)) {
             $userInfo = $kernel_service->getUserInfo("USER_ELE", $to[$k]->eleve);
             $to[$k]->eleve_infos = $userInfo["prenom"] . " " . $userInfo["nom"];
         }
         $topic->eleves = $to;
         $topic->nb_eleves = count($to);
         // Avatar de l'auteur
         $avatar = Prefs::get('prefs', 'avatar', $topic->createur);
         $topic->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         //print_r2($topic);
         // 2. Les messages
         if ($eleve && $eleve != 'CLASSE') {
             // Filtrage sur un élève
             $list = $dao->getListCarnetsMessagesForTopicAndEleve($id, $eleve);
             $idEleves = array($eleve);
         } else {
             // Tous les élèves de la classe
             $eleves = $carnet_service->getUserElevesInClasse($topic->classe);
             $list = $dao->getListCarnetsMessagesForTopicAndEleves($id, $eleves);
             //print_r($list);
             $idEleves = array();
             foreach ($to as $item) {
                 $idEleves[] = $item->eleve;
             }
         }
         //print_r($idEleves);
         while (list($k, ) = each($list)) {
             $userInfo = $kernel_service->getUserInfo("ID", $list[$k]->auteur);
             $list[$k]->auteur_nom = $userInfo["prenom"] . " " . $userInfo["nom"];
             $list[$k]->auteur_infos = $userInfo;
             $userInfo = $kernel_service->getUserInfo("USER_ELE", $list[$k]->eleve);
             $list[$k]->eleve_nom = $userInfo["prenom"] . " " . $userInfo["nom"];
             $list[$k]->eleve_infos = $userInfo;
             // Avatar de l'expéditeur
             $avatar = Prefs::get('prefs', 'avatar', $list[$k]->auteur);
             $list[$k]->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         }
         $canWriteClasse = $carnet_service->canMakeInCarnet('WRITE_CLASSE', NULL);
         $canPrintTopic = $carnet_service->canMakeInCarnet('PRINT_TOPIC', NULL);
         // On enregistre sa lecture (tracking)
         $carnet_service->userReadTopic($id, $session['user_id'], $idEleves);
         CopixHTMLHeader::addCSSLink(_resource("styles/module_carnet.css"));
         if ($print) {
             CopixHTMLHeader::addCSSLink(_resource("styles/module_carnet_print.css"), array('media' => 'print'));
         }
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $topic->titre);
         //$tpl->assign ('MENU', '<a href="'.CopixUrl::get ('carnet||getCarnet', array("classe"=>$classe, "eleve"=>$eleve)).'">'.CopixI18N::get ('carnet|carnet.backCarnet').'</a>');
         //print_r($list);
         //print_r($topic);
         $tplListe = new CopixTpl();
         $tplListe->assign('ppo', $ppo);
         $tplListe->assign('topic', $topic);
         $tplListe->assign('eleve', $eleve);
         $tplListe->assign('canWriteClasse', $canWriteClasse);
         $tplListe->assign('canPrintTopic', $canPrintTopic);
         $tplListe->assign('list', $list);
         $tplListe->assign('session', Kernel::getSessionBU());
         $tplListe->assign('linkClasse', CopixUrl::get('carnet||getTopic', array('id' => $topic->id)));
         if ($print) {
             $result = $tplListe->fetch("gettopicprint.tpl");
         } else {
             $result = $tplListe->fetch("gettopic.tpl");
         }
         $tpl->assign("MAIN", $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 public function getRessource()
 {
     $tpl = new CopixTpl();
     $tplMain = new CopixTpl();
     $mode = _request("mode", "view");
     if (0 && !_request("id")) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('ressource.error.numBiblioNonDef'), 'back' => CopixUrl::get('||')));
     }
     $id = _request("id");
     $ressource_dao = CopixDAOFactory::create("ressource_ressources");
     // Liste des domaines par niveaux
     $niveau_dao = CopixDAOFactory::create("ressource_niveaux");
     $domaine_dao = CopixDAOFactory::create("ressource_domaines");
     $niveau_list = $niveau_dao->getOrdre();
     foreach ($niveau_list as $niveau_key => $niveau_val) {
         $niveau_list[$niveau_key]->domaines = $domaine_dao->getByNiveau($niveau_val->niveaux_id);
     }
     $tplMain->assign('niveau_list', $niveau_list);
     // Liste des fonctions
     $fonction_dao = CopixDAOFactory::create("ressource_fonctions");
     $fonction_list = $fonction_dao->getOrdre();
     $tplMain->assign('fonction_list', $fonction_list);
     // Liste des contenus
     $contenu_dao = CopixDAOFactory::create("ressource_contenus");
     $contenu_list = $contenu_dao->getOrdre();
     $tplMain->assign('contenu_list', $contenu_list);
     if ($mode == "view" || $mode == "edit") {
         // if( $mode=="view" ) $minright=PROFILE_CCV_SHOW;
         if ($mode == "view") {
             $minright = 0;
         } else {
             $minright = PROFILE_CCV_PUBLISH;
         }
         if (!Ressource::checkRight("RES", $id, $minright)) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('ressource.error.accesInterdit'), 'back' => CopixUrl::get('||')));
         }
         $ressource = $ressource_dao->get($id);
         $tags_dao = CopixDAOFactory::create("ressource_tags");
         $tags = $tags_dao->getTagsForRessource($id, $ressource->ressources_id_annu);
         $tplMain->assign('ressource', $ressource);
         $tplMain->assign('tags_list', $tags);
         $tpl->assign('TITLE_PAGE', CopixI18N::get('ressource.title.module') . ' &raquo; ' . $ressource->ressources_nom);
         $menu = array();
         if ($mode == "view" && Ressource::checkRight("RES", $id, PROFILE_CCV_MODERATE)) {
             $menu[] = array('url' => CopixUrl::get('ressource||getRessource', array('id' => $ressource->ressources_id, 'mode' => 'edit')), 'txt' => CopixI18N::get('ressource.menu.modifierRessource'));
         }
         if ($mode == "edit" && Ressource::checkRight("RES", $id, PROFILE_CCV_MODERATE)) {
             $menu[] = array('url' => CopixUrl::get('ressource||getRessource', array('id' => $ressource->ressources_id, 'mode' => 'del')), 'txt' => CopixI18N::get('ressource.menu.effacerRessource'));
         }
         $menu[] = array('url' => CopixUrl::get('|getSearchAdvanced', array('id' => $ressource->ressources_id_annu)), 'txt' => CopixI18N::get('ressource.menu.parCriteres'));
         $menu[] = array('url' => CopixUrl::get('ressource||getList', array('id' => $ressource->ressources_id_annu)), 'txt' => CopixI18N::get('ressource.menu.retourListe'));
         if (Ressource::checkRight("RES", $id, PROFILE_CCV_WRITE)) {
             $menu[] = array('url' => CopixUrl::get('ressource||getRessource', array('id' => $ressource->ressources_id_annu, 'mode' => 'new')), 'txt' => CopixI18N::get('ressource.menu.ajouterRessource'));
         }
         // Liste des domaines sélectionnées
         $domainesel_dao = CopixDAOFactory::create("ressource_res2domaine");
         $domainesel_tmp = $domainesel_dao->getByRessource($ressource->ressources_id);
         foreach ($domainesel_tmp as $domainesel_key => $domainesel_val) {
             $domainesel_list[$domainesel_val->domaines_id] = true;
         }
         $tplMain->assign('domainesel_list', $domainesel_list);
         // Liste des fonctions sélectionnées
         $fonctionsel_dao = CopixDAOFactory::create("ressource_res2fonction");
         $fonctionsel_tmp = $fonctionsel_dao->getByRessource($ressource->ressources_id);
         foreach ($fonctionsel_tmp as $fonctionsel_key => $fonctionsel_val) {
             $fonctionsel_list[$fonctionsel_val->fonctions_id] = true;
         }
         $tplMain->assign('fonctionsel_list', $fonctionsel_list);
         // Liste des contenus sélectionnées
         $contenusel_dao = CopixDAOFactory::create("ressource_res2contenu");
         $contenusel_tmp = $contenusel_dao->getByRessource($ressource->ressources_id);
         foreach ($contenusel_tmp as $contenusel_key => $contenusel_val) {
             $contenusel_list[$contenusel_val->contenus_id] = true;
         }
         $tplMain->assign('contenusel_list', $contenusel_list);
         $tplMain->assign('annu_id', $ressource->ressources_id_annu);
         $tplMain->assign('res_id', $id);
         if ($mode == "edit") {
             $tplMain->assign('edit', true);
         }
     }
     if ($mode == "new") {
         if (!Ressource::checkRight("ANNU", $id, PROFILE_CCV_WRITE)) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('ressource.error.accesInterdit'), 'back' => CopixUrl::get('||')));
         }
         $ressource = CopixDAOFactory::createRecord("ressource_ressources");
         $userinfo = Kernel::getSessionBU();
         if (isset($userinfo['nom']) && isset($userinfo['prenom'])) {
             $ressource->ressources_submit_user = trim($userinfo['prenom'] . ' ' . $userinfo['nom']);
         }
         $tplMain->assign('ressource', $ressource);
         $tplMain->assign('annu_id', $id);
         $tplMain->assign('res_id', 0);
         $tplMain->assign('edit', true);
         $tpl->assign('TITLE_PAGE', CopixI18N::get('ressource.title.module') . ' &raquo; ' . CopixI18N::get('ressource.title.nouvelleRessource'));
         $menu = array();
         $menu[] = array('url' => CopixUrl::get('ressource||getList', array('id' => $id)), 'txt' => CopixI18N::get('ressource.menu.retourListe'));
     }
     if ($mode == "del") {
         if (!Ressource::checkRight("RES", $id, PROFILE_CCV_MODERATE)) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('ressource.error.accesInterdit'), 'back' => CopixUrl::get('||')));
         }
         $ressource = CopixDAOFactory::createRecord("ressource_ressources");
         $ressource = $ressource_dao->get($id);
         // DELETE
         if (_request("confirm") == md5(_currentUser()->getLogin() . $ressource->ressources_id)) {
             die("DELETE");
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('ressource.title.delete', array($ressource->ressources_nom)));
         $menu = array();
         $menu[] = array('url' => CopixUrl::get('ressource||getRessource', array('id' => $ressource->ressources_id, 'mode' => 'edit')), 'txt' => CopixI18N::get('ressource.menu.retourRessource'));
         $menu[] = array('url' => CopixUrl::get('ressource||getList', array('id' => $ressource->ressources_id_annu)), 'txt' => CopixI18N::get('ressource.menu.retourListe'));
         return CopixActionGroup::process('genericTools|Messages::getConfirm', array('title' => CopixI18N::get('ressource.alerte.effaceRessource', array($ressource->ressources_nom)), 'confirm' => CopixUrl::get('ressource||getRessource', array('id' => $ressource->ressources_id, 'mode' => 'del', 'confirm' => md5(_currentUser()->getLogin() . $ressource->ressources_id))), 'cancel' => CopixUrl::get('ressource||getRessource', array('id' => $ressource->ressources_id)), 'back' => CopixUrl::get('||')));
     }
     // Liste des ressources
     $result = $tplMain->fetch("getressource.tpl");
     $tpl->assign('MENU', $menu);
     $tpl->assign('MAIN', $result);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }