public function getController(\Request $request) { \Current_User::requireLogin(); $cmd = $request->shiftCommand(); if ($cmd == 'Admin' && \Current_User::allow('election')) { $admin = new \election\Controller\Admin($this); return $admin; } else { $user = new \election\Controller\User($this); return $user; } }
public function getController(\Request $request) { $cmd = $request->shiftCommand(); if ($cmd == 'Admin') { if (\Current_User::allow('tailgate')) { $admin = new \tailgate\Controller\Admin($this); return $admin; } else { \Current_User::requireLogin(); } } else { $user = new \tailgate\Controller\User($this); return $user; } }
public function getController(\Request $request) { $cmd = $request->shiftCommand(); if (\Current_User::allow('sysinventory')) { switch ($cmd) { case 'system': $system = new \systemsinventory\Controller\System($this); return $system; case 'settings': if (\Current_User::allow('systemsinventory', 'settings')) { $settings = new \systemsinventory\Controller\Settings($this); return $settings; } default: $search = new \systemsinventory\Controller\Search($this); return $search; } } else { \Current_User::requireLogin(); } }
/** * Action * * @author Greg Meiste <*****@*****.**> */ function action() { Layout::addStyle('wiki'); if (!PHPWS_Settings::get('wiki', 'allow_anon_view') && !Current_User::isLogged()) { Current_User::requireLogin(); return; } if (isset($_REQUEST['page_id']) && is_numeric($_REQUEST['page_id'])) { PHPWS_Core::initModClass('wiki', 'WikiPage.php'); $wikipage = new WikiPage($_REQUEST['page_id']); } else { if (isset($_REQUEST['page']) && is_string($_REQUEST['page'])) { PHPWS_Core::initModClass('wiki', 'WikiPage.php'); $wikipage = new WikiPage($_REQUEST['page']); } } if (!isset($_REQUEST['op']) && !isset($_REQUEST['page_op'])) { // phpWebSite 1.5.0 and later mod_rewrite method if (isset($_GET['var1'])) { $_REQUEST['id'] = $_GET['id'] = $_GET['var1']; } if (isset($_REQUEST['id']) && is_string($_REQUEST['id'])) { PHPWS_Core::initModClass('wiki', 'WikiPage.php'); $wikipage = new WikiPage($_REQUEST['id']); } $_REQUEST['page_op'] = 'view'; } WikiManager::addToMiniAdmin(); if (isset($_REQUEST['page_op']) && isset($wikipage)) { $wikipage->action(); return; } switch (@$_REQUEST['op']) { case 'admin': case 'savesettings': PHPWS_Core::initModClass('wiki', 'WikiSettings.php'); WikiSettings::admin(); break; case 'doimagedelete': case 'doimageupload': case 'imageupload': WikiManager::imageUpload(); break; case 'imagedelete': PHPWS_Core::initModClass('wiki', 'WikiImage.php'); $delImage = new WikiImage($_REQUEST['id']); $template['TITLE'] = dgettext('wiki', 'Wiki Images'); $template['CONTENT'] = $delImage->delete(); Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE); break; case 'imagecopy': PHPWS_Core::initModClass('wiki', 'WikiImage.php'); $image = new WikiImage($_REQUEST['id']); Clipboard::copy($image->getFilename(), $image->getTag()); PHPWS_Core::goBack(); break; case 'recentchanges': $template['TITLE'] = dgettext('wiki', 'Recent changes'); $template['CONTENT'] = WikiManager::recentChanges(); Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE); break; case 'random': WikiManager::random(); break; case 'interwikisetup': case 'addinterwiki': PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki(); $interwiki->setup(); break; case 'editinterwiki': case 'saveinterwiki': case 'deleteinterwiki': case 'dodeleteinterwiki': PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki($_REQUEST['id']); $interwiki->setup(); break; case 'copyinterwiki': PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki($_REQUEST['id']); Clipboard::copy($interwiki->getLabel(), $interwiki->getLabel() . ':PageName'); PHPWS_Core::goBack(); break; default: $_REQUEST['page'] = PHPWS_Settings::get('wiki', 'default_page'); WikiManager::action(); } }
public function userViewFolder() { $this->loadFolder(); if (!$this->folder->id || !$this->folder->public_folder) { $this->title = dgettext('filecabinet', 'Sorry'); $this->content = dgettext('filecabinet', 'This is a private folder.'); return; } if (!$this->folder->allow()) { if (Current_User::isLogged()) { $this->title = dgettext('filecabinet', 'Sorry'); $this->content = dgettext('filecabinet', 'You do not have permission to view this folder.'); } else { Current_User::requireLogin(); } return; } $this->title = $this->folder->title; $this->loadForms(); $kids = PHPWS_Settings::get('filecabinet', 'no_kids'); $this->forms->folderContents($this->folder); }
public function viewPage() { if (empty($this->page)) { $this->loadPage(); } if ($this->page->id) { $this->page->loadKey(); if ($this->page->_key->allowView()) { $content = $this->page->view(); if (Current_User::allow('pagesmith', 'edit_page', $this->page->id)) { $content .= sprintf('<p class="pagesmith-edit">%s</p>', $this->page->editLink()); } } else { if (!Current_User::requireLogin()) { $content = dgettext('pagesmith', 'Restricted page.'); } } Layout::add($content); } else { header('HTTP/1.0 404 Not Found'); Layout::add(dgettext('pagesmith', 'Sorry, but your page could not be found. You may wish to search for it.')); } }
/** * Displays the blog entry * * @param boolean edit If true, show edit link * @param boolean summarized If true, this is a summarized entry */ public function view($edit = true, $summarized = true) { if (!$this->id) { PHPWS_Core::errorPage(404); } $key = new Key($this->key_id); if (!$key->allowView() || !Blog_User::allowView()) { Current_User::requireLogin(); return dgettext('blog', 'You do not have permission to view this entry.'); } $template['TITLE'] = sprintf('<a href="%s" rel="bookmark">%s</a>', $this->getViewLink(true), $this->title); $template['TITLE_NO_LINK'] = $this->title; if ($this->publish_date > time()) { $template['UNPUBLISHED'] = dgettext('blog', 'Unpublished'); } elseif ($this->expire_date && $this->expire_date < time()) { $template['UNPUBLISHED'] = dgettext('blog', 'Expired'); } $template['LOCAL_DATE'] = $this->getPublishDate(); $summary = $this->getSummary(true); $entry = $this->getEntry(true); if ($summarized) { if (empty($summary)) { $template['SUMMARY'] = PHPWS_Text::parseTag($entry); } else { if (!empty($entry)) { $template['READ_MORE'] = PHPWS_Text::rewriteLink(Icon::get('chevron-circle-down') . ' ' . dgettext('blog', 'Read more'), 'blog', array('id' => $this->id), null, 'Read more of this entry', 'btn btn-default'); } $template['SUMMARY'] = PHPWS_Text::parseTag($summary); } } else { $template['SUMMARY'] = PHPWS_Text::parseTag($summary); $template['ENTRY'] = PHPWS_Text::parseTag($entry); } $template['IMAGE'] = $this->getFile($this->thumbnail && $summarized); if ($edit && (Current_User::allow('blog', 'edit_blog', $this->id, 'entry') || Current_User::allow('blog', 'edit_blog') && $this->author_id == Current_User::getId())) { $vars['blog_id'] = $this->id; $vars['action'] = 'admin'; $vars['command'] = 'edit'; $template['EDIT_LINK'] = PHPWS_Text::secureLink(dgettext('blog', 'Edit'), 'blog', $vars); $template['EDIT_URI'] = PHPWS_Text::linkAddress('blog', $vars, true); if (!$summarized) { MiniAdmin::add('blog', array(PHPWS_Text::secureLink(dgettext('blog', 'Edit blog'), 'blog', $vars))); } } // Check setting for showing when the entry was posted if (PHPWS_Settings::get('blog', 'show_posted_by')) { $template['POSTED_BY'] = dgettext('blog', 'By'); $template['AUTHOR'] = $this->author; } // Check settings for showing the author of the entry if (PHPWS_Settings::get('blog', 'show_posted_date')) { $template['PUBLISHED'] = dgettext('blog', 'Published'); $template['POSTED_ON'] = dgettext('blog', 'Posted on'); $template['PUBLISHED_DATE'] = $this->getPublishDateShort(); } if ($summarized) { $view_tpl = 'view_list.tpl'; } else { $template['COMMENT_SCRIPT'] = PHPWS_Settings::get('blog', 'comment_script'); $key->flag(); $view_tpl = 'view_full.tpl'; } return PHPWS_Template::process($template, 'blog', $view_tpl); }
/** * sends a user to the 403 error page and logs a message (if specified) * to the security log * @param string message Message sent to log * @param boolean login If true, then allow change to login */ public static function disallow($message = null, $login = true) { if ($login && Current_User::requireLogin()) { return; } else { PHPWS_User::disallow($message); } }