/** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function users_register($module, &$content) { PHPWS_Core::initModClass('users', 'Permission.php'); PHPWS_Core::initModClass('users', 'My_Page.php'); $no_permissions = $no_my_page = FALSE; $result = Users_Permission::createPermissions($module); if (is_null($result)) { PHPWS_Boost::addLog('users', dgettext('users', 'Permissions file not implemented.')); $content[] = dgettext('users', 'Permissions file not implemented.'); $no_permissions = TRUE; } elseif (PHPWS_Error::isError($result)) { $content[] = dgettext('users', 'Permissions table not created successfully.'); PHPWS_Error::log($result); return FALSE; } else { $content[] = dgettext('users', 'Permissions table created successfully.'); } $result = My_Page::registerMyPage($module); if (PHPWS_Error::isError($result)) { PHPWS_Boost::addLog('users', dgettext('users', 'A problem occurred when trying to register this module to My Page.')); $content[] = dgettext('users', 'A problem occurred when trying to register this module to My Page.'); return FALSE; } elseif ($result != FALSE) { $content[] = dgettext('users', 'My Page registered to Users module.'); } else { $no_my_page = TRUE; } // If the module doesn't have permissions or a My Page // then don't register the module if ($no_permissions && $no_my_page) { return FALSE; } else { return TRUE; } }
public static function registerModule($module, &$content) { if (is_file(PHPWS_SOURCE_DIR . 'mod/' . $module . '/conf/rss.php')) { $reg_file = PHPWS_Core::getConfigFile($module, 'rss.php'); } else { $reg_file = false; } if ($reg_file == FALSE) { PHPWS_Boost::addLog($module, dgettext('rss', 'No RSS file found.')); return FALSE; } PHPWS_Core::initModClass('rss', 'Channel.php'); include $reg_file; $oChannel = new RSS_Channel(); $oChannel->module = $module; if (!isset($channel) || !is_array($channel)) { $content[] = dgettext('rss', 'RSS file found but no channel information.'); PHPWS_Boost::addLog($module, dgettext('rss', 'RSS file found but no channel information.')); } $oModule = new PHPWS_Module($module); if (!empty($channel['title'])) { $oChannel->title = strip_tags($channel['title']); } else { $oChannel->title = $oModule->proper_name; } if (!empty($channel['description'])) { $oChannel->description = strip_tags($channel['description']); } if (!empty($channel['link'])) { $oChannel->link = strip_tags($channel['link']); } else { $oChannel->link = PHPWS_Core::getHomeHttp(); } $result = $oChannel->save(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); PHPWS_Boost::addLog($module, dgettext('rss', 'An error occurred registering to RSS module.')); $content[] = dgettext('rss', 'An error occurred registering to RSS module.'); return NULL; } else { $content[] = sprintf(dgettext('rss', 'RSS registration to %s module successful.'), $oModule->proper_name); return TRUE; } }
/** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function users_unregister($module, &$content) { PHPWS_Core::initModClass('users', 'Permission.php'); PHPWS_Core::initModClass('users', 'My_Page.php'); $result = Users_Permission::removePermissions($module); if (PHPWS_Error::isError($result)) { $content[] = dgettext('users', 'Permissions table not removed successfully.'); return FALSE; } elseif ($result) { $content[] = dgettext('users', 'Permissions table removed successfully.'); } $result = My_Page::unregisterMyPage($module); if (PHPWS_Error::isError($result)) { PHPWS_Boost::addLog('users', dgettext('users', 'A problem occurred when trying to unregister this module from My Page.')); $content[] = dgettext('users', 'A problem occurred when trying to unregister this module from My Page.'); return FALSE; } elseif ($result != FALSE) { $content[] = dgettext('users', 'My Page unregistered from Users module.'); } return TRUE; }
public function unregisterModToMod($unregister_from_mod, $register_mod, &$content) { $unregisterFile = $unregister_from_mod->getDirectory() . 'boost/unregister.php'; if (!is_file($unregisterFile)) { return NULL; } include_once $unregisterFile; $unregisterFunc = $unregister_from_mod->title . '_unregister'; if (!function_exists($unregisterFunc)) { return NULL; } $result = $unregisterFunc($register_mod->title, $content); if (PHPWS_Error::isError($result)) { $content[] = sprintf(dgettext('boost', 'An error occurred while unregistering the %s module.'), $register_mod->getProperName()); PHPWS_Error::log($result); PHPWS_Boost::addLog($register_mod->title, $result->getMessage()); } elseif ($result == true) { PHPWS_Boost::unsetRegistered($unregister_from_mod->title, $register_mod->title); $content[] = sprintf(dgettext('boost', "%1\$s successfully unregistered from %2\$s."), $register_mod->getProperName(true), $unregister_from_mod->getProperName(true)); } }
public static function registerModule($module, &$content) { PHPWS_Core::initModClass('controlpanel', 'Tab.php'); PHPWS_Core::initModClass('controlpanel', 'Link.php'); $cpFile = sprintf('%smod/%s/boost/controlpanel.php', PHPWS_SOURCE_DIR, $module); if (!is_file($cpFile)) { PHPWS_Boost::addLog($module, dgettext('controlpanel', 'Control Panel file not implemented.')); return false; } include $cpFile; // insure cp file does not change translation directory if (isset($tabs) && is_array($tabs)) { foreach ($tabs as $info) { $tab = new PHPWS_Panel_Tab(); if (!isset($info['id'])) { $tab->setId(strtolower(preg_replace('/\\W/', '_', $info['title']))); } else { $tab->setId($info['id']); } if (!isset($info['title'])) { $content[] = dgettext('controlpanel', 'Unable to create tab.') . ' ' . dgettext('controlpanel', 'Missing title.'); continue; } $tab->setTitle($info['title']); if (!isset($info['link'])) { $content[] = dgettext('controlpanel', 'Unable to create tab.') . ' ' . dgettext('controlpanel', 'Missing link.'); continue; } $tab->setLink($info['link']); if (isset($info['itemname'])) { $tab->setItemname($info['itemname']); } else { $tab->setItemname('controlpanel'); } $result = $tab->save(); if (PHPWS_Error::isError($result)) { $content[] = dgettext('controlpanel', 'An error occurred when trying to save a controlpanel tab.'); PHPWS_Error::log($result); return false; } } $content[] = sprintf(dgettext('controlpanel', 'Control Panel tabs created for %s.'), $module); } else { PHPWS_Boost::addLog($module, dgettext('controlpanel', 'Control Panel tabs not implemented.')); } if (isset($link) && is_array($link)) { $db = new PHPWS_DB('controlpanel_tab'); foreach ($link as $info) { $modlink = new PHPWS_Panel_Link(); if (isset($info['label'])) { $modlink->setLabel($info['label']); } if (isset($info['restricted'])) { $modlink->setRestricted($info['restricted']); } elseif (isset($info['admin'])) { $modlink->setRestricted($info['admin']); } $modlink->setUrl($info['url']); $modlink->setActive(1); if (isset($info['itemname'])) { $modlink->setItemName($info['itemname']); } else { $modlink->setItemName($module); } $modlink->setDescription($info['description']); if (is_string($info['image'])) { $modlink->setImage($info['image']); } elseif (is_array($info['image'])) { $modlink->setImage($info['image']['name']); } $db->addWhere('id', $info['tab']); $db->addColumn('id'); $result = $db->select('one'); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); continue; } elseif (!isset($result)) { $tab_id = 'unsorted'; PHPWS_Boost::addLog($module, dgettext('controlpanel', 'Unable to load a link into a specified tab.')); } else { $tab_id = $info['tab']; } $modlink->setTab($tab_id); $result = $modlink->save(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); $content[] = dgettext('controlpanel', 'There was a problem trying to save a Control Panel link.'); return false; } $db->resetWhere(); } $content[] = sprintf(dgettext('controlpanel', 'Control Panel links created for %s.'), $module); } else { PHPWS_Boost::addLog($module, dgettext('controlpanel', 'No Control Panel links found.')); } PHPWS_ControlPanel::reset(); return true; }