本文整理汇总了PHP中elgg_pop_context函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_pop_context函数的具体用法?PHP elgg_pop_context怎么用?PHP elgg_pop_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_pop_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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])) {
// a plugin has already set this variable
$result = $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;
}
示例2: 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();
}
示例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;
}
示例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()];
}
示例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;
}
示例6: 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 "";
}
}
示例7: 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 "";
}
}
示例8: 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));
}
示例9: 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;
}
示例10: questions_page_handler
function questions_page_handler($segments)
{
// elgg_push_breadcrumb(elgg_echo('questions'), "/questions/all");
$pages = dirname(__FILE__) . "/pages/questions";
switch ($segments[0]) {
case "all":
include "{$pages}/all.php";
break;
case "owner":
include "{$pages}/owner.php";
break;
/*
case "friends":
gatekeeper();
include "$pages/friends.php";
break;
*/
/*
case "friends":
gatekeeper();
include "$pages/friends.php";
break;
*/
case "view":
set_input('guid', $segments[1]);
include "{$pages}/view.php";
break;
case "add":
gatekeeper();
set_input('guid', $segments[1]);
include "{$pages}/add.php";
break;
case "edit":
gatekeeper();
set_input('guid', $segments[1]);
include "{$pages}/edit.php";
break;
case 'group':
// group_gatekeeper();
include "{$pages}/owner.php";
break;
default:
return false;
}
elgg_pop_context();
return true;
}
示例11: 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>/all
* Bookmarklet: bookmarks/bookmarklet/<guid> (user)
*
* Title is ignored
*
* @param array $page
* @return bool
*/
function bookmarks_page_handler($page)
{
elgg_load_library('elgg:bookmarks');
if (!isset($page[0])) {
$page[0] = 'all';
}
elgg_push_breadcrumb(elgg_echo('bookmarks'), 'bookmarks/all');
switch ($page[0]) {
case "all":
echo elgg_view_resource('bookmarks/all');
break;
case "owner":
echo elgg_view_resource('bookmarks/owner');
break;
case "friends":
echo elgg_view_resource('bookmarks/friends');
break;
case "view":
set_input('guid', $page[1]);
echo elgg_view_resource('bookmarks/view');
break;
case "add":
echo elgg_view_resource('bookmarks/add');
break;
case "edit":
set_input('guid', $page[1]);
echo elgg_view_resource('bookmarks/edit');
break;
case 'group':
echo elgg_view_resource('bookmarks/owner');
break;
case "bookmarklet":
set_input('container_guid', $page[1]);
echo elgg_view_resource('bookmarks/bookmarklet');
break;
default:
return false;
}
elgg_pop_context();
return true;
}
示例12: elgg_get_page_owner_guid
<?php
$userId = elgg_get_page_owner_guid();
$offset = get_input('offset', 0);
$count = elgg_get_entities_from_relationship(array('type' => 'group', 'relationship' => 'member', 'relationship_guid' => $userId, 'inverse_relationship' => false, 'count' => true));
if (!$count) {
echo elgg_echo('groups:none');
} else {
$groups = elgg_get_entities_from_relationship(array('type' => 'group', 'relationship' => 'member', 'relationship_guid' => $userId, 'inverse_relationship' => false, "offset" => $offset, "limit" => ZHGROUPS_IN_PROFILE_LIMIT));
echo '<div id="zhaohu_profile_joined_groups">';
echo "<h3>" . elgg_echo("zhgroups:memberof", array($count)) . "</h3>";
elgg_push_context('inprofile');
$options = array("count" => $count, "offset" => $offset, "limit" => ZHGROUPS_IN_PROFILE_LIMIT, "full_view" => false, 'list_type' => 'gallery', "pagination" => true);
//fordebug system_message("count ".$options["count"]);
echo elgg_view_entity_list($groups, $options);
echo '</div>';
elgg_pop_context('inprofile');
}
示例13: 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>/all
* 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');
// 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;
}
示例14: cas_insertUser
/**
* Insert user into elgg user table using info from ldap
* Tries to insert, otherwise returns error
*
* @return user or error (false?)
*/
function cas_insertUser($username, $ldap_attributes, $config)
{
// name is 'cn' in ldap
$name = $ldap_attributes['cn'];
// remove periods from ldap username
// ex. anthony.hopkins -> anthonyhopkins
$uname = !empty($ldap_attributes['textUid']) ? $ldap_attributes['textUid'] : str_replace(".", "", $username);
$email = $ldap_attributes['mail'];
$user = new ElggUser();
$user->username = $uname;
$user->email = $email;
$user->name = $name;
$user->access_id = 2;
$user->salt = generate_random_cleartext_password();
// Note salt generated before password!
// cas users don't need password stored locally
// so create an invalid password
// a real password can be saved at a later time if they become a local user
$user->password = md5(time());
//generate_user_password($user, $password);
// returns guid or false
$guid = $user->save();
if (!$guid) {
return false;
}
$obj = get_entity($guid);
if (isset($config->casadminuser) && $config->casadminuser == $uname) {
if ($obj instanceof \ElggUser) {
//set context for permissions check
elgg_push_context('au_cas_auth_make_admin');
if (make_user_admin($guid)) {
system_message(elgg_echo('admin:user:makeadmin:yes'));
} else {
register_error(elgg_echo('admin:user:makeadmin:no'));
}
// set context back
elgg_pop_context();
} else {
register_error(elgg_echo('admin:user:makeadmin:no'));
}
}
return $user;
}
示例15: sendLegacy
/**
* Pre 1.9 notificatins
*
* Listen to the 'publish','object' event and send out notifications
* to interested users, as well as anyone tagged
*
* @param string $event Equals 'publish'
* @param string $entity_type Equals 'object'
* @param ElggEntity $entity Published entity
* @return boolean
*/
public function sendLegacy($event, $entity_type, $entity)
{
if (!$entity instanceof Post || $entity->origin != 'wall') {
return true;
}
$poster = $entity->getOwnerEntity();
$container = $entity->getContainerEntity();
$message = $entity->formatMessage(true);
$sent = array(elgg_get_logged_in_user_guid(), $poster->guid, $container->guid);
// Notify wall owner
if ($poster->guid !== $container->guid && $container instanceof ElggUser) {
$to = $container->guid;
$from = $poster->guid;
$target = elgg_echo("wall:target:{$entity->getSubtype()}");
$ownership = elgg_echo('wall:ownership:your', array($target));
$subject = elgg_echo('wall:new:notification:subject', array($poster->name, $ownership));
$body = elgg_echo('wall:new:notification:message', array($poster->name, $ownership, $message, $entity->getURL()));
notify_user($to, $from, $subject, $body);
}
// Notify tagged users
$tagged_friends = $entity->getTaggedFriends();
foreach ($tagged_friends as $tagged_friend) {
// user tagged herself or the wall owner
if ($tagged_friend->guid == $poster->guid || $tagged_friend->guid == $container->guid || in_array($tagged_friend->guid, $sent)) {
continue;
}
$sent[] = $tagged_friend->guid;
$to = $tagged_friend->guid;
$from = $poster->guid;
$subject = elgg_echo('wall:tagged:notification:subject', array($poster->name));
$body = elgg_echo('wall:tagged:notification:message', array($poster->name, $message, $entity->getURL()));
notify_user($to, $from, $subject, $body);
}
elgg_push_context('widgets');
$default_msg_body = elgg_view_entity($entity, array('full_view' => false));
elgg_pop_context();
global $NOTIFICATION_HANDLERS;
// Get users interested in content from this person and notify them
// (Person defined by container_guid so we can also subscribe to groups if we want)
foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
$interested_users = ElggBatch('elgg_get_entities_from_relationship', array('site_guids' => ELGG_ENTITIES_ANY_VALUE, 'relationship' => 'notify' . $method, 'relationship_guid' => $entity->container_guid, 'inverse_relationship' => true, 'type' => 'user', 'limit' => false));
foreach ($interested_users as $user) {
if ($user instanceof ElggUser && !$user->isBanned() && !in_array($user->guid, $sent)) {
if (has_access_to_entity($entity, $user) && $entity->access_id != ACCESS_PRIVATE) {
$body = elgg_trigger_plugin_hook('notify:entity:message', 'object', array('entity' => $entity, 'to_entity' => $user, 'method' => $method), $default_msg_body);
if ($body !== false) {
notify_user($user->guid, $entity->container_guid, $subject, $body, null, array($method));
}
}
}
}
}
return true;
}