Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 public static function loadNavBar()
 {
     $auth = \Current_User::getAuthorization();
     $vars['is_admin'] = \Current_User::allow('election');
     $vars['logout_uri'] = $auth->logout_link;
     $vars['username'] = \Current_User::getDisplayName();
     $template = new \Template($vars);
     $template->setModuleTemplate('election', 'navbar.html');
     $content = $template->get();
     \Layout::plug($content, 'NAV_LINKS');
 }
Esempio n. 3
0
 public static function loggedIn()
 {
     $auth = Current_User::getAuthorization();
     $template['GREETING'] = dgettext('users', 'Hello');
     $template['USERNAME'] = Current_User::getUsername();
     $template['DISPLAY_NAME'] = Current_User::getDisplayName();
     $template['PANEL'] = $template['MODULES'] = PHPWS_ControlPanel::panelLink();
     $logout_link = $auth->getLogoutLink();
     $template['ACCOUNT'] = '<a href="index.php?module=users&action=user&tab=my_page">' . dgettext('users', '<span class="glyphicon glyphicon-user"></span> Account') . '</a>';
     if ($logout_link) {
         $template['LOGOUT'] =& $logout_link;
     } else {
         $template['LOGOUT'] = PHPWS_Text::moduleLink(dgettext('users', '<span class="fa fa-sign-out"></span> Log Out'), 'users', array('action' => 'user', 'command' => 'logout'));
     }
     $template['HOME_USER_PANEL'] = $template['HOME'] = PHPWS_Text::moduleLink(dgettext('users', 'Home'));
     $usermenu = PHPWS_User::getUserSetting('user_menu');
     return PHPWS_Template::process($template, 'users', 'usermenus/' . $usermenu);
 }
Esempio n. 4
0
 public static function plug()
 {
     $tpl = array();
     $tpl['HOME_LINK'] = PHPWS_Text::moduleLink('Menu', 'intern');
     $tpl['ADD_LINK'] = PHPWS_Text::moduleLink('Add Student', 'intern', array('action' => 'edit_internship'));
     $tpl['SEARCH_LINK'] = PHPWS_Text::moduleLink('Search', 'intern', array('action' => 'search'));
     $auth = Current_User::getAuthorization();
     $tpl['USER_FULL_NAME'] = Current_User::getDisplayName();
     $tpl['LOGOUT_URI'] = $auth->logout_link;
     $adminOptions = array();
     // Edit list of majors
     if (Current_User::allow('intern', 'edit_major')) {
         $adminOptions['EDIT_MAJORS_LINK'] = PHPWS_Text::secureLink('Edit Undergraduate Majors', 'intern', array('action' => MAJOR_EDIT));
     }
     // Edit list grad programs
     if (Current_User::allow('intern', 'edit_grad_prog')) {
         $adminOptions['EDIT_GRAD_LINK'] = PHPWS_Text::secureLink('Edit Graduate Programs', 'intern', array('action' => GRAD_PROG_EDIT));
     }
     // Edit departments
     if (Current_User::allow('intern', 'edit_dept')) {
         $adminOptions['EDIT_DEPARTMENTS_LINK'] = PHPWS_Text::secureLink('Edit Departments', 'intern', array('action' => DEPT_EDIT));
     }
     // Edit list of states
     if (Current_User::allow('intern', 'edit_states')) {
         $adminOptions['EDIT_STATES_LINK'] = PHPWS_Text::secureLink('Edit States', 'intern', array('action' => STATE_EDIT));
     }
     if (Current_User::isDeity()) {
         $adminOptions['CONTROL_PANEL'] = PHPWS_Text::secureLink('Control Panel', 'controlpanel');
         $adminOptions['EDIT_ADMINS_LINK'] = PHPWS_Text::secureLink('Edit Administrators', 'intern', array('action' => 'edit_admins'));
     }
     // If any admin options were added, them show the dropdown and merge those
     // links into the main set of template tags
     if (sizeof($adminOptions) > 0) {
         $tpl['ADMIN_OPTIONS'] = '';
         // dummy var to show dropdown menu in template
         $tpl = array_merge($tpl, $adminOptions);
     }
     Layout::plug(PHPWS_Template::process($tpl, 'intern', 'top.tpl'), 'NAV_LINKS');
 }
