Exemplo n.º 1
0
 static function addModule($sec_id, $module = null, $title = "", $readonly = false)
 {
     global $_struct;
     if (!$module) {
         $module = 'apContent';
     }
     $sec_id = ap::id($sec_id);
     if (($info = apModuleManager::getModuleInfo($module)) && ($sec = $_struct->getSection($sec_id)) && ($modules = $sec->getModules()) && ($m = $modules->add($module, $title ? $title : @$info['name']))) {
         if ($readonly) {
             $m->getRootElement()->setAttribute('readonly', 'readonly');
         }
         if (method_exists($m, 'install')) {
             if (!$m->install()) {
                 apModuleManager::removeModule($sec_id, $m->getId());
             }
         }
         $modules->getXML()->save();
         return $m;
     }
     return false;
 }
Exemplo n.º 2
0
 static function removeSection($id)
 {
     global $_struct;
     if ($sec = $_struct->getSection(ap::id($id))) {
         $modules = $sec->getModules();
         foreach ($modules as $m) {
             apModuleManager::removeModule($sec->getId(), $m->getId());
         }
         ap::getClientstructure()->removeSection($sec->getId(), true);
         ap::getClientstructure()->save();
         $sec->remove(true);
     }
 }