当前位置: 首页>>代码示例>>PHP>>正文


PHP Key::restrictView方法代码示例

本文整理汇总了PHP中Key::restrictView方法的典型用法代码示例。如果您正苦于以下问题:PHP Key::restrictView方法的具体用法?PHP Key::restrictView怎么用?PHP Key::restrictView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Key的用法示例。


在下文中一共展示了Key::restrictView方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showFP

function showFP()
{
    $db = new PHPWS_DB('ps_page');
    $db->addWhere('front_page', 1);
    if ($db->isTableColumn('deleted')) {
        $db->addWhere('deleted', 0);
    }
    Key::restrictView($db, 'pagesmith');
    $db->loadClass('pagesmith', 'PS_Page.php');
    $result = $db->getObjects('PS_Page');
    if (!PHPWS_Error::logIfError($result) && !empty($result)) {
        PHPWS_Core::initModClass('pagesmith', 'PageSmith.php');
        foreach ($result as $page) {
            $content = $page->view();
            if ($content && !PHPWS_Error::logIfError($content)) {
                if (Current_User::allow('pagesmith', 'edit_page', $page->id)) {
                    $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink());
                }
                Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE);
            }
        }
    } else {
        return null;
    }
}
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:25,代码来源:runtime.php

示例2: loadChildren

 /**
  * Grabs all the child links under the current link
  */
 public function loadChildren($data = null, $hash = null)
 {
     // If we're doing this the old, inefficient way...
     if (empty($data) || empty($hash)) {
         $db = $this->getDB();
         $db->addWhere('parent', $this->id);
         $db->addOrder('link_order');
         Key::restrictView($db);
         $result = $db->getObjects('menu_link');
         if (empty($result)) {
             return;
         }
         foreach ($result as $link) {
             $link->loadChildren();
             $this->_children[$link->id] = $link;
         }
     } elseif (empty($hash[$this->id])) {
         return;
     } else {
         foreach ($hash[$this->id] as $rowId) {
             $link = new Menu_Link();
             PHPWS_Core::plugObject($link, $data[$rowId]);
             $link->loadChildren($data, $hash);
             $this->_children[$link->id] = $link;
         }
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:30,代码来源:Menu_Link.php

示例3: showBlocks

 public static function showBlocks($key)
 {
     $db = new PHPWS_DB('block');
     $db->addWhere('block_pinned.key_id', $key->id);
     $db->addWhere('id', 'block_pinned.block_id');
     Key::restrictView($db, 'block');
     $result = $db->getObjects('Block_Item');
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         return NULL;
     }
     if (empty($result)) {
         return NULL;
     }
     foreach ($result as $block) {
         $block->setPinKey($key);
         Layout::add($block->view(), 'block', $block->getContentVar());
         $GLOBALS['Current_Blocks'][$block->id] = TRUE;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:20,代码来源:Block.php

示例4: getScheduleList

 /**
  * Returns a list of schedules according to the user's permissions
  */
 public function getScheduleList($mode = 'object')
 {
     $db = new PHPWS_DB('calendar_schedule');
     Key::restrictView($db);
     $user_id = Current_User::getId();
     if ($user_id) {
         // this should always be true, adding just to create another where group
         $db->addWhere('id', 0, '>', 'and', 'user_cal0');
         $db->addWhere('user_id', $user_id, '=', 'and', 'user_cal1');
         $db->addWhere('public', 0, '=', 'and', 'user_cal1');
         $db->addWhere('public', 1, '=', 'or', 'user_cal2');
         $db->setGroupConj('user_cal1', 'and');
         $db->setGroupConj('user_cal2', 'or');
         $db->groupIn('user_cal1', 'user_cal0');
         $db->groupIn('user_cal2', 'user_cal0');
     } else {
         $db->addWhere('public', 1);
     }
     $db->addOrder('title');
     switch ($mode) {
         case 'object':
             return $db->getObjects('Calendar_Schedule');
             break;
         case 'brief':
             $db->addColumn('id');
             $db->addColumn('title');
             $db->setIndexBy('id');
             return $db->select('col');
             break;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:34,代码来源:Calendar.php

示例5: upcomingEvents

 public function upcomingEvents()
 {
     $db = new PHPWS_DB('calendar_schedule');
     $db->addWhere('show_upcoming', 0, '>');
     $db->addWhere('public', 1);
     Key::restrictView($db, 'calendar');
     $result = $db->getObjects('Calendar_Schedule');
     if (PHPWS_Error::logIfError($result) || !$result) {
         return null;
     }
     $startdate = time();
     foreach ($result as $schedule) {
         $tpl = array();
         switch ($schedule->show_upcoming) {
             case 1:
                 // one week
                 $days_ahead = 7;
                 break;
             case 2:
                 // two weeks
                 $days_ahead = 14;
                 break;
             case 3:
                 // one month
                 $days_ahead = 30;
                 break;
         }
         $enddate = $startdate + 86400 * $days_ahead;
         $event_list = $schedule->getEvents($startdate, $enddate);
         if (!$event_list) {
             continue;
         }
         $tpl['TITLE'] = $schedule->getViewLink();
         $current_day = null;
         $count = 0;
         if (empty($event_list)) {
             continue;
         }
         foreach ($event_list as $event) {
             $vars = array('view' => 'day', 'date' => $event->start_time, 'sch_id' => $schedule->id);
             $tpl['events'][$count] = $event->getTpl();
             if ($current_day != strftime(CALENDAR_UPCOMING_FORMAT, $event->start_time)) {
                 $current_day = strftime(CALENDAR_UPCOMING_FORMAT, $event->start_time);
                 $tpl['events'][$count]['DAY'] = PHPWS_Text::moduleLink($current_day, 'calendar', $vars);
             } else {
                 $tpl['events'][$count]['DAY'] = null;
             }
             $count++;
         }
         $upcoming[] = PHPWS_Template::process($tpl, 'calendar', 'view/upcoming.tpl');
     }
     if (!empty($upcoming)) {
         $ftpl['TITLE'] = dgettext('calendar', 'Upcoming events');
         $ftpl['CONTENT'] = implode("\n", $upcoming);
         return PHPWS_Template::process($ftpl, 'calendar', 'user_main.tpl');
     } else {
         return null;
     }
 }
开发者ID:par-orillonsoft,项目名称:phpwebsite,代码行数:59,代码来源:User.php

示例6: getLinks

 /**
  * Returns the menu link objects associated to a menu
  */
 public function getLinks($parent = 0, $active_only = TRUE)
 {
     if (!$this->id) {
         return NULL;
     }
     // Get all records for this menu
     $db = new PHPWS_DB('menu_links');
     $db->setDistinct();
     $db->addWhere('menu_id', $this->id, NULL, NULL, 1);
     Key::restrictView($db);
     $db->addOrder('link_order');
     $db->setIndexBy('id');
     $data = $db->getObjects('Menu_Link');
     if (empty($data) || PHPWS_Error::logIfError($data)) {
         return NULL;
     }
     $final = $this->formLink($data);
     $GLOBALS['MENU_LINKS'][$this->id] = $final;
     return $final;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:23,代码来源:Menu_Item.php

示例7: show

 /**
  * Function called by mod developer to add their
  * link or to just show the menu on that item
  */
 public static function show()
 {
     \Layout::addJSHeader("<script type='text/javascript' src='" . PHPWS_SOURCE_HTTP . "javascript/responsive_img/responsive-img.min.js'></script>", 81);
     $seen = array();
     $key = Key::getCurrent();
     if (empty($key) || empty($key->title) || empty($key->url)) {
         return;
     }
     $db = new PHPWS_DB('menus');
     $db->addWhere('menu_assoc.key_id', $key->id);
     $db->addWhere('id', 'menu_assoc.menu_id');
     $db->loadClass('menu', 'Menu_Item.php');
     Key::restrictView($db, 'menu');
     $result = $db->getObjects('Menu_Item');
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
     } elseif (!empty($result)) {
         foreach ($result as $menu) {
             $seen[] = $menu->id;
             if ($menu->assoc_image) {
                 Layout::set($menu->showAssocImage(), 'menu', 'image');
             }
             Layout::set($menu->view(), 'menu', 'menu_' . $menu->id);
         }
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:30,代码来源:Menu.php

示例8: getResults

 public static function getResults($phrase, $module = NULL, $exact_match = FALSE)
 {
     PHPWS_Core::initModClass('search', 'Stats.php');
     $pageTags = array();
     $pageTags['MODULE_LABEL'] = dgettext('search', 'Module');
     $pageTags['TITLE_LABEL'] = dgettext('search', 'Title');
     $ignore = Search_User::getIgnore();
     if (PHPWS_Error::isError($ignore)) {
         PHPWS_Error::log($ignore);
         $ignore = NULL;
     }
     if (empty($phrase)) {
         return FALSE;
     }
     $words = explode(' ', $phrase);
     if (!empty($ignore)) {
         $words_removed = array_intersect($words, $ignore);
         if (!empty($words_removed)) {
             $pageTags['REMOVED_LABEL'] = dgettext('search', 'The following search words were ignored');
             $pageTags['IGNORED_WORDS'] = implode(' ', $words_removed);
             foreach ($words_removed as $remove) {
                 $key = array_search($remove, $words);
                 unset($words[$key]);
             }
         }
     }
     if (empty($words)) {
         return FALSE;
     }
     PHPWS_Core::initCoreClass('DBPager.php');
     $pager = new DBPager('phpws_key', 'Key');
     $pager->setModule('search');
     $pager->setTemplate('search_results.tpl');
     $pager->addToggle('class="bgcolor1"');
     $pager->addRowTags('getTplTags');
     $pager->addPageTags($pageTags);
     foreach ($words as $keyword) {
         if (strlen($keyword) < SEARCH_MIN_WORD_LENGTH) {
             continue;
         }
         if ($exact_match) {
             $s_keyword = "%{$keyword} %";
         } else {
             $s_keyword = "%{$keyword}%";
         }
         $pager->addWhere('search.keywords', $s_keyword, 'like', 'or', 1);
     }
     // No keywords were set. All under minimum word length
     if (empty($s_keyword)) {
         return null;
     }
     $pager->setEmptyMessage(dgettext('search', 'Nothing found'));
     $pager->db->setGroupConj(1, 'AND');
     if ($module) {
         $pager->addWhere('search.module', $module);
         Key::restrictView($pager->db, $module);
     } else {
         Key::restrictView($pager->db);
     }
     $result = $pager->get();
     Search_Stats::record($words, $pager->total_rows, $exact_match);
     return $result;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:63,代码来源:User.php

示例9: show

 public static function show($start_date = null, $end_date = null)
 {
     if (!Blog_User::allowView()) {
         return null;
     }
     $db = new PHPWS_DB('blog_entries');
     if ($start_date) {
         $db->addWhere('publish_date', $start_date, '>=', 'and', 2);
     }
     if ($end_date) {
         $db->addWhere('publish_date', $end_date, '<=', 'and', 2);
     }
     $db->addWhere('approved', 1);
     $db->addWhere('publish_date', time(), '<');
     $db->addWhere('expire_date', time(), '>', 'and', 1);
     $db->addWhere('expire_date', 0, '=', 'or', 1);
     $db->setGroupConj(1, 'and');
     Key::restrictView($db, 'blog');
     $total_entries = Blog_User::totalEntries($db);
     $limit = PHPWS_Settings::get('blog', 'blog_limit');
     if (isset($_GET['page'])) {
         $page = $_GET['page'];
     } else {
         $page = 0;
     }
     if (!is_numeric($page) || $page < 2) {
         $offset = $page = 0;
     } else {
         $offset = ($page - 1) * $limit;
     }
     Layout::addStyle('blog');
     $result = Blog_User::getEntries($db, $limit, $offset);
     if ($page > 0 && empty($result)) {
         PHPWS_Core::reroute('blog/action/view/page/1');
     }
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         return NULL;
     }
     if (empty($result)) {
         if (Current_User::allow('blog')) {
             MiniAdmin::add('blog', PHPWS_Text::secureLink(dgettext('blog', 'Create first blog entry!'), 'blog', array('action' => 'admin', 'command' => 'new')));
         }
         return NULL;
     }
     if ($page < 2) {
         $past_entries = PHPWS_Settings::get('blog', 'past_entries');
         if ($past_entries) {
             $db->setLimit($past_entries, $limit);
             $past = $db->getObjects('Blog');
             if (PHPWS_Error::isError($past)) {
                 PHPWS_Error::log($past);
             } elseif ($past) {
                 Blog_User::showPast($past);
             }
         }
     }
     $rss = false;
     foreach ($result as $blog) {
         if (!$rss) {
             if (PHPWS_Core::moduleExists('rss')) {
                 PHPWS_Core::initModClass('rss', 'RSS.php');
                 $key = new Key($blog->key_id);
                 RSS::showIcon($key);
                 $rss = true;
             }
         }
         $view = $blog->view();
         if (!empty($view)) {
             $list[] = $view;
         }
     }
     $page_vars['action'] = 'view';
     if ($page > 1) {
         $page_vars['page'] = $page - 1;
         $tpl['PREV_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Previous page'), 'blog', $page_vars);
         if ($limit + $offset < $total_entries) {
             $page_vars['page'] = $page + 1;
             $tpl['NEXT_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Next page'), 'blog', $page_vars);
         }
     } elseif ($limit + $offset < $total_entries) {
         $page_vars['page'] = 2;
         $tpl['NEXT_PAGE'] = PHPWS_Text::moduleLink(dgettext('blog', 'Next page'), 'blog', $page_vars);
     }
     $tpl['ENTRIES'] = implode('', $list);
     $content = PHPWS_Template::process($tpl, 'blog', 'list_view.tpl');
     if (Current_User::allow('blog', 'edit_blog')) {
         Blog_User::miniAdminList();
         $vars['action'] = 'admin';
         $vars['command'] = 'new';
         $link[] = PHPWS_Text::secureLink(dgettext('blog', 'Add new blog'), 'blog', $vars);
         MiniAdmin::add('blog', $link);
     }
     return $content;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:95,代码来源:Blog_User.php


注:本文中的Key::restrictView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。