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


PHP elgg_gatekeeper函数代码示例

本文整理汇总了PHP中elgg_gatekeeper函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_gatekeeper函数的具体用法?PHP elgg_gatekeeper怎么用?PHP elgg_gatekeeper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: notifications_page_handler

/**
 * Route page requests
 *
 * @param array $page Array of url parameters
 * @return bool
 */
function notifications_page_handler($page)
{
    elgg_gatekeeper();
    $current_user = elgg_get_logged_in_user_entity();
    // default to personal notifications
    if (!isset($page[0])) {
        $page[0] = 'personal';
    }
    if (!isset($page[1])) {
        forward("notifications/{$page[0]}/{$current_user->username}");
    }
    $user = get_user_by_username($page[1]);
    if ($user->guid != $current_user->guid && !$current_user->isAdmin()) {
        forward();
    }
    $base = elgg_get_plugins_path() . 'notifications';
    // note: $user passed in
    switch ($page[0]) {
        case 'group':
            require "{$base}/groups.php";
            break;
        case 'personal':
            require "{$base}/index.php";
            break;
        default:
            return false;
    }
    return true;
}
开发者ID:ibou77,项目名称:elgg,代码行数:35,代码来源:start.php

示例2: user_settings_page_handler

/**
 * User settings page handler
 *
 * @param array $segments URL segments
 * @return bool
 */
function user_settings_page_handler($segments)
{
    elgg_gatekeeper();
    $page = array_shift($segments);
    $username = array_shift($segments);
    if (!$page) {
        $page = 'user';
    }
    if (!$username) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_user_by_username($username);
    }
    if (!$user) {
        forward('', '404');
    }
    if (!$user->canEdit()) {
        forward('', '403');
    }
    elgg_set_page_owner_guid($user->guid);
    $resource = elgg_view_resource("settings/{$page}", array('username' => $user->username, 'entity' => $user, 'segments' => $segments));
    if ($resource) {
        echo $resource;
        return true;
    }
    return false;
}
开发者ID:hypeJunction,项目名称:Elgg-user_settings,代码行数:33,代码来源:start.php

示例3: notifications_page_handler

/**
 * Route page requests
 *
 * @param array $page Array of url parameters
 * @return bool
 */
function notifications_page_handler($page)
{
    elgg_gatekeeper();
    $current_user = elgg_get_logged_in_user_entity();
    // default to personal notifications
    if (!isset($page[0])) {
        $page[0] = 'personal';
    }
    if (!isset($page[1])) {
        forward("notifications/{$page[0]}/{$current_user->username}");
    }
    set_input('username', $page[1]);
    // note: $user passed in
    switch ($page[0]) {
        case 'group':
            echo elgg_view_resource('notifications/groups');
            break;
        case 'personal':
            echo elgg_view_resource('notifications/index');
            break;
        default:
            return false;
    }
    return true;
}
开发者ID:bhargavgarlapati,项目名称:Elgg,代码行数:31,代码来源:start.php

示例4: gnusocial_api_pagehandler

/**
 * Serves pages for gnusocial.
 *
 * @param array $page
 * @return bool
 */
