public function processDefault()
 {
     $tpl = new CopixTpl();
     $tplModule = new CopixTpl();
     //if user is not connected :
     if (1) {
         // S'il y a un blog prevu a l'accueil
         $dispBlog = false;
         $getKernelLimitsIdBlog = Kernel::getKernelLimits('id_blog');
         if ($getKernelLimitsIdBlog) {
             _classInclude('blog|kernelblog');
             if ($blog = _ioDao('blog|blog')->getBlogById($getKernelLimitsIdBlog)) {
                 // On v�rifie qu'il y a au moins un article
                 $stats = KernelBlog::getStats($blog->id_blog);
                 if ($stats['nbArticles']['value'] > 0) {
                     $dispBlog = true;
                 }
             }
         }
         if ($dispBlog) {
             //return CopixActionGroup::process ('blog|frontblog::getListArticle', array ('blog'=>$blog->url_blog));
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||', array('blog' => $blog->url_blog)));
         }
         if (!CopixConfig::exists('|can_public_rssfeed') || CopixConfig::get('|can_public_rssfeed')) {
             CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('public||rss', array()) . '" type="application/rss+xml" title="' . htmlentities(CopixI18N::get('public|public.rss.flux.title')) . '" />');
         }
         CopixHTMLHeader::addCSSLink(_resource("styles/module_fichesecoles.css"));
         $tplModule->assign('user', _currentUser());
         $result = $tplModule->fetch('welcome|welcome_' . CopixI18N::getLang() . '.tpl');
         $tpl->assign('TITLE_PAGE', '' . CopixI18N::get('public|public.welcome.title'));
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 /**
  * 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);
 }
 /**
  * Récupère l'objet en session
  * Appelle les zones agendamenu et agendaeditlecon
  * @author Audrey Vassal <*****@*****.**>
  */
 public function processGetEdit()
 {
     CopixHTMLHeader::addCSSLink(_resource("styles/module_agenda.css"));
     require_once COPIX_UTILS_PATH . 'CopixDateTime.class.php';
     $serviceAuth = new AgendaAuth();
     $serviceType = new AgendaType();
     $serviceAgenda = new AgendaService();
     $serviceDate = new DateService();
     if (!($toEdit = $this->_getSessionLecon())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.unableToGetEdited'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     $serviceAuth->getCapability($toEdit->id_agenda);
     if ($serviceAuth->getCapability($toEdit->id_agenda) < $serviceAuth->getWriteLecon() || $serviceAgenda->getTypeAgendaByIdAgenda($toEdit->id_agenda) != $serviceType->getClassRoom()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     $listAgendas = $serviceAgenda->getAvailableAgenda();
     $listAgendasAffiches = $serviceAgenda->getAgendaAffiches();
     //template pour agenda
     $tplAgenda = new CopixTpl();
     $tplAgenda->assign('MAIN_AGENDA', CopixZone::process('agenda|agendaeditlecon', array('e' => _request('e'), 'errors' => _request('errors'), 'toEdit' => $toEdit)));
     //template principal
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('agenda|agenda.title.lecon', array('jour' => CopixDateTime::yyyymmddToDate($toEdit->date_lecon))));
     $menu = $serviceAgenda->getAgendaMenu('');
     $tpl->assign('MENU', $menu);
     $tpl->assign('MAIN', $tplAgenda->fetch('agenda|main.agenda.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
function smarty_function_htmlarea($params, &$smarty)
{
    static $_init = false;
    extract($params);
    //check the initialisation
    if (!$_init) {
        CopixHtmlHeader::addJsCode('_editor_url = "' . CopixUrl::get() . 'js/htmlarea/";');
        //path of the library
        if (empty($path)) {
            $path = CopixUrl::get() . 'js/htmlarea/';
            //default path under CopiX
        }
        CopixHTMLHeader::addJSLink($path . 'htmlarea.js');
        CopixHTMLHeader::addJSLink($path . 'dialog.js');
        if (empty($lang)) {
            $lang = CopixI18N::getLang();
        }
        CopixHTMLHeader::addJSLink($path . 'lang/' . $lang . '.js');
        CopixHTMLHeader::addCSSLink($path . 'htmlarea.css');
        CopixHTMLHeader::addJSLink($path . 'popupwin.js');
        CopixHTMLHeader::addJSCode('
                HTMLArea.loadPlugin("TableOperations");
                HTMLArea.loadPlugin("InsertAnchor");
                HTMLArea.loadPlugin("TableToggleBorder");
                HTMLArea.loadPlugin("AstonTools");
                HTMLArea.loadPlugin("ContextMenu");
                ');
        $_init = true;
    }
    if (empty($content)) {
        $content = '';
    }
    //name of the textarea.
    if (empty($name)) {
        $smarty->trigger_error('htmlarea: missing name parameter');
    } else {
        //       CopixHTMLHeader::addOthers ($script);
        if (!$width) {
            $width = 500;
        }
        if (!$height) {
            $height = 500;
        }
        $out = '<textarea id="' . $name . '" name="' . $name . '" style="width: ' . $width . 'px; height:' . $height . 'px;" >' . $content . '</textarea>';
        $out .= '<script type="text/javascript" defer="1">
       var editor' . $name . ' = null;
       editor' . $name . ' = new HTMLArea("' . $name . '");
       editor' . $name . '.registerPlugin("TableOperations");
       editor' . $name . '.registerPlugin("TableToggleBorder");
       editor' . $name . '.registerPlugin("InsertAnchor");
       editor' . $name . '.registerPlugin("AstonTools");
       editor' . $name . '.registerPlugin("ContextMenu");
       editor' . $name . '.config.pageStyle = "@import url(\\"' . CopixUrl::get() . 'styles/styles_copix.css\\");";
       editor' . $name . '.generate ();
       </script>';
    }
    return $out;
}
 function beforeDisplay(&$display)
 {
     $HTTP_USER_AGENT = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : '';
     if (preg_match("/MSIE 6.0/", $HTTP_USER_AGENT)) {
         CopixHTMLHeader::addCSSLink(_resource("styles/theme_ie.css"));
         CopixHTMLHeader::addCSSLink(_resource("styles/theme_ie6.css"));
     } elseif (preg_match("/MSIE 7.0/", $HTTP_USER_AGENT)) {
         CopixHTMLHeader::addCSSLink(_resource("styles/theme_ie.css"));
         CopixHTMLHeader::addCSSLink(_resource("styles/theme_ie7.css"));
     }
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     CopixHTMLHeader::addCSSLink(_resource("styles/module_blog_admin.css"));
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_blog.js');
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     $tpl->assign('article', $this->getParam('article', null));
     $tpl->assign('kind', $this->getParam('kind', null));
     $tpl->assign('id_blog', $id_blog);
     $tpl->assign('id_bact', $this->getParam('id_bact', ''));
     $tpl->assign('errors', $this->getParam('errors', ''));
     $tpl->assign('showErrors', $this->getParam('showErrors', false));
     $tpl->assign('preview', $this->getParam('preview', '0'));
     $tpl->assign('tabArticleCategory', $this->getParam('tabArticleCategory', null));
     $tpl->assign('can_format_articles', CopixConfig::get('blog|blog.default.can_format_articles'));
     $tpl->assign('default_format_articles', CopixConfig::get('blog|blog.default.default_format_articles'));
     $formats = CopixConfig::get('blog|blog.formats_articles');
     $tabFormats = explode(',', $formats);
     $values = $output = array();
     foreach ($tabFormats as $k) {
         $values[] = $k;
         $output[] = CopixI18N::get('blog|blog.default_format_articles.' . $k);
     }
     $tpl->assign('format_bact', array('values' => $values, 'output' => $output));
     $art = $this->getParam('article');
     $tpl->assign('edition_sumary', CopixZone::process('kernel|edition', array('field' => 'sumary_bact', 'format' => $art->format_bact, 'content' => $art->sumary_bact, 'options' => array('toolbarSet' => 'IconitoBlog'), 'object' => array('type' => 'MOD_BLOG', 'id' => $this->getParam('id_blog')), 'height' => 160)));
     $tpl->assign('edition_content', CopixZone::process('kernel|edition', array('field' => 'content_bact', 'format' => $art->format_bact, 'content' => $art->content_bact, 'options' => array('toolbarSet' => 'IconitoBlog'), 'object' => array('type' => 'MOD_BLOG', 'id' => $this->getParam('id_blog')), 'height' => 290)));
     //cat�gorie de l'article
     if ($this->getParam('kind', null) == 1) {
         $article = $this->getParam('article', null);
         $idCategorie = $article->tabSelectCat[0];
         foreach ($this->getParam('tabArticleCategory', null) as $key => $obj) {
             if ($obj->id_bacg == $idCategorie) {
                 $categorie = $obj->name_bacg;
             }
         }
         $tpl->assign('categorie', $categorie);
     }
     $tpl->assign('canWriteOnline', BlogAuth::canMakeInBlog('ADMIN_ARTICLE_MAKE_ONLINE', create_blog_object($id_blog)));
     // retour de la fonction :
     $toReturn = $tpl->fetch('article.edit.tpl');
     return true;
 }
function smarty_function_calendar($params, &$smarty)
{
    static $_init = false;
    extract($params);
    //check the initialisation
    if (!$_init) {
        //path of the library
        CopixHTMLHeader::addCSSLink(CopixUrl::get() . "js/dynCal/dynCalendar.css", array('media' => 'screen'));
        CopixHTMLHeader::addJSLink(CopixUrl::get() . "js/dynCal/browserSniffer.js");
        CopixHTMLHeader::addJSLink(CopixUrl::get() . "js/dynCal/dynCalendar.js");
        if (empty($lang)) {
            $lang = CopixI18N::getLang();
        }
        CopixHTMLHeader::addJSLink(CopixUrl::get() . "js/dynCal/lang/" . $lang . ".js");
        $_init = true;
    }
    //Calculating the jsCode (kind of silly trick to use a separator as a part of jsCode, but still quick)
    $jsCode = str_replace(array('d', 'm', 'Y'), array('day', 'month', 'year'), CopixI18N::getDateFormat(" + '/' + "));
    CopixHTMLHeader::addJSCode("\n\r" . '
                        function calendarCallback' . $name . '(day, month, year) {
            var tmp;
            if (String(month).length == 1) {
               month = \'0\' + month;
            }
            if (String(day).length == 1) {
               day = \'0\' + day;
            }
            tmp = document.getElementById (\'' . $name . '\');
                                   tmp.value = ' . $jsCode . ';
                        }
    ' . "\n\r");
    //name of the textarea.
    if (empty($name)) {
        $smarty->trigger_error('[smarty_calendar] missing name parameter');
    } else {
        $out = '<input type="text" class="calendar" id="' . $name . '" name="' . $name . '" value="' . $value . '">' . "\n\r";
        $out .= '<script language="javascript" type="text/javascript">' . "\n\r";
        $out .= '<!--' . "\n\r";
        $out .= 'calendar_' . $name . ' = new dynCalendar(\'calendar_' . $name . '\', \'calendarCallback' . $name . '\', \'' . CopixUrl::get() . 'js/dynCal/images/\');' . "\n\r";
        $out .= '//-->' . "\n\r";
        $out .= '</script>' . "\n\r";
    }
    return $out;
}
 /**
  * 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);
 }
 public function processAdmin()
 {
     //check if the user is admin :
     if (!Kernel::isAdmin()) {
         return $this->error('charte.noRight', true, '||');
     }
     $ppo = new CopixPPO();
     $ppo->errors = isset($this->flash->errors) ? $this->flash->errors : null;
     $ppo->success = isset($this->flash->success) ? $this->flash->success : null;
     $ppo->chartes = $this->service('CharteService')->getChartesTypes();
     $ppo->radio = array(1 => 'oui', 0 => 'non');
     $ppo->idClasseur = $ppo->idMalle = null;
     $modsAvailable = Kernel::getModAvailable($this->user->type);
     $malleAvailable = Kernel::filterModuleList($modsAvailable, 'MOD_MALLE');
     // Malle activée
     if (!empty($malleAvailable)) {
         $modsEnabled = Kernel::getModEnabled($this->user->type, $this->user->idEn);
         $mal = Kernel::filterModuleList($modsEnabled, 'MOD_MALLE');
         // Si la malle est bien initialisée
         if (!empty($mal)) {
             $ppo->idMalle = $mal[0]->module_id;
         } else {
             return $this->error('charte.admin.noMalle', true, 'malle||');
         }
     } else {
         $classeurAvailable = Kernel::filterModuleList($modsAvailable, 'MOD_CLASSEUR');
         // Classeur activé
         if (!empty($classeurAvailable)) {
             Kernel::createMissingModules($this->user->type, $this->user->idEn);
             $modsEnabled = Kernel::getModEnabled($this->user->type, $this->user->idEn);
             $classeur = Kernel::filterModuleList($modsEnabled, 'MOD_CLASSEUR');
             if (!empty($classeur)) {
                 $ppo->idClasseur = $classeur[0]->module_id;
             }
         }
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_charte.css"));
     return _arPPO($ppo, 'charte.admin.tpl');
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     CopixHTMLHeader::addCSSLink(_resource("styles/module_blog_admin.css"));
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_blog.js');
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     $tpl->assign('page', $this->getParam('page', null));
     $tpl->assign('id_blog', $this->getParam('id_blog', ''));
     $tpl->assign('id_bpge', $this->getParam('id_bpge', ''));
     $tpl->assign('errors', $this->getParam('errors', ''));
     $tpl->assign('showErrors', $this->getParam('showErrors', ''));
     $tpl->assign('preview', $this->getParam('preview', '0'));
     $tpl->assign('kind', $this->getParam('kind', '0'));
     $tpl->assign('can_format_articles', CopixConfig::get('blog|blog.default.can_format_articles'));
     $tpl->assign('default_format_articles', CopixConfig::get('blog|blog.default.default_format_articles'));
     //$tpl->assign ('wikibuttons', CopixZone::process ('kernel|wikibuttons', array('field'=>'content_bpge', 'object'=>array('type'=>'MOD_BLOG', 'id'=>$this->getParam('id_blog')))));
     $formats = CopixConfig::get('blog|blog.formats_articles');
     $tabFormats = explode(',', $formats);
     $values = $output = array();
     foreach ($tabFormats as $k) {
         $values[] = $k;
         $output[] = CopixI18N::get('blog|blog.default_format_articles.' . $k);
     }
     $tpl->assign('format_bpge', array('values' => $values, 'output' => $output));
     $pag = $this->getParam('page');
     //print_r($pag);
     if (!isset($pag->content_bpge)) {
         $pag->content_bpge = '';
     }
     //$content = (isset($pag->content_bpge)) ? $pag->content_bpge : '';
     //$tpl->assign ('content_bpge', CopixZone::process ('kernel|edition', array('field'=>'content_bpge', 'format'=>'wiki', 'content'=>$content, 'object'=>array('type'=>'MOD_BLOG', 'id'=>$this->getParam('id_blog')), 'height'=>290)));
     $tpl->assign('edition_content', CopixZone::process('kernel|edition', array('field' => 'content_bpge', 'format' => $pag->format_bpge, 'content' => $pag->content_bpge, 'object' => array('type' => 'MOD_BLOG', 'id' => $this->getParam('id_blog')), 'height' => 290)));
     $tpl->assign('canWriteOnline', BlogAuth::canMakeInBlog('ADMIN_ARTICLE_MAKE_ONLINE', create_blog_object($id_blog)));
     // retour de la fonction :
     $toReturn = $tpl->fetch('page.edit.tpl');
     return true;
 }
 /**
  * Accueil d'une liste
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/23
  * @param integer $id Id de la liste
  */
 public function getListe()
 {
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     $id = _request("id") ? _request("id") : NULL;
     $errors = array();
     $dao = CopixDAOFactory::create("liste|liste_listes");
     $liste = $dao->get($id);
     if (!$liste) {
         $errors[] = CopixI18N::get('liste|liste.error.noListe');
     } else {
         $mondroit = $kernel_service->getLevel("MOD_LISTE", $id);
         if (!ListeService::canMakeInListe('VIEW_HOME', $mondroit)) {
             $errors[] = CopixI18N::get('kernel|kernel.error.noRights');
         } else {
             $parent = $kernel_service->getModParentInfo("MOD_LISTE", $id);
             $liste->parent = $parent;
         }
     }
     //print_r($liste);
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('liste||')));
     } else {
         CopixHTMLHeader::addCSSLink(_resource("styles/module_liste.css"));
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $liste->parent["nom"]);
         $menu = array();
         $menu[] = array('txt' => CopixI18N::get('liste|liste.homeLinkMsgSend'), 'url' => CopixUrl::get('minimail||getListSend'));
         $tpl->assign('MENU', $menu);
         $tplListe = new CopixTpl();
         $tplListe->assign('liste', $liste);
         $tplListe->assign('canWrite', ListeService::canMakeInListe('WRITE', $mondroit));
         $result = $tplListe->fetch('getliste.tpl');
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 /**
  * R�cup�re l'objet en session
  * Cr�� un objet vide  et initialise la propri�t� id_agenda
  * @author Audrey Vassal <*****@*****.**>
  */
 public function processGetEdit()
 {
     CopixHTMLHeader::addCSSLink(_resource("styles/module_agenda.css"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.ui.datepicker-fr.js"));
     $serviceAuth = new AgendaAuth();
     $serviceAgenda = new AgendaService();
     if (!($toEdit = $this->_getSessionEvent())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.unableToGetEdited'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //var_dump($toEdit);
     //r�cup�ration de la liste des agendas affich�s
     $listAgendasAffiches = $serviceAgenda->getAgendaAffiches();
     //on v�rifie les droits des utilisateurs sur la liste des agendas affich�s
     foreach ((array) $listAgendasAffiches 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->getWriteAgenda()) {
             $ableToWrite = true;
         }
     }
     if (!$ableToWrite) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     $obj = new AgendaService();
     $listAgendas = $obj->getAvailableAgenda();
     //r�cup�ration de la liste des agendas affich�s
     $serviceAgenda = new AgendaService();
     //on r�cup�re en session la liste des agendas en cours de visualisation
     $arAgendasAffiches = $serviceAgenda->getAgendaAffiches();
     $arTitleAgendasAffiches = $serviceAgenda->getArTitleAgendaByArIdAgenda($arAgendasAffiches);
     //template pour agenda
     $tplAgenda = new CopixTpl();
     $tplAgenda->assign('MAIN_AGENDA', CopixZone::process('agenda|agendaeditevent', array('arTitleAgendasAffiches' => $arTitleAgendasAffiches, 'e' => $this->getRequest('e'), 'errors' => $this->getRequest('errors'), 'toEdit' => $toEdit)));
     //template principal
     $tpl = new CopixTpl();
     $tpl->assign('BODY_ON_LOAD', "setDatePicker('#datedeb_event,#datefin_event,#dateendrepeat_event')");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('agenda|agenda.title.editEvent'));
     $menu = $serviceAgenda->getAgendaMenu('create');
     $tpl->assign('MENU', $menu);
     $tpl->assign('MAIN', $tplAgenda->fetch('agenda|main.agenda.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Affichage du formulaire d'écriture d'un message (réponse à une discussion)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/16
  * @see doMessageForm()
  * @param integer $topic Id de la discussion
  * @param integer $eleve (option) Id de l'élève concerné
  * @param string $message Texte du message (si formulaire soumis)
  * @param array $errors (option) Erreurs rencontrées
  * @param integer $preview (option) Si 1, affichera la preview du message soumis, si 0 validera le formulaire
  */
 public function processGetMessageForm()
 {
     $carnet_service =& CopixClassesFactory::Create('carnet|CarnetService');
     $dao_carnets_to = CopixDAOFactory::create("carnet|carnet_topics_to");
     //$eleves = $carnet_service->getHisCarnetEleves();	// Ses élèves
     $criticErrors = array();
     $id = NULL;
     $topic = $this->getRequest('topic', null);
     $eleve = $this->getRequest('eleve', null);
     $message = $this->getRequest('message', null);
     $errors = $this->getRequest('errors', array());
     $preview = $this->getRequest('preview', 0);
     $format = CopixConfig::get('carnet|default_format');
     if ($id) {
         // Edition d'un message
         $criticErrors[] = CopixI18N::get('carnet|carnet.error.impossible');
     } elseif ($topic && $eleve) {
         // Réponse dans un topic, sur un élève
         $rTopic = $dao_carnets_to->get($topic, $eleve);
         if (!$rTopic) {
             $criticErrors[] = CopixI18N::get('carnet|carnet.error.noTopic');
         } else {
             $mondroit = $carnet_service->getUserDroitInCarnet(array("eleve" => $eleve));
             if (!$mondroit) {
                 $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
             }
         }
     } else {
         $criticErrors[] = CopixI18N::get('carnet|carnet.error.impossible');
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('carnet||')));
     } else {
         $tpl = new CopixTpl();
         //$titre = ($id) ? 'Modification du message' : 'Nouveau message';
         CopixHTMLHeader::addCSSLink(_resource("styles/module_carnet.css"));
         CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_carnet.js');
         $tpl->assign('TITLE_PAGE', $rTopic->topic_titre);
         $tplForm = new CopixTpl();
         $tplForm->assign('topic', $topic);
         $tplForm->assign('eleve', $eleve);
         $tplForm->assign('message', $message);
         $tplForm->assign('format', $format);
         $tplForm->assign("errors", $errors);
         $tplForm->assign("id", $id);
         $tplForm->assign('preview', $preview);
         $tplForm->assign('message_edition', CopixZone::process('kernel|edition', array('field' => 'message', 'format' => $format, 'content' => $message, 'height' => 200)));
         $result = $tplForm->fetch('getmessageform.tpl');
         $tpl->assign('MAIN', $result);
         //$tpl->assign ('MENU', '<a href="'.CopixUrl::get ('carnet||getTopic', array("id"=>$topic, "eleve"=>$eleve)).'">'.CopixI18N::get ('carnet|carnet.backTopic').'</a> :: <a href="'.CopixUrl::get ('carnet||getCarnet', array("eleve"=>$eleve)).'">'.CopixI18N::get ('carnet|carnet.backCarnet').'</a>');
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 /**
  * Liste des agendas disponibles
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/08/24
  * @param integer $id Id de l'agenda (si aucun, l'envoie dans l'agenda perso)
  */
 public function processAgendaList()
 {
     $serviceAuth = new AgendaAuth();
     $serviceType = new AgendaType();
     $serviceAgenda = new AgendaService();
     $tpl = new CopixTpl();
     $agendaDispos = AgendaService::getAvailableAgenda();
     $agendaAffiches = AgendaService::getAgendaAffiches();
     $ableToWrite = $ableToModerate = false;
     //on vérifie les droits des utilisateurs sur la liste des agendas affichés
     foreach ((array) $agendaAffiches as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affiché
         //print_r($serviceAuth->getWriteAgenda());
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteAgenda()) {
             $ableToWrite = true;
             break;
         }
     }
     //on vérifie les droits des utilisateurs sur la liste des agendas affichés
     foreach ((array) $agendaAffiches as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'import
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getModerate()) {
             $ableToModerate = true;
             break;
         }
     }
     $listeFiltre = $agendaDispos;
     //on vérifie les droits de lecture des utilisateurs
     foreach ((array) $listeFiltre as $key => $agenda) {
         //on vérifie si l'utilisateur a les droits de lecture sur la liste des agendas
         if ($serviceAuth->getCapability($agenda->id_agenda) < $serviceAuth->getRead()) {
             unset($listeFiltre[$key]);
         }
     }
     //on construit le tableau de couleurs associées au type d'agenda
     $arColorByIdAgenda = array();
     foreach ((array) $listeFiltre as $agenda) {
         $arColor = $serviceType->getColors($serviceAgenda->getTypeAgendaByIdAgenda($agenda->id_agenda));
         $i = 0;
         foreach ($arColorByIdAgenda as $idAgenda => $couleurAgenda) {
             if ($arColorByIdAgenda[$idAgenda] == $arColor[$i]) {
                 $i = $i + 1;
             }
         }
         if ($i < count($arColor)) {
             $arColorByIdAgenda[$agenda->id_agenda] = $arColor[$i];
         } else {
             $arColorByIdAgenda[$agenda->id_agenda] = $arColor[0];
         }
     }
     $ppo = new CopixPPO();
     $ppo->arColorByIdAgenda = $arColorByIdAgenda;
     $ppo->listAgendas = $listeFiltre;
     $ppo->agendasSelectionnes = $agendaAffiches;
     CopixHTMLHeader::addCSSLink(_resource("styles/module_agenda.css"));
     return _arPPO($ppo, array('template' => 'popup_agendalist.agenda.tpl', 'mainTemplate' => 'main|main_fancy.php'));
 }
 /**
  * Affichage d'une malle en popup, permettant de sélectionner un ou plusieurs fichiers à insérer dans une zone de saisie formaté wiki (blog, forum...)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/11/23
  * @param integer $id Id de la malle
  * @param integer $folder Id du répertoire
  * @param array $errors (option) Erreurs rencontrées
  * @param string $field Champ utilisé dans la fenêtre "en-dessous"
  * @param string $format Format de la zone de saisie (wiki, html, fckeditor...)
  */
 public function processGetMallePopup()
 {
     $ppo = new CopixPPO();
     $kernelService =& CopixClassesFactory::Create('kernel|kernel');
     $malleService =& CopixClassesFactory::Create('malle|malleService');
     $daoMalles = CopixDAOFactory::create("malle|malle_malles");
     $daoFolders = CopixDAOFactory::create("malle|malle_folders");
     $daoFiles = CopixDAOFactory::create("malle|malle_files");
     $id = $this->getRequest('id', null);
     $folder = $this->getRequest('folder', 0);
     $errors = $this->getRequest('errors', array());
     $field = $this->getRequest('field', null);
     $format = $this->getRequest('format', null);
     $criticErrors = array();
     if ($folder) {
         $rFolder = $daoFolders->get($folder);
         if (!$rFolder) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noFolder');
         } elseif ($rFolder->malle != $id) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noFolder');
         }
     } else {
         $rMalle = $daoMalles->get($id);
         if (!$rMalle) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noMalle');
         }
     }
     if (!$criticErrors) {
         $mondroit = $kernelService->getLevel("MOD_MALLE", $id);
         //print_r($mondroit);
         if (!$malleService->canMakeInMalle("READ", $mondroit)) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         } else {
             $parent = $kernelService->getModParentInfo("MOD_MALLE", $id);
             //print_r($parent);
         }
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('malle||')));
     } else {
         // On récupère les dossiers de ce répertoire
         $folders = $daoFolders->getFoldersInFolder($id, $folder);
         // On récupère les fichiers de ce répertoire
         $files = $daoFiles->getFilesInFolder($id, $folder);
         foreach ($files as $k => $file) {
             // Ajout des infos sur le type du fichier
             $mime = $malleService->getTypeInfos($file->type, $file->fichier);
             $files[$k]->type_text = $mime['type_text'];
             $files[$k]->type_icon = $mime['type_icon'];
         }
         $dispMenu = true;
         if (substr($parent['type'], 0, 5) == 'USER_') {
             $title = CopixI18N::get('malle|malle.perso');
             $dispMenu = false;
         } else {
             $title = isset($parent["nom"]) ? $parent["nom"] : CopixI18N::get('malle.moduleDescription');
         }
         $ppo->TITLE_PAGE = CopixI18N::get('malle|malle.popup.title');
         $ppo->id = $id;
         $ppo->folder = $folder;
         $ppo->folders = $folders;
         $ppo->files = $files;
         $ppo->errors = $errors;
         $ppo->field = $field;
         $ppo->format = $format;
         $ppo->combofolders = CopixZone::process('malle|combofolders', array('malle' => $id, 'folder' => $folder, 'fieldName' => 'folder', 'attribs' => 'ONCHANGE="this.form.submit();"', 'linesSup' => array(0 => array('value' => '', 'libelle' => CopixI18N::get('malle|malle.comboDirectAccess')))));
         $ppo->uploadMaxSize = CopixConfig::get('malle|uploadMaxSize');
         /*
         // On déduit le chemin absolu
         $path = $_SERVER['PHP_SELF'];
         $pos = strrpos($path, "/");
         if ($pos !== false) {
             $abspath = substr($path,0,$pos+1);
         }
         $ppo->abspath = $abspath;
         */
         CopixHTMLHeader::addCSSLink(_resource("styles/module_malle_popup.css"));
         CopixHTMLHeader::addJSLink(_resource("js/iconito/module_malle.js"));
         return _arPPO($ppo, array('template' => 'getmallepopup.tpl', 'mainTemplate' => 'main|main_popup.php'));
     }
 }
 public function process($pParams, $pContent = null)
 {
     $id = $this->getParam('id', uniqid('modalbox'));
     $customContent = $this->getParam('customContent');
     if (!$customContent) {
         $title = $this->getParam('title', '');
         $icon = $this->getParam('icon');
     }
     $openTriggers = $this->getParam('openTriggers');
     $closeTriggers = $this->getParam('closeTriggers');
     $onOpen = $this->getParam('onOpen');
     $onClose = $this->getParam('onClose');
     $this->validateParams();
     CopixHTMLHeader::addJSFramework();
     $options = array('id' => $id);
     if ($customContent) {
         $options['contentId'] = $customContent;
     }
     if ($openTriggers) {
         if (!is_array($openTriggers)) {
             $openTriggers = split(',', $openTriggers);
         }
         $options['openTriggers'] = $openTriggers;
     }
     if ($closeTriggers) {
         if (!is_array($closeTriggers)) {
             $closeTriggers = split(',', $closeTriggers);
         }
         $options['closeTriggers'] = $closeTriggers;
     }
     if ($customContent) {
         $boxContent = $pContent;
     } else {
         $boxContent = '<td width="100%">' . $pContent . '</td>';
         if ($icon) {
             $titleColspan = 2;
             $boxContent = '<td style="text-align: center"><img src="' . _resource($icon) . '"/></td>' . $boxContent;
         } else {
             $titleColspan = 1;
         }
         $boxContent = '<tbody><tr>' . $boxContent . '</tr></tbody>';
         if ($title) {
             $boxContent = '<thead><tr><th width="100%" colspan="' . $titleColspan . '">' . htmlEntities($title) . '</th></tr></thead>' . $boxContent;
         }
         $boxContent = '<table id="' . $id . '_content" class="CopixModalBox_Content CopixTable">' . $boxContent . '</table>';
     }
     CopixHTMLHeader::addCSSLink(_resource('styles/taglib/js_modalbox.css'), array('id' => 'taglib_js_modalbox_css'));
     CopixHTMLHeader::addJSLink(_resource('js/taglib/js_modalbox.js'), array('id' => 'taglib_js_modalbox_js'));
     $js = new CopixJSWidget();
     $js->Copix->ModalBox->register($options);
     $events = array();
     if ($onOpen) {
         $events['open'] = $js->function_(null, null, $onOpen);
     }
     if ($onClose) {
         $events['close'] = $js->function_(null, null, $onClose);
     }
     if (count($events)) {
         $js->_($id)->addEvents($events);
     }
     CopixHTMLHeader::addJSDOMReadyCode($js);
     return '<div id="' . $id . '" style="display:none">' . $boxContent . '</div>';
 }
 /**
  * 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'));
 }
function smarty_function_htmleditor($params, &$smarty)
{
    static $_init = false;
    extract($params);
    //check the initialisation
    if (!$_init) {
        switch (strtolower(CopixConfig::get('htmleditor|type'))) {
            case 'htmlarea':
                CopixHtmlHeader::addJsCode('_editor_url = "' . CopixUrl::get() . 'js/htmlarea/";');
                //path of the library
                if (empty($htmlPath)) {
                    $htmlPath = CopixUrl::get() . 'js/htmlarea/';
                    //default path under CopiX
                }
                CopixHTMLHeader::addJSLink($htmlPath . 'htmlarea.js');
                CopixHTMLHeader::addJSLink($htmlPath . 'dialog.js');
                if (empty($lang)) {
                    $lang = CopixI18N::getLang();
                }
                CopixHTMLHeader::addJSLink($htmlPath . 'lang/' . $lang . '.js');
                CopixHTMLHeader::addCSSLink($htmlPath . 'htmlarea.css');
                CopixHTMLHeader::addJSLink($htmlPath . 'popupwin.js');
                $jsCode = 'HTMLArea.loadPlugin("TableOperations");
                HTMLArea.loadPlugin("InsertAnchor");
                HTMLArea.loadPlugin("TableToggleBorder");
                HTMLArea.loadPlugin("ContextMenu");';
                if (CopixModule::isValid('pictures') && CopixModule::isValid('cms') && CopixModule::isValid('document')) {
                    $jsCode = 'HTMLArea.loadPlugin("AstonTools");';
                }
                CopixHTMLHeader::addJSCode($jsCode);
                break;
            case 'fckeditor':
            default:
                $path = COPIX_MODULE_PATH . 'htmleditor/' . COPIX_CLASSES_DIR;
                $htmlPath = CopixUrl::get() . 'js/FCKeditor/';
                require_once $path . 'fckeditor.php';
                break;
        }
        //     CopixHTMLHeader::addJSLink ($path.'fckconfig.js');
        //		 CopixHTMLHeader::addJSLink ($path.'fckeditor.js');
        $_init = true;
    }
    if (empty($content)) {
        $content = '&nbsp;';
    }
    //name of the textarea.
    if (empty($name)) {
        $smarty->trigger_error('htmleditor: missing name parameter');
    } else {
        if (!$width) {
            $width = CopixConfig::get('htmleditor|width');
            //$width = '100%';
        }
        if (!$height) {
            $height = CopixConfig::get('htmleditor|height');
            //$height = '450px';
        }
        switch (strtolower(CopixConfig::get('htmleditor|type'))) {
            case 'htmlarea':
                $out = '<textarea id="' . $name . '" name="' . $name . '" style="width: ' . $width . 'px; height:' . $height . 'px;" >' . $content . '</textarea>';
                $out .= '<script type="text/javascript" defer="1">
         var editor' . $name . ' = null;
         editor' . $name . ' = new HTMLArea("' . $name . '");
         editor' . $name . '.registerPlugin("TableOperations");
         editor' . $name . '.registerPlugin("TableToggleBorder");
         editor' . $name . '.registerPlugin("InsertAnchor");
         editor' . $name . '.registerPlugin("ContextMenu");';
                if (CopixModule::isValid('pictures') && CopixModule::isValid('cms') && CopixModule::isValid('document')) {
                    $out .= 'editor' . $name . '.registerPlugin("AstonTools");';
                }
                $out .= 'editor' . $name . '.config.pageStyle = "@import url(\\"' . CopixUrl::get() . 'styles/styles_copix.css\\");";
         editor' . $name . '.generate ();
         </script>';
                break;
            case 'fckeditor':
            default:
                /*
                 * ATTENTION les éléments de config viewPhototèque etc font doublon avec la sélection de la toolbarset, mais sont nécessaire à Copix
                 * Par contre si on ne les load pas, on a une erreur de FCKeditor, il faut donc supprimer ce gestionnaire d'erreur sinon on se prend un alert javascript
                 * le gestionnaire en question se trouve dans "FCKToolbarItems.GetItem" (chercher cette chaîne pour le trouver) et désactiver "alert( FCKLang.UnknownToolbarItem.replace( /%1/g, itemName ) ) ;"
                 */
                $oFCKeditor = new FCKeditor($name);
                $oFCKeditor->BasePath = $htmlPath;
                $oFCKeditor->Value = $content;
                $oFCKeditor->ToolbarSet = 'Copix';
                $oFCKeditor->Width = $width;
                $oFCKeditor->Height = $height;
                $oFCKeditor->Config['viewPhototheque'] = CopixModule::isValid('pictures') ? 'true' : 'false';
                $oFCKeditor->Config['viewCmsLink'] = CopixModule::isValid('cms') ? 'true' : 'false';
                $oFCKeditor->Config['viewLinkPopup'] = CopixModule::isValid('cms') ? 'true' : 'false';
                $oFCKeditor->Config['viewDocument'] = CopixModule::isValid('document') ? 'true' : 'false';
                // Configuration de la feuille de style à utiliser.
                $oFCKeditor->Config['EditorAreaCSS'] = CopixUrl::get() . 'styles/styles_copix.css';
                $out = $oFCKeditor->CreateHtml();
                break;
        }
    }
    return $out;
}
 /**
  * Préparation de l'édition d'un blog.
  */
 public function processGetShowBlog()
 {
     $id_blog = $this->getRequest('id_blog', null);
     $blogDAO = CopixDAOFactory::create('blog|blog');
     $blog = $blogDAO->get($id_blog);
     if (!BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageBlog'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||')));
     }
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('||')));
     }
     $kind = $this->getRequest('kind', '0');
     $tpl = new CopixTpl();
     $tabBlogFunctions = null;
     $result = null;
     if ($kind == '0') {
         // Articles
         CopixHTMLHeader::addCSSLink(_resource("styles/module_blog.css"));
         $selectCategory = $this->getRequest('selectCategory', '');
         $selectMonth = $this->getRequest('selectMonth', '');
         $id_bact = $this->getRequest('id_bact', '');
         $result = CopixZone::process('ShowBlogArticle', array('id_blog' => $id_blog, 'blog' => $blog, 'kind' => $kind, 'selectCategory' => $selectCategory, 'selectMonth' => $selectMonth, 'id_bact' => $id_bact, 'p' => $this->getRequest('p', '')));
     } else {
         if ($kind == '1') {
             // Catégories
             $result = CopixZone::process('ShowBlogCategory', array('id_blog' => $id_blog, 'kind' => $kind));
         } else {
             if ($kind == '2') {
                 // Liens
                 $result = CopixZone::process('ShowBlogLink', array('id_blog' => $id_blog, 'kind' => $kind));
             } else {
                 if ($kind == '3') {
                     // Photos
                     $can = BlogAuth::canMakeInBlog('ADMIN_PHOTOS', $blog);
                     if ($can) {
                         $parent = Kernel::getModParentInfo("MOD_BLOG", $id_blog);
                         if ($parent) {
                             $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
                             $mods = Kernel::filterModuleList($mods, 'MOD_ALBUM');
                             if ($mods && $mods[0]) {
                                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('album||go', array('id' => $mods[0]->module_id)));
                             }
                         }
                     }
                     // Si on arrive là, c'est pas normal
                     $result = CopixZone::process('ShowBlogPhoto', array('id_blog' => $id_blog, 'kind' => $kind));
                 } else {
                     if ($kind == '7') {
                         // Documents
                         $can = BlogAuth::canMakeInBlog('ADMIN_DOCUMENTS', $blog);
                         if ($can) {
                             $parent = Kernel::getModParentInfo("MOD_BLOG", $id_blog);
                             if ($parent) {
                                 $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
                                 $mods = Kernel::filterModuleList($mods, 'MOD_MALLE');
                                 if ($mods && $mods[0]) {
                                     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('malle||go', array('id' => $mods[0]->module_id)));
                                 }
                             }
                         }
                         // Si on arrive là, c'est pas normal
                         $result = CopixZone::process('ShowBlogDocument', array('id_blog' => $id_blog, 'kind' => $kind));
                     } else {
                         if ($kind == '5') {
                             // Pages
                             $result = CopixZone::process('ShowBlogPage', array('id_blog' => $id_blog, 'kind' => $kind));
                         } else {
                             if ($kind == '6') {
                                 // RSS
                                 $result = CopixZone::process('ShowBlogFluxRss', array('id_blog' => $id_blog, 'kind' => $kind));
                             } else {
                                 if ($kind == '8') {
                                     // Droits particuliers sur le blog
                                     $result = CopixZone::process('ShowBlogDroits', array('blog' => $blog, 'kind' => $kind, 'errors' => $this->getRequest('errors'), 'membres' => $this->getRequest('membres'), 'droit' => $this->getRequest('droit')));
                                 } else {
                                     if ($kind == '9') {
                                         // Stats du blog
                                         $result = CopixZone::process('stats|module', array('module_type' => 'MOD_BLOG', 'module_id' => $id_blog, 'date' => $this->getRequest('date'), 'mois' => $this->getRequest('mois'), 'annee' => $this->getRequest('annee'), 'url' => CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $kind)), 'errors' => $this->getRequest('errors')));
                                     } else {
                                         // Options
                                         $kind = 4;
                                         $tabFunctions = returnAllBlogFunctions();
                                         $blogFunctionsDAO = CopixDAOFactory::create('blog|blogfunctions');
                                         $resBlogFunctions = $blogFunctionsDAO->get($id_blog);
                                         $tabBlogFunctions = array();
                                         if ($resBlogFunctions != null) {
                                             foreach ($tabFunctions as $fct) {
                                                 eval('if($resBlogFunctions->' . $fct->value . '==\'1\')array_push($tabBlogFunctions, $fct);');
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $menu = getBlogAdminMenu($blog, $kind);
     $tpl->assign('TITLE_PAGE', $blog->name_blog);
     $tpl->assign('MENU', $menu);
     // _dump($blog);
     $tpl->assign('MAIN', CopixZone::process('ShowBlog', array('id_blog' => $id_blog, 'blog' => $blog, 'kind' => $kind, 'tabBlogFunctions' => $tabBlogFunctions, 'RESULT' => $result)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Affiche la liste des ecoles
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2010/09/24
  */
 public function processEcoles()
 {
     CopixHTMLHeader::addCSSLink(_resource("styles/module_fichesecoles.css"));
     $ppo = new CopixPPO();
     $ppo->ville = (int) $this->request('ville');
     $ppo->search = $this->request('search');
     $ppo->TITLE_PAGE = CopixI18N::get('public|public.listEcoles');
     return _arPPO($ppo, 'ecoles.tpl');
 }
 /**
  * Validation d'un commentaire.
  */
 public function doValidComment()
 {
     if (Kernel::isSpam()) {
         return new CopixActionReturn(CopixActionReturn::HTTPCODE, CopixHTTPHeader::get404(), "Page introuvable");
     }
     $url_bact = _request('url_bact');
     //On verifit que le blog existe (on r�cup�re le blog avec son nom)
     $dao = CopixDAOFactory::create('blog|blog');
     if (!($blog = $dao->getBlogByName(_request('blog')))) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindBlog'), 'back' => CopixUrl::get('')));
     }
     // On v�rifie que le droit de lecture est pr�sent
     if (!BlogAuth::canMakeInBlog('READ', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('')));
     }
     if (!$blog->has_comments_activated) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.add.comment.closed'), 'back' => CopixUrl::get('', array('blog' => _request('blog')))));
     }
     $id_bact = $this->getRequest('id_bact', null);
     if (!BlogAuth::canComment($blog->id_blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('', array('blog' => _request('blog')))));
     }
     $tpl = new CopixTpl();
     $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment');
     $comment = CopixDAOFactory::createRecord('blog|blogarticlecomment');
     $this->_validFromPostProperties($comment);
     $comment->date_bacc = date('Ymd');
     $comment->time_bacc = date('Hi');
     $comment->is_online = $blog->type_moderation_comments != 'POST' ? 0 : 1;
     $comment->authorip_bacc = $_SERVER["REMOTE_ADDR"];
     CopixHTMLHeader::addCSSLink(CopixUrl::get('blog||getBlogCss', array('id_blog' => $blog->id_blog)));
     $tpl->assign('blog', $blog);
     $errors = $commentDAO->check($comment);
     //print_r($comment);
     $showErrors = false;
     if ($errors != 1) {
         // Traitement des erreurs
         $showErrors = true;
     } else {
         // Insertion dans la base
         $commentDAO->insert($comment);
     }
     $zoneArticle = CopixZone::process('ShowArticle', array('blog' => $blog, 'article' => $this->getRequest('article', ''), 'errors' => $errors, 'showErrors' => $showErrors, 'comment' => $comment));
     list($title, $article) = explode("{/}", $zoneArticle);
     $tpl->assign('TITLE_PAGE', $title . ' - ' . $blog->name_blog);
     $tpl->assign('Article', $article);
     $tpl->assign('ListLink', CopixZone::process('ListLink', array('blog' => $blog)));
     $tpl->assign('ListCategory', CopixZone::process('ListCategory', array('blog' => $blog)));
     $tpl->assign('ListArchive', CopixZone::process('ListArchive', array('blog' => $blog)));
     $tpl->assign('ListPage', CopixZone::process('ListPage', array('blog' => $blog)));
     $tpl->assign('ListSearch', CopixZone::process('ListSearch', array('blog' => $blog)));
     if (!$showErrors) {
         if ($comment->is_online == 1) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||showArticle', array('blog' => urlencode($blog->url_blog), 'article' => _request('article'))) . '#comments');
         } else {
             return CopixActionGroup::process('genericTools|Messages::getInformation', array('message' => CopixI18N::get('blog.comments.offline.info'), 'continue' => CopixUrl::get('blog|default|showArticle', array('blog' => $blog->url_blog, 'article' => $url_bact))));
         }
     }
     //		$menu = array();
     $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
     //print_r($parent);
     $blog->parent = $parent;
     /*
             if ($parent['type']=='CLUB') {
                 $droit = Kernel::getLevel($parent['type'], $parent['id']);
                 //print_r($droit);
                 if (GroupeService::canMakeInGroupe('VIEW_HOME', $droit))
                     $menu[] = array('url'=>CopixUrl::get ('groupe||getHome', array("id"=>$parent['id'])), 'txt'=>CopixI18N::get ('blog.menuToGroup'));
             }
             if (BlogAuth::canMakeInBlog('ACCESS_ADMIN',$blog))
                 $menu[] = array('url'=>CopixUrl::get ('admin|showBlog', array("id_blog"=>$blog->id_blog)), 'txt'=>CopixI18N::get ('blog.menuAdmin'));
     */
     //print_r($menu);
     $menu = array();
     if (BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         $menu = getBlogAdminMenu($blog);
     }
     $tpl->assign('MENU', $menu);
     CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('blog||rss', array("blog" => $blog->url_blog)) . '" type="application/rss+xml" title="' . htmlentities($blog->name_blog) . '" />');
     if ($blog->template) {
         $MAIN = $tpl->fetch($blog->template);
     } else {
         $MAIN = $tpl->fetch('blog_main.tpl');
     }
     $tpl->assign('MAIN', $MAIN);
     $tpl->assign('HEADER_MODE', 'compact');
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function getEditPhotos()
 {
     CopixHTMLHeader::addCSSLink(_resource("styles/module_album.css"));
     $tpl = new CopixTpl();
     $menu = array();
     $menu[] = array('txt' => CopixI18N::get('album.menu.gotoalbum'), 'url' => CopixUrl::get('album||album', array("album_id" => _request("album_id"), "dossier_id" => _request("dossier_id"))), 'size' => 95);
     $tpl->assign('MENU', $menu);
     $tpl->assign('TITLE_PAGE', CopixI18N::get('album.title.editphotos'));
     $tpl->assign('MAIN', CopixZone::process('album|editphotos', array('album_id' => _request("album_id"), 'dossier_id' => _request("dossier_id"))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function getNew()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_comptes.css"));
     $tpl = new CopixTpl();
     $tplAnimateurs = new CopixTpl();
     $animateurs_dao = _dao("kernel|kernel_animateurs");
     $animateurs = $animateurs_dao->findAll();
     $ppo->animateurs = array();
     foreach ($animateurs as $animateur) {
         $ppo->animateurs[$animateur->user_type . "-" . $animateur->user_id] = $animateur;
     }
     //// Personnes externes ///////////////////////////////////////
     $userext_dao = _dao("kernel|kernel_ext_user");
     $list = $userext_dao->listUsers();
     $user_key = 0;
     foreach ($list as $user_val) {
         $ppo->userext[$user_key] = $user_val;
         $user_key++;
     }
     foreach ($ppo->userext as $user_key => $user_val) {
         if (isset($ppo->animateurs["USER_EXT-" . $user_val->ext_id])) {
             // Si la personne est déjà animateur
             unset($ppo->userext[$user_key]);
         } else {
             $ppo->userext[$user_key]->user_infos = Kernel::getUserInfo('USER_EXT', $user_val->ext_id);
             if (!isset($ppo->userext[$user_key]->user_infos['login'])) {
                 // Si la personne n'a pas de login de type enseignant
                 unset($ppo->userext[$user_key]);
             }
         }
     }
     $sql = "\n            SELECT PER.nom AS nom, PER.prenom1 AS prenom,\n                   B2U.bu_type AS bu_type, B2U.bu_id AS bu_id,\n                   USR.login_dbuser\n            FROM kernel_bu_personnel PER\n            JOIN kernel_bu_personnel_entite ENT ON PER.numero=ENT.id_per\n            JOIN kernel_link_bu2user B2U ON PER.numero=B2U.bu_id AND B2U.bu_type IN ('USER_VIL','USER_ENS','USER_ADM')\n            JOIN dbuser USR ON B2U.user_id=USR.id_dbuser\n            -- WHERE PER.deleted=0\n            GROUP BY bu_type,bu_id\n        ";
     $pers = _doQuery($sql);
     $ppo->pers = array();
     foreach ($pers as $pers_item) {
         $ppo->pers[$pers_item->bu_type][$pers_item->bu_id] = $pers_item;
     }
     /*
     echo "<pre>";
     // print_r($ppo->animateurs);
     print_r($ppo->userext);
     // print_r($ppo->userens);
     die();
     */
     $tplAnimateurs->assign('ppo', $ppo);
     $result = $tplAnimateurs->fetch("animateurs-new.tpl");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " &raquo; " . CopixI18N::get('comptes.title.animateur_list'));
     $tpl->assign('MAIN', $result);
     $tpl->assign('MENU', $this->menu);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function beforeAction()
 {
     _currentUser()->assertCredential('group:[current_user]');
     CopixHTMLHeader::addCSSLink(_resource("styles/module_visio.css"));
 }
 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');
 }
예제 #26
0
 public function addFile($iPath)
 {
     CopixHTMLHeader::addCSSLink(_resource($iPath));
 }
 /**
  * Fonction appelée lorsque l'on clique sur le lien export du menu
  * Récupère en session les agendas visualisables de l'utilisateur
  * récupère l'objet exportParams en session s'il existe, le créer sinon, puis stock en session
  * @since 2006/08/17
  * @author Audrey Vassal <*****@*****.**>
  * appelle les zones agendamenu et agendaexport
  */
 public function processGetPrepareExport()
 {
     CopixHTMLHeader::addCSSLink(_resource("styles/module_agenda.css"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.ui.datepicker-fr.js"));
     $serviceAuth = new AgendaAuth();
     $serviceAgenda = new AgendaService();
     //on vérifie les droits des utilisateurs sur la liste des agendas affichés
     $listAgendasAffiches = $serviceAgenda->getAgendaAffiches();
     foreach ((array) $listAgendasAffiches 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()) {
             $ableToRead = true;
         }
     }
     if (!$ableToRead) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //on récupère en session la liste des agendas en cours de visualisation
     $arAgendasAffiches = $serviceAgenda->getAgendaAffiches();
     $arTitleAgendasAffiches = $serviceAgenda->getArTitleAgendaByArIdAgenda($arAgendasAffiches);
     if (!($exportParams = $this->_getSessionExport())) {
         //initialisation de l'objet exportParams avec le premier agenda affiché de la liste
         $exportParams->id_agenda = current($arAgendasAffiches);
         $this->_setSessionExport($exportParams);
     }
     //récupération de la liste des agendas en bdd (pour l'affichage du menu)
     $listAgendas = $serviceAgenda->getAvailableAgenda();
     //récupération de la liste des agendas affichés
     $listAgendasAffiches = $serviceAgenda->getAgendaAffiches();
     //template pour agenda
     $tplAgenda = new CopixTpl();
     $tplAgenda->assign('MAIN_AGENDA', CopixZone::process('agenda|agendaexport', array('arTitleAgendasAffiches' => $arTitleAgendasAffiches, 'e' => $this->getRequest('e'), 'errors' => $this->getRequest('errors'), 'exportParams' => $exportParams)));
     //template principal
     $tpl = new CopixTpl();
     $tpl->assign('BODY_ON_LOAD', "setDatePicker('#datedeb_export,#datefin_export')");
     $tpl->assign('TITLE_PAGE', CopixI18N::get('agenda|agenda.message.export'));
     $menu = $serviceAgenda->getAgendaMenu('export');
     $tpl->assign('MENU', $menu);
     $tpl->assign('MAIN', $tplAgenda->fetch('agenda|main.agenda.tpl'));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function setPrefs()
 {
     if (0 && Kernel::isDemo()) {
         return Kernel::noDemo();
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_prefs.css"));
     CopixHTMLHeader::addOthers('<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"/>');
     CopixHTMLHeader::addOthers('<META HTTP-EQUIV="Expires" CONTENT="-1"/>');
     CopixHTMLHeader::addOthers('<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"/>');
     $tpl = new CopixTpl();
     // Liste des modules qui peuvent avoir des préférences...
     $modules = Prefs::getModules();
     $arModulesPath = CopixConfig::instance()->arModulesPath;
     $datas = array();
     $errors = array();
     reset($modules);
     foreach ($modules as $mod_key => $mod_val) {
         foreach ($arModulesPath as $modulePath) {
             $class_file = $modulePath . $mod_val->rep . '/' . COPIX_CLASSES_DIR . 'mod' . $mod_val->rep . 'prefs.class.php';
             if (!file_exists($class_file)) {
                 continue;
             }
             $module_class =& CopixClassesFactory::Create($mod_val->rep . '|mod' . $mod_val->rep . 'prefs');
             reset($_POST);
             // Parcours de tous les parametres passé en POST, pour chaque module.
             foreach ($_POST as $post_key => $post_val) {
                 if (ereg('^' . $mod_val->rep . '_(.+)$', $post_key, $regs)) {
                     $datas[$mod_val->rep][$regs[1]] = $post_val;
                 }
             }
             // Appel de la fonction de vérification du module.
             if (method_exists($module_class, 'checkPrefs')) {
                 $d = isset($datas[$mod_val->rep]) ? $datas[$mod_val->rep] : null;
                 $error = $module_class->checkPrefs($mod_val->rep, $d);
                 if (sizeof($error)) {
                     $errors[$mod_val->rep] = $error;
                 }
             }
         }
     }
     if (sizeof($errors)) {
         //print_r($errors);
         //			$tplPrefs = new CopixTpl ();
         // Liste des modules disponibles...
         reset($modules);
         foreach ($modules as $mod_key => $mod_val) {
             foreach ($arModulesPath as $modulePath) {
                 $class_file = $modulePath . $mod_val->rep . '/' . COPIX_CLASSES_DIR . 'mod' . $mod_val->rep . 'prefs.class.php';
                 if (!file_exists($class_file)) {
                     continue;
                 }
                 // Chargement de la classe...
                 $module_class =& CopixClassesFactory::Create($mod_val->rep . '|mod' . $mod_val->rep . 'prefs');
                 // Récupération de la structure des prefs...
                 $d = isset($data[$mod_val->rep]) ? $data[$mod_val->rep] : null;
                 $pref = $module_class->getPrefs($d);
                 $pref['code'] = $mod_val->rep;
                 if (isset($pref['form'])) {
                     // Protection contre les modules aux prefs vides
                     foreach ($pref['form'] as $key => $val) {
                         if (isset($val['code']) && isset($_POST[$pref['code'] . '_' . $val['code']])) {
                             $pref['form'][$key]['value'] = $_POST[$pref['code'] . '_' . $val['code']];
                         }
                         //print_r($val);
                         if (isset($val['code']) && isset($errors[$pref['code']][$val['code']])) {
                             $pref['form'][$key]['error'] = $errors[$pref['code']][$val['code']];
                         }
                     }
                 }
                 $prefs[] = $pref;
             }
         }
         $tpl->assign('TITLE_PAGE', CopixI18N::get('prefs.moduleDescription'));
         $tpl->assign('MAIN', CopixZone::process('prefs|prefs', array('prefs' => $prefs)));
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     } else {
         reset($modules);
         foreach ($modules as $mod_key => $mod_val) {
             foreach ($arModulesPath as $modulePath) {
                 $class_file = $modulePath . $mod_val->rep . '/' . COPIX_CLASSES_DIR . 'mod' . $mod_val->rep . 'prefs.class.php';
                 if (!file_exists($class_file)) {
                     continue;
                 }
                 $module_class =& CopixClassesFactory::Create($mod_val->rep . '|mod' . $mod_val->rep . 'prefs');
                 $d = isset($datas[$mod_val->rep]) ? $datas[$mod_val->rep] : null;
                 $module_class->setPrefs($mod_val->rep, $d);
             }
         }
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('prefs|default|default', array('msg' => 'save')));
 }
 public function getGroup()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $tpl = new CopixTpl();
     $tplGrVilles = new CopixTpl();
     CopixHTMLHeader::addCSSLink(_resource("styles/module_regroupements.css"));
     $regroupements_service =& CopixClassesFactory::Create('regroupements|regroupements');
     $tpl->assign('TITLE_PAGE', CopixI18N::get('regroupements|regroupements.villes.titre'));
     $tpl->assign('MENU', $regroupements_service->getMenu());
     $dao_grvilles_gr2ville = CopixDAOFactory::create("regroupements|grvilles_gr2ville");
     $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles");
     $dao_villes = CopixDAOFactory::create("kernel|kernel_tree_vil");
     $villes = $dao_villes->findAll();
     $tplGrVilles->assign('villes', $villes);
     if (_request("delete")) {
         $dao_grvilles->delete(_request("delete"));
         $dao_grvilles_gr2ville->deleteByGroupe(_request("delete"));
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|'));
     }
     if (_request("save") && _request("save") == 1) {
         $date = date("Y-m-d H:i:s");
         $user = Kernel::getUserInfo();
         if (_request("form_id") > 0) {
             $grvilles_infos = $dao_grvilles->get(_request("form_id"));
             $grvilles_infos->nom = _request("form_nom");
             $grvilles_infos->updated_at = $date;
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->update($grvilles_infos);
             $dao_grvilles_gr2ville->deleteByGroupe(_request("form_id"));
         } else {
             $grvilles_infos = CopixDAOFactory::createRecord("regroupements|grvilles");
             $grvilles_infos->nom = _request("form_nom");
             if ($grvilles_infos->nom == '') {
                 $grvilles_infos->nom = 'Sans nom';
             }
             $grvilles_infos->updated_at = date("Y-m-d H:i:s");
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->insert($grvilles_infos);
         }
         $grvilles_gr2ville = _record("regroupements|grvilles_gr2ville");
         $grvilles_gr2ville->id_groupe = $grvilles_infos->id;
         $grvilles_gr2ville->updated_at = $date;
         $grvilles_gr2ville->updated_by = $user['login'];
         foreach ($villes as $ville) {
             if (_request("ville_" . $ville->vil_id_vi) == 1) {
                 $grvilles_gr2ville->id_ville = $ville->vil_id_vi;
                 _dao("regroupements|grvilles_gr2ville")->insert($grvilles_gr2ville);
             }
         }
         if (_request("form_id") == 0) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|', array('groupe' => $grvilles_infos->id)));
         }
     }
     if (_request("groupe")) {
         $tplGrVilles->assign('grvilles_id', _request("groupe"));
         $tplGrVilles->assign('grvilles_form', true);
         if (_request("groupe") > 0) {
             // Edition d'un groupe
             $grvilles_infos = $dao_grvilles->get(_request("groupe"));
             $grvilles_villes_raw = $dao_grvilles_gr2ville->findByGroupe(_request("groupe"));
             // Tableau indexé par id de ville
             $grvilles_villes = array();
             foreach ($grvilles_villes_raw as $grvilles_villes_item) {
                 $grvilles_villes[$grvilles_villes_item->id_ville] = $grvilles_villes_item;
             }
             $tplGrVilles->assign('grvilles_infos', $grvilles_infos);
             $tplGrVilles->assign('grvilles_villes', $grvilles_villes);
         } else {
             // Création d'un nouveau groupe
         }
     }
     $grvilles_list = $dao_grvilles->findAll();
     // print_r($grvilles_list);
     $tplGrVilles->assign('grvilles_list', $grvilles_list);
     $main = $tplGrVilles->fetch('getgrvilles.tpl');
     $tpl->assign('MAIN', $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Input:    name     = (required  name of the select box
  *           id       = (optional) id of SELECT element.
  *           values   = (optional) values to display the values captions will be
  *                        html_escaped, not the ids
  *           selected = (optional) id of the selected element
  *           assign   = (optional) name of the template variable we'll assign
  *                      the output to instead of displaying it directly
  *           emptyValues = id / value for the empty selection
  *           emptyShow   = [true] / false - wether to show or not the "emptyString"
  *           objectMap   = (optional) if given idProperty;captionProperty
  *           extra = (optional) if given, will be added directly in the select tag
  */
 public function process($pParams, $pContent = null)
 {
     extract($pParams);
     //input check
     if (empty($name)) {
         throw new CopixTemplateTagException("[plugin copixselect] parameter 'name' cannot be empty");
     }
     if (!empty($objectMap)) {
         $tab = explode(';', $objectMap);
         if (count($tab) != 2) {
             throw new CopixTemplateTagException("[plugin copixselect] parameter 'objectMap' must looks like idProp;captionProp");
         }
         $idProp = $tab[0];
         $captionProp = $tab[1];
         $shortCaptionProp = $captionProp;
         if (isset($tab[2])) {
             $shortCaptionProp = $tab[2];
         }
     }
     if (empty($extra)) {
         $extra = '';
     }
     if (empty($id)) {
         $id = $name;
     }
     if (empty($values)) {
         $values = array();
     }
     if (!is_array($values) && !$values instanceof Iterator) {
         $values = (array) $values;
     }
     if (empty($zIndex)) {
         $zIndex = '1000';
     }
     if (empty($heightDiv)) {
         $heightDiv = 'auto';
     } else {
         $heightDiv = intval($heightDiv) . 'px';
     }
     if (empty($widthDiv)) {
         $widthDiv = 'auto';
     } else {
         $widthDiv = intval($widthDiv) . 'px';
     }
     if (empty($width)) {
         $width = 'auto';
     } else {
         $width = intval($width) . 'px';
     }
     if (!isset($img)) {
         $img = 'img/tools/multiple.gif';
     }
     if (!isset($selected)) {
         $selected = '';
     }
     if (!isset($selectedIsIdentical)) {
         $selectedIsIdentical = false;
     }
     if (!isset($class)) {
         $class = 'copixselect';
     }
     $js = new CopixJSWidget();
     $toReturn = "\n        <span id='clicker_{$id}'>\n            <input id='caption{$id}' name='caption{$name}' type='text' readonly='readonly' class='{$class}' style='width:{$width};cursor:default;text-align:left;padding-left:3px;height:13px;' value ='' /><img src=" . CopixUrl::getResource('img/tools/multiple.gif') . " align='absbottom' vspace='1' alt='' />\n            <input id='{$id}' name='{$name}' type='hidden' class='{$class}' value ='{$selected}' />\n        </span>\n        <div class='{$class}' style='position:absolute;z-index:{$zIndex};display:none;width:{$widthDiv};height:{$heightDiv}' id='div{$id}'>\n            <table class='{$class}' style='width:{$widthDiv};'>";
     //each of the values.s
     $arValues = array();
     $toReturnValue = '';
     $event = "onmouseover = \"\$(this).setStyle('cursor','pointer');\$(this).setStyle ('background-color','#AAAAAA');\" onmouseout = \"\$(this).setStyle('background-color','white');\" onclick =\" \$('{$id}').value = \$(this).getProperty('rel');\$('caption{$id}').value = \$(this).innerHTML;\$('caption{$id}').fireEvent ('mouseleavezone');\" ";
     if (empty($objectMap)) {
         $arValues = $values;
         $compteur = 0;
         foreach ($values as $key => $caption) {
             if ($selectedIsIdentical && $selected === $key || !$selectedIsIdentical && $selected == $key) {
                 $js->_("caption" . $id)->value = $caption;
             }
             $toReturn .= "<tr>\n                                <td class='{$id}' rel='{$key}' " . $event . " >{$values}</td>\n                            </tr>";
         }
     } else {
         //if given an object mapping request.
         $compteur = 0;
         foreach ($values as $object) {
             if ($selectedIsIdentical && $selected === $object->{$idProp} || !$selectedIsIdentical && $selected == $object->{$idProp}) {
                 $js->_("caption" . $id)->value = $object->{$shortCaptionProp};
             }
             $arValues[$object->{$idProp}] = $object->{$captionProp};
             $toReturn .= "<tr>\n                                <td class='{$id}' rel='" . $object->{$idProp} . "' " . $event . " >" . $arValues[$object->{$idProp}] . "</td>\n                            </tr>";
         }
     }
     $toReturn .= "</table>\n        </div>";
     _tag('mootools', array('plugin' => array('zone', 'overlayfix')));
     CopixHTMLHeader::addCSSLink(_resource('styles/taglib/copixselect.css'), array('id' => 'taglib_copix_select_css'));
     CopixHTMLHeader::addJSLink(_resource('js/taglib/copixselect.js'));
     $js->selectoverload($id);
     CopixHTMLHeader::addJSDOMReadyCode($js);
     return $toReturn;
 }