/**
  * Launch an actiongroup method
  * @param string $path identifier 'module|AG::method'
  * @param array $vars parameters
  */
 function &process($path, $vars = array())
 {
     static $instance = array();
     $toReturn = null;
     $extractedPath = CopixActionGroup::extractPath($path);
     if ($extractedPath === null) {
         trigger_error(CopixI18N::get('copix:copix.error.load.actiongroup', $path), E_USER_ERROR);
         return $toReturn;
     }
     $actionGroupID = $extractedPath->module . '|' . $extractedPath->actiongroup;
     if (!isset($instance[$actionGroupID])) {
         if ($extractedPath->module === null) {
             $execPath = COPIX_PROJECT_PATH;
         } else {
             $execPath = COPIX_MODULE_PATH . $extractedPath->module . '/';
         }
         $fileName = $execPath . COPIX_ACTIONGROUP_DIR . strtolower(strtolower($extractedPath->actiongroup)) . '.actiongroup.php';
         if (is_readable($fileName)) {
             require_once $fileName;
         } else {
             trigger_error(CopixI18N::get('copix:copix.error.load.actiongroup', $path . '-' . $fileName), E_USER_ERROR);
             return $toReturn;
         }
         //Nom des objets/méthodes à utiliser.
         $objName = 'ActionGroup' . $extractedPath->actiongroup;
         //instance de l'objet, qui s'enregistre dans GLOBALS['COPIX']['ACTIONGROUP']
         $instance[$actionGroupID] =& new $objName();
     }
     $methName = $extractedPath->method;
     CopixContext::push($extractedPath->module);
     $instance[$actionGroupID]->vars =& $vars;
     $toReturn = $instance[$actionGroupID]->{$methName}();
     CopixContext::pop();
     return $toReturn;
 }
 /**
  * Accueil des stats
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/03/19
  */
 public function home()
 {
     if (!Admin::canAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|admin.menu.stats'));
     $tpl->assign('MENU', Admin::getMenu('stats'));
     $tplStats = new CopixTpl();
     $modules = Kernel::getAllModules();
     $tab = array();
     foreach ($modules as $mod_val) {
         $arModulesPath = CopixConfig::instance()->arModulesPath;
         foreach ($arModulesPath as $modulePath) {
             $class_file = $modulePath . $mod_val . '/' . COPIX_CLASSES_DIR . 'kernel' . $mod_val . '.class.php';
             if (!file_exists($class_file)) {
                 continue;
             }
             $module_class =& CopixClassesFactory::Create($mod_val . '|Kernel' . $mod_val);
             //print_r($module_class);
             if (!is_callable(array($module_class, 'getStatsRoot'))) {
                 continue;
             }
             //$classeModule = CopixClassesFactory::create("$label|Kernel$label");
             $tab[$mod_val]['module_nom'] = Kernel::Code2Name('mod_' . $mod_val);
             $tab[$mod_val]['stats'] = $module_class->getStatsRoot();
         }
     }
     //print_r($tab);
     $tplStats->assign('tab', $tab);
     $tpl->assign('MAIN', $tplStats->fetch('sysutils|stats.modules.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * go
  *
  * Appel automatique, avec détection du noeud à afficher.
  * @author	Frédéric Mossmann
  * @since	10.03.2009
  *
  */
 public function go()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login')));
     }
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_concerto.js');
     if (!_request("id") || !ereg('^[0-9]+$', _request("id"))) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('kernel||getNodes'));
     }
     $sql = 'SELECT login,password FROM kernel_bu_auth WHERE node_type=\'responsable\' AND node_id=' . _currentUser()->getExtra('id') . ' AND id=\'' . addslashes(_request("id")) . '\' AND service=\'concerto\'';
     $concerto = _doQuery($sql);
     if (!$concerto) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('kernel||getNodes'));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('concerto|concerto.title'));
     // $tpl->assign ('MENU', '<a href="'.CopixUrl::get ('groupe||getListPublic').'">'.CopixI18N::get ('groupe|groupe.annuaire').'</a> :: <a href="'.CopixUrl::get ('groupe||getListMy').'">'.CopixI18N::get ('groupe|groupe.my').'</a>');
     $tplListe = new CopixTpl();
     $tplListe->assign('login', $concerto[0]->login);
     $tplListe->assign('password', $concerto[0]->password);
     $result = $tplListe->fetch("concerto-form.tpl");
     $tpl->assign("MAIN", $result);
     $tpl->assign('BODY_ON_LOAD', 'concerto_redirect();');
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function processDefault()
 {
     _classInclude('sysutils|admin');
     if (!Admin::canAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     echo "Récupération des classeurs de classe sans casier\n";
     echo "----------------------------------------------------------------------\n\n";
     // Récupération des classeurs de classe sans casier
     $sql = 'SELECT DISTINCT module_classeur.id' . ' FROM kernel_mod_enabled, module_classeur' . ' LEFT JOIN module_classeur_dossier ON (module_classeur_dossier.module_classeur_id = module_classeur.id)' . ' WHERE module_classeur.id = kernel_mod_enabled.module_id' . ' AND kernel_mod_enabled.module_type = "MOD_CLASSEUR"' . ' AND kernel_mod_enabled.node_type = "BU_CLASSE"' . ' AND (module_classeur_dossier.id IS NULL' . ' OR module_classeur_dossier.id NOT IN (SELECT id FROM module_classeur_dossier WHERE casier = 1 AND module_classeur_id = module_classeur.id))';
     $results = _doQuery($sql);
     $dossierDAO = _ioDAO('classeur|classeurdossier');
     _classInclude('classeur|classeurService');
     echo count($results) . " casiers à créer.\n";
     foreach ($results as $result) {
         $casier = _record('classeur|classeurdossier');
         $casier->classeur_id = $result->id;
         $casier->parent_id = 0;
         $casier->nom = CopixI18N::get('classeur|classeur.casierNom');
         $casier->nb_dossiers = 0;
         $casier->nb_fichiers = 0;
         $casier->taille = 0;
         $casier->cle = classeurService::createKey();
         $casier->casier = 1;
         $casier->date_creation = date('Y-m-d H:i:s');
         $dossierDAO->insert($casier);
         echo "Casier du classeur {$result->id} créé avec succès !\n";
     }
     echo "\n\nFin de la tâche";
     return _arNone();
 }
 /**
  * Configuration de MagicMail
  *
  * @author Frederic Mossmann <*****@*****.**>
  * @since 2006/08/09
  */
 public function getMagicMail()
 {
     $id = _request("id");
     if (Kernel::getLevel("MOD_MAGICMAIL", $id) < PROFILE_CCV_ADMIN) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('||')));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('magicmail.message.title'));
     $dao = CopixDAOFactory::create("magicmail|magicmail");
     $magic_result = $dao->get($id);
     $tplForm = new CopixTpl();
     $tplForm->assign('id', $id);
     $tplForm->assign('infos', $magic_result);
     // $tplForm->assign ('magicmail_mail', CopixConfig::get ('magicmail|magicmail_mail'));
     if (_request("return")) {
         $tplForm->assign('return', _request("return"));
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_prefs.css"));
     $tplForm->assign('msg', array('type' => 'ok', 'image_url' => _resource('img/prefs/smiley_black.png'), 'image_alt' => 'Ok !', 'value' => CopixI18N::get('prefs|prefs.msg.prefsrecorded')));
     $result = $tplForm->fetch("login_form.tpl");
     $tpl->assign("MAIN", $result);
     $menu = array();
     $tpl->assign('MENU', $menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Validation des éléments en base de données
  */
 public function doValid()
 {
     try {
         $record = _record('copixtestautodao');
     } catch (Exception $e) {
         return CopixActionGroup::process();
     }
 }
 /**
  * Efface le cache de Copix (dossiers et BDD)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/12/05
  */
 public function clear()
 {
     if (!Admin::canAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     CacheServices::clearCache();
     CacheServices::clearConfDB();
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('sysutils||'));
 }
 public function error($iMsg, $i18n = true, $iBack = null)
 {
     //build msg
     $msg = $i18n ? $this->i18n($iMsg) : $iMsg;
     //build url
     $back = empty($iBack) ? $this->module . '|' . $this->actiongroup . '|' : $iBack;
     $back = $this->url($back);
     return CopixActionGroup::process('genericTools|Messages::getError', array('message' => $msg, 'back' => $back));
 }
 /**
  * Fonction qui est appellée pour afficher l'aide
  */
 public function processDefault()
 {
     if (_request('id_sh', null) === null) {
         return CopixActionGroup::process('generictools|Messages::getError', array('message' => _i18n('simplehelp.error.missingParameters'), 'back' => _url('simplehelp|admin|listAide')));
     }
     $aide = _ioDAO('simplehelp')->get(_request('id_sh', null));
     $ppo = new CopixPPO(array('TITLE_PAGE' => $aide->title_sh));
     $ppo->MAIN = CopixZone::process('ShowAide', array('id_sh' => CopixRequest::get('id_sh', null)));
     return _arDirectPPO($ppo, 'popup.tpl');
 }
 /**
  * Installe le jeu d'essai
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/10/26
  */
 public function processInstall()
 {
     global $params;
     $db = new Demo_DB();
     $tools = new Demo_Tools();
     $db->extract_db_infos();
     $db->db_connect();
     $fileSQL = '../instal/demo/jeu_essai.sql';
     $errors = array();
     if (CopixConfig::get('kernel|jeuEssaiInstalled') == 1) {
         $errors[] = CopixI18N::get('sysutils|demo.error.alreadyInstalled');
     } elseif (!is_file($fileSQL)) {
         $errors[] = CopixI18N::get('sysutils|demo.error.noFileSql');
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get()));
     }
     $contents = file_get_contents($fileSQL);
     $lines = explode(";\n", $contents);
     $path = CopixUrl::getRequestedScriptPath();
     foreach ($lines as $line) {
         $line = trim($line);
         if ($line) {
             $line = str_replace('<PATH>', $path, $line);
             // print_r("<br>***line=".$line);
             $db->run_query($line);
         }
     }
     $db->db_close();
     // Copie des dossiers (pas de slashs à la fin!)
     $tools->installFolder('www/static/malle/2_9a4ba0cdef');
     $tools->installFolder('var/data/blog/logos');
     $tools->installFolder('www/static/album/2_be8550b87c');
     $tools->installFolder('www/static/album/3_cf057489c9');
     $tools->installFolder('www/static/album/4_c996b6cf13');
     $tools->installFolder('www/static/prefs/avatar');
     // Fin
     CopixConfig::set('kernel|jeuEssaiInstalled', 1);
     // Vidage de cache
     CacheServices::clearCache();
     CacheServices::clearConfDB();
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|demo.titlePage'));
     $tplDemo = new CopixTpl();
     //$tplDemo->assign ("toto", 1);
     $tplDemo->assign('demo_txt_installed', CopixI18N::get('sysutils|demo.txt.installed'));
     $tplDemo->assign('demo_txt_accounts', CopixI18N::get('sysutils|demo.txt.accounts'));
     $tpl->assign("MAIN", $tplDemo->fetch("demo_install.tpl"));
     $tpl->assign('MENU', Admin::getMenu('demo'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Supprime un webservice
  *
  * @return CopixActionReturn
  */
 public function processDeleteWsService()
 {
     CopixRequest::assert('id_wsservice');
     $id_wsservice = _request('id_wsservice');
     $wsservice = _ioDao('wsservices')->get($id_wsservice);
     // si on n'a pas encore confirmé
     if (_request('confirm') === null) {
         return CopixActionGroup::process('generictools|Messages::getConfirm', array('message' => sprintf('Etes vous sûr de vouloir supprimer le webservice "%s" ?', $wsservice->name_wsservices), 'confirm' => _url('admin|deleteWsService', array('id_wsservice' => $id_wsservice, 'confirm' => 1)), 'cancel' => _url('admin|listWebServices')));
         // si on a confirmé la suppression
     } else {
         _ioDao('wsservices')->delete($id_wsservice);
         return _arRedirect(_url('admin|listWebServices'));
     }
 }
 public function home()
 {
     if (!Kernel::isAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $tplHome = new CopixTpl();
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|admin.moduleDescription'));
     $tpl->assign('MENU', Admin::getMenu('sysutils'));
     $tplHome->assign('superadmin', Kernel::isSuperAdmin());
     $tplHome->assign('adminfonctionnel', Kernel::isAdminFonctionnel());
     $tpl->assign('MAIN', $tplHome->fetch('sysutils|home.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Envoie du mail
  */
 public function processSend()
 {
     $ppo->mail = CopixSession::get('admin|email|donnees');
     $ppo->mail['send'] = true;
     $ppo->mail['dest'] = _request("maildest");
     $ppo->mail['cc'] = _request("mailcc");
     $ppo->mail['cci'] = _request("mailcci");
     $ppo->mail['from'] = _request("mailfrom");
     $ppo->mail['fromname'] = _request("mailfromname");
     $ppo->mail['subject'] = _request("mailtitle");
     $ppo->mail['msg'] = _request("mailmsg");
     CopixSession::set('admin|email|donnees', $ppo->mail);
     $arrErrors = _class("emailservices")->sendMail($ppo->mail);
     return CopixActionGroup::process('admin|Email::create', array('error' => $arrErrors, 'sending' => 'true'));
 }
 /**
  * Supression d'un groupe d'utilisateur
  */
 public function processDelete()
 {
     if (CopixRequest::getInt('confirm') == 1) {
         $sp = _daoSp();
         $sp->addCondition('id_dbgroup', '=', CopixRequest::getInt('id'));
         _ioDAO('dbgroup_users')->deleteBy($sp);
         _ioDAO('dbgroup')->delete(CopixRequest::getInt('id'));
         return _arRedirect(_url('auth|groups|'));
     } else {
         if (!($group = _ioDAO('dbgroup')->get(CopixRequest::getInt('id')))) {
             throw new Exception('Groupe introuvable');
         }
         return CopixActionGroup::process('generictools|Messages::getConfirm', array('message' => _i18n('auth.confirmDeleteGroup', $group->caption_dbgroup), 'confirm' => _url('auth|groups|delete', array('id' => $group->id_dbgroup, 'confirm' => 1)), 'cancel' => _url('auth|groups|')));
     }
 }
 /**
  * Supression d'un utilisateur
  */
 public function processDelete()
 {
     if (CopixRequest::getInt('confirm') == 1) {
         $sp = _daoSp();
         $sp->addCondition('user_dbgroup', '=', 'auth|dbuserhandler:' . CopixRequest::getInt('id'));
         _ioDAO('dbgroup_users')->deleteBy($sp);
         _ioDAO('dbuser')->delete(CopixRequest::getInt('id'));
         return _arRedirect(_url('auth|users|'));
     } else {
         if (!($user = _ioDAO('dbuser')->get(CopixRequest::getInt('id')))) {
             throw new Exception('Utilisateur introuvable');
         }
         return CopixActionGroup::process('generictools|Messages::getConfirm', array('message' => _i18n('auth.confirmDeleteUser', $user->login_dbuser), 'confirm' => _url('auth|users|delete', array('id' => $user->id_dbuser, 'confirm' => 1)), 'cancel' => _url('auth|users|')));
     }
 }
 /**
  * Try to log in
  * @param string $this->vars['login'] the login
  * @param string $this->vars['password'] the password
  * @return Object CopixActionReturn
  */
 function doLogin()
 {
     $plugAuth =& $GLOBALS['COPIX']['COORD']->getPlugin('auth|auth');
     $user =& $plugAuth->getUser();
     $user->login($this->vars['login'], $this->vars['password']);
     if (intval(CopixConfig::get('auth|enableAfterLoginOverride')) == 1 && isset($this->vars['auth_url_return']) && !empty($this->vars['auth_url_return'])) {
         $url_return = $this->vars['auth_url_return'];
     } else {
         $url_return = CopixConfig::get('auth|afterLogin');
     }
     //check if the url return is correct.
     if (strpos($url_return, 'http://') === false) {
         $url_return = CopixUrl::get() . $url_return;
     }
     if (!$user->isConnected()) {
         sleep(intval(CopixConfig::get('auth|intervalBetweenFailedLogin')));
         return CopixActionGroup::process('auth|Login::getLoginForm', array('login' => $this->vars['login'], 'failed' => 1));
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
 }
 public function processQuiz()
 {
     $pId = CopixRequest::getInt('id', false);
     if (!$pId) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.noQuiz'), 'back' => CopixUrl::get('quiz|admin|')));
     }
     //get the quiz's informations
     $QuizData = _ioDAO('quiz_quiz')->get($pId);
     if ($QuizData == null || count($QuizData) == 0) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('quiz.errors.noQuiz'), 'back' => CopixUrl::get('quiz||')));
     }
     $author = Kernel::getUserInfo('ID', $QuizData->id_author, array('link_data' => true));
     $ppo = new CopixPPO();
     $ppo->quiz = $QuizData;
     $ppo->author = $author;
     $ppo->MENU[] = array('txt' => $this->i18n('quiz.admin.listActive'), 'type' => 'list-active', 'url' => $this->url('quiz|default|default', array('qaction' => 'list')));
     $ppo->MENU[] = array('txt' => $this->i18n('quiz.admin.listAll'), 'type' => 'list', 'url' => $this->url('quiz|admin|list'));
     $ppo->MENU[] = array('txt' => $this->i18n('quiz.admin.new'), 'type' => 'create', 'url' => $this->url('quiz|admin|modif', array('qaction' => 'new')));
     return _arPPO($ppo, 'admin.quiz.tpl');
 }
 /**
  * Affiche la matrice des droits de visibilité entre utilisateurs
  *
  * @author Frédéric Mossmann <*****@*****.**>
  * @since 2006/12/07
  */
 public function view()
 {
     CopixHTMLHeader::addCSSLink(_resource("styles/module_sysutils.css"));
     if (!Admin::canAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $user_types = array('USER_VIL', 'USER_ENS', 'USER_ADM', 'USER_RES', 'USER_ELE', 'USER_EXT');
     $visibility_matrice = array();
     foreach ($user_types as $src) {
         foreach ($user_types as $dst) {
             $visibility_matrice[$src][$dst] = Kernel::getUserTypeVisibility($dst, $src);
         }
     }
     $tplUserVisibility = new CopixTpl();
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sysutils|admin.moduleDescription'));
     $tplUserVisibility->assign('visibility', $visibility_matrice);
     $tplUserVisibility->assign('user_types', $user_types);
     $tpl->assign('MAIN', $tplUserVisibility->fetch('sysutils|uservisibility.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
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;
}
 public function processGo()
 {
     $ppo = new CopixPPO();
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nologin'), 'back' => CopixUrl::get('auth|default|login')));
     }
     $user = _currentUser();
     $ppo->ceriseprim_url = '';
     $ppo->ceriseprim_admin = '';
     if (preg_match("/^(?P<node_type>[\\w_]+)-(?P<node_id>\\d+)\$/", _request("id"), $regs)) {
         if ($regs['node_type'] == "BU_ECOLE" || $regs['node_type'] == "BU_CLASSE") {
             if ($regs['node_type'] == "BU_ECOLE") {
                 $sql = "\n                        SELECT *\n                        FROM kernel_bu_ecole\n                        WHERE numero=:id\n                    ";
                 $params = array(':id' => $regs['node_id']);
             }
             if ($regs['node_type'] == "BU_CLASSE") {
                 $sql = "\n                        SELECT kernel_bu_ecole.RNE\n                        FROM kernel_bu_ecole\n                        JOIN kernel_bu_ecole_classe ON kernel_bu_ecole.numero=kernel_bu_ecole_classe.ecole\n                        WHERE kernel_bu_ecole_classe.id=:id\n                    ";
                 $params = array(':id' => $regs['node_id']);
             }
             $ecoles_list = _doQuery($sql, $params);
             if (count($ecoles_list)) {
                 $url = CopixConfig::get('default|conf_Ceriseprim_url') . "/" . $ecoles_list[0]->RNE . "/ico.php?user=personnel-" . $user->getExtra('id') . "&date=" . date('Y-m-d') . "&key=" . md5($ecoles_list[0]->RNE . "personnel-" . $user->getExtra('id') . date('Y-m-d') . CopixConfig::get('default|conf_Ceriseprim_secret'));
                 $ppo->ceriseprim_url = $url;
                 if ($regs['node_type'] == "BU_ECOLE") {
                     $mynodes = Kernel::getMyNodes();
                     foreach ($mynodes as $node) {
                         if ($node->type == $regs['node_type'] && $node->id == $regs['node_id'] && $node->droit >= 70) {
                             $ppo->ceriseprim_admin = CopixConfig::get('default|conf_Ceriseprim_url') . "/support/iconito/updateIconito.php?rne=" . $ecoles_list[0]->RNE;
                         }
                     }
                 }
             }
         }
     }
     return _arPPO($ppo, 'default.tpl');
 }
 /**
  * Affichage de la fiche d'une ecole
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/09/03
  * @param integer $id Id de l'ecole
  */
 public function blogs()
 {
     $id = $this->getRequest('id', null);
     $pAnnee = $this->getRequest('annee', null);
     //
     $ecoleDAO = CopixDAOFactory::create('kernel|kernel_bu_ecole');
     $ficheDAO = CopixDAOFactory::create("fiches_ecoles");
     $criticErrors = array();
     if (!($rEcole = $ecoleDAO->get($id))) {
         $criticErrors[] = CopixI18N::get('fichesecoles.error.param');
     } elseif (!FichesEcolesService::canMakeInFicheEcole($id, 'VIEW')) {
         $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('annuaire||')));
     }
     $arClasses = AnnuaireService::getClassesInEcole($rEcole->numero, array('forceCanViewEns' => true, 'onlyWithBlog' => true, 'onlyWithBlogIsPublic' => 1, 'enseignant' => false, 'annee' => $pAnnee));
     $rEcole->blog = getNodeBlog('BU_ECOLE', $rEcole->numero, array('is_public' => 1));
     // Get vocabulary catalog to use
     $nodeVocabularyCatalogDAO = _ioDAO('kernel|kernel_i18n_node_vocabularycatalog');
     $vocabularyCatalog = $nodeVocabularyCatalogDAO->getCatalogForNode('BU_ECOLE', $id);
     $tpl = new CopixTpl();
     $tpl->assign('rEcole', $rEcole);
     $tpl->assign('arClasses', $arClasses);
     $tpl->assign('catalog', $vocabularyCatalog->id_vc);
     if ($anneeDebutBlogs = CopixConfig::get('fichesecoles|anneeDebutBlogs')) {
         $anneeFinBlogs = Kernel::getAnneeScolaireCourante()->id_as;
         //Kernel::deb("anneeDebutBlogs=$anneeDebutBlogs / anneeFinBlogs=$anneeFinBlogs");
         if (!$pAnnee) {
             $pAnnee = $anneeFinBlogs;
         }
         if ($anneeFinBlogs > $anneeDebutBlogs) {
             $comboAnnees = CopixZone::process('kernel|combo_annees', array('name' => 'annee', 'selected' => $pAnnee, 'debut' => $anneeDebutBlogs, 'fin' => $anneeFinBlogs, 'extra2' => 'onChange="ficheViewBlogs(' . $id . ',this.options[this.selectedIndex].value);"'));
             $tpl->assign('comboAnnees', $comboAnnees);
         }
     }
     $result = $tpl->fetch('blogs.tpl');
     header('Content-type: text/html; charset=utf-8');
     //echo utf8_encode($result);
     echo $result;
     return new CopixActionReturn(COPIX_AR_NONE, 0);
 }
Exemplo n.º 22
0
 public function noDemo()
 {
     if (Kernel::isDemo()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.nodemo'), 'TITLE_PAGE' => CopixI18N::get('kernel|kernel.error.demomode'), 'back' => CopixUrl::get('||')));
         //     'back'=>'javascript:history.go(-1);' ));
     }
 }
 /**
  * Fonction appelée lorsque l'on clique sur le bouton 'import'
  * Appel la méthode privée _validFromFormImportParams
  * vérifie les infos saisies dans le formulaire
  * stock l'objet en session
  * @author Audrey Vassal <*****@*****.**>
  */
 public function doExport()
 {
     $serviceAuth = new AgendaAuth();
     $serviceExport = new ExportService();
     $agendaService = new AgendaService();
     $dateService = new DateService();
     //demande de mettre l'objet à jour en fonction des valeurs saisies dans le formulaire
     if (!($exportParams = $this->_getSessionExport())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.cannotFindSession'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //on vérifie les droits des utilisateurs sur la liste des agendas sélectionnés
     foreach ((array) $this->getRequest('agenda') as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affiché
         if ($serviceAuth->getCapability($id_agenda) < $serviceAuth->getRead()) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
         }
     }
     $this->_validFromFormExportParams($exportParams);
     $errors = $this->_checkExport($exportParams);
     if (count($errors) > 0) {
         $this->_setSessionExport($exportParams);
         return CopixActionGroup::process('agenda|ImportExport::getPrepareExport', array('e' => 1, 'errors' => $errors));
     } else {
         //var_dump($exportParams);
         //die();
         //on récupère tous les évènements des agendas cochés dans la période demandée
         foreach ((array) _request('agenda') as $idAgenda) {
             $arEventsPeriode[$idAgenda] = $agendaService->checkEventOfAgendaInBdd($idAgenda, CopixDateTime::dateToYYYYMMDD($exportParams->datedeb_export), CopixDateTime::dateToYYYYMMDD($exportParams->datefin_export));
         }
         //on classe ces évènements par jour
         $arEventByDay = $agendaService->getEventsByDay($arEventsPeriode, CopixDateTime::dateToYYYYMMDD($exportParams->datedeb_export), CopixDateTime::dateToYYYYMMDD($exportParams->datefin_export));
         //on ordonne les évènements par ordre croissant d'heure de début d'évènement dans la journée
         //var_dump($arEventByDay);
         $arEventByDay = $agendaService->getEventsInOrderByDay($arEventByDay);
         $content = $serviceExport->getFileICal($arEventByDay, CopixDateTime::dateToTimestamp($exportParams->datedeb_export), CopixDateTime::dateToTimestamp($exportParams->datefin_export));
     }
     //on vide la session
     $this->_setSessionExport(null);
     return _arContent($content, array('filename' => 'agenda.ics', 'content-disposition' => 'attachement', 'content-type' => CopixMIMETypes::getFromExtension('.ics')));
 }
 /**
  * Téléchargement d'une pièce jointe dans un classeur
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2012/06/21
  * @param integer $id Id du minimail de départ
  */
 public function attachmentToClasseur()
 {
     //_dump($_POST);
     $this->addJs('js/iconito/module_classeur.js');
     $this->addJs('js/iconito/module_minimail.js');
     $this->addCss('styles/module_classeur.css');
     _classInclude('classeur|classeurService');
     _classInclude('kernel|Request');
     $idUser = _currentUser()->getId();
     $idMessage = _request("id");
     $files = _request('files', array());
     $destination = _request('destination');
     $errors = array();
     $daoFrom = _ioDAO("minimail|minimail_from");
     $daoTo = CopixDAOFactory::create("minimail_to");
     $message = $daoFrom->getMessage($idMessage);
     $canMake = $isRecv = $isSend = false;
     if ($message && $message->from_id == $idUser) {
         // Message qu'il a envoyé
         $canMake = $isSend = true;
     } else {
         // Il en est peut-être destinataire
         $canMake = $isRecv = $daoTo->selectDestFromIdAndToUser($idMessage, $idUser);
         // Test s'il est dans les destin
     }
     if (!$canMake) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('minimail.error.cantDisplay'), 'back' => CopixUrl::get('minimail||')));
     }
     $menu = array();
     $menu[] = array('txt' => CopixI18N::get('minimail.mess_recv'), 'url' => CopixUrl::get('minimail||getListRecv'), 'current' => $isRecv);
     $menu[] = array('txt' => CopixI18N::get('minimail.mess_send'), 'url' => CopixUrl::get('minimail||getListSend'), 'current' => $isSend);
     $menu[] = array('txt' => CopixI18N::get('minimail.mess_write'), 'url' => CopixUrl::get('minimail||getNewForm'));
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = $message;
     $ppo->MENU = $menu;
     $ppo->message = $message;
     //_dump(Request::isXmlHttpRequest());
     if (Request::isPostMethod()) {
         $error = $success = array();
         if (!$files) {
             $error[] = CopixI18N::get('minimail.attachmentToClasseur.error.noFiles');
         }
         if ($destination) {
             list($ppo->destinationType, $ppo->destinationId) = explode('-', $destination);
             if ('classeur' == $ppo->destinationType) {
                 $rClasseur = _ioDAO('classeur|classeur')->get($ppo->destinationId);
             }
             if ('dossier' == $ppo->destinationType) {
                 if ($rDossier = _ioDAO('classeur|classeurdossier')->get($ppo->destinationId)) {
                     $rClasseur = _ioDAO('classeur|classeur')->get($rDossier->classeur_id);
                 }
             }
         }
         if (!$destination || !$rClasseur) {
             $error[] = CopixI18N::get('classeur|classeur.error.noDestination');
         }
         if ($error) {
             $ppo->error = $error;
             return _arPPO($ppo, array('template' => 'attachmentToClasseur.tpl', 'mainTemplate' => 'main|main_popup.php'));
         }
         //_dump($destination);
         //_dump($rClasseur);
         $dir = realpath('./static/classeur') . '/' . $rClasseur->id . '-' . $rClasseur->cle . '/';
         if (!file_exists($dir)) {
             mkdir($dir, 0755, true);
         }
         foreach ($files as $file) {
             $fichierPhysique = realpath("../var/data") . "/minimail/" . $file;
             $nomFichierPhysique = $file;
             $fichier = _record('classeur|classeurfichier');
             $fichier->classeur_id = $rClasseur->id;
             $fichier->dossier_id = isset($rDossier) && $rDossier ? $rDossier->id : 0;
             $fichier->titre = MinimailService::getAttachmentName($file);
             $fichier->fichier = $nomFichierPhysique;
             $fichier->taille = filesize($fichierPhysique);
             $fichier->type = strtoupper(substr(strrchr($nomFichierPhysique, '.'), 1));
             $fichier->cle = classeurService::createKey();
             $fichier->date_upload = date('Y-m-d H:i:s');
             $fichier->user_type = _currentUser()->getExtra('type');
             $fichier->user_id = _currentUser()->getExtra('id');
             _ioDAO('classeur|classeurfichier')->insert($fichier);
             if ($fichier->id > 0) {
                 $nomClasseur = $rClasseur->id . '-' . $rClasseur->cle;
                 $nomFichier = $fichier->id . '-' . $fichier->cle;
                 $extension = strtolower(strrchr($nomFichierPhysique, '.'));
                 if (copy($fichierPhysique, $dir . $fichier->id . '-' . $fichier->cle . $extension)) {
                     $success[] = MinimailService::getAttachmentName($file);
                 } else {
                     $error[] = CopixI18N::get('minimail.attachmentToClasseur.error.moved', array(MinimailService::getAttachmentName($file)));
                 }
             } else {
                 $error[] = CopixI18N::get('minimail.attachmentToClasseur.error.creation', array(MinimailService::getAttachmentName($file)));
             }
         }
         if (count($success) > 0) {
             $dest = $rClasseur;
             if (isset($rDossier) && $rDossier) {
                 $dest .= ' / ' . $rDossier;
             }
             if (1 == count($success)) {
                 Kernel::setFlashMessage('success', CopixI18N::get('minimail.attachmentToClasseur.moved_1', array(implode(', ', $success), $dest)));
             } else {
                 Kernel::setFlashMessage('success', CopixI18N::get('minimail.attachmentToClasseur.moved_N', array(implode(', ', $success), $dest)));
             }
         }
         if ($error) {
             Kernel::setFlashMessage('error', implode('<br />', $error));
         }
         $ppo->ok = 1;
         //echo 'OK';
         //return _arNone();
         //return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('minimail||getMessage', array('id' => $idMessage)));
     }
     return _arPPO($ppo, array('template' => 'attachmentToClasseur.tpl', 'mainTemplate' => 'main|main_popup.php'));
 }
 public function processEndQuestions()
 {
     $pId = CopixRequest::getInt('id', false);
     if (!$pId || is_null(qSession('id')) || $pId != qSession('id')) {
         return CopixActionGroup::process('quiz|default::Quiz', array('id' => $pId));
     }
     $ppo = new CopixPPO();
     CopixHTMLHeader::addCSSLink(_resource("styles/module_quiz.css"));
     return _arPPO($ppo, 'end_questions.tpl');
 }
 public function processDefault()
 {
     _classInclude('classeur|classeurService');
     $classeurDAO = _ioDAO('classeur|classeur');
     $dossierDAO = _ioDAO('classeur|classeurdossier');
     $ppo->conf_ModClasseur_upload = CopixConfig::exists('default|conf_ModClasseur_upload') ? CopixConfig::get('default|conf_ModClasseur_upload') : 0;
     if (is_null($ppo->classeur = $classeurDAO->get(_request('classeurId', null)))) {
         return CopixActionGroup::process('generictools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.errorOccurred'), 'back' => CopixUrl::get('', array('error' => 'classeur_not_found'))));
     }
     if (!realpath('./upload')) {
         return CopixActionGroup::process('generictools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.errorOccurred'), 'back' => CopixUrl::get('', array('error' => 'upload_folder_not_found'))));
     }
     if ($ppo->save->mode = _request('save-mode', null)) {
         switch ($ppo->save->mode) {
             case 'upload':
                 $ppo->save->ok = true;
                 $ppo->save->error = '';
                 $ppo->save->folder_input = _request('destination', 0);
                 if (!preg_match('/dossier-(?P<folder>\\d+)/', $ppo->save->folder_input, $matches)) {
                     $ppo->save->ok = false;
                     $ppo->save->error = '-ERR destination';
                     break;
                 }
                 $ppo->save->folder_id = $matches['folder'];
                 if ($ppo->classeur->upload_fs) {
                     $dir = realpath('.') . '/upload/' . $ppo->classeur->upload_fs . '/';
                     if (is_dir($dir)) {
                         $this->rrmdir($dir);
                     }
                 }
                 $ppo->classeur->upload_db = $ppo->save->folder_id;
                 $ppo->classeur->upload_fs = 'classeur-' . $ppo->classeur->id;
                 if (!$ppo->classeur->upload_pw) {
                     $ppo->classeur->upload_pw = substr(md5($ppo->classeur->id . $ppo->save->folder_id . $ppo->classeur->cle . date('YmdHis')), 0, 8);
                 }
                 $classeurDAO->update($ppo->classeur);
                 // Création du répertoire
                 $dir = realpath('.') . '/upload/' . $ppo->classeur->upload_fs . '/';
                 if (!file_exists($dir)) {
                     mkdir($dir, 0755, true);
                     $htaccess = fopen($dir . '.htaccess', 'w');
                     fwrite($htaccess, "<Limit GET HEAD OPTIONS POST>\n\trequire user " . $ppo->classeur->upload_fs . "\n</Limit>\n<Files .htaccess>\n\torder allow,deny\n\tdeny from all\n</Files>\n");
                     fclose($htaccess);
                 }
                 // Génération du fichier .htpasswd
                 $htpasswd_file = realpath('.') . '/upload/.htpasswd';
                 $htpasswd_output = '';
                 $in = fopen($htpasswd_file, 'r');
                 $htpasswd_updated = false;
                 if ($in) {
                     while (preg_match("/:/", $line = fgets($in))) {
                         $line = rtrim($line);
                         $a = explode(':', $line);
                         if ($a[0] != 'classeur-' . $ppo->classeur->id) {
                             $htpasswd_output .= $line . "\n";
                         }
                     }
                 }
                 $htpasswd_salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 2);
                 $htpasswd_output .= $ppo->classeur->upload_fs . ":" . crypt($ppo->classeur->upload_pw, $htpasswd_salt) . "\n";
                 fclose($in);
                 $out = fopen($htpasswd_file, 'w');
                 fwrite($out, $htpasswd_output);
                 fclose($out);
                 // Génération du fichier .htdigest
                 $htpasswd_file = realpath('.') . '/upload/.htdigest';
                 $htpasswd_output = '';
                 $in = fopen($htpasswd_file, 'r');
                 $htpasswd_updated = false;
                 if ($in) {
                     while (preg_match("/:/", $line = fgets($in))) {
                         $line = rtrim($line);
                         $a = explode(':', $line);
                         if ($a[0] != 'classeur-' . $ppo->classeur->id) {
                             $htpasswd_output .= $line . "\n";
                         }
                     }
                 }
                 $htpasswd_output .= $ppo->classeur->upload_fs . ":Classeur:" . md5($ppo->classeur->upload_fs . ":Classeur:" . $ppo->classeur->upload_pw) . "\n";
                 fclose($in);
                 $out = fopen($htpasswd_file, 'w');
                 fwrite($out, $htpasswd_output);
                 fclose($out);
                 break;
             case 'upload-delete':
                 $dir = realpath('.') . '/upload/' . $ppo->classeur->upload_fs . '/';
                 if (strlen($ppo->classeur->upload_fs) > 3 && is_dir($dir)) {
                     $this->rrmdir($dir);
                 }
                 $ppo->classeur->upload_db = null;
                 $ppo->classeur->upload_fs = null;
                 $ppo->classeur->upload_pw = null;
                 $classeurDAO->update($ppo->classeur);
                 // Suppression de l'utilisateur dans le .htpasswd
                 $htpasswd_file = realpath('.') . '/upload/.htpasswd';
                 $htpasswd_output = '';
                 $in = fopen($htpasswd_file, 'r');
                 $htpasswd_updated = false;
                 if ($in) {
                     while (preg_match("/:/", $line = fgets($in))) {
                         $line = rtrim($line);
                         $a = explode(':', $line);
                         if ($a[0] != 'classeur-' . $ppo->classeur->id) {
                             $htpasswd_output .= $line . "\n";
                         }
                     }
                 }
                 fclose($in);
                 $out = fopen($htpasswd_file, 'w');
                 fwrite($out, $htpasswd_output);
                 fclose($out);
                 // Suppression de l'utilisateur dans le .htdigest
                 $htpasswd_file = realpath('.') . '/upload/.htdigest';
                 $htpasswd_output = '';
                 $in = fopen($htpasswd_file, 'r');
                 $htpasswd_updated = false;
                 if ($in) {
                     while (preg_match("/:/", $line = fgets($in))) {
                         $line = rtrim($line);
                         $a = explode(':', $line);
                         if ($a[0] != 'classeur-' . $ppo->classeur->id) {
                             $htpasswd_output .= $line . "\n";
                         }
                     }
                 }
                 fclose($in);
                 $out = fopen($htpasswd_file, 'w');
                 fwrite($out, $htpasswd_output);
                 fclose($out);
                 break;
             default:
                 break;
         }
         $ppo->classeur = $classeurDAO->get($ppo->classeur->id);
         $classeurs2htaccess_list = $classeurDAO->findBy(_daoSp()->addCondition('upload_fs', '!=', null));
         $classeurs2htaccess_string = '';
         /*
         $classeurs2htaccess_string .= "<Directory ".realpath('./upload').">\n";
         $classeurs2htaccess_string .= "\t<Limit GET HEAD OPTIONS POST>\n";
         $classeurs2htaccess_string .= "\t\trequire user admin\n";
         $classeurs2htaccess_string .= "\t</Limit>\n";
         $classeurs2htaccess_string .= "</Directory>\n";
         if($classeurs2htaccess_list) foreach( $classeurs2htaccess_list AS $classeurs2htaccess_item ) {
             $classeurs2htaccess_string .= "<Directory ".realpath('./upload/'.$classeurs2htaccess_item->upload_fs).">\n";
             $classeurs2htaccess_string .= "\t<Limit GET HEAD OPTIONS POST>\n";
             $classeurs2htaccess_string .= "\t\trequire user ".$classeurs2htaccess_item->upload_fs."\n";
             $classeurs2htaccess_string .= "\t</Limit>\n";
             $classeurs2htaccess_string .= "</Directory>\n";
         }
         
         $htaccess_file = realpath('.').'/upload/.htaccess';
         $out = fopen( $htaccess_file, 'w' );
         fwrite( $out, $classeurs2htaccess_string );
         fclose( $out );
         */
     }
     $ppo->classeur->upload_url = CopixUrl::get() . "upload/" . $ppo->classeur->upload_fs . "/";
     if ($ppo->classeur->upload_db) {
         $ppo->classeur->folder_infos = $dossierDAO->get($ppo->classeur->upload_db);
     } else {
         $ppo->classeur->folder_infos = NULL;
     }
     $ppo->niveauUtilisateur = Kernel::getLevel('MOD_CLASSEUR', $ppo->classeur->id);
     return _arPPO($ppo, 'options_default.tpl');
 }
 /**
  * Affichage de l'annuaire en version popup
  *
  * Affiche les discussions d'un forum et les informations sur les discussions (titre, dernier message...), avec un lien pour lire chaque discussion.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/18
  */
 public function getPopup()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('annuaire|annuaire.error.noLogged'), 'back' => CopixUrl::get('||')));
     }
     CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire_popup.js"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.tablesorter.min.js"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.metadata.js"));
     CopixHTMLHeader::addCSSLink(_resource("js/jquery/css/jquery.tablesorter.css"));
     $grville = _request('grville') ? _request('grville') : NULL;
     $ville = _request('ville') ? _request('ville') : NULL;
     $ecole = _request('ecole') ? _request('ecole') : NULL;
     $classe = _request('classe') ? _request('classe') : NULL;
     $field = _request('field') ? _request('field') : '';
     $profils = _request('profils') ? _request('profils') : array();
     $profil = $this->getRequest('profil');
     // Si on force sur un profil unique a afficher
     $ALL = CopixConfig::get('annuaire|annu_combo_all');
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     // Annuaire par défaut, on regarde sa session
     if (!$classe && !$ecole && !$ville) {
         $home = $annuaireService->getAnnuaireHome();
         //print_r($home);
         switch ($home['type']) {
             case 'BU_GRVILLE':
                 $grville = $home['id'];
                 $ville = $ALL;
                 $ecole = $ALL;
                 $classe = $ALL;
                 break;
             case 'BU_VILLE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 if ($info) {
                     $grville = $info['ALL']->vil_id_grville;
                 }
                 $ville = $home['id'];
                 $ecole = $ALL;
                 $classe = $ALL;
                 break;
             case 'BU_ECOLE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 if ($info) {
                     $grville = $info['ALL']->vil_id_grville;
                     $ville = $info['ALL']->eco_id_ville;
                 }
                 $ecole = $home['id'];
                 $classe = $ALL;
                 break;
             case 'BU_CLASSE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 //_dump($info);
                 if ($info) {
                     $grville = $info['parent']['ALL']->vil_id_grville;
                     $ville = $info['parent']['ALL']->eco_id_ville;
                     $ecole = $info['parent']['id'];
                 }
                 $classe = $home['id'];
                 //echo "grville=$grville / ville=$ville / ecole=$ecole / classe=$classe";
                 break;
         }
     }
     $comboEcoles = $comboClasses = true;
     // On force les valeurs des combos
     if ($profil) {
         switch ($profil) {
             case 'USER_VIL':
                 $comboEcoles = $comboClasses = false;
                 $ecole = $classe = $ALL;
                 break;
         }
     }
     $matrix =& enic::get('matrixCache');
     $helper =& enic::get('matrixHelpers');
     $right = _request('right', 'voir');
     // voir ou communiquer
     $iCan = 'communiquer' == $right ? 'iCanTalkToThisType' : 'iCanSeeThisType';
     $tplListe = new CopixTpl();
     $visib = array('USER_ELE' => $helper->{$iCan}('USER_ELE'), 'USER_ENS' => $helper->{$iCan}('USER_ENS') || $helper->{$iCan}('USER_DIR'), 'USER_RES' => $helper->{$iCan}('USER_RES'), 'USER_EXT' => $helper->{$iCan}('USER_EXT'), 'USER_ADM' => $helper->{$iCan}('USER_ADM'), 'USER_VIL' => $helper->{$iCan}('USER_VIL'));
     //_dump($visib);
     $debug = false;
     $start = microtime(true);
     $tplListe->assign('combogrvilles', CopixZone::process('annuaire|combogrvilles', array('droit' => $right, 'value' => $grville, 'fieldName' => 'grville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_grville(this,this.form);"', 'linesSup' => array())));
     if ($debug) {
         echo "combogrvilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
     }
     $start = microtime(true);
     $tplListe->assign('combovilles', CopixZone::process('annuaire|combovilles', array('droit' => $right, 'grville' => $grville, 'value' => $ville, 'fieldName' => 'ville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ville(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllVilles'))))));
     if ($debug) {
         echo "combovilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
     }
     $start = microtime(true);
     if ($ville == $ALL && $comboEcoles) {
         $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles'))))));
         if ($debug) {
             echo "comboecolesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($comboEcoles) {
         $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesinville', array('droit' => $right, 'ville' => $ville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles'))))));
         if ($debug) {
             echo "comboecolesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     }
     $start = microtime(true);
     if ($ville == $ALL && $ecole == $ALL && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($ecole == $ALL && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinville', array('droit' => $right, 'ville' => $ville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($ecole && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinecole', array('droit' => $right, 'ecole' => $ecole, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesinecole " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboempty', array('fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"')));
         if ($debug) {
             echo "comboempty " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     }
     if ($ville_as_array = Kernel::getKernelLimits('ville_as_array')) {
         // Limitation par URL, on verifie les parametres
         if ($ville && $ville != $ALL && !in_array($ville, $ville_as_array)) {
             $ville = 0;
         }
         if ($ecole && $ecole != $ALL && ($rEcole = Kernel::getNodeInfo('BU_ECOLE', $ecole, false)) && !in_array($rEcole['ALL']->vil_id_grville, $ville_as_array)) {
             $ecole = 0;
         }
         if ($classe && $classe != $ALL && ($rClasse = Kernel::getNodeInfo('BU_CLASSE', $classe, false)) && !in_array($rClasse['ALL']->eco_id_ville, $ville_as_array)) {
             $classe = 0;
         }
     }
     //kernel::myDebug ("grville=$grville / ville=$ville / ecole=$ecole / classe=$classe");
     //kernel::myDebug ($profils);
     if ($classe && $classe !== $ALL) {
         // Une classe précise
         $visib['USER_ELE'] = $matrix->classe($classe)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->classe($classe)->_right->USER_ENS->{$right} || $matrix->classe($classe)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->classe($classe)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->classe($classe)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->classe($classe)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->classe($classe)->_right->USER_VIL->{$right};
     } elseif ($ecole && $classe == $ALL && $ecole !== $ALL) {
         // Une école
         $visib['USER_ELE'] = $matrix->ecole($ecole)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->ecole($ecole)->_right->USER_ENS->{$right} || $matrix->ecole($ecole)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->ecole($ecole)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->ecole($ecole)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->ecole($ecole)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->ecole($ecole)->_right->USER_VIL->{$right};
     } elseif ($ville && $classe == $ALL && $ecole == $ALL && $ville !== $ALL) {
         // Une ville
         $visib['USER_ELE'] = $matrix->ville($ville)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->ville($ville)->_right->USER_ENS->{$right} || $matrix->ville($ville)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->ville($ville)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->ville($ville)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->ville($ville)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->ville($ville)->_right->USER_VIL->{$right};
     } elseif ($grville && $classe == $ALL && $ecole == $ALL && $ville == $ALL) {
         // Un groupe de villes
         $visib['USER_ELE'] = $matrix->grville($grville)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->grville($grville)->_right->USER_ENS->{$right} || $matrix->grville($grville)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->grville($grville)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->grville($grville)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->grville($grville)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->grville($grville)->_right->USER_VIL->{$right};
     }
     //_dump($visib);
     // Si on restreint a un profil
     if ($profil && $visib[$profil]) {
         switch ($profil) {
             case 'USER_VIL':
                 $profils = array();
                 $profils['VIL'] = 1;
                 break;
         }
     }
     if (!$profils && $visib['USER_ELE']) {
         $profils['ELE'] = 1;
     } elseif (!$profils && $visib['USER_ENS']) {
         $profils['PEC'] = 1;
     } elseif (!$profils && $visib['USER_RES']) {
         $profils['PAR'] = 1;
     } elseif (!$profils && $visib['USER_EXT']) {
         $profils['EXT'] = 1;
     } elseif (!$profils && $visib['USER_ADM']) {
         $profils['ADM'] = 1;
     } elseif (!$profils && $visib['USER_VIL']) {
         $profils['VIL'] = 1;
     }
     //kernel::myDebug($visib);
     // =============== ELEVES =========================
     $eleves = array();
     if (isset($profils['ELE']) && $grville && $ville && $ecole && $classe && $visib['USER_ELE']) {
         if ($classe != $ALL) {
             // Une classe précise
             $eleves = $annuaireService->getEleves('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les eleves d'une école
             $eleves = $annuaireService->getEleves('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les eleves d'une ville
             $eleves = $annuaireService->getEleves('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les eleves d'un groupe de villes
             $eleves = $annuaireService->getEleves('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL =========================
     $personnel = array();
     if (isset($profils['PEC']) && $grville && $ville && $ecole && $classe && $visib['USER_ENS']) {
         if ($classe != $ALL) {
             // Une classe précise
             $personnel = $annuaireService->getPersonnel('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les classes d'une école
             $personnel = $annuaireService->getPersonnel('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $personnel = $annuaireService->getPersonnel('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $personnel = $annuaireService->getPersonnel('BU_GRVILLE', $grville);
         }
     }
     // =============== PARENTS =========================
     $parents = array();
     if (isset($profils['PAR']) && $grville && $ville && $ecole && $classe && $visib['USER_RES']) {
         if ($classe != $ALL) {
             // Une classe précise
             $parents = $annuaireService->getParents('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les classes d'une école
             $parents = $annuaireService->getParents('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $parents = $annuaireService->getParents('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $parents = $annuaireService->getParents('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL ADMINISTRATIF =========================
     $adm = array();
     if (isset($profils['ADM']) && $grville && $ville && $ecole && $classe && $visib['USER_ADM']) {
         if (($classe != $ALL || $classe == $ALL) && $ecole != $ALL) {
             // Les classes d'une école
             $adm = $annuaireService->getPersonnelAdm('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $adm = $annuaireService->getPersonnelAdm('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $adm = $annuaireService->getPersonnelAdm('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL EXTERIEUR =========================
     $ext = array();
     if (isset($profils['EXT']) && $grville && $ville && $ecole && $classe && $visib['USER_EXT']) {
         $ext = $annuaireService->getPersonnelExt('ROOT', 0);
     }
     // =============== PERSONNEL VILLE =========================
     $vil = array();
     if (isset($profils['VIL']) && $grville && $ville && $visib['USER_VIL']) {
         if ($ville != $ALL) {
             // Dans une ville
             $vil = $annuaireService->getPersonnelVil('BU_VILLE', $ville);
         } elseif ($ville == $ALL) {
             // Dans un groupe de villes
             $vil = $annuaireService->getPersonnelVil('BU_GRVILLE', $grville);
         }
     }
     $droits = array('checkAll' => $annuaireService->canMakeInAnnuaire('POPUP_CHECK_ALL'));
     $users = array();
     foreach ($eleves as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($parents as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($personnel as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($adm as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($vil as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($ext as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     //_dump($eleves);
     /*
     if ('communiquer' === $right) {
         foreach ($users as $k => $user) {
             //print_r($user);
             //$matrix->communiquer();
         }
     }
     */
     usort($users, array('ActionGroupAnnuaire', '_usortPopup'));
     $tplListe->assign('field', $field);
     $tplListe->assign('grville', $grville);
     $tplListe->assign('eleves', $eleves);
     $tplListe->assign('personnel', $personnel);
     $tplListe->assign('parents', $parents);
     $tplListe->assign('ext', $ext);
     $tplListe->assign('adm', $adm);
     $tplListe->assign('vil', $vil);
     $tplListe->assign('profils', $profils);
     $tplListe->assign('droits', $droits);
     $tplListe->assign('ville', $ville);
     $tplListe->assign('ecole', $ecole);
     $tplListe->assign('classe', $classe);
     $tplListe->assign('visib', $visib);
     $tplListe->assign('profil', $profil);
     $tplListe->assign('users', $users);
     $tplListe->assign('right', $right);
     $result = $tplListe->fetch('getpopup.tpl');
     $ppo = new CopixPPO();
     $ppo->result = $result;
     $ppo->TITLE_PAGE = CopixI18N::get('annuaire|annuaire.moduleDescription');
     CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire.js"));
     return _arPPO($ppo, array('template' => 'getpopup_ppo.tpl', 'mainTemplate' => 'default|main_popup.php'));
 }
 public function processDefault()
 {
     //return _arRedirect (_url ('|viewHelp'));
     return CopixActionGroup::process('aide|default::viewHelp');
 }
 public function processDefault()
 {
     if (!Kernel::isAdmin()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     }
     $ppo = new CopixPPO();
     $ppo->from = array('USER_VIL', 'USER_DIR', 'USER_ENS', 'USER_RES', 'USER_ELE', 'USER_ATI', 'USER_EXT', 'USER_ADM');
     $ppo->to = array('USER_VIL', 'USER_DIR', 'USER_ENS', 'USER_RES', 'USER_ELE', 'USER_ATI', 'USER_EXT', 'USER_ADM');
     $ppo->where = array('NOWHERE', 'BU_CLASSE', 'BU_ECOLE', 'BU_VILLE', 'BU_GRVILLE', 'ROOT');
     $ppo->do = array('VOIR', 'COMM');
     $ppo->trad = array('USER_VIL' => "Agent ville", 'USER_DIR' => "Directeur", 'USER_ENS' => "Enseignant", 'USER_RES' => "Parent", 'USER_ELE' => "Elève", 'USER_ADM' => "Admin", 'USER_ATI' => "Anim TICE", 'USER_EXT' => "Personne ext", 'NOWHERE' => "Interdit", 'BU_CLASSE' => "Même classe", 'BU_ECOLE' => "Même école", 'BU_VILLE' => "Même ville", 'BU_GRVILLE' => "Même groupe<br/>de ville", 'ROOT' => "Partout", 'VOIR' => "Voir", 'COMM' => "Ecrire");
     if (_request("save", 0) == 1) {
         // echo "<pre>"; print_r($_POST); die();
         // Clear matrix
         _doQuery('DELETE FROM module_rightmatrix');
         /* Mode checkbox
         			foreach( $ppo->from AS $cpt_from ) {
         				foreach( $ppo->to AS $cpt_to ) {
         					foreach( $ppo->do AS $cpt_do ) {
         						// Retournement de la Matrice pour écrire dans le domaine le plus large (uniquement)
         						foreach( array_reverse($ppo->where) AS $cpt_where ) {
         							$droit = _request("right_".$cpt_from."_".$cpt_to."_".$cpt_where."_".$cpt_do);
         							// if($droit) echo "<li>[$cpt_from][$cpt_to][$cpt_where][$cpt_do] = ".($droit?"OUI":"non")."</li>";
         							// if($droit) echo "<li>[$cpt_from][$cpt_to][$cpt_where][$cpt_do] = ".($droit?"OUI":"non")."</li>";
         							if($droit) _doQuery('INSERT INTO module_rightmatrix (user_type_in, user_type_out, node_type, `right`) VALUES (:user_type_in, :user_type_out, :node_type, :right)', array( ':user_type_in'=> $cpt_from, ':user_type_out' => $cpt_to, ':node_type' => $cpt_where, ':right' => $cpt_do ));
         							if($droit) break;
         						}
         					}
         				}
         			}
         			*/
         foreach ($ppo->from as $cpt_from) {
             foreach ($ppo->to as $cpt_to) {
                 foreach ($ppo->do as $cpt_do) {
                     $droit = _request("right_" . $cpt_from . "_" . $cpt_to . "_" . $cpt_do);
                     if ($droit != "NOWHERE") {
                         _doQuery('INSERT INTO module_rightmatrix (user_type_in, user_type_out, node_type, `right`) VALUES (:user_type_in, :user_type_out, :node_type, :right)', array(':user_type_in' => $cpt_from, ':user_type_out' => $cpt_to, ':node_type' => $droit, ':right' => $cpt_do));
                     }
                 }
             }
         }
         // die('save');
     }
     // Initialisation de la matrice
     $ppo->right = array();
     foreach ($ppo->from as $cpt_from) {
         $ppo->right[$cpt_from] = array();
         foreach ($ppo->to as $cpt_to) {
             $ppo->right[$cpt_from][$cpt_to] = array();
             foreach ($ppo->where as $cpt_where) {
                 $ppo->right[$cpt_from][$cpt_to][$cpt_where] = array();
                 foreach ($ppo->do as $cpt_do) {
                     $ppo->right[$cpt_from][$cpt_to][$cpt_where][$cpt_do] = false;
                 }
             }
         }
     }
     // Récupération des information de la matrice en base de données
     $tmp_right = _doQuery('SELECT * FROM module_rightmatrix');
     foreach ($tmp_right as $tmp_right_item) {
         $ppo->right[$tmp_right_item->user_type_in][$tmp_right_item->user_type_out][$tmp_right_item->node_type][$tmp_right_item->right] = true;
     }
     return _arPPO($ppo, 'matrix-display.tpl');
 }
 /**
  * Ajout d'une info supplementaire
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/01/30
  * @param integer $id Id de la procedure
  */
 public function insertInfoSupp()
 {
     $id = $this->getRequest('id', null);
     $info_message = $this->getRequest('info_message', null);
     $info_commentaire = $this->getRequest('info_commentaire', null);
     $visible = $this->getRequest('visible', null);
     $daoIntervention = CopixDAOFactory::create("intervention");
     $daoInfoSupp = CopixDAOFactory::create("infosupp");
     $criticErrors = $errors = array();
     if ($id && ($rFiche = $daoIntervention->get($id))) {
         $title = $rFiche->objet;
         $mondroit = Kernel::getLevel("MOD_TELEPROCEDURES", $rFiche->type_teleprocedure);
         if (!TeleproceduresService::canMakeInTelep('ADD_COMMENT', $mondroit)) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         }
     } else {
         $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.prob.telep');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('teleprocedures||')));
     }
     if ($info_message || $info_commentaire) {
         //$canCheckVisible = TeleproceduresService::canMakeInTelep('CHECK_VISIBLE', $mondroit);
         $rFiche->insertInfoSupp($info_message, $info_commentaire);
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('|fiche', array('id' => $id)));
 }