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; }