/**
  * Validate the user's informations.
  */
 function doValid()
 {
     if (!($toValid = $this->_getSession())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('users.error.unableToGetObject'), 'back' => CopixUrl::get('users|admin|')));
     }
     $pluginAuth =& $GLOBALS['COPIX']['COORD']->getPlugin('auth|auth');
     $authUser = $pluginAuth->getUser();
     //demande de mettre l'objet à jour en fonction des valeurs saisies dans le
     //formulaire.
     $this->_validFromForm($toValid);
     $existingGroups = array();
     //vérifie si l'utilisateur n'existe pas déja.
     if ($toValid->is__new) {
         if ($authUser->get($toValid->login)) {
             $this->_setSession($toValid);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('users|admin|edit', array('e' => '1', 'exist' => '1')));
         }
     } else {
         $userProfile =& new CopixProfile($toValid->login);
         $existingGroups = $userProfile->getGroups();
     }
     if (($errors = $this->_check($toValid)) !== true) {
         $this->_setSession($toValid);
         return CopixActionGroup::process('users|AdminUsers::getEdit', array('e' => 1, 'errors' => $errors));
     } else {
         //modif ou création selon le cas.
         if ($toValid->is__new === false) {
             //Tentative de mise à jour des informations
             $authUser->updateInformations($toValid->login, $toValid);
             //Mise à jour du mot de passe si demandé.
             if ($toValid->__newPassword) {
                 $authUser->updatePassword($toValid->login, $toValid->password);
             }
             //on suprime la liste des groupes auquel il appartenait avant
             $daoUserGroup =& CopixDAOFactory::create('copix:CopixUserGroup');
             $daoUserGroup->removeUser($toValid->login);
         } else {
             $authUser->createUser($toValid);
         }
         //on rajoute maintenant les utilisateurs du groupe.
         $daoUserGroup =& CopixDAOFactory::create('copix:CopixUserGroup');
         $groupUser =& CopixDAOFactory::createRecord('copix:CopixUserGroup');
         $groupUser->login_cusr = $toValid->login;
         foreach ((array) $toValid->__groups as $group) {
             $groupUser->id_cgrp = $group->id_cgrp;
             $daoUserGroup->insert($groupUser);
         }
         //retour sur la page de liste.
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('users|admin|', array('pattern' => $toValid->login)));
     }
 }
 /**
  * Moves all the path that are linked to the given path
  */
 function move($path, $newPath)
 {
     $dao =& CopixDAOFactory::create('copix:CopixCapability');
     $daoGroupCap =& CopixDAOFactory::create('copix:CopixGroupCapabilities');
     //gets the moved list.
     $listToMove = $this->getList($path);
     //moves the elements.
     foreach ($listToMove as $pathToReplace) {
         $pathToCreate = str_replace($path, $newPath, $pathToReplace);
         //creates the dest cap.
         $oldCap =& $dao->get($pathToReplace);
         $newCap =& CopixDAOFactory::createRecord('copix:CopixCapability');
         $newCap->name_ccpb = str_replace($path, $newPath, $pathToReplace);
         $newCap->description_ccpb = $oldCap->description_ccpb;
         $dao->insert($newCap);
         //moves associations.
         $daoGroupCap->movePath($pathToReplace, $pathToCreate);
         $dao->delete($pathToReplace);
     }
 }
 /**
  * Soumission du formulaire de création d'un dossier
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/12/02
  * @param integer $id Id de la malle
  * @param integer $folder Id du répertoire destination
  * @param sting $new_folder Nom du répertoire à créer
  */
 public function doAddFolder()
 {
     $kernelService =& CopixClassesFactory::Create('kernel|kernel');
     $malleService =& CopixClassesFactory::Create('malle|malleService');
     $daoMalles = CopixDAOFactory::create("malle|malle_malles");
     $daoFolders = CopixDAOFactory::create("malle|malle_folders");
     $id = $this->getRequest('id', null);
     $folder = $this->getRequest('folder', 0);
     $new_folder = $this->getRequest('new_folder', null);
     $criticErrors = array();
     if ($folder) {
         $rFolder = $daoFolders->get($folder);
         if (!$rFolder) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noFolder');
         } elseif ($rFolder->malle != $id) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noFolder');
         }
     } else {
         $rMalle = $daoMalles->get($id);
         if (!$rMalle) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noMalle');
         }
     }
     if (!$criticErrors) {
         $mondroit = $kernelService->getLevel("MOD_MALLE", $id);
         //print_r($mondroit);
         if (!$malleService->canMakeInMalle("FOLDER_CREATE", $mondroit)) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         } else {
             $parent = $kernelService->getModParentInfo("MOD_MALLE", $id);
         }
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('malle||')));
     } else {
         $errors = array();
         if (!$new_folder) {
             $errors[] = CopixI18N::get('malle|malle.error.typeFolder');
         }
         if (!$errors) {
             // On insère dans la base
             $new = CopixDAOFactory::createRecord("malle|malle_folders");
             $new->malle = $id;
             $new->parent = $folder;
             $new->nom = $new_folder;
             $new->date_creation = date("Y-m-d H:i:s");
             $new->nb_folders = 0;
             $new->nb_files = 0;
             $new->taille = 0;
             $daoFolders->insert($new);
             if ($new->id !== NULL) {
                 $malleService->update_infos_for_folder($id, $folder);
                 $urlReturn = CopixUrl::get('malle||getMalle', array('id' => $id, 'folder' => $folder));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             } else {
                 // Prob d'insertion dans la base
                 $errors[] = CopixI18N::get('malle|malle.error.createFolder');
             }
         }
         return CopixActionGroup::process('malle|malle::getMalle', array('id' => $id, 'folder' => $folder, 'errors' => $errors));
     }
 }
 /**
  * Store data
  *
  * @access private
  */
 function storeData($entityName)
 {
     $_entityName = $entityName;
     $_httpRequest =& HttpRequest::instance();
     $_session =& HttpSession::instance();
     $_tagged = $_session->getAttribute('TAGGED');
     $_index = $_session->getAttribute('INDEX');
     $_create = $_index < 0;
     $_next = false;
     if ($_httpRequest->getAttribute('accept')) {
         $_httpRequest->removeAttribute('accept');
         $_new = $_httpRequest->getAttribute('ENTITY');
         foreach ($_session->getAttribute('ENTITY') as $_key => $_value) {
             $_old[$_key] = $_value;
         }
         $_equal = true;
         foreach ($_new as $_key => $_value) {
             if ($_value !== $_old[$_key]) {
                 $_updated[$_key] = $_value;
                 $_equal = false;
             } else {
                 $_updated[$_key] = $_old[$_key];
             }
         }
         if (!$_equal) {
             $_dao =& CopixDAOFactory::create($_entityName);
             if ($_create) {
                 $_entity =& CopixDAOFactory::createRecord($_entityName);
                 foreach ($_updated as $_key => $_value) {
                     $_entity->{$_key} = $_value;
                 }
                 $_dao->insert($_entity);
                 $_connection =& CopixDbFactory::getConnection();
                 $_tagged[] = $_connection->lastId();
             } else {
                 // update
                 $_dlname = 'get' . $_entityName . 'DataList';
                 $_dataList = $this->{$_dlname}();
                 $_idLabel = $_dataList['id']['var'];
                 $_entity = $_dao->get($_updated[$_idLabel]);
                 foreach ($_updated as $_key => $_value) {
                     $_entity->{$_key} = $_value;
                 }
                 $_dao->update($_entity);
             }
         }
         ++$_index;
         // next one ?
         $_next = $_create || $_index < sizeOf($_tagged);
     } elseif ($_httpRequest->getAttribute('cancel')) {
         $_httpRequest->removeAttribute('cancel');
         ++$_index;
         // next one ?
         $_next = !$_create && $_index < sizeOf($_tagged);
     } else {
         // always return to the list
     }
     if ($_next) {
         $_session->setAttribute('INDEX', $_index);
         $_httpRequest->removeAttribute('ENTITY');
         $_forward = $_create ? 'create' : 'update';
         $_httpRequest->setAttribute($_forward, $_forward);
         // $_httpRequest->setAttribute('TAGGED', $_tagged);
         // TODO: la méthode CopixUrl::getUrl ne gère pas correctement les tableaux, d'où :
         foreach ($_tagged as $_key => $_Id) {
             $_httpRequest->setAttribute('TAGGED[' . $_key . ']', $_Id);
         }
         $_requestUrl = new ProjectUrl('manage' . $_entityName . 'Data', null, 'workflow', $_httpRequest->toArray());
     } else {
         $_requestUrl = new ProjectUrl('show' . $_entityName . 'List', null, 'workflow');
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, $_requestUrl->getUrl(false));
 }
 function _saveUsers($toSave)
 {
     $daoUserGroup =& CopixDAOFactory::create('copix:CopixUserGroup');
     $groupUser =& CopixDAOFactory::createRecord('copix:CopixUserGroup');
     $groupUser->id_cgrp = $toSave->id_cgrp;
     foreach ($toSave->getUsers() as $login) {
         $groupUser->login_cusr = $login;
         $daoUserGroup->insert($groupUser);
     }
 }
 /**
  * Validation d'un commentaire (=ajout d'un comm)
  */
 public function doValidComment()
 {
     $id_blog = $this->getRequest('id_blog', null);
     $id_bact = $this->getRequest('id_bact', null);
     if (!BlogAuth::canMakeInBlog('ADMIN_ARTICLES', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     // On r�cup�re l'utilisateur connect�
     $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment');
     // CREATION D'UN COMM
     $comment = CopixDAOFactory::createRecord('blogarticlecomment');
     $this->_validFromPostProperties($comment);
     $comment->date_bacc = date('Ymd');
     $comment->time_bacc = date('Hi');
     $comment->authorip_bacc = $_SERVER["REMOTE_ADDR"];
     $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.comment.title'));
     $errors = _dao('blog|blogarticlecomment')->check($comment);
     if ($errors != 1) {
         // Traitement des erreurs
         $showErrors = true;
     } else {
         // Insertion dans la base
         $commentDAO->insert($comment);
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|listComment', array("id_blog" => $id_blog, "id_bact" => $id_bact)));
     }
     // Recherche de tous les blogs de la base
     $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment');
     $res = $commentDAO->findCommentOrderBy($id_bact, NULL);
     $resultats = array();
     foreach ($res as $r) {
         $r->time_bacc = BDToTime($r->time_bacc);
         array_push($resultats, $r);
     }
     $tpl->assign('MAIN', CopixZone::process('ListComment', array('resultats' => $resultats, 'id_bact' => $id_bact, 'id_blog' => $this->getRequest('id_blog', ''), 'errors' => $errors, 'showErrors' => $showErrors, 'toEdit' => $comment)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processDoCreateAccounts()
 {
     $comptes_service =& CopixClassesFactory::Create('comptes|ComptesService');
     if (!Admin::canAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $limit = $this->getRequest('limit', 5);
     $password = $this->getRequest('password', '123456');
     $ppo = new CopixPPO();
     // dbuser : id_dbuser 	login_dbuser 	password_dbuser 	email_dbuser 	enabled_dbuser
     // kernel_link_bu2user : user_id 	bu_type 	bu_id
     $sql_params = array();
     $sql = '
         SELECT
             E.idEleve, E.nom, E.prenom1 AS prenom,
             KLB2U.*
         FROM
             kernel_bu_eleve E
         LEFT JOIN
             kernel_link_bu2user KLB2U ON E.idEleve=KLB2U.bu_id AND KLB2U.bu_type="USER_ELE"
         WHERE bu_type IS NULL';
     $ppo->user_ele = CopixDB::getConnection()->doQuery($sql, $sql_params);
     $sql = '
         SELECT
             P.numero, P.nom, P.prenom1 AS prenom, P.civilite, P.id_sexe,
             PE.role,
             KLB2U.*
         FROM
             kernel_bu_personnel_entite PE, kernel_bu_personnel P
         LEFT JOIN
             kernel_link_bu2user KLB2U ON P.numero=KLB2U.bu_id AND KLB2U.bu_type="USER_ENS"
         WHERE PE.type_ref="ECOLE" AND (PE.role=1 OR PE.role=2) AND PE.id_per=P.numero
         AND bu_type IS NULL';
     $ppo->user_ens = CopixDB::getConnection()->doQuery($sql, $sql_params);
     $sql = '
         SELECT
             P.numero, P.nom, P.prenom1 AS prenom, P.civilite, P.id_sexe,
             PE.role,
             KLB2U.*
         FROM
             kernel_bu_personnel_entite PE, kernel_bu_personnel P
         LEFT JOIN
             kernel_link_bu2user KLB2U ON P.numero=KLB2U.bu_id AND KLB2U.bu_type="USER_VIL"
         WHERE PE.type_ref="VILLE" AND PE.role=4 AND PE.id_per=P.numero
         AND bu_type IS NULL';
     $ppo->user_vil = CopixDB::getConnection()->doQuery($sql, $sql_params);
     $sql = '
         SELECT
             R.numero, R.nom, R.prenom1 AS prenom, R.civilite, R.id_sexe,
             KLB2U.*
         FROM
             kernel_bu_responsable R
         LEFT JOIN
             kernel_link_bu2user KLB2U ON R.numero=KLB2U.bu_id AND KLB2U.bu_type="USER_RES"
         WHERE bu_type IS NULL';
     $ppo->user_res = CopixDB::getConnection()->doQuery($sql, $sql_params);
     $fusible = $limit;
     echo "<pre>";
     foreach ($ppo->user_ele as $eleve) {
         if ($fusible-- <= 0) {
             break;
         }
         $user_infos = Kernel::getUserInfo('USER_ELE', $eleve->idEleve);
         $login = $comptes_service->createLogin($user_infos);
         $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
         $user_new->login_dbuser = $login;
         $user_new->password_dbuser = md5($password);
         $user_new->email_dbuser = '';
         $user_new->enabled_dbuser = 1;
         _dao("kernel|kernel_copixuser")->insert($user_new);
         $bu_new = _record("kernel|kernel_bu2user2");
         $bu_new->user_id = $user_new->id_dbuser;
         $bu_new->bu_type = 'USER_ELE';
         $bu_new->bu_id = $eleve->idEleve;
         _dao("kernel|kernel_bu2user2")->insert($bu_new);
         echo $eleve->nom . ";" . $eleve->prenom . ";" . $login . ";" . $password . "\n";
     }
     foreach ($ppo->user_ens as $ens) {
         if ($fusible-- <= 0) {
             break;
         }
         $user_infos = Kernel::getUserInfo('USER_ENS', $ens->numero);
         $login = $comptes_service->createLogin($user_infos);
         $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
         $user_new->login_dbuser = $login;
         $user_new->password_dbuser = md5($password);
         $user_new->email_dbuser = '';
         $user_new->enabled_dbuser = 1;
         _dao("kernel|kernel_copixuser")->insert($user_new);
         $bu_new = _record("kernel|kernel_bu2user2");
         $bu_new->user_id = $user_new->id_dbuser;
         $bu_new->bu_type = 'USER_ENS';
         $bu_new->bu_id = $ens->numero;
         _dao("kernel|kernel_bu2user2")->insert($bu_new);
         echo $ens->nom . ";" . $ens->prenom . ";" . $login . ";" . $password . "\n";
     }
     foreach ($ppo->user_vil as $vil) {
         if ($fusible-- <= 0) {
             break;
         }
         $user_infos = Kernel::getUserInfo('USER_VIL', $vil->numero);
         $login = $comptes_service->createLogin($user_infos);
         $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
         $user_new->login_dbuser = $login;
         $user_new->password_dbuser = md5($password);
         $user_new->email_dbuser = '';
         $user_new->enabled_dbuser = 1;
         _dao("kernel|kernel_copixuser")->insert($user_new);
         $bu_new = _record("kernel|kernel_bu2user2");
         $bu_new->user_id = $user_new->id_dbuser;
         $bu_new->bu_type = 'USER_VIL';
         $bu_new->bu_id = $vil->numero;
         _dao("kernel|kernel_bu2user2")->insert($bu_new);
         echo $vil->nom . ";" . $vil->prenom . ";" . $login . ";" . $password . "\n";
     }
     foreach ($ppo->user_res as $res) {
         if ($fusible-- <= 0) {
             break;
         }
         $user_infos = Kernel::getUserInfo('USER_RES', $res->numero);
         $login = $comptes_service->createLogin($user_infos);
         $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
         $user_new->login_dbuser = $login;
         $user_new->password_dbuser = md5($password);
         $user_new->email_dbuser = '';
         $user_new->enabled_dbuser = 1;
         _dao("kernel|kernel_copixuser")->insert($user_new);
         $bu_new = _record("kernel|kernel_bu2user2");
         $bu_new->user_id = $user_new->id_dbuser;
         $bu_new->bu_type = 'USER_RES';
         $bu_new->bu_id = $res->numero;
         _dao("kernel|kernel_bu2user2")->insert($bu_new);
         echo $res->nom . ";" . $res->prenom . ";" . $login . ";" . $password . "\n";
     }
     echo "</pre>";
     die;
     /*
              *
              *
              *
              * 				$user_infos = Kernel::getUserInfo( $user_type, $user_id );
     
                     // V�rification de l'existance d'un login.
                     // -> Si c'est le cas, il ne faut pas proposer un nouveau login.
                     $bu_user = $bu_dao->getByBUID( $user_type, $user_id );
     
                     if( !count($bu_user) ) {
     
                         $user_infos['login']  = $comptes_service->createLogin( $user_infos );
                     $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
                             $user_new->login_dbuser = $pLogin[$typeid];
                             $user_new->password_dbuser = md5($pPasswd[$typeid]);
                             $user_new->email_dbuser = '';
                             $user_new->enabled_dbuser = 1;
                                                     if( $user_dao->insert( $user_new ) ) {
     
                                 // Cr�ation du lien entre l'utilisateur de la base unique et le login.
                                 $bu_new = _record("kernel|kernel_bu2user2");
                                 $bu_new->user_id = $user_new->id_dbuser;
                                 $bu_new->bu_type = $user_type;
                                 $bu_new->bu_id = $user_id;
     
                                 // Enregistrement et v�rification de l'insertion.
                                 if( _dao("kernel|kernel_bu2user2")->insert( $bu_new ) ) {
     */
 }
 /**
  * Fonction qui est appelée lorsque l'on valide la saisie d'un évènement
  * Met à jour l'objet avec les données du formulaire
  * Vérifie les informations saisies dans le formulaire
  * @author Audrey Vassal <*****@*****.**>
  * @return redirige vers l'action "getVueSemaine" de l'actiongroup agenda
  */
 public function doValid()
 {
     $serviceAuth = new AgendaAuth();
     $serviceAgenda = new AgendaService();
     $serviceType = new AgendaType();
     if (!($toValid = $this->_getSessionLecon())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.cannotFindSession'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     if ($serviceAuth->getCapability($toValid->id_agenda) < $serviceAuth->getWriteLecon() || $serviceAgenda->getTypeAgendaByIdAgenda($toValid->id_agenda) != $serviceType->getClassRoom()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //demande de mettre l'objet à jour en fonction des valeurs saisies dans le formulaire
     $this->_validFromForm($toValid);
     $errors = $this->_check();
     if (count($errors) > 0) {
         $this->_setSessionLecon($toValid);
         return CopixActionGroup::process('agenda|Lecon::getEdit', array('e' => 1, 'errors' => $errors));
     } else {
         $daoLecon =& CopixDAOFactory::getInstanceOf('lecon');
         $record =& CopixDAOFactory::createRecord('lecon');
         $criteres = _daoSp();
         $criteres->addCondition('id_lecon', '=', $toValid->id_lecon);
         $resultat = $daoLecon->findBy($criteres);
         $modif = false;
         if (count($resultat) > 0) {
             //modification
             $record = $resultat[0];
             $modif = true;
         }
         $record->id_agenda = $toValid->id_agenda;
         $record->desc_lecon = $toValid->desc_lecon;
         $record->date_lecon = $toValid->date_lecon;
         if ($modif) {
             $daoLecon->update($record);
         } else {
             $daoLecon->insert($record);
         }
         //on vide la session
         $this->_setSessionLecon(null);
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('agenda|agenda|vueSemaine'));
     }
 }
 /**
  * Validation d'une page.
  */
 public function doValidPage()
 {
     $id_blog = $this->getRequest('id_blog', null);
     $go = $this->getRequest('go', 'preview');
     //die ("go=$go");
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_PAGES', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManagePage'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $showErrors = false;
     $pageDAO = CopixDAOFactory::create('blog|blogpage');
     $id_bpge = $this->getRequest('id_bpge', null);
     if (strlen($id_bpge) == 0) {
         $id_bpge = null;
     }
     // On r�cup�re l'utilisateur connect�
     $user = BlogAuth::getUserInfos();
     if ($id_bpge != null) {
         // EDITION D'UNE PAGE
         $page = $pageDAO->get($id_bpge);
         $this->_validFromPostProperties($page);
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.page.title'));
         $errors = _dao('blog|blogpage')->check($page);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } elseif ($go == 'save') {
             // Modification dans la base
             $page->content_html_bpge = smarty_modifier_blog_format_article($page->content_bpge, $page->format_bpge);
             $pageDAO->update($page);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UNE PAGE
         $page = CopixDAOFactory::createRecord('blogpage');
         $this->_validFromPostProperties($page);
         $page->order_bpge = $pageDAO->getNewPos($id_blog);
         $page->date_bpge = date('Ymd');
         $page->author_bpge = $user->userId;
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.page.title'));
         $errors = _dao('blog|blogpage')->check($page);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } elseif ($go == 'save') {
             // Insertion dans la base
             $page->content_html_bpge = smarty_modifier_blog_format_article($page->content_bpge, $page->format_bpge);
             $pageDAO->insert($page);
             $page->url_bpge = killBadUrlChars($page->id_bpge . '-' . $page->name_bpge);
             $pageDAO->update($page);
             //on vide la session
             //$this->_setSessionPage(null);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditPage', array('id_blog' => $id_blog, 'id_bpge' => $id_bpge, 'page' => $page, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'), 'preview' => $go == 'preview' ? 1 : 0)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Cette méthode à pour role de sauver en base la description
  * d'une personne. Elle est utilisée pour la création d'une nouvelle 
  * personne.
  * TODO : Renommer + vérifier les types 
  **/
 function sauver()
 {
     $error = false;
     $tpl =& new CopixTpl();
     $nom = $this->vars['nom'];
     $prenom = $this->vars['prenom'];
     $dateNaissance = $this->vars['date_naiss'];
     $DAOPersonne =& CopixDAOFactory::create('personne');
     $nouvellePers = CopixDAOFactory::createRecord('personne');
     $nouvellePers->nom = $nom;
     $nouvellePers->prenom = $prenom;
     $nouvellePers->date_naiss = $dateNaissance;
     $DAOPersonne->insert($nouvellePers);
     $numberOfMails = $this->vars['numberOfMail'];
     $emails = array();
     $emailCategory = array();
     for ($i = 1; $i <= $numberOfMails; $i++) {
         array_push($emails, $this->vars['email|' . $i]);
         array_push($emailCategory, $this->vars['emailCat|' . $i]);
     }
     $DAOEMail =& CopixDAOFactory::create('email');
     if ($emails != null) {
         for ($i = 0; $i < $numberOfMails; $i++) {
             $emailValeur = $emails[$i];
             $emailCatId = $emails[$i];
             $nouvelEmail = CopixDAOFactory::createRecord('email');
             $nouvelEmail->id_pers = $nouvellePers->id;
             $nouvelEmail->valeur = $emailValeur;
             $nouvelEmail->id_cat = $emailCatId;
             $nouvelEmail->defaut = 0;
             $DAOEMail->insert($nouvelEmail);
         }
     }
     $numberOfAdresseLigne = $this->vars['numberOfAdresseLigne'];
     $adresseLigne = array();
     for ($i = 1; $i <= $numberOfAdresseLigne; $i++) {
         array_push($adresseLigne, $this->vars['adresse|' . $i]);
     }
     $cp = $this->vars['cp'];
     $ville = $this->vars['ville'];
     $pays = $this->vars['pays'];
     $DAOAdresse =& CopixDAOFactory::create('adresse');
     $nouvelleAdresse = CopixDAOFactory::createRecord('adresse');
     $nouvelleAdresse->id_pers = $nouvellePers->id;
     $nouvelleAdresse->cp = $cp;
     $nouvelleAdresse->ville = $ville;
     $nouvelleAdresse->pays = $pays;
     $DAOAdresse->insert($nouvelleAdresse);
     $DAOAdresseLigne =& CopixDAOFactory::create('adresseligne');
     if ($adresseLigne != null) {
         for ($i = 0; $i < $numberOfAdresseLigne; $i++) {
             $valeurLigne = $adresseLigne[$i];
             $nouvelleLigne = CopixDAOFactory::createRecord('adresseLigne');
             $nouvelleLigne->id_adresse = $nouvelleAdresse->id;
             $nouvelleLigne->valeur = $valeurLigne;
             $DAOAdresseLigne->insert($nouvelleLigne);
         }
     }
     $url = new CopixUrl();
     $url->set('action', 'toutespers');
     return new CopixActionReturn(COPIX_AR_REDIRECT, $url->getUrl());
 }
/**
 * Alias à CopixDAOFactory::createRecord ()
 * @param	string	$pRecordName	le nom du record que l'on souhaite créer
 * @param	string	$pConnection	la base a utilisé
 * @see CopixDAOFactory::createRecord
 * @return CopixDAORecord
 */
function _record($pRecordName, $pConnection = null)
{
    return CopixDAOFactory::createRecord($pRecordName, $pConnection);
}
 /**
  *
  */
 public function doValidBlog()
 {
     $id_blog = $this->getRequest('id_blog', null);
     $blogDAO = CopixDAOFactory::create('blog|blog');
     $blog = $blogDAO->get($id_blog);
     if (!BlogAuth::canMakeInBlog('ADMIN_OPTIONS', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageBlog'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||')));
     }
     $tpl = new CopixTpl();
     // Récupération de toutes les fonctions du blog
     $tabFunctions = returnAllBlogFunctions();
     $tabSelectedFunctions = (array) $this->getRequest('tabBlogFunctions', '');
     $tabBlogFunctions = array();
     foreach ($tabFunctions as $fct) {
         if (in_array($fct->value, $tabSelectedFunctions)) {
             $fct->selected = 1;
         }
         array_push($tabBlogFunctions, $fct);
     }
     if ($id_blog != null) {
         // EDITION D'UN BLOG
         $blog->name_blog = $this->getRequest('name_blog', '');
         $blog->is_public = $this->getRequest('is_public', 1);
         $blog->privacy = $this->getRequest('privacy');
         $blog->has_comments_activated = $this->getRequest('has_comments_activated', 1);
         $blog->type_moderation_comments = $this->getRequest('type_moderation_comments', 'POST');
         $blog->default_format_articles = $this->getRequest('default_format_articles', 'wiki');
         //$blog->id_ctpt	 = $this->getRequest('id_ctpt', '');
         //$blog->url_blog	 = $this->getRequest('url_blog', '');
         // Gestion du LOGO
         if (is_uploaded_file($_FILES['logoFile']['tmp_name'])) {
             $file = COPIX_VAR_PATH . CopixConfig::get('blog|logoPath') . $blog->logo_blog;
             if (file_exists($file)) {
                 @unlink($file);
             }
             $blog->logo_blog = $blog->id_blog . '_' . $_FILES['logoFile']['name'];
             $file = COPIX_VAR_PATH . CopixConfig::get('blog|logoPath') . $blog->logo_blog;
             move_uploaded_file($_FILES['logoFile']['tmp_name'], $file);
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.blog.title'));
         $errors = _dao('blog|blog')->check($blog);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Modification dans la base
             $blogDAO->update($blog);
             /*
             $blogFunctionsDAO = CopixDAOFactory::create('blog|blogfunctions');
             $blogFunctionsDAO->updateBlogFunctions($id_blog, $tabBlogFunctions);
             */
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array('id_blog' => $id_blog, 'kind' => $this->getRequest('kind', 0))));
         }
     } else {
         // CREATION D'UN BLOG
         $blog = CopixDAOFactory::createRecord('blog');
         $blog->name_blog = $this->getRequest('name_blog', '');
         $blog->id_ctpt = $this->getRequest('id_ctpt', '');
         $blog->url_blog = $this->getRequest('url_blog', '');
         // Gestion du LOGO
         if (is_uploaded_file($_FILES['logoFile']['tmp_name'])) {
             $file = COPIX_VAR_PATH . CopixConfig::get('blog|logoPath') . $blog->logo_blog;
             if (file_exists($file)) {
                 @unlink($file);
             }
             $blog->logo_blog = $blog->id_blog . '_' . $_FILES['logoFile']['name'];
             $file = COPIX_VAR_PATH . CopixConfig::get('blog|logoPath') . $blog->logo_blog;
             move_uploaded_file($_FILES['logoFile']['tmp_name'], $file);
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.blog.title'));
         $errors = _dao('blog|blog')->check($blog);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Insertion dans la base
             $blogDAO->insert($blog);
             $blogFunctionsDAO = CopixDAOFactory::create('blog|blogfunctions');
             $blogFunctionsDAO->createBlogFunctions($blog->id_blog, $tabBlogFunctions);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditBlog', array('id_blog' => $id_blog, 'blog' => $blog, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', 0), 'tabBlogFunctions' => $tabBlogFunctions)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function doRessourceSave()
 {
     // Modification
     $res_id = _request("res_id", 0);
     if (trim(_request("nom")) == "") {
         return false;
     }
     if (!$res_id) {
         return false;
     }
     $ressource_dao = CopixDAOFactory::create("ressource_ressources");
     if ($res_id > 0) {
         $ressource = $ressource_dao->get($res_id);
     } else {
         $ressource = CopixDAOFactory::createRecord("ressource_ressources");
         $ressource->ressources_id_annu = _request("annu_id");
         $ressource->ressources_submit_user = _request("submit_user");
         $ressource->ressources_submit_date = date("Y-m-d H:i:s");
         $ressource->ressources_valid_user = "";
         $ressource->ressources_valid_date = date("Y-m-d H:i:s");
     }
     $ressource->ressources_nom = _request("nom");
     $ressource->ressources_url = _request("url");
     $ressource->ressources_description = _request("description");
     $ressource->ressources_mots = _request("mots");
     $ressource->ressources_auteur = _request("auteur");
     $ressource->ressources_submit_user = _request("submit_user");
     if ($res_id > 0) {
         $ressource_dao->update($ressource);
     } else {
         $ressource_dao->insert($ressource);
         $res_id = $ressource->ressources_id;
     }
     $fonction_dao = CopixDAOFactory::create("ressource_res2fonction");
     $fonction_enr = $fonction_dao->delByRessource(_request("res_id"));
     $fonction_new = CopixDAOFactory::createRecord("ressource_res2fonction");
     foreach (_request("fonction") as $fonction_item) {
         $fonction_new->res2fonction_id_ressource = _request("res_id");
         $fonction_new->res2fonction_id_fonction = $fonction_item;
         $fonction_dao->insert($fonction_new);
     }
     $contenu_dao = CopixDAOFactory::create("ressource_res2contenu");
     $contenu_enr = $contenu_dao->delByRessource(_request("res_id"));
     $contenu_new = CopixDAOFactory::createRecord("ressource_res2contenu");
     foreach (_request("contenu") as $contenu_item) {
         $contenu_new->res2contenu_id_ressource = _request("res_id");
         $contenu_new->res2contenu_id_contenu = $contenu_item;
         $contenu_dao->insert($contenu_new);
     }
     $domaine_dao = CopixDAOFactory::create("ressource_res2domaine");
     $domaine_enr = $domaine_dao->delByRessource(_request("res_id"));
     $domaine_new = CopixDAOFactory::createRecord("ressource_res2domaine");
     foreach (_request("domaine") as $domaine_item) {
         $domaine_new->res2domaine_id_ressource = _request("res_id");
         $domaine_new->res2domaine_id_domaine = $domaine_item;
         $domaine_dao->insert($domaine_new);
     }
     Ressource::savetags(_request("res_id"));
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('ressource||getRessource', array('id' => _request("res_id"))));
 }
 public function savetags($res_id)
 {
     $ressource_dao = CopixDAOFactory::create("ressource_ressources");
     $ressource = $ressource_dao->get($res_id);
     $tags_dao = CopixDAOFactory::create("ressource_tags");
     $tags_dao->delRessource($res_id);
     $tags = Ressource::motcles2tags($ressource->ressources_mots);
     $restag = CopixDAOFactory::createRecord("ressource_ressources");
     foreach ($tags as $tag_key => $tag_val) {
         $restag->annu = $ressource->ressources_id_annu;
         $restag->res = $res_id;
         $restag->tag = $tag_key;
         @$tags_dao->insert($restag);
     }
 }
 public function init()
 {
     $path2data = realpath(COPIX_VAR_PATH) . "/data/concerto/logins-concerto--" . date('Y-m-d') . ".csv";
     if (CopixConfig::exists('|conf_ModConcerto_ip')) {
         $ips = CopixConfig::get('|conf_ModConcerto_ip');
         $ips_array = explode(";", $ips);
         if (!in_array($_SERVER["REMOTE_ADDR"], $ips_array)) {
             die('Forbidden : bad IP address');
         }
     } else {
         die('Forbidden : check config');
     }
     $comptes_service =& CopixClassesFactory::Create('comptes|ComptesService');
     $user_dao =& CopixDAOFactory::create("kernel|kernel_copixuser");
     $bu_dao =& CopixDAOFactory::create("kernel|kernel_bu2user");
     // $sql = 'SELECT KB_RES.numero, KB_RES.nom, KB_RES.prenom1, K_LB2U.user_id, K_LB2U.bu_type, K_LB2U.bu_id FROM kernel_bu_responsable KB_RES LEFT JOIN kernel_link_bu2user K_LB2U ON KB_RES.numero=K_LB2U.bu_id AND K_LB2U.bu_type="USER_RES" WHERE K_LB2U.bu_type IS NULL';
     $sql = 'SELECT KB_RES.numero, KB_RES.nom, KB_RES.prenom1, K_LB2U.user_id, K_LB2U.bu_type, K_LB2U.bu_id, KB_SER.id_ext FROM kernel_bu_services KB_SER, kernel_bu_responsable KB_RES LEFT JOIN kernel_link_bu2user K_LB2U ON KB_RES.numero=K_LB2U.bu_id AND K_LB2U.bu_type="USER_RES" WHERE KB_SER.id_local=KB_RES.numero AND KB_SER.service="concerto" AND KB_SER.objet="responsable" AND K_LB2U.bu_type IS NULL';
     $a = _doQuery($sql);
     if (count($a) > 0) {
         $user_infos = array();
         $file = fopen($path2data, "a");
         fseek($file, 0, SEEK_END);
         // echo $path2data."<br/>";
         // echo "Position=".ftell($file)."<br/>";
         if (ftell($file) == 0) {
             $entete = array('id', 'login', 'password');
             fputcsv($file, $entete, ";");
             // echo "Position=".ftell($file)." (après ajout entête)<br/>";
         }
         $cpt = 0;
         // $limit=1;
         foreach ($a as $a_key => $a_item) {
             $user_infos['type'] = "USER_RES";
             $user_infos['id'] = $a_item->numero;
             $user_infos['nom'] = $a_item->nom;
             $user_infos['prenom'] = $a_item->prenom1;
             // $a[$a_key]->user_infos = Kernel::getUserInfo( "USER_RES", $a_item->numero );
             $a[$a_key]->login = $comptes_service->createLogin($user_infos);
             // $a[$a_key]->user_infos = Kernel::getUserInfo( "USER_RES", $a_item->numero );
             // $a[$a_key]->login = $comptes_service->createLogin( $a[$a_key]->user_infos );
             $a[$a_key]->passwd = $comptes_service->createPasswd();
             // Création d'un login dans CopixUser
             $user_new = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
             $user_new->login_dbuser = $a[$a_key]->login;
             $user_new->password_dbuser = md5($a[$a_key]->passwd);
             $user_new->email_dbuser = '';
             $user_new->enabled_dbuser = 1;
             $user_dao->insert($user_new);
             // Création du lien entre l'utilisateur de la base unique et le login.
             $bu_new = CopixDAOFactory::createRecord("kernel|kernel_bu2user");
             $bu_new->user_id = $user_new->id_dbuser;
             $bu_new->bu_type = $user_infos['type'];
             $bu_new->bu_id = $user_infos['id'];
             $bu_dao->insert($bu_new);
             $ligne = array($a[$a_key]->id_ext, $a[$a_key]->login, $a[$a_key]->passwd);
             fputcsv($file, $ligne, ";");
             $cpt++;
             // if( $cpt>=$limit) break;
         }
         // echo "Position=".ftell($file)." (après enregistrement)<br/>";
         fclose($file);
     }
     /*
     $tplListe = new CopixTpl ();
     $tplListe->assign ('data', $a);
     $result = $tplListe->fetch("concerto-init.tpl");
     */
     if ($handle = fopen($path2data, "r")) {
         $contents = fread($handle, filesize($path2data));
         fclose($handle);
     } else {
         $contents = 'vide ' . $path2data;
     }
     echo "<pre>" . $contents . "</pre>";
     die;
 }
 function &fetchRecord($recordName)
 {
     if ($fetched =& $this->fetch()) {
         $record =& CopixDAOFactory::createRecord($recordName);
         $record->initFromDBObject($fetched);
         return $record;
     }
     $ret = false;
     return $ret;
 }
 /**
  * Formulaire de modification des infos d'une ecole
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/09/03
  * @param integer $id Id de l'ecole
  */
 public function form()
 {
     $id = $this->getRequest('id', null);
     $save = $this->getRequest('save', null);
     $nbZones = 4;
     $horaires = $this->getRequest('horaires', null);
     for ($i = 1; $i <= $nbZones; $i++) {
         $field = 'zone' . $i . '_titre';
         ${$field} = $this->getRequest($field, null);
         $field = 'zone' . $i . '_texte';
         ${$field} = $this->getRequest($field, null);
     }
     $photoMaxWidth = CopixConfig::get('fichesecoles|photoMaxWidth');
     $criticErrors = $errors = array();
     $ecoleDAO = CopixDAOFactory::create('kernel|kernel_bu_ecole');
     $ficheDAO = CopixDAOFactory::create("fiches_ecoles");
     if (!($rEcole = $ecoleDAO->get($id))) {
         $criticErrors[] = CopixI18N::get('fichesecoles.error.param');
     } elseif (!FichesEcolesService::canMakeInFicheEcole($id, 'MODIFY')) {
         $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('annuaire||')));
     }
     //$tplForm->assign ('',$errors);
     //var_dump($rEcole);
     $canModifyVille = FichesEcolesService::canMakeInFicheEcole($id, 'MODIFY_VILLE');
     $rFiche = $ficheDAO->get($id);
     $rForm = CopixDAOFactory::createRecord('fiches_ecoles');
     if ($save == 1) {
         $rForm->id = $id;
         $rForm->photo = $rFiche ? $rFiche->photo : '';
         $rForm->doc1_fichier = $rFiche ? $rFiche->doc1_fichier : '';
         if (is_uploaded_file($_FILES['photoFile']['tmp_name'])) {
             if ($size = @getimagesize($_FILES['photoFile']['tmp_name'])) {
                 $formats = array(IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_GIF);
                 if (!in_array($size[2], $formats)) {
                     $errors[] = CopixI18N::get('fichesecoles.error.photo.badformat');
                 } else {
                     if ($rFiche) {
                         $file = COPIX_VAR_PATH . CopixConfig::get('fichesecoles|photoPath') . $rFiche->photo;
                         if (file_exists($file)) {
                             @unlink($file);
                         }
                     }
                     $fileName = $rForm->id . "_" . $_FILES['photoFile']['name'];
                     $file = COPIX_VAR_PATH . CopixConfig::get('fichesecoles|photoPath') . $fileName;
                     if (@move_uploaded_file($_FILES['photoFile']['tmp_name'], $file)) {
                         $this->_resizeImage($file, $photoMaxWidth);
                         $rForm->photo = $fileName;
                     }
                 }
             } else {
                 $errors[] = CopixI18N::get('fichesecoles.error.photo.badformat');
             }
         } else {
             switch ($_FILES['photoFile']['error']) {
                 case 0:
                     //no error; possible file attack!
                     $errors[] = CopixI18N::get('malle|malle.error.upload_default', $_FILES['photoFile']['type']);
                     break;
                 case 1:
                     //uploaded file exceeds the upload_max_filesize directive in php.ini
                     $errors[] = CopixI18N::get('malle|malle.error.upload_toobig', $_FILES['photoFile']['type']);
                     break;
                 case 2:
                     //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
                     $errors[] = CopixI18N::get('malle|malle.error.upload_toobig', $_FILES['photoFile']['type']);
                     break;
                 case 3:
                     //uploaded file was only partially uploaded
                     $errors[] = CopixI18N::get('malle|malle.error.upload_partial', $_FILES['photoFile']['type']);
                     break;
                 case 4:
                     // Pas d'upload
                     break;
                 default:
                     $errors[] = CopixI18N::get('malle|malle.error.upload_default', $_FILES['photoFile']['type']);
                     break;
             }
         }
         $rForm->doc1_titre = _request('doc1_titre');
         if (_request('doc1_suppr')) {
             if ($rForm->doc1_fichier) {
                 $file = COPIX_VAR_PATH . CopixConfig::get('fichesecoles|docPath') . $rForm->doc1_fichier;
                 if (file_exists($file)) {
                     @unlink($file);
                 }
             }
             $rForm->doc1_fichier = null;
             $rForm->doc1_titre = null;
         } elseif (is_uploaded_file($_FILES['doc1_fichier']['tmp_name'])) {
             if ($rFiche) {
                 $file = COPIX_VAR_PATH . CopixConfig::get('fichesecoles|docPath') . $rFiche->doc1_fichier;
                 if (file_exists($file)) {
                     @unlink($file);
                 }
             }
             $fileName = $rForm->id . "_" . $_FILES['doc1_fichier']['name'];
             $file = COPIX_VAR_PATH . CopixConfig::get('fichesecoles|docPath') . $fileName;
             if (@move_uploaded_file($_FILES['doc1_fichier']['tmp_name'], $file)) {
                 $rForm->doc1_fichier = $fileName;
             }
         } else {
             switch ($_FILES['doc1_fichier']['error']) {
                 case 0:
                     //no error; possible file attack!
                     $errors[] = CopixI18N::get('malle|malle.error.upload_default', $_FILES['doc1_fichier']['type']);
                     break;
                 case 1:
                     //uploaded file exceeds the upload_max_filesize directive in php.ini
                     $errors[] = CopixI18N::get('malle|malle.error.upload_toobig', $_FILES['doc1_fichier']['type']);
                     break;
                 case 2:
                     //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
                     $errors[] = CopixI18N::get('malle|malle.error.upload_toobig', $_FILES['doc1_fichier']['type']);
                     break;
                 case 3:
                     //uploaded file was only partially uploaded
                     $errors[] = CopixI18N::get('malle|malle.error.upload_partial', $_FILES['doc1_fichier']['type']);
                     break;
                 case 4:
                     // Pas d'upload
                     break;
                 default:
                     $errors[] = CopixI18N::get('malle|malle.error.upload_default', $_FILES['doc1_fichier']['type']);
                     break;
             }
         }
         $rForm->horaires = $horaires;
         for ($i = 1; $i <= $nbZones; $i++) {
             $fieldTitre = 'zone' . $i . '_titre';
             $rForm->{$fieldTitre} = ${$fieldTitre};
             $fieldTexte = 'zone' . $i . '_texte';
             $rForm->{$fieldTexte} = ${$fieldTexte};
             if ($rForm->{$fieldTexte} && !$rForm->{$fieldTitre}) {
                 $errors[] = CopixI18N::get('fichesecoles.error.zone', $i);
             }
         }
         if ($canModifyVille) {
             $rForm->zone_ville_titre = $this->getRequest('zone_ville_titre', null);
             $rForm->zone_ville_texte = $this->getRequest('zone_ville_texte', null);
             if ($rForm->zone_ville_texte && !$rForm->zone_ville_titre) {
                 $errors[] = CopixI18N::get('fichesecoles.error.zoneVille');
             }
         } else {
             if (!$rFiche) {
                 // Pas encore de fiche
                 $ville = FichesEcolesService::getZoneVille($rEcole);
                 $rForm->zone_ville_titre = $ville['zone_ville_titre'];
                 $rForm->zone_ville_texte = $ville['zone_ville_texte'];
             } else {
                 $rForm->zone_ville_titre = $rFiche->zone_ville_titre;
                 $rForm->zone_ville_texte = $rFiche->zone_ville_texte;
             }
         }
         if (!count($errors)) {
             if ($rFiche) {
                 $ficheDAO->update($rForm);
             } else {
                 $ficheDAO->insert($rForm);
             }
             if ($canModifyVille) {
                 FichesEcolesService::propageZoneVille($rEcole, $rForm);
             }
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('default|fiche', array('id' => $id)));
         }
     } else {
         // Arrivee dans le formulaire
         if (!$rFiche) {
             $rFiche = _record('fiches_ecoles');
         }
         $rForm = $rFiche;
         //var_dump($rEcole);
         if ($canModifyVille && !$rForm->zone_ville_titre && !$rForm->zone_ville_texte) {
             $ville = FichesEcolesService::getZoneVille($rEcole);
             $rForm->zone_ville_titre = $ville['zone_ville_titre'];
             $rForm->zone_ville_texte = $ville['zone_ville_texte'];
         }
     }
     $tplForm = new CopixTpl();
     $tplForm->assign('rEcole', $rEcole);
     $tplForm->assign('rForm', $rForm);
     $formats = CopixConfig::get('blog|blog.formats_articles');
     $tplForm->assign('form_horaires', CopixZone::process('kernel|edition', array('field' => 'horaires', 'format' => 'ckeditor', 'content' => $rForm->horaires, 'class' => 'zone_horaires', 'object' => array('type' => 'BU_ECOLE', 'id' => $id))));
     $tplForm->assign('form_zone1_texte', CopixZone::process('kernel|edition', array('field' => 'zone1_texte', 'format' => 'ckeditor', 'content' => $rForm->zone1_texte, 'class' => 'zone_texte', 'object' => array('type' => 'BU_ECOLE', 'id' => $id))));
     $tplForm->assign('form_zone2_texte', CopixZone::process('kernel|edition', array('field' => 'zone2_texte', 'format' => 'ckeditor', 'content' => $rForm->zone2_texte, 'class' => 'zone_texte', 'object' => array('type' => 'BU_ECOLE', 'id' => $id))));
     $tplForm->assign('form_zone3_texte', CopixZone::process('kernel|edition', array('field' => 'zone3_texte', 'format' => 'ckeditor', 'content' => $rForm->zone3_texte, 'class' => 'zone_texte', 'object' => array('type' => 'BU_ECOLE', 'id' => $id))));
     $tplForm->assign('form_zone4_texte', CopixZone::process('kernel|edition', array('field' => 'zone4_texte', 'format' => 'ckeditor', 'content' => $rForm->zone4_texte, 'class' => 'zone_texte', 'object' => array('type' => 'BU_ECOLE', 'id' => $id))));
     if ($canModifyVille) {
         $tplForm->assign('form_zone_ville_texte', CopixZone::process('kernel|edition', array('field' => 'zone_ville_texte', 'format' => 'ckeditor', 'content' => $rForm->zone_ville_texte, 'height' => 80, 'width' => 780, 'object' => array('type' => 'BU_ECOLE', 'id' => $id))));
     }
     $tplForm->assign('photoMaxWidth', $photoMaxWidth);
     $tplForm->assign('errors', $errors);
     $tplForm->assign('canModifyVille', $canModifyVille);
     $main = $tplForm->fetch('form.tpl');
     $title = $rEcole->nom;
     if ($rEcole->type) {
         $title .= ' (' . $rEcole->type . ')';
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', $title);
     if (strtolower($rEcole->type) == 'crèche') {
         $tpl->assign('TITLE_CONTEXT', CopixI18N::get('kernel|kernel.codes.mod_fichesecoles_creche'));
     }
     //$tpl->assign ('MENU', '<a href="'.CopixUrl::get ('|fiche', array('id'=>$id)).'">'.CopixI18N::get ('kernel|kernel.back').'</a>');
     $tpl->assign("MAIN", $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Traitement du formulaire d'ajout d'un service SSO
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/11/14
  * @param integer $sso Id de la collection SSO
  * @param string $url URL à interroger
  * @param string $type Type
  * @todo vérifier les droits
  */
 public function doServiceNewForm()
 {
     $id = $this->getRequest('id', null);
     $url = $this->getRequest('url', null);
     $type = $this->getRequest('type', null);
     $criticErrors = $errors = array();
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('sso||')));
     }
     if (!$url) {
         $errors[] = CopixI18N::get('sso.error.newsso_url');
     }
     if (!$type) {
         $errors[] = CopixI18N::get('sso.error.newsso_type');
     }
     //  print_r(htmlentities(CopixUrl::get('sso||doActivateService', array('id'=>$newSso->sso_auth_id))));
     if (!$errors) {
         // Ok, on traite
         $dao = CopixDAOFactory::create("sso|sso_auth");
         $newSso = CopixDAOFactory::createRecord("sso_auth");
         $newSso->sso_auth_id_sso = $id;
         $newSso->sso_auth_login_local = _currentUser()->getLogin();
         $newSso->sso_auth_type = $type;
         $newSso->sso_auth_url = $url;
         $newSso->sso_auth_date_crea = date("Y-m-d H:i:s");
         $newSso->sso_auth_login_distant = '';
         $newSso->sso_auth_secret_key = '';
         $newSso->sso_auth_date_valid = '';
         $dao->insert($newSso);
         if ($newSso->sso_auth_id !== NULL) {
             $go = $url . '?mode=register' . "&login_ico=" . _currentUser()->getLogin() . "&url=" . urlencode(CopixUrl::get() . CopixUrl::get('sso||doActivateService', array('id' => $newSso->sso_auth_id)));
             //        die ($go);
             return new CopixActionReturn(COPIX_AR_REDIRECT, $go);
         }
     }
     return CopixActionGroup::process('sso|sso::getServiceNewForm', array('id' => $id, 'errors' => $errors, 'url' => $url, 'type' => $type));
 }
 /**
  * saves the value for id, will compile if different from the actual value.
  */
 function set($id, $value)
 {
     //if the config var exists only....
     if (isset($this->_configVars[$id])) {
         $this->_configVars[$id]['Value'] = $value;
         //Sets the value itself.
         //Update the value in the file.
         $this->_configVars[$id]['Value'] = $value;
         //Saves changes in the database
         if ($this->_checkDBConnection()) {
             $dao =& CopixDAOFactory::create('copix:CopixConfig');
             $toInsert =& CopixDAOFactory::createRecord('copix:CopixConfig');
             $toInsert->id_ccfg = $id;
             $toInsert->group_ccfg = $this->group;
             $toInsert->value_ccfg = $value;
             if ($dao->get($toInsert->id_ccfg) === false) {
                 $dao->insert($toInsert);
                 //did not exists before
             } else {
                 $dao->update($toInsert);
                 //updates the DB values
             }
         }
         //Saves changes in the PHP File
         $this->_writeInPHPCache();
     } else {
         trigger_error('unknow variable ' . $id . ' not set.');
     }
 }
 public function doFolder()
 {
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     if (!_request("album_id") || trim(_request("album_id")) == "" || !preg_match("/^[0-9]+\$/", _request("album_id"))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('album.error.noalbumnumber'), 'back' => CopixUrl::get('||')));
     }
     $album_id = _request("album_id");
     if (Kernel::getLevel("MOD_ALBUM", $album_id) < PROFILE_CCV_PUBLISH) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('||')));
     }
     $album_dao = CopixDAOFactory::create("album");
     $album = $album_dao->get($album_id);
     $dossier_id = CopixRequest::getInt('dossier_id', -1);
     if ($dossier_id == -1) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('album.error.nofoldernumber'), 'back' => CopixUrl::get('album||album', array('album_id' => $album_id))));
     }
     $dossier_dao = CopixDAOFactory::create("dossier");
     if ($dossier_id > 0) {
         $dossier = $dossier_dao->get($dossier_id);
         if ($dossier->dossier_album != $album_id) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('album.error.badfoldernumber'), 'back' => CopixUrl::get('album||album', array('album_id' => $album_id))));
         }
     } else {
         $dossier->dossier_id = 0;
         $dossier->dossier_album = $album_id;
         $dossier->dossier_parent = -1;
         $dossier->dossier_nom = CopixI18N::get('album|album.message.topfolder');
         $dossier->dossier_comment = "";
         $dossier->album_id = $album_id;
     }
     if (!_request("subaction")) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('album.error.badsubaction'), 'back' => CopixUrl::get('album||album', array('album_id' => $album_id, 'dossier_id' => $dossier_id))));
     }
     switch (_request("subaction")) {
         case 'new':
             $dossier_new = CopixDAOFactory::createRecord("dossier");
             $dossier_new->dossier_album = $album_id;
             $dossier_new->dossier_parent = $dossier_id;
             $dossier_new->dossier_nom = _request("folder_new", "Nouveau dossier");
             $dossier_new->dossier_comment = '';
             $dossier_new->dossier_date = date("Y-m-d H:i:s");
             $dossier_new->dossier_cle = substr(md5(microtime()), 0, 10);
             $dossier_new->dossier_public = '0';
             $dossier_dao->insert($dossier_new);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('album|default|album', array('album_id' => $album_id, 'dossier_id' => $dossier_new->dossier_id)));
             break;
         case 'rename':
             $dossier->dossier_nom = _request("folder_rename");
             $dossier_dao->update($dossier);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('album|default|album', array('album_id' => $album_id, 'dossier_id' => $dossier_id)));
             break;
         case 'move':
             $dossier->dossier_parent = _request("folder_move");
             $dossier_dao->update($dossier);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('album|default|album', array('album_id' => $album_id, 'dossier_id' => $dossier_id)));
             break;
         case 'delete':
             // action=dofolder subaction=delete album_id=1& dossier_id=4 dossier_todo=moveparent
             Album::delFolder(_request("album_id"), _request("dossier_id"), _request("dossier_todo"));
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('album|default|album', array('album_id' => $album_id, 'dossier_id' => max(0, $dossier->dossier_parent))));
             break;
         default:
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('album.error.badsubaction'), 'back' => CopixUrl::get('album||album', array('album_id' => $album_id, 'dossier_id' => $dossier_id))));
             break;
     }
 }
 /**
  * add to database
  */
 function _addModuleInDatabase($moduleName)
 {
     //insert in database if we can
     if ($GLOBALS['COPIX']['COORD']->getPlugin('copixdb') !== null) {
         $dao = CopixDAOFactory::create('copix:CopixModule');
         $record = CopixDAOFactory::createRecord('copix:CopixModule');
         $record->name_cpm = $moduleName;
         $dao->insert($record);
     }
 }
 /**
  * Validation d'un article.
  */
 public function doValidArticle()
 {
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.ui.datepicker-fr.js"));
     $id_blog = $this->getRequest('id_blog', null);
     $go = $this->getRequest('go', 'preview');
     //die ("go=$go");
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_ARTICLES', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageCategory'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     // On r�cup�re l'utilisateur connect�
     $user = BlogAuth::getUserInfos();
     $articleDAO = CopixDAOFactory::create('blog|blogarticle');
     // Cat�gories coch�es...
     $tabSelectCat = array();
     if (_request('tabSelectCat')) {
         $tabSelectCat = (array) _request('tabSelectCat');
     }
     $id_bact = $this->getRequest('id_bact', null);
     if (strlen($id_bact) == 0) {
         $id_bact = null;
     }
     $showErrors = false;
     if ($id_bact != null) {
         // EDITION D'UN ARTICLE
         $article = $articleDAO->get($id_bact);
         $this->_validFromPostProperties($article);
         if (!$article->date_bact) {
             $article->date_bact = date('d/m/Y');
         }
         if (!$article->time_bact) {
             $article->time_bact = date('H:i');
         }
         $article->date_bact = CopixDateTime::dateToTimestamp($article->date_bact);
         $article->time_bact = timeToBD($article->time_bact);
         $article->author_bact = $user->userId;
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.article.title'));
         //print_r($article);
         $errors = $articleDAO->check($article);
         if (count($tabSelectCat) == 0) {
             $errors = array();
             array_push($errors, CopixI18N::get('blog.error.nocategoryselect'));
         }
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } elseif ($go == 'save') {
             // Modification dans la base
             $article->url_bact = killBadUrlChars($article->id_bact . '-' . $article->name_bact);
             $article->sumary_html_bact = smarty_modifier_blog_format_article($article->sumary_bact, $article->format_bact);
             $article->content_html_bact = smarty_modifier_blog_format_article($article->content_bact, $article->format_bact);
             $articleDAO->update($article);
             // Insertion dans la base blogarticle_blogarticlecategory
             $artctgDAO = CopixDAOFactory::create('blog|blogarticle_blogarticlecategory');
             $artctgDAO->deleteAndInsert($article->id_bact, $tabSelectCat);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UN ARTICLE
         $article = CopixDAOFactory::createRecord('blogarticle');
         $this->_validFromPostProperties($article);
         if (!$article->date_bact) {
             $article->date_bact = date('d/m/Y');
         }
         if (!$article->time_bact) {
             $article->time_bact = date('H:i');
         }
         $article->date_bact = CopixDateTime::dateToTimestamp($article->date_bact);
         $article->time_bact = timeToBD($article->time_bact);
         $article->author_bact = $user->userId;
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.article.title'));
         $errors = $articleDAO->check($article);
         if (count($tabSelectCat) == 0) {
             $errors = array();
             array_push($errors, CopixI18N::get('blog.error.nocategoryselect'));
         }
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } elseif ($go == 'save') {
             // Insertion dans la base
             $article->sumary_html_bact = smarty_modifier_blog_format_article($article->sumary_bact, $article->format_bact);
             $article->content_html_bact = smarty_modifier_blog_format_article($article->content_bact, $article->format_bact);
             $articleDAO->insert($article);
             $article->url_bact = killBadUrlChars($article->id_bact . '-' . $article->name_bact);
             $articleDAO->update($article);
             // Insertion dans la base blogarticle_blogarticlecategory
             $artctgDAO = CopixDAOFactory::create('blog|blogarticle_blogarticlecategory');
             $artctgDAO->deleteAndInsert($article->id_bact, $tabSelectCat);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     // Pr�paration du filtre CATEGORIES
     $blogArticleCategoryDAO = CopixDAOFactory::create('blog|blogarticlecategory');
     $resArticleCategory = $blogArticleCategoryDAO->findAllOrder($id_blog);
     $tabArticleCategory = array();
     foreach ($resArticleCategory as $cat) {
         if (in_array($cat->id_bacg, $tabSelectCat)) {
             $cat->selected = true;
         } else {
             $cat->selected = false;
         }
         array_push($tabArticleCategory, $cat);
     }
     $article->time_bact = BDToTime($article->time_bact);
     $tpl->assign('BODY_ON_LOAD', "setDatePicker('#date_bact')");
     $tpl->assign('MAIN', CopixZone::process('EditArticle', array('id_blog' => $id_blog, 'id_bact' => $id_bact, 'article' => $article, 'kind' => $this->getRequest('kind', '0'), 'errors' => $errors, 'showErrors' => $showErrors, 'tabArticleCategory' => $tabArticleCategory, 'preview' => $go == 'preview' ? 1 : 0)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Validation d'un commentaire.
  */
 public function doValidComment()
 {
     if (Kernel::isSpam()) {
         return new CopixActionReturn(CopixActionReturn::HTTPCODE, CopixHTTPHeader::get404(), "Page introuvable");
     }
     $url_bact = _request('url_bact');
     //On verifit que le blog existe (on r�cup�re le blog avec son nom)
     $dao = CopixDAOFactory::create('blog|blog');
     if (!($blog = $dao->getBlogByName(_request('blog')))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindBlog'), 'back' => CopixUrl::get('')));
     }
     // On v�rifie que le droit de lecture est pr�sent
     if (!BlogAuth::canMakeInBlog('READ', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('')));
     }
     if (!$blog->has_comments_activated) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.add.comment.closed'), 'back' => CopixUrl::get('', array('blog' => _request('blog')))));
     }
     $id_bact = $this->getRequest('id_bact', null);
     if (!BlogAuth::canComment($blog->id_blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('', array('blog' => _request('blog')))));
     }
     $tpl = new CopixTpl();
     $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment');
     $comment = CopixDAOFactory::createRecord('blog|blogarticlecomment');
     $this->_validFromPostProperties($comment);
     $comment->date_bacc = date('Ymd');
     $comment->time_bacc = date('Hi');
     $comment->is_online = $blog->type_moderation_comments != 'POST' ? 0 : 1;
     $comment->authorip_bacc = $_SERVER["REMOTE_ADDR"];
     CopixHTMLHeader::addCSSLink(CopixUrl::get('blog||getBlogCss', array('id_blog' => $blog->id_blog)));
     $tpl->assign('blog', $blog);
     $errors = $commentDAO->check($comment);
     //print_r($comment);
     $showErrors = false;
     if ($errors != 1) {
         // Traitement des erreurs
         $showErrors = true;
     } else {
         // Insertion dans la base
         $commentDAO->insert($comment);
     }
     $zoneArticle = CopixZone::process('ShowArticle', array('blog' => $blog, 'article' => $this->getRequest('article', ''), 'errors' => $errors, 'showErrors' => $showErrors, 'comment' => $comment));
     list($title, $article) = explode("{/}", $zoneArticle);
     $tpl->assign('TITLE_PAGE', $title . ' - ' . $blog->name_blog);
     $tpl->assign('Article', $article);
     $tpl->assign('ListLink', CopixZone::process('ListLink', array('blog' => $blog)));
     $tpl->assign('ListCategory', CopixZone::process('ListCategory', array('blog' => $blog)));
     $tpl->assign('ListArchive', CopixZone::process('ListArchive', array('blog' => $blog)));
     $tpl->assign('ListPage', CopixZone::process('ListPage', array('blog' => $blog)));
     $tpl->assign('ListSearch', CopixZone::process('ListSearch', array('blog' => $blog)));
     if (!$showErrors) {
         if ($comment->is_online == 1) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||showArticle', array('blog' => urlencode($blog->url_blog), 'article' => _request('article'))) . '#comments');
         } else {
             return CopixActionGroup::process('genericTools|Messages::getInformation', array('message' => CopixI18N::get('blog.comments.offline.info'), 'continue' => CopixUrl::get('blog|default|showArticle', array('blog' => $blog->url_blog, 'article' => $url_bact))));
         }
     }
     //		$menu = array();
     $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
     //print_r($parent);
     $blog->parent = $parent;
     /*
             if ($parent['type']=='CLUB') {
                 $droit = Kernel::getLevel($parent['type'], $parent['id']);
                 //print_r($droit);
                 if (GroupeService::canMakeInGroupe('VIEW_HOME', $droit))
                     $menu[] = array('url'=>CopixUrl::get ('groupe||getHome', array("id"=>$parent['id'])), 'txt'=>CopixI18N::get ('blog.menuToGroup'));
             }
             if (BlogAuth::canMakeInBlog('ACCESS_ADMIN',$blog))
                 $menu[] = array('url'=>CopixUrl::get ('admin|showBlog', array("id_blog"=>$blog->id_blog)), 'txt'=>CopixI18N::get ('blog.menuAdmin'));
     */
     //print_r($menu);
     $menu = array();
     if (BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         $menu = getBlogAdminMenu($blog);
     }
     $tpl->assign('MENU', $menu);
     CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('blog||rss', array("blog" => $blog->url_blog)) . '" type="application/rss+xml" title="' . htmlentities($blog->name_blog) . '" />');
     if ($blog->template) {
         $MAIN = $tpl->fetch($blog->template);
     } else {
         $MAIN = $tpl->fetch('blog_main.tpl');
     }
     $tpl->assign('MAIN', $MAIN);
     $tpl->assign('HEADER_MODE', 'compact');
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Formulaire de saisie/modif d'un type de teleprocedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/01/15
  * @param integer $save 1 si submit du formulaire
  */
 public function formtype()
 {
     $idtype = $this->getRequest('idtype');
     $teleprocedure = $this->getRequest('teleprocedure');
     $save = $this->getRequest('save');
     $daoType =& CopixDAOFactory::create('teleprocedures|type');
     $criticErrors = $errors = array();
     $tplForm = new CopixTpl();
     $tplForm->assign('is_online', array('values' => array(1, 0), 'output' => array(CopixI18N::get('blog|blog.oui'), CopixI18N::get('blog|blog.non'))));
     $formats = CopixConfig::get('teleprocedures|formats_types');
     $tabFormats = preg_split('/[\\s,]+/', $formats);
     $values = $output = array();
     foreach ($tabFormats as $k) {
         $values[] = $k;
         $output[] = CopixI18N::get('blog|blog.default_format_articles.' . $k);
     }
     $tplForm->assign('format', array('values' => $values, 'output' => $output));
     $tplForm->assign('linkpopup_responsables', CopixZone::process('annuaire|linkpopup', array('field' => 'responsables', 'profil' => 'USER_VIL')));
     $tplForm->assign('linkpopup_lecteurs', CopixZone::process('annuaire|linkpopup', array('field' => 'lecteurs', 'profil' => 'USER_VIL')));
     // Verifications
     if ($idtype) {
         if ($rType = $daoType->get($idtype)) {
             $mondroit = Kernel::getLevel("MOD_TELEPROCEDURES", $rType->teleprocedure);
             if (!TeleproceduresService::canMakeInTelep('ADMIN', $mondroit)) {
                 $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
             }
         } else {
             $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.noParameter');
         }
     } elseif ($teleprocedure) {
         $mondroit = Kernel::getLevel("MOD_TELEPROCEDURES", $teleprocedure);
         if (!TeleproceduresService::canMakeInTelep('ADMIN', $mondroit)) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         }
     } 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||')));
     }
     // Traitement
     if ($idtype) {
         // Modif
         $title = CopixI18N::get('teleprocedures|teleprocedures.title.modifType');
         if ($save) {
             // Responsables
             $responsables = $this->getRequest('responsables');
             $responsables = str_replace(array(" "), "", $responsables);
             $responsables = str_replace(array(",", ";"), ",", $responsables);
             $responsables = preg_split('/[\\s,]+/', $responsables);
             $tabResponsables = array();
             $deja = array();
             // On vérifie que les membres existent
             while (list(, $login) = each($responsables)) {
                 if (!$login) {
                     continue;
                 }
                 $userInfo = Kernel::getUserInfo("LOGIN", $login);
                 if (!$userInfo) {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoUser', array($login));
                 } elseif ($userInfo['type'] != 'USER_VIL') {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoVille', array($login));
                 } else {
                     $tabResponsables[] = $userInfo;
                     $deja[] = $login;
                 }
             }
             //print_r($tabResponsables);
             // Lecteurs
             $lecteurs = $this->getRequest('lecteurs');
             $lecteurs = str_replace(array(" "), "", $lecteurs);
             $lecteurs = str_replace(array(",", ";"), ",", $lecteurs);
             $lecteurs = preg_split('/[\\s,]+/', $lecteurs);
             $tabLecteurs = array();
             // On vérifie que les membres existent
             while (list(, $login) = each($lecteurs)) {
                 if (!$login) {
                     continue;
                 }
                 $userInfo = Kernel::getUserInfo("LOGIN", $login);
                 if (!$userInfo) {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoUser', array($login));
                 } elseif ($userInfo['type'] != 'USER_VIL') {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoVille', array($login));
                 } elseif (in_array($login, $deja)) {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberDeja', array($login));
                 } else {
                     $tabLecteurs[] = $userInfo;
                 }
             }
             $type = $rType;
             $type->nom = $this->getRequest('nom');
             $type->is_online = $this->getRequest('is_online');
             $type->teleprocedure = $this->getRequest('teleprocedure');
             $type->format = $this->getRequest('format');
             $type->texte_defaut = $this->getRequest('texte_defaut');
             $type->responsables = $this->getRequest('responsables');
             $type->lecteurs = $this->getRequest('lecteurs');
             $type->mail_from = $this->getRequest('mail_from');
             $type->mail_to = $this->getRequest('mail_to');
             $type->mail_cc = $this->getRequest('mail_cc');
             $type->mail_message = $this->getRequest('mail_message');
             if ($type->mail_from && !validateEMail($type->mail_from)) {
                 $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.incorrectMail', $type->mail_from);
             }
             if ($type->mail_to) {
                 $list = preg_split('/[\\s,]+/', $type->mail_to);
                 foreach ($list as $email) {
                     if (!validateEMail($email)) {
                         $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.incorrectMail', $email);
                     }
                 }
             }
             if ($type->mail_cc) {
                 $list = preg_split('/[\\s,]+/', $type->mail_cc);
                 foreach ($list as $email) {
                     if (!validateEMail($email)) {
                         $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.incorrectMail', $email);
                     }
                 }
             }
             if ($type->mail_to && !$type->mail_from) {
                 $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.mail_from');
             }
             $errorsDao = _dao('teleprocedures|type')->check($type);
             //die();
             if (count($errors) || is_array($errorsDao)) {
                 // Erreurs
                 if (is_array($errorsDao)) {
                     $errors = array_merge($errorsDao, $errors);
                 }
             } else {
                 // Pas d'erreurs
                 $daoType->update($type);
                 TeleproceduresService::saveDroits("type", $idtype, 'responsables', $tabResponsables);
                 TeleproceduresService::saveDroits("type", $idtype, 'lecteurs', $tabLecteurs);
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('admin|admin', array('id' => $type->teleprocedure)));
             }
         } else {
             $type = $rType;
         }
     } else {
         // Creation
         $title = CopixI18N::get('teleprocedures|teleprocedures.title.newType');
         $type = CopixDAOFactory::createRecord('teleprocedures|type');
         if ($save) {
             // Responsables
             $responsables = $this->getRequest('responsables');
             $responsables = str_replace(array(" "), "", $responsables);
             $responsables = str_replace(array(",", ";"), ",", $responsables);
             $responsables = preg_split('/[\\s,]+/', $responsables);
             $tabResponsables = array();
             while (list(, $login) = each($responsables)) {
                 if (!$login) {
                     continue;
                 }
                 $userInfo = Kernel::getUserInfo("LOGIN", $login);
                 if (!$userInfo) {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoUser', array($login));
                 } elseif ($userInfo['type'] != 'USER_VIL') {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoVille', array($login));
                 } else {
                     $tabResponsables[] = $userInfo;
                     $deja[] = $login;
                 }
             }
             // Lecteurs
             $lecteurs = $this->getRequest('lecteurs');
             $lecteurs = str_replace(array(" "), "", $lecteurs);
             $lecteurs = str_replace(array(",", ";"), ",", $lecteurs);
             $lecteurs = preg_split('/[\\s,]+/', $lecteurs);
             $tabLecteurs = array();
             // On vérifie que les membres existent
             while (list(, $login) = each($lecteurs)) {
                 if (!$login) {
                     continue;
                 }
                 $userInfo = Kernel::getUserInfo("LOGIN", $login);
                 if (!$userInfo) {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoUser', array($login));
                 } elseif ($userInfo['type'] != 'USER_VIL') {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberNoVille', array($login));
                 } elseif (in_array($login, $deja)) {
                     $errors[] = CopixI18N::get('teleprocedures|teleprocedures.error.memberDeja', array($login));
                 } else {
                     $tabLecteurs[] = $userInfo;
                 }
             }
             $type->nom = $this->getRequest('nom');
             $type->is_online = $this->getRequest('is_online');
             $type->teleprocedure = $this->getRequest('teleprocedure');
             $type->format = $this->getRequest('format');
             $type->texte_defaut = $this->getRequest('texte_defaut');
             $type->responsables = $this->getRequest('responsables');
             $type->lecteurs = $this->getRequest('lecteurs');
             $type->mail_from = $this->getRequest('mail_from');
             $type->mail_to = $this->getRequest('mail_to');
             $type->mail_cc = $this->getRequest('mail_cc');
             $type->mail_message = $this->getRequest('mail_message');
             $errorsDao = _dao('teleprocedures|type')->check($type);
             if (count($errors) || is_array($errorsDao)) {
                 // Erreurs
                 if (is_array($errorsDao)) {
                     $errors = array_merge($errorsDao, $errors);
                 }
             } else {
                 // Pas d'erreurs
                 $daoType->insert($type);
                 if ($type->idtype) {
                     TeleproceduresService::saveDroits("type", $type->idtype, 'responsables', $tabResponsables);
                     TeleproceduresService::saveDroits("type", $type->idtype, 'lecteurs', $tabLecteurs);
                 }
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('admin|admin', array('id' => $type->teleprocedure)));
             }
         } else {
             $type->teleprocedure = $teleprocedure;
             $type->is_online = 1;
             $type->format = CopixConfig::get('teleprocedures|default_format');
         }
     }
     //print_r($type);
     $tplForm->assign('type', $type);
     $tplForm->assign('edition_texte_defaut', CopixZone::process('kernel|edition', array('field' => 'texte_defaut', 'format' => $type->format, 'content' => $type->texte_defaut, 'height' => 460)));
     $tplForm->assign('errors', $errors);
     $tplForm->assign('mailEnabled', CopixConfig::get('|mailEnabled'));
     $main = $tplForm->fetch('form-type.tpl');
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', $title);
     $tpl->assign("MAIN", $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * getUserExtMod
  *
  * Affiche le formulaire de modification d'un utilisateur extérieur
  *
  * @package	Comptes
  * @author	Frédéric Mossmann <*****@*****.**>
  */
 public function getUserExtMod()
 {
     if (!Kernel::isAdmin() && !_currentUser()->hasAssistance('can_comptes')) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $errors = array();
     $tpl = new CopixTpl();
     $userext_dao =& CopixDAOFactory::create("kernel|kernel_ext_user");
     $copixuser_dao =& CopixDAOFactory::create("kernel|kernel_copixuser");
     $bu2user_dao =& CopixDAOFactory::create("kernel|kernel_bu2user2");
     $pNom = trim(_request('nom'));
     $pPrenom = trim(_request('prenom'));
     $pLogin = trim(_request('login'));
     $pPasswd1 = trim(_request('passwd1'));
     $pPasswd2 = trim(_request('passwd2'));
     $mode = _request('mode');
     if ($mode) {
         switch ($mode) {
             case 'MOD':
                 $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getuserextmod'));
                 $userext_item = $userext_dao->get(_request('id'));
                 if (!$userext_item) {
                     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
                 }
                 if ($pNom == '' && $pPrenom == '') {
                     $errors['ext_nom'] = CopixI18N::get('comptes.alert.nameempty');
                 }
                 if ($pPasswd1 != '' && $pPasswd1 != $pPasswd2) {
                     $errors['passwd2'] = CopixI18N::get('comptes.alert.passwddiff');
                 }
                 if (count($errors) == 0) {
                     $userext_item->ext_nom = $pNom;
                     $userext_item->ext_prenom = $pPrenom;
                     $userext_dao->update($userext_item);
                     if ($pPasswd1 != '' && $pPasswd1 == $pPasswd2) {
                         // Changer passwd
                         // dbuser : id_dbuser 	login_dbuser 	password_dbuser 	email_dbuser 	enabled_dbuser
                         // kernel_link_bu2user : user_id 	bu_type 	bu_id
                         $sql = "\n                                UPDATE dbuser\n                                JOIN kernel_link_bu2user\n                                    ON dbuser.id_dbuser=kernel_link_bu2user.user_id\n                                SET dbuser.password_dbuser=md5(:passwd)\n                                WHERE kernel_link_bu2user.bu_type = 'USER_EXT'\n                                AND   kernel_link_bu2user.bu_id   = :id";
                         _doQuery($sql, array(':passwd' => $pPasswd1, ':id' => _request('id')));
                     }
                     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
                 }
                 break;
             case 'ADD':
                 $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getuserextadd'));
                 $userext_item = CopixDAOFactory::createRecord("kernel|kernel_ext_user");
                 if ($pNom == '' && $pPrenom == '') {
                     $errors['ext_nom'] = CopixI18N::get('comptes.alert.nameempty');
                     $userext_item->ext_id = 0;
                 }
                 if (trim($pLogin) == '') {
                     $errors['login'] = CopixI18N::get('comptes.alert.loginempty');
                 } else {
                     $logins = _doQuery('SELECT * FROM dbuser WHERE login_dbuser=:login', array(':login' => $pLogin));
                     if (count($logins)) {
                         $errors['login'] = CopixI18N::get('comptes.alert.loginexists');
                     }
                 }
                 if ($pPasswd1 == '') {
                     $errors['passwd1'] = CopixI18N::get('comptes.alert.passwdempty');
                 }
                 if ($pPasswd1 != '' && $pPasswd1 != $pPasswd2) {
                     $errors['passwd2'] = CopixI18N::get('comptes.alert.passwddiff');
                 }
                 if (count($errors) == 0) {
                     // $userext_item->ext_id
                     $userext_item->ext_nom = $pNom;
                     $userext_item->ext_prenom = $pPrenom;
                     $userext_item->ext_description = '';
                     $userext_dao->insert($userext_item);
                     $copixuser_item = CopixDAOFactory::createRecord("kernel|kernel_copixuser");
                     $copixuser_item->login_dbuser = trim($pLogin);
                     $copixuser_item->password_dbuser = md5($pPasswd1);
                     $copixuser_item->email_dbuser = '';
                     $copixuser_item->enabled_dbuser = 1;
                     $copixuser_dao->insert($copixuser_item);
                     $bu2user_item = CopixDAOFactory::createRecord("kernel|kernel_bu2user2");
                     $bu2user_item->user_id = $copixuser_item->id_dbuser;
                     $bu2user_item->bu_type = "USER_EXT";
                     $bu2user_item->bu_id = $userext_item->ext_id;
                     $bu2user_dao->insert($bu2user_item);
                     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
                 }
                 break;
             case 'DEL':
                 // die("Do Del");
                 $userext_item = $userext_dao->get(abs(_request('id')));
                 if ($userext_item) {
                     $userext_dao->delete(abs(_request('id')));
                 }
                 _doQuery('DELETE FROM dbuser, kernel_link_bu2user USING dbuser JOIN kernel_link_bu2user ON dbuser.id_dbuser=kernel_link_bu2user.user_id WHERE kernel_link_bu2user.bu_type="USER_EXT" AND kernel_link_bu2user.bu_id=:id', array(':id' => abs(_request('id'))));
                 // _doQuery('DELETE FROM kernel_link_bu2user WHERE kernel_link_bu2user.bu_type="USER_EXT" AND kernel_link_bu2user.bu_id=:id', array(':id'=>abs(_request('id'))));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
                 break;
         }
     } else {
         if (_request('id') > 0) {
             $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getuserextmod'));
             $userext_item = $userext_dao->get(_request('id'));
             if (!$userext_item) {
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
             }
             if (!Kernel::isSuperAdmin() && Kernel::getLevel('ROOT', 0, "USER_EXT", $userext_item->ext_id) >= PROFILE_CCV_ADMIN) {
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
             }
             $mode = 'MOD';
         } elseif (_request('id') < 0) {
             $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getuserextdel'));
             $userext_item = $userext_dao->get(abs(_request('id')));
             if (!$userext_item) {
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
             }
             if (!Kernel::isSuperAdmin() && Kernel::getLevel('ROOT', 0, "USER_EXT", $userext_item->ext_id) >= PROFILE_CCV_ADMIN) {
                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes||getUserExt'));
             }
             $mode = 'DEL';
         } else {
             $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getuserextadd'));
             $userext_item = CopixDAOFactory::createRecord("kernel|kernel_ext_user");
             $userext_item->ext_id = 0;
             $mode = 'ADD';
         }
     }
     if ($mode == 'ADD' || $mode == 'MOD') {
         $result = CopixZone::process('comptes|getUserExtForm', array('user' => $userext_item, 'mode' => $mode, 'errors' => $errors));
     } else {
         return CopixActionGroup::process('genericTools|Messages::getConfirm', array('title' => CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.getuserextdel'), 'message' => CopixI18N::get('comptes.alert.getuserextdel', trim($userext_item->ext_prenom . ' ' . $userext_item->ext_nom)), 'confirm' => CopixUrl::get('comptes|default|getUserExtMod', array('id' => _request('id'), 'mode' => 'DEL')), 'cancel' => CopixUrl::get('comptes|default|getUserExt')));
     }
     $tpl->assign('MAIN', $result);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Validation d'une cat�gorie.
  */
 public function doValidCategory()
 {
     $id_blog = $this->getRequest('id_blog', null);
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_CATEGORIES', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageCategory'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $categoryDAO = CopixDAOFactory::create('blog|blogarticlecategory');
     $id_bacg = $this->getRequest('id_bacg', null);
     if (strlen($id_bacg) == 0) {
         $id_bacg = null;
     }
     if ($id_bacg != null) {
         // EDITION D'UNE CATEGORIE
         $category = $categoryDAO->get($id_bacg);
         $category->id_blog = $id_blog;
         $category->name_bacg = $this->getRequest('name_bacg');
         $category->url_bacg = $this->getRequest('url_bacg');
         if (strlen($category->url_bacg) == 0) {
             $category->url_bacg = killBadUrlChars($category->name_bacg);
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.category.title'));
         $errors = _dao('blog|blogarticlecategory')->check($category);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Modification dans la base
             $categoryDAO->update($category);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UNE CATEGORIE
         $category = CopixDAOFactory::createRecord('blogarticlecategory');
         $category->id_blog = $id_blog;
         $category->name_bacg = $this->getRequest('name_bacg');
         $category->order_bacg = $categoryDAO->getNewPos($id_blog);
         $category->url_bacg = killBadUrlChars($category->name_bacg);
         if (strlen($category->url_bacg) == 0) {
             $category->url_bacg = killBadUrlChars($category->name_bacg);
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.category.title'));
         $errors = _dao('blog|blogarticlecategory')->check($category);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Insertion dans la base
             $categoryDAO->insert($category);
             $category->url_bacg = killBadUrlChars($category->id_bacg . '-' . $category->name_bacg);
             $categoryDAO->update($category);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditCategory', array('id_blog' => $id_blog, 'id_bacg' => $id_bacg, 'category' => $category, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * 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);
 }
 /**
  * Validation d'une catégorie.
  */
 public function doValidRss()
 {
     $id_blog = $this->getRequest('id_blog', null);
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     if (!BlogAuth::canMakeInBlog('ADMIN_RSS', create_blog_object($id_blog))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageRss'), 'back' => CopixUrl::get('blog|admin|listBlog')));
     }
     $tpl = new CopixTpl();
     $fluxRssDAO = CopixDAOFactory::create('blog|blogfluxrss');
     $id_bfrs = $this->getRequest('id_bfrs', null);
     if (strlen($id_bfrs) == 0) {
         $id_bfrs = null;
     }
     if ($id_bfrs != null) {
         // EDITION D'UNE Link
         $fluxRss = $fluxRssDAO->get($id_bfrs);
         $fluxRss->id_blog = $id_blog;
         $fluxRss->name_bfrs = $this->getRequest('name_bfrs');
         $fluxRss->url_bfrs = $this->getRequest('url_bfrs');
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.rss.title'));
         $errors = _dao('blog|blogfluxrss')->check($fluxRss);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Modification dans la base
             $fluxRssDAO->update($fluxRss);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     } else {
         // CREATION D'UNE Link
         $fluxRss = CopixDAOFactory::createRecord('blogfluxrss');
         $fluxRss->id_blog = $id_blog;
         $fluxRss->name_bfrs = $this->getRequest('name_bfrs');
         $fluxRss->url_bfrs = $this->getRequest('url_bfrs');
         $fluxRss->order_bfrs = $fluxRssDAO->getNewPos($id_blog);
         $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.rss.title'));
         $errors = _dao('blog|blogfluxrss')->check($fluxRss);
         if ($errors != 1) {
             // Traitement des erreurs
             $showErrors = true;
         } else {
             // Insertion dans la base
             $fluxRssDAO->insert($fluxRss);
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0'))));
         }
     }
     $tpl->assign('MAIN', CopixZone::process('EditRss', array('id_blog' => $id_blog, 'id_brfs' => $id_bfrs, 'fluxRss' => $fluxRss, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function getGroup()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $tpl = new CopixTpl();
     $tplGrVilles = new CopixTpl();
     CopixHTMLHeader::addCSSLink(_resource("styles/module_regroupements.css"));
     $regroupements_service =& CopixClassesFactory::Create('regroupements|regroupements');
     $tpl->assign('TITLE_PAGE', CopixI18N::get('regroupements|regroupements.villes.titre'));
     $tpl->assign('MENU', $regroupements_service->getMenu());
     $dao_grvilles_gr2ville = CopixDAOFactory::create("regroupements|grvilles_gr2ville");
     $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles");
     $dao_villes = CopixDAOFactory::create("kernel|kernel_tree_vil");
     $villes = $dao_villes->findAll();
     $tplGrVilles->assign('villes', $villes);
     if (_request("delete")) {
         $dao_grvilles->delete(_request("delete"));
         $dao_grvilles_gr2ville->deleteByGroupe(_request("delete"));
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|'));
     }
     if (_request("save") && _request("save") == 1) {
         $date = date("Y-m-d H:i:s");
         $user = Kernel::getUserInfo();
         if (_request("form_id") > 0) {
             $grvilles_infos = $dao_grvilles->get(_request("form_id"));
             $grvilles_infos->nom = _request("form_nom");
             $grvilles_infos->updated_at = $date;
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->update($grvilles_infos);
             $dao_grvilles_gr2ville->deleteByGroupe(_request("form_id"));
         } else {
             $grvilles_infos = CopixDAOFactory::createRecord("regroupements|grvilles");
             $grvilles_infos->nom = _request("form_nom");
             if ($grvilles_infos->nom == '') {
                 $grvilles_infos->nom = 'Sans nom';
             }
             $grvilles_infos->updated_at = date("Y-m-d H:i:s");
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->insert($grvilles_infos);
         }
         $grvilles_gr2ville = _record("regroupements|grvilles_gr2ville");
         $grvilles_gr2ville->id_groupe = $grvilles_infos->id;
         $grvilles_gr2ville->updated_at = $date;
         $grvilles_gr2ville->updated_by = $user['login'];
         foreach ($villes as $ville) {
             if (_request("ville_" . $ville->vil_id_vi) == 1) {
                 $grvilles_gr2ville->id_ville = $ville->vil_id_vi;
                 _dao("regroupements|grvilles_gr2ville")->insert($grvilles_gr2ville);
             }
         }
         if (_request("form_id") == 0) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|', array('groupe' => $grvilles_infos->id)));
         }
     }
     if (_request("groupe")) {
         $tplGrVilles->assign('grvilles_id', _request("groupe"));
         $tplGrVilles->assign('grvilles_form', true);
         if (_request("groupe") > 0) {
             // Edition d'un groupe
             $grvilles_infos = $dao_grvilles->get(_request("groupe"));
             $grvilles_villes_raw = $dao_grvilles_gr2ville->findByGroupe(_request("groupe"));
             // Tableau indexé par id de ville
             $grvilles_villes = array();
             foreach ($grvilles_villes_raw as $grvilles_villes_item) {
                 $grvilles_villes[$grvilles_villes_item->id_ville] = $grvilles_villes_item;
             }
             $tplGrVilles->assign('grvilles_infos', $grvilles_infos);
             $tplGrVilles->assign('grvilles_villes', $grvilles_villes);
         } else {
             // Création d'un nouveau groupe
         }
     }
     $grvilles_list = $dao_grvilles->findAll();
     // print_r($grvilles_list);
     $tplGrVilles->assign('grvilles_list', $grvilles_list);
     $main = $tplGrVilles->fetch('getgrvilles.tpl');
     $tpl->assign('MAIN', $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function doCreateMail()
 {
     $id = _request("id");
     $dao = CopixDAOFactory::create("magicmail|magicmail");
     $mymagicmail = $dao->get($id);
     // $newlogin = substr( md5(microtime()), 0, 10 );
     $url = CopixConfig::get('magicmail|magicmail_url');
     $url .= 'register.php?action=add&url=' . urlencode(CopixUrl::get()) . '&id=' . urlencode($id);
     if ($mymagicmail && trim($mymagicmail->magicmail_login . '@' . $mymagicmail->magicmail_domain) != '') {
         $url .= '&login='******'r');
     if ($file) {
         $reply = '';
         while (!feof($file)) {
             $reply .= fgets($file, 4096);
         }
         // while (!feof($file))
         fclose($file);
         $return = '';
         if (ereg("^\\+OK (.+)@(.+)\$", $reply, $data)) {
             if (!$mymagicmail) {
                 $mymagicmail = CopixDAOFactory::createRecord("magicmail|magicmail");
                 $mymagicmail->magicmail_id = $id;
                 $mymagicmail->magicmail_login = $data[1];
                 $mymagicmail->magicmail_domain = $data[2];
                 $dao->insert($mymagicmail);
             } else {
                 //					echo( '<pre>'.print_r($mymagicmail,true).'</pre>');
                 $mymagicmail->magicmail_login = $data[1];
                 $mymagicmail->magicmail_domain = $data[2];
                 //					echo( '<pre>'.print_r($mymagicmail,true).'</pre>');
                 $dao->update($mymagicmail);
                 //					echo( '<pre>'.print_r($mymagicmail,true).'</pre>');
                 //					die('Gloups!');
             }
             $return = 'ok';
         } else {
             $return = 'error';
         }
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('magicmail|default|go', array('id' => _request("id"), 'return' => $return)));
 }