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


PHP elgg_push_context函数代码示例

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


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

示例1: testHtmlawedFilterTagsAnchorsInput

 /**
  * Test anchor tags as input
  */
 public function testHtmlawedFilterTagsAnchorsInput()
 {
     $tests = array();
     // these should all work
     foreach ($this->validSchemes as $scheme) {
         $input = "<a href=\"{$scheme}://test\">Test</a>";
         $tests[$input] = "<a href=\"{$scheme}://test\">Test</a>";
     }
     $bad_schemes = array('javascript', 'itmss', 'magnet');
     // these should be denied
     foreach ($bad_schemes as $scheme) {
         $input = "<a href=\"{$scheme}://test\">Test</a>";
         $tests[$input] = "<a href=\"denied:{$scheme}://test\">Test</a>";
     }
     // set context to input to avoid adding nofollow
     elgg_push_context('input');
     foreach ($tests as $input => $expected) {
         $result = _elgg_htmlawed_filter_tags(null, null, $input);
         $this->assertEqual($expected, $result);
     }
     $weird_schemes = array('<a href="http://javascript:alert">Test</a>' => '<a href="http://javascript:alert">Test</a>', '<a href="javascript:https://">Test</a>' => '<a href="denied:javascript:https://">Test</a>', '<a href="ftp:\\/\\/">Test</a>' => '<a href="ftp:\\/\\/">Test</a>');
     foreach ($weird_schemes as $input => $expected) {
         $result = _elgg_htmlawed_filter_tags(null, null, $input);
         $this->assertEqual($expected, $result);
     }
     elgg_pop_context();
 }
开发者ID:elgg,项目名称:elgg,代码行数:30,代码来源:ElggHtmLawedTest.php

示例2: get

 /**
  * Get some input from variables passed submitted through GET or POST.
  *
  * If using any data obtained from get_input() in a web page, please be aware that
  * it is a possible vector for a reflected XSS attack. If you are expecting an
  * integer, cast it to an int. If it is a string, escape quotes.
  *
  * Note: this function does not handle nested arrays (ex: form input of param[m][n])
  * because of the filtering done in htmlawed from the filter_tags call.
  * @todo Is this ^ still true?
  *
  * @param string $variable      The variable name we want.
  * @param mixed  $default       A default value for the variable if it is not found.
  * @param bool   $filter_result If true, then the result is filtered for bad tags.
  *
  * @return mixed
  */
 function get($variable, $default = null, $filter_result = true)
 {
     $result = $default;
     elgg_push_context('input');
     if (isset($this->CONFIG->input[$variable])) {
         // a plugin has already set this variable
         $result = $this->CONFIG->input[$variable];
         if ($filter_result) {
             $result = filter_tags($result);
         }
     } else {
         $request = _elgg_services()->request;
         $value = $request->get($variable);
         if ($value !== null) {
             $result = $value;
             if (is_string($result)) {
                 // @todo why trim
                 $result = trim($result);
             }
             if ($filter_result) {
                 $result = filter_tags($result);
             }
         }
     }
     elgg_pop_context();
     return $result;
 }
开发者ID:elgg,项目名称:elgg,代码行数:44,代码来源:Input.php

示例3: uservalidationbyadmin_register_user_hook

/**
 * Listen to the registration of a new user
 *
 * @param string $hook         the name of the hook
 * @param string $type         the type of the hook
 * @param bool   $return_value the current return value
 * @param array  $params       supplied params
 *
 * @return bool
 */
