本文整理汇总了PHP中Current_User::authorized方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::authorized方法的具体用法?PHP Current_User::authorized怎么用?PHP Current_User::authorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Current_User
的用法示例。
在下文中一共展示了Current_User::authorized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin
public function admin()
{
switch ($_REQUEST['iop']) {
case 'delete_image':
if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->loadImage(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
$this->image->delete();
PHPWS_Core::goBack();
break;
case 'post_image_upload':
if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
if (!$this->postImageUpload()) {
\Cabinet::setMessage('Failed to upload image. Check directory permissions.');
}
Layout::nakedDisplay();
//\PHPWS_Core::goBack();
break;
case 'upload_image_form':
if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->loadImage(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
$this->edit();
echo Layout::wrap($this->content, 'Image Upload', true);
exit;
}
}
示例2: process
public static function process()
{
if (!Current_User::authorized('analytics')) {
Current_User::disallow();
}
$panel = self::cpanel();
if (isset($_REQUEST['command'])) {
$command = $_REQUEST['command'];
} else {
$command = $panel->getCurrentTab();
}
switch ($command) {
case 'list':
$panel->setContent(self::listTrackers());
break;
case 'new':
$panel->setContent(self::newTracker());
break;
case 'create':
$panel->setContent(self::createTracker());
break;
case 'edit':
$panel->setContent(self::editTracker());
break;
case 'delete':
$panel->setContent(self::deleteTracker());
break;
case 'save_tracker':
$panel->setContent(self::saveTracker());
break;
}
Layout::add(PHPWS_ControlPanel::display($panel->display()));
}
示例3: adminMenu
function adminMenu()
{
if (!Current_User::allow('whatsnew')) {
Current_User::disallow();
}
$this->loadPanel();
$javascript = false;
$this->loadMessage();
switch ($_REQUEST['aop']) {
case 'menu':
if (!isset($_GET['tab'])) {
$this->loadForm('settings');
} else {
$this->loadForm($_GET['tab']);
}
break;
case 'post_settings':
if (!Current_User::authorized('whatsnew')) {
Current_User::disallow();
}
if ($this->postSettings()) {
$this->forwardMessage(dgettext('whatsnew', 'Whatsnew settings saved.'));
PHPWS_Core::reroute('index.php?module=whatsnew&aop=menu');
} else {
$this->loadForm('settings');
}
break;
case 'flush_cache':
if (!Current_User::authorized('whatsnew')) {
Current_User::disallow();
}
if ($this->flushCache()) {
$this->forwardMessage(dgettext('whatsnew', 'Cache flushed.'));
PHPWS_Core::reroute('index.php?module=whatsnew&aop=menu');
} else {
$this->loadForm('settings');
}
break;
}
$tpl['TITLE'] = $this->title;
$tpl['CONTENT'] = $this->content;
$tpl['MESSAGE'] = $this->message;
if ($javascript) {
Layout::nakedDisplay(PHPWS_Template::process($tpl, 'whatsnew', 'main_admin.tpl'));
} else {
$this->panel->setContent(PHPWS_Template::process($tpl, 'whatsnew', 'main_admin.tpl'));
Layout::add(PHPWS_ControlPanel::display($this->panel->display()));
}
}
示例4: admin
public function admin()
{
switch ($_REQUEST['mop']) {
case 'delete_multimedia':
if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->loadMultimedia(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
$this->multimedia->delete();
PHPWS_Core::goBack();
break;
case 'post_multimedia_upload':
if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->postMultimediaUpload();
\PHPWS_Core::goBack();
break;
case 'upload_multimedia_form':
if (!Current_User::secured('filecabinet', 'edit_folders', $this->multimedia->folder_id, 'folder')) {
Current_User::disallow();
}
$this->loadMultimedia(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
if (!$this->multimedia->id) {
$this->multimedia->folder_id = filter_input(INPUT_GET, 'folder_id', FILTER_VALIDATE_INT);
}
$this->edit();
echo json_encode(array('title' => $this->title, 'content' => $this->content));
exit;
case 'edit_rtmp':
if (!Current_User::secured('filecabinet', 'edit_folders', $this->multimedia->folder_id, 'folder')) {
Current_User::disallow();
}
$this->loadMultimedia(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
$this->editRTMP();
echo json_encode(array('title' => $this->title, 'content' => $this->content));
exit;
case 'post_rtmp':
if (!Current_User::authorized('filecabinet', 'edit_folders', $this->multimedia->folder_id, 'folder')) {
Current_User::disallow();
}
if (!$this->postRTMP()) {
$this->editRTMP();
}
\PHPWS_Core::goBack();
break;
}
return $this->content;
}
示例5: remove
function remove()
{
if (!(Current_User::authorized('wiki', 'delete_page') && $this->getAllowEdit() && !$this->getVrCurrent())) {
Current_User::disallow(dgettext('wiki', 'User attempted to remove previous page version.'));
return;
}
PHPWS_Core::initModClass('version', 'Version.php');
$version = new Version('wiki_pages', $this->getId());
$version->delete(FALSE);
WikiManager::sendMessage(dgettext('wiki', 'Old revision removed'), array('page' => $this->getTitle(FALSE)), FALSE);
}
示例6: process
public function process()
{
if (!Current_User::allow('checkin')) {
Current_User::disallow();
}
if (isset($_REQUEST['aop'])) {
if ($_REQUEST['aop'] == 'switch') {
if (Current_User::allow('checkin', 'settings')) {
$cmd = 'settings';
} elseif (Current_User::allow('checkin', 'assign_visitors')) {
$cmd = 'assign';
} else {
$cmd = 'waiting';
}
} else {
$cmd = $_REQUEST['aop'];
}
} elseif ($_REQUEST['tab']) {
$cmd = $_REQUEST['tab'];
} else {
PHPWS_Core::errorPage('404');
}
$js = false;
$js = isset($_GET['print']);
switch ($cmd) {
case 'finish_meeting':
$this->finishMeeting();
PHPWS_Core::goBack();
break;
case 'start_meeting':
$this->startMeeting();
PHPWS_Core::goBack();
break;
case 'sendback':
$this->sendBack();
PHPWS_Core::goBack();
break;
case 'unavailable':
$this->unavailable();
PHPWS_Core::goBack();
break;
case 'available':
$this->available();
PHPWS_Core::goBack();
break;
case 'report':
if (!PHPWS_Settings::get('checkin', 'staff_see_reports') && !Current_User::allow('checkin', 'assign_visitors')) {
Current_User::disallow();
}
if (isset($_GET['daily_report'])) {
$this->dailyReport(isset($_GET['print']));
} elseif (isset($_GET['summary_report'])) {
$this->summaryReport();
} else {
$this->report();
}
//$this->report2();
break;
case 'daily_report':
if (!PHPWS_Settings::get('checkin', 'staff_see_reports') && !Current_User::allow('checkin', 'assign_visitors')) {
Current_User::disallow();
}
break;
case 'month_report':
if (!Current_User::allow('checkin', 'assign_visitors')) {
Current_User::disallow();
}
$this->monthReport(isset($_GET['print']));
break;
case 'visitor_report':
if (!Current_User::allow('checkin', 'assign_visitors')) {
Current_User::disallow();
}
$this->visitorReport(isset($_GET['print']));
break;
case 'reassign':
// Called via ajax
if (Current_User::authorized('checkin', 'assign_visitors')) {
if (isset($_GET['staff_id']) && $_GET['staff_id'] >= 0 && isset($_GET['visitor_id'])) {
$this->loadVisitor($_GET['visitor_id']);
$staff_id = $this->visitor->assigned;
$db = new PHPWS_DB('checkin_visitor');
$db->addValue('assigned', (int) $_GET['staff_id']);
$db->addWhere('id', (int) $_GET['visitor_id']);
PHPWS_Error::logIfError($db->update());
printf('staff_id %s, visitor_id %s', $_GET['staff_id'], $_GET['visitor_id']);
$this->loadStaff($staff_id);
/*
if ($this->staff->status == 3) {
$this->staff->status = 0;
$this->staff->save();
}
*/
}
}
exit;
break;
case 'move_up':
if (Current_User::allow('checkin', 'assign_visitors')) {
$db = new PHPWS_DB('checkin_staff');
//.........这里部分代码省略.........
示例7:
<?php
/**
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
*/
if (!defined('PHPWS_SOURCE_DIR')) {
include '../../core/conf/404.html';
exit;
}
if (!Current_User::authorized('block')) {
Current_User::disallow();
return;
}
PHPWS_Core::initModClass('block', 'Block_Admin.php');
Block_Admin::action();
示例8: postBlock
public static function postBlock(Block_Item $block)
{
if (!Current_User::authorized('block', 'edit_block', $block->id)) {
Current_User::disallow();
}
if (isset($_POST['pick_block'])) {
self::lockBlock($_POST['block_list'], $_POST['key_id']);
return true;
}
if (isset($_POST['hide_title'])) {
$block->hide_title = 1;
} else {
$block->hide_title = 0;
}
if (isset($_POST['hide_narrow'])) {
$block->hide_narrow = 1;
} else {
$block->hide_narrow = 0;
}
$block->setTitle($_POST['title']);
$block->setContent($_POST['block_content']);
if (empty($block->title)) {
$content = trim(strip_tags($_POST['block_content']));
if (!empty($content)) {
try {
$offset = strpos($content, ' ', 10);
$title_sub = ucfirst(substr($content, 0, $offset));
} catch (\Exception $e) {
/**
* strpos will throw a warning which, depending on error settings,
* is changed into an exception.
* The fastest way to check for a character in a string is strpos, so
* error checking cannot be done.
*
*/
if ($e->getCode() == 0) {
$title_sub = substr($content, 0, 15);
} else {
throw $e;
}
}
$block->setTitle($title_sub);
$block->hide_title = 1;
} else {
$block->setTitle(t('Untitled'));
$block->hide_title = 1;
}
}
if (empty($block->content) && empty($block->title) && empty($block->file_id)) {
return false;
} else {
return true;
}
}
示例9: main
public static function main()
{
if (!Current_User::authorized('blog')) {
Current_User::disallow(dgettext('blog', 'User attempted access to Blog administration.'));
return;
}
$title = $content = NULL;
$message = Blog_Admin::getForward();
$panel = Blog_Admin::cpanel();
$panel->enableSecure();
if (isset($_REQUEST['command'])) {
$command = $_REQUEST['command'];
} else {
$command = $panel->getCurrentTab();
}
if (isset($_REQUEST['blog_id'])) {
$blog = new Blog((int) $_REQUEST['blog_id']);
} else {
$blog = new Blog();
}
switch ($command) {
case 'edit':
$panel->setCurrentTab('list');
if (!Current_User::isUser($blog->author_id) && !Current_User::authorized('blog', 'edit_blog', $_REQUEST['blog_id'], 'entry')) {
Current_User::disallow(dgettext('blog', 'User tried to edit a blog.'));
return;
}
$title = dgettext('blog', 'Update Blog Entry');
$content = Blog_Form::edit($blog);
break;
case 'new':
$title = dgettext('blog', 'New Blog Entry');
$content = Blog_Form::edit($blog);
break;
case 'delete':
//Blog_Admin::resetCache();
$result = $blog->delete();
Blog_Admin::setForward(dgettext('blog', 'Blog entry deleted.'), 'list');
break;
case 'list':
$title = dgettext('blog', 'Blog Entries');
$content = Blog_Admin::entry_list();
break;
case 'menu_submit_link':
Menu::pinLink(dgettext('blog', 'Submit entry'), 'index.php?module=blog&action=user&action=submit');
PHPWS_Core::reroute('index.php?module=blog&action=admin&tab=settings&authkey=' . Current_User::getAuthKey());
break;
case 'sticky':
if (!Current_User::isUnrestricted('blog')) {
Current_User::disallow();
}
Blog_Admin::sticky($blog);
PHPWS_Core::goBack();
break;
case 'unsticky':
if (!Current_User::isUnrestricted('blog')) {
Current_User::disallow();
}
Blog_Admin::unsticky($blog);
PHPWS_Core::goBack();
break;
case 'post_entry':
$title = dgettext('blog', 'Blog Archive');
$panel->setCurrentTab('list');
$blog->post_entry();
$link_back = PHPWS_Text::linkAddress('blog', array('action' => 'admin', 'tab' => 'list'), TRUE);
if ($blog->_error) {
if (empty($blog->id)) {
$panel->setCurrentTab('new');
}
$content = Blog_Form::edit($blog);
} else {
if (!isset($_POST['blog_id']) && PHPWS_Core::isPosted()) {
Blog_Admin::setForward(dgettext('blog', 'Entry saved successfully.'), 'list');
}
$result = $blog->save();
//Blog_Admin::resetCache();
if (PHPWS_Error::isError($result)) {
$message = dgettext('blog', 'An error occurred when trying to save your entry. Please check your logs.');
PHPWS_Error::log($result);
Blog_Admin::setForward($message, 'list');
}
if (!$blog->approved) {
Blog_Admin::setForward(dgettext('blog', 'Your entry is being held for approval.'), 'list');
} else {
PHPWS_Core::reroute($blog->getViewLink(true));
}
}
break;
case 'reset_cache':
Blog_Admin::resetCache();
PHPWS_Core::goBack();
break;
case 'post_settings':
if (!Current_User::authorized('blog', 'settings')) {
Current_User::disallow();
return;
}
if (Current_User::isDeity() && isset($_POST['purge_confirm'])) {
$title = dgettext('blog', 'Purge Blog Entries');
//.........这里部分代码省略.........
示例10: postDenyAllow
public static function postDenyAllow()
{
if (!Current_User::authorized('access', 'admin_options')) {
Current_User::disallow();
exit;
}
PHPWS_Core::initModClass('access', 'Allow_Deny.php');
if (!empty($_POST['allow_deny_enabled'])) {
PHPWS_Settings::set('access', 'allow_deny_enabled', 1);
} else {
PHPWS_Settings::set('access', 'allow_deny_enabled', 0);
}
PHPWS_Settings::save('access');
if (isset($_POST['add_allow_address']) && !empty($_POST['allow_address'])) {
$allow = new Access_Allow_Deny();
$allow->allow_or_deny = 1;
$result = $allow->setIpAddress($_POST['allow_address']);
if (!$result) {
return $result;
}
$allow->active = 1;
return $allow->save();
}
if (isset($_POST['add_deny_address']) && !empty($_POST['deny_address'])) {
$deny = new Access_Allow_Deny();
$deny->allow_or_deny = 0;
$result = $deny->setIpAddress($_POST['deny_address']);
if (!$result) {
return $result;
}
$deny->active = 1;
return $deny->save();
}
if (isset($_POST['allow_action']) && $_POST['allow_action'] != 'none') {
if ($_POST['allow_action'] == 'allow_all') {
if (PHPWS_Settings::get('access', 'allow_all')) {
PHPWS_Settings::set('access', 'allow_all', 0);
} else {
PHPWS_Settings::set('access', 'allow_all', 1);
}
PHPWS_Settings::save('access');
return true;
} elseif (!empty($_POST['allows'])) {
$db = new PHPWS_DB('access_allow_deny');
// just in case something goes wrong
$db->addWhere('allow_or_deny', 1);
$db->addWhere('id', $_POST['allows']);
switch ($_POST['allow_action']) {
case 'active':
$db->addValue('active', 1);
return $db->update();
break;
case 'deactive':
$db->addValue('active', 0);
return $db->update();
break;
case 'delete':
return $db->delete();
break;
}
}
}
if ($_POST['deny_action'] == 'deny_all') {
if (PHPWS_Settings::get('access', 'deny_all')) {
PHPWS_Settings::set('access', 'deny_all', 0);
} else {
PHPWS_Settings::set('access', 'deny_all', 1);
}
PHPWS_Settings::save('access');
return true;
} elseif (!empty($_POST['denys'])) {
$db = new PHPWS_DB('access_allow_deny');
// just in case something goes wrong
$db->addWhere('allow_or_deny', 0);
$db->addWhere('id', $_POST['denys']);
switch ($_POST['deny_action']) {
case 'active':
$db->addValue('active', 1);
return $db->update();
break;
case 'deactive':
$db->addValue('active', 0);
return $db->update();
break;
case 'delete':
return $db->delete();
break;
}
}
return true;
}
示例11: admin
public static function admin()
{
if (!Current_User::allow('layout')) {
Current_User::disallow();
}
PHPWS_Core::initModClass('controlpanel', 'Panel.php');
$title = $content = null;
$panel = Layout_Admin::adminPanel();
if (isset($_REQUEST['command'])) {
$command = $_REQUEST['command'];
} else {
$command = $panel->getCurrentTab();
}
switch ($command) {
case 'arrange':
$title = dgettext('layout', 'Arrange Layout');
$content[] = Layout_Admin::arrangeForm();
break;
case 'turn_off_box_move':
Layout::moveBoxes(false);
PHPWS_Core::goBack();
break;
case 'post_style_change':
$result = Layout_Admin::postStyleChange();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
}
javascript('close_refresh');
break;
case 'reset_boxes':
if (!Current_User::authorized('layout')) {
Current_User::disallow();
}
Layout::resetDefaultBoxes();
unset($_SESSION['Layout_Settings']);
PHPWS_Core::reroute('index.php?module=layout&action=admin&authkey=' . Current_User::getAuthKey());
break;
case 'move_boxes_on':
if (!Current_User::authorized('layout')) {
Current_User::disallow();
}
Layout::moveBoxes(true);
PHPWS_Core::goBack();
break;
case 'move_boxes_off':
if (!Current_User::authorized('layout')) {
Current_User::disallow();
}
Layout::moveBoxes(false);
PHPWS_Core::goBack();
break;
case 'confirmThemeChange':
$title = dgettext('layout', 'Themes');
if (isset($_POST['confirm'])) {
Layout_Admin::changeTheme();
PHPWS_Core::reroute('index.php?module=layout&action=admin&tab=theme');
exit;
} else {
Layout::reset();
}
$content[] = Layout_Admin::adminThemes();
break;
case 'meta':
$title = dgettext('layout', 'Edit Meta Tags');
$content[] = Layout_Admin::metaForm();
break;
case 'clear_templates':
if (!Current_User::authorized('layout')) {
Current_User::disallow();
}
$files = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . 'templates/cache', false, true);
if (!empty($files) && is_array($files)) {
foreach ($files as $fn) {
$delete_cache_path = "templates/cache/{$fn}";
if (is_file($delete_cache_path)) {
unlink('templates/cache/' . $fn);
}
}
}
PHPWS_Core::goBack();
break;
case 'clear_cache':
if (!Current_User::authorized('layout')) {
Current_User::disallow();
}
PHPWS_Cache::clearCache();
PHPWS_Core::goBack();
break;
case 'moveBox':
$result = Layout_Admin::moveBox();
PHPWS_Error::logIfError($result);
javascript('close_refresh');
Layout::nakedDisplay();
break;
case 'postMeta':
if (!Current_User::authorized('layout')) {
Current_User::disallow();
}
Layout_Admin::postMeta();
if (isset($_POST['key_id'])) {
//.........这里部分代码省略.........
示例12: array
<?php
/**
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
*/
if (!defined('PHPWS_SOURCE_DIR')) {
include '../../core/conf/404.html';
exit;
}
PHPWS_Core::requireConfig('boost');
if (DEITY_ACCESS_ONLY && !Current_User::isDeity()) {
Current_User::disallow();
}
if (!Current_User::authorized('boost')) {
Current_User::disallow();
}
if (!isset($_REQUEST['action'])) {
PHPWS_Core::errorPage(404);
}
$js = false;
$content = array();
PHPWS_Core::initModClass('boost', 'Form.php');
PHPWS_Core::initModClass('controlpanel', 'Panel.php');
PHPWS_Core::initModClass('boost', 'Action.php');
$boostPanel = new PHPWS_Panel('boost');
$boostPanel->enableSecure();
Boost_Form::setTabs($boostPanel);
$vars = array('action' => 'admin', 'tab' => $boostPanel->getCurrentTab());
$backToBoost = PHPWS_Text::secureLink(dgettext('boost', 'Return to Boost'), 'boost', $vars);
switch ($_REQUEST['action']) {
示例13: delete
/**
* Delete
*
* @author Greg Meiste <greg.meiste+github@gmail.com>
*/
function delete()
{
if (!Current_User::authorized('wiki', 'upload_images') && !(PHPWS_Settings::get('wiki', 'allow_image_upload') && Current_User::isLogged())) {
Current_User::disallow(dgettext('wiki', 'User attempted access to image delete.'));
return;
}
if (isset($_REQUEST['yes'])) {
@unlink(PHPWS_HOME_DIR . 'images/wiki/' . $this->getFilename());
$db = new PHPWS_DB('wiki_images');
$db->addWhere('id', $this->getId());
if (PHPWS_Error::logIfError($db->delete())) {
return dgettext('wiki', 'Error deleting image.');
}
return dgettext('wiki', 'Image deleted!');
} else {
if (isset($_REQUEST['no'])) {
return dgettext('wiki', 'Image was not deleted!');
}
}
$tags = array();
$tags['MESSAGE'] = dgettext('wiki', 'Are you sure you want to delete this image?');
$tags['YES'] = PHPWS_Text::secureLink(dgettext('wiki', 'Yes'), 'wiki', array('op' => 'doimagedelete', 'yes' => 1, 'id' => $this->getId()));
$tags['NO'] = PHPWS_Text::secureLink(dgettext('wiki', 'No'), 'wiki', array('op' => 'doimagedelete', 'no' => 1, 'id' => $this->getId()));
$tags['WIKIPAGE'] = '<img src="images/wiki/' . $this->getFilename() . '" alt="" />';
return PHPWS_Template::processTemplate($tags, 'wiki', 'confirm.tpl');
}
示例14: main
public static function main()
{
if (!Current_User::allow('search')) {
Current_User::disallow();
}
$panel = Search_Admin::cpanel();
if (isset($_REQUEST['command'])) {
$command = $_REQUEST['command'];
} elseif (isset($_REQUEST['tab'])) {
$command = $_REQUEST['tab'];
} else {
$command = $panel->getCurrentTab();
}
switch ($command) {
case 'delete_keyword':
case 'add_keyword':
case 'remove_searchword':
case 'add_ignore':
if (!Current_User::authorized('search')) {
Current_User::disallow();
}
break;
}
switch ($command) {
case 'keyword':
$template = Search_Admin::keyword();
break;
case 'ignore':
$template = Search_Admin::ignore();
break;
case 'settings':
$template = Search_Admin::settings();
break;
case 'close_admin':
unset($_SESSION['Search_Add_Words']);
unset($_SESSION['Search_Admin']);
PHPWS_Core::goBack();
break;
case 'delete_keyword':
Search_Admin::deleteKeyword();
PHPWS_Core::goBack();
break;
case 'add_parse_word':
if (!isset($_REQUEST['keyword'])) {
PHPWS_Core::goBack();
}
Search_Admin::addParseWord($_REQUEST['keyword']);
Search_Admin::sendMessage(dgettext('search', 'Keywords added to admin menu.'), 'keyword');
break;
case 'drop_keyword':
if (isset($_SESSION['Search_Add_Words'])) {
$array_key = array_search($_REQUEST['kw'], $_SESSION['Search_Add_Words']);
if ($array_key !== FALSE) {
unset($_SESSION['Search_Add_Words'][$array_key]);
}
}
PHPWS_Core::goBack();
break;
case 'add_keyword':
if (!isset($_GET['kw']) || !isset($_GET['key_id'])) {
PHPWS_Core::goBack();
}
Search_Admin::addKeyword($_GET['kw'], $_GET['key_id']);
PHPWS_Core::goBack();
break;
case 'remove_searchword':
if (!isset($_GET['kw']) || !isset($_GET['key_id'])) {
PHPWS_Core::goBack();
}
Search_Admin::removeSearchword($_GET['kw'], $_GET['key_id']);
PHPWS_Core::goBack();
break;
case 'add_ignore':
if (!isset($_GET['keyword'])) {
PHPWS_Core::goBack();
}
Search_Admin::setIgnore($_GET['keyword'], 1);
PHPWS_Core::goBack();
break;
case 'remove_ignore':
if (!isset($_GET['keyword'])) {
PHPWS_Core::goBack();
}
Search_Admin::setIgnore($_GET['keyword'], 0);
PHPWS_Core::goBack();
break;
case 'save_settings':
Search_Admin::saveSettings();
Search_Admin::sendMessage(dgettext('search', 'Settings saved'), 'settings');
break;
}
$template['MESSAGE'] = Search_Admin::getMessage();
$final = PHPWS_Template::process($template, 'search', 'main.tpl');
$panel->setContent($final);
$finalPanel = $panel->display();
Layout::add(PHPWS_ControlPanel::display($finalPanel));
}
示例15: admin
public function admin()
{
switch ($_REQUEST['dop']) {
case 'delete_document':
if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->document->delete();
PHPWS_Core::returnToBookmark();
break;
case 'post_document_upload':
if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->postDocumentUpload();
javascript('close_refresh');
Layout::nakedDisplay();
//\PHPWS_Core::goBack();
break;
case 'upload_document_form':
if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
Current_User::disallow();
}
$this->loadDocument(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
$this->edit();
echo Layout::wrap($this->content, 'Document Upload', true);
exit;
case 'add_access':
if (!Current_User::authorized('filecabinet')) {
Current_User::disallow();
}
$keyword = null;
$this->loadDocument();
// document exists, try making a shortcut
if ($this->document->id) {
PHPWS_Core::initModClass('access', 'Shortcut.php');
$shortcut = new Access_Shortcut();
if (isset($_GET['keyword'])) {
$keyword = $_GET['keyword'];
}
if (empty($keyword)) {
$keyword = $this->document->title;
}
$result = $shortcut->setKeyword($keyword);
$new_keyword = $shortcut->keyword;
// if setKeyword returns a false or error, we have them pick a different name
if (!$result || PHPWS_Error::isError($result)) {
$message = dgettext('filecabinet', 'Access shortcut name already in use. Please enter another.');
$success = false;
} else {
$shortcut->setUrl('filecabinet', $this->document->getViewLink());
$shortcut->save();
$success = true;
$message = '<p>' . dgettext('filecabinet', 'Access shortcut successful!') . '</p>';
$message .= '<a href="' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '">' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '</a>';
}
} else {
$message = dgettext('filecabinet', 'File not found');
// not really a success but prevents a repost prompt
$success = true;
}
echo json_encode(array('success' => $success, 'message' => $message, 'keyword' => $new_keyword));
exit;
}
}