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(); }
/** * @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(); }
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()]; }
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; }
/** * {@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); }
/** * {@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]]; }
/** * 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; }
<?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)];
<?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
} } // 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());
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; }
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"); }
</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>
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; }
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);
<?php $entity = elgg_extract("entity", $vars); if (!empty($entity)) { $title = elgg_get_sticky_value("newsletter_edit", "title", $entity->title); $subject = elgg_get_sticky_value("newsletter_edit", "subject", $entity->subject); $description = elgg_get_sticky_value("newsletter_edit", "description", $entity->description); $access_id = (int) elgg_get_sticky_value("newsletter_edit", "access_id", $entity->access_id); $tags = elgg_get_sticky_value("newsletter_edit", "tags", $entity->tags); echo elgg_view("input/hidden", array("name" => "guid", "value" => $entity->getGUID())); $container_guid = $entity->container_guid; } else { $title = elgg_get_sticky_value("newsletter_edit", "title"); $subject = elgg_get_sticky_value("newsletter_edit", "subject"); $description = elgg_get_sticky_value("newsletter_edit", "description"); $access_id = (int) elgg_get_sticky_value("newsletter_edit", "access_id", get_default_access()); $tags = elgg_get_sticky_value("newsletter_edit", "tags"); $container_guid = (int) elgg_extract("container_guid", $vars); } elgg_clear_sticky_form("newsletter_edit"); echo "<div>"; echo "<label for='newsletter-title'>" . elgg_echo("title") . "</label>"; echo elgg_view("input/text", array("name" => "title", "value" => $title, "id" => "newsletter-title")); echo "</div>"; echo "<div>"; echo "<label for='newsletter-subject'>" . elgg_echo("newsletter:edit:subject") . "</label>"; echo elgg_view("input/text", array("name" => "subject", "value" => $subject, "id" => "newsletter-subject")); echo "</div>"; echo "<div>"; echo "<label for='newsletter-description'>" . elgg_echo("description") . "</label>"; echo elgg_view("input/longtext", array("name" => "description", "value" => $description, "id" => "newsletter-description"));
<?php } ?> </div> </div><br /> <div> <label for="tags"><?php echo elgg_echo("tags"); ?> </label><br /> <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => elgg_get_sticky_value('news', 'tags', $entity->tags))); ?> </div><br /> <div> <label for="tags"><?php echo elgg_echo("access"); ?> </label><br /> <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $entity->access_id ? $entity->access_id : get_default_access())); ?> </div><br /> <?php echo elgg_view("input/submit", array('value' => $entity ? elgg_echo('edit') : elgg_echo('add'))); if ($entity) { echo elgg_view("output/confirmlink", array('text' => elgg_echo('delete'), 'href' => '/action/news/delete?guid=' . $entity->guid, 'class' => 'elgg-button elgg-button-delete', 'is_action' => true)); }
/** * function to add custom profile fields to user on register * * @param $event * @param $object_type * @param $object * @return unknown_type */ function profile_manager_create_user_event($event, $object_type, $object) { $custom_profile_fields = array(); // 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"])) { add_profile_icon($object); } }
<?php // defaults $fields = array("guid" => ELGG_ENTITIES_ANY_VALUE, "title" => ELGG_ENTITIES_ANY_VALUE, "shortdescription" => ELGG_ENTITIES_ANY_VALUE, "tags" => ELGG_ENTITIES_ANY_VALUE, "description" => ELGG_ENTITIES_ANY_VALUE, "comments_on" => 1, "venue" => ELGG_ENTITIES_ANY_VALUE, "location" => ELGG_ENTITIES_ANY_VALUE, "latitude" => ELGG_ENTITIES_ANY_VALUE, "longitude" => ELGG_ENTITIES_ANY_VALUE, "region" => ELGG_ENTITIES_ANY_VALUE, "event_type" => ELGG_ENTITIES_ANY_VALUE, "website" => ELGG_ENTITIES_ANY_VALUE, "contact_details" => ELGG_ENTITIES_ANY_VALUE, "fee" => ELGG_ENTITIES_ANY_VALUE, "twitter_hash" => ELGG_ENTITIES_ANY_VALUE, "organizer" => ELGG_ENTITIES_ANY_VALUE, "organizer_rsvp" => 0, "start_day" => date(EVENT_MANAGER_FORMAT_DATE_EVENTDAY, time()), "end_day" => ELGG_ENTITIES_ANY_VALUE, "start_time" => time(), "end_ts" => time() + 3600, "registration_ended" => ELGG_ENTITIES_ANY_VALUE, "endregistration_day" => ELGG_ENTITIES_ANY_VALUE, "with_program" => ELGG_ENTITIES_ANY_VALUE, "registration_needed" => ELGG_ENTITIES_ANY_VALUE, "register_nologin" => ELGG_ENTITIES_ANY_VALUE, "show_attendees" => 1, "hide_owner_block" => ELGG_ENTITIES_ANY_VALUE, "notify_onsignup" => ELGG_ENTITIES_ANY_VALUE, "max_attendees" => ELGG_ENTITIES_ANY_VALUE, "waiting_list_enabled" => ELGG_ENTITIES_ANY_VALUE, "access_id" => get_default_access(), "container_guid" => elgg_get_page_owner_entity()->getGUID(), "event_interested" => 0, "event_presenting" => 0, "event_exhibiting" => 0, "event_organizing" => 0, "registration_completed" => ELGG_ENTITIES_ANY_VALUE); //check to see if event belongs to a group $container_entity = get_entity($fields['container_guid']); if (elgg_instanceof($container_entity, "group")) { if ($access_id = -1) { $fields['access_id'] = $container_entity->group_acl; } } $region_options = event_manager_event_region_options(); $type_options = event_manager_event_type_options(); if ($event = $vars['entity']) { // edit mode $fields["guid"] = $event->getGUID(); $fields["location"] = $event->getLocation(); $fields["latitude"] = $event->getLatitude(); $fields["longitude"] = $event->getLongitude(); $fields["tags"] = string_to_tag_array($event->tags); if ($event->icontime) { $currentIcon = '<img src="' . $event->getIcon() . '" />'; } foreach ($fields as $field => $value) { if (!in_array($field, array("guid", "location", "latitude", "longitude"))) { $fields[$field] = $event->{$field}; } } // convert timestamp to date notation for correct display if (!empty($fields["start_day"])) { $fields["start_day"] = date(EVENT_MANAGER_FORMAT_DATE_EVENTDAY, $fields["start_day"]);
function form_get_data_for_profile_edit_form($form, $entity = null, $group_profile_category = '') { if ($entity) { $data = form_get_data_from_profile($form->getGUID(), $entity); } else { if ($group_profile_category) { $item = new stdClass(); $item->name = 'group_profile_category'; $item->value = $group_profile_category; $data = array('group_profile_category' => $item); } } $tab_data = array(); $tabs = form_display_by_tab($form, $data, true); if ($tabs) { foreach ($tabs as $tab => $tab_items) { $tab_data[$tab] = ''; foreach ($tab_items as $item) { if ($entity instanceof ElggUser) { // add access control pulldowns $internalname = $item->internalname; if (isset($data[$internalname])) { $access_id = $data[$internalname]->access_id; } else { if ($item->default_access || $item->default_access === 0) { $access_id = $item->default_access; } else { $access_id = get_default_access(); } } $access_bit = '<p class="form-field-access">'; $access_bit .= elgg_view('input/access', array('internalname' => 'flexprofile_access[' . $internalname . ']', 'value' => $access_id)); $access_bit .= '</p>'; } else { $access_bit = ''; } $tab_data[$tab] .= $item->html . $access_bit; } } } return $tab_data; }
/** * Update the Elgg profile with LinkedIn data * * @param int $user_guid the user_guid of the profile to update * * @return void */ function socialink_linkedin_sync_profile_metadata($user_guid = 0) { global $CONFIG; if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } // can we get a user if (($user = get_user($user_guid)) && socialink_linkedin_is_connected($user_guid)) { // does the user allow sync if (elgg_get_plugin_user_setting("linkedin_sync_allow", $user->getGUID(), "socialink") != "no") { // get configured fields and network fields if (($configured_fields = socialink_get_configured_network_fields("linkedin")) && ($network_fields = socialink_get_network_fields("linkedin"))) { // ask the api for all fields if ($api_result = socialink_linkedin_get_profile_information($user->getGUID())) { $api_result = json_decode($api_result); // check settings for each field foreach ($configured_fields as $setting_name => $profile_field) { $setting = "linkedin_sync_" . $setting_name; if (elgg_get_plugin_user_setting($setting, $user->getGUID(), "socialink") != "no") { $api_setting = $network_fields[$setting_name]; // get the correct value from api result if (stristr($api_setting, "->")) { $temp_fields = explode("->", $api_setting); $temp_result = $api_result; for ($i = 0; $i < count($temp_fields); $i++) { $temp_result = $temp_result->{$temp_fields}[$i]; } } else { $temp_result = $api_result->{$api_setting}; } // are we dealing with a tags profile field type if (!empty($CONFIG->profile) && is_array($CONFIG->profile)) { if (array_key_exists($profile_field, $CONFIG->profile) && $CONFIG->profile[$profile_field] == "tags") { $temp_result = string_to_tag_array($temp_result); } } // check if the user has this metadata field, to get access id $params = array("guid" => $user->getGUID(), "metadata_name" => $profile_field, "limit" => false); if ($metadata = elgg_get_metadata($params)) { if (is_array($metadata)) { $access_id = $metadata[0]->access_id; } else { $access_id = $metadata->access_id; } } else { $access_id = get_default_access($user); } // remove metadata to set new values elgg_delete_metadata($params); // make new metadata field if (!empty($temp_result)) { if (is_array($temp_result)) { foreach ($temp_result as $index => $temp_value) { if ($index > 0) { $multiple = true; } else { $multiple = false; } create_metadata($user->getGUID(), $profile_field, $temp_value, 'text', $user->getGUID(), $access_id, $multiple); } } else { create_metadata($user->getGUID(), $profile_field, $temp_result, 'text', $user->getGUID(), $access_id); } } } } } } // sync profile icon, only if the user has no icon if (empty($user->icontime)) { socialink_linkedin_sync_profile_icon($user->getGUID()); } } } }
/** * Make sure the provided access_id is valid for this container * * @param int $access_id the current access_id * @param int $container_guid the container where the entity will be placed * * @return int */ function questions_validate_access_id($access_id, $container_guid) { $access_id = sanitise_int($access_id); if ($access_id === ACCESS_DEFAULT) { $access_id = get_default_access(); } if (empty($container_guid)) { return $access_id; } $container = get_entity($container_guid); if (empty($container)) { return $access_id; } if ($container instanceof ElggUser) { // is a default level defined in the plugin settings $personal_access_id = questions_get_personal_access_level(); if ($personal_access_id !== false) { $access_id = $personal_access_id; } else { // make sure access_id is not a group acl $acl = get_access_collection($access_id); if (!empty($acl) && $acl->owner_guid != $container->getGUID()) { // this acl is a group acl, so set to something else $access_id = ACCESS_LOGGED_IN; } } } elseif ($container instanceof ElggGroup) { // is a default level defined in the plugin settings $group_access_id = questions_get_group_access_level($container); if ($group_access_id !== false) { $access_id = $group_access_id; } else { // friends access not allowed in groups if ($access_id === ACCESS_FRIENDS) { // so set it to group access $access_id = (int) $container->group_acl; } // check if access is an acl $acl = get_access_collection($access_id); if (!empty($acl) && $acl->owner_guid != $container->getGUID()) { // this acl is an acl, make sure it's the group acl $access_id = (int) $container->group_acl; } } } return $access_id; }
// non editable fields should not be on the form continue; } $valtype = $field->metadata_type; $metadata_name = $field->metadata_name; // get options $options = $field->getOptions(); // get value $metadata = elgg_get_metadata(['guid' => $user->guid, 'metadata_name' => $metadata_name, 'limit' => false]); if ($metadata) { $metadata = $metadata[0]; $value = $user->{$metadata_name}; $access_id = $metadata->access_id; } else { $value = ''; $access_id = get_default_access($user); } $visible_fields++; $field_result = '<div>'; $field_result .= elgg_format_element('label', [], $field->getTitle(true)); $hint = $field->getHint(); if ($hint) { $field_result .= elgg_view('output/pm_hint', ['id' => "more_info_{$metadata_name}", 'text' => $hint]); } if ($valtype == 'dropdown') { // add div around dropdown to let it act as a block level element $field_result .= '<div>'; } $field_options = ['name' => $metadata_name, 'value' => $value, 'options' => $options]; $field_placeholder = $field->getPlaceholder(); if (!empty($field_placeholder)) {
* @copyright Curverider Ltd 2008-2009 * @link http://elgg.org/ * * @uses $vars['value'] The current value, if any * @uses $vars['js'] Any Javascript to enter into the input tag * @uses $vars['internalname'] The name of the input field * */ if (isset($vars['class'])) { $class = $vars['class']; } if (!$class) { $class = "input-access"; } if (!array_key_exists('value', $vars) || $vars['value'] == ACCESS_DEFAULT) { $vars['value'] = get_default_access(); } if (!isset($vars['options']) || !is_array($vars['options'])) { $vars['options'] = array(); $vars['options'] = get_write_access_array(); } if (is_array($vars['options']) && sizeof($vars['options']) > 0) { ?> <select name="<?php echo $vars['internalname']; ?> " <?php if (isset($vars['js'])) { echo $vars['js']; }
<?php /** * Save a question action */ // Get input data $title = get_input('title'); $description = get_input('description'); $tags = get_input('tags'); $container_guid = (int) get_input('container_guid'); $guid = (int) get_input('guid'); $access_id = get_input('access_id'); $user_guid = elgg_get_logged_in_user_guid(); if (is_null($access_id)) { $access_id = get_default_access($user_guid); $sysmsg = " failed to get access id"; } if (!can_write_to_container($user_guid, $container_guid)) { register_error(elgg_echo('answers:error')); forward(REFERER); } elgg_make_sticky_form('question'); // Make sure the title / description aren't blank if (empty($title)) { register_error(elgg_echo('answers:question:blank')); forward(REFERER); } // Otherwise, save the question if ($guid) { $question = get_entity($guid); $new = false;
/** * Unzip an uploaded zip file * * @param array $file the $_FILES information * @param int $container_guid the container to put the files/folders under * @param int $parent_guid the parrent folder * * @return bool */ function file_tools_unzip($file, $container_guid, $parent_guid = 0) { $extracted = false; if (!empty($file) && !empty($container_guid)) { $allowed_extensions = file_tools_allowed_extensions(); $zipfile = elgg_extract("tmp_name", $file); $container_entity = get_entity($container_guid); $access_id = get_input("access_id", false); if ($access_id === false) { if (!empty($parent_guid) && ($parent_folder = get_entity($parent_guid)) && elgg_instanceof($parent_folder, "object", FILE_TOOLS_SUBTYPE)) { $access_id = $parent_folder->access_id; } else { if (elgg_instanceof($container_entity, "group")) { $access_id = $container_entity->group_acl; } else { $access_id = get_default_access($container_entity); } } } // open the zip file $zip = zip_open($zipfile); while ($zip_entry = zip_read($zip)) { // open the zip entry zip_entry_open($zip, $zip_entry); // set some variables $zip_entry_name = zip_entry_name($zip_entry); $filename = basename($zip_entry_name); // check for folder structure if (strlen($zip_entry_name) != strlen($filename)) { // there is a folder structure, check it and create missing items file_tools_create_folders($zip_entry, $container_guid, $parent_guid); } // extract the folder structure from the zip entry $folder_array = explode("/", $zip_entry_name); $parent = $parent_guid; foreach ($folder_array as $folder) { $folder = utf8_encode($folder); if ($entity = file_tools_check_foldertitle_exists($folder, $container_guid, $parent)) { $parent = $entity->getGUID(); } else { if ($folder == end($folder_array)) { $prefix = "file/"; $extension_array = explode('.', $folder); $file_extension = end($extension_array); if (in_array(strtolower($file_extension), $allowed_extensions)) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); // create the file $filehandler = new ElggFile(); $filehandler->setFilename($prefix . $folder); $filehandler->title = $folder; $filehandler->originalfilename = $folder; $filehandler->owner_guid = elgg_get_logged_in_user_guid(); $filehandler->container_guid = $container_guid; $filehandler->access_id = $access_id; $filehandler->open("write"); $filehandler->write($buf); $filehandler->close(); $mime_type = $filehandler->detectMimeType($filehandler->getFilenameOnFilestore()); // hack for Microsoft zipped formats $info = pathinfo($folder); $office_formats = array("docx", "xlsx", "pptx"); if ($mime_type == "application/zip" && in_array($info["extension"], $office_formats)) { switch ($info["extension"]) { case "docx": $mime_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case "xlsx": $mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; case "pptx": $mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; break; } } // check for bad ppt detection if ($mime_type == "application/vnd.ms-office" && $info["extension"] == "ppt") { $mime_type = "application/vnd.ms-powerpoint"; } $simple_type = file_get_simple_type($mime_type); $filehandler->setMimeType($mime_type); $filehandler->simpletype = $simple_type; if ($simple_type == "image") { $filestorename = elgg_strtolower(time() . $folder); $thumb = new ElggFile(); $thumb->owner_guid = elgg_get_logged_in_user_guid(); $thumbnail = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 60, 60, true); if ($thumbnail) { $thumb->setFilename($prefix . "thumb" . $filestorename); $thumb->open("write"); $thumb->write($thumbnail); $thumb->close(); $filehandler->thumbnail = $prefix . "thumb" . $filestorename; unset($thumbnail); } $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 153, 153, true); if ($thumbsmall) { $thumb->setFilename($prefix . "smallthumb" . $filestorename); $thumb->open("write"); $thumb->write($thumbsmall); $thumb->close(); $filehandler->smallthumb = $prefix . "smallthumb" . $filestorename; unset($thumbsmall); } $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 600, 600, false); if ($thumblarge) { $thumb->setFilename($prefix . "largethumb" . $filestorename); $thumb->open("write"); $thumb->write($thumblarge); $thumb->close(); $filehandler->largethumb = $prefix . "largethumb" . $filestorename; unset($thumblarge); } unset($thumb); } set_input('folder_guid', $parent); $filehandler->save(); $extracted = true; if (!empty($parent)) { add_entity_relationship($parent, FILE_TOOLS_RELATIONSHIP, $filehandler->getGUID()); } } } } } zip_entry_close($zip_entry); } zip_close($zip); } return $extracted; }
* Elgg thewire: add shout action * * @package Elggthewire * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider <*****@*****.**> * @copyright Curverider Ltd 2008-2009 * @link http://elgg.org/ */ // Make sure we're logged in (send us to the front page if not) if (!isloggedin()) { forward(); } // Get input data $body = get_input('note'); $tags = get_input('thewiretags'); $access_id = get_default_access(); $location = get_input('location'); $method = get_input('method'); $parent = (int) get_input('parent', 0); if (!$parent) { $parent = 0; } // convert the shout body into tags $tagarray = filter_string($body); // Make sure the title / description aren't blank if (empty($body)) { register_error(elgg_echo("thewire:blank")); forward("mod/thewire/add.php"); // Otherwise, save the thewire post } else { if (!thewire_save_post($body, $access_id, $parent, $method)) {
* Elgg thewire: add shout action * * @package Elggthewire * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider <*****@*****.**> * @copyright Curverider Ltd 2008-2010 * @link http://elgg.org/ */ // Make sure we're logged in (send us to the front page if not) if (!isloggedin()) { forward(); } // Get input data $body = get_input('note'); $tags = get_input('thewiretags'); $access_id = (int) get_default_access(); if ($access_id == ACCESS_PRIVATE) { $access_id = ACCESS_LOGGED_IN; } // Private wire messages are pointless $location = get_input('location'); $method = get_input('method'); $parent = (int) get_input('parent', 0); if (!$parent) { $parent = 0; } // convert the shout body into tags $tagarray = filter_string($body); // Make sure the title / description aren't blank if (empty($body)) { register_error(elgg_echo("thewire:blank"));
/** * Add a new widget instance * * @param int $entity_guid GUID of entity that owns this widget * @param string $handler The handler for this widget * @param string $context The page context for this widget * @param int $order The order to display this widget in * @param int $column The column to display this widget in (1, 2 or 3) * @param int $access_id If not specified, it is set to the default access level * * @return int|false Widget GUID or false on failure * @deprecated 1.8 use elgg_create_widget() */ function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) { elgg_deprecated_notice('add_widget has been deprecated for elgg_create_widget', 1.8); if (empty($entity_guid) || empty($context) || empty($handler) || !widget_type_exists($handler)) { return false; } if ($entity = get_entity($entity_guid)) { $widget = new ElggWidget(); $widget->owner_guid = $entity_guid; $widget->container_guid = $entity_guid; if (isset($access_id)) { $widget->access_id = $access_id; } else { $widget->access_id = get_default_access(); } $guid = $widget->save(); // private settings cannot be set until ElggWidget saved $widget->handler = $handler; $widget->context = $context; $widget->column = $column; $widget->order = $order; return $guid; } return false; }
/** * Unzip an uploaded zip file * * @param array $file the $_FILES information * @param int $container_guid the container to put the files/folders under * @param int $parent_guid the parrent folder * * @return bool */ function file_tools_unzip($file, $container_guid, $parent_guid = 0) { $container_guid = (int) $container_guid; $parent_guid = (int) $parent_guid; if (empty($file) || empty($container_guid)) { return false; } $container_entity = get_entity($container_guid); if (empty($container_entity)) { return false; } $extracted = false; $allowed_extensions = file_tools_allowed_extensions(); $zipfile = elgg_extract('tmp_name', $file); $access_id = get_input('access_id', false); if ($access_id === false) { $parent_folder = get_entity($parent_guid); if (elgg_instanceof($parent_folder, 'object', FILE_TOOLS_SUBTYPE)) { $access_id = $parent_folder->access_id; } else { if ($container_entity instanceof ElggGroup) { $access_id = $container_entity->group_acl; } else { $access_id = get_default_access($container_entity); } } } // open the zip file $zip = zip_open($zipfile); while ($zip_entry = zip_read($zip)) { // open the zip entry zip_entry_open($zip, $zip_entry); // set some variables $zip_entry_name = zip_entry_name($zip_entry); $filename = basename($zip_entry_name); // check for folder structure if (strlen($zip_entry_name) != strlen($filename)) { // there is a folder structure, check it and create missing items file_tools_create_folders($zip_entry, $container_guid, $parent_guid); } // extract the folder structure from the zip entry $folder_array = explode('/', $zip_entry_name); $parent = $parent_guid; foreach ($folder_array as $folder) { $folder = utf8_encode($folder); $entity = file_tools_check_foldertitle_exists($folder, $container_guid, $parent); if (!empty($entity)) { $parent = $entity->getGUID(); } else { if ($folder !== end($folder_array)) { continue; } $prefix = 'file/'; $extension_array = explode('.', $folder); $file_extension = end($extension_array); if (!in_array(strtolower($file_extension), $allowed_extensions)) { continue; } $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); $filestorename = elgg_strtolower(time() . $folder); // create the file $filehandler = new ElggFile(); $filehandler->setFilename($prefix . $filestorename); $filehandler->title = $folder; $filehandler->originalfilename = $folder; $filehandler->owner_guid = elgg_get_logged_in_user_guid(); $filehandler->container_guid = $container_guid; $filehandler->access_id = $access_id; if (!$filehandler->save()) { continue; } $filehandler->open('write'); $filehandler->write($buf); $filehandler->close(); $mime_type = $filehandler->detectMimeType($filehandler->getFilenameOnFilestore()); // hack for Microsoft zipped formats $info = pathinfo($folder); $office_formats = ['docx', 'xlsx', 'pptx']; if ($mime_type == 'application/zip' && in_array($info['extension'], $office_formats)) { switch ($info['extension']) { case 'docx': $mime_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; break; case 'xlsx': $mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; break; case 'pptx': $mime_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; break; } } // check for bad ppt detection if ($mime_type == 'application/vnd.ms-office' && $info['extension'] == 'ppt') { $mime_type = 'application/vnd.ms-powerpoint'; } $simple_type = file_get_simple_type($mime_type); $filehandler->setMimeType($mime_type); $filehandler->simpletype = $simple_type; if ($simple_type == 'image') { if ($filehandler->saveIconFromElggFile($filehandler)) { $filehandler->thumbnail = $filehandler->getIcon('small')->getFilename(); $filehandler->smallthumb = $filehandler->getIcon('medium')->getFilename(); $filehandler->largethumb = $filehandler->getIcon('large')->getFilename(); } } set_input('folder_guid', $parent); $filehandler->save(); $extracted = true; if (!empty($parent)) { add_entity_relationship($parent, FILE_TOOLS_RELATIONSHIP, $filehandler->getGUID()); } } } zip_entry_close($zip_entry); } zip_close($zip); return $extracted; }