public function processAdmin()
 {
     //check if the user is admin :
     if (!Kernel::isAdmin()) {
         return $this->error('charte.noRight', true, '||');
     }
     $ppo = new CopixPPO();
     $ppo->errors = isset($this->flash->errors) ? $this->flash->errors : null;
     $ppo->success = isset($this->flash->success) ? $this->flash->success : null;
     $ppo->chartes = $this->service('CharteService')->getChartesTypes();
     $ppo->radio = array(1 => 'oui', 0 => 'non');
     $ppo->idClasseur = $ppo->idMalle = null;
     $modsAvailable = Kernel::getModAvailable($this->user->type);
     $malleAvailable = Kernel::filterModuleList($modsAvailable, 'MOD_MALLE');
     // Malle activée
     if (!empty($malleAvailable)) {
         $modsEnabled = Kernel::getModEnabled($this->user->type, $this->user->idEn);
         $mal = Kernel::filterModuleList($modsEnabled, 'MOD_MALLE');
         // Si la malle est bien initialisée
         if (!empty($mal)) {
             $ppo->idMalle = $mal[0]->module_id;
         } else {
             return $this->error('charte.admin.noMalle', true, 'malle||');
         }
     } else {
         $classeurAvailable = Kernel::filterModuleList($modsAvailable, 'MOD_CLASSEUR');
         // Classeur activé
         if (!empty($classeurAvailable)) {
             Kernel::createMissingModules($this->user->type, $this->user->idEn);
             $modsEnabled = Kernel::getModEnabled($this->user->type, $this->user->idEn);
             $classeur = Kernel::filterModuleList($modsEnabled, 'MOD_CLASSEUR');
             if (!empty($classeur)) {
                 $ppo->idClasseur = $classeur[0]->module_id;
             }
         }
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_charte.css"));
     return _arPPO($ppo, 'charte.admin.tpl');
 }
 public function createMissingModules($node_type, $node_id)
 {
     $modavailable = Kernel::getModAvailable($node_type);
     $modenabled = Kernel::getModEnabled($node_type, $node_id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'), 1);
     $modinstalled = array();
     foreach ($modenabled as $module) {
         $modinstalled[] = strtolower($module->module_type);
     }
     //var_dump($modinstalled);
     $nodeInfo = Kernel::getNodeInfo($node_type, $node_id);
     if ($node_type == 'CLUB') {
         foreach ($modavailable as $module) {
             // echo "<li>".$module->module_type."</li>";
             if ($module->module_type == 'MOD_MAGICMAIL') {
                 $modname = 'magicmail';
                 // _dump($modinstalled);
                 // if( array_search("mod_magicmail", $modinstalled)===false ) echo "magicmail ";
                 // if( array_search("mod_blog", $modinstalled)!==false ) echo "blog ";
                 if (array_search("mod_magicmail", $modinstalled) === false && array_search("mod_blog", $modinstalled) !== false) {
                     $file =& CopixSelectorFactory::create($modname . "|" . $modname);
                     $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                     //var_dump($filePath);
                     if (is_readable($filePath)) {
                         $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
                         if (method_exists($modservice, "create")) {
                             $subtitle = $node_type == 'BU_ECOLE' && isset($nodeInfo['ALL']->eco_type) ? $nodeInfo['ALL']->eco_type : '';
                             $prenom = isset($nodeInfo['prenom']) ? $nodeInfo['prenom'] : '';
                             $modid = $modservice->create(array('title' => trim($prenom . ' ' . $nodeInfo['nom']), 'subtitle' => $subtitle, 'node_type' => $node_type, 'node_id' => $node_id));
                             if ($modid != null) {
                                 // _dump( array( $module->module_type, $modid, $node_type, $node_id ));
                                 Kernel::registerModule($module->module_type, $modid, $node_type, $node_id);
                             }
                         }
                     }
                 }
             }
         }
         return false;
     }
     foreach ($modavailable as $module) {
         //var_dump($module);
         if (preg_match("/^MOD_(.+)\$/", $module->module_type, $modinfo)) {
             $modname = strtolower($modinfo[1]);
             if (array_search("mod_" . $modname, $modinstalled) === false) {
                 $file =& CopixSelectorFactory::create($modname . "|" . $modname);
                 $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                 //var_dump($filePath);
                 if (is_readable($filePath)) {
                     $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
                     if (method_exists($modservice, "create")) {
                         $subtitle = $node_type == 'BU_ECOLE' && isset($nodeInfo['ALL']->eco_type) ? $nodeInfo['ALL']->eco_type : '';
                         $prenom = isset($nodeInfo['prenom']) ? $nodeInfo['prenom'] : '';
                         $modid = $modservice->create(array('title' => trim($prenom . ' ' . $nodeInfo['nom']), 'subtitle' => $subtitle, 'node_type' => $node_type, 'node_id' => $node_id));
                         if ($modid != null) {
                             Kernel::registerModule($module->module_type, $modid, $node_type, $node_id);
                         }
                     }
                 }
             }
         }
     }
 }