public function getSso()
 {
     $id = $this->getRequest('id', null);
     if (!$id) {
         // Récupération des infos de l'utilisateur.
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_SSO" && $modInfo->module_id) {
                 $urlReturn = CopixUrl::get('sso||getSso', array('id' => $modInfo->module_id));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             }
         }
     }
     if (!$id) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => 'Problème', 'back' => CopixUrl::get('||')));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sso.title.servext'));
     $dao = CopixDAOFactory::create("sso|sso_auth");
     // $all = $dao->findAll();
     $all = $dao->findBySso($id);
     $tpl->assign('MAIN', CopixZone::process('sso|SsoAuthList', array('list' => $all, 'id' => _request("id"))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Récupération de tous les agendas en base de données
  * @author Audrey Vassal <*****@*****.**>
  * @since 2006/07/24
  * @return array tableau d'objet agenda
  */
 public function getAvailableAgenda()
 {
     //var_dump($_SESSION);
     if (!_sessionGet('modules|agenda|his')) {
         $serviceAuth = new AgendaAuth();
         $res = array();
         $ags = array();
         // 1. Son agenda perso
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_AGENDA" && $modInfo->module_id) {
                 $ags[] = $modInfo->module_id;
             }
         }
         // 2. Ceux de sa classe, son école, ses groupes...
         $mynodes = Kernel::getNodes();
         foreach ($mynodes as $nodes) {
             foreach ($nodes as $node) {
                 //print_r($node);
                 if (substr($node['type'], 0, 5) == 'USER_') {
                     continue;
                 }
                 $modules = Kernel::getModEnabled($node['type'], $node['id']);
                 $agenda = Kernel::filterModuleList($modules, 'MOD_AGENDA');
                 if ($agenda && $serviceAuth->getCapability($agenda[0]->module_id) >= $serviceAuth->getRead()) {
                     $ags[] = $agenda[0]->module_id;
                 }
             }
         }
         //print_r($ags);
         $daoAgenda =& CopixDAOFactory::getInstanceOf('agenda|agenda');
         $agendas = $daoAgenda->findAgendasInIds($ags);
         foreach ($agendas as $agenda) {
             $tmp = new stdClass();
             $tmp->id_agenda = $agenda->id_agenda;
             $tmp->title_agenda = $agenda->title_agenda;
             $tmp->desc_agenda = $agenda->desc_agenda;
             $tmp->type_agenda = $agenda->type_agenda;
             /*
                       $tmp = array (
                           'id_agenda' => $agenda->id_agenda,
                           'title_agenda' => $agenda->title_agenda,
                           'desc_agenda' => $agenda->desc_agenda,
                           'type_agenda' => $agenda->type_agenda,
                       );
             */
             $res[] = $tmp;
         }
         //die();
         //$sess = $daoAgenda->findAll ();
         _sessionSet('modules|agenda|his', serialize($res));
     }
     return unserialize(_sessionGet('modules|agenda|his'));
 }
 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');
 }
 /**
  * Entrée générique dans un agenda
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/08/24
  * @param integer $id Id de l'agenda (si aucun, l'envoie dans l'agenda perso)
  */
 public function go()
 {
     $id = $this->getRequest('id', null);
     $dao = CopixDAOFactory::create('agenda|agenda');
     if ($id == null) {
         // Si pas d'id, on l'envoie dans son agenda perso
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_AGENDA" && $modInfo->module_id) {
                 $id = $modInfo->module_id;
             }
         }
     }
     if ($id && ($agenda = $dao->get($id))) {
         $this->_setSessionSemaineParams(null);
         $obj = new AgendaService();
         $obj->setAgendaAffiches(array($id => $id));
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('agenda|agenda|'));
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
 }
 public function processDefault()
 {
     $tpl = new CopixTpl();
     $tplModule = new CopixTpl();
     if (!$this->user->connected) {
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('welcome|default|'));
     }
     $tpl->assign('TITLE_PAGE', CopixI18N::get('kernel.title.accueilsimple'));
     $nodes_all = Kernel::getNodeParents($this->user->type, $this->user->idEn);
     $nodes_all = Kernel::sortNodeList($nodes_all);
     // _dump($nodes_all);
     $nodes = array();
     foreach ($nodes_all as $node) {
         if ($node['type'] == 'CLUB' && CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance')) && $node['id'] == $groupeAssistance) {
             continue;
         }
         if ($node['type'] == 'CLUB' && $node['droit'] < 20) {
             continue;
         }
         if (!isset($nodes[$node['type']])) {
             $nodes[$node['type']] = array();
         }
         //module not initialized : loaded into inconito
         if (!isset($nodes[$node['type']][$node['id']])) {
             $nodes[$node['type']][$node['id']] = $node;
             Kernel::createMissingModules($node['type'], $node['id']);
             $nodes[$node['type']][$node['id']]['modules'] = Kernel::getModEnabled($node['type'], $node['id'], $this->user->type, $this->user->idEn, 0, count($nodes_all) > $this->conf_notification_maxnodes ? 0 : 1);
             // Cas des groupes : on ajoute les membres et admin, selon les droits
             if ($node['type'] == 'CLUB') {
                 $addModule = new CopixPPO();
                 $addModule->node_type = $node['type'];
                 $addModule->node_id = $node['id'];
                 $addModule->module_type = 'MOD_ADMIN';
                 $addModule->module_id = 0;
                 $addModule->module_nom = CopixI18N::get('groupe|groupe.group.admin');
                 $nodes[$node['type']][$node['id']]['modules'][] = $addModule;
             }
             /*
              * ===== CONTENT GENERATION =====
              *
              */
             //cas parent élève
             if ($node['type'] == 'USER_ELE') {
                 $contentNode = Kernel::getNodeParents($node['type'], $node['id']);
                 $contentNode = Kernel::filterNodeList($contentNode, 'BU_CLASSE');
                 if (empty($contentNode)) {
                     continue;
                 }
                 $contentNode = $contentNode[0];
             } else {
                 $contentNode = $node;
             }
             //get content from db :
             $content = $this->db->query('SELECT * FROM module_admindash WHERE id_zone = ' . $contentNode['id'] . ' AND type_zone = "' . $contentNode['type'] . '"')->toArray1();
             // Get vocabulary catalog to use
             $nodeVocabularyCatalogDAO = _ioDAO('kernel|kernel_i18n_node_vocabularycatalog');
             $vocabularyCatalog = $nodeVocabularyCatalogDAO->getCatalogForNode($contentNode['type'], $contentNode['id']);
             //if no content : get default content
             if (empty($content['content'])) {
                 switch ($contentNode['type']) {
                     case 'BU_CLASSE':
                     case 'USER_ELE':
                         $content['content'] = CopixZone::process('kernel|dashboardClasse', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'BU_ECOLE':
                         $content['content'] = CopixZone::process('kernel|dashboardEcole', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'BU_VILLE':
                         $content['content'] = CopixZone::process('kernel|dashboardVille', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'CLUB':
                         $content['content'] = CopixZone::process('kernel|dashboardGrTravail', array('idZone' => $contentNode['id'], 'catalog' => $vocabularyCatalog->id_vc));
                         break;
                     case 'ROOT':
                         if ($contentNode['droit'] >= 60) {
                             $contentTpl = new CopixTpl();
                             $content['content'] = $contentTpl->fetch('zone.dashboard.root.tpl');
                         } else {
                             $contentTpl = new CopixTpl();
                             $content['content'] = $contentTpl->fetch('zone.dashboard.userext.tpl');
                         }
                         break;
                     default:
                         $content['content'] = '';
                         break;
                 }
             }
             //twitter integration
             $twitterSrc = '';
             if (!empty($content['social_stream'])) {
                 enic::to_load('social');
                 $twitter = new enicSocialTwitter();
                 $twitterSrc = $content['social_stream'];
             }
             //is admin :
             $is_admin = $contentNode['droit'] >= 60;
             //build html content
             $content_tpl = new CopixTpl();
             $content_tpl->assign('content', $content['content']);
             if (!empty($content['picture'])) {
                 $content_tpl->assign('picture', $content['picture']);
                 $content_tpl->assign('picturePath', $this->picturesPath);
             }
             $content_tpl->assign('twitter', $twitterSrc);
             $content_tpl->assign('is_admin', $is_admin);
             $content_tpl->assign('id', $contentNode['id']);
             $content_tpl->assign('type', $contentNode['type']);
             $content_tpl->assign('catalog', $vocabularyCatalog->id_vc);
             if ($contentNode['type'] == "BU_ECOLE") {
                 $content_tpl->assign('idZone', $contentNode['id']);
             }
             $content = $content_tpl->fetch('dashboard.nodes.tpl');
             //add css
             $this->addCss('styles/dashboard_zone.css');
             //free memory
             unset($content_tpl);
             /*
              *  ===== END CONTENT GENERATION =====
              */
             $nodes[$node['type']][$node['id']]['content'] = $content;
         } elseif ($nodes[$node['type']][$node['id']]['droit'] < $node['droit']) {
             $nodes[$node['type']][$node['id']] = $node;
         }
     }
     if (CopixConfig::exists('|use_class_validity') && CopixConfig::get('|use_class_validity')) {
         $tplModule->assign("use_class_validity", 1);
         if (isset($nodes['BU_CLASSE'])) {
             foreach ($nodes['BU_CLASSE'] as $classe_id => $classe_data) {
                 $validity_timestamp = Kernel::getValidityDateForClass($classe_data['id']);
                 if ($validity_timestamp) {
                     $nodes['BU_CLASSE'][$classe_id]['validity_timestamp'] = $validity_timestamp;
                     $nodes['BU_CLASSE'][$classe_id]['validity_date'] = date('d/m/Y', $validity_timestamp);
                     // Si l'école existe : mémoriser max validity
                     if (isset($nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole])) {
                         if (!isset($nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_timestamp']) || $nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_timestamp'] < $validity_timestamp) {
                             $nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_timestamp'] = $validity_timestamp;
                             $nodes['BU_ECOLE'][$nodes['BU_CLASSE'][$classe_id]['ALL']->cla_ecole]['validity_date'] = date('d/m/Y', $validity_timestamp);
                         }
                     }
                 }
             }
         }
         $count_validity_ok = 0;
         $count_validity_bad = 0;
         foreach ($nodes as $node_type => $node_type_list) {
             foreach ($node_type_list as $node_id => $node) {
                 if (isset($nodes[$node_type][$node_id]['validity_timestamp'])) {
                     if ($nodes[$node_type][$node_id]['validity_timestamp'] < time()) {
                         unset($nodes[$node_type][$node_id]);
                         $count_validity_bad++;
                     } else {
                         $count_validity_ok++;
                     }
                 }
             }
         }
     } else {
         $tplModule->assign("use_class_validity", 0);
     }
     /* DRAFT WORKING */
     // _dump($nodes);
     /* $rClasse = Kernel::getNodeInfo ('BU_CLASSE', $nodes['BU_CLASSE'][1]['id'], false);
        CopixZone::process ('annuaire|infosclasse', array('rClasse'=>$rClasse)); */
     //echo $this->matrix->display();
     // _dump($nodes);
     $tplModule->assign("nodes", $nodes);
     if (count($nodes) == 0) {
         $result = $tplModule->fetch("dashboard-empty.tpl");
     } else {
         $result = $tplModule->fetch("dashboard.tpl");
     }
     $tpl->assign('MAIN', $result);
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Affichage principal
  */
 public function processVoirContenu()
 {
     $ppo = new CopixPPO();
     _classInclude('classeur|classeurService');
     // Récupération des paramètres
     $ppo->classeurId = _request('classeurId', null);
     $ppo->dossierId = _request('dossierId', 0);
     $ppo->confirmMessage = _request('confirmMessage', null);
     $ppo->errorMessage = _request('errorMessage', null);
     $vue = _request('vue', null);
     // Paramètres de tri
     $triColonne = _request('triColonne', null);
     $triDirection = _request('triDirection', 'ASC');
     // Gestion des droits
     $ppo->withSubLockers = Kernel::getLevel('MOD_CLASSEUR', $ppo->classeurId) >= PROFILE_CCV_PUBLISH ? true : false;
     $ppo->conf_ModClasseur_upload = CopixConfig::exists('default|conf_ModClasseur_upload') ? CopixConfig::get('default|conf_ModClasseur_upload') : 0;
     // Récupération de l'identifiant du classeur personnel si non disponible en session
     if (is_null($ppo->idClasseurPersonnel = _sessionGet('classeur|idClasseurPersonnel'))) {
         // Création des modules inexistants.
         Kernel::createMissingModules(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         $modsList = Kernel::getModEnabled(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == 'MOD_CLASSEUR' && $modInfo->module_id) {
                 _sessionSet('classeur|idClasseurPersonnel', $modInfo->module_id);
                 $ppo->idClasseurPersonnel = _sessionGet('classeur|idClasseurPersonnel');
             }
         }
     }
     // Si ID du classeur non spécifié, on récupère l'identifiant du classeur perso disponible en session
     if (is_null($ppo->classeurId)) {
         $ppo->classeurId = _sessionGet('classeur|idClasseurPersonnel');
     }
     // Si type de vue spécifié, on le met en session et on le stocke en BDD
     $kernelConfUserDAO = _ioDAO('kernel|kernel_conf_user');
     if (!is_null($vue) && ($vue == 'liste' || $vue == 'vignette')) {
         _sessionSet('classeur|typeVue', $vue);
         $confVue = $kernelConfUserDAO->getByPathAndUserId('/module_classeur/vue', _currentUser()->getExtra('id'));
         if ($confVue) {
             $confVue->value = $vue;
             $kernelConfUserDAO->update($confVue);
         } else {
             $kernelConfUser = _record('kernel|kernel_conf_user');
             $kernelConfUser->path = '/module_classeur/vue';
             $kernelConfUser->id_dbuser = _currentUser()->getExtra('id');
             $kernelConfUser->value = $vue;
             $kernelConfUserDAO->insert($kernelConfUser);
         }
     }
     // Récupération de la vue en session ou BDD
     if (!is_null(_sessionGet('classeur|typeVue'))) {
         $ppo->vue = _sessionGet('classeur|typeVue');
     } else {
         $confVue = $kernelConfUserDAO->getByPathAndUserId('/module_classeur/vue', _currentUser()->getExtra('id'));
         if ($confVue) {
             _sessionSet('classeur|typeVue', $vue);
             $ppo->vue = _sessionGet('classeur|typeVue');
         } else {
             _sessionSet('classeur|typeVue', 'liste');
             $kernelConfUser = _record('kernel|kernel_conf_user');
             $kernelConfUser->path = '/module_classeur/vue';
             $kernelConfUser->id_dbuser = _currentUser()->getExtra('id');
             $kernelConfUser->value = 'liste';
             $kernelConfUserDAO->insert($kernelConfUser);
         }
     }
     // Si tri spécifié, mise en session
     if (!is_null($triColonne)) {
         ClasseurService::setContentSort($triColonne, $triDirection);
     }
     // Ouverture du dossier courant dans l'arborescence
     if ($ppo->dossierId != 0) {
         classeurService::openTree($ppo->classeurId, $ppo->dossierId);
     }
     $modParentInfo = Kernel::getModParentInfo('MOD_CLASSEUR', $ppo->classeurId);
     $ppo->TITLE_PAGE = $modParentInfo['nom'];
     $classeurDAO = _ioDAO('classeur|classeur');
     $folderDAO = _ioDAO('classeur|classeurdossier');
     $fichierDAO = _ioDAO('classeur|classeurfichier');
     $classeur = $classeurDAO->get($ppo->classeurId);
     $folder = $folderDAO->get($classeur->upload_db);
     if ($ppo->conf_ModClasseur_upload && $classeur->upload_fs) {
         $nomClasseur = $classeur->id . '-' . $classeur->cle;
         // $extension  = strtolower(strrchr($fichier->fichier, '.'));
         // $nomFichier = $fichier->id.'-'.$fichier->cle.$extension;
         $path = realpath('./upload') . '/' . $classeur->upload_fs;
         if ($classeur->upload_fs && glob($path . '/*')) {
             foreach (glob($path . '/*') as $file) {
                 if (is_file($file)) {
                     $fichier = _record('classeur|classeurfichier');
                     $title = Kernel::stripText($file);
                     $fichier->classeur_id = $classeur->id;
                     $fichier->dossier_id = $classeur->upload_db;
                     // TODO : Verifier existance
                     $fichier->titre = substr(basename($file), 0, 63);
                     $fichier->commentaire = '';
                     $fichier->fichier = basename($file);
                     $fichier->taille = file_exists($file) ? filesize($file) : 0;
                     $fichier->type = strtoupper(substr(strrchr($file, '.'), 1));
                     $fichier->cle = classeurService::createKey();
                     $fichier->date_upload = date('Y-m-d H:i:s');
                     $fichier->user_type = _currentUser()->getExtra('type');
                     $fichier->user_id = _currentUser()->getExtra('id');
                     $fichierDAO->insert($fichier);
                     $nomClasseur = $classeur->id . '-' . $classeur->cle;
                     $nomFichier = $fichier->id . '-' . $fichier->cle;
                     $extension = strtolower(strrchr($file, '.'));
                     $dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/';
                     // Déplacement du fichier temporaire dans le classeur
                     copy($file, $dir . $fichier->id . '-' . $fichier->cle . $extension);
                     ClasseurService::doAutoRotateJpegByOrientation($dir . $fichier->id . '-' . $fichier->cle . $extension, $extension);
                     // Suppression du fichier temporaire
                     unlink($file);
                 }
                 if ($classeur->upload_db) {
                     classeurService::updateFolderInfos($folder);
                 }
             }
         }
         // print_r($classeur);
         // upload_fs
     }
     return _arPPO($ppo, 'voir_contenu.tpl');
 }
 /**
  * Affichage du détail d'une malle
  *
  * Affiche l'ensemble des fichiers, dossiers et actions possibles de réaliser dans un dossier d'une malle
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/12/02
  * @param integer $id Id de la malle
  * @param integer $folder Id du répertoire
  * @param array $errors (option) Erreurs rencontrées
  */
 public function processGetMalle()
 {
     $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);
     // Malle perso : si $id non défini ou si $id=0
     if (!$id) {
         // Récupération des infos de l'utilisateur.
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             // Recherche du module de malle.
             //print_r($modInfo);
             if ($modInfo->module_type == "MOD_MALLE" && $modInfo->module_id) {
                 // Sélection de la malle personnelle.
                 $urlReturn = CopixUrl::get('malle||getMalle', array('id' => $modInfo->module_id));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             }
         }
     }
     $folder = $this->getRequest('folder', 0);
     $errors = $this->getRequest('errors', array());
     $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');
         }
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $title);
         $can = array('file_download' => $malleService->canMakeInMalle("FILE_DOWNLOAD", $mondroit), 'file_upload' => $malleService->canMakeInMalle("FILE_UPLOAD", $mondroit), 'folder_create' => $malleService->canMakeInMalle("FOLDER_CREATE", $mondroit), 'item_delete' => $malleService->canMakeInMalle("ITEM_DELETE", $mondroit), 'item_move' => $malleService->canMakeInMalle("ITEM_MOVE", $mondroit), 'item_copy' => $malleService->canMakeInMalle("ITEM_COPY", $mondroit), 'item_rename' => $malleService->canMakeInMalle("ITEM_RENAME", $mondroit), 'item_downloadZip' => $malleService->canMakeInMalle("ITEM_DOWNLOAD_ZIP", $mondroit));
         //print_r($can);
         $nbFiles = count($files);
         $nbFolders = count($folders);
         // CONSTRUCTION DU MENU
         // S.Holtz 2010.09
         $menu = array();
         $size = 64;
         if ($can['file_upload']) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.addfile'), 'type' => 'addfile', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptAddFile', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['file_upload']) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.addweb'), 'type' => 'addfile addweb', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptAddWeb', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['folder_create']) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.addfolder'), 'type' => 'addfolder', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptAddFolder', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_copy'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.copy'), 'type' => 'copy', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptCopyItems', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_move'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.move'), 'type' => 'move', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptMoveItems', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_delete'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.delete'), 'type' => 'delete', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptDeleteItems', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_downloadZip'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.download'), 'type' => 'download', 'size' => $size + 10, 'url' => CopixUrl::get('malle|malle|promptDownloadZip', array('id' => $id, 'folder' => $folder)));
         }
         $tpl->assign('MENU', $menu);
         // FIN CONSTRUCTION DU MENU
         $tplMalle = new CopixTpl();
         $tplMalle->assign('id', $id);
         $tplMalle->assign('folder', $folder);
         $tplMalle->assign('folders', $folders);
         $tplMalle->assign('files', $files);
         $tplMalle->assign('errors', $errors);
         $tplMalle->assign('can', $can);
         $tplMalle->assign('petitpoucet', CopixZone::process('malle|petitpoucet', array('malle' => $id, 'folder' => $folder)));
         $tplMalle->assign('combofoldersdest', CopixZone::process('malle|combofolders', array('malle' => $id, 'folder' => $folder, 'fieldName' => 'folderDest', 'attribs' => 'style="width:100%;"')));
         $tplMalle->assign('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'))))));
         $tplMalle->assign("uploadMaxSize", CopixConfig::get('malle|uploadMaxSize'));
         //Kernel::myDebug($files);
         //if ($mondroit>=PROFILE_CCV_PUBLISH)	$tplForum->assign ('canPublish', 1);
         //else																$tplForum->assign ('canPublish', 0);
         $result = $tplMalle->fetch('getmalle.tpl');
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 /**
  * 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 2005/12/28
  * @param string $field Nom du champ dans le formulaire. Correspond à l'attribut "name" et "id" dans le template (les deux doivent être positionnés)
  * @param string $format Format de la zone de saisie (wiki, html, fckeditor...)
  * @param array $objet (option) Module dans lequel se trouve la barre wiki, 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, une malle et un classeur, et si oui on affiche les liens vers l'album photos, la malle et le classeur en mode popup
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $field = $this->getParam('field', NULL);
     $format = $this->getParam('format', NULL);
     $object = $this->getParam('object', NULL);
     $withAlbum = $this->getParam('withAlbum', true);
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/wikibuttons.js');
     if ($field && $format) {
         $buttonAlbum = $buttonMalle = $buttonClasseur = array();
         // Bouton album photos et malle
         $buttons = array();
         // Tableau avec les boutons
         switch ($format) {
             case "wiki":
                 CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/format_' . $format . '.js');
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.bold'), 'accesskey' => 'g', 'tabindex' => 10, 'link' => "javascript:bbstyle('','{$field}',0);");
                 // Gras
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.italic'), 'accesskey' => 'i', 'tabindex' => 11, 'link' => "javascript:bbstyle('','{$field}',2);");
                 // Italique
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.image'), 'accesskey' => 'm', 'tabindex' => 12, 'link' => "javascript:bblink('','{$field}',12);");
                 // Image
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.link'), 'accesskey' => 'l', 'tabindex' => 13, 'link' => "javascript:bblink('','{$field}',8);");
                 // Lien
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.hr'), 'accesskey' => 'h', 'tabindex' => 14, 'link' => "javascript:bbcar('','{$field}',4);");
                 // HR
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h1'), 'accesskey' => 'j', 'tabindex' => 15, 'link' => "javascript:bblink('','{$field}',20);");
                 // H1
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h2'), 'accesskey' => 'v', 'tabindex' => 16, 'link' => "javascript:bblink('','{$field}',22);");
                 // H2
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h3'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bblink('','{$field}',24);");
                 // H3
                 break;
             case "dokuwiki":
                 CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/format_' . $format . '.js');
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.bold'), 'accesskey' => 'g', 'tabindex' => 10, 'link' => "javascript:bbstyle('','{$field}',0);", 'icon' => 'bold.png');
                 // Gras
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.italic'), 'accesskey' => 'i', 'tabindex' => 11, 'link' => "javascript:bbstyle('','{$field}',2);", 'icon' => 'italic.png');
                 // Italique
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.underline'), 'accesskey' => 's', 'tabindex' => 12, 'link' => "javascript:bbstyle('','{$field}',4);", 'icon' => 'underline.png');
                 // Souligne
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.image'), 'accesskey' => 'm', 'tabindex' => 12, 'link' => "javascript:bblink('','{$field}',12);", 'icon' => 'image.png');
                 // Image
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.link'), 'accesskey' => 'l', 'tabindex' => 13, 'link' => "javascript:bblink('','{$field}',8);", 'icon' => 'linkextern.png');
                 // Lien
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.email'), 'accesskey' => 'e', 'tabindex' => 13, 'link' => "javascript:bblink('','{$field}',10);", 'icon' => '../../tpl/default/images/mail_icon.gif');
                 // Email
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.hr'), 'accesskey' => 'h', 'tabindex' => 14, 'link' => "javascript:bbcar('','{$field}',4);", 'icon' => 'hr.png');
                 // HR
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h1'), 'accesskey' => 'j', 'tabindex' => 15, 'link' => "javascript:bblink('','{$field}',20);", 'icon' => 'h1.png');
                 // H1
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h2'), 'accesskey' => 'v', 'tabindex' => 16, 'link' => "javascript:bblink('','{$field}',22);", 'icon' => 'h2.png');
                 // H2
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h3'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bblink('','{$field}',24);", 'icon' => 'h3.png');
                 // H3
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.ul'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bbcar('','{$field}',5);", 'icon' => 'ul.png');
                 // UL
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.ol'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bbcar('','{$field}',6);", 'icon' => 'ol.png');
                 // OL
                 break;
         }
         if ($object) {
             $user_type = _currentUser()->getExtra('type');
             $user_id = _currentUser()->getExtra('id');
             if ('USER' === $object) {
                 Kernel::createMissingModules($user_type, $user_id);
                 $parent = array('type' => $user_type, 'id' => $user_id);
             } elseif (preg_match('/^MOD_/', $object['type'])) {
                 $parent = Kernel::getModParentInfo($object['type'], $object['id']);
             } else {
                 $parent = Kernel::getNodeInfo($object['type'], $object['id']);
             }
             if ($parent) {
                 $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
                 $alb = Kernel::filterModuleList($mods, 'MOD_ALBUM');
                 if ($alb && $withAlbum) {
                     $url = CopixUrl::get('album||getpopup', array('album_id' => $alb[0]->module_id, 'field' => $field, 'format' => $format));
                     $buttonAlbum = array('titre' => CopixI18N::get('wikibuttons.album'), 'accesskey' => 'a', 'tabindex' => 18, 'link' => $url);
                     // Album photos
                 }
                 $mal = Kernel::filterModuleList($mods, 'MOD_MALLE');
                 if ($mal) {
                     $url = CopixUrl::get('malle|malle|getMallePopup', array('id' => $mal[0]->module_id, 'field' => $field, 'format' => $format));
                     $buttonMalle = array('titre' => CopixI18N::get('wikibuttons.malleTxt'), 'accesskey' => 'd', 'tabindex' => 19, 'link' => $url);
                     // Malle
                 }
                 $cla = Kernel::filterModuleList($mods, 'MOD_CLASSEUR');
                 if ($cla) {
                     $url = CopixUrl::get('classeur||getClasseurPopup', array('classeurId' => $cla[0]->module_id, 'field' => $field, 'format' => $format, 'withPersonal' => 1, 'moduleType' => $object['type'], 'moduleId' => $object['id']));
                     $buttonClasseur = array('titre' => CopixI18N::get('wikibuttons.classeurTxt'), 'accesskey' => 'd', 'tabindex' => 20, 'link' => $url);
                     // Classeur
                 }
             }
         }
         $tpl->assign('format', $format);
         $tpl->assign('buttons', $buttons);
         $tpl->assign('buttonAlbum', $buttonAlbum);
         $tpl->assign('buttonMalle', $buttonMalle);
         $tpl->assign('buttonClasseur', $buttonClasseur);
         $tpl->assign('field', $field);
         $toReturn = $tpl->fetch('wikibuttons.tpl');
     }
     return true;
 }