/**
     * Déclare la fonction getHTTPObject () dans l'en tête HTML.
     * @param mixed $pParams aucun paramètre attendu ici.
     */
    public function process($pParams, $pContent = null)
    {
        static $called = false;
        if (!$called) {
            CopixHTMLHeader::addJSCode('function getHTTPObject()
{
  var xmlhttp = false;
  /*@cc_on
  @if (@_jscript_version >= 5)
     try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     }catch (e){
        try{
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch (E) {
           xmlhttp = false;
        }
     }
  @else
     xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != "undefined"){
     try{
        xmlhttp = new XMLHttpRequest();
     }catch (e){
        xmlhttp = false;
     }
  }
  return xmlhttp;
}', 'getHTTPObject');
            $called = true;
        }
    }
 /**
  * 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);
 }
 public function process($pParams, $content)
 {
     extract($pParams);
     if (!isset($name)) {
         throw new CopixTemplateTagException("Manque nom");
     }
     $toReturn = "<div id=\"wiki_toolbar\" style=\"clear:both\">\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('**','**','" . _i18n("wiki|wiki.bold") . "');\" title=\"" . _i18n("wiki|wiki.bold") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/bold.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('//','//','" . _i18n("wiki|wiki.italic") . "');\" title=\"" . _i18n("wiki|wiki.italic") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/italic.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('__','__','" . _i18n("wiki|wiki.underline") . "');\" title=\"" . _i18n("wiki|wiki.underline") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/underline.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('   *','','" . _i18n("wiki|wiki.listitem") . "');\" title=\"" . _i18n("wiki|wiki.listitem") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/list.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('<del>','</del>','" . _i18n("wiki|wiki.strike") . "');\" title=\"" . _i18n("wiki|wiki.strike") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/strike.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('\n----\n','','');\" title=\"" . _i18n("wiki|wiki.hr") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/hr.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:fontStyle('\\'\\'','\\'\\'','" . _i18n("wiki|wiki.code") . "');\" title=\"" . _i18n("wiki|wiki.code") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/code.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(1);\" title=\"" . _i18n("wiki|wiki.header", 1) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h1.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(2);\" title=\"" . _i18n("wiki|wiki.header", 2) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h2.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(3);\" title=\"" . _i18n("wiki|wiki.header", 3) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h3.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(4);\" title=\"" . _i18n("wiki|wiki.header", 4) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h4.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:addHeader(5);\" title=\"" . _i18n("wiki|wiki.header", 5) . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/h5.png') . "\" /></a>\n";
     $toReturn .= "<a class=\"wiki_toolbar\" onclick=\"javascript:sendForPreview();\" title=\"" . _i18n("wiki|wiki.show.preview") . "\"><img src=\"" . CopixUrl::getResource('/img/modules/wiki/preview.png') . "\" /></a>\n";
     $toReturn .= "</div>";
     $toReturn .= "\n<textarea class=\"noresizable\" id=\"wiki_area_content\" name=\"{$name}\"\n    cols=\"100\" rows=\"30\">{$content}\n</textarea>\n<div id=\"aj_wiki_prev\" style=\"display: none\">\n</div>\n\n        ";
     $urlofrenderer = _url('generictools|ajax|getwikipreview');
     CopixHTMLHeader::addJsCode("\nvar onPreviewMode = false;\nfunction sendForPreview()\n{\n    if(!onPreviewMode){\n        var borders=\$('wiki_area_content').getStyle('border');\n        var width=\$('wiki_area_content').getStyle('width');\n        \$('aj_wiki_prev').setStyles({\n            'border': borders,\n            'width' : width\n        });\n        var aj = new Ajax('" . $urlofrenderer . "',{\n            method : 'post',\n            update :'aj_wiki_prev',\n            data : 'torender='+\$('wiki_area_content').value\n        }).request();\n        onPreviewMode = true;\n        \$('wiki_area_content').setStyle('display','none')\n        \$('aj_wiki_prev').setStyle('display','block')\n    }else{\n        \$('wiki_area_content').setStyle('display','block');\n        \$('aj_wiki_prev').setStyle('display','none');\n        onPreviewMode = false;\n    }\n}\n\nfunction addHeader(n)\n{\n    var h=\"\";\n    if(n==1) h=\"======\";\n    if(n==2) h=\"=====\";\n    if(n==3) h=\"====\";\n    if(n==4) h=\"===\";\n    if(n==5) h=\"==\";\n\n    var editor = document.getElementById('wiki_area_content');\n    fontStyle(h+\" \",\" \"+h,\"Header\"+n);\n}\n\n/**\n * apply tagOpen/tagClose to selection in textarea, use sampleText instead\n * of selection if there is none copied and adapted from phpBB\n *\n * @author phpBB development team\n * @author MediaWiki development team\n * @author Andreas Gohr <*****@*****.**>\n * @author Jim Raynor <*****@*****.**>\n */\nfunction fontStyle(tagOpen, tagClose, sampleText)\n{\n  var txtarea = document.getElementById('wiki_area_content');\n  // IE\n  if(document.selection  && !is_gecko) {\n    var theSelection = document.selection.createRange().text;\n    var replaced = true;\n    if(!theSelection){\n      replaced = false;\n      theSelection=sampleText;\n    }\n    txtarea.focus();\n\n    // This has change\n    text = theSelection;\n    if(theSelection.charAt(theSelection.length - 1) == \" \"){// exclude ending space char, if any\n      theSelection = theSelection.substring(0, theSelection.length - 1);\n      r = document.selection.createRange();\n      r.text = tagOpen + theSelection + tagClose + \" \";\n    } else {\n      r = document.selection.createRange();\n      r.text = tagOpen + theSelection + tagClose;\n    }\n    if(!replaced){\n      r.moveStart('character',-text.length-tagClose.length);\n      r.moveEnd('character',-tagClose.length);\n    }\n    r.select();\n  // Mozilla\n  } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {\n    var replaced = false;\n    var startPos = txtarea.selectionStart;\n    var endPos   = txtarea.selectionEnd;\n    if(endPos - startPos) replaced = true;\n    var scrollTop=txtarea.scrollTop;\n    var myText = (txtarea.value).substring(startPos, endPos);\n    if(!myText) { myText=sampleText;}\n    if(myText.charAt(myText.length - 1) == \" \"){ // exclude ending space char, if any\n      subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + \" \";\n    } else {\n      subst = tagOpen + myText + tagClose;\n    }\n    txtarea.value = txtarea.value.substring(0, startPos) + subst +\n                    txtarea.value.substring(endPos, txtarea.value.length);\n    txtarea.focus();\n\n    //set new selection\n    //modified by Patrice Ferlet\n    // - selection wasn't good for selected text replaced\n    txtarea.selectionStart=startPos+tagOpen.length;\n    txtarea.selectionEnd=startPos+tagOpen.length+myText.length;\n\n    txtarea.scrollTop=scrollTop;\n  // All others\n  } else {\n    var copy_alertText=alertText;\n    var re1=new RegExp(\"\\\$1\",\"g\");\n    var re2=new RegExp(\"\\\$2\",\"g\");\n    copy_alertText=copy_alertText.replace(re1,sampleText);\n    copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);\n    var text;\n    if (sampleText) {\n      text=prompt(copy_alertText);\n    } else {\n      text=\"\";\n    }\n    if(!text) { text=sampleText;}\n    text=tagOpen+text+tagClose;\n    //append to the end\n    txtarea.value += text;\n\n    // in Safari this causes scrolling\n    if(!is_safari) {\n      txtarea.focus();\n    }\n\n  }\n  // reposition cursor if possible\n  if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();\n}\n        ");
     return $toReturn;
 }
 public function process($pParams)
 {
     // paramètres requis
     $requestedParameters = array('form', 'submit', 'divErrors', 'urlVerif', 'urlSubmit');
     foreach ($requestedParameters as $param) {
         if (!isset($pParams[$param])) {
             throw new CopixTemplateTagException(_i18n('copix:copix.smarty.badTagParamValue', array('null', $param, 'ajax_submitform')));
         }
     }
     // on a besoin de mootools
     _tag('mootools');
     // code javascript
     $jsCode = '
         window.addEvent(\'domready\', function(){
             $(\'' . $pParams['submit'] . '\').addEvent(\'click\', function(e) {
                 $(\'' . $pParams['submit'] . '\').disabled = true;
                 $(\'' . $pParams['form'] . '\').action = \'' . _url($pParams['urlVerif']) . '\';
                 new Event (e).stop ();
                 $(\'' . $pParams['form'] . '\').send ({
                     update: $(\'formErrors\'),
                     onComplete: function (response) {
                         if (response == \'true\') {
                             $(\'' . $pParams['form'] . '\').action = \'' . _url($pParams['urlSubmit']) . '\';
                             $(\'' . $pParams['form'] . '\').submit ();
                         } else {
                             $(\'' . $pParams['submit'] . '\').disabled = false;
                         }
                     },
                 });
             });
         });';
     CopixHTMLHeader::addJSCode($jsCode, 'ajax_submitform_' . $pParams['form']);
 }
 /**
  * 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);
 }
 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);
     }
 }
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;
}
 public function process($pParams, $pContent = null)
 {
     $toReturn = '    ' . $pContent . '<br /><br />';
     $toReturn .= '    <a href="' . CopixUrl::get($pParams['yes']) . '">' . _i18n('copix:common.buttons.yes') . '</a>';
     $toReturn .= '    <a href="' . CopixUrl::get($pParams['no']) . '">' . _i18n('copix:common.buttons.no') . '</a>';
     _tag('mootools');
     CopixHTMLHeader::addJsCode("\n        window.addEvent('domready', function () {\n            var elem = new Element('div');\n            elem.setStyles({'z-index':99999,'background-color':'white','border':'1px solid black','width':'200px','height':'100px','top': window.getScrollTop().toInt()+window.getHeight ().toInt()/2-100+'px','left':window.getScrollLeft().toInt()+window.getWidth ().toInt()/2-100+'px','position':'absolute','text-align':'center'});\n            elem.setHTML ('{$toReturn}');\n            elem.injectInside(document.body);\n\n        });\n\n        ");
     return null;
 }
 public function process($pParams)
 {
     extract($pParams);
     if (!isset($name)) {
         throw new CopixTemplateTagException('[AutoComplete] Required parameter name');
     }
     if (!isset($field)) {
         $field = $name;
     }
     if (!isset($id)) {
         $id = $name;
     }
     if (!isset($value)) {
         $value = "";
     }
     if (!isset($onSelect)) {
         $onSelect = "";
     }
     if (!isset($onRequest)) {
         $onRequest = '';
     }
     if (!isset($extra)) {
         $extra = '';
     }
     if (!isset($pParams['datasource'])) {
         $pParams['datasource'] = 'dao';
     }
     $toMaj = '';
     $onSelectTemp = '';
     if (isset($maj)) {
         $onSelectTemp .= "eleme.selected.id = 'selector_autocomplete';";
         foreach ($maj as $key => $field) {
             $onSelectTemp .= "\n                        \$\$('#selector_autocomplete .{$key}').each (function (el) {\n                            \$('{$field}').value = el.innerHTML;\n                        });\n                    ";
             $toMaj .= $key . ';';
         }
     }
     $onSelect = $onSelectTemp . $onSelect;
     $url = 'generictools|ajax|getAutoComplete';
     if (isset($pParams['url'])) {
         $url = $pParams['url'];
     }
     $length = isset($length) ? $length : 1;
     $pParams['view'] = isset($pParams['view']) ? $pParams['view'] : $field;
     $tab = array();
     foreach ($pParams as $key => $param) {
         $tab[$key] = $param;
     }
     $tab['nb'] = 10;
     $tab['tomaj'] = $toMaj;
     $js = new CopixJSWidget();
     $js->tag_autocomplete($id, $name, $length, $tab, _url($url), $js->function_(null, 'el', $onRequest), $js->function_(null, 'el,eleme,element', $onSelect));
     CopixHTMLHeader::addJSDOMReadyCode($js);
     CopixHTMLHeader::addJSLink(_resource('js/taglib/tag_autocomplete.js'));
     _eTag("mootools", array('plugin' => "observer;autocompleter"));
     $toReturn = '<input type="text" id="' . $name . '" name="' . $name . '" value="' . $value . '" ' . $extra . ' /><span id="autocompleteload_' . $name . '"><img src="' . CopixUrl::getResource('img/tools/load.gif') . '" /></span>';
     return $toReturn;
 }
/**
* Plugin smarty type fonction
* Purpose: adds a favicon to the page (in the HTML Header)
*
* Input:    src = the image source
* Examples:
* {favicon src='./img/copix/favicon.ico' }
*/
function smarty_function_favicon($params, &$me)
{
    extract($params);
    //are there any values given ?
    if (empty($src)) {
        $me->_trigger_fatal_error("[plugin favicon] parameter 'src' cannot be empty");
        return;
    }
    CopixHTMLHeader::addFavIcon($src);
}
Ejemplo n.º 11
0
 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"));
     }
 }
 /**
  * Construction de l'input
  * @param	mixed	$pParams	tableau de paramètre ou clef
  * @param 	mixed	$pContent
  * @return 	string	l'input fabriqué
  * 	Paramètres recommandés :
  * 		id : identifiant utile pour les labels, le javascript..
  * 		name : nom de l'input utile pour récupérer sa valeur avec php
  *
  * 	Autres paramètres (liste non exhaustive)
  * 		value : valeur à afficher
  * 		maxlength : nombre de caractères maximals
  * 		size : taille de l'input affiché
  * 		next : zone suivante qui prendra le focus lorsque maxlenght sera atteind
  * 		previous : zone précédente qui prendra le focus lorsque tous les caratères seront effacés
  * 		(ces deux derniers paramètres sont gérés à l'aide de javascript)
  */
 public function process($pParams)
 {
     extract($pParams);
     if (!isset($pParams['id']) && !isset($pParams['name'])) {
         throw new CopixTagException("[CopixTagInput] Missing id or name parameter");
     }
     if (!isset($pParams['id'])) {
         $pParams['id'] = $pParams['name'];
     } elseif (!isset($pParams['name'])) {
         $pParams['name'] = $pParams['id'];
     }
     $readonly = '';
     if (isset($pParams['readonly'])) {
         if ($pParams['readonly']) {
             $readonly = 'readonly="readonly"';
         }
         unset($pParams['readonly']);
     }
     if (isset($pParams['value']) && !empty($pParams['value'])) {
         $pParams['value'] = htmlspecialchars($pParams['value'], ENT_QUOTES);
     }
     if (!isset($extra)) {
         $extra = '';
     } else {
         unset($pParams['extra']);
     }
     $toReturn = '<input type="text" ' . $readonly . ' ' . $extra . ' ';
     foreach ($pParams as $key => $param) {
         if ($key != 'next' && $key != 'previous') {
             $toReturn .= $key . '="' . $param . '" ';
         }
     }
     if (!isset($maxlength)) {
         $maxlength = '1';
     }
     if (isset($next) && $next != null && $maxlength != null || isset($previous) && $previous != null) {
         CopixHTMLHeader::addJSLink(_resource('js/taglib/tag_inputtext.js'));
         if (!isset($previous)) {
             $previous = 'null';
         }
         if (!isset($next)) {
             $next = '';
         }
         if ($next == 'true') {
             $toReturn .= 'onKeyDown="javascript:autofocus(this,' . $maxlength . ',event,\'' . $previous . '\');" ';
         } else {
             $toReturn .= 'onKeyDown="javascript:focusid(this,' . $maxlength . ',event,\'' . $next . '\',\'' . $previous . '\');" ';
         }
     }
     $toReturn .= ' />';
     return $toReturn;
 }
Ejemplo n.º 13
0
 /**
  * Affiche la série de boutons permettant à l'utilisateur de mettre en forme simplement le texte qu'il saisit dans une zone de texte libre.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2007/05/22
  * @param string $field Nom du champ dans le formulaire.
  * @param string $format Format à utiliser (html, wiki...)
  * @param string $content Contenu "brut" saisi
  * @param array $objet (option) Module dans lequel se trouve la zone d'édition, dans un tableau indexé avec TYPE et ID (exemple: type=>MOD_BLOG, id=>4). Si positionné, on va vérifier si le parent de cet objet a un album photos, et si oui on affiche le lien vers l'album photos en mode popup
  * @param integer $width (option) Largeur de la zone de saisie
  * @param integer $height (option) Hauteur de la zone de saisie
  * @param array $options (option) Options permettant de personnaliser la zone
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $field = $this->getParam('field', NULL);
     $format = $this->getParam('format', NULL);
     $content = $this->getParam('content', NULL);
     $object = $this->getParam('object', array());
     $width = $this->getParam('width', 650);
     $height = $this->getParam('height', 300);
     $class = $this->getParam('class');
     $options = $this->getParam('options', array());
     $html = '';
     if ($field && $format) {
         if ('USER' === $object) {
         } else {
             $object_type = isset($object['type']) ? $object['type'] : null;
             $object_id = isset($object['id']) ? $object['id'] : null;
             $object = $object_type && $object_id ? array('type' => $object_type, 'id' => $object_id) : null;
         }
         switch ($format) {
             case "wiki":
                 $tpl->assign('wikibuttons', CopixZone::process('kernel|wikibuttons', array('field' => $field, 'format' => $format, 'object' => $object)));
                 break;
             case "html":
                 $tpl->assign('wikibuttons', CopixZone::process('kernel|wikibuttons', array('field' => $field, 'format' => $format, 'object' => $object)));
                 break;
             case "htmlnl2br":
                 $tpl->assign('wikibuttons', CopixZone::process('kernel|wikibuttons', array('field' => $field, 'format' => $format, 'object' => $object)));
                 break;
             case "dokuwiki":
                 $tpl->assign('wikibuttons', CopixZone::process('kernel|wikibuttons', array('field' => $field, 'format' => $format, 'object' => $object)));
                 break;
             case "fckeditor":
             case "ckeditor":
                 CopixHTMLHeader::addJSLink(_resource('js/ckeditor/ckeditor.js'));
                 CopixHTMLHeader::addJSLink(_resource('js/ckeditor/config.js'));
                 $tpl->assign('wikibuttons', CopixZone::process('kernel|wikibuttons', array('field' => $field, 'format' => 'ckeditor', 'object' => $object)));
                 break;
         }
         $tpl->assign('field', $field);
         $tpl->assign('format', $format);
         $tpl->assign('content', $content);
         $tpl->assign('width', $width);
         $tpl->assign('height', $height);
         $tpl->assign('class', $class);
         $tpl->assign('options', $options);
     }
     //_dump($options);
     $toReturn = $tpl->fetch('zone.edition.tpl');
     return true;
 }
/**
 * Plugin smarty type fonction
 * init for tooltip function plugin
 * Part of tooltip package, written by Laurent Jouanneau
 * http://ljouanneau.com/softs/javascript/
 * use :
 *  {tooltipinit}
 *  {tooltipinit path="path_to_tooltip.js"}
 *
 */
function smarty_function_tooltipinit($params, &$smarty)
{
    static $tooltipinit = 0;
    if ($tooltipinit == 0 || isset($params['force'])) {
        extract($params);
        if (!isset($path)) {
            $path = 'js/';
        }
        CopixHTMLHeader::addJSLink($path . 'tooltip.js');
        $tooltipinit = 1;
        return '<div id="tooltip"></div>';
    } else {
        return '';
    }
}
 /**
  * Déclare la fonction getHTTPObject () dans l'en tête HTML.
  * @param mixed $pParams aucun paramètre attendu ici.
  */
 public function process($pParams, $pContent = null)
 {
     $pluginList = null;
     // Charge les plugins demandés
     if (isset($pParams['plugins'])) {
         $pParams['plugin'] = $pParams['plugins'];
     }
     if (isset($pParams['plugin'])) {
         $pluginList = $pParams['plugin'];
         if (!is_array($pluginList)) {
             $pluginList = explode(';', $pluginList);
         }
     }
     CopixHTMLHeader::addJSFramework($pluginList);
 }
 public function process($pParams, $pContent = null)
 {
     $tabGroupId = $this->getParam('id', uniqid('tab'));
     $tabs = $this->requireParam('tabs', null, array());
     $groupClass = $this->getParam('groupClass', '');
     $tabClass = $this->getParam('tabClass', '');
     $selectedClass = $this->getParam('selectedClass', 'tabSelected');
     $onSelect = $this->getParam('onSelect', null, 'string');
     $onUnselect = $this->getParam('onUnselect', null, 'string');
     $default = $this->getParam('default');
     $this->validateParams();
     if ($default && !isset($tabs[$default])) {
         _log('[tag tabgroup] invalid default for tabgroup ' . $tabGroupId . ': ' . $default, 'errors');
         $default = null;
     }
     $toReturn = array();
     $toReturn[] = sprintf('<div class="tabGroup %s" id="%s">', $groupClass, $tabGroupId);
     $tabIds = array();
     $tabKeys = array();
     $i = 0;
     $tabIndexes = array();
     foreach ($tabs as $key => $caption) {
         $tabId = $tabGroupId . '_tab' . $i;
         //preg_replace('/[^\w]/', '_', $key);
         //$tabIds[$tabId] = $key;
         $elementIds[$key] = $tabId;
         $tabIndexes[$key] = $i++;
         $toReturn[] = sprintf('<span class="tabCaption %s %s" id="%s">%s</span>', $tabClass, $key == $default ? $selectedClass : '', $tabId, _copix_utf8_htmlentities($caption));
     }
     $toReturn[] = '</div>';
     CopixHTMLHeader::addJSLink(_resource('js/taglib/tabgroup.js'), array('id' => 'taglib_tabgroup_js'));
     $params = array('id' => $tabGroupId, 'selectedClass' => $selectedClass, 'tabs' => array_keys($tabs));
     if ($default) {
         $params['defaultTab'] = $tabIndexes[$default];
     }
     $js = new CopixJSWidget();
     if ($onSelect) {
         $params['onSelect'] = $js->function_(null, 'tabId', $onSelect);
     }
     if ($onUnselect) {
         $params['onUnselect'] = $js->function_(null, 'tabId', $onUnselect);
     }
     $js->Copix->registerTabGroup($params);
     CopixHTMLHeader::addJSDOMReadyCode($js);
     return implode("\n", $toReturn);
 }
 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;
 }
 public function beforeAction($actionName)
 {
     CopixHTMLHeader::addJSLink(_resource('js/iconito/module_cahierdetextes.js'));
     // Contrôle d'accès au module
     if (Kernel::getLevel('MOD_CAHIERDETEXTES', _request('cahierId', _request('id', null))) < PROFILE_CCV_READ) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get()));
     } elseif (Kernel::getLevel('MOD_CAHIERDETEXTES', _request('cahierId', _request('id', null))) == PROFILE_CCV_READ) {
         if ($actionName == "processVoirTravaux" && is_null($eleve = _request('eleve', null))) {
             $myNode = CopixSession::get('myNode');
             $eleve = $myNode['type'] == "USER_ELE" ? $myNode['id'] : null;
         } else {
             $eleve = _request('eleve', null);
         }
         if (is_null($eleve) && $actionName != 'go') {
             return CopixActionGroup::process('generictools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.errorOccurred'), 'back' => CopixUrl::get('')));
         }
     }
 }
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);
 }
