本文整理汇总了PHP中get_default_access函数的典型用法代码示例。如果您正苦于以下问题:PHP get_default_access函数的具体用法?PHP get_default_access怎么用?PHP get_default_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_access函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_page
function process_page(ElggObject $page)
{
$tags_to_groups = array('ib' => 10113262, 'inkomstenbelasting' => 10113262, 'ob' => 12967492, 'btw' => 12967492, 'omzetbelasting' => 12967492, 'lh' => 10112672, 'loonheffingen' => 10112672, 'open forum' => 7746192, 'toeslagen' => 7746232, 'Toeslagen' => 7746232, 'vennootschapsbelasting' => 7746292);
$container_guid = false;
if (!$page->tags) {
return;
}
if (!is_array($page->tags)) {
$tags = array($page->tags);
} else {
$tags = $page->tags;
}
foreach ($tags_to_groups as $tag => $group_guid) {
if (in_array($tag, $tags)) {
$container_guid = $group_guid;
continue;
}
}
$news = new ElggObject();
$news->subtype = "news";
$news->title = $page->title;
$news->description = $page->description;
$news->tags = $page->tags;
$news->owner_guid = $page->owner_guid;
$news->container_guid = $container_guid;
$news->access_id = get_default_access();
$news->save();
$news->time_created = $page->time_created;
$news->time_updated = $page->time_updated;
$news->save();
}
示例2: createWidget
/**
* @see elgg_create_widget
* @access private
* @since 1.9.0
*/
public function createWidget($owner_guid, $handler, $context, $access_id = null)
{
if (empty($owner_guid) || empty($handler) || !$this->validateType($handler)) {
return false;
}
$owner = get_entity($owner_guid);
if (!$owner) {
return false;
}
$widget = new \ElggWidget();
$widget->owner_guid = $owner_guid;
$widget->container_guid = $owner_guid;
// @todo - will this work for group widgets?
if (isset($access_id)) {
$widget->access_id = $access_id;
} else {
$widget->access_id = get_default_access();
}
if (!$widget->save()) {
return false;
}
// private settings cannot be set until \ElggWidget saved
$widget->handler = $handler;
$widget->context = $context;
return $widget->getGUID();
}
示例3: getSite
static function getSite($a, $args, $c)
{
$site = elgg_get_site_entity();
$accessIds = [];
foreach (get_write_access_array() as $id => $description) {
$accessIds[] = ["id" => $id, "description" => $description];
}
return ["guid" => $site->guid, "title" => $site->title, "menu" => [["guid" => "menu:" . 1, "title" => "Blog", "link" => "/blog", "js" => true], ["guid" => "menu:" . 2, "title" => "Nieuws", "link" => "/news", "js" => true], ["guid" => "menu:" . 3, "title" => "Forum", "link" => "/forum", "js" => true]], "accessIds" => $accessIds, "defaultAccessId" => get_default_access()];
}
示例4: profile_river_updates
function profile_river_updates($event, $type, $object)
{
$user = get_entity($object->guid);
if ($user instanceof ElggUser) {
$view = 'river/user/default/profileupdate';
elgg_delete_river(array('subject_guid' => $user->guid, 'view' => $view));
elgg_create_river_item(array('view' => $view, 'action_type' => 'update', 'subject_guid' => $user->guid, 'object_guid' => $user->guid, 'access_id' => get_default_access($user)));
}
return true;
}
示例5: put
/**
* {@inheritdoc}
*/
public function put(ParameterBag $params)
{
$owner = get_entity($params->guid);
if (!$owner->canEdit()) {
throw new GraphException("You are not allowed to modify this user's profile", HttpResponse::HTTP_FORBIDDEN);
}
$profile_fields = (array) elgg_get_config('profile_fields');
$access_id = $params->access_id !== null ? $params->access_id : get_default_access($owner);
$input = array();
foreach ($profile_fields as $field => $valuetype) {
// Making sure the consumer has sent these fields with the request
if (isset($params->{$field}) && $this->request->get($field) !== null) {
$value = $params->{$field};
$value = _elgg_html_decode($value);
if (!is_array($value) && $valuetype != 'longtext' && elgg_strlen($value) > 250) {
throw new GraphException(elgg_echo('profile:field_too_long', array(elgg_echo("profile:{$field}")), HttpResponse::HTTP_BAD_REQUEST));
}
if ($value && $valuetype == 'url' && !preg_match('~^https?\\://~i', $value)) {
$value = "http://{$value}";
}
if ($valuetype == 'tags') {
$value = string_to_tag_array($value);
}
if ($valuetype == 'email' && !empty($value) && !is_email_address($value)) {
throw new GraphException(elgg_echo('profile:invalid_email', array(elgg_echo("profile:{$field}"))), HttpResponse::HTTP_BAD_REQUEST);
}
$input[$field] = $value;
}
}
// go through custom fields
if (sizeof($input) > 0) {
foreach ($input as $shortname => $value) {
$options = array('guid' => $owner->guid, 'metadata_name' => $shortname, 'limit' => false);
elgg_delete_metadata($options);
if (!is_null($value) && $value !== '') {
// only create metadata for non empty values (0 is allowed) to prevent metadata records
// with empty string values #4858
if (is_array($value)) {
$i = 0;
foreach ($value as $interval) {
$i++;
$multiple = $i > 1 ? TRUE : FALSE;
create_metadata($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
}
} else {
create_metadata($owner->getGUID(), $shortname, $value, 'text', $owner->getGUID(), $access_id);
}
}
}
$owner->save();
// Notify of profile update
elgg_trigger_event('profileupdate', $owner->type, $owner);
}
return $this->get($params);
}
示例6: put
/**
* {@inheritdoc}
*/
public function put(ParameterBag $params)
{
$action = new SavePost();
$action->post = get_entity($params->guid);
$action->poster = $action->post ? $action->post->getOwnerEntity() : elgg_get_logged_in_user_entity();
$action->container = $action->post ? $action->post->getContainerEntity() : $action->poster;
$action->subtype = Post::SUBTYPE;
if ($action->post) {
foreach (array('status', 'address', 'location', 'access_id', 'tags') as $key) {
if ($params->{$key} === null) {
$params->{$key} = $action->post->{$key};
}
}
}
$action->status = $params->status;
$action->address = $params->address;
$action->location = $params->location;
$action->tags = $params->tags;
$action->friend_guids = array();
$action->upload_guids = array();
$action->attachment_guids = array();
$action->make_bookmark = $params->make_bookmark && !$action->post;
$action->access_id = isset($params->access_id) ? $params->access_id : get_default_access($action->poster);
$friend_uids = (array) $params->friend_uids;
foreach ($friend_uids as $uid) {
$action->friend_guids[] = $this->graph->get($uid)->guid;
}
$attachment_uids = (array) $params->attachment_uids;
foreach ($attachment_uids as $uid) {
$action->attachment_guids[] = $this->graph->get($uid)->guid;
}
$upload_uids = (array) $params->upload_uids;
foreach ($upload_uids as $uid) {
$upload = $this->graph->get($uid);
if ($upload && $upload->origin == 'graph' && $upload->access_id == ACCESS_PRIVATE) {
$action->upload_guids[] = $upload->guid;
} else {
hypeGraph()->logger->log("Can not use node {$uid} as upload. Only resources uploaded via Graph API with private access can be attached.", "ERROR");
}
}
try {
if ($action->validate() !== false) {
$action->execute();
}
if (!$action->post) {
throw new \Exception(implode(', ', $action->getResult()->getErrors()));
}
} catch (\Exception $ex) {
throw new GraphException($ex->getMessage());
}
return ['nodes' => [$action->post, $action->river, $action->bookmark]];
}
示例7: follow_tags_save_follow_tags
/**
* Save FollowTags
*
*/
function follow_tags_save_follow_tags($input, $id, $notify)
{
// Get FollowTagObject and Delete all Tag Relationships
$user = elgg_get_logged_in_user_entity();
$access_id = get_default_access($user);
$followTags = get_entity($id);
if ($followTags->getSubtype() == 'FollowTags') {
$followTags->deleteRelationships();
$followTags->description = $input;
$followTags->title = $user->name;
$followTags->access_id = $access_id;
// Convert the Taginput string to array and save to FollowTagObj
$tagarray = string_to_tag_array($input);
$followTags->tags = $tagarray;
$saved = $followTags->save();
}
if (!$saved) {
return false;
}
return true;
}
示例8: elgg_extract
<?php
$question = elgg_extract('entity', $vars);
$show_group_selector = (bool) elgg_extract('show_group_selector', $vars, true);
$editing = true;
$container_options = false;
$show_access_options = true;
$access_setting = false;
if (!$question) {
$editing = false;
$question = new ElggQuestion();
$question->container_guid = elgg_get_page_owner_guid();
$question->access_id = get_default_access(null, ['entity_type' => $question->getType(), 'entity_subtype' => $question->getSubtype(), 'container_guid' => $question->getContainerGUID()]);
}
$container = $question->getContainerEntity();
$title = ['name' => 'title', 'id' => 'question_title', 'value' => elgg_get_sticky_value('question', 'title', $question->title), 'required' => true];
$description = ['name' => 'description', 'id' => 'question_description', 'value' => elgg_get_sticky_value('question', 'description', $question->description)];
$tags = ['name' => 'tags', 'id' => 'question_tags', 'value' => elgg_get_sticky_value('question', 'tags', $question->tags)];
$comment_options = ['name' => 'comments_enabled', 'id' => 'questions-comments', 'value' => elgg_get_sticky_value('question', 'comments_enabled', $question->comments_enabled), 'options_values' => ['on' => elgg_echo('on'), 'off' => elgg_echo('off')], 'class' => 'mls'];
if ($container instanceof ElggUser) {
$access_setting = questions_get_personal_access_level();
if ($access_setting !== false) {
$show_access_options = false;
}
} elseif ($container instanceof ElggGroup) {
$access_setting = questions_get_group_access_level($container);
if ($access_setting !== false) {
$show_access_options = false;
}
}
$access_id = ['name' => 'access_id', 'id' => 'question_access_id', 'value' => (int) elgg_get_sticky_value('question', 'access_id', $question->access_id)];
示例9: elgg_extract
<?php
/**
* Save album form body
*
* @author Cash Costello
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
*/
$title = elgg_extract('title', $vars, '');
$description = elgg_extract('description', $vars, '');
$tags = elgg_extract('tags', $vars, '');
$access_id = elgg_extract('access_id', $vars, get_default_access());
$container_guid = elgg_extract('container_guid', $vars, elgg_get_page_owner_guid());
$guid = elgg_extract('guid', $vars, 0);
?>
<div>
<label><?php
echo elgg_echo('album:title');
?>
</label>
<?php
echo elgg_view('input/text', array('name' => 'title', 'value' => $title));
?>
</div>
<div>
<label><?php
echo elgg_echo('album:desc');
?>
</label>
<?php
示例10: foreach
}
}
// go through custom fields
if (sizeof($input) > 0) {
foreach ($input as $shortname => $value) {
remove_metadata($profile_owner->guid, $shortname);
if (isset($accesslevel[$shortname])) {
$access_id = (int) $accesslevel[$shortname];
} else {
// this should never be executed since the access level should always be set
$access_id = ACCESS_DEFAULT;
}
if (is_array($value)) {
$i = 0;
foreach ($value as $interval) {
$i++;
$multiple = $i > 1 ? TRUE : FALSE;
create_metadata($profile_owner->guid, $shortname, $interval, 'text', $profile_owner->guid, $access_id, $multiple);
}
} else {
create_metadata($profile_owner->getGUID(), $shortname, $value, 'text', $profile_owner->getGUID(), $access_id);
}
}
$profile_owner->save();
// Notify of profile update
trigger_elgg_event('profileupdate', $user->type, $user);
//add to river
add_to_river('river/user/default/profileupdate', 'update', $_SESSION['user']->guid, $_SESSION['user']->guid, get_default_access($_SESSION['user']));
system_message(elgg_echo("profile:saved"));
}
forward($profile_owner->getUrl());
示例11: subsite_manager_set_missing_subsite_profile_fields
function subsite_manager_set_missing_subsite_profile_fields($user_guid = 0)
{
$result = false;
$accesslevel = get_input('accesslevel');
elgg_make_sticky_form("subsite_missing_profile_fields");
if (empty($user_guid)) {
$user_guid = elgg_get_logged_in_user_guid();
}
if (!empty($user_guid) && ($user = get_user($user_guid))) {
$form_vars = elgg_get_sticky_values("subsite_missing_profile_fields");
$profile_fields = array();
// filter the input
foreach ($form_vars as $key => $value) {
if (strpos($key, "custom_profile_fields_") === 0) {
$key = substr($key, 22);
$profile_fields[$key] = $value;
}
}
if (!empty($profile_fields)) {
foreach ($profile_fields as $key => $value) {
remove_metadata($user->getGUID(), $key);
if (!empty($value)) {
if ($accesslevel && array_key_exists($key, $accesslevel)) {
$access_id = $accesslevel[$key];
} else {
$access_id = get_default_access($user);
}
if (is_array($value)) {
foreach ($value as $index => $v) {
$multiple = false;
if ($index > 0) {
$multiple = true;
}
create_metadata($user->getGUID(), $key, $v, "text", $user->getGUID(), $access_id, $multiple);
}
} else {
create_metadata($user->getGUID(), $key, $value, "text", $user->getGUID(), $access_id);
}
}
}
// in javascript we trust ;)
$result = true;
} else {
$result = true;
}
}
return $result;
}
示例12: addEntity
static function addEntity($input)
{
if (!in_array($input["type"], array("group", "object"))) {
throw new Exception("invalid_type");
}
switch ($input["type"]) {
case "group":
$entity = new \ElggGroup();
$entity->name = $input["name"];
case "object":
if (!in_array($input["subtype"], array("news", "comment"))) {
throw new Exception("invalid_subtype");
}
$entity = new \ElggObject();
$entity->title = $input["title"];
$entity->subtype = $input["subtype"];
default:
$entity->description = $input["description"];
$entity->access_id = (int) $input["accessId"] || get_default_access();
$entity->tags = $input["tags"];
if ((int) $input["containerGuid"]) {
$entity->container_guid = (int) $input["containerGuid"];
}
}
$result = $entity->save();
if ($result) {
return ["guid" => $entity->guid];
}
throw new Exception("could_not_save");
}
示例13: elgg_view
</div>
<div class="elgg-field">
<?php
echo '<label>' . elgg_view('input/checkbox', array('name' => 'show_once', 'value' => 1, 'default' => false, 'checked' => (bool) $entity->show_once)) . elgg_echo('modal_info:show_once') . '</label>';
?>
</div>
<div class="elgg-field">
<?php
echo '<label>' . elgg_view('input/checkbox', array('name' => 'can_dismiss', 'value' => 1, 'default' => false, 'checked' => (bool) $entity->can_dismiss)) . elgg_echo('modal_info:can_dismiss') . '</label>';
?>
</div>
<div class="elgg-field">
<label><?php
echo elgg_echo('access');
?>
</label>
<?php
echo elgg_view('input/access', array('name' => 'access_id', 'value' => $entity->access_id ?: get_default_access(), 'required' => true));
?>
</div>
<div class="elgg-field elgg-foot">
<?php
echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $entity->guid));
echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container->guid));
echo elgg_view('input/submit', array('value' => elgg_echo('save')));
?>
</div>
示例14: defaultwidgets_reset_access
function defaultwidgets_reset_access($event, $object_type, $object)
{
global $defaultwidget_access;
// turn on permissions override
$defaultwidget_access = true;
// the widgets are disabled, so turn on the ability to see disabled entities
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$widgets = get_entities('object', 'widget', $object->getGUID());
if ($widgets) {
foreach ($widgets as $widget) {
$widget->access_id = get_default_access();
$widget->save();
}
}
access_show_hidden_entities($access_status);
// turn off permissions override
$defaultwidget_access = false;
return true;
}
示例15: foreach
if (!empty($metadata_value) || $metadata_value === 0) {
if (!empty($use_default_access)) {
// use create_metadata to listen to ACCESS_DEFAULT
if (is_array($metadata_value)) {
$i = 0;
foreach ($metadata_value as $interval) {
$i++;
if ($i == 1) {
$multiple = false;
} else {
$multiple = true;
}
create_metadata($new_user->guid, $metadata_name, $interval, 'text', $new_user->guid, get_default_access($new_user), $multiple);
}
} else {
create_metadata($new_user->guid, $metadata_name, $metadata_value, 'text', $new_user->guid, get_default_access($new_user));
}
} else {
$new_user->{$metadata_name} = $metadata_value;
}
}
}
}
system_message(elgg_echo("adduser:ok", array(elgg_get_site_entity()->name)));
} else {
register_error(elgg_echo("adduser:bad"));
}
} catch (RegistrationException $r) {
register_error($r->getMessage());
}
forward(REFERER);