public function insertReplinks($entity, $lr) { $rep_from = get_entities_from_relationship('friend', $entity->getGUID(), false, 'user', '', 0, 10, 10); //array which contains the resources if (is_array($rep_from)) { foreach ($rep_from as $i => $resource) { $this->replinks["from"][$i] = $resource->guid; } } else { $this->replinks["from"] = array(); } $rep_to = get_entities_from_relationship('friend', $entity->getGUID(), true, 'user', '', 0, 10, 10); //array which contains the resources if (is_array($rep_to)) { foreach ($rep_to as $i => $resource) { $this->replinks["to"][$i] = $resource->guid; } } else { $this->replinks["to"] = array(); } }
/** * Function to get all objects attached to a particular object * @param int $guid * @param string $type - the type of object to return e.g. 'file', 'friend_of' etc * @return an array of objects **/ function get_attachments($guid, $type = "") { $attached = get_entities_from_relationship("attached", $guid, $inverse_relationship = false, $type, $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false, $site_guid = 0); return $attached; }
function method_getElggData($params, $error) { global $CONFIG; if (!$this->is_loggedin()) { return array("err" => SESSION_ERROR); } $owner = $_SESSION['user']; $request = $params[0]; // erlaubte Abfragen: friends, contacs, user $filter = $params[1]; $friendselect = $params[2]; // $firstRow = $params[3]; // $lastRow = $params[3]; $entry["data"] = array(); $entry["colnames"] = array(); $entry["colwidths"] = array(); if ($request == "demo" && $friendselect == elgg_echo('ElggMan:rb:view:user') && $this->is_admin()) { $varColumns = $this->getVarColumnsUser(); } else { $varColumns = $this->getVarColumns(); } $limit = MAXENTRIES; switch ($request) { case "friends": switch ($friendselect) { case elgg_echo('ElggMan:friends'): $users = $owner->getFriends("", MAXENTRIES, $offset = 0); break; case elgg_echo('ElggMan:friends:incoming'): $in_count = get_entities_from_relationship('friendrequest', $owner->guid, true, "", "", 0, "", 0, 0, true); $users = get_entities_from_relationship("friendrequest", $owner->guid, true, "", "", 0, "", $in_count); break; case elgg_echo('ElggMan:friends:outgoing'): $sent_count = get_entities_from_relationship("friendrequest", $owner->guid, false, "user", "", 0, "", 0, 0, true); $users = get_entities_from_relationship("friendrequest", $owner->guid, false, "user", "", 0, "", $sent_count); } // switch break; case "contacts": $users = $owner->getObjects("PrivateContact", MAXENTRIES, $offset = 0); break; case "notActivatedUsers": access_show_hidden_entities(true); $prefix = $CONFIG->dbprefix; $sql = "SELECT guid FROM {$prefix}entities WHERE type = 'user' and enabled <> 'yes'"; $result = get_data($sql); if (is_array($result)) { foreach ($result as $row) { $users[] = westorElggMan_get_entity($row->guid); } } break; case "usersOnline": $users = find_active_users(600, MAXENTRIES); break; case "demo": $limit = 2; $entry["helpTxt"] = elgg_echo('ElggMan:helpTableColumns'); default: // "users" || "blockedUsers": $users = westorElggMan_get_entities($type = "user", $subtype = "", $owner_guid = 0, $order_by = "", $limit); break; } // switch if (is_array($users)) { foreach ($users as $user) { if ($request == "users" && $user->isBanned()) { continue; } if ($request == "blockedUsers" && !$user->isBanned()) { continue; } $name = $this->getEntityProperty($user, elgg_echo('ElggMan:displayname')); if ($filter) { // Filter angegeben if (stripos($name, $filter) === false) { continue; } } $line = array($user->getGUID(), false, $this->getEntityProperty($user, 'userIcon'), $name); if (is_array($varColumns)) { foreach ($varColumns as $varColumn) { if ($varColumn == elgg_echo('ElggMan_:cMobile')) { $line[] = $this->getEntityProperty($user, 'smsIcon'); } else { $line[] = $this->getEntityProperty($user, $varColumn); } } } $entry["data"][] = $line; // f = friend // a = admin // s = self $entry["metadata"][$user->getGUID()] = array('f' => is_object($owner->isFriendsWith($user->guid)), 'a' => westorElggMan_isAdmin($user), 's' => $owner->getGUID() == $user->getGUID(), 'u' => $user->getURL()); } } $entry["colnames"] = array('', '', '', elgg_echo("ElggMan:displayname")); $entry["colnames"] = array_merge($entry["colnames"], $varColumns); if (!$this->is_admin() || $request == "demo" && $friendselect == elgg_echo('ElggMan:rb:view:user')) { $entry["colwidths"] = $this->getAllColumnWidths("user"); } else { $entry["colwidths"] = $this->getAllColumnWidths("admin"); } // list the colrenderer to use, null for default $entry["colrenderer"] = array(null, 'bool', 'img', null); $i = 4; if (is_array($varColumns)) { foreach ($varColumns as $varColumn) { if ($varColumn == elgg_echo('ElggMan_:cMobile')) { $entry["colrenderer"][] = 'img'; $entry["colwidths"][$i] = 30; } else { $entry["colrenderer"][] = null; } $i++; } } // $entry["colwidths"] = array(0, 22, 22, 180); // foreach($varColumns as $varColumn){ // if ($varColumn == elgg_echo('ElggMan_:cSince') || $varColumn == elgg_echo('ElggMan_:cLastLogin') || $varColumn == elgg_echo('ElggMan_:cLastAction') ) { // $entry["colwidths"][] = 80; // } else { // $entry["colwidths"][] = 170; // } // } return $entry; }
$iconsize = "medium"; } ?> <div id="groups_info_column_right"><!-- start of groups_info_column_right --> <div id="groups_icon_wrapper"><!-- start of groups_icon_wrapper --> <?php echo elgg_view("groups/icon", array('entity' => $vars['entity'], 'size' => $iconsize)); ?> </div><!-- end of groups_icon_wrapper --> <div id="group_stats"><!-- start of group_stats --> <?php echo "<p><b>" . elgg_echo("groups:owner") . ": </b><a href=\"" . get_user($vars['entity']->owner_guid)->getURL() . "\">" . get_user($vars['entity']->owner_guid)->name . "</a></p>"; ?> <p><?php echo elgg_echo('groups:members') . ": " . get_entities_from_relationship('member', $vars['entity']->guid, true, 'user', '', 0, '', 9999, 0, true); ?> </p> </div><!-- end of group_stats --> </div><!-- end of groups_info_column_right --> <div id="groups_info_column_left"><!-- start of groups_info_column_left --> <?php if ($vars['full'] == true) { $group_fields = profile_manager_get_categorized_group_fields(); if (count($group_fields["fields"]) > 0) { $group_fields = $group_fields["fields"]; foreach ($group_fields as $field) { $metadata_name = $field->metadata_name; $value = $vars['entity']->{$metadata_name}; // make title
/** * Obtains the people who have made a given user a friend * * @param int $user_guid The user's GUID * @param string $subtype The subtype of users, if any * @param int $limit Number of results to return (default 10) * @param int $offset Indexing offset, if any * @return false|array Either an array of ElggUsers or false, depending on success */ function get_user_friends_of($user_guid, $subtype = "", $limit = 10, $offset = 0) { return get_entities_from_relationship("friend", $user_guid, true, "user", $subtype, 0, "time_created desc", $limit, $offset); }
* @author Curverider Ltd * @copyright Curverider Ltd 2008-2009 * @link http://elgg.com/ */ $group = $vars['entity']; $owner = get_entity($vars['entity']->owner_guid); $forward_url = $group->getURL(); ?> <div class="contentWrapper"> <form action="<?php echo $vars['url']; ?> action/groups/invite" method="post"> <?php if ($friends = get_entities_from_relationship('friend', $_SESSION['guid'], false, 'user', '', 0, '', 9999)) { echo elgg_view('friends/picker', array('entities' => $friends, 'internalname' => 'user_guid', 'highlight' => 'all')); } // echo elgg_view('sharing/invite',array('shares' => $shares, 'owner' => $owner, 'group' => $group)); ?> <input type="hidden" name="forward_url" value="<?php echo $forward_url; ?> " /> <input type="hidden" name="group_guid" value="<?php echo $group->guid; ?> " /> <input type="submit" value="<?php echo elgg_echo('invite'); ?>
* * Object view of a custom profile field category * * @package profile_manager * @author ColdTrick IT Solutions * @copyright Coldtrick IT Solutions 2009 * @link http://www.coldtrick.com/ */ if (get_context() != "search") { $object = $vars["entity"]; // get title $title = $object->getTitle(); $rels = ""; $rel_count = get_entities_from_relationship(CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_CATEGORY_RELATIONSHIP, $object->guid, true, "object", CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE, null, null, null, null, true); if ($rel_count > 0) { $cats = get_entities_from_relationship(CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_CATEGORY_RELATIONSHIP, $object->guid, true, "object", CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE, null, null, $rel_count); $guids = array(); foreach ($cats as $cat) { $guids[] = $cat->guid; } $rels = implode(",", $guids); } ?> <div class="custom_fields_category" id="custom_profile_field_category_<?php echo $object->guid; ?> "> <div class="custom_fields_category_edit" onclick="editCategory('<?php echo $object->guid; ?> ','<?php
/** * Retrieves items from the river. All parameters are optional. * * @param int|array $subject_guid Acting entity to restrict to. Default: all * @param int|array $object_guid Entity being acted on to restrict to. Default: all * @param string $subject_relationship If set to a relationship type, this will use $subject_guid as the starting point and set the subjects to be all users this entity has this relationship with (eg 'friend'). Default: blank * @param string $type The type of entity to restrict to. Default: all * @param string $subtype The subtype of entity to restrict to. Default: all * @param string $action_type The type of river action to restrict to. Default: all * @param int $limit The number of items to retrieve. Default: 20 * @param int $offset The page offset. Default: 0 * @param int $posted_min The minimum time period to look at. Default: none * @param int $posted_max The maximum time period to look at. Default: none * @return array|false Depending on success */ function get_river_items($subject_guid = 0, $object_guid = 0, $subject_relationship = '', $type = '', $subtype = '', $action_type = '', $limit = 20, $offset = 0, $posted_min = 0, $posted_max = 0) { // Get config global $CONFIG; // Sanitise variables if (!is_array($subject_guid)) { $subject_guid = (int) $subject_guid; } else { foreach ($subject_guid as $key => $temp) { $subject_guid[$key] = (int) $temp; } } if (!is_array($object_guid)) { $object_guid = (int) $object_guid; } else { foreach ($object_guid as $key => $temp) { $object_guid[$key] = (int) $temp; } } if (!empty($type)) { $type = sanitise_string($type); } if (!empty($subtype)) { $subtype = sanitise_string($subtype); } if (!empty($action_type)) { $action_type = sanitise_string($action_type); } $limit = (int) $limit; $offset = (int) $offset; $posted_min = (int) $posted_min; $posted_max = (int) $posted_max; // Construct 'where' clauses for the river $where = array(); $where[] = str_replace("and enabled='yes'", '', str_replace('owner_guid', 'subject_guid', get_access_sql_suffix())); if (empty($subject_relationship)) { if (!empty($subject_guid)) { if (!is_array($subject_guid)) { $where[] = " subject_guid = {$subject_guid} "; } else { $where[] = " subject_guid in (" . implode(',', $subject_guid) . ") "; } } } else { if (!is_array($subject_guid)) { if ($entities = get_entities_from_relationship($subject_relationship, $subject_guid, false, '', '', 0, '', 9999)) { $guids = array(); foreach ($entities as $entity) { $guids[] = (int) $entity->guid; } // $guids[] = $subject_guid; $where[] = " subject_guid in (" . implode(',', $guids) . ") "; } else { return array(); } } } if (!empty($object_guid)) { if (!is_array($object_guid)) { $where[] = " object_guid = {$object_guid} "; } else { $where[] = " object_guid in (" . implode(',', $object_guid) . ") "; } } if (!empty($type)) { $where[] = " type = '{$type}' "; } if (!empty($subtype)) { $where[] = " subtype = '{$subtype}' "; } if (!empty($action_type)) { $where[] = " action_type = '{$action_type}' "; } if (!empty($posted_min)) { $where[] = " posted > {$posted_min} "; } if (!empty($posted_max)) { $where[] = " posted < {$posted_max} "; } $whereclause = implode(' and ', $where); // Construct main SQL $sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,posted from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}"; // Get data return get_data($sql); }
<?php /** * Group profile widget - this displays a users groups on their profile **/ //the number of groups to display $number = (int) $vars['entity']->num_display; if (!$number) { $number = 4; } //the page owner $owner = $vars['entity']->owner_guid; //$groups = get_users_membership($owner); //$groups = list_entities_from_relationship('member',$owner,false,'group','',0,$number,false,false,false); $groups = get_entities_from_relationship('member', $owner, false, "group", "", 0, "", $number, 0, false, 0); if ($groups) { echo "<div class=\"groupmembershipwidget\">"; foreach ($groups as $group) { $icon = elgg_view("groups/icon", array('entity' => $group, 'size' => 'small')); echo "<div class=\"contentWrapper\">" . $icon . " <div class='search_listing_info'><p><span>" . $group->name . "</span><br />"; echo $group->briefdescription . "</p></div><div class=\"clearfloat\"></div></div>"; } echo "</div>"; } // echo $groups;
<?php /** * Elgg notifications plugin group index * * @package ElggNotifications * @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 Elgg framework require_once dirname(dirname(dirname(__FILE__))) . '/engine/start.php'; // Ensure only logged-in users can see this page gatekeeper(); // Set the context to settings set_context('settings'); // Get the form global $SESSION, $CONFIG; $people = array(); $groupmemberships = get_entities_from_relationship('member', $_SESSION['user']->guid, false, 'group', '', 0, '', 9999); $body = elgg_view('input/form', array('body' => elgg_view('notifications/subscriptions/groupsform', array('groups' => $groupmemberships)), 'method' => 'post', 'action' => $CONFIG->wwwroot . 'action/notificationsettings/groupsave')); // Insert it into the correct canvas layout $body = elgg_view_layout('two_column_left_sidebar', '', $body); // Draw the page page_draw(elgg_echo('notifications:subscriptions:changesettings:groups'), $body);
/** * Automatically triggered notification on 'create' events that looks at registered * objects and attempts to send notifications to anybody who's interested * * @see register_notification_object */ function object_notifications($event, $object_type, $object) { // We only want to trigger notification events for ElggEntities if ($object instanceof ElggEntity) { // Get config data global $CONFIG, $SESSION, $NOTIFICATION_HANDLERS; $hookresult = trigger_plugin_hook('object:notifications', $object_type, array('event' => $event, 'object_type' => $object_type, 'object' => $object), false); if ($hookresult === true) { return true; } // Have we registered notifications for this type of entity? $object_type = $object->getType(); if (empty($object_type)) { $object_type = '__BLANK__'; } $object_subtype = $object->getSubtype(); if (empty($object_subtype)) { $object_subtype = '__BLANK__'; } if (isset($CONFIG->register_objects[$object_type][$object_subtype])) { $descr = $CONFIG->register_objects[$object_type][$object_subtype]; $string = $descr . ": " . $object->getURL(); // Get users interested in content from this person and notify them // (Person defined by container_guid so we can also subscribe to groups if we want) foreach ($NOTIFICATION_HANDLERS as $method => $foo) { if ($interested_users = get_entities_from_relationship('notify' . $method, $object->container_guid, true, 'user', '', 0, '', 99999)) { if (is_array($interested_users)) { foreach ($interested_users as $user) { if ($user instanceof ElggUser) { if (!$user->isBanned()) { if ($user->guid != $SESSION['user']->guid && has_access_to_entity($object, $user) && $object->access_id != ACCESS_PRIVATE) { $methodstring = trigger_plugin_hook('notify:entity:message', $object->getType(), array('entity' => $object, 'to_entity' => $user, 'method' => $method), $string); if (empty($methodstring) && $methodstring !== false) { $methodstring = $string; } if ($methodstring !== false) { notify_user($user->guid, $object->container_guid, $descr, $methodstring, NULL, array($method)); } } } } } } } } } } }
/** * Get the collections belonging to a site. * * @param int $site_guid * @param string $subtype * @param int $limit * @param int $offset */ function get_site_collections($site_guid, $subtype = "", $limit = 10, $offset = 0) { $site_guid = (int) $site_guid; $subtype = sanitise_string($subtype); $limit = (int) $limit; $offset = (int) $offset; return get_entities_from_relationship("member_of_site", $site_guid, true, "collection", $subtype, 0, "time_created desc", $limit, $offset); }
/** * Construct and execute the query required for the activity stream. * * @param int $limit Limit the query. * @param int $offset Execute from the given object * @param mixed $type A type, or array of types to look for. Note: This is how they appear in the SYSTEM LOG. * @param mixed $subtype A subtype, or array of types to look for. Note: This is how they appear in the SYSTEM LOG. * @param mixed $owner_guid The guid or a collection of GUIDs * @param string $owner_relationship If defined, the relationship between $owner_guid and the entity owner_guid - so "is $owner_guid $owner_relationship with $entity->owner_guid" * @return array An array of system log entries. */ function get_activity_stream_data($limit = 10, $offset = 0, $type = "", $subtype = "", $owner_guid = "", $owner_relationship = "") { global $CONFIG; $limit = (int) $limit; $offset = (int) $offset; if ($type) { if (!is_array($type)) { $type = array(sanitise_string($type)); } else { foreach ($type as $k => $v) { $type[$k] = sanitise_string($v); } } } if ($subtype) { if (!is_array($subtype)) { $subtype = array(sanitise_string($subtype)); } else { foreach ($subtype as $k => $v) { $subtype[$k] = sanitise_string($v); } } } if ($owner_guid) { if (is_array($owner_guid)) { foreach ($owner_guid as $k => $v) { $owner_guid[$k] = (int) $v; } } else { $owner_guid = array((int) $owner_guid); } } $owner_relationship = sanitise_string($owner_relationship); // Get a list of possible views $activity_events = array(); $activity_views = array_merge(elgg_view_tree('activity', 'default'), elgg_view_tree('river', 'default')); // Join activity with river $done = array(); foreach ($activity_views as $view) { $fragments = explode('/', $view); $tmp = explode('/', $view, 2); $tmp = $tmp[1]; if (isset($fragments[0]) && ($fragments[0] == 'river' || $fragments[0] == 'activity') && !in_array($tmp, $done)) { if (isset($fragments[1])) { $f = array(); for ($n = 1; $n < count($fragments); $n++) { $val = sanitise_string($fragments[$n]); switch ($n) { case 1: $key = 'type'; break; case 2: $key = 'subtype'; break; case 3: $key = 'event'; break; } $f[$key] = $val; } // Filter result based on parameters $add = true; if ($type) { if (!in_array($f['type'], $type)) { $add = false; } } if ($add && $subtype) { if (!in_array($f['subtype'], $subtype)) { $add = false; } } if ($add && $event) { if (!in_array($f['event'], $event)) { $add = false; } } if ($add) { $activity_events[] = $f; } } $done[] = $tmp; } } $n = 0; foreach ($activity_events as $details) { // Get what we're talking about if ($details['subtype'] == 'default') { $details['subtype'] = ''; } if ($details['type'] && $details['event']) { if ($n > 0) { $obj_query .= " or "; } $access = ""; if ($details['type'] != 'relationship') { $access = " and " . get_access_sql_suffix('sl'); } $obj_query .= "( sl.object_type='{$details['type']}' and sl.object_subtype='{$details['subtype']}' and sl.event='{$details['event']}' {$access} )"; $n++; } } // User if (count($owner_guid) && $owner_guid[0] != 0) { $user = "******" . implode(',', $owner_guid) . ")"; if ($owner_relationship) { $friendsarray = ""; if ($friends = get_entities_from_relationship($owner_relationship, $owner_guid[0], false, "user", $subtype, 0, "time_created desc", 9999)) { $friendsarray = array(); foreach ($friends as $friend) { $friendsarray[] = $friend->getGUID(); } $user = "******" . implode(',', $friendsarray) . ")"; } } } $query = "SELECT sl.* from {$CONFIG->dbprefix}system_log sl where 1 {$user} and ({$obj_query}) order by sl.time_created desc limit {$offset}, {$limit}"; return get_data($query); }
/** * 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/ */ function friends_of_friends_get_list($user_guid, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { global $CONFIG; $user_guid = (int) $user_guid; $friends = get_entities_from_relationship('friend', $user_guid, false, 'user', '', 0, $limit); $friends_aux = array(); if (is_array($friends)) { foreach ($friends as $friend) { $friends_aux[] = $friend->getGUID(); } } $list_friends = 0; if (!empty($friends_aux)) { $list_friends = implode(',', $friends_aux); } if ($order_by == "") { $order_by = "time_created desc"; } $order_by = sanitise_string($order_by); $limit = (int) $limit; $offset = (int) $offset; $site_guid = (int) $site_guid; if ($site_guid == 0) { $site_guid = $CONFIG->site_guid; } $where = array(); $where[] = "r.relationship='friend'"; if ($user_guid) { $where[] = "r.guid_one IN ({$list_friends})"; } if ($site_guid > 0) { $where[] = "e.site_guid = {$site_guid}"; } // Select what we're joining based on the options $joinon = "e.guid = r.guid_two"; if ($count) { $query = "SELECT count(distinct e.guid) as total "; } else { $query = "SELECT distinct e.* "; } $query .= " from {$CONFIG->dbprefix}entity_relationships r JOIN {$CONFIG->dbprefix}entities e on {$joinon} where "; foreach ($where as $w) { $query .= " {$w} and "; } $query .= get_access_sql_suffix("e"); // Add access controls if (!$count) { $query .= " order by {$order_by} limit {$offset}, {$limit}"; // Add order and limit $data = get_data($query, "entity_row_to_elggstar"); if ($data) { foreach ($data as $id => $row) { if ($row->getGUID() == $user_guid) { unset($data[$id]); } } } return $data; } else { if ($count = get_data_row($query)) { return $count->total; } } return false; }
* @author Diego Andrés Ramírez Aragón <*****@*****.**> * @copyright Corporación Somos más - 2009 * @link http://www.somosmas.org * */ if (get_plugin_setting("groupcontents", "blogextended") == "yes") { $field_label = elgg_echo("content:owner"); if (isset($vars["label"])) { $field_label = $vars["label"]; } $value = ""; if (isset($vars["entity"])) { $value = $vars["entity"]->content_owner; } $options = array("" => elgg_echo("my:profile")); $objects = get_entities_from_relationship("member", page_owner(), false, "group"); if (!empty($objects)) { foreach ($objects as $object) { $options["{$object->guid}"] = $object->name; } } if (isset($vars["assign_to"])) { $options = array(); $value = $vars["assign_to"]; $group = get_entity($value); $options[$value] = $group->name; } ?> <p><label><?php echo $field_label;
/** * Get the sites this object is part of * * @param int $object_guid The object's GUID * @param int $limit Number of results to return * @param int $offset Any indexing offset * @return false|array On success, an array of ElggSites */ function get_object_sites($object_guid, $limit = 10, $offset = 0) { $object_guid = (int) $object_guid; $limit = (int) $limit; $offset = (int) $offset; return get_entities_from_relationship("member_of_site", $object_guid, false, "site", "", 0, "time_created desc", $limit, $offset); }
/** * returns an array containing the categories and the fields ordered by category and field order */ function profile_manager_get_categorized_fields($user = null, $edit = false, $register = false) { $result = array(); $profile_type = null; if ($register == true) { // failsafe for edit $edit = true; } if (!empty($user) && $user instanceof ElggUser) { $profile_type_guid = $user->custom_profile_type; if (!empty($profile_type_guid)) { $profile_type = get_entity($profile_type_guid); // check if profile type is a REAL profile type if (!empty($profile_type) && $profile_type instanceof ElggObject) { if ($profile_type->getSubtype() != CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE) { $profile_type = null; } } } } $result["categories"] = array(); $result["categories"][0] = array(); $result["fields"] = array(); $ordered_cats = array(); $cat_count = get_entities("object", CUSTOM_PROFILE_FIELDS_CATEGORY_SUBTYPE, null, null, null, null, true); // get ordered categories if ($cat_count > 0) { $cats = get_entities("object", CUSTOM_PROFILE_FIELDS_CATEGORY_SUBTYPE, null, null, $cat_count); foreach ($cats as $cat) { $ordered_cats[$cat->order] = $cat; } ksort($ordered_cats); } // get filtered categories $filtered_ordered_cats = array(); // default category $filtered_ordered_cats[0] = array(); if (!empty($ordered_cats)) { foreach ($ordered_cats as $key => $cat) { if (!$edit) { $rel_count = get_entities_from_relationship(CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_CATEGORY_RELATIONSHIP, $cat->guid, true, "object", CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE, null, null, null, null, true); if ($rel_count == 0) { $filtered_ordered_cats[$cat->guid] = array(); $result["categories"][$cat->guid] = $cat; } elseif (!empty($profile_type) && check_entity_relationship($profile_type->guid, CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_CATEGORY_RELATIONSHIP, $cat->guid)) { $filtered_ordered_cats[$cat->guid] = array(); $result["categories"][$cat->guid] = $cat; } } else { $filtered_ordered_cats[$cat->guid] = array(); $result["categories"][$cat->guid] = $cat; } } } $field_count = get_entities("object", CUSTOM_PROFILE_FIELDS_PROFILE_SUBTYPE, null, null, null, null, true); // adding fields to categories if ($field_count > 0) { $fields = get_entities("object", CUSTOM_PROFILE_FIELDS_PROFILE_SUBTYPE, null, null, $field_count); foreach ($fields as $field) { if (!($cat_guid = $field->category_guid)) { $cat_guid = 0; // 0 is default } $admin_only = $field->admin_only; if ($admin_only != "yes" || isadminloggedin()) { if ($edit) { if (!$register || $field->show_on_register == "yes") { $filtered_ordered_cats[$cat_guid][$field->order] = $field; } } else { // only add if value exists $metadata_name = $field->metadata_name; if (!empty($user->{$metadata_name}) || $user->{$metadata_name} === 0) { $filtered_ordered_cats[$cat_guid][$field->order] = $field; } } } } } // sorting fields and filtering empty categories foreach ($filtered_ordered_cats as $cat_guid => $fields) { if (!empty($fields)) { ksort($fields); $result["fields"][$cat_guid] = $fields; } else { unset($result["categories"][$cat_guid]); } } return $result; }
} } $tab_header = ""; $tab_content = ""; $list_content = ""; echo "<b><FONT COLOR=\"FF0000\">Click on the tabs below this text to fill both primary and secondary profile Fields(for resources only) </b></FONT>"; foreach ($cats as $cat_guid => $cat) { // make nice title for category if ($cat_guid == 0) { $title = elgg_echo("profile_manager:categories:list:default"); } else { $title = $cat->getTitle(); } $class = ""; if ($cat_guid != 0) { $profile_type_count = get_entities_from_relationship(CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_CATEGORY_RELATIONSHIP, $cat_guid, true, "object", CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_SUBTYPE, null, null, null, null, true); if ($profile_type_count > 0) { $class = "custom_fields_edit_profile_category"; $types = $cat->getEntitiesFromRelationship(CUSTOM_PROFILE_FIELDS_PROFILE_TYPE_CATEGORY_RELATIONSHIP, true, $profile_type_count); // add extra class so it can be toggle in the display foreach ($types as $type) { $class .= " custom_profile_type_" . $type->guid; } } } $tab_header .= "<li class='" . $class . "'><a href='javascript:void(0);' onclick='toggle_tabbed_nav(\"" . $cat_guid . "\", this);'>" . $title . "</a></li>\n"; $tab_content .= "<div id='profile_manager_profile_edit_tab_content_" . $cat_guid . "' class='profile_manager_profile_edit_tab_content'>\n"; $list_content .= "<div class='" . $class . "'>\n"; $list_content .= "<h3 class='settings'>" . $title . "</h3>\n"; // display each field for currect category foreach ($fields[$cat_guid] as $field) {
/** * Gets the number of of entities from a specific relationship type * * @param string $relationship Relationship type (eg "friends") * @return int|false The number of entities or false on failure */ function countEntitiesFromRelationship($relationship) { return get_entities_from_relationship($relationship, $this->getGUID(), false, "", "", "", "time_created desc", null, null, true); }
/** * Return all groups a user is a member of. * * @param unknown_type $user_guid */ function get_users_membership($user_guid) { return get_entities_from_relationship('member', $user_guid, false); }
<?php /** * Elgg notifications plugin index * * @package ElggNotifications * @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 Elgg framework require_once dirname(dirname(dirname(__FILE__))) . '/engine/start.php'; // Ensure only logged-in users can see this page gatekeeper(); // Set the context to settings set_context('settings'); // Get the form global $SESSION; $people = array(); if ($people_ents = get_entities_from_relationship('notify', $SESSION['user']->guid, false, 'user', '', 0, '', 99999)) { foreach ($people_ents as $ent) { $people[] = $ent->guid; } } $body = elgg_view('notifications/subscriptions/form', array('people' => $people)); // Insert it into the correct canvas layout $body = elgg_view_layout('two_column_left_sidebar', '', $body); // Draw the page page_draw(elgg_echo('notifications:subscriptions:changesettings'), $body);
/** * Return the write access for the current group if the user has write access to it. */ function groups_write_acl_plugin_hook($hook, $entity_type, $returnvalue, $params) { $page_owner = page_owner_entity(); // get all groups if logged in if ($loggedin = get_loggedin_user()) { $groups = get_entities_from_relationship('member', $loggedin->getGUID()); if (is_array($groups)) { foreach ($groups as $group) { $returnvalue[$group->group_acl] = elgg_echo('groups:group') . ': ' . $group->name; } } } // This doesn't seem to do anything. // There are no hooks to override container permissions for groups // // if ($page_owner instanceof ElggGroup) // { // if (can_write_to_container()) // { // $returnvalue[$page_owner->group_acl] = elgg_echo('groups:group') . ": " . $page_owner->name; // } // } return $returnvalue; }
<?php /** * Manage group invite requests. * * @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/ */ require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php"; gatekeeper(); $group_guid = (int) get_input('group_guid'); $group = get_entity($group_guid); set_page_owner($group_guid); $title = elgg_echo('groups:membershiprequests'); $area2 = elgg_view_title($title); if ($group && $group->canEdit()) { $requests = get_entities_from_relationship('membership_request', $group_guid, true, '', '', 0, '', 9999); $area2 .= elgg_view('groups/membershiprequests', array('requests' => $requests, 'entity' => $group)); } else { $area2 .= elgg_echo("groups:noaccess"); } $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2); page_draw($title, $body);
function westorElggMan_get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { if (function_exists("elgg_entities_from_relationship")) { $options = array(); $options['relationship'] = $relationship; $options['relationship_guid'] = $relationship_guid; $options['inverse_relationship'] = $inverse_relationship; if ($type) { $options['types'] = $type; } if ($subtype) { $options['subtypes'] = $subtype; } if ($owner_guid) { $options['owner_guid'] = $owner_guid; } $options['limit'] = $limit; if ($offset) { $options['offset'] = $offset; } if ($order_by) { $options['order_by']; } if ($site_guid) { $options['site_guid']; } if ($count) { $options['count'] = $count; } return elgg_get_entities_from_relationship($options); } else { return get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by, $limit, $offset, $count, $site_guid); } }
<?php global $NOTIFICATION_HANDLERS; foreach ($NOTIFICATION_HANDLERS as $method => $foo) { $subsbig[$method] = get_entities_from_relationship('notify' . $method, $vars['user']->guid, false, 'group', '', 0, '', 99999); $tmparray = array(); foreach ($subsbig[$method] as $tmpent) { $tmparray[] = $tmpent->guid; } $subsbig[$method] = $tmparray; } echo elgg_view_title(elgg_echo('notifications:subscriptions:changesettings:groups')); ?> <div class="contentWrapper"> <div class="notification_methods"> <?php echo elgg_view('notifications/subscriptions/jsfuncs', $vars); ?> <p> <?php echo elgg_echo('notifications:subscriptions:groups:description'); ?> </p> <?php if (isset($vars['groups']) && !empty($vars['groups'])) { ?> <table id="notificationstable" cellspacing="0" cellpadding="4" border="1" width="100%"> <tr> <td> </td>
<?php /** * @package Elgg * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Roger Curry, Grid Research Centre [curry@cpsc.ucalgary.ca] * @author Tingxi Tan, Grid Research Centre [txtan@cpsc.ucalgary.ca] * @link http://grc.ucalgary.ca/ */ //the number of publications to display $number = (int) $vars['entity']->num_display; if (!$number) { $number = 4; } //the page owner $owner = $vars['entity']->owner_guid; $publications = get_entities_from_relationship('author', $owner, true, 'object', 'publication', 0, '', $number); if ($publications) { echo "<div id=\"publicationwidget\" class=\"contentWrapper\">"; foreach ($publications as $publication) { set_context('references'); echo elgg_view_entity($publication); } echo "</div>"; }
<?php /** * Elgg groups plugin * * @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/ */ $owner = $vars['owner']; $group = $vars['group']; if ($friends = get_entities_from_relationship('friend', $owner->getGUID(), false, 'user', '')) { foreach ($friends as $friend) { if (!$group->isMember($friend)) { $label = elgg_view("profile/icon", array('entity' => $friend, 'size' => 'tiny')); $label .= "{$friend->name}"; $options[$label] = $friend->getGUID(); } } if ($options) { echo elgg_view('input/checkboxes', array('internalname' => 'user_guid', 'options' => $options)); } else { echo elgg_echo('groups:nofriends'); } }
function get_question_for_answer($answer) { if ($answer->question_guid) { $question = get_entity($answer->question_guid); if ($question) { return $question; } } $questions = get_entities_from_relationship("answer", $answer->getGUID(), true); if (count($questions) > 0) { return $questions[0]; } else { return false; } }