/** * @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 function main() { $auth = Current_User::getAuthorization(); if (!Current_User::isLogged() || !$auth->local_user) { PHPWS_Core::errorPage('403'); } $result = $this->init(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'The is a problem with My Page.'))); return; } elseif (!$result) { Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'No modules are registered to My Page.'))); return; } $panel = My_Page::cpanel(); $module = $panel->getCurrentTab(); if (!$this->moduleIsRegistered($module)) { Layout::add(dgettext('users', 'This module is not registered with My Page')); return; } $content = My_Page::userOption($module); if (PHPWS_Error::isError($content)) { $content = $content->getMessage(); } Layout::add(PHPWS_ControlPanel::display($content)); }
public static function user_form() { $form = new PHPWS_Form(); My_Page::addHidden($form, 'layout'); $form->addHidden('lo_command', 'save_settings'); $css = Layout::getAlternateStyles(); if ($css) { $form->addSelect('alternate', $css); $form->setMatch('alternate', PHPWS_Cookie::read('layout_style')); $form->setLabel('alternate', dgettext('layout', 'Available styles')); $form->addSubmit(dgettext('layout', 'Save settings')); } else { $blank = dgettext('layout', 'No alternate style sheets available.'); return $blank; } $template = $form->getTemplate(); return PHPWS_Template::process($template, 'layout', 'user_form.tpl'); }
/** * @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; }
/** * @author Matthew McNaney <mcnaney at gmail dot com> * @version $Id$ */ function layout_update(&$content, $currentVersion) { switch ($currentVersion) { case version_compare($currentVersion, '2.2.0', '<'): $content[] = 'This package will not update versions under 2.2.0.'; return false; case version_compare($currentVersion, '2.2.1', '<'): $content[] = '+ Fixed improper sql call in update_220.sql file.'; case version_compare($currentVersion, '2.3.0', '<'): $content[] = '<pre>'; if (PHPWS_Boost::updateFiles(array('conf/config.php', 'conf/error.php'), 'layout')) { $content[] = 'Updated conf/config.php and conf/error.php file.'; } else { $content[] = 'Unable to update conf/config.php and conf/error.php file.'; } $content[] = ' 2.3.0 changes ------------- + Removed references from object constructors. + Added the plug function to allow users to inject content directly into a theme. + Added translate functions. + Layout now looks for and includes a theme\'s theme.php file. + Fixed unauthorized access. + Added XML mode to config.php file. Puts Layout in XHTML+XML content mode. + Added missing media parameters to XML mode. </pre>'; case version_compare($currentVersion, '2.4.0', '<'): $files = array('img/layout.png', 'templates/no_cookie.tpl'); $content[] = '<pre>'; if (PHPWS_Boost::updateFiles($files, 'layout')) { $content[] = '--- Successfully updated the following files:'; } else { $content[] = '--- Was unable to copy the following files:'; } $content[] = ' ' . implode("\n ", $files); $content[] = ' 2.4.0 changes ------------- + Layout now checks and forces a user to enable cookies on their browser. + Rewrote Javascript detection. Was buggy before as session destruction could disrupt it. + Added German translations + Updated language functions + Fixed: bug in Layout confused a user\'s style sheet settings after the theme was changed. + Rewrote theme change code. + Added ability to force theme on layout settings construction. + Changed Control Panel icon </pre>'; case version_compare($currentVersion, '2.4.1', '<'): $files = array('conf/config.php'); $content[] = '<pre>'; if (PHPWS_Boost::updateFiles($files, 'layout')) { $content[] = '--- Successfully updated the following files:'; } else { $content[] = '--- Was unable to copy the following files:'; } $content[] = ' ' . implode("\n ", $files); $content[] = ' 2.4.1 changes ------------- + Bug #1741111 - Fixed moving a top box up and a bottom box down. + The cookie check is not determined by a define in the config file. + The cookie check was interfering with the rss feed. Cut off the page too quickly. Moved cookie check to the close.php file. </pre>'; case version_compare($currentVersion, '2.4.2', '<'): $content[] = '<pre>'; $files = array('templates/arrange.tpl', 'conf/error.php', 'templates/move_box_select.tpl'); layoutUpdateFiles($files, $content); if (!PHPWS_Boost::inBranch()) { $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/layout/boost/changes/2_4_2.txt'); } $content[] = '</pre>'; case version_compare($currentVersion, '2.4.3', '<'): $content[] = '<pre>2.4.3 changes ----------------- + nakedDisplay now allows a choice whether to use the blank template or not when it wraps. Default is to not. + Fixed noCache. </pre>'; case version_compare($currentVersion, '2.4.4', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('layout_config'); if (PHPWS_Error::logIfError($db->dropTableColumn('userAllow'))) { $content[] = '--- An error occurred when trying to drop the userAllow column from the layout_config table.'; } else { $content[] = '--- Dropped the userAllow column from the layout_config table.'; } layoutUpdateFiles(array('templates/user_form.tpl'), $content); $content[] = '2.4.4 changes ------------------- + Dropped unused column from config table. + Added collapse function. Adds id="layout-collapse" to theme template under the {COLLAPSE} tag. + Changed method of checking for javascript status. Less chance for error. + Fixed notice.</pre>'; case version_compare($currentVersion, '2.4.5', '<'): $content[] = '<pre>'; $db = new PHPWS_DB('layout_config'); if (PHPWS_Error::logIfError($db->addTableColumn('deity_reload', 'smallint not null default 0'))) { $content[] = 'Could not create layout_config.deity_reload column.'; return false; } else { $content[] = 'Added layout_config.deity_reload column.'; } layoutUpdateFiles(array('templates/metatags.tpl', 'conf/config.php'), $content); $content[] = '2.4.5 changes -------------------- + Added option to use a Key\'s summary or title to fill in the meta description. + Added new cacheHeader function to retain javascript and css information should a module return cached content before the above can be established. + Deities can now move a box to a theme locked area. + Added LAYOUT_IGNORE_JS_CHECK to force javascript use. + PHP 5 formatted'; case version_compare($currentVersion, '2.4.6', '<'): $content[] = '<pre>2.4.6 changes --------------------- + Fix to cache headers </pre>'; case version_compare($currentVersion, '2.4.7', '<'): $content[] = '<pre>'; layoutUpdateFiles(array('templates/themes.tpl'), $content); $content[] = '2.4.7 changes --------------------- + Added option to layout theme tab to disable or order module style sheet inclusion. + Can enable box move from mini admin </pre>'; case version_compare($currentVersion, '2.4.8', '<'): $content[] = '<pre>2.4.8 changes --------------------- + Bug#2424256 - Removed browser check to use @import on style sheets. </pre>'; case version_compare($currentVersion, '2.5.0', '<'): $content[] = '<pre>2.5.0 changes --------------------- + Icon class used. + Change of template directories to conform with core hub/branch change. + PHP 5 strict fixes. + New javascript detection method. + Default theme is now simple. + Allow admin to use hub or local themes. </pre>'; case version_compare($currentVersion, '2.5.1', '<'): $content[] = '<pre>2.5.1 changes --------------------- + Eloi George javascript patch applied </pre>'; case version_compare($currentVersion, '2.5.2', '<'): $content[] = '<pre>2.5.2 changes --------------------- + Eloi George templating patch added. + Fixed silent javascript failure. </pre>'; case version_compare($currentVersion, '2.5.3', '<'): $content[] = '<pre>2.5.3 changes --------------------- + Added HTTP tag for theming. Assists with http vs https + HOME_URL also added for theming. </pre>'; case version_compare($currentVersion, '2.5.4', '<'): $content[] = '<pre>2.5.4 changes --------------------- + Static notice corrected. + Page title can be changed from miniadmin </pre>'; case version_compare($currentVersion, '2.5.5', '<'): require_once PHPWS_SOURCE_DIR . 'mod/users/class/My_Page.php'; My_Page::unregisterMyPage('layout'); $content[] = '<pre>2.5.5 changes --------------------- + Unregister My Page </pre>'; case version_compare($currentVersion, '2.6.0', '<'): $content[] = <<<EOF <pre>2.6.0 changes -------------------- + Removed Layout\\'s caching code. + Fixed layout's problem with locked content variables. + Fixed: Content without a content_var was overwriting previously unlabeled content. + Added Layout method includeJavascript. Shortcut for script inclusion over addJSHeader. + Added Font Awesome icons. + Reworded box move command in miniadmin. + Removed deprecated ckeditor function. </pre> EOF; case version_compare($currentVersion, '2.6.1', '<'): $content[] = <<<EOF <pre>2.6.1 changes -------------------- + Added THEME_HTTP to the Layout wrap function. </pre> EOF; case version_compare($currentVersion, '2.7.0', '<'): if (PHPWS_Core::moduleExists('block')) { $db = Database::newDB(); $t = $db->addTable('layout_config'); $t->addField('header'); $t->addField('footer'); $config_result = $db->selectOneRow(); if (!empty($config_result['header'])) { $header_block = new Block_Item(); $header_block->title = 'Layout header'; $header_block->content = $_SESSION['Layout_Settings']->header; $header_block->hide_title = true; $header_block->save(); } if (!empty($config_result['footer'])) { $footer_block = new Block_Item(); $footer_block->title = 'Layout footer'; $footer_block->content = $_SESSION['Layout_Settings']->footer; $footer_block->hide_title = true; $footer_block->save(); } } $content[] = <<<EOF <pre>2.7.0 changes -------------------- + Removed header and footer. Moved data to Blocks. + Fixed some admin forms </pre> EOF; } return true; }
/** * Controller of user requests. Based on the command request variable * defaults to my_page */ public static function userAction() { $auth = Current_User::getAuthorization(); $content = $title = null; if (isset($_REQUEST['command'])) { $command = $_REQUEST['command']; } else { $command = 'my_page'; } switch ($command) { case 'login': if (!Current_User::isLogged() && isset($_POST['phpws_username']) && isset($_POST['phpws_password'])) { $result = Current_User::loginUser($_POST['phpws_username'], $_POST['phpws_password']); // here if (!$result) { $title = dgettext('users', 'Login page'); $message = dgettext('users', 'Username and password combination not found.'); $content = User_Form::loginPage(); } elseif (PHPWS_Error::isError($result)) { if (preg_match('/L\\d/', $result->code)) { $title = dgettext('users', 'Sorry'); $content = $result->getMessage(); $content .= ' ' . sprintf('<a href="mailto:%s">%s</a>', PHPWS_User::getUserSetting('site_contact'), dgettext('users', 'Contact the site administrator')); } else { PHPWS_Error::log($result); $message = dgettext('users', 'A problem occurred when accessing user information. Please try again later.'); } } else { Current_User::getLogin(); PHPWS_Core::returnToBookmark(); } } else { PHPWS_Core::errorPage('403'); } break; // This is used by auth scripts if they need to return the user to // where they left off after redirection to another site for SSO // This is used by auth scripts if they need to return the user to // where they left off after redirection to another site for SSO case 'return_bookmark': PHPWS_Core::popUrlHistory(); break; // reset user password // reset user password case 'rp': $user_id = User_Action::checkResetPassword(); if ($user_id) { $title = dgettext('users', 'Reset my password'); $content = User_Form::resetPassword($user_id, $_GET['auth']); } else { $title = dgettext('users', 'Sorry'); $content = dgettext('users', 'Your password request was not found or timed out. Please apply again.'); } break; case 'my_page': if ($auth->local_user) { PHPWS_Core::initModClass('users', 'My_Page.php'); $my_page = new My_Page(); $my_page->main(); } else { Layout::add(PHPWS_ControlPanel::display(dgettext('users', 'My Page unavailable to remote users.'), 'my_page')); } break; case 'signup_user': $title = dgettext('users', 'New Account Sign-up'); if (Current_User::isLogged()) { $content = dgettext('users', 'You already have an account.'); break; } $user = new PHPWS_User(); if (PHPWS_User::getUserSetting('new_user_method') == 0) { $content = dgettext('users', 'Sorry, we are not accepting new users at this time.'); break; } $content = User_Form::signup_form($user); break; case 'submit_new_user': $title = dgettext('users', 'New Account Sign-up'); $user_method = PHPWS_User::getUserSetting('new_user_method'); if ($user_method == 0) { Current_User::disallow(dgettext('users', 'New user signup not allowed.')); return; } $user = new PHPWS_User(); $result = User_Action::postNewUser($user); if (is_array($result)) { $content = User_Form::signup_form($user, $result); } else { $content = User_Action::successfulSignup($user); } break; case 'logout': $auth = Current_User::getAuthorization(); $auth->logout(); PHPWS_Core::killAllSessions(); PHPWS_Core::reroute('index.php?module=users&action=reset'); break; case 'login_page': if (Current_User::isLogged()) { PHPWS_Core::home(); } $title = dgettext('users', 'Login Page'); $content = User_Form::loginPage(); break; case 'confirm_user': if (Current_User::isLogged()) { PHPWS_Core::home(); } if (User_Action::confirmUser()) { $title = dgettext('users', 'Welcome!'); $content = dgettext('users', 'Your account has been successfully activated. Please log in.'); } else { $title = dgettext('users', 'Sorry'); $content = dgettext('users', 'This authentication does not exist.<br /> If you did not log in within the time frame specified in your email, please apply for another account.'); } User_Action::cleanUpConfirm(); break; case 'forgot_password': if (Current_User::isLogged()) { PHPWS_Core::home(); } $title = dgettext('users', 'Forgot Password'); $content = User_Form::forgotForm(); break; case 'post_forgot': $title = dgettext('users', 'Forgot Password'); if (ALLOW_CAPTCHA) { PHPWS_Core::initCoreClass('Captcha.php'); if (!Captcha::verify()) { $content = dgettext('users', 'Captcha information was incorrect.'); $content .= User_Form::forgotForm(); } else { if (!User_Action::postForgot($content)) { $content .= User_Form::forgotForm(); } } } elseif (!User_Action::postForgot($content)) { $content .= User_Form::forgotForm(); } break; case 'reset_pw': $pw_result = User_Action::finishResetPW(); switch ($pw_result) { case PHPWS_Error::isError($pw_result): $title = dgettext('users', 'Reset my password'); $content = dgettext('users', 'Passwords were not acceptable for the following reason:'); $content .= '<br />' . $pw_result->getmessage() . '<br />'; $content .= User_Form::resetPassword($_POST['user_id'], $_POST['authhash']); break; case 0: $title = dgettext('users', 'Sorry'); $content = dgettext('users', 'A problem occurred when trying to update your password. Please try again later.'); break; case 1: PHPWS_Core::home(); break; } break; default: PHPWS_Core::errorPage('404'); break; } if (isset($message)) { $tag['MESSAGE'] = $message; } if (isset($title)) { $tag['TITLE'] = $title; } if (isset($content)) { $tag['CONTENT'] = $content; } if (isset($tag)) { $final = PHPWS_Template::process($tag, 'users', 'user_main.tpl'); Layout::add($final); } }