Esempio n. 5
0
 public static function getLogoutURI()
 {
     return Current_User::getAuthorization()->logout_link;
 }
Esempio n. 6
0
 /**
  * This function adds links to the navigation bar at the top of the page.
  * This function assumes that there is a NAV_LINKS tag in the main theme template.
  */
 private function addNavLinks()
 {
     // Link to the pages. One nav button for each link.
     $viewStats = array("LINK" => "index.php?module=faxmaster&op=show_stats", "TEXT" => "View Statistics");
     $viewArchive = array("LINK" => "index.php?module=faxmaster&op=show_archive", "TEXT" => "View Archive");
     $settings = array("LINK" => "index.php?module=faxmaster&op=settings", "TEXT" => "Settings");
     $actionLog = array("LINK" => "index.php?module=faxmaster&op=showActionLog", "TEXT" => "Action Log");
     // Fill the links array
     $links = array();
     $links['repeat_nav_links'][] = $viewStats;
     // view stats button
     // Only show 'View Archive' button if user has permission to view the archive
     if (Current_User::allow('faxmaster', 'viewArchive')) {
         $links['repeat_nav_links'][] = $viewArchive;
         // view archive button
     }
     // Only show 'Settings' button if user has proper permissions
     if (Current_User::allow('faxmaster', 'settings')) {
         $links['repeat_nav_links'][] = $settings;
         // settings button
     }
     $links['repeat_nav_links'][] = $actionLog;
     $links['BRAND'] = 'Fax Server';
     $links['BRAND_LINK'] = 'index.php';
     if (Current_User::isDeity()) {
         $links['CONTROL_PANEL'] = PHPWS_Text::secureLink('Control Panel', 'controlpanel');
         $links['ADMIN_OPTIONS'] = '';
         //dummy tag to show dropdown menu in template
     }
     $links['USER_FULL_NAME'] = Current_User::getDisplayName();
     $auth = Current_User::getAuthorization();
     $links['LOGOUT_URI'] = $auth->logout_link;
     // Plug the navlinks into the navbar
     $navLinks = PHPWS_Template::process($links, 'faxmaster', 'navLinks.tpl');
     Layout::plug($navLinks, 'NAV_LINKS');
 }
Esempio n. 7
0
 public static function loadAdminBar()
 {
     $auth = \Current_User::getAuthorization();
     $nav_vars['is_deity'] = \Current_user::isDeity();
     $nav_vars['logout_uri'] = $auth->logout_link;
     $nav_vars['username'] = \Current_User::getDisplayName();
     if (\Current_User::allow('systemsinventory', 'edit')) {
         $nav_vars['add'] = '<a href="systemsinventory/system/add"><i class="fa fa-plus"></i> Add System</a>';
     }
     if (\Current_User::allow('systemsinventory', 'view')) {
         $nav_vars['search'] = '<a href="systemsinventory/search"><i class="fa fa-search"></i> Search Systems</a>';
     }
     if (\Current_User::allow('systemsinventory', 'reports')) {
         $nav_vars['reports'] = '<a href="systemsinventory/reports"><i class="fa fa-area-chart"></i> Reports</a>';
     }
     if (\Current_User::allow('systemsinventory', 'settings')) {
         $nav_vars['settings'] = '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"><i class="fa fa-cog"></i> Settings</a>';
     }
     $nav_bar = new \Template($nav_vars);
     $nav_bar->setModuleTemplate('systemsinventory', 'navbar.html');
     $content = $nav_bar->get();
     \Layout::plug($content, 'NAV_LINKS');
 }
Esempio n. 8
0
    /**
     * 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);
        }
    }
Esempio n. 9
0
 public static function isLocalUser()
 {
     $auth = Current_User::getAuthorization();
     return $auth->local_user;
 }