Ejemplo n.º 21
0
 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;
 }
 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');
 }
 /**
  * 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);
     }
 }
 public function beforeAction()
 {
     _currentUser()->assertCredential('group:[current_user]');
     CopixHTMLHeader::addCSSLink(_resource("styles/module_visio.css"));
 }
 public function getGroup()
 {
     if (!Kernel::isAdmin()) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     }
     $tpl = new CopixTpl();
     $tplGrVilles = new CopixTpl();
     CopixHTMLHeader::addCSSLink(_resource("styles/module_regroupements.css"));
     $regroupements_service =& CopixClassesFactory::Create('regroupements|regroupements');
     $tpl->assign('TITLE_PAGE', CopixI18N::get('regroupements|regroupements.villes.titre'));
     $tpl->assign('MENU', $regroupements_service->getMenu());
     $dao_grvilles_gr2ville = CopixDAOFactory::create("regroupements|grvilles_gr2ville");
     $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles");
     $dao_villes = CopixDAOFactory::create("kernel|kernel_tree_vil");
     $villes = $dao_villes->findAll();
     $tplGrVilles->assign('villes', $villes);
     if (_request("delete")) {
         $dao_grvilles->delete(_request("delete"));
         $dao_grvilles_gr2ville->deleteByGroupe(_request("delete"));
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|'));
     }
     if (_request("save") && _request("save") == 1) {
         $date = date("Y-m-d H:i:s");
         $user = Kernel::getUserInfo();
         if (_request("form_id") > 0) {
             $grvilles_infos = $dao_grvilles->get(_request("form_id"));
             $grvilles_infos->nom = _request("form_nom");
             $grvilles_infos->updated_at = $date;
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->update($grvilles_infos);
             $dao_grvilles_gr2ville->deleteByGroupe(_request("form_id"));
         } else {
             $grvilles_infos = CopixDAOFactory::createRecord("regroupements|grvilles");
             $grvilles_infos->nom = _request("form_nom");
             if ($grvilles_infos->nom == '') {
                 $grvilles_infos->nom = 'Sans nom';
             }
             $grvilles_infos->updated_at = date("Y-m-d H:i:s");
             $grvilles_infos->updated_by = $user['login'];
             $dao_grvilles->insert($grvilles_infos);
         }
         $grvilles_gr2ville = _record("regroupements|grvilles_gr2ville");
         $grvilles_gr2ville->id_groupe = $grvilles_infos->id;
         $grvilles_gr2ville->updated_at = $date;
         $grvilles_gr2ville->updated_by = $user['login'];
         foreach ($villes as $ville) {
             if (_request("ville_" . $ville->vil_id_vi) == 1) {
                 $grvilles_gr2ville->id_ville = $ville->vil_id_vi;
                 _dao("regroupements|grvilles_gr2ville")->insert($grvilles_gr2ville);
             }
         }
         if (_request("form_id") == 0) {
             return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|', array('groupe' => $grvilles_infos->id)));
         }
     }
     if (_request("groupe")) {
         $tplGrVilles->assign('grvilles_id', _request("groupe"));
         $tplGrVilles->assign('grvilles_form', true);
         if (_request("groupe") > 0) {
             // Edition d'un groupe
             $grvilles_infos = $dao_grvilles->get(_request("groupe"));
             $grvilles_villes_raw = $dao_grvilles_gr2ville->findByGroupe(_request("groupe"));
             // Tableau indexé par id de ville
             $grvilles_villes = array();
             foreach ($grvilles_villes_raw as $grvilles_villes_item) {
                 $grvilles_villes[$grvilles_villes_item->id_ville] = $grvilles_villes_item;
             }
             $tplGrVilles->assign('grvilles_infos', $grvilles_infos);
             $tplGrVilles->assign('grvilles_villes', $grvilles_villes);
         } else {
             // Création d'un nouveau groupe
         }
     }
     $grvilles_list = $dao_grvilles->findAll();
     // print_r($grvilles_list);
     $tplGrVilles->assign('grvilles_list', $grvilles_list);
     $main = $tplGrVilles->fetch('getgrvilles.tpl');
     $tpl->assign('MAIN', $main);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 public function 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);
 }
 /**
  * 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);
 }
 /**
  * Affichage de l'annuaire en version popup
  *
  * Affiche les discussions d'un forum et les informations sur les discussions (titre, dernier message...), avec un lien pour lire chaque discussion.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/18
  */
 public function getPopup()
 {
     if (!Kernel::is_connected()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('annuaire|annuaire.error.noLogged'), 'back' => CopixUrl::get('||')));
     }
     CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire_popup.js"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.tablesorter.min.js"));
     CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.metadata.js"));
     CopixHTMLHeader::addCSSLink(_resource("js/jquery/css/jquery.tablesorter.css"));
     $grville = _request('grville') ? _request('grville') : NULL;
     $ville = _request('ville') ? _request('ville') : NULL;
     $ecole = _request('ecole') ? _request('ecole') : NULL;
     $classe = _request('classe') ? _request('classe') : NULL;
     $field = _request('field') ? _request('field') : '';
     $profils = _request('profils') ? _request('profils') : array();
     $profil = $this->getRequest('profil');
     // Si on force sur un profil unique a afficher
     $ALL = CopixConfig::get('annuaire|annu_combo_all');
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     // Annuaire par défaut, on regarde sa session
     if (!$classe && !$ecole && !$ville) {
         $home = $annuaireService->getAnnuaireHome();
         //print_r($home);
         switch ($home['type']) {
             case 'BU_GRVILLE':
                 $grville = $home['id'];
                 $ville = $ALL;
                 $ecole = $ALL;
                 $classe = $ALL;
                 break;
             case 'BU_VILLE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 if ($info) {
                     $grville = $info['ALL']->vil_id_grville;
                 }
                 $ville = $home['id'];
                 $ecole = $ALL;
                 $classe = $ALL;
                 break;
             case 'BU_ECOLE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 if ($info) {
                     $grville = $info['ALL']->vil_id_grville;
                     $ville = $info['ALL']->eco_id_ville;
                 }
                 $ecole = $home['id'];
                 $classe = $ALL;
                 break;
             case 'BU_CLASSE':
                 $info = Kernel::getNodeInfo($home['type'], $home['id']);
                 //_dump($info);
                 if ($info) {
                     $grville = $info['parent']['ALL']->vil_id_grville;
                     $ville = $info['parent']['ALL']->eco_id_ville;
                     $ecole = $info['parent']['id'];
                 }
                 $classe = $home['id'];
                 //echo "grville=$grville / ville=$ville / ecole=$ecole / classe=$classe";
                 break;
         }
     }
     $comboEcoles = $comboClasses = true;
     // On force les valeurs des combos
     if ($profil) {
         switch ($profil) {
             case 'USER_VIL':
                 $comboEcoles = $comboClasses = false;
                 $ecole = $classe = $ALL;
                 break;
         }
     }
     $matrix =& enic::get('matrixCache');
     $helper =& enic::get('matrixHelpers');
     $right = _request('right', 'voir');
     // voir ou communiquer
     $iCan = 'communiquer' == $right ? 'iCanTalkToThisType' : 'iCanSeeThisType';
     $tplListe = new CopixTpl();
     $visib = array('USER_ELE' => $helper->{$iCan}('USER_ELE'), 'USER_ENS' => $helper->{$iCan}('USER_ENS') || $helper->{$iCan}('USER_DIR'), 'USER_RES' => $helper->{$iCan}('USER_RES'), 'USER_EXT' => $helper->{$iCan}('USER_EXT'), 'USER_ADM' => $helper->{$iCan}('USER_ADM'), 'USER_VIL' => $helper->{$iCan}('USER_VIL'));
     //_dump($visib);
     $debug = false;
     $start = microtime(true);
     $tplListe->assign('combogrvilles', CopixZone::process('annuaire|combogrvilles', array('droit' => $right, 'value' => $grville, 'fieldName' => 'grville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_grville(this,this.form);"', 'linesSup' => array())));
     if ($debug) {
         echo "combogrvilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
     }
     $start = microtime(true);
     $tplListe->assign('combovilles', CopixZone::process('annuaire|combovilles', array('droit' => $right, 'grville' => $grville, 'value' => $ville, 'fieldName' => 'ville', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ville(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllVilles'))))));
     if ($debug) {
         echo "combovilles " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
     }
     $start = microtime(true);
     if ($ville == $ALL && $comboEcoles) {
         $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles'))))));
         if ($debug) {
             echo "comboecolesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($comboEcoles) {
         $tplListe->assign('comboecoles', CopixZone::process('annuaire|comboecolesinville', array('droit' => $right, 'ville' => $ville, 'value' => $ecole, 'fieldName' => 'ecole', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_ecole(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllEcoles'))))));
         if ($debug) {
             echo "comboecolesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     }
     $start = microtime(true);
     if ($ville == $ALL && $ecole == $ALL && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesingrville', array('droit' => $right, 'grville' => $grville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesingrville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($ecole == $ALL && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinville', array('droit' => $right, 'ville' => $ville, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesinville " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($ecole && $comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboclassesinecole', array('droit' => $right, 'ecole' => $ecole, 'value' => $classe, 'fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"', 'linesSup' => array(0 => array('value' => $ALL, 'libelle' => CopixI18N::get('annuaire|annuaire.comboAllClasses'))))));
         if ($debug) {
             echo "comboclassesinecole " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     } elseif ($comboClasses) {
         $tplListe->assign('comboclasses', CopixZone::process('annuaire|comboempty', array('fieldName' => 'classe', 'attribs' => 'class="annu_combo_popup" ONCHANGE="change_classe(this,this.form);"')));
         if ($debug) {
             echo "comboempty " . date("H:i:s") . " " . (microtime(true) - $start) . "<br />";
         }
     }
     if ($ville_as_array = Kernel::getKernelLimits('ville_as_array')) {
         // Limitation par URL, on verifie les parametres
         if ($ville && $ville != $ALL && !in_array($ville, $ville_as_array)) {
             $ville = 0;
         }
         if ($ecole && $ecole != $ALL && ($rEcole = Kernel::getNodeInfo('BU_ECOLE', $ecole, false)) && !in_array($rEcole['ALL']->vil_id_grville, $ville_as_array)) {
             $ecole = 0;
         }
         if ($classe && $classe != $ALL && ($rClasse = Kernel::getNodeInfo('BU_CLASSE', $classe, false)) && !in_array($rClasse['ALL']->eco_id_ville, $ville_as_array)) {
             $classe = 0;
         }
     }
     //kernel::myDebug ("grville=$grville / ville=$ville / ecole=$ecole / classe=$classe");
     //kernel::myDebug ($profils);
     if ($classe && $classe !== $ALL) {
         // Une classe précise
         $visib['USER_ELE'] = $matrix->classe($classe)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->classe($classe)->_right->USER_ENS->{$right} || $matrix->classe($classe)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->classe($classe)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->classe($classe)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->classe($classe)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->classe($classe)->_right->USER_VIL->{$right};
     } elseif ($ecole && $classe == $ALL && $ecole !== $ALL) {
         // Une école
         $visib['USER_ELE'] = $matrix->ecole($ecole)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->ecole($ecole)->_right->USER_ENS->{$right} || $matrix->ecole($ecole)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->ecole($ecole)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->ecole($ecole)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->ecole($ecole)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->ecole($ecole)->_right->USER_VIL->{$right};
     } elseif ($ville && $classe == $ALL && $ecole == $ALL && $ville !== $ALL) {
         // Une ville
         $visib['USER_ELE'] = $matrix->ville($ville)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->ville($ville)->_right->USER_ENS->{$right} || $matrix->ville($ville)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->ville($ville)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->ville($ville)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->ville($ville)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->ville($ville)->_right->USER_VIL->{$right};
     } elseif ($grville && $classe == $ALL && $ecole == $ALL && $ville == $ALL) {
         // Un groupe de villes
         $visib['USER_ELE'] = $matrix->grville($grville)->_right->USER_ELE->{$right};
         $visib['USER_ENS'] = $matrix->grville($grville)->_right->USER_ENS->{$right} || $matrix->grville($grville)->_right->USER_DIR->{$right};
         $visib['USER_RES'] = $matrix->grville($grville)->_right->USER_RES->{$right};
         $visib['USER_ADM'] = $matrix->grville($grville)->_right->USER_ADM->{$right};
         $visib['USER_EXT'] = $matrix->grville($grville)->_right->USER_EXT->{$right};
         $visib['USER_VIL'] = $matrix->grville($grville)->_right->USER_VIL->{$right};
     }
     //_dump($visib);
     // Si on restreint a un profil
     if ($profil && $visib[$profil]) {
         switch ($profil) {
             case 'USER_VIL':
                 $profils = array();
                 $profils['VIL'] = 1;
                 break;
         }
     }
     if (!$profils && $visib['USER_ELE']) {
         $profils['ELE'] = 1;
     } elseif (!$profils && $visib['USER_ENS']) {
         $profils['PEC'] = 1;
     } elseif (!$profils && $visib['USER_RES']) {
         $profils['PAR'] = 1;
     } elseif (!$profils && $visib['USER_EXT']) {
         $profils['EXT'] = 1;
     } elseif (!$profils && $visib['USER_ADM']) {
         $profils['ADM'] = 1;
     } elseif (!$profils && $visib['USER_VIL']) {
         $profils['VIL'] = 1;
     }
     //kernel::myDebug($visib);
     // =============== ELEVES =========================
     $eleves = array();
     if (isset($profils['ELE']) && $grville && $ville && $ecole && $classe && $visib['USER_ELE']) {
         if ($classe != $ALL) {
             // Une classe précise
             $eleves = $annuaireService->getEleves('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les eleves d'une école
             $eleves = $annuaireService->getEleves('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les eleves d'une ville
             $eleves = $annuaireService->getEleves('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les eleves d'un groupe de villes
             $eleves = $annuaireService->getEleves('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL =========================
     $personnel = array();
     if (isset($profils['PEC']) && $grville && $ville && $ecole && $classe && $visib['USER_ENS']) {
         if ($classe != $ALL) {
             // Une classe précise
             $personnel = $annuaireService->getPersonnel('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les classes d'une école
             $personnel = $annuaireService->getPersonnel('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $personnel = $annuaireService->getPersonnel('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $personnel = $annuaireService->getPersonnel('BU_GRVILLE', $grville);
         }
     }
     // =============== PARENTS =========================
     $parents = array();
     if (isset($profils['PAR']) && $grville && $ville && $ecole && $classe && $visib['USER_RES']) {
         if ($classe != $ALL) {
             // Une classe précise
             $parents = $annuaireService->getParents('BU_CLASSE', $classe);
         } elseif ($classe == $ALL && $ecole != $ALL) {
             // Les classes d'une école
             $parents = $annuaireService->getParents('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $parents = $annuaireService->getParents('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $parents = $annuaireService->getParents('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL ADMINISTRATIF =========================
     $adm = array();
     if (isset($profils['ADM']) && $grville && $ville && $ecole && $classe && $visib['USER_ADM']) {
         if (($classe != $ALL || $classe == $ALL) && $ecole != $ALL) {
             // Les classes d'une école
             $adm = $annuaireService->getPersonnelAdm('BU_ECOLE', $ecole);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville != $ALL) {
             // Les classes d'une ville
             $adm = $annuaireService->getPersonnelAdm('BU_VILLE', $ville);
         } elseif ($classe == $ALL && $ecole == $ALL && $ville == $ALL) {
             // Les classes d'un groupe de villes
             $adm = $annuaireService->getPersonnelAdm('BU_GRVILLE', $grville);
         }
     }
     // =============== PERSONNEL EXTERIEUR =========================
     $ext = array();
     if (isset($profils['EXT']) && $grville && $ville && $ecole && $classe && $visib['USER_EXT']) {
         $ext = $annuaireService->getPersonnelExt('ROOT', 0);
     }
     // =============== PERSONNEL VILLE =========================
     $vil = array();
     if (isset($profils['VIL']) && $grville && $ville && $visib['USER_VIL']) {
         if ($ville != $ALL) {
             // Dans une ville
             $vil = $annuaireService->getPersonnelVil('BU_VILLE', $ville);
         } elseif ($ville == $ALL) {
             // Dans un groupe de villes
             $vil = $annuaireService->getPersonnelVil('BU_GRVILLE', $grville);
         }
     }
     $droits = array('checkAll' => $annuaireService->canMakeInAnnuaire('POPUP_CHECK_ALL'));
     $users = array();
     foreach ($eleves as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($parents as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($personnel as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($adm as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($vil as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     foreach ($ext as $user) {
         $users[$user->bu_type . '-' . $user->bu_id] = $user;
     }
     //_dump($eleves);
     /*
     if ('communiquer' === $right) {
         foreach ($users as $k => $user) {
             //print_r($user);
             //$matrix->communiquer();
         }
     }
     */
     usort($users, array('ActionGroupAnnuaire', '_usortPopup'));
     $tplListe->assign('field', $field);
     $tplListe->assign('grville', $grville);
     $tplListe->assign('eleves', $eleves);
     $tplListe->assign('personnel', $personnel);
     $tplListe->assign('parents', $parents);
     $tplListe->assign('ext', $ext);
     $tplListe->assign('adm', $adm);
     $tplListe->assign('vil', $vil);
     $tplListe->assign('profils', $profils);
     $tplListe->assign('droits', $droits);
     $tplListe->assign('ville', $ville);
     $tplListe->assign('ecole', $ecole);
     $tplListe->assign('classe', $classe);
     $tplListe->assign('visib', $visib);
     $tplListe->assign('profil', $profil);
     $tplListe->assign('users', $users);
     $tplListe->assign('right', $right);
     $result = $tplListe->fetch('getpopup.tpl');
     $ppo = new CopixPPO();
     $ppo->result = $result;
     $ppo->TITLE_PAGE = CopixI18N::get('annuaire|annuaire.moduleDescription');
     CopixHTMLHeader::addJSLink(_resource("js/iconito/module_annuaire.js"));
     return _arPPO($ppo, array('template' => 'getpopup_ppo.tpl', 'mainTemplate' => 'default|main_popup.php'));
 }
    public function process($pParams, $pContent = null)
    {
        // paramètre id
        if (!isset($pParams['id'])) {
            throw new CopixTemplateTagException(_i18n('copix:taglib.showdiv.missingIdParameter'));
        }
        // paramètre show
        if (!isset($pParams['show'])) {
            $pParams['show'] = true;
        } else {
            $pParams['show'] = $pParams['show'] == 'true' || $pParams['show'] == 1;
        }
        // paramètre captioni18n fourni, qui vaut dans le cas up et le cas down
        if (isset($pParams['captioni18n'])) {
            $pParams['captionup'] = _i18n($pParams['captioni18n']);
            $pParams['captiondown'] = $pParams['captionup'];
            // si on a un paramètre caption qui s'occupe de tout les cas
        } elseif (isset($pParams['caption'])) {
            $pParams['captionup'] = $pParams['caption'];
            $pParams['captiondown'] = $pParams['caption'];
            // paramètres captionupi18n et captiondowni18n, qui valent chacun pour leur cas
        } elseif (isset($pParams['captionupi18n']) && isset($pParams['captiondowni18n'])) {
            $pParams['captionup'] = _i18n($pParams['captionupi18n']);
            $pParams['captiondown'] = _i18n($pParams['captiondowni18n']);
            // pas de paramètre captionup ou captiondown
        } elseif (!isset($pParams['captionup']) || !isset($pParams['captiondown'])) {
            $pParams['captionup'] = null;
            $pParams['captiondown'] = null;
        }
        // paramètre showicon
        $pParams['showicon'] = !isset($pParams['showicon']) || isset($pParams['showicon']) && ($pParams['showicon'] == 'true' || $pParams['showicon'] == 1);
        // paramètre iconup
        $pParams['iconup'] = isset($pParams['iconup']) ? _resource($pParams['iconup']) : _resource('img/tools/way_up.png');
        // paramètre icondown
        $pParams['icondown'] = isset($pParams['icondown']) ? _resource($pParams['icondown']) : _resource('img/tools/way_down.png');
        // code javascript pour afficher / cacher un div
        CopixHTMLHeader::addJsCode('if (!window.smarty_show_div_infos) {
    smarty_show_div_infos = new Array ();
}

function smarty_show_div (id, show)
{
    if (show) {
        img = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'img_up\']) ? smarty_show_div_infos[id][\'img_up\'] : null;
        style = \'\';
        caption = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'caption_up\']) ? smarty_show_div_infos[id][\'caption_up\'] : null;
    } else {
        img = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'img_down\']) ? smarty_show_div_infos[id][\'img_down\'] : null;
        style = \'none\';
        caption = (window.smarty_show_div_infos[id] && window.smarty_show_div_infos[id][\'caption_down\']) ? smarty_show_div_infos[id][\'caption_down\'] : null;
    }

    document.getElementById (id).style.display = style;
    if (document.getElementById (\'img_\' + id) != undefined) {
        document.getElementById (\'img_\' + id).src = img;
        if (caption != null) {
            document.getElementById (\'caption_\' + id).innerHTML = caption;
        }
    }
}

function smarty_invert_show (id)
{
    smarty_show_div (id, (document.getElementById (id).style.display != \'\'));
}', 'smarty_show_div');
        // code JS pour créer le tableau des infos de cet ID
        CopixHTMLHeader::addJsCode('smarty_show_div_infos[\'' . $pParams['id'] . '\'] = new Array ();', 'smarty_show_div_' . $pParams['id']);
        // code JS pour les images
        if ($pParams['showicon'] && !is_null($pParams['iconup']) && !is_null($pParams['icondown'])) {
            CopixHTMLHeader::addJsCode('smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'img_up\'] = \'' . $pParams['iconup'] . '\';' . "\n" . 'smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'img_down\'] = \'' . $pParams['icondown'] . '\';', 'smarty_show_div_img_' . $pParams['id']);
        }
        // code javascript pour les captions
        if (!is_null($pParams['captionup']) && !is_null($pParams['captiondown'])) {
            CopixHTMLHeader::addJsCode('smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'caption_up\'] = \'' . str_replace("'", "\\'", $pParams['captionup']) . '\';' . "\n" . 'smarty_show_div_infos[\'' . $pParams['id'] . '\'][\'caption_down\'] = \'' . str_replace("'", "\\'", $pParams['captiondown']) . '\';', 'smarty_show_div_captions_' . $pParams['id']);
        }
        // création du code HTML
        if ($pParams['showicon'] || !is_null($pParams['captionup']) && !is_null($pParams['captiondown'])) {
            if ($pParams['show']) {
                $imgSrc = $pParams['iconup'];
                $caption = $pParams['captionup'];
            } else {
                $imgSrc = $pParams['icondown'];
                $caption = $pParams['captiondown'];
            }
            $out = '<a href="javascript: smarty_invert_show (\'' . $pParams['id'] . '\');">';
            // si on veut afficher un icon
            if ($pParams['showicon']) {
                $out .= '<img id="img_' . $pParams['id'] . '" src="' . $imgSrc . '" style="cursor:pointer" alt="showdiv" />';
            }
            // si on veut afficher un caption
            if (!is_null($caption)) {
                $out .= ' <span id="caption_' . $pParams['id'] . '">' . $caption . "</span>";
            }
            $out .= '</a>';
        } else {
            $out = null;
        }
        return $out;
    }
 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');
 }