本文整理汇总了PHP中elgg_set_ignore_access函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_set_ignore_access函数的具体用法?PHP elgg_set_ignore_access怎么用?PHP elgg_set_ignore_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_set_ignore_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: weekly_cron
/**
* @TODO - is there a way we can target them directly instead of iterating through all?
*
* @param type $h
* @param type $t
* @param type $r
* @param type $p
* @return type
*/
function weekly_cron($h, $t, $r, $p)
{
$ia = elgg_set_ignore_access(true);
// check for abandoned acls
$dbprefix = elgg_get_config('dbprefix');
// try to make this as light as possible
$options = array('type' => 'object', 'subtype' => 'granular_access', 'limit' => false);
$batch = new ElggBatch('elgg_get_entities', $options);
foreach ($batch as $b) {
$sql = "SELECT COUNT(guid) as total FROM {$dbprefix}entities WHERE access_id = {$b->acl_id}";
$result = get_data($sql);
if ($result[0]->total) {
continue;
}
$sql = "SELECT COUNT(id) as total FROM {$dbprefix}metadata WHERE access_id = {$b->acl_id}";
$result = get_data($sql);
if ($result[0]->total) {
continue;
}
$sql = "SELECT COUNT(id) as total FROM {$dbprefix}annotations WHERE access_id = {$b->acl_id}";
$result = get_data($sql);
if ($result[0]->total) {
continue;
}
// this appears to be orphaned
delete_access_collection($b->acl_id);
$b->delete();
}
elgg_set_ignore_access($ia);
return $r;
}
示例2: content_subscriptions_prepare_comment_notification
/**
* Change the default notification message for comments
*
* @param string $hook the name of the hook
* @param stirng $type the type of the hook
* @param Elgg_Notifications_Notification $return_value the current return value
* @param array $params supplied values
*
* @return Elgg_Notifications_Notification
*/
function content_subscriptions_prepare_comment_notification($hook, $type, $return_value, $params)
{
if (empty($return_value) || !$return_value instanceof \Elgg\Notifications\Notification) {
return $return_value;
}
if (empty($params) || !is_array($params)) {
return $return_value;
}
$event = elgg_extract("event", $params);
if (empty($event) || !$event instanceof \Elgg\Notifications\Event) {
return $return_value;
}
// ignore access for now
$ia = elgg_set_ignore_access(true);
$comment = $event->getObject();
$actor = $event->getActor();
$object = $comment->getContainerEntity();
$language = elgg_extract("language", $params, get_current_language());
$recipient = elgg_extract("recipient", $params);
$return_value->subject = elgg_echo("content_subscriptions:create:comment:subject", array($object->title), $language);
$return_value->body = elgg_echo("content_subscriptions:create:comment:message", array($recipient->name, $actor->name, $object->title, $comment->description, $object->getURL()), $language);
$return_value->summary = elgg_echo("content_subscriptions:create:comment:summary", array($object->title), $language);
// restore access
elgg_set_ignore_access($ia);
return $return_value;
}
示例3: testWriteAccessArray
/**
* https://github.com/Elgg/Elgg/pull/6393
* Hook handlers for 'access:collections:write','all' hook should respect
* group's content access mode and container write permissions
*/
public function testWriteAccessArray()
{
$membersonly = ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY;
$unrestricted = ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED;
$original_page_owner = elgg_get_page_owner_entity();
elgg_set_page_owner_guid($this->group->guid);
$ia = elgg_set_ignore_access(false);
// User is not a member of the group
// Member-only group
$this->group->setContentAccessMode($membersonly);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
// Unrestricted group
$this->group->setContentAccessMode($unrestricted);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertFalse(array_key_exists($this->group->group_acl, $write_access));
// User is a member (can write to container)
$this->group->join($this->user);
// Member-only group
$this->group->setContentAccessMode($membersonly);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
// Unrestricted group
$this->group->setContentAccessMode($unrestricted);
$write_access = get_write_access_array($this->user->guid, true);
$this->assertTrue(array_key_exists($this->group->group_acl, $write_access));
elgg_set_ignore_access($ia);
$this->group->leave($this->user);
$original_page_owner_guid = elgg_instanceof($original_page_owner) ? $original_page_owner->guid : 0;
elgg_set_page_owner_guid($original_page_owner_guid);
}
示例4: 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)) {
// ignore access
$ia = elgg_set_ignore_access(true);
// add user to the auto join groups
if ($auto_joins = elgg_get_plugin_setting("auto_join", "group_tools")) {
$auto_joins = string_to_tag_array($auto_joins);
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);
}
}
}
}
// auto detect email invited groups
if ($groups = group_tools_get_invited_groups_by_email($user->email, $site_guid)) {
foreach ($groups as $group) {
// join the group
$group->join($user);
}
}
// restore access settings
elgg_set_ignore_access($ia);
}
}
}
示例5: river_activity_3C_bday_mailer
function river_activity_3C_bday_mailer($hook, $entity_type, $returnvalue, $params)
{
$bday = elgg_get_plugin_setting('birth_day', 'river_activity_3C');
elgg_set_ignore_access(true);
$siteurl = elgg_get_site_entity()->url;
$sitename = elgg_get_site_entity()->name;
$siteemail = elgg_get_site_entity()->email;
$from = $sitename . ' <' . $siteemail . '>';
$month = date('m', strtotime("now"));
$options = array('metadata_names' => 'BD_month', 'metadata_values' => $month, 'types' => 'user', 'limit' => false, 'full_view' => false, 'pagination' => false);
$bd_users = new ElggBatch('elgg_get_entities_from_metadata', $options);
$bd_today = date('j, F', strtotime('now'));
foreach ($bd_users as $bd_user) {
$bd_name = $bd_user->name;
$bd_email = $bd_user->email;
$bd_day = date('j, F', strtotime($bd_user->{$bday}));
if ($bd_day == $bd_today) {
if ($bd_email) {
$message = elgg_echo('river_activity_3C:bday_message', array($bd_name, $bd_day, $sitename, $siteurl));
elgg_send_email($from, $bd_email, elgg_echo('river_activity_3C:bday_message:subject'), $message);
$result = elgg_echo("river_activity_3C:bday_mailer_cron_true");
} else {
$result = elgg_echo("river_activity_3C:bday_mailer_cron_false");
}
}
}
elgg_set_ignore_access(false);
return $returnvalue . $result;
}
示例6: testSqlAdditionalSelectsAsVolatileDataWithCache
/**
* Checks if additional select columns are readable as volatile data even if we hit the cache while fetching entity.
*
* https://github.com/Elgg/Elgg/issues/5544
*/
public function testSqlAdditionalSelectsAsVolatileDataWithCache()
{
// remove ignore access as it disables entity cache
$access = elgg_set_ignore_access(false);
// may not have groups in DB - let's create one
$group = new ElggGroup();
$group->name = 'test_group';
$group->access_id = ACCESS_PUBLIC;
$this->assertTrue($group->save() !== false);
foreach (array('site', 'user', 'group', 'object') as $type) {
$entities = elgg_get_entities(array('type' => $type, 'selects' => array('42 as added_col3'), 'limit' => 1));
$entity = array_shift($entities);
$this->assertTrue($entity instanceof ElggEntity);
$this->assertEqual($entity->added_col3, null, "Additional select columns are leaking to attributes for " . get_class($entity));
$this->assertEqual($entity->getVolatileData('select:added_col3'), 42);
// make sure we have cached the entity
$this->assertNotEqual(false, _elgg_retrieve_cached_entity($entity->guid));
}
// run these again but with different value to make sure cache does not interfere
foreach (array('site', 'user', 'group', 'object') as $type) {
$entities = elgg_get_entities(array('type' => $type, 'selects' => array('64 as added_col3'), 'limit' => 1));
$entity = array_shift($entities);
$this->assertTrue($entity instanceof ElggEntity);
$this->assertEqual($entity->added_col3, null, "Additional select columns are leaking to attributes for " . get_class($entity));
$this->assertEqual($entity->getVolatileData('select:added_col3'), 64, "Failed to overwrite volatile data in cached entity");
}
elgg_set_ignore_access($access);
$group->delete();
}
示例7: current_dokuwiki_entity
function current_dokuwiki_entity($create = true)
{
$page_owner = elgg_get_page_owner_guid();
$user = elgg_get_logged_in_user_entity();
//error_log($page_owner->guid);
//error_log($user->guid);
if (!$page_owner) {
$page_owner = 0;
}
$entities = elgg_get_entities(array('types' => 'object', 'subtypes' => 'dokuwiki', 'limit' => 1, 'owner_guid' => $page_owner));
if ($entities) {
$doku = $entities[0];
return $doku;
} elseif ($user && $create) {
elgg_set_ignore_access(true);
$newdoku = new ElggObject();
$newdoku->access_id = ACCESS_PUBLIC;
$newdoku->owner_guid = $page_owner;
$newdoku->subtype = 'dokuwiki';
$newdoku->container_guid = $page_owner;
$newdoku->save();
$acl = array();
$acl[] = "# acl.auth.php";
$acl[] = '# <?php exit()?\\>';
$acl[] = "* @ALL 0";
$acl[] = "* @user 1";
$acl[] = "* @member 8";
$acl[] = "* @admin 16";
$acl[] = "* @root 255";
$newdoku->wiki_acl = implode("\n", $acl) . "\n";
elgg_set_ignore_access(false);
return $newdoku;
}
}
示例8: newsletter_cron_handler
/**
* The cron hook will take care of sending all the scheduled newsletters
*
* @param string $hook name of the hook
* @param string $type type of the hook
* @param string $returnvalue returnvalue of the hook
* @param array $params params of the hook
*
* @return void
*/
function newsletter_cron_handler($hook, $type, $returnvalue, $params)
{
if (!empty($params) && is_array($params)) {
$cron_ts = elgg_extract("time", $params, time());
// check for time drift
if (date("i", $cron_ts) >= 30) {
// example of the time: 14:59:56
// which should be the hourly cron for 15:00:00
$cron_ts = $cron_ts + 30 * 60;
}
// make the timestamp to an hour
$newsletter_ts = mktime(date("H", $cron_ts), 0, 0, date("n", $cron_ts), date("j", $cron_ts), date("Y", $cron_ts));
$options = array("type" => "object", "subtype'" => Newsletter::SUBTYPE, "limit" => false, "metadata_name_value_pairs" => array("name" => "scheduled", "value" => $newsletter_ts));
// ignore access
$ia = elgg_set_ignore_access(true);
$newsletters = elgg_get_entities_from_metadata($options);
// retore access
elgg_set_ignore_access($ia);
if (!empty($newsletters)) {
foreach ($newsletters as $newsletter) {
newsletter_start_commandline_sending($newsletter);
}
}
}
}
示例9: daily
/**
* Add menu items to the filter menu
*
* @param string $hook 'cron'
* @param string $type 'daily'
* @param string $return_value optional output
* @param array $params supplied params
*
* @return void
*/
public static function daily($hook, $type, $return_value, $params)
{
if (!static_out_of_date_enabled()) {
return;
}
$time = elgg_extract('time', $params, time());
$days = (int) elgg_get_plugin_setting('out_of_date_days', 'static');
$site = elgg_get_site_entity();
$options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => false, 'modified_time_upper' => $time - $days * 24 * 60 * 60, 'modified_time_lower' => $time - ($days + 1) * 24 * 60 * 60, 'order_by' => 'e.time_updated DESC'];
// ignore access
$ia = elgg_set_ignore_access(true);
$batch = new \ElggBatch('elgg_get_entities', $options);
$users = [];
foreach ($batch as $entity) {
$last_editors = $entity->getAnnotations(['annotation_name' => 'static_revision', 'limit' => 1, 'order_by' => 'n_table.time_created DESC']);
if (empty($last_editors)) {
continue;
}
$users[$last_editors[0]->getOwnerGUID()] = $last_editors[0]->getOwnerEntity();
}
// restore access
elgg_set_ignore_access($ia);
if (empty($users)) {
return;
}
foreach ($users as $user) {
$subject = elgg_echo('static:out_of_date:notification:subject');
$message = elgg_echo('static:out_of_date:notification:message', [$user->name, elgg_normalize_url('static/out_of_date/' . $user->username)]);
notify_user($user->getGUID(), $site->getGUID(), $subject, $message, [], 'email');
}
}
示例10: updateQuestion
/**
* After the question is updated in the databse make sure the answers have the same access_id
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param \ElggObject $entity the affected object
*
* @return void
*/
public static function updateQuestion($event, $type, $entity)
{
if (!$entity instanceof \ElggQuestion) {
return;
}
$org_attributes = $entity->getOriginalAttributes();
if (elgg_extract('access_id', $org_attributes) === null) {
// access wasn't updated
return;
}
// ignore access for this part
$ia = elgg_set_ignore_access(true);
// get all the answers for this question
$answers = $entity->getAnswers(['limit' => false]);
if (empty($answers)) {
// restore access
elgg_set_ignore_access($ia);
return;
}
/* @var $answer \ElggAnswer */
foreach ($answers as $answer) {
// update the access_id with the questions access_id
$answer->access_id = $entity->access_id;
$answer->save();
}
// restore access
elgg_set_ignore_access($ia);
}
示例11: westorElggMan_cron_handler
function westorElggMan_cron_handler($hook, $entity_type, $returnvalue, $params)
{
global $CONFIG;
// old elgg bevore 1.7.0
global $is_admin;
$is_admin = true;
if (function_exists("elgg_set_ignore_access")) {
// new function for access overwrite
elgg_set_ignore_access(true);
}
$context = westorElggMan_get_context();
westorElggMan_set_context('westorElggMan');
$prefix = $CONFIG->dbprefix;
$sql = "SELECT {$prefix}metadata.entity_guid\nFROM (({$prefix}metadata AS {$prefix}metadata_1 INNER JOIN {$prefix}metastrings AS {$prefix}metastrings_3\nON {$prefix}metadata_1.name_id = {$prefix}metastrings_3.id) INNER JOIN {$prefix}metastrings\nAS {$prefix}metastrings_2 ON {$prefix}metadata_1.value_id = {$prefix}metastrings_2.id) INNER JOIN (({$prefix}metadata INNER JOIN {$prefix}metastrings ON {$prefix}metadata.name_id = {$prefix}metastrings.id) INNER JOIN {$prefix}metastrings AS {$prefix}metastrings_1 ON {$prefix}metadata.value_id = {$prefix}metastrings_1.id) ON {$prefix}metadata_1.entity_guid = {$prefix}metadata.entity_guid\nWHERE ((({$prefix}metastrings.string)='waitForSend') AND (({$prefix}metastrings_1.string)='1')\nAND (({$prefix}metastrings_3.string)='hiddenTo') AND (({$prefix}metastrings_2.string)<>'1'))";
// and (scheduled is null || scheduled <= now());
try {
$result = get_data($sql);
} catch (Exception $e) {
westorElggMan_set_context($context);
throw new Exception($e);
}
if (is_array($result)) {
$elggMan = new class_elggMan();
$now = date("Y-m-d H:i:s");
foreach ($result as $row) {
$message = westorElggMan_get_entity($row->entity_guid);
if (is_object($message) && $message->getSubtype() == "messages" && ($message->scheduled == null || $message->scheduled <= $now)) {
$elggMan->sendMsgNow($message);
}
}
}
westorElggMan_set_context($context);
}
示例12: hj_framework_set_ancestry
/**
* Retrieve ancestry relationships / update if they have changed
*
* @param int $guid
* @param mixed $subtypes
* @return boolean|array
*/
function hj_framework_set_ancestry($guid)
{
$entity = get_entity($guid);
if (!$entity) {
return false;
}
$ia = elgg_set_ignore_access(true);
// Build an hierarchy from [0]highest to [X]lowest
$ancestry = array();
$ancestry_guids = array();
$container = $entity->getContainerEntity();
while (elgg_instanceof($container)) {
array_unshift($ancestry, $container);
array_unshift($ancestry_guids, $container->guid);
$container = $container->getContainerEntity();
}
// Store as a hash so we don't unnecessarily update the hierarchy every time save() is calleed
if (!isset($entity->hierarchy_hash) || $entity->hierarchy_hash != sha1(serialize($ancestry_guids))) {
remove_entity_relationships($entity->guid, 'descendant', false);
foreach ($ancestry as $ancestor) {
if (elgg_instanceof($ancestor, 'object')) {
update_entity_last_action($ancestor->guid, $entity->time_created);
}
if (!check_entity_relationship($entity->guid, 'descendant', $ancestor->guid)) {
add_entity_relationship($entity->guid, 'descendant', $ancestor->guid);
}
}
$entity->hierarchy_hash = sha1(serialize($ancestry_guids));
}
elgg_set_ignore_access($ia);
return $ancestry;
}
示例13: event_shutdown
function event_shutdown()
{
State::$handle_updates = false;
if (State::$users_leaving_probation) {
set_time_limit(0);
}
$ia = elgg_set_ignore_access(true);
$force_private = elgg_get_plugin_setting(QUARANTINE_PRIVATE, PLUGIN_ID);
foreach (State::$entities_quarantined as $entity) {
if ($entity->{ORIGINAL_ACCESS_ID} === null || $entity->access_id != ACCESS_PRIVATE) {
$entity->{ORIGINAL_ACCESS_ID} = $entity->access_id;
}
if ($force_private) {
$entity->access_id = ACCESS_PRIVATE;
} elseif ($entity->access_id == ACCESS_PUBLIC) {
$entity->access_id = ACCESS_LOGGED_IN;
}
$entity->save();
}
foreach (State::$users_leaving_probation as $user) {
$options = ['owner_guid' => $user->guid, 'metadata_name' => QUARANTINED, 'metadata_value' => '1', 'limit' => 0];
$batch = new \ElggBatch('elgg_get_entities_from_metadata', $options, null, 25, false);
foreach ($batch as $object) {
/* @var \ElggObject $object */
approve_content($object);
}
}
elgg_set_ignore_access($ia);
}
示例14: notifyLastEditor
/**
* Make sure the last editor of a static page gets notified about a comment
*
* @param string $event 'create'
* @param string $type 'object'
* @param \ElggObject $object the object that was just created
*
* @return void
*/
public static function notifyLastEditor($event, $type, \ElggObject $object)
{
// check of this is a comment
if (empty($object) || !elgg_instanceof($object, 'object', 'comment')) {
return;
}
// is it a comment on a static page
$container = $object->getContainerEntity();
if (empty($container) || !elgg_instanceof($container, 'object', 'static')) {
return;
}
$comment_owner = $object->getOwnerEntity();
// get last revisor
$ia = elgg_set_ignore_access(true);
$revisions = $container->getAnnotations(['annotation_name' => 'static_revision', 'limit' => 1, 'reverse_order_by' => true]);
$static_owner = $revisions[0]->getOwnerEntity();
elgg_set_ignore_access($ia);
// don't notify yourself
if ($static_owner->getGUID() == $comment_owner->getGUID()) {
return;
}
// @see actions/comment/save
$subject = elgg_echo('generic_comment:email:subject');
$message = elgg_echo('generic_comment:email:body', [$container->title, $comment_owner->name, $object->description, $container->getURL(), $comment_owner->name, $comment_owner->getURL()]);
$params = ['object' => $object, 'action' => 'create'];
notify_user($static_owner->getGUID(), $comment_owner->getGUID(), $subject, $message, $params);
}
示例15: routeAll
/**
* Check if requested page is a static page
*
* @param string $hook name of the hook
* @param string $type type of the hook
* @param array $return_value return value
* @param array $params hook parameters
*
* @return array
*/
public static function routeAll($hook, $type, $return_value, $params)
{
if (!is_array($return_value)) {
// someone else already routed this page
return;
}
/**
* $return_value contains:
* $return_value['identifier'] => requested handler
* $return_value['segments'] => url parts ($page)
*/
$identifier = elgg_extract('identifier', $return_value);
if (empty($identifier)) {
return;
}
$handlers = _elgg_services()->router->getPageHandlers();
if (elgg_extract($identifier, $handlers)) {
return;
}
$ia = elgg_set_ignore_access(true);
$entities = elgg_get_entities_from_metadata(['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => 1, 'metadata_name_value_pairs' => ['friendly_title' => $identifier], 'metadata_case_sensitive' => false]);
elgg_set_ignore_access($ia);
if (empty($entities)) {
return;
}
$entity = $entities[0];
if (!has_access_to_entity($entity) && !$entity->canEdit()) {
return;
}
$return_value['segments'] = ['view', $entity->getGUID()];
$return_value['identifier'] = 'static';
return $return_value;
}