本文整理汇总了PHP中elgg_get_ignore_access函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_ignore_access函数的具体用法?PHP elgg_get_ignore_access怎么用?PHP elgg_get_ignore_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_ignore_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_list_vars
/**
* filter the items sent to a list view
*
* @param type $hook
* @param type $type
* @param type $return
* @param type $params
* @return type
*/
function filter_list_vars($hook, $type, $return, $params)
{
$filter_river = elgg_get_plugin_setting('hide_old_items', PLUGIN_ID);
if ($filter_river == 'no') {
// no need to filter
return $return;
}
if ($return['items'] && is_array($return['items'])) {
foreach ($return['items'] as $key => $item) {
if (!$item instanceof \ElggRiverItem) {
continue;
}
if ($item->type == 'object') {
continue;
}
if ($item->subject_guid == elgg_get_logged_in_user_guid()) {
continue;
}
if (elgg_is_admin_logged_in()) {
continue;
}
if (elgg_get_ignore_access()) {
continue;
}
unset($return['items'][$key]);
}
}
return $return;
}
示例2: getWaitingUsers
public function getWaitingUsers($count = false)
{
$ia = elgg_get_ignore_access();
elgg_set_ignore_access(true);
if ($count) {
$result = $this->countEntitiesFromRelationship(EVENT_MANAGER_RELATION_SLOT_REGISTRATION_WAITINGLIST, true);
} else {
$result = $this->getEntitiesFromRelationship(EVENT_MANAGER_RELATION_SLOT_REGISTRATION_WAITINGLIST, true);
}
elgg_set_ignore_access($ia);
return $result;
}
示例3: page_handler_webodf_elgg
function page_handler_webodf_elgg($page)
{
// Read the URI parameters based on <siteurl>/gdocspreview/param1/param2
$file_guid = $page[0];
$timestamp = intval($page[1]);
if (isset($timestamp)) {
// This is a hack, but it works. It will prevent anyone or Google from
// storing the public URL to access our private files. There is a 90
// second window in which the file is accessible. After that period,
// if you try to access the file from the same URL, it will be denied.
$date = new DateTime();
$max = $date->format('U') + 90;
$min = $date->format('U') - 90;
if ($timestamp > $min && $timestamp < $max) {
// keep track of the old access level
$old_access = elgg_get_ignore_access();
// temporarily make the access level public
elgg_set_ignore_access(true);
$file = get_entity($file_guid);
if (!$file) {
register_error(elgg_echo("file:downloadfailed"));
forward();
}
$mime = $file->getMimeType();
if (!$mime) {
$mime = "application/octet-stream";
}
$filename = $file->originalfilename;
// fix for IE https issue
header("Pragma: public");
header("Content-type: {$mime}");
if (strpos($mime, "image/") !== false || $mime == "application/pdf") {
header("Content-Disposition: inline; filename=\"{$filename}\"");
} else {
header("Content-Disposition: attachment; filename=\"{$filename}\"");
}
ob_clean();
flush();
readfile($file->getFilenameOnFilestore());
// restore the access level
elgg_set_ignore_access($old_access);
exit;
} else {
register_error(elgg_echo("file:downloadfailed"));
forward();
}
} else {
register_error(elgg_echo("file:downloadfailed"));
forward();
}
}
示例4: _elgg_cache_entity
/**
* Cache an entity.
*
* Stores an entity in $ENTITY_CACHE;
*
* @param ElggEntity $entity Entity to cache
*
* @return void
* @see _elgg_retrieve_cached_entity()
* @see _elgg_invalidate_cache_for_entity()
* @access private
* @todo Use an ElggCache object
*/
function _elgg_cache_entity(ElggEntity $entity)
{
global $ENTITY_CACHE;
// Don't cache non-plugin entities while access control is off, otherwise they could be
// exposed to users who shouldn't see them when control is re-enabled.
if (!$entity instanceof ElggPlugin && elgg_get_ignore_access()) {
return;
}
// Don't store too many or we'll have memory problems
// @todo Pick a less arbitrary limit
if (count($ENTITY_CACHE) > 256) {
$random_guid = array_rand($ENTITY_CACHE);
unset($ENTITY_CACHE[$random_guid]);
// Purge separate metadata cache. Original idea was to do in entity destructor, but that would
// have caused a bunch of unnecessary purges at every shutdown. Doing it this way we have no way
// to know that the expunged entity will be GCed (might be another reference living), but that's
// OK; the metadata will reload if necessary.
elgg_get_metadata_cache()->clear($random_guid);
}
$ENTITY_CACHE[$entity->guid] = $entity;
}
示例5: group_tools_join_site_handler
function group_tools_join_site_handler($event, $type, $relationship)
{
if (!empty($relationship) && $relationship instanceof ElggRelationship) {
$user_guid = $relationship->guid_one;
$site_guid = $relationship->guid_two;
if (($user = get_user($user_guid)) && ($auto_joins = elgg_get_plugin_setting("auto_join", "group_tools"))) {
$auto_joins = string_to_tag_array($auto_joins);
// ignore access
$ia = elgg_get_ignore_access();
elgg_set_ignore_access(true);
foreach ($auto_joins as $group_guid) {
if (($group = get_entity($group_guid)) && $group instanceof ElggGroup) {
if ($group->site_guid == $site_guid) {
// join the group
$group->join($user);
}
}
}
// restore access settings
elgg_set_ignore_access($ia);
}
}
}
示例6: elgg_push_breadcrumb
} else {
elgg_push_breadcrumb($crumbs_title, "vouchers/owner/{$page_owner->username}");
}
$title = $voucher->title;
elgg_push_breadcrumb($title);
$content = elgg_view_entity($voucher, array('full_view' => true));
if ($voucher->comments_on != 'Off') {
$content .= elgg_view_comments($voucher);
}
$sidebar = '';
// show voucher sales on sidebar if any only for voucher owner
if (elgg_is_logged_in()) {
$user = elgg_get_logged_in_user_entity();
if ($user && $user->guid == $page_owner->guid) {
// set ignore access for loading all sales entries
$ia = elgg_get_ignore_access();
elgg_set_ignore_access(true);
// load list buyers
$options = array('type' => 'object', 'subtype' => 'vsales', 'limit' => 0, 'metadata_name_value_pairs' => array(array('name' => 'txn_vguid', 'value' => $voucher->guid, 'operand' => '=')));
$buyerslist = elgg_get_entities_from_metadata($options);
$sidebar .= '<div style="font-size:90%;">';
$sidebar .= '<h3>' . elgg_echo('vouchers:sales') . '</h3>';
if (is_array($buyerslist)) {
foreach ($buyerslist as $b) {
//$sidebar .= $b->voucher_guid.' - '.$b->user_guid.' - '.$b->txn_date.'<br/>';
$buyer = get_user($b->txn_buyer_guid);
$sidebar .= '<p><a href="' . elgg_get_site_url() . 'profile/' . $buyer->username . '">' . $buyer->username . '</a> - ' . elgg_view_friendly_time($b->time_created);
$sidebar .= '<br/>' . elgg_echo('vouchers:transactionid') . ': ' . $b->txn_id;
//$sidebar .= '<br/>'.elgg_echo('vouchers:addvoucher:code').': '.get_buyer_code($b->txn_code, $voucher).'</p>';
}
}
示例7: create
/**
* Function to add custom profile fields to user on register
*
* @param string $event Event name
* @param string $object_type Event type
* @param ElggUser $object User being created
*
* @return array
*/
public static function create($event, $object_type, $object)
{
$custom_profile_fields = [];
// retrieve all field that were on the register page
foreach ($_POST as $key => $value) {
if (strpos($key, 'custom_profile_fields_') === 0) {
$key = substr($key, 22);
$custom_profile_fields[$key] = get_input("custom_profile_fields_{$key}");
}
}
if (count($custom_profile_fields) > 0) {
$categorized_fields = profile_manager_get_categorized_fields(null, true, true);
$configured_fields = $categorized_fields['fields'];
// set ignore access
$ia = elgg_get_ignore_access();
elgg_set_ignore_access(true);
foreach ($custom_profile_fields as $shortname => $value) {
// determine if $value should be an array
if (!is_array($value) && !empty($configured_fields)) {
// only do something if it not is already an array
foreach ($configured_fields as $configured_field) {
if ($configured_field->metadata_name == $shortname) {
if ($configured_field->metadata_type == 'tags' || $configured_field->output_as_tags == 'yes') {
$value = string_to_tag_array($value);
// no need to continue this foreach
break;
}
}
}
}
// use create_metadata to listen to default access
if (is_array($value)) {
$i = 0;
foreach ($value as $interval) {
$i++;
if ($i == 1) {
$multiple = false;
} else {
$multiple = true;
}
create_metadata($object->guid, $shortname, $interval, 'text', $object->guid, get_default_access($object), $multiple);
}
} else {
create_metadata($object->guid, $shortname, $value, 'text', $object->guid, get_default_access($object));
}
}
// restore ignore access
elgg_set_ignore_access($ia);
}
if (isset($_FILES['profile_icon'])) {
if (!profile_manager_add_profile_icon($object)) {
// return false to delete the user
return false;
}
}
$terms = elgg_get_plugin_setting('registration_terms', 'profile_manager');
if ($terms) {
$object->setPrivateSetting('general_terms_accepted', time());
}
elgg_clear_sticky_form('profile_manager_register');
}
示例8: elgg_get_ignore_access
<?php
$access_level = elgg_get_ignore_access();
elgg_set_ignore_access();
$guid = get_input('group_guid');
$groupName = get_input('name');
function copyGroup($guid, $name, $parentGroupGuid = null, array $options = null)
{
$inheritMembers = $_POST['inheritMembers'];
$inheritFiles = $_POST['inheritFiles'];
$inheritForums = $_POST['inheritForums'];
$inheritSubGroups = $_POST['subGroups'];
if ($options) {
$inheritMembers = $options['inheritMembers'];
$inheritFiles = $options['inheritFiles'];
$inheritForums = $options['inheritForums'];
$inheritSubGroups = $options['inheritSubGroups'];
}
$groupOptions = array('inheritMembers' => $inheritMembers, 'inheritFiles' => $inheritFiles, 'inheritForums' => $inheritForums, 'inheritSubGroups' => $inheritSubGroups);
//check if a sub-group when parentGroupGuid is null
if (!isset($parentGroupGuid)) {
$parentGroup = elgg_get_entities_from_relationship(array("relationship" => "au_subgroup_of", "relationship_guid" => $guid));
$parentGroupGuid = $parentGroup[0]->guid;
}
//get group
$oldGroup = get_entity($guid);
//get user
$user = get_user($oldGroup->owner_guid);
//create new group
$newGroup = clone $oldGroup;
$newGroup->name = $name;
示例9: elgg_solr_get_access_query
/**
* Get access query for Solr search
*
* @param int $user_guid GUID of the user accessing content
* @return string
*/
function elgg_solr_get_access_query($user_guid = null)
{
if (elgg_get_ignore_access()) {
return '';
}
if (!isset($user_guid)) {
$user_guid = elgg_get_logged_in_user_guid();
}
if (elgg_is_admin_user($user_guid)) {
return '';
}
$access_public = elgg_solr_escape_special_chars(ACCESS_PUBLIC);
$access_friends = elgg_solr_escape_special_chars(ACCESS_FRIENDS);
$user_guid = elgg_solr_escape_special_chars($user_guid);
$queries = [];
if ($user_guid) {
$queries['ors']['collections'] = "access_id:{!join from=access_list_is to=access_id}id:{$user_guid}";
$queries['ors']['is_owner'] = "owner_guid:{$user_guid}";
$queries['ors']['is_friend'] = "access_id:{$access_friends} AND owner_guid:{!join from=friends_of_is to=owner_guid}id:{$user_guid}";
} else {
$queries['ors']['collections'] = "access_id:{$access_public}";
}
$params = ['user_guid' => $user_guid];
$queries = elgg_trigger_plugin_hook('elgg_solr:access', 'entities', $params, $queries);
if (!empty($queries['ors'])) {
$ors = [];
foreach ($queries['ors'] as $or) {
$ors[] = "({$or})";
}
$queries['ands'][] = implode(' OR ', $ors);
}
$query_str = '';
if (!empty($queries['ands'])) {
$ands = [];
foreach ($queries['ands'] as $and) {
$ands[] = "({$and})";
}
$query_str = '(' . implode(' AND ', $ands) . ')';
}
return $query_str;
}
示例10: getIgnoreAccess
/**
* Get the ignore access value
*
* @return bool
*/
protected function getIgnoreAccess()
{
if (null === $this->ignoreAccess) {
return elgg_get_ignore_access();
} else {
return $this->ignoreAccess;
}
}
示例11: elgg_check_access_overrides
/**
* Decides if the access system should be ignored for a user.
*
* Returns true (meaning ignore access) if either of these 2 conditions are true:
* 1) an admin user guid is passed to this function.
* 2) {@link elgg_get_ignore_access()} returns true.
*
* @see elgg_set_ignore_access()
*
* @param int $user_guid The user to check against.
*
* @return bool
* @since 1.7.0
*/
function elgg_check_access_overrides($user_guid = 0)
{
if (!$user_guid || $user_guid <= 0) {
$is_admin = false;
} else {
$is_admin = elgg_is_admin_user($user_guid);
}
return $is_admin || elgg_get_ignore_access();
}
示例12: social_connect_handle_authentication
function social_connect_handle_authentication($user_profile, $provider)
{
global $CONFIG;
global $HA_SOCIAL_CONNECT_PROVIDERS_CONFIG;
$ignore_access = elgg_get_ignore_access();
$provider_name = $HA_SOCIAL_CONNECT_PROVIDERS_CONFIG[$provider]['provider_name'];
$user_uid = $user_profile->identifier;
// establish the value for the proceeding hook
$default_proceed = elgg_get_plugin_setting("ha_settings_{$provider}_hook1_default", 'social_connect');
if (!$default_proceed || $default_proceed == 'global') {
$default_proceed = elgg_get_plugin_setting('ha_settings_hook1_default', 'social_connect');
}
if (!$default_proceed) {
$default_proceed = SOCIAL_CONNECT_DEFAULT_PROCEED;
} else {
if ($default_proceed == 'true') {
$default_proceed = true;
} else {
if ($default_proceed == 'false') {
$default_proceed = false;
}
}
}
// the arguments for social connect events and hooks
$args = array('mode' => null, 'userid' => $user_uid, 'provider' => $HA_SOCIAL_CONNECT_PROVIDERS_CONFIG[$provider], 'user' => null, 'profile' => $user_profile);
// look for users that have already connected via this plugin
$options = array('type' => 'user', 'plugin_id' => 'social_connect', 'plugin_user_setting_name_value_pairs' => array("{$provider}/uid" => $user_uid), 'plugin_user_setting_name_value_pairs_operator' => 'AND', 'limit' => 0);
$users = elgg_get_entities_from_plugin_user_settings($options);
if (!$users) {
// user has not connected with plugin before
$args['mode'] = 'connect';
elgg_set_ignore_access(true);
$proceed = elgg_trigger_plugin_hook('social_connect', 'user', $args, $default_proceed);
elgg_set_ignore_access($ignore_access);
if ($proceed === false) {
// hook prevented social connection
return;
} else {
if ($proceed === 'email' || $proceed === 'emailOnly') {
// hook wants to try and connect via email address
// check whether the user already exists with the email provided
$useremail = $user_profile->email;
if ($useremail && ($users = get_user_by_email($useremail))) {
social_connect_user($user_uid, $users[0], $user_profile, $provider);
system_message(sprintf(elgg_echo('social_connect:connect:ok'), $provider_name));
$args['mode'] = 'email';
$args['user'] = $users[0];
elgg_set_ignore_access(true);
elgg_trigger_event('social_connect', 'user', $args);
elgg_set_ignore_access($ignore_access);
return;
}
if ($proceed === 'emailOnly') {
// hook wants only email address connection or failure
register_error(sprintf(elgg_echo('social_connect:connect:emailnotfound'), $proceed));
return;
}
}
}
// email connection not required or failed, so register a new user
$userlogin = str_replace(' ', '', $user_profile->displayName);
if (!$userlogin) {
$userlogin = $provider . '_user_' . rand(1000, 9999);
}
$org_userlogin = $userlogin;
while (get_user_by_username($userlogin)) {
$userlogin = $org_userlogin . '_' . rand(1000, 9999);
}
unset($org_userlogin);
$password = generate_random_cleartext_password();
$username = $user_profile->displayName;
$user = new ElggUser();
$user->username = $userlogin;
$user->name = $username;
$user->email = $user_profile->email;
$user->access_id = ACCESS_PUBLIC;
$user->salt = generate_random_cleartext_password();
$user->password = generate_user_password($user, $password);
$user->owner_guid = 0;
$user->container_guid = 0;
if ($user->save()) {
if ($user->email && elgg_get_plugin_setting('notify_new_user', 'social_connect')) {
$email = elgg_echo('email:social_connect:body', array($userlogin, $password));
set_user_notification_setting($user->getGUID(), 'email', true);
notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:social_connect:subject', array($provider_name)), $email, NULL, 'email');
}
} else {
register_error(sprintf(elgg_echo('social_connect:register:bad'), $provider_name) . elgg_echo("zhaohu:sorry"));
elgg_log("ZHError social_connect:register:bad , userlogin {$userlogin}", "ERROR");
return;
}
system_message(sprintf(elgg_echo('social_connect:register:ok'), $provider_name));
social_connect_user($user_uid, $user, $user_profile, $provider);
$args['mode'] = 'register';
$args['user'] = $user;
elgg_set_ignore_access(true);
elgg_trigger_event('social_connect', 'user', $args);
elgg_set_ignore_access($ignore_access);
} elseif (count($users) == 1) {
// one user has already been registered on Elgg with this provider
//.........这里部分代码省略.........
示例13: canEdit
/**
* Can the user change this access collection?
*
* Use the plugin hook of 'access:collections:write', 'user' to change this.
* @see get_write_access_array() for details on the hook.
*
* Respects access control disabling for admin users and {@link elgg_set_ignore_access()}
*
* @see get_write_access_array()
*
* @param int $collection_id The collection id
* @param mixed $user_guid The user GUID to check for. Defaults to logged in user.
* @return bool
*/
function canEdit($collection_id, $user_guid = null)
{
if ($user_guid) {
$user = _elgg_services()->entityTable->get((int) $user_guid);
} else {
$user = _elgg_services()->session->getLoggedInUser();
}
$collection = get_access_collection($collection_id);
if (!$user instanceof \ElggUser || !$collection) {
return false;
}
$write_access = get_write_access_array($user->getGUID(), 0, true);
// don't ignore access when checking users.
if ($user_guid) {
return array_key_exists($collection_id, $write_access);
} else {
return elgg_get_ignore_access() || array_key_exists($collection_id, $write_access);
}
}
示例14: hj_framework_handle_multifile_upload
function hj_framework_handle_multifile_upload($user_guid)
{
if (!empty($_FILES)) {
$access = elgg_get_ignore_access();
elgg_set_ignore_access(true);
$file = $_FILES['Filedata'];
$filehandler = new hjFile();
$filehandler->owner_guid = (int) $user_guid;
$filehandler->container_guid = (int) $user_guid;
$filehandler->access_id = ACCESS_DEFAULT;
$filehandler->data_pattern = hj_framework_get_data_pattern('object', 'hjfile');
$filehandler->title = $file['name'];
$filehandler->description = '';
$prefix = "hjfile/";
$filestorename = elgg_strtolower($file['name']);
$mime = hj_framework_get_mime_type($file['name']);
$filehandler->setFilename($prefix . $filestorename);
$filehandler->setMimeType($mime);
$filehandler->originalfilename = $file['name'];
$filehandler->simpletype = hj_framework_get_simple_type($mime);
$filehandler->filesize = round($file['size'] / (1024 * 1024), 2) . "Mb";
$filehandler->open("write");
$filehandler->close();
move_uploaded_file($file['tmp_name'], $filehandler->getFilenameOnFilestore());
$file_guid = $filehandler->save();
hj_framework_set_entity_priority($filehandler);
elgg_trigger_plugin_hook('hj:framework:file:process', 'object', array('entity' => $filehandler));
if ($file_guid) {
$meta_value = $filehandler->getGUID();
} else {
$meta_value = $filehandler->getFilenameOnFilestore();
}
if ($file_guid && $filehandler->simpletype == "image") {
$thumb_sizes = hj_framework_get_thumb_sizes();
foreach ($thumb_sizes as $thumb_type => $thumb_size) {
$thumbnail = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $thumb_size['w'], $thumb_size['h'], $thumb_size['square'], 0, 0, 0, 0, true);
if ($thumbnail) {
$thumb = new ElggFile();
$thumb->setMimeType($file['type']);
$thumb->owner_guid = $user_guid;
$thumb->setFilename("{$prefix}{$filehandler->getGUID()}{$thumb_type}.jpg");
$thumb->open("write");
$thumb->write($thumbnail);
$thumb->close();
$thumb_meta = "{$thumb_type}thumb";
$filehandler->{$thumb_meta} = $thumb->getFilename();
unset($thumbnail);
}
}
}
$response = array('status' => 'OK', 'value' => $meta_value);
} else {
$response = array('status' => 'FAIL');
}
echo json_encode($response);
elgg_set_ignore_access($access);
return;
}
示例15: get_all_private_settings
/**
* Return an array of all private settings.
*
* @param int $entity_guid The entity GUID
*
* @return array|false
* @see set_private_setting()
* @see get_private_settings()
* @see remove_private_setting()
* @see remove_all_private_settings()
* @link http://docs.elgg.org/DataModel/Entities/PrivateSettings
*/
function get_all_private_settings($entity_guid)
{
global $PRIVATE_SETTINGS_CACHE;
static $private_setting_memcache;
$dbprefix = elgg_get_config("dbprefix");
$entity_guid = (int) $entity_guid;
// check if you have access to the entity
if (!elgg_get_ignore_access() && !get_entity_as_row($entity_guid)) {
return false;
}
// first check localy
if (isset($PRIVATE_SETTINGS_CACHE[$entity_guid])) {
return $PRIVATE_SETTINGS_CACHE[$entity_guid];
}
if (!isset($private_setting_memcache) && is_memcache_available()) {
$private_setting_memcache = new ElggMemcache("private_settings");
}
if ($private_setting_memcache) {
if ($settings = $private_setting_memcache->load($entity_guid)) {
// cache localy
$PRIVATE_SETTINGS_CACHE[$entity_guid] = $settings;
if (!empty($settings)) {
return $settings;
} else {
return false;
}
}
}
$query = "SELECT *";
$query .= " FROM {$dbprefix}private_settings";
$query .= " WHERE entity_guid = {$entity_guid}";
$settings = array();
if ($result = get_data($query)) {
foreach ($result as $r) {
$settings[$r->name] = $r->value;
}
}
if ($private_setting_memcache) {
$private_setting_memcache->save($entity_guid, $settings);
}
if (!empty($settings)) {
// cache localy
$PRIVATE_SETTINGS_CACHE[$entity_guid] = $settings;
return $settings;
}
return false;
}