function uservalidationbyadmin_register_user_hook($hook, $type, $return_value, $params)
{
    if (empty($params) || !is_array($params)) {
        return $return_value;
    }
    $user = elgg_extract("user", $params);
    if (empty($user) || !elgg_instanceof($user, "user")) {
        return $return_value;
    }
    // make sure we can see everything
    $hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // make sure we can save metadata
    elgg_push_context("uservalidationbyadmin_new_user");
    // this user needs validation
    $user->admin_validated = false;
    // check who to notify
    $notify_admins = uservalidationbyadmin_get_admin_notification_setting();
    if ($notify_admins == "direct") {
        uservalidationbyadmin_notify_admins();
    }
    // check if we need to disable the user
    if ($user->isEnabled()) {
        $user->disable();
    }
    // restore context
    elgg_pop_context();
    // restore access settings
    access_show_hidden_entities($hidden);
    return $return_value;
}
开发者ID:coldtrick,项目名称:uservalidationbyadmin,代码行数:41,代码来源:hooks.php

示例4: prepareMenu

 public static function prepareMenu($h, $t, $v, $p)
 {
     $default = new MenuList(elgg_extract('default', $v, []));
     $alt = new MenuList(elgg_extract('alt', $v, []));
     // dump alt items into default
     $default->appendList($alt);
     $avatar = $default->get('profile');
     $account = $default->get('account');
     if ($avatar && $account) {
         $user = elgg_get_logged_in_user_entity();
         // copy account children under avatar
         $children = new MenuList($account->getChildren());
         // copy admin out
         $admin = $children->remove('administration');
         $url = $avatar->getHref();
         $profile = new \ElggMenuItem('view-profile', elgg_echo('profile'), $url);
         $children->move($profile, 0);
         $avatar->setHref(null);
         elgg_push_context('mrclay_aalborg_topbar');
         $avatar->setText(elgg_view_entity_icon($user, 'tiny'));
         elgg_pop_context();
         $default->remove($account);
         $default->push($avatar);
         if ($admin) {
             $admin->setTooltip(elgg_echo('admin'));
             $admin->setText(elgg_view_icon('settings-alt'));
             $default->move($admin, 0);
         }
     }
     return ['default' => $default->getItems()];
 }
开发者ID:Twizanex,项目名称:Elgg-mrclay_aalborg,代码行数:31,代码来源:Topbar.php

示例5: uservalidationbyemail_disable_new_user

/**
 * Disables a user upon registration.
 *
 * @param string $hook
 * @param string $type
 * @param bool   $value
 * @param array  $params
 * @return bool
 */
function uservalidationbyemail_disable_new_user($hook, $type, $value, $params)
{
    $user = elgg_extract('user', $params);
    // no clue what's going on, so don't react.
    if (!$user instanceof ElggUser) {
        return;
    }
    // another plugin is requesting that registration be terminated
    // no need for uservalidationbyemail
    if (!$value) {
        return $value;
    }
    // has the user already been validated?
    if (elgg_get_user_validation_status($user->guid) == true) {
        return $value;
    }
    // disable user to prevent showing up on the site
    // set context so our canEdit() override works
    elgg_push_context('uservalidationbyemail_new_user');
    $hidden_entities = access_get_show_hidden_status();
    access_show_hidden_entities(TRUE);
    // Don't do a recursive disable.  Any entities owned by the user at this point
    // are products of plugins that hook into create user and might need
    // access to the entities.
    // @todo That ^ sounds like a specific case...would be nice to track it down...
    $user->disable('uservalidationbyemail_new_user', FALSE);
    // set user as unvalidated and send out validation email
    elgg_set_user_validation_status($user->guid, FALSE);
    uservalidationbyemail_request_validation($user->guid);
    elgg_pop_context();
    access_show_hidden_entities($hidden_entities);
    return $value;
}
开发者ID:bhargavgarlapati,项目名称:Elgg,代码行数:42,代码来源:start.php

示例6: bookmarks_page_handler

/**
 * Dispatcher for bookmarks.
 *
 * URLs take the form of
 *  All bookmarks:        bookmarks/all
 *  User's bookmarks:     bookmarks/owner/<username>
 *  Friends' bookmarks:   bookmarks/friends/<username>
 *  View bookmark:        bookmarks/view/<guid>/<title>
 *  New bookmark:         bookmarks/add/<guid> (container: user, group, parent)
 *  Edit bookmark:        bookmarks/edit/<guid>
 *  Group bookmarks:      bookmarks/group/<guid>/owner
 *  Bookmarklet:          bookmarks/bookmarklet/<guid> (user)
 *
 * Title is ignored
 *
 * @param array $page
 */
