/** * Récupération de l'objet utilisateur. */ function &getUser() { if (!isset($_SESSION[$this->config->session_name])) { $_SESSION[$this->config->session_name] =& CopixClassesFactory::create($this->config->class_name); } return $_SESSION[$this->config->session_name]; }
public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $module_type = $this->getParam('module_type'); $module_id = $this->getParam('module_id'); $action = $this->getParam('action'); $date_debut = $this->getParam('date_debut', null); $date_fin = $this->getParam('date_fin', null); $dao = _dao('stats|logs'); $stats = $dao->getStatsModuleAction(array('module_type' => $module_type, 'module_id' => $module_id, 'action' => $action, 'date_debut' => $date_debut, 'date_fin' => $date_fin)); //print_r($stats); foreach ($stats as $k => $s) { // Détection du nom Copix du module list(, $module) = explode("_", strtolower($module_type)); $class = CopixClassesFactory::create("{$module}|Stats{$module}"); $obj = $class->getObjet($action, $s->objet_a); //print_r($obj); $stats[$k]->objet_name = isset($obj->name) ? $obj->name : ''; } $tpl->assign('name', CopixI18N::get('stats.action.' . $module_type . '-' . $action)); $tpl->assign('stats', $stats); //$tpl->assign ('canWriteOnline' , BlogAuth::canMakeInBlog('ADMIN_ARTICLE_MAKE_ONLINE',create_blog_object($id_blog))); // retour de la fonction : $toReturn = $tpl->fetch('module.action.tpl'); return true; }
public static function get($pType, $pParams, $pAssert = true) { if ($pType === null) { $pType = 'varchar'; } if (isset(self::$_arFields[$pType])) { $class = self::$_arFields[$pType]; return new $class($pParams); } else { if (strpos($pType, '|')) { return CopixClassesFactory::create($pType, array($pParams)); } else { if (class_exists('CopixField' . $pType)) { $class = 'CopixField' . $pType; return new $class($pParams); } else { if ($pAssert) { throw new CopixException('Ce type n\'existe pas [' . $pType . ']'); } else { return new CopixFieldVarchar($pParams); } } } } }
public function service($iService) { if (!is_string($iService)) { trigger_error('Enic failed to load Service : invalid name', E_USER_WARNING); } if (!isset($this->shared['s' . $iService])) { $this->shared['s' . $iService] =& CopixClassesFactory::create($iService); } return $this->shared['s' . $iService]; }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $service =& CopixClassesFactory::create('InstallService'); if (isset($this->params['newInstall'])) { $tpl->assign('newInstall', $this->params['newInstall']); } else { $tpl->assign('newInstall', false); } $tpl->assign('arModules', $service->getModules()); $toReturn = $tpl->fetch('install.customised.tpl'); }
public function testSimpleRTFTemplate() { $template = CopixClassesFactory::create('genericTools|RTFTemplate'); $template->assign('VARIABLE_1', 'Voici une belle présentation <b>avec des infos importantes</b> ', true); $template->assign('VARIABLE_2', '<ul><li>puce 1</li><li>puce 2</li><li>puce 3</li></ul>', true); $template->assign('VARIABLE_3', 'Contenu simple', true); $codeDuDocumentRTFFinal = $template->fetch('generictools|rtftest.rtf'); $selector = CopixSelectorFactory::create('generictools|rtftest.expectedresult.rtf'); $expectedResultFilePath = $selector->getPath(COPIX_TEMPLATES_DIR) . $selector->fileName; $codeDuDocumentRTFTest = file_get_contents($expectedResultFilePath); CopixFile::write('/tmp/document_sortie.rtf', $codeDuDocumentRTFFinal); $this->assertEquals($codeDuDocumentRTFFinal, $codeDuDocumentRTFTest); }
/** * Crée un groupe * * Crée le groupe, donne les droits de propriétaire à son créateur, et initialise les premiers modules. * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/08 * @param string $titre Titre * @param string $description Description * @param integer $is_open 1 si le groupe est public, 0 s'il est privé * @param integer $createur Id utilisateur du créateur * @param array $tab_membres Tableau avec les membres à inscrire de suite (clé = id user) * @param array $his_modules Tableau avec les modules à installer et à relier à ce club * @param string $parentClass Type du parent (BU_ECOLE...) * @param integer $parentRef Référence du parent * @return integer l'Id du groupe créé ou NULL si erreur */ public function createGroupe($titre, $description, $is_open, $createur, $tab_membres, $his_modules, $parentClass, $parentRef) { $res = NULL; if (1) { $daoGroupe = _dao("groupe"); $newGroupe = _record("groupe"); $newGroupe->titre = $titre; $newGroupe->description = $description; $newGroupe->is_open = $is_open; $newGroupe->date_creation = date("Y-m-d H:i:s"); $newGroupe->createur = $createur; $daoGroupe->insert($newGroupe); if ($newGroupe->id !== NULL) { //print_r($his_modules); $kernelClasse = CopixClassesFactory::create("kernel|Kernel"); // On ajoute les modules while (list($moduleType, ) = each($his_modules)) { list(, $module) = explode("_", strtolower($moduleType)); //print_r($module); $classeNew = CopixClassesFactory::create("{$module}|Kernel{$module}"); $new = $classeNew->create(array('title' => $titre, 'node_type' => 'CLUB', 'node_id' => $newGroupe->id)); //print_r("new=$new"); if ($new) { // Module bien crée, on le rattache $register = $kernelClasse->registerModule($moduleType, $new, "CLUB", $newGroupe->id); } } // On insère le créateur $userInfo = $kernelClasse->getUserInfo("ID", $createur); $kernelClasse->setLevel("CLUB", $newGroupe->id, $userInfo["type"], $userInfo["id"], PROFILE_CCV_ADMIN); // On insère les éventuels membres while (list($userId, ) = each($tab_membres)) { $userInfo = $kernelClasse->getUserInfo("ID", $userId); $kernelClasse->setLevel("CLUB", $newGroupe->id, $userInfo["type"], $userInfo["id"], PROFILE_CCV_MEMBER); } // On rattache le groupe à son parent $kernelClasse->setClubParent($newGroupe->id, $parentClass, $parentRef); $res = $newGroupe->id; //die(); } } return $res; }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $plugAuth =& $GLOBALS['COPIX']['COORD']->getPlugin('auth|auth'); $user =& $plugAuth->getUser(); if ($user->isConnected()) { $tpl->assign('showErrors', $this->params['e']); //dao error or something else if (isset($this->params['toEdit']->errors)) { $tpl->assign('errors', $this->params['toEdit']->errors); } else { $tpl->assign('errors', $this->params['toEdit']->check()); } $tpl->assign('toEdit', $this->params['toEdit']); $services =& CopixClassesFactory::create('comment|commentservices'); $tpl->assign('formatList', $services->getFormatList()); $toReturn = $tpl->fetch('comment.add.tpl'); } else { $toReturn = CopixI18N::get('comment|comment.messages.needLogin'); } return true; }
function smarty_function_commentthis($params, &$smarty) { extract($params); if (empty($displaytype)) { $displaytype = 'list'; } if (empty($type)) { $smarty->trigger_error('commentthis: missing type parameter'); } if (empty($id)) { $smarty->trigger_error('commentthis: missing id parameter'); } if (empty($dest)) { $dest = CopixUrl::get('comment||getList', array('type' => $type, 'id' => $id, 'back' => $back)); } $dao =& CopixDAOFactory::create('comment|Comment'); $services =& CopixClassesFactory::create('comment|commentservices'); $services->enableComment($id, $type); switch ($displaytype) { case 'link': $nbComment = $dao->getNbComment($id, $type); $toReturn = '<a href=' . $dest . '>' . $nbComment . ' '; $toReturn .= $nbComment > 1 ? CopixI18N::get('comment|comment.messages.comments') : CopixI18N::get('comment|comment.messages.comment'); $toReturn .= '</a>'; break; case 'form': $back = CopixUrl::getCurrentUrl(); CopixActionGroup::process('comment|comment::doPrepareAdd', array('type' => $type, 'id' => $id, 'back' => $back)); $toEdit = CopixActionGroup::process('comment|comment::_getSessionComment'); $toReturn = CopixZone::process('comment|AddComment', array('toEdit' => $toEdit)); break; case 'list': default: $toReturn = CopixZone::process('comment|CommentList', array('type' => $type, 'id' => $id)); break; } return $toReturn; }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); // On récupère les noms des drivers de base de donnée installés dans copix $dbDriverPath = COPIX_PATH . 'db/drivers/'; if ($handle = opendir($dbDriverPath)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && !is_file($file) && strtoupper($file) != "CVS") { $tabDBType[] = $file; } } closedir($handle); } $services =& CopixClassesFactory::create('InstallService'); $tpl->assign('arType', $tabDBType); $tpl->assign('databaseNotOk', $this->params['databaseNotOk']); $tpl->assign('configurationFileWritable', $services->checkConfigurationFileWritable()); $tpl->assign('configurationFilePath', XML_COPIXDB_PROFIL); $tpl->assign('currentParameters', $services->getCurrentParameters()); $tpl->assign('copixdbok', $GLOBALS['COPIX']['COORD']->getPlugin('copixdb') !== null); // retour de la fonction : $toReturn = $tpl->fetch('install.edit.tpl'); return true; }
/** * Suppression effective d'une discussion * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/10 * @param integer $id Id de la discussion a supprimer */ public function doDeleteTopic() { $errors = array(); $id = _request("id") ? _request("id") : NULL; $dao_topics = CopixDAOFactory::create("forum_topics"); $forumService = CopixClassesFactory::create("forum|forumService"); $rTopic = $dao_topics->get($id); if (!$rTopic) { $errors[] = CopixI18N::get('forum|forum.error.noTopic'); } else { $mondroit = Kernel::getLevel("MOD_FORUM", $rTopic->forum_id); if (!$forumService->canMakeInForum('DELETE_TOPIC', $mondroit)) { $errors[] = CopixI18N::get('kernel|kernel.error.noRights'); } } if ($errors) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('forum||'))); } else { $del = $forumService->deleteForumTopic($id); if (!$del) { $errors[] = CopixI18N::get('forum|forum.error.delTopic'); } if ($errors) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('forum||getTopic', array("id" => $id)))); } $urlReturn = CopixUrl::get('forum||getForum', array("id" => $rTopic->forum_id)); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } }
/** * Création d'un histogramme horizontal * @return objet Column */ public function createColumn() { return CopixClassesFactory::create("chart_swf|SWFColumn"); }
/** * Mise à jour des données n'ayant pas été enregistrées au moment des logs dans la base de données. Correspond à la recherche des parents des modules * * @author Christophe Beyer <*****@*****.**> * @since 2007/06/12 */ public function updateCron() { $serv = CopixClassesFactory::create("stats|StatsService"); $send = $serv->updateCron(); return new CopixActionReturn(COPIX_AR_NONE, 0); }
/** * Ajoute une discussion (avec le premier message) dans un ou plusieurs carnets de correspondance * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/16 * @param integer $classe Id de la classe * @param integer $createur Id utilisateur du créateur de la discussion * @param string $titre Titre de la discussion * @param string $message Corps du premier message * @param array $eleves Id des élèves concernés * @param string $format Format de la discussion * @return integer Id du topic crée ou NULL si erreur */ public function addCarnetTopic($classe, $createur, $titre, $message, $eleves, $format) { $res = NULL; $daoTopics = _dao("carnet|carnet_topics"); $kernelClasse = CopixClassesFactory::create("kernel|Kernel"); $newTopic = _record("carnet|carnet_topics"); $newTopic->titre = $titre; $newTopic->message = $message; $newTopic->format = $format; $newTopic->classe = $classe; $newTopic->createur = $createur; $newTopic->date_creation = date("Y-m-d H:i:s"); $daoTopics->insert($newTopic); if ($newTopic->id !== NULL) { $daoTopicsTo = _dao("carnet|carnet_topics_to"); /* if (!$eleve) { // Tous les élèves de la classe ! $eleves = $kernelClasse->getNodeChilds ("BU_CLASSE", $classe); while (list(,$v) = each($eleves)) { if ($v["type"]=="USER_ELE") { // Todo prévoir fonction qui ne renvoie que les élèves pour zapper ce test $newTopicTo = _record("carnet|carnet_topics_to"); $newTopicTo->topic = $newTopic->id; $newTopicTo->eleve = $v["id"]; $daoTopicsTo->insert ($newTopicTo); } } } else { // Chez un élève précis $daoTopicsTo = _dao("carnet|carnet_topics_to"); $newTopicTo = _record("carnet|carnet_topics_to"); $newTopicTo->topic = $newTopic->id; $newTopicTo->eleve = $eleve; $daoTopicsTo->insert ($newTopicTo); } */ foreach ($eleves as $eleve) { $daoTopicsTo = _dao("carnet|carnet_topics_to"); $newTopicTo = _record("carnet|carnet_topics_to"); $newTopicTo->topic = $newTopic->id; $newTopicTo->eleve = $eleve; $daoTopicsTo->insert($newTopicTo); } $res = $newTopic->id; } return $res; }
public function processMuninTeleprocedures() { $serv = CopixClassesFactory::create("stats|IconitoService"); if (_request('config', 0)) { echo "graph_title Teleprocedures\n"; echo "graph_args --base 1000 -l 0\n"; echo "graph_vlabel Nb\n"; echo "graph_scale yes\n"; echo "graph_info This graph shows how CPU time is spent.\n"; echo "graph_category Ecole Numerique\n"; echo "graph_period minute\n"; echo "teleprocedures_type.label Types de teleprocedures\n"; echo "teleprocedures.label Teleprocedures\n"; } else { echo "teleprocedures_type.value " . $serv->getNbObject("teleprocedures_type") . "\n"; echo "teleprocedures.value " . $serv->getNbObject("teleprocedures") . "\n"; } return new CopixActionReturn(COPIX_AR_NONE, 0); }
/** * Soumission du formulaire d'�criture d'un minimail (envoie le minimail) * * @author Christophe Beyer <*****@*****.**> * @since 2005/10/18 * @see getNewForm() * @param string $dest Logins du(des) destinataire(s) * @param string $title Titre du minimail * @param string $message Corps du minimail * @param string $go Forme de soumission : preview (pr�visualiser) ou send (enregistrer) */ public function doSend() { $dest = _request("dest") ? _request("dest") : ""; $title = _request("title") ? _request("title") : ""; $message = _request("message") ? _request("message") : ""; $format = _request("format") ? _request("format") : ""; $go = _request("go") ? _request("go") : 'preview'; $iReply = CopixRequest::getInt('reply'); $iForward = CopixRequest::getInt('forward'); $destTxt = $dest; $destTxt = str_replace(array(" "), "", $destTxt); $destTxt = str_replace(array(",", ";"), ",", $destTxt); $destin = array_unique(explode(",", $destTxt)); $fromId = _currentUser()->getId(); $errors = array(); if (!$dest) { $errors[] = CopixI18N::get('minimail.error.typeDest'); } if (!$title) { $errors[] = CopixI18N::get('minimail.error.typeTitle'); } if (!$message) { $errors[] = CopixI18N::get('minimail.error.typeMessage'); } if (!$format) { $errors[] = CopixI18N::get('minimail.error.typeFormat'); } $tabDest = array(); // On v�rifie que les destinataires existent while (list(, $login) = each($destin)) { if (!$login) { continue; } $userInfo = Kernel::getUserInfo("LOGIN", $login, array('strict' => true)); //print_r("login=$login"); //print_r($userInfo); if (!$userInfo) { $errors[] = CopixI18N::get('minimail.error.badDest', array($login)); } elseif ($userInfo["user_id"] == $fromId) { $errors[] = CopixI18N::get('minimail.error.writeHimself'); } else { $droits = Kernel::getUserInfoMatrix($userInfo); if ($droits['communiquer']) { $tabDest[$userInfo["user_id"]] = $userInfo["user_id"]; } else { $errors[] = CopixI18N::get('minimail.error.cannotWrite', array($login)); } } } // On v�rifie les pi�ces jointes CopixConfig::get('minimail|attachment_size'); //print_r($_FILES); for ($i = 1; $i <= 3; $i++) { if (isset($_FILES['attachment' . $i]) && !is_uploaded_file($_FILES['attachment' . $i]['tmp_name'])) { switch ($_FILES['attachment' . $i]['error']) { case 0: //no error; possible file attack! $errors[] = CopixI18N::get('minimail|minimail.error.upload_default', $i); break; case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini $errors[] = CopixI18N::get('minimail|minimail.error.upload_toobig', $i); break; case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = CopixI18N::get('minimail|minimail.error.upload_toobig', $i); break; case 3: //uploaded file was only partially uploaded $errors[] = CopixI18N::get('minimail|minimail.error.upload_partial', $i); break; case 4: //no file was uploaded break; default: $errors[] = CopixI18N::get('minimail|minimail.error.upload_default', $i); break; } } } if (!$errors) { if (!$errors && $go == 'save') { $serv = CopixClassesFactory::create("MinimailService"); $send = $serv->sendMinimail($title, $message, $fromId, $tabDest, $format); if (!$send) { $errors[] = CopixI18N::get('minimail.error.send'); } } if (!$errors && $go == 'save') { // Reponse ou forward ? if ($iReply) { // On verifie qu'on est destinataire if ($inDest = _ioDAO('minimail_to')->selectDestFromIdAndToUser($iReply, $fromId)) { _doQuery("UPDATE module_minimail_to SET is_replied=1 WHERE id=:id", array(':id' => $inDest->id2)); } } elseif ($iForward) { $message = _ioDAO('minimail_from')->get($iForward); // Si on etait l'expediteur if ($message && $message->from_id == $fromId) { _doQuery("UPDATE module_minimail_from SET is_forwarded=1 WHERE id=:id", array(':id' => $iForward)); // Si on etait destinataire } elseif ($message && ($inDest = _ioDAO('minimail_to')->selectDestFromIdAndToUser($iForward, $fromId))) { _doQuery("UPDATE module_minimail_to SET is_forwarded=1 WHERE id=:id", array(':id' => $inDest->id2)); } } // Ajout des pieces jointes $attachments = array(); $dataPath = realpath("../var/data"); for ($i = 1; $i <= 3; $i++) { if (isset($_FILES["attachment" . $i]) && isset($_FILES["attachment" . $i]["name"]) && $_FILES["attachment" . $i]["name"]) { $name = $send . "_" . $_FILES["attachment" . $i]["name"]; $uploadFrom = $_FILES["attachment" . $i]["tmp_name"]; $uploadTo = $dataPath . "/minimail/" . $name; if (move_uploaded_file($uploadFrom, $uploadTo)) { $attachments[] = $name; } else { $errors[] = CopixI18N::get('minimail.error.send', array($i)); } } } if (count($attachments) > 0) { $DAOminimail_from = CopixDAOFactory::create("minimail_from"); $mp = $DAOminimail_from->get($send); $mp->attachment1 = isset($attachments[0]) ? $attachments[0] : NULL; $mp->attachment2 = isset($attachments[1]) ? $attachments[1] : NULL; $mp->attachment3 = isset($attachments[2]) ? $attachments[2] : NULL; $DAOminimail_from->update($mp); } // update_message_pj ($res, $pj[0], $pj[1], $pj[2]); if (!$errors) { $urlReturn = CopixUrl::get('|getListSend'); return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } } } //_dump($message); return CopixActionGroup::process('minimail|minimail::getNewForm', array('dest' => $dest, 'title' => $title, 'message' => $message, 'format' => $format, 'errors' => $errors, 'preview' => $go == 'save' ? 0 : 1, 'reply' => $iReply, 'forward' => $iForward)); //$url_return = CopixConfig::get('minimail|afterMsgSend'); //$url_return = CopixUrl::get('minimail||getListSend'); }
/** * apply updates on the edited comment. * save to datebase if ok and save file. */ function doValid() { $plugAuth =& $GLOBALS['COPIX']['COORD']->getPlugin('auth|auth'); $user =& $plugAuth->getUser(); if ($user->isConnected()) { if (!($toValid = $this->_getSessionComment())) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('comment.error.unableToGetSession'))); } $services =& CopixClassesFactory::create('comment|commentservices'); if (!$services->canComment($toValid->id_cmt, $toValid->type_cmt)) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('comment.error.unableToComment'))); } $dao =& CopixDAOFactory::create('Comment'); $this->_validFromForm($toValid); //inserting or updating. if ($toValid->INTERNAL_COPIX_IsNew !== true) { if ($toValid->check() !== true) { $this->_setSessionComment($toValid); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comment||edit', array('e' => '1'))); } $dao->update($toValid); } else { $toValid->date_cmt = date('Ymd'); $toValid->author_cmt = $user->login; $toValid->position_cmt = $dao->getNextPosition($toValid->type_cmt, $toValid->id_cmt); if ($toValid->check() !== true) { $this->_setSessionComment($toValid); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comment||edit', array('e' => '1'))); } $dao->insert($toValid); } // Gestion du notifier pour les projets koyo // CopixEventNotifier::notify(new CopixEvent('AddComment', array('id' => $toValid->id_cmt, 'type' => $toValid->type_cmt))); $this->_setSessionComment(null); if ($toValid->backToComment) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comment||', array('back' => urlencode($toValid->back), 'id' => $toValid->id_cmt, 'type' => $toValid->type_cmt))); } else { return new CopixActionReturn(COPIX_AR_REDIRECT, $toValid->back); } } else { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('comment|comment.messages.needLogin'))); } }
/** * Soumission du formulaire d'écriture d'un message sur une liste * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/23 * @see getMessageForm() * @param integer $liste Id de la liste sur laquelle on écrit * @param string $title Titre du minimail * @param string $message Corps du minimail * @param string $go Forme de soumission : preview (prévisualiser) ou send (enregistrer) */ public function doMessageForm() { $errors = $criticErrors = array(); $liste = _request("liste") ? _request("liste") : NULL; $titre = _request("titre") ? _request("titre") : NULL; $message = _request("message") ? _request("message") : NULL; $go = _request("go") ? _request("go") : 'preview'; if ($liste) { // Nouveau message $dao_listes = CopixDAOFactory::create("liste|liste_listes"); $rListe = $dao_listes->get($liste); if (!$rListe) { $criticErrors[] = CopixI18N::get('liste|liste.error.noListe'); } else { $kernel_service =& CopixClassesFactory::Create('kernel|kernel'); $mondroit = $kernel_service->getLevel("MOD_LISTE", $liste); if (!ListeService::canMakeInListe('WRITE', $mondroit)) { $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights'); } } } else { $criticErrors[] = CopixI18N::get('liste|liste.error.impossible'); } if (!$titre) { $errors[] = CopixI18N::get('liste|liste.error.typeTitle'); } if (!$message) { $errors[] = CopixI18N::get('liste|liste.error.typeMessage'); } if ($criticErrors) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('liste||'))); } else { $auteur = _currentUser()->getId(); if (!$errors && $go == 'save') { // Insertion $service = CopixClassesFactory::create("ListeService"); $add = $service->addListeMessage($liste, $auteur, $titre, $message); if (!$add) { $errors[] = CopixI18N::get('liste|liste.error.sendMessage'); } $urlReturn = CopixUrl::get('liste||getListe', array("id" => $liste)); if (!$errors) { return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn); } } return CopixActionGroup::process('liste|liste::getMessageForm', array('liste' => $liste, 'titre' => $titre, 'message' => $message, 'errors' => $errors, 'preview' => $go == 'save' ? 0 : 1)); } }
/** * Alias à CopixClassesFactory::create (); * @param string $pClassId identifiant de la classe à créer (module|classe) * @param array $pArgs Arguments de création * @return object * @see CopixClassesFactory::create */ function _class($pClassId, $pArgs = null) { return CopixClassesFactory::create($pClassId, $pArgs); }
/** * Lance la validation des différents champs * @param $pField le champ a valider * @return array retourne un tableau d'erreur, si le tableau est vide alors il n'y a pas d'erreur */ public function isValid() { $this->_errors = $errors = array(); if ($this->getParams('valid') !== null) { $arClasses = explode('::', $this->getParams('valid')); if (count($arClasses) != 2) { throw new CopixFieldException(_i18n('copixfield.message.validIncorrect')); } $classe = CopixClassesFactory::create($arClasses[0]); $errors = $classe->{$arClasses}[1]($this); if ($errors === null) { $errors = array(); } if (!is_array($errors)) { $errors = array($errors); } } $this->_errors = $errors; return $errors; }
/** * getModEnabled * * Retourne la liste des modules attachÈs ‡ un noeud, et en option, ceux dÈpendant du type d'utilisateur. * * @author FrÈdÈric Mossmann <*****@*****.**> * @param string $node_type Type de noeud. * @param integer $node_id Identifiant du noeud. * @param string $user_type Type d'utilisateur (facultatif). * @param integer $user_id Identifiant du noeud (facultatif). */ public function getModEnabled($node_type, $node_id, $user_type = '', $user_id = 0, $full = 0, $notification = 0) { // echo "getModEnabled( $node_type, $node_id, $user_type, $user_id)"; $carnetDeLiaison = CopixConfig::exists('kernel|carnetDeLiaison') && CopixConfig::get('kernel|carnetDeLiaison'); $dao = _dao("kernel|kernel_mod_enabled"); $modules = array(); // Parent d'eleve... if (0 == strncmp($node_type, "USER_ELE", 8) && 0 == strncmp($user_type, "USER_RES", 8)) { $parents = Kernel::getNodeParents($node_type, $node_id); $parent = Kernel::filterNodeList($parents, 'BU_CLASSE'); if (count($parent)) { if ($parent[0]['droit'] >= 30) { $parent_modules = Kernel::getModEnabled($parent[0]['type'], $parent[0]['id'], $node_type, $node_id); /* echo '<li>$parent[0][] = '.$parent[0]['type']."/".$parent[0]['id']."</li>"; echo '<li>$node_* = '.$node_type."/".$node_id."</li>"; */ $perso = new stdClass(); foreach ($parent_modules as $parent_module) { /* $perso->node_type = $parent[0]['type']; $perso->node_id = $parent[0]['id']; */ $perso->node_type = $node_type; $perso->node_id = $node_id; $perso->module_type = $parent_module->module_type; $perso->module_id = $parent_module->module_id; $perso->module_nom = Kernel::Code2Name($parent_module->module_type); $modules[] = clone $perso; } /* $perso->node_type = $parent[0]['type']; $perso->node_id = $parent[0]['id']; */ $perso->node_type = $node_type; $perso->node_id = $node_id; $perso->module_type = 'MOD_CARNET'; $perso->module_id = 'ELEVE_' . $node_id; $perso->module_nom = Kernel::Code2Name('MOD_CARNET'); if ($carnetDeLiaison) { $modules[] = clone $perso; } } } // _dump($modules); if ($notification) { Kernel::getModlistNotifications($modules); } reset($modules); return $modules; } $list = $dao->getByNode($node_type, $node_id); foreach ($list as $v) { if (!$full) { if ($v->module_type == 'MOD_MAGICMAIL') { continue; } } $v->module_nom = Kernel::Code2Name($v->module_type); $modules[] = clone $v; } // _dump($modules); //print_r($modules); if ($user_type == "USER_ENS" && $node_type == "BU_CLASSE" && Kernel::getLevel($node_type, $node_id) >= 60) { $carnetcorresp = new CopixPPO(); $carnetcorresp->node_type = $node_type; $carnetcorresp->node_id = $node_id; $carnetcorresp->module_type = 'MOD_CARNET'; $carnetcorresp->module_id = 'CLASSE_' . $node_id; $carnetcorresp->module_nom = Kernel::Code2Name('MOD_CARNET'); if ($carnetDeLiaison) { $modules[] = clone $carnetcorresp; } } //for KNE if (in_array($user_type, array('USER_ELE', 'USER_ENS', 'USER_DIR', 'USER_DID')) && $node_type == 'BU_CLASSE' && CopixClassesFactory::create('kne|kneService')->active) { $modKne = new stdClass(); $modKne->node_type = $node_type; $modKne->node_id = $node_id; $modKne->module_type = 'MOD_KNE'; $modKne->module_id = $node_id; $modKne->module_nom = kernel::Code2Name('MOD_KNE'); $modules[] = $modKne; } //for Coreprim if (in_array($user_type, array('USER_ELE', 'USER_ENS', 'USER_DIR', 'USER_DID')) && $node_type == 'BU_CLASSE' && CopixConfig::exists('default|rssEtagereEnabled') && CopixConfig::get('default|rssEtagereEnabled')) { $modRssEtagere = new stdClass(); $modRssEtagere->node_type = $node_type; $modRssEtagere->node_id = $node_id; $modRssEtagere->module_type = 'MOD_RSSETAGERE'; $modRssEtagere->module_id = $node_type . "-" . $node_id; $modRssEtagere->module_nom = kernel::Code2Name('MOD_RSSETAGERE'); $modules[] = $modRssEtagere; } if (CopixConfig::exists('|conf_ModTeleprocedures') && CopixConfig::get('|conf_ModTeleprocedures') == 0) { // Pas de module de tÈlÈprocÈdures... } else { if ($user_type == "USER_ENS" && $node_type == "BU_ECOLE" && Kernel::getLevel($node_type, $node_id) >= 60) { $teleprocedures = new CopixPPO(); $teleprocedures->node_type = $node_type; $teleprocedures->node_id = $node_id; $teleprocedures->module_type = 'MOD_TELEPROCEDURES'; $teleprocedures->module_id = 'ECOLE_' . $node_id; $teleprocedures->module_nom = Kernel::Code2Name('MOD_TELEPROCEDURES'); $modules[] = clone $teleprocedures; } elseif (CopixConfig::exists('teleprocedures|USER_ADM_as_USER_ENS') && CopixConfig::get('teleprocedures|USER_ADM_as_USER_ENS') && $user_type == "USER_ADM" && $node_type == "BU_ECOLE" && Kernel::getLevel($node_type, $node_id) >= 30) { $teleprocedures = new CopixPPO(); $teleprocedures->node_type = $node_type; $teleprocedures->node_id = $node_id; $teleprocedures->module_type = 'MOD_TELEPROCEDURES'; $teleprocedures->module_id = 'ECOLE_' . $node_id; $teleprocedures->module_nom = Kernel::Code2Name('MOD_TELEPROCEDURES'); $modules[] = clone $teleprocedures; } } // Cas particuliers : modules personnels sans numÈros if (0 == strncmp($node_type, "USER_", 5)) { $perso_list = array('MOD_ANNUAIRE', 'MOD_MINIMAIL', 'MOD_GROUPE', 'MOD_RESSOURCE'); foreach ($perso_list as $perso_module) { $perso = new CopixPPO(); $perso->node_type = $node_type; $perso->node_id = $node_id; $perso->module_id = NULL; $perso->module_type = $perso_module; $perso->module_nom = Kernel::Code2Name($perso_module); $modules[] = clone $perso; unset($perso); } } // Cas particulier : module d'administration if ($node_type == "ROOT" && Kernel::getLevel($node_type, $node_id) >= 60) { $sysutils = new CopixPPO(); $sysutils->node_type = $node_type; $sysutils->node_id = $node_id; $sysutils->module_id = NULL; $sysutils->module_type = 'MOD_SYSUTILS'; $sysutils->module_nom = Kernel::Code2Name('MOD_SYSUTILS'); $modules[] = clone $sysutils; $charte = new CopixPPO(); $charte->node_type = $node_type; $charte->node_id = $node_id; $charte->module_id = NULL; $charte->module_type = 'MOD_CHARTE'; $charte->module_nom = Kernel::Code2Name('MOD_CHARTE'); $modules[] = clone $charte; } // Cas ENS+VIL : SSO vers Gael si tout est configurÈ. $SsoGaelService =& CopixClassesFactory::Create('ssogael|ssogael'); if (($user_type == "USER_ENS" && $node_type == "BU_ECOLE" || $user_type == "USER_VIL" && $node_type == "BU_VILLE") && method_exists($SsoGaelService, "canSsoGael") && $SsoGaelService->canSsoGael() && Kernel::getLevel($node_type, $node_id) >= 60) { $comptes = new stdClass(); $comptes->node_type = $node_type; $comptes->node_id = $node_id; $comptes->module_type = 'MOD_SSOGAEL'; $comptes->module_id = $node_type . '-' . $node_id; $comptes->module_nom = Kernel::Code2Name('MOD_SSO_GAEL'); $comptes->module_popup = true; // Mode Popup !!! $modules[] = clone $comptes; } // Cas particulier : gestion des groupes de ville (AC/TICE) if ($node_type == "ROOT" && Kernel::getLevel($node_type, $node_id) >= 60) { $mod_grvilles = new stdClass(); $mod_grvilles->node_type = $node_type; $mod_grvilles->node_id = $node_id; $mod_grvilles->module_type = 'MOD_REGROUPEMENTS'; $mod_grvilles->module_id = $node_type . '-' . $node_id; $mod_grvilles->module_nom = Kernel::Code2Name('MOD_REGROUPEMENTS'); $modules[] = clone $mod_grvilles; } // Cas particulier : Gestion autonome // if( $user_type == "USER_EXT" // && $node_type == "ROOT" // && Kernel::getLevel( $node_type, $node_id ) >= 60 ) { if (CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled')) { if (($node_type == "ROOT" || $user_type == "USER_ENS" && $node_type == "BU_ECOLE" || $user_type == "USER_ENS" && $node_type == "BU_CLASSE" || $user_type == "USER_VIL" && $node_type == "BU_VILLE") && Kernel::getLevel($node_type, $node_id) >= 60) { $mod_grvilles = new CopixPPO(); $mod_grvilles->node_type = $node_type; $mod_grvilles->node_id = $node_id; $mod_grvilles->module_type = 'MOD_GESTIONAUTONOME'; $mod_grvilles->module_id = $node_type . '-' . $node_id; $mod_grvilles->module_nom = Kernel::Code2Name('MOD_GESTIONAUTONOME'); $modules[] = clone $mod_grvilles; } } elseif (($node_type == "ROOT" || $user_type == "USER_ENS" && $node_type == "BU_ECOLE" || $user_type == "USER_ENS" && $node_type == "BU_CLASSE" || $user_type == "USER_VIL" && $node_type == "BU_VILLE") && Kernel::getLevel($node_type, $node_id) >= 60) { $comptes->node_type = $node_type; $comptes->node_id = $node_id; $comptes->module_type = 'MOD_COMPTES'; $comptes->module_id = $node_type . '-' . $node_id; $comptes->module_nom = Kernel::Code2Name('MOD_COMPTES'); $modules[] = clone $comptes; } if ($user_type == "USER_ENS" && ($node_type == "BU_ECOLE" && Kernel::getLevel($node_type, $node_id) >= 60 || $node_type == "BU_CLASSE") && CopixConfig::exists('default|conf_Ceriseprim_actif') && CopixConfig::get('default|conf_Ceriseprim_actif')) { $perso->node_type = $node_type; $perso->node_id = $node_id; $perso->module_type = 'MOD_CERISEPRIM'; $perso->module_id = $node_type . "-" . $node_id; $perso->module_nom = Kernel::Code2Name('MOD_CERISEPRIM'); $modules[] = clone $perso; } // _dump($modules); if ($notification) { Kernel::getModlistNotifications($modules); } reset($modules); return $modules; }
/** * Soumission du formulaire d'administration des modules * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/16 * @see getHomeAdminModules() * @param integer $id Id du groupe * @param array $his_modules Les modules � ajouter. Le tableau contient dont les clefs correspondent aux codes des modules */ public function doFormAdminModules() { $dao = CopixDAOFactory::create("groupe"); $kernel_service =& CopixClassesFactory::Create('kernel|kernel'); $groupeService =& CopixClassesFactory::Create('groupe|groupeService'); $id = $this->getRequest('id', null); $his_modules = $this->getRequest('his_modules', array()); $errors = array(); $groupe = $dao->getGroupe($id); if (!$groupe) { $errors[] = CopixI18N::get('groupe|groupe.error.noGroup'); } $mondroit = $kernel_service->getLevel("CLUB", $id); if (!$groupeService->canMakeInGroupe('ADMIN', $mondroit)) { $errors[] = CopixI18N::get('kernel|kernel.error.noRights'); } if ($errors) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('groupe||'))); } else { // Tous les modules dispos $modules = $kernel_service->getModAvailable("club"); //print_r($modules); // On cherche ses modules $mod_enabled = $kernel_service->getModEnabled("club", $id); // On ajoute les modules //print_r($his_modules); // On parcourt l'ensemble des modules ayant pu �tre coch�s/d�coch�s foreach ($modules as $tmp) { $moduleType = $tmp->module_type; list(, $module) = explode("_", strtolower($moduleType)); // On v�rifie quand m�me qu'un module de ce type n'existe pas d�j� reset($mod_enabled); $deja = false; while (!$deja && (list(, $mod) = each($mod_enabled))) { $deja = $mod->module_type == $moduleType ? $mod->module_id : false; } // print_r("<br/>moduleType=$moduleType / deja=$deja / "); if ($deja && (!isset($his_modules[$moduleType]) || !$his_modules[$moduleType])) { // Cocher -> d�cocher, on supprime le module //print_r("Del"); $classeDel = CopixClassesFactory::create("{$module}|Kernel{$module}"); $del = $classeDel->delete($deja); if ($del) { // Suppression effectu�e, on d�tache le module du groupe $unregister = $kernel_service->unregisterModule($moduleType, $deja, "CLUB", $id); } } elseif (!$deja && isset($his_modules[$moduleType])) { // D�cocher -> cocher, on instancie le module // print_r("Add"); $classeNew = CopixClassesFactory::create("{$module}|Kernel{$module}"); $new = $classeNew->create(array('title' => $groupe[0]->titre, 'node_type' => 'CLUB', 'node_id' => $id)); // print_r("new=$new"); if ($new) { // Module bien cr�e, on le rattache $register = $kernel_service->registerModule($moduleType, $new, "CLUB", $id); // print_r("new=$new / register=$register"); } } else { // Pas de changement //print_r("Rien"); } } $back = CopixUrl::get('groupe||getHomeAdminModules', array("id" => $id, "done" => 1)); return new CopixActionReturn(COPIX_AR_REDIRECT, $back); } }