function gnusocial_api_pagehandler($page)
{
    if (!isset($page[0])) {
        return false;
    }
    switch ($page[0]) {
        case 'authorize':
            gnusocial_api_authorize();
            break;
        case 'revoke':
            gnusocial_api_revoke();
            break;
        case 'forward':
            gnusocial_api_forward();
            break;
        case 'login':
            gnusocial_api_login();
            break;
        case 'interstitial':
            elgg_gatekeeper();
            // only let gnusocial users do this.
            $guid = elgg_get_logged_in_user_guid();
            $gnusocial_name = elgg_get_plugin_user_setting('gnusocial_name', $guid, 'gnusocial_api');
            if (!$gnusocial_name) {
                register_error(elgg_echo('gnusocial_api:invalid_page'));
                forward();
            }
            $pages = dirname(__FILE__) . '/pages/gnusocial_api';
            include "{$pages}/interstitial.php";
            break;
        default:
            return false;
    }
    return true;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:41,代码来源:start.php

示例5: _elgg_comments_page_handler

/**
 * Page handler for generic comments manipulation.
 *
 * @param array $page
 * @return bool
 * @access private
 */
function _elgg_comments_page_handler($page)
{
    switch ($page[0]) {
        case 'edit':
            elgg_gatekeeper();
            if (empty($page[1])) {
                register_error(elgg_echo('generic_comment:notfound'));
                forward(REFERER);
            }
            $comment = get_entity($page[1]);
            if (!$comment instanceof \ElggComment || !$comment->canEdit()) {
                register_error(elgg_echo('generic_comment:notfound'));
                forward(REFERER);
            }
            $target = $comment->getContainerEntity();
            if (!$target instanceof \ElggEntity) {
                register_error(elgg_echo('generic_comment:notfound'));
                forward(REFERER);
            }
            $title = elgg_echo('generic_comments:edit');
            elgg_push_breadcrumb($target->getDisplayName(), $target->getURL());
            elgg_push_breadcrumb($title);
            $params = array('entity' => $target, 'comment' => $comment, 'is_edit_page' => true);
            $content = elgg_view_form('comment/save', null, $params);
            $params = array('content' => $content, 'title' => $title, 'filter' => '');
            $body = elgg_view_layout('content', $params);
            echo elgg_view_page($title, $body);
            return true;
            break;
        default:
            return false;
            break;
    }
}
开发者ID:sephiroth88,项目名称:Elgg,代码行数:41,代码来源:comments.php

示例6: trip_companions_page_handler

/**
 * Gestor de páginas
 *
 * @param array $page Array of page routing elements
 * @return bool
 */
function trip_companions_page_handler($page)
{
    //system_message("page handler " . elgg_extract(0, $page));
    // only logged in users can do things
    elgg_gatekeeper();
    if (elgg_extract(0, $page) === 'add' && elgg_is_xhr()) {
        echo elgg_view('resources/evaluationcontent/add_form');
        return true;
    }
    if (elgg_extract(0, $page) === 'import') {
        echo elgg_view('resources/trip_companions/add_form');
        return true;
    }
    $friends = $groups = 0;
    switch ($page[0]) {
        case 'groups':
            $groups = 10;
            break;
        default:
            $friends = $groups = 10;
            break;
    }
    $page_owner = elgg_get_logged_in_user_entity();
    elgg_set_page_owner_guid($page_owner->guid);
    elgg_set_context("trip_companions");
    $content = elgg_view('resources/trip_companions/list', array('owner' => $page_owner, 'friends' => $friends, 'groups' => $groups));
    if ($content) {
        echo $content;
        return true;
    }
    return false;
}
开发者ID:rosanamontes,项目名称:teranga.go,代码行数:38,代码来源:start.php

示例7: twitter_api_pagehandler

/**
 * Serves pages for twitter.
 *
 * @param array $page
 * @return bool
 */
function twitter_api_pagehandler($page)
{
    if (!isset($page[0])) {
        return false;
    }
    switch ($page[0]) {
        case 'authorize':
            twitter_api_authorize();
            break;
        case 'revoke':
            twitter_api_revoke();
            break;
        case 'forward':
            twitter_api_forward();
            break;
        case 'login':
            twitter_api_login();
            break;
        case 'interstitial':
            elgg_gatekeeper();
            // only let twitter users do this.
            $guid = elgg_get_logged_in_user_guid();
            $twitter_name = elgg_get_plugin_user_setting('twitter_name', $guid, 'twitter_api');
            if (!$twitter_name) {
                register_error(elgg_echo('twitter_api:invalid_page'));
                forward();
            }
            echo elgg_view('resources/twitter_api/interstitial');
            break;
        default:
            return false;
    }
    return true;
}
开发者ID:elgg,项目名称:twitter_api,代码行数:40,代码来源:start.php

示例8: site_announcements_editor_gatekeeper

/**
 * Only site announcement editors can access this part
 *
 * @return void
 */
function site_announcements_editor_gatekeeper()
{
    elgg_gatekeeper();
    if (!site_announcements_is_editor()) {
        register_error(elgg_echo('limited_access'));
        forward(REFERER);
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:13,代码来源:functions.php

示例9: blog

 /**
  * Listen to the blog page handler, to takeover some pages
  *
  * @param string $hook         "route"
  * @param string $type         "blog"
  * @param array  $return_value the current page_handler params
  * @param null   $params       null
  *
  * @return array|bool
  */
 public static function blog($hook, $type, $return_value, $params)
 {
     if (empty($return_value) || !is_array($return_value)) {
         // someone else had a route hook
         return $return_value;
     }
     $page = elgg_extract("segments", $return_value);
     if (empty($page)) {
         return $return_value;
     }
     $pages_path = elgg_get_plugins_path() . "blog_tools/pages/";
     switch ($page[0]) {
         case "owner":
             $user = get_user_by_username($page[1]);
             if (!empty($user)) {
                 $return_value = false;
                 // push all blogs breadcrumb
                 elgg_push_breadcrumb(elgg_echo("blog:blogs"), "blog/all");
                 set_input("owner_guid", $user->guid);
                 include $pages_path . "owner.php";
             }
             break;
         case "read":
             // Elgg 1.7 compatibility
         // Elgg 1.7 compatibility
         case "view":
             if (!elgg_is_logged_in()) {
                 $setting = elgg_get_plugin_setting("advanced_gatekeeper", "blog_tools");
                 if ($setting != "no") {
                     if (isset($page[1]) && !get_entity($page[1])) {
                         elgg_gatekeeper();
                     }
                 }
             }
             set_input("guid", $page[1]);
             // to be used in the blog_tools/full/related view
             break;
         case "add":
         case "edit":
             $return_value = false;
             // push all blogs breadcrumb
             elgg_push_breadcrumb(elgg_echo("blog:blogs"), "blog/all");
             set_input("page_type", $page[0]);
             if (isset($page[1])) {
                 set_input("guid", $page[1]);
             }
             if (isset($page[2])) {
                 set_input("revision", $page[2]);
             }
             include $pages_path . "edit.php";
             break;
         case "featured":
             $return_value = false;
             include $pages_path . "featured.php";
             break;
     }
     return $return_value;
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:68,代码来源:Router.php

示例10: reportedcontent_page_handler

/**
 * Reported content page handler
 *
 * Serves the add report page
 *
 * @param array $page Array of page routing elements
 * @return bool
 */
function reportedcontent_page_handler($page)
{
    // only logged in users can report things
    elgg_gatekeeper();
    if (elgg_extract(0, $page) === 'add' && elgg_is_xhr()) {
        echo elgg_view('resources/reportedcontent/add_form');
        return true;
    }
    echo elgg_view('resources/reportedcontent/add');
    return true;
}
开发者ID:elgg,项目名称:reportedcontent,代码行数:19,代码来源:start.php

示例11: invitefriends_page_handler

/**
 * Page handler function
 * 
 * @param array $page Page URL segments
 * @return bool
 */
function invitefriends_page_handler($page)
{
    elgg_gatekeeper();
    elgg_set_context('friends');
    elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
    $title = elgg_echo('friends:invite');
    $body = elgg_view('invitefriends/form');
    $params = array('content' => $body, 'title' => $title);
    $body = elgg_view_layout('one_sidebar', $params);
    echo elgg_view_page($title, $body);
    return true;
}
开发者ID:tjcaverly,项目名称:Elgg,代码行数:18,代码来源:start.php

示例12: reportedcontent_page_handler

/**
 * Reported content page handler
 *
 * Serves the add report page
 *
 * @param array $page Array of page routing elements
 * @return bool
 */
function reportedcontent_page_handler($page)
{
    // only logged in users can report things
    elgg_gatekeeper();
    $title = elgg_echo('reportedcontent:this');
    $content = elgg_view_form('reportedcontent/add');
    $sidebar = elgg_echo('reportedcontent:instructions');
    $params = array('title' => $title, 'content' => $content, 'sidebar' => $sidebar);
    $body = elgg_view_layout('one_sidebar', $params);
    echo elgg_view_page($title, $body);
    return true;
}
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:20,代码来源:start.php

示例13: site_notifications_page_handler

/**
 * Page handler
 *
 * /site_notifications/view/<username>
 *
 * @param array $segments URL segments
 * @return boolean
 */
function site_notifications_page_handler($segments)
{
    elgg_gatekeeper();
    if (!isset($segments[1])) {
        $segments[1] = elgg_get_logged_in_user_entity()->username;
    }
    $user = get_user_by_username($segments[1]);
    if (!$user) {
        return false;
    }
    elgg_set_page_owner_guid($user->guid);
    echo elgg_view_resource('site_notifications/view');
    return true;
}
开发者ID:elgg,项目名称:elgg,代码行数:22,代码来源:start.php

示例14: dashboard_page_handler

/**
 * Dashboard page handler
 * @return bool
 */
function dashboard_page_handler()
{
    // Ensure that only logged-in users can see this page
    elgg_gatekeeper();
    // Set context and title
    elgg_set_context('dashboard');
    elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
    $title = elgg_echo('dashboard');
    // wrap intro message in a div
    $intro_message = elgg_view('dashboard/blurb');
    $params = array('content' => $intro_message, 'num_columns' => 3, 'show_access' => false);
    $widgets = elgg_view_layout('widgets', $params);
    $body = elgg_view_layout('one_column', array('title' => false, 'content' => $widgets));
    echo elgg_view_page($title, $body);
    return true;
}
开发者ID:tjcaverly,项目名称:Elgg,代码行数:20,代码来源:start.php

示例15: answers_page_handler

/**
 * Handles all answer pages
 *
 * @param array $segments
 *
 * @return bool
 */
function answers_page_handler($segments)
{
    elgg_push_breadcrumb(elgg_echo('questions'), 'questions/all');
    $pages = dirname(dirname(__FILE__)) . '/pages/answers';
    switch ($segments[0]) {
        case 'edit':
            elgg_gatekeeper();
            set_input('guid', $segments[1]);
            include "{$pages}/edit.php";
            break;
        default:
            forward('questions/all');
            return false;
    }
    return true;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:23,代码来源:page_handlers.php


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