function bookmarks_page_handler($page)
{
    elgg_load_library('elgg:bookmarks');
    elgg_push_breadcrumb(elgg_echo('bookmarks'), 'bookmarks/all');
    elgg_push_context('bookmarks');
    // old group usernames
    if (substr_count($page[0], 'group:')) {
        preg_match('/group\\:([0-9]+)/i', $page[0], $matches);
        $guid = $matches[1];
        if ($entity = get_entity($guid)) {
            bookmarks_url_forwarder($page);
        }
    }
    // user usernames
    $user = get_user_by_username($page[0]);
    if ($user) {
        bookmarks_url_forwarder($page);
    }
    $pages = dirname(__FILE__) . '/pages/bookmarks';
    switch ($page[0]) {
        case "all":
            include "{$pages}/all.php";
            break;
        case "owner":
            include "{$pages}/owner.php";
            break;
        case "friends":
            include "{$pages}/friends.php";
            break;
        case "read":
        case "view":
            set_input('guid', $page[1]);
            include "{$pages}/view.php";
            break;
        case "add":
            gatekeeper();
            include "{$pages}/add.php";
            break;
        case "edit":
            gatekeeper();
            set_input('guid', $page[1]);
            include "{$pages}/edit.php";
            break;
        case 'group':
            group_gatekeeper();
            include "{$pages}/owner.php";
            break;
        case "bookmarklet":
            set_input('container_guid', $page[1]);
            include "{$pages}/bookmarklet.php";
            break;
        default:
            return false;
    }
    elgg_pop_context();
    return true;
}
开发者ID:rasul,项目名称:Elgg,代码行数:74,代码来源:start.php

示例7: pam_handler

/**
 * Can we allow the user with the credentials to log in?
 * Check stormpath, create the user if they can log in and don't exist
 * Enable the user if they can log in but were waiting for email verification
 * 
 * @param type $credentials
 * @return boolean
 */
function pam_handler($credentials)
{
    // try to authenticate first
    $application = get_application();
    $authResult = $application->authenticate($credentials['username'], $credentials['password']);
    $account = $authResult->account;
    if (!$account || strtolower($account->status) != 'enabled') {
        return false;
    }
    // we need to search hidden users too
    // in case of email confirmation disabling
    $show_hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // we have an account and it's enabled
    // see if we have a matching account here
    // check if logging in with email address
    if (strpos($credentials['username'], '@') !== false) {
        $users = get_user_by_email($credentials['username']);
        $user = $users[0];
    } else {
        $user = get_user_by_username($credentials['username']);
    }
    // custom context gives us permission to do this
    elgg_push_context('stormpath_validate_user');
    // if we don't have a user we need to create one
    if (!$user) {
        $user = new \ElggUser();
        $user->username = preg_replace("/[^a-zA-Z0-9]/", "", $account->username);
        $user->email = $account->email;
        $user->name = $account->fullName;
        $user->access_id = ACCESS_PUBLIC;
        $user->salt = _elgg_generate_password_salt();
        $user->password = generate_user_password($user, $credentials['password']);
        $user->owner_guid = 0;
        // Users aren't owned by anyone, even if they are admin created.
        $user->container_guid = 0;
        // Users aren't contained by anyone, even if they are admin created.
        $user->language = get_current_language();
        $user->save();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
        // Turn on email notifications by default
        set_user_notification_setting($user->getGUID(), 'email', true);
    }
    // see if we need to enable/verify the user
    if (!$user->isEnabled() && in_array($user->disable_reason, array('stormpath_new_user', 'uservalidationbyemail_new_user'))) {
        $user->enable();
        $user->__stormpath_user = $account->href;
        elgg_set_user_validation_status($user->guid, TRUE, 'stormpath');
    }
    elgg_pop_context();
    access_show_hidden_entities($show_hidden);
    if ($user && $user->isEnabled()) {
        return true;
    }
    return false;
}
开发者ID:arckinteractive,项目名称:elgg_stormpath,代码行数:65,代码来源:start.php

示例8: thewire_tools_route_thewire

/**
 * Extends thewire pagehandler with some extra pages
 *
 * @param string $hook_name   'route'
 * @param string $entity_type 'thewire'
 * @param bool   $return      the default return value
 * @param array  $params      supplied params
 *
 * @return bool
 */
function thewire_tools_route_thewire($hook_name, $entity_type, $return, $params)
{
    $page = elgg_extract("segments", $return);
    if (is_array($page)) {
        switch ($page[0]) {
            case "group":
                if (!empty($page[1])) {
                    set_input("group_guid", $page[1]);
                    // @todo is this still needed or replace with page_owner in page
                    if (!empty($page[2])) {
                        set_input("wire_username", $page[2]);
                        // @todo is this still needed?
                    }
                    $include_file = "pages/group.php";
                    break;
                }
            case "tag":
            case "search":
                if (isset($page[1])) {
                    if ($page[0] == "tag") {
                        set_input("query", "#" . $page[1]);
                    } else {
                        set_input("query", $page[1]);
                    }
                }
                $include_file = "pages/search.php";
                break;
            case "autocomplete":
                $include_file = "procedures/autocomplete.php";
                break;
            case "conversation":
                if (isset($page[1])) {
                    set_input("guid", $page[1]);
                }
                $include_file = "procedures/conversation.php";
                break;
            case "thread":
                elgg_push_context("thewire_thread");
            case "reply":
                if (!empty($page[1])) {
                    $entity = get_entity($page[1]);
                    if (!empty($entity) && elgg_instanceof($entity->getContainerEntity(), "group")) {
                        elgg_set_page_owner_guid($entity->getContainerGUID());
                    }
                }
                break;
        }
        if (!empty($include_file)) {
            include dirname(dirname(__FILE__)) . "/" . $include_file;
            $return = false;
        }
    }
    return $return;
}
开发者ID:Twizanex,项目名称:thewire_tools,代码行数:64,代码来源:hooks.php

示例9: list_relatedgroups

function list_relatedgroups($group, $options = array())
{
    if ($group instanceof ElggGroup) {
        $defaults = array('full_view' => false, 'pagination' => true);
        $options = array_merge($defaults, $options);
        $options['relationship'] = 'related';
        $options['relationship_guid'] = $group->guid;
        elgg_push_context('relatedgroups');
        $list = elgg_list_entities_from_relationship($options);
        elgg_pop_context();
        return $list;
    } else {
        return "";
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:15,代码来源:relatedgroups.php

示例10: list_subgroups

function list_subgroups($group, $options = array())
{
    if ($group instanceof ElggGroup) {
        $defaults = array('full_view' => false, 'pagination' => true);
        $options = array_merge($defaults, $options);
        $options['type'] = 'group';
        $options['container_guid'] = $group->guid;
        elgg_push_context('subgroups');
        $list = elgg_list_entities($options);
        elgg_pop_context();
        return $list;
    } else {
        return "";
    }
}
开发者ID:rijojoy,项目名称:MyIceBerg,代码行数:15,代码来源:subgroups.php

示例11: thewire

 /**
  * Extends thewire pagehandler with some extra pages
  *
  * @param string $hook_name   'route'
  * @param string $entity_type 'thewire'
  * @param bool   $return      the default return value
  * @param array  $params      supplied params
  *
  * @return bool
  */
 public static function thewire($hook_name, $entity_type, $return, $params)
 {
     $page = elgg_extract('segments', $return);
     if (!isset($page[0])) {
         $page = ['all'];
     }
     switch ($page[0]) {
         case 'all':
         case 'owner':
             set_input('limit', get_input('limit', elgg_get_config('default_limit')));
             return;
         case 'group':
             if (!empty($page[1])) {
                 set_input('group_guid', $page[1]);
                 // @todo is this still needed or replace with page_owner in page
                 if (!empty($page[2])) {
                     set_input('wire_username', $page[2]);
                     // @todo is this still needed?
                 }
                 echo elgg_view_resource('thewire/group');
                 return false;
             }
         case 'tag':
         case 'search':
             if (isset($page[1])) {
                 if ($page[0] == 'tag') {
                     set_input('query', '#' . $page[1]);
                 } else {
                     set_input('query', $page[1]);
                 }
             }
             echo elgg_view_resource('thewire/search');
             return false;
         case 'autocomplete':
             echo elgg_view_resource('thewire/autocomplete');
             return false;
         case 'thread':
             elgg_push_context('thewire_thread');
         case 'reply':
             if (!empty($page[1])) {
                 $entity = get_entity($page[1]);
                 if (!empty($entity) && elgg_instanceof($entity->getContainerEntity(), 'group')) {
                     elgg_set_page_owner_guid($entity->getContainerGUID());
                 }
             }
             break;
     }
 }
开发者ID:coldtrick,项目名称:thewire_tools,代码行数:58,代码来源:Router.php

示例12: group_profile_router

/**
 * Route groups pages
 *
 * @param string $hook   "route"
 * @param string $type   "groups"
 * @param array  $return Identifier and segments
 * @param array  $params Hook params
 * @return array
 */
function group_profile_router($hook, $type, $return, $params)
{
    if (!is_array($return)) {
        return;
    }
    // Initial page identifier might be different from /groups
    // i.e. subtype specific handler e.g. /schools
    $initial_identifier = elgg_extract('identifier', $params);
    $identifier = elgg_extract('identifier', $return);
    $segments = elgg_extract('segments', $return);
    if ($identifier !== 'groups') {
        return;
    }
    $page = array_shift($segments);
    if (!$page) {
        $page = 'all';
    }
    // we want to pass the original identifier to the resource view
    // doing this via route hook in order to keep the page handler intact
    $resource_params = array('identifier' => $initial_identifier ?: 'groups');
    switch ($page) {
        case 'profile':
            $guid = array_shift($segments);
            $resource_params['guid'] = $guid;
            elgg_push_context('group_profile');
            elgg_set_page_owner_guid($guid);
            break;
        case 'activity':
            $guid = array_shift($segments);
            $resource_params['guid'] = $guid;
            break;
        default:
            return;
    }
    elgg_load_library('elgg:groups');
    $resource_params['page'] = $page;
    $resource_params['segments'] = $segments;
    echo elgg_view_resource("groups/{$page}", $resource_params);
    return false;
}
开发者ID:hypeJunction,项目名称:Elgg-group_profile,代码行数:49,代码来源:start.php

示例13: am_list_entities_by_container_or_tag

/** 
 * Custom function to grab entities belonging to a container OR a tag
 */
function am_list_entities_by_container_or_tag($options)
{
    if ($options['container_guid']) {
        $container_sql = "e.container_guid IN ({$options['container_guid']})";
    }
    if ($options['tag']) {
        $access_sql = get_access_sql_suffix('tag_meta_table');
        $tag_sql = "\n\t\t\t(\n\t\t\t\t(tag_msn.string IN ('tags')) AND ( BINARY tag_msv.string IN ('{$options['tag']}')) \n\t\t\t\tAND\n\t\t\t\t{$access_sql}\n\t\t\t)\n\t\t";
    }
    $subtypes = is_array($options['subtypes']) ? $options['subtypes'] : array();
    $limit = $options['limit'] === NULL ? 10 : $options['limit'];
    $offset = $options['offset'] === NULL ? 0 : $options['offset'];
    $title = $options['title'] === NULL ? 'Custom Module' : $options['title'];
    global $CONFIG;
    // As long as we have either a container_guid or a tag, use the $wheres
    if ($container_sql || $tag_sql) {
        $joins[] = "JOIN {$CONFIG->dbprefix}metadata tag_meta_table on e.guid = tag_meta_table.entity_guid";
        $joins[] = "JOIN {$CONFIG->dbprefix}metastrings tag_msn on tag_meta_table.name_id = tag_msn.id";
        $joins[] = "JOIN {$CONFIG->dbprefix}metastrings tag_msv on tag_meta_table.value_id = tag_msv.id";
        // Need to watch the brackets here..
        $wheres[] = "\n\t\t\t(\n\t\t\t\t{$container_sql}\n\t\t\t\tOR\n\t\t\t\t{$tag_sql}\n\t\t\t)\n\t\t";
    }
    // Not sure if I still need this one..
    elgg_push_context('search');
    // Don't display metadata menu
    elgg_push_context('widgets');
    $params = array('type' => 'object', 'subtypes' => $subtypes, 'joins' => $joins, 'wheres' => $wheres, 'full_view' => FALSE, 'limit' => $limit, 'offset' => $offset, 'owner_guids' => $options['owner_guids'], 'created_time_upper' => $options['created_time_upper'], 'created_time_lower' => $options['created_time_lower'], 'count' => $options['count']);
    if ($options['count']) {
        $entities = elgg_get_entities_from_metadata($params);
        echo $entities;
    } else {
        $entities = elgg_list_entities_from_metadata($params);
        if ($entities) {
            return $entities;
        } else {
            return "<div style='width: 100%; text-align: center; margin: 10px;'><strong>No results</strong></div>";
        }
    }
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:42,代码来源:ajaxmodule.php

示例14: testContainsTellsYouIfAGivenContextIsInTheCurrentStack

 public function testContainsTellsYouIfAGivenContextIsInTheCurrentStack()
 {
     $context = new Context();
     $context->push('foo');
     $context->push('bar');
     $context->push('baz');
     $this->assertTrue($context->contains('foo'));
     $this->assertTrue($context->contains('bar'));
     $this->assertTrue($context->contains('baz'));
     $popped = $context->pop();
     $this->assertFalse($context->contains($popped));
     // TODO: remove once global state is fully deprecated (2.0)
     _elgg_services()->setValue('context', new Context());
     elgg_push_context('foo');
     elgg_push_context('bar');
     elgg_push_context('baz');
     $this->assertTrue(elgg_in_context('foo'));
     $this->assertTrue(elgg_in_context('bar'));
     $this->assertTrue(elgg_in_context('baz'));
     $popped = elgg_pop_context();
     $this->assertFalse(elgg_in_context($popped));
 }
开发者ID:ibou77,项目名称:elgg,代码行数:22,代码来源:ContextTest.php

示例15: get_input

/**
 * Get some input from variables passed submitted through GET or POST.
 *
 * If using any data obtained from get_input() in a web page, please be aware that
 * it is a possible vector for a reflected XSS attack. If you are expecting an
 * integer, cast it to an int. If it is a string, escape quotes.
 *
 * Note: this function does not handle nested arrays (ex: form input of param[m][n])
 * because of the filtering done in htmlawed from the filter_tags call.
 * @todo Is this ^ still true?
 *
 * @param string $variable      The variable name we want.
 * @param mixed  $default       A default value for the variable if it is not found.
 * @param bool   $filter_result If true, then the result is filtered for bad tags.
 *
 * @return mixed
 */
function get_input($variable, $default = NULL, $filter_result = TRUE)
{
    global $CONFIG;
    $result = $default;
    elgg_push_context('input');
    if (isset($CONFIG->input[$variable])) {
        $result = $CONFIG->input[$variable];
        if ($filter_result) {
            $result = filter_tags($result);
        }
    } elseif (isset($_REQUEST[$variable])) {
        if (is_array($_REQUEST[$variable])) {
            $result = $_REQUEST[$variable];
        } else {
            $result = trim($_REQUEST[$variable]);
        }
        if ($filter_result) {
            $result = filter_tags($result);
        }
    }
    elgg_pop_context();
    return $result;
}
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:40,代码来源:input.php


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