/** * Dispatches odt_editor pages. * URLs take the form of * Save as: odt_editor/saveas/<guid> * * @param array $page * @return bool */ function odt_editor_page_handler($page) { $odt_editor_pages_dir = elgg_get_plugins_path() . 'odt_editor/pages'; $page_type = $page[0]; switch ($page_type) { case 'saveas': set_input('guid', $page[1]); include "{$odt_editor_pages_dir}/odt_editor/saveas.php"; break; case 'create': $container = get_entity($page[1]); if (!$container) { $container = get_loggedin_userid(); } // show new document in WebODF editor page // 0 as indicator for new document set_input('guid', 0); set_input('container_guid', $page[1]); include "{$odt_editor_pages_dir}/file/odt_editor.php"; $result = false; break; case 'gettemplate': include "{$odt_editor_pages_dir}/odt_editor/gettemplate.php"; break; default: return false; } return true; }
/** * Returns HTML for a blog post. * * @param int $guid of a blog entity. * @return string html */ function blog_get_page_content_read($owner_guid = NULL, $guid = NULL) { $content = elgg_view('page_elements/content_header', array('context' => $context, 'type' => 'blog')); if ($guid) { $blog = get_entity($guid); if (!elgg_instanceof($blog, 'object', 'blog') && $blog->status == 'final') { $content .= elgg_echo('blog:error:post_not_found'); } else { elgg_push_breadcrumb($blog->title, $blog->getURL()); $content .= elgg_view_entity($blog, TRUE); } } else { $options = array('type' => 'object', 'subtype' => 'blog', 'full_view' => FALSE, 'order_by_metadata' => array('name' => 'publish_date', 'direction' => 'DESC', 'as' => 'int')); if ($owner_guid) { $options['owner_guid'] = $owner_guid; } // show all posts for admin or users looking at their own blogs // show only published posts for other users. if (!(isadminloggedin() || isloggedin() && $owner_guid == get_loggedin_userid())) { $options['metadata_name_value_pairs'] = array(array('name' => 'status', 'value' => 'published'), array('name' => 'publish_date', 'operand' => '<', 'value' => time())); } $content .= elgg_list_entities_from_metadata($options); } return array('content' => $content); }
function getUnreadMessages() { $userId = get_loggedin_userid(); $limit = 5; // Get the user's inbox, this will be all messages where the 'toId' field matches their guid $messages = get_entities_from_metadata_multi(array("toId" => $userId, "readYet" => 0), "object", "messages", $userId, $limit, 0); return $messages; }
/** * Tests the protected attributes */ public function testElggEntityAttributes() { $test_attributes = array(); $test_attributes['guid'] = ''; $test_attributes['type'] = ''; $test_attributes['subtype'] = ''; $test_attributes['owner_guid'] = get_loggedin_userid(); $test_attributes['container_guid'] = get_loggedin_userid(); $test_attributes['site_guid'] = 0; $test_attributes['access_id'] = ACCESS_PRIVATE; $test_attributes['time_created'] = ''; $test_attributes['time_updated'] = ''; $test_attributes['enabled'] = 'yes'; $test_attributes['tables_split'] = 1; $test_attributes['tables_loaded'] = 0; $this->assertIdentical($this->entity->expose_attributes(), $test_attributes); }
function groups_from_members_submenus() { global $CONFIG; $page_owner = page_owner_entity(); // Submenu items for all group pages if ($page_owner instanceof ElggGroup && get_context() == 'groups' && get_loggedin_userid() != $page_owner->getOwner()) { if (isloggedin() && !isadminloggedin()) { $context = get_context(); set_context('groupsfrommembers'); if ($page_owner->canEdit()) { add_submenu_item(elgg_echo('groups:invite'), $CONFIG->wwwroot . "mod/groupsfrommembers/invite.php?group_guid={$page_owner->getGUID()}", '1groupsactions'); if (!$page_owner->isPublicMembership()) { add_submenu_item(elgg_echo('groups:membershiprequests'), $CONFIG->wwwroot . "mod/groups/membershipreq.php?group_guid={$page_owner->getGUID()}", '1groupsactions'); } } set_context($context); } } }
/** * A basic test that will be called and fail. */ public function testElggSiteConstructor() { $attributes = array(); $attributes['guid'] = ''; $attributes['type'] = 'site'; $attributes['subtype'] = ''; $attributes['owner_guid'] = get_loggedin_userid(); $attributes['container_guid'] = get_loggedin_userid(); $attributes['site_guid'] = 0; $attributes['access_id'] = ACCESS_PRIVATE; $attributes['time_created'] = ''; $attributes['time_updated'] = ''; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; $attributes['name'] = ''; $attributes['description'] = ''; $attributes['url'] = ''; $this->assertIdentical($this->site->expose_attributes(), $attributes); }
<?php /** * Join a group action. * * @package ElggGroups * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd * @copyright Curverider Ltd 2008-2009 * @link http://elgg.com/ */ // Load configuration global $CONFIG; gatekeeper(); $user_guid = get_input('user_guid', get_loggedin_userid()); $group_guid = get_input('group_guid'); $user = get_entity($user_guid); $group = get_entity($group_guid); if ($user instanceof ElggUser && $group instanceof ElggGroup) { if ($group->isPublicMembership()) { if ($group->join($user)) { system_message(elgg_echo("groups:joined")); // Remove any invite or join request flags remove_entity_relationship($group->guid, 'invited', $user->guid); remove_entity_relationship($user->guid, 'membership_request', $group->guid); // add to river add_to_river('river/group/create', 'join', $user->guid, $group->guid); forward($group->getURL()); exit; } else { register_error(elgg_echo("groups:cantjoin"));
* @link http://elgg.com/ */ // Load configuration global $CONFIG; gatekeeper(); $user_guid = get_input('user_guid'); if (!is_array($user_guid)) { $user_guid = array($user_guid); } $dgroup_guid = get_input('dgroup_guid'); if (sizeof($user_guid)) { foreach ($user_guid as $u_id) { $user = get_entity($u_id); $dgroup = get_entity($dgroup_guid); if ($user && $dgroup) { if (get_loggedin_userid() == $dgroup->owner_guid) { if (!check_entity_relationship($dgroup->guid, 'invited', $user->guid)) { if ($user->isFriend()) { // Create relationship add_entity_relationship($dgroup->guid, 'invited', $user->guid); // Send email if (notify_user($user->getGUID(), $dgroup->owner_guid, sprintf(elgg_echo('dgroups:invite:subject'), $user->name, $dgroup->name), sprintf(elgg_echo('dgroups:invite:body'), $user->name, $dgroup->name, "{$CONFIG->url}action/dgroups/join?user_guid={$user->guid}&dgroup_guid={$dgroup->guid}"), NULL)) { system_message(elgg_echo("dgroups:userinvited")); } else { register_error(elgg_echo("dgroups:usernotinvited")); } } else { register_error(elgg_echo("dgroups:usernotinvited")); } } else { register_error(elgg_echo("dgroups:useralreadyinvited"));
/** * setups the submenus * * @global <type> $CONFIG */ function pageSetup_izap_videos() { global $CONFIG; // get the page owner $pageowner = page_owner_entity(); // if page owner is user and context is izap_videos if ($pageowner instanceof ElggUser && get_context() == 'videos') { if ($pageowner != get_loggedin_user()) { add_submenu_item(sprintf(elgg_echo('izap_videos:user'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/list/' . $pageowner->username, 'USER_IZAPVIDEOS'); add_submenu_item(sprintf(elgg_echo('izap_videos:userfrnd'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/friends/' . $pageowner->username, 'USER_IZAPVIDEOS'); add_submenu_item(sprintf(elgg_echo('izap_videos:user_favorites'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/favorites/' . $pageowner->username, 'USER_IZAPVIDEOS'); } // for loggedin users only if (isloggedin()) { if ($pageowner instanceof ElggUser) { add_submenu_item(elgg_echo('izap_videos:add'), $CONFIG->wwwroot . 'pg/videos/add/' . get_loggedin_user()->username, 'IZAPVIDEOS'); } } } // for all if (get_context() == GLOBAL_IZAP_VIDEOS_PAGEHANDLER) { if (isloggedin()) { add_submenu_item(sprintf(elgg_echo('izap_videos:videos'), get_loggedin_user()->name), $CONFIG->wwwroot . 'pg/videos/list/' . get_loggedin_user()->username, 'MY_IZAPVIDEOS'); add_submenu_item(sprintf(elgg_echo('izap_videos:frnd'), get_loggedin_user()->name), $CONFIG->wwwroot . 'pg/videos/friends/' . get_loggedin_user()->username, 'MY_IZAPVIDEOS'); add_submenu_item(elgg_echo('izap_videos:my_favorites'), $CONFIG->wwwroot . 'pg/videos/favorites/' . get_loggedin_user()->username, 'MY_IZAPVIDEOS'); } add_submenu_item(elgg_echo('izap_videos:all'), $CONFIG->wwwroot . 'pg/videos/all', 'IZAPVIDEOS'); } // if the page owner is group and context is group if ($pageowner instanceof ElggGroup && (get_context() == 'groups' || get_context() == 'videos') && ($pageowner->izap_videos_enable == 'yes' || empty($pageowner->izap_videos_enable))) { if (can_write_to_container(get_loggedin_userid(), $pageowner->guid, 'izap_videos')) { add_submenu_item(elgg_echo('izap_videos:addgroupVideo'), $CONFIG->wwwroot . 'pg/videos/add/' . $pageowner->username, 'IZAPVIDEOS'); } add_submenu_item(sprintf(elgg_echo('izap_videos:user'), $pageowner->name), $CONFIG->wwwroot . 'pg/videos/list/' . $pageowner->username, 'IZAPVIDEOS'); } // if the context is admin and is admin logged in if (get_context() == 'admin' && isadminloggedin()) { add_submenu_item(elgg_echo('izap_videos:adminSettings'), $CONFIG->wwwroot . 'pg/videos/adminSettings/' . get_loggedin_user()->username . '?option=settings', 'IZAPADMIN'); } }
/** * Determines whether or not this user is a friend of the currently logged in user * * @return true|false */ function isFriend() { return user_is_friend(get_loggedin_userid(), $this->getGUID()); }
/** * Get the notification settings for a given user. * * @param int $user_guid The user id * @return stdClass */ function get_user_notification_settings($user_guid = 0) { $user_guid = (int) $user_guid; if ($user_guid == 0) { $user_guid = get_loggedin_userid(); } $all_metadata = get_metadata_for_entity($user_guid); if ($all_metadata) { $prefix = "notification:method:"; $return = new stdClass(); foreach ($all_metadata as $meta) { $name = substr($meta->name, strlen($prefix)); $value = $meta->value; if (strpos($meta->name, $prefix) === 0) { $return->{$name} = $value; } } return $return; } return false; }
<?php /** * Action for adding a wire post * */ // don't filter since we strip and filter escapes some characters $body = get_input('body', '', false); $access_id = ACCESS_PUBLIC; $method = 'site'; $parent_guid = (int) get_input('parent_guid'); // make sure the post isn't blank if (empty($body)) { register_error(elgg_echo("thewire:blank")); forward(REFERER); } $guid = thewire_save_post($body, get_loggedin_userid(), $access_id, $parent_guid, $method); if (!$guid) { register_error(elgg_echo("thewire:error")); forward(REFERER); } // Send response to original poster if not already registered to receive notification if ($parent_guid) { thewire_send_response_notification($guid, $parent_guid, $user); $parent = get_entity($parent_guid); forward("thewire/thread/{$parent->wire_thread}"); } system_message(elgg_echo("thewire:posted")); forward(REFERER);
/** * Find the plugin settings for a user. * * @param string $plugin_name Plugin name. * @param int $user_guid The guid who's settings to retrieve. * @return array of settings in an associative array minus prefix. */ function find_plugin_usersettings($plugin_name = "", $user_guid = 0) { $plugin_name = sanitise_string($plugin_name); $user_guid = (int) $user_guid; if (!$plugin_name) { $plugin_name = get_plugin_name(); } if ($user_guid == 0) { $user_guid = get_loggedin_userid(); } // Get metadata for user $all_metadata = get_all_private_settings($user_guid); //get_metadata_for_entity($user_guid); if ($all_metadata) { $prefix = "plugin:settings:{$plugin_name}:"; $return = new stdClass(); foreach ($all_metadata as $key => $meta) { $name = substr($key, strlen($prefix)); $value = $meta; if (strpos($key, $prefix) === 0) { $return->{$name} = $value; } } return $return; } return false; }
/** * Serve out views for site pages. * * @param unknown_type $page * @return unknown_type */ function sitepages_page_handler($page) { global $CONFIG; // for the owner block. if ($logged_in_guid = get_loggedin_userid()) { set_page_owner($logged_in_guid); } // sanity checking. // on bad params we'll forward so people will bookmark the correct URLs // @todo valid page names need to be pulled out into some sort of config var or admin option. $default_page = 'About'; $action = isset($page[0]) ? $page[0] : FALSE; $page_type = isset($page[1]) ? $page[1] : FALSE; switch ($action) { case 'edit': $title = elgg_echo('sitepages'); $content = sitepages_get_edit_section_content($page_type); break; case 'read': $title = elgg_echo('sitepages:' . strtolower($page_type)); $content = sitepages_get_page_content($page_type); break; default: forward("{$CONFIG->site->url}pg/sitepages/read/{$default_page}"); break; } page_draw($title, $content); }
/** * Import data from an parsed xml data array. * * @param array $data * @param int $version */ public function import(ODD $data) { if (!$data instanceof ODDEntity) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); } // Set type and subtype $this->attributes['type'] = $data->getAttribute('class'); $this->attributes['subtype'] = $data->getAttribute('subclass'); // Set owner $this->attributes['owner_guid'] = get_loggedin_userid(); // Import as belonging to importer. // Set time $this->attributes['time_created'] = strtotime($data->getAttribute('published')); $this->attributes['time_updated'] = time(); return true; }
function plugins_send_notifications($entity) { global $CONFIG, $NOTIFICATION_HANDLERS; $owner = $entity->getOwnerEntity(); // Get users interested in content from this person and notify them foreach ($NOTIFICATION_HANDLERS as $method => $foo) { $interested_users = elgg_get_entities_from_relationship(array('relationship' => 'notify' . $method, 'relationship_guid' => $owner->guid, 'inverse_relationship' => TRUE, 'types' => 'user', 'limit' => 99999)); if ($interested_users && is_array($interested_users)) { foreach ($interested_users as $user) { if ($user instanceof ElggUser && !$user->isBanned()) { if ($user->guid != get_loggedin_userid() && has_access_to_entity($entity, $user)) { $subtype = $entity->getSubtype(); if ($subtype == 'plugin_project') { $text = $entity->description; } else { $text = $entity->release_notes; } $subject = sprintf(elgg_echo("plugins:{$subtype}:notify:subject"), $owner->name, $entity->title); $body = sprintf(elgg_echo("plugins:{$subtype}:notify:body"), $owner->name, $entity->title, $text, $entity->getURL()); notify_user($user->guid, $entity->owner_guid, $subject, $body, NULL, array($method)); } } } } } }
<?php /** * Custom front page. * This is in a view so we can parse it for keywords. * * @package SitePages * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd * @copyright Curverider Ltd 2008-2010 * @link http://elgg.org/ */ $sitepage = sitepages_get_sitepage_object('front'); if ($sitepage) { if (get_loggedin_userid()) { echo $sitepage->logged_in_content; } else { echo $sitepage->logged_out_content; } }
// Get variables global $CONFIG; $username = get_input('username'); $password = get_input('password'); $password2 = get_input('password2'); $email = get_input('email'); $name = get_input('name'); $admin = get_input('admin'); if (is_array($admin)) { $admin = $admin[0]; } // For now, just try and register the user try { if (trim($password) != "" && strcmp($password, $password2) == 0 && ($guid = register_user($username, $password, $name, $email, true))) { $new_user = get_entity($guid); if ($guid && $admin) { $new_user->admin = 'yes'; } $new_user->admin_created = true; $new_user->created_by_guid = get_loggedin_userid(); $new_user->issimpleuser = "******"; notify_user($new_user->guid, $CONFIG->site->guid, elgg_echo('useradd:subject'), sprintf(elgg_echo('useradd:body'), $name, $CONFIG->site->name, $CONFIG->site->url, $username, $password)); system_message(sprintf(elgg_echo("adduser:ok"), $CONFIG->sitename)); } else { register_error(elgg_echo("adduser:bad")); } } catch (RegistrationException $r) { register_error($r->getMessage()); } forward($_SERVER['HTTP_REFERER']); exit;
<?php // only logged in users can add blog posts gatekeeper(); // get the form input $title = get_input('title'); $body = get_input('id'); $keyword = get_input('keyword'); // create a new search object $search_obj = new ElggObject(); $search_obj->title = $title; $search_obj->id = $id; $search_obj->keyword = $keyword; $search_obj->subtype = "mmsearch"; // for now make all blog posts public $search_obj->access_id = ACCESS_PUBLIC; // owner is logged in user $search_obj->owner_guid = get_loggedin_userid(); // save to database $search_obj->save(); // forward user to a page that displays the post forward($search_obj->getURL());
* @license GNU Public License version 3 * @Contact iZAP Team "<*****@*****.**>" * @Founder Tarun Jangra "<*****@*****.**>" * @link http://www.izap.in/ * */ $videoId = get_input('videoId'); $video = izapVideoCheck_izap_videos($videoId); $attribs = $video->getAttributes(); $newVideo = new IzapVideos(); foreach ($attribs as $attribute => $value) { $newVideo->{$attribute} = $value; } $newVideo->views = 1; $newVideo->owner_guid = get_loggedin_userid(); $newVideo->container_guid = get_loggedin_userid(); $newVideo->access_id = $video->access_id; $newVideo->copiedFrom = $video->owner_guid; $newVideo->copiedVideoId = $videoId; $newVideo->copiedVideoUrl = $video->getUrl(); izapCopyFiles_izap_videos($video->owner_guid, $video->imagesrc); if ($video->videotype == 'uploaded') { izapCopyFiles_izap_videos($video->owner_guid, $video->videofile); izapCopyFiles_izap_videos($video->owner_guid, $video->orignalfile); } if ($newVideo->save()) { system_message(elgg_echo('izap_videos:success:videoCopied')); forward($newVideo->getURL()); } else { system_message(elgg_echo('izap_videos:success:videoNotCopied')); forward($_SERVER['HTTP_REFERER']);
<?php /** * Friends of friends. * * @package friends_of_friends * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Pedro Prez * @copyright 2009 * @link http://www.pedroprez.com.ar/ */ require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php"; gatekeeper(); set_context('friendsoffriends'); // Get the current page's owner $page_owner = page_owner_entity(); if ($page_owner === false || is_null($page_owner)) { $page_owner = get_loggedin_user(); set_page_owner(get_loggedin_userid()); } $title = elgg_view_title(elgg_echo('friendsoffriends')); // Display main admin menu $body = friends_of_friends_list_entities($page_owner->getGUID(), 10, true); page_draw(elgg_echo('friendsoffriends'), elgg_view_layout("two_column_left_sidebar", '', $title . $body));
$blog->description = $body; // Now let's add tags. We can pass an array directly to the object property! Easy. if (is_array($tagarray)) { $blog->tags = $tagarray; } //whether the user wants to allow comments or not on the blog post $blog->comments_on = $comments_on; // Now save the object if (!$blog->save()) { register_error(elgg_echo("blog:error")); forward($_SERVER['HTTP_REFERER']); } // Success message system_message(elgg_echo("blog:posted")); // add to river add_to_river('river/object/blog/create', 'create', get_loggedin_userid(), $blog->guid); // Remove the blog post cache //unset($_SESSION['blogtitle']); unset($_SESSION['blogbody']); unset($_SESSION['blogtags']); remove_metadata($_SESSION['user']->guid, 'blogtitle'); remove_metadata($_SESSION['user']->guid, 'blogbody'); remove_metadata($_SESSION['user']->guid, 'blogtags'); // Forward to the main blog page $page_owner = get_entity($blog->container_guid); if ($page_owner instanceof ElggUser) { $username = $page_owner->username; } else { if ($page_owner instanceof ElggGroup) { $username = "******" . $page_owner->guid; } } forward("pg/blog/{$username}");
/** * Update an annotation. * * @param int $annotation_id * @param string $name * @param string $value * @param string $value_type * @param int $owner_guid * @param int $access_id */ function update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id) { global $CONFIG; $annotation_id = (int) $annotation_id; $name = trim($name); $value = trim($value); $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type))); $owner_guid = (int) $owner_guid; if ($owner_guid == 0) { $owner_guid = get_loggedin_userid(); } $access_id = (int) $access_id; $access = get_access_sql_suffix(); // Add the metastring $value = add_metastring($value); if (!$value) { return false; } $name = add_metastring($name); if (!$name) { return false; } // If ok then add it $result = update_data("UPDATE {$CONFIG->dbprefix}annotations set value_id='{$value}', value_type='{$value_type}', access_id={$access_id}, owner_guid={$owner_guid} where id={$annotation_id} and name_id='{$name}' and {$access}"); if ($result !== false) { $obj = get_annotation($annotation_id); if (trigger_elgg_event('update', 'annotation', $obj)) { return true; } else { delete_annotation($annotation_id); } } return $result; }
} if (!$banned) { $info .= "<p><b><a href=\"" . $vars['entity']->getUrl() . "\" rel=\"{$rel}\">" . $vars['entity']->name . "</a></b></p>"; } else { $info .= "<p><b><strike>" . $vars['entity']->name . "</b></strike><br />" . elgg_echo('profile:banned') . "</p>"; } // TODO: look into a way to pass $authorised and $event_id in $vars $authorised = FALSE; $event_id = get_input('event_id', 0); if ($event_id) { if (isadminloggedin()) { $authorised = TRUE; } else { // load the event from the database $event = get_entity($event_id); $user_id = get_loggedin_userid(); if ($event && $event->owner_guid == $user_id) { $authorised = TRUE; } } } if ($authorised) { $link = '<p><a href="#" '; $link .= 'onclick="javascript:event_calendar_personal_toggle(' . $event_id . ',' . $vars['entity']->guid . '); return false;" '; $link .= ' >'; $link .= '<span id="event_calendar_user_data_' . $vars['entity']->guid . '">' . elgg_echo('event_calendar:remove_from_the_calendar') . '</span>'; $link .= '</a></p>'; $info .= $link; } // echo elgg_view_listing($icon, $info); echo elgg_view('search/gallery_listing', array('icon' => $icon, 'info' => $info));
array_unshift($container_guids, $context_container_guid); } // register_error("Container guids: " . print_r($container_guids, true) . ", raw: " . print_r($_REQUEST["group_selection"], true)); $file = null; foreach ($container_guids as $container_guid) { list($file, $guid) = create_file($container_guid, $title, $desc, $access_id, $original_guid, $tags, $new_file); // make sure session cache is cleared unset($_SESSION['uploadtitle']); unset($_SESSION['uploaddesc']); unset($_SESSION['uploadtags']); unset($_SESSION['uploadaccessid']); // handle results differently for new files and file updates if ($new_file) { if ($guid) { system_message(elgg_echo("file:saved")); add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid); } else { // failed to save file object - nothing we can do about this register_error(elgg_echo("file:uploadfailed") . "new"); } } else { if ($guid) { system_message(elgg_echo("file:saved")); } else { register_error(elgg_echo("file:uploadfailed") . "existing"); } } } // forward the user onward if ($new_file) { $container_user = get_entity($context_container_guid);
<?php /** * User's wire posts * */ $owner = elgg_get_page_owner_entity(); if (!$owner) { forward('thewire/all'); } $title = elgg_echo('thewire:user', array($owner->name)); elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all"); elgg_push_breadcrumb($owner->name); if (get_loggedin_userid() == $owner->guid) { $form_vars = array('class' => 'thewire-form'); $content = elgg_view_form('thewire/add', $form_vars); $content .= elgg_view('input/urlshortener'); } $content .= elgg_list_entities(array('type' => 'object', 'subtype' => 'thewire', 'owner_guid' => $owner->guid, 'limit' => 15)); $body = elgg_view_layout('content', array('filter_context' => 'mine', 'content' => $content, 'title' => $title, 'sidebar' => elgg_view('thewire/sidebar'))); echo elgg_view_page($title, $body);
<?php // only logged in users can add blog posts gatekeeper(); // get the form input $title = get_input('title'); $body = get_input('body'); $tags = string_to_tag_array(get_input('tags')); // create a new blog object $blogpost = new ElggObject(); $blogpost->title = $title; $blogpost->description = $body; $blogpost->subtype = "blog"; // for now make all blog posts public $blogpost->access_id = ACCESS_PUBLIC; // owner is logged in user $blogpost->owner_guid = get_loggedin_userid(); // save tags as metadata $blogpost->tags = $tags; // save to database $blogpost->save(); // forward user to a page that displays the post forward($blogpost->getURL());
/** * Creates a new access control collection owned by the specified user. * * @param string $name The name of the collection. * @param int $owner_guid The GUID of the owner (default: currently logged in user). * @param int $site_guid The GUID of the site (default: current site). * @return int|false Depending on success (the collection ID if successful). */ function create_access_collection($name, $owner_guid = 0, $site_guid = 0) { global $CONFIG; $name = trim($name); if (empty($name)) { return false; } if ($owner_guid == 0) { $owner_guid = get_loggedin_userid(); } if ($site_id == 0 && isset($CONFIG->site_guid)) { $site_id = $CONFIG->site_guid; } $name = sanitise_string($name); if (!($id = insert_data("insert into {$CONFIG->dbprefix}access_collections set name = '{$name}', owner_guid = {$owner_guid}, site_guid = {$site_id}"))) { return false; } $params = array('collection_id' => $id); if (!trigger_plugin_hook('access:collections:addcollection', 'collection', $params, true)) { return false; } return $id; }
?> </a></h4> </div> <?php if ($excerpt) { echo '<div class="simplepie_excerpt">' . strip_tags($item->get_description(true), $blog_tags) . '</div>'; } if ($post_date) { ?> <div class="simplepie_date">Posted on <?php echo $item->get_date('j F Y | g:i a'); ?> </div> <?php } ?> </div> <?php } ?> <?php } else { if (get_loggedin_userid() == page_owner()) { echo '<p>' . elgg_echo('simplepie:notset') . '</p>'; } } ?> </div>
/** * Sets up submenus. Triggered on pagesetup. * */ function plugins_add_submenus() { global $CONFIG; $plugins_base = "{$CONFIG->wwwroot}pg/plugins"; if (get_context() == 'admin') { $title = elgg_echo("plugins:admin:menu"); add_submenu_item($title, "{$plugins_base}/admin/"); return; } if (get_context() != "plugins") { return; } $page_owner = page_owner_entity(); if (isloggedin() && page_owner() == get_loggedin_userid()) { $title = sprintf(elgg_echo("plugins:yours"), elgg_echo('plugins:types:')); add_submenu_item($title, "{$plugins_base}/developer/{$page_owner->username}"); //add_submenu_item(sprintf(elgg_echo('plugins:yours:friends'),page_owner_entity()->name), $CONFIG->wwwroot . "pg/plugins/". $page_owner->username . "/friends/"); } else { if (page_owner()) { $title = sprintf(elgg_echo("plugins:user"), $page_owner->name, elgg_echo('plugins:types:')); add_submenu_item($title, "{$plugins_base}/developer/{$page_owner->username}"); //if ($page_owner instanceof ElggUser) // This one's for users, not groups //add_submenu_item(sprintf(elgg_echo('plugins:friends'),$page_owner->name), $CONFIG->wwwroot . "pg/plugins/". $page_owner->username . "/friends/"); } } add_submenu_item(elgg_echo('plugins:all'), "{$plugins_base}/all/"); // add upload link when viewing own plugin page if (get_loggedin_userid() == page_owner()) { add_submenu_item(elgg_echo('plugins:upload'), "{$plugins_base}/new/project/{$page_owner->username}"); } }