Пример #1
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');
 }
Пример #2
0
 public static function getDisplayName($respectMask = true)
 {
     if (self::isGuest()) {
         return null;
     }
     if (self::isMasquerading() && $respectMask) {
         //TODO: Fix the users class so we don't have to query this ourselves....
         $db = new \PHPWS_DB('users');
         $db->addWhere('username', $_SESSION['hms_masquerade_username']);
         $result = $db->select('row');
         return $result['display_name'];
     }
     return Current_User::getDisplayName();
 }
Пример #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);
 }
Пример #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');
 }
Пример #5
0
 public function save()
 {
     // No need to save dummy keys
     if ($this->id === 0) {
         return true;
     }
     if (empty($this->module) || empty($this->item_id)) {
         return false;
     }
     if (empty($this->item_name) || $this->item_name == 'home') {
         $this->item_name = $this->module;
     }
     if (empty($this->create_date)) {
         $this->create_date = time();
     }
     if (empty($this->creator)) {
         $this->creator = Current_User::getDisplayName();
         $this->creator_id = Current_User::getId();
     }
     $this->updater = Current_User::getDisplayName();
     $this->updater_id = Current_User::getId();
     $this->update_date = time();
     $db = new PHPWS_DB('phpws_key');
     if (!$this->id) {
         $db->addWhere('module', $this->module);
         $db->addWhere('item_name', $this->item_name);
         $db->addWhere('item_id', $this->item_id);
         $result = $db->select('row');
         if (PHPWS_Error::isError($result)) {
             return $result;
         } elseif ($result) {
             return PHPWS_Error::get(KEY_DUPLICATE, 'core', 'Key::save', sprintf('%s-%s-%s', $this->module, $this->item_name, $this->item_id));
         }
         $db->reset();
     }
     $result = $db->saveObject($this);
     if (PHPWS_Error::isError($result)) {
         $this->_error = $result;
         return $result;
     }
     return true;
 }
Пример #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');
 }
Пример #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');
 }
Пример #8
0
 public function post_entry()
 {
     if (!Current_User::authorized('blog', 'edit_blog')) {
         Current_User::disallow();
     }
     if (empty($_POST['title'])) {
         $this->_error[] = dgettext('blog', 'Missing title.');
     } else {
         $this->title = strip_tags($_POST['title']);
     }
     $summary_and_entry = $_POST['summary'];
     if (!$this->id && strlen($summary_and_entry) > 1000) {
         if (!preg_match('/<hr[^>]?/', $summary_and_entry)) {
             $paragraphs = explode('<p>', $summary_and_entry);
             if (count($paragraphs) > 3) {
                 $paragraphs[2] .= '<hr />';
                 $summary_and_entry = implode('<p>', $paragraphs);
             }
         }
     }
     if (empty($summary_and_entry)) {
         $this->_error[] = dgettext('blog', 'Your submission must have some content.');
     } else {
         // We don't catch the regular expression result because we only care about matches
         preg_replace_callback('@(.*?)<hr[^>]*/>(.*)@s', function ($matches) {
             $GLOBALS['split_summary'] = $matches;
         }, $summary_and_entry);
         if (isset($GLOBALS['split_summary'])) {
             $this->setSummary($GLOBALS['split_summary'][1]);
             $this->setEntry($GLOBALS['split_summary'][2]);
         } else {
             $this->setSummary($summary_and_entry);
             $this->entry = null;
         }
     }
     if (isset($_POST['image_id'])) {
         $this->image_id = (int) $_POST['image_id'];
     }
     if (isset($_POST['thumbnail'])) {
         $this->thumbnail = 1;
     } else {
         $this->thumbnail = 0;
     }
     if (empty($this->author)) {
         $this->author = Current_User::getDisplayName();
     }
     if (empty($_POST['publish_date'])) {
         $this->publish_date = time();
     } else {
         $this->publish_date = strtotime($_POST['publish_date']);
     }
     if (empty($_POST['expire_date'])) {
         $this->expire_date = 0;
     } else {
         $this->expire_date = strtotime($_POST['expire_date']);
     }
     $this->approved = 1;
     $link_choices[] = 'none';
     $link_choices[] = 'default';
     $link_choices[] = 'readmore';
     $link_choices[] = 'parent';
     $link_choices[] = 'url';
     $image_link =& $_POST['image_link'];
     if (!in_array($image_link, $link_choices)) {
         $this->image_link = 'default';
     } elseif ($_POST['image_link'] != 'url') {
         $this->image_link = $image_link;
     } else {
         $url = $_POST['image_url'];
         if (!empty($url) || $url == 'http://') {
             $this->image_link = PHPWS_Text::checkLink($url);
         } else {
             $this->image_link = 'default';
         }
     }
     return true;
 }