本文整理汇总了PHP中Relation::get_all_relations方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::get_all_relations方法的具体用法?PHP Relation::get_all_relations怎么用?PHP Relation::get_all_relations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::get_all_relations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
function render()
{
switch ($this->view) {
case "public":
// default PA view
break;
case 'user':
if (empty($this->uid)) {
return "user_id is required";
}
break;
default:
return "Unknown RelationsModule view: {$this->view}";
}
$extra = array();
if (isset(PA::$network_info->extra)) {
$extra = unserialize(PA::$network_info->extra);
}
$this->isfriend = FALSE;
$relations = Relation::get_all_relations((int) $this->uid);
foreach ($relations as $i => $rel) {
$relations[$i]['no_of_relations'] = count(Relation::get_relations($rel['user_id'], APPROVED));
if ($rel['status'] == PENDING) {
$this->pending_relations[] = $rel;
unset($relations[$i]);
}
}
$this->links = $this->relations = $relations;
if (!empty(PA::$login_user->user_id)) {
// get the relation between page user and loged in user
$my_relations = Relation::get_all_relations(PA::$login_user->user_id);
foreach ($my_relations as $i => $rel) {
if ($rel['user_id'] == $this->uid) {
$this->isfriend = $rel['status'];
}
}
// get the friend requests
$this->myfriends = Relation::get_all_user_ids(PA::$login_user->user_id);
$this->to_confirm = array();
foreach ($this->myfriends as $i => $rel) {
$rel['no_of_relations'] = count(Relation::get_relations($rel['user_id'], APPROVED));
if ($rel['user_id'] == $this->uid) {
$this->isfriend = $rel['status'];
}
if ($rel['status'] == PENDING) {
$this->to_confirm[] = $rel;
unset($this->myfriends[$i]);
}
}
}
if (count($this->relations) > 0) {
$this->view_all_url = "{$base_url}/view_all_members.php?view_type=relations&uid={$uid}";
}
$this->inner_HTML = $this->generate_inner_html();
$content = parent::render();
return $content;
}
示例2: handle_field_param
function handle_field_param($data)
{
global $login_uid, $page_uid;
if (isset($login_uid)) {
$Image_owner = $login_uid == $data->author_id ? TRUE : FALSE;
$relations_ids = Relation::get_all_relations((int) $data->author_id);
$user_in_relation = array();
foreach ($relations_ids as $ids) {
$user_in_relation['friends_id'][] = $ids['user_id'];
/*
if(!empty($ids['in_family']))
$user_in_relation['in_family'][] = $ids['in_family'];*/
}
}
// No one can view the media
$param = FALSE;
$network_owner = PA::$network_info->owner_id;
switch ($data->file_perm) {
case NONE:
if (isset($login_uid) && $Image_owner || $login_uid == SUPER_USER_ID || $login_uid == $network_owner) {
$param = TRUE;
}
break;
case ANYONE:
$param = TRUE;
break;
case WITH_IN_DEGREE_1:
if (isset($login_uid) && (in_array($login_uid, $user_in_relation['friends_id']) || $Image_owner || $login_uid == SUPER_USER_ID || $login_uid == $network_owner)) {
$param = TRUE;
}
break;
/*
case IN_FAMILY:
if (isset($login_uid) &&(is_array($user_in_relation)) && (in_array($login_uid,$user_in_relation['in_family']) || ($Image_owner)) ) {
$param = TRUE;
}
break;*/
}
// When user wants to see the Group image
if (isset($login_uid) && isset($_GET['gid'])) {
$is_author_member = $this->is_author_group_member($login_uid, $_GET['gid']);
// any group member can view group gallery!
if ($is_author_member) {
$param = TRUE;
}
}
return $param;
}
示例3: render
function render()
{
$links = array();
if ($this->page_id == PAGE_USER_PUBLIC) {
$links = Comment::get_comment_for_user(PA::$page_uid, 5);
} else {
if ($this->page_id == PAGE_USER_PRIVATE) {
$relations_ids = Relation::get_all_relations((int) PA::$login_uid, 0, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', APPROVED, PA::$network_info->network_id);
$tmp_links = array();
foreach ($relations_ids as $relation) {
$tmp_links[] = Comment::get_comment_for_user((int) $relation['user_id'], 5);
}
$cnt = 0;
$links = array();
$link_cnts = array();
do {
foreach ($tmp_links as $idx => $rel_links) {
if (empty($link_cnts[$idx])) {
$link_cnts[$idx] = 0;
}
if (isset($rel_links[$link_cnts[$idx]])) {
$links[] = $rel_links[$link_cnts[$idx]++];
$cnt++;
}
if ($cnt >= 5) {
break;
}
}
} while ($cnt++ <= 5);
} else {
$links = Comment::get_comment_for_content(NULL, $count = 5, 'DESC', TRUE);
}
}
foreach ($links as &$link) {
if (!empty($link['content_id'])) {
$post = Content::load_content((int) $link['content_id'], PA::$login_uid);
$link['post_title'] = $post->title;
} else {
$link['post_title'] = __('No title');
}
}
$this->inner_HTML = $this->generate_inner_html($links);
$content = parent::render();
return $content;
}
示例4: render
public function render()
{
$status = null;
if (!empty(PA::$extra['reciprocated_relationship']) && PA::$extra['reciprocated_relationship'] == NET_YES) {
$status = APPROVED;
}
$relations = Relation::get_all_relations((int) PA::$uid, 6, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', $status, PA::$network_info->network_id);
for ($i = 0; $i < count($relations); $i++) {
$count_relations = Relation::get_relations($relations[$i]['user_id'], $status, PA::$network_info->network_id);
$relations[$i]['no_of_relations'] = count($count_relations);
}
$this->links = $relations;
if (!empty($this->links)) {
$this->view_all_url = PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=relations&uid=' . PA::$uid;
}
$this->inner_HTML = $this->generate_inner_html();
$content = parent::render();
return $content;
}
示例5: handle_field_param
function handle_field_param($data)
{
global $login_uid, $page_uid;
if (isset($login_uid)) {
$Image_owner = $login_uid == $data->author_id ? TRUE : FALSE;
$relations_ids = Relation::get_all_relations((int) $data->author_id);
$user_in_relation = array();
foreach ($relations_ids as $ids) {
$user_in_relation['friends_id'][] = $ids['user_id'];
/*
if(!empty($ids['in_family']))
$user_in_relation['in_family'][] = $ids['in_family'];*/
}
}
// No one can view the media
$param = FALSE;
switch ($data->file_perm) {
case NONE:
if (isset($login_uid) && $Image_owner) {
$param = TRUE;
}
break;
case ANYONE:
$param = TRUE;
break;
case WITH_IN_DEGREE_1:
if (isset($login_uid) && (in_array($login_uid, $user_in_relation['friends_id']) || $Image_owner)) {
$param = TRUE;
}
break;
/*
case IN_FAMILY:
if (isset($login_uid) &&(is_array($user_in_relation)) && (in_array($login_uid,$user_in_relation['in_family']) || ($Image_owner)) ) {
$param = TRUE;
}
break;*/
}
// When user wants to see the Group image
$param = isset($_GET['gid']) ? TRUE : $param;
return $param;
}
示例6: render
function render()
{
if (empty(PA::$login_user->user_id)) {
return '';
}
// login required
$params = array();
$params['limit'] = $this->show;
switch ($this->view) {
case 'user':
if ($this->uid != PA::$login_user->user_id) {
return "";
// no display in this case
}
// get relations, we are only interested in Activities for Friends
$this->relations = array();
$this->relations[] = '-1';
// add one bogus to workaround empty array issue in Activities
// it would otherwise return ALL activities, unfiltered
$relations = Relation::get_all_relations((int) $this->uid);
foreach ($relations as $i => $rel) {
if ($rel['status'] != PENDING) {
$this->relations[] = $relations[$i]['user_id'];
}
}
$params['relation_ids'] = $this->relations;
break;
default:
break;
}
$this->activities = Activities::get_activities($params);
$tmp_file = dirname(__FILE__) . "/" . $this->skin . "_" . $this->inner_template;
$inner_html_gen =& new Template($tmp_file, $this);
$this->inner_HTML = $inner_html_gen->fetch();
$content = parent::render();
return $content;
}
示例7: loadRelations
public function loadRelations()
{
// load all this users relations
$this->user->{'local_relations'} = Relation::get_all_relations($this->user->user_id);
$this->user->{'external_relations'} = Relation::get_external_relations($this->user->user_id);
}
示例8: set_vars
function set_vars()
{
global $login_uid;
/* For handling the Album according to thier type */
switch ($this->type) {
case 'Images':
$all_albums = Album::load_all($this->uid, IMAGE_ALBUM);
break;
case 'Videos':
$all_albums = Album::load_all($this->uid, VIDEO_ALBUM);
break;
case 'Audios':
$all_albums = Album::load_all($this->uid, AUDIO_ALBUM);
break;
default:
// Treating Images are the default parameters
break;
}
/* setting all the album for this page */
/* Retrive the All album of user */
$album = array();
$j = 0;
if (!empty($all_albums)) {
foreach ($all_albums as $alb) {
$album[$j]['id'] = $alb['collection_id'];
$album[$j]['name'] = $alb['title'];
$j++;
}
$this->default_album_id = @$album[0]['id'];
$this->default_album_name = @$album[0]['name'];
$this->my_all_album = $album;
}
/* For handling Users Friend Album*/
if (isset($login_uid)) {
/* Here we calculate all the relation (Friend's) Ids
TODO: add a check to load it only when a user wants to see his friend's gallery
*/
/*
$relations_ids = Relation::get_all_relations((int)$login_uid);
$users = array();
$users_ids = array();
$users = Network::get_members(array('network_id'=>PA::$network_info->network_id));
if ( $users['total_users'] ) {
for( $i = 0; $i < $users['total_users']; $i++) {
$users_ids[] = $users['users_data'][$i]['user_id'];
}
}
if (!empty($relations_ids)) {
$cnt = count($relations_ids);
for ($i = 0; $i < $cnt; $i++) {
if (!in_array($relations_ids[$i]['user_id'], $users_ids)) {
unset($relations_ids[$i]);
}
}
}
// extracting some name who are not member of that network ;)
*/
$relations_ids = Relation::get_all_relations((int) PA::$login_uid, 0, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', APPROVED, PA::$network_info->network_id);
/* Here varify that users has any relation or not ... as well as loads all album */
if (!empty($relations_ids)) {
/* Here we get all the frnds list of login User */
$frnd_albums = array();
$i = 0;
sortByFunc($relations_ids, create_function('$relations_ids', 'return $relations_ids["login_name"];'));
foreach ($relations_ids as $frnd_id) {
$frnd_list[$i]['name'] = $frnd_id['login_name'];
$frnd_list[$i]['id'] = $frnd_id['user_id'];
$i++;
}
}
}
// End of Friend Album
$this->friend_list = @$frnd_list;
// can be empty
}
示例9: _render_friends
function _render_friends($scope) {
$section = ($scope == 'internal') ? 'friends' : 'friends_ext';
$section_singular = $this->section_singular_names[$section];
$page = (int)@$_REQUEST['friend_page'];
$friend_state =& $this->state[$section];
// paging controls
$total_friends = Relation::count_relations($this->user->user_id, $scope);
$total_pages = (int)ceil((float)$total_friends / $this->friends_per_page);
if ($page > $total_pages) $page = $total_pages;
if ($page < 1) $page = 1;
$paging = "Show page: ";
for ($i = 1; $i < $total_pages+1; ++$i) {
if ($i == $page) {
$paging .= "$i ";
} else {
$paging .= "<a href=\"javascript:badge.reload_section('badge_$section', '$this->url/$this->badge_tag/$section?friend_page=$i');\">$i</a> ";
}
}
$first_friend = ($page-1)*$this->friends_per_page + 1;
$last_friend = min($first_friend + $this->friends_per_page - 1, $total_friends);
$paging .= "(showing $first_friend-$last_friend of $total_friends friends)";
// 'showing XXX' link
$showing = $this->make_showing_link($friend_state, $section, "friend_page=$page");
// facewall display
$facewall = "";
foreach (Relation::get_all_relations($this->user->user_id, 0, FALSE, $this->friends_per_page, $page, 'created', 'desc', $scope) as $rel) {
$facewall .= '<div id="'.$section_singular.'_'.($scope == 'internal' ? $rel['user_id'] : md5($rel['user_id'])).'">'.$this->render_friend_image($rel, $scope).'</div>';
}
// outer template
return <<<ENS
<p>$showing</p>
<!--<p>How many items to show at once: <select id="item_count" onchange="badge.update()">
<option value="5">5</option>
<option value="10">10</option>
<option value="15" selected="selected">15</option>
<option value="20">20</option>
</select></p>-->
<div>
$facewall
<div style="clear: both"></div>
</div>
<p>$paging</p>
ENS;
}
示例10: get_external_relations
/**
* Load EXTERNAL relations of all types and their information
* @param $user_id user_id of the user
* @return $user_relation_data an array having user relation's information
*/
static function get_external_relations($user_id, $no_of_relations = 0, $cnt = FALSE, $show = 'ALL', $page = 0, $sort_by = 'created', $direction = 'DESC')
{
// this is just a convenience wrapper
return Relation::get_all_relations($user_id, $no_of_relations, $cnt, $show, $page, $sort_by, $direction, 'external');
}
示例11: array
$setting_data = ModuleSetting::load_setting(4, $uid);
// user general info
$user_data_general = array();
$user_generaldata = User::load_user_profile($uid, (int) $_SESSION['user']['id'], GENERAL);
for ($i = 0; $i < count($user_generaldata); $i++) {
$name = $user_generaldata[$i]['name'];
$value = $user_generaldata[$i]['value'];
$perm_name = $name . "_perm";
$perm_value = $user_generaldata[$i]['perm'];
$user_data_general["{$name}"] = $value;
$user_data_general["{$perm_name}"] = $perm_value;
}
// relations
if ($_SESSION['user']['id']) {
// user Relations (user relations with all informations)
$relations = Relation::get_all_relations((int) $uid);
}
$users = User::allUsers_with_paging(1, 10);
$module1 = new ImagesModule($pictures);
if ($page_type == 'public') {
$module1->mode = PUB;
} else {
$module1->mode = PRI;
}
$module1->title = "My Pictures";
$module1->orientation = LEFT;
$module2 = new RelationsModule($relations);
if ($page_type == 'public') {
$module2->mode = PUB;
} else {
$module2->mode = PRI;
示例12: get_users
function get_users()
{
if ($this->mode == 'alphabetical') {
$this->sort_by = 'UP.field_value';
$sorting_direction = 'ASC';
} else {
$this->sort_by = 'U.created';
$sorting_direction = 'DESC';
}
$this->search = array('field_type' => $this->skin, 'field_name' => 'login_name');
if (@$this->q) {
$this->search['operator'] = 'LIKE';
$this->search['value'] = "%{$this->q}%";
}
$users = array();
if ($this->mode == 'friends') {
$this->users = Relation::get_all_relations((int) $this->uid);
foreach ($relations as $i => $rel) {
$relations[$i]['no_of_relations'] = count(Relation::get_relations($rel['user_id'], APPROVED));
}
foreach ($this->users as $i => $u) {
if ($u['status'] == PENDING) {
unset($this->users[$i]);
} else {
// we make Object of Array
$r = NULL;
foreach ($u as $k => $v) {
$r->{$k} = $v;
}
$this->users[$i] = $r;
$this->users[$i]->pa_id = $r->user_id;
}
}
$this->user_count = count($this->users);
if (!$this->user_count) {
// this user has no friends
$this->mode = 'newest';
}
}
if (!$this->user_count) {
// load users on the basis of the search parameters.
$this->users = ShadowUser::search($this->search, $this->show, $this->page, $this->sort_by, $sorting_direction);
$this->user_count = ShadowUser::search($this->search, "COUNT");
}
if ($this->user_count) {
// prepare paging info
$this->n_pages = (int) ceil($this->user_count / $this->show);
}
}
示例13: array
<a href="{$url_enc}" target="_blank"><div class="person_image">{$img}</div><div class="person_name">{$title_enc}</div></a>
</div>
EOS;
$items_html[] = array("item", $h);
}
$html .= badge_render_section($items_html);
}
}
} else {
// old-style friends / groups badge
$html .= "<p><b><a target=\"_blank\" href=\"{$base_url}/user.php?uid={$user->user_id}\">{$user->first_name} {$user->last_name}</a></b>'s {$show_what}:</p>";
$show_all_url = "";
switch ($show_what) {
case 'friends':
$perpage = (int) $param;
$relations = Relation::get_all_relations($user->user_id, 0, FALSE, $param, $page);
$n = count($relations);
$rows = intval($n / 3) + ($n % 3 ? 1 : 0);
$pos = 0;
$html .= "<table>";
for ($y = 0; $y < $rows; ++$y) {
$html .= "<tr>";
for ($x = 0; $x < $cols && $pos < $n; ++$x, ++$pos) {
$html .= '<td valign="bottom">';
$rel = $relations[$pos];
$html .= '<a target="_blank" href="' . $base_url . '/user.php?uid=' . $rel['user_id'] . '">';
if ($rel['picture'] && file_exists("files/" . $rel['picture'])) {
$html .= uihelper_resize_mk_user_img($rel['picture'], 50, 50) . "<br/>";
}
$html .= htmlspecialchars($rel['login_name']) . '</a>';
$html .= "</td>";
示例14: peopleaggregator_getUserRelations
function peopleaggregator_getUserRelations($args)
{
$login = $args['login'];
$page = $args['page'];
$perpage = $args['resultsPerPage'];
// $detail = $args['detailLevel'];
$imageSize = $args['profileImageSize'];
if (preg_match("/^(\\d+)x(\\d+)\$/", $imageSize, $m)) {
$imageWidth = (int) $m[1];
$imageHeight = (int) $m[2];
} else {
$imageWidth = $imageHeight = 0;
}
// look up user ID
$user = new User();
$user->load($login);
$total = Relation::count_relations($user->user_id);
$total_pages = api_n_pages($total, $perpage);
$relations_out = array();
foreach (Relation::get_all_relations($user->user_id, 0, FALSE, $perpage, $page) as $rel) {
$rel_out = array('id' => 'user:' . $rel['user_id'], 'login' => $rel['login_name'], 'relation' => $rel['relation_type'], 'url' => PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $rel['user_id']);
$img_info = api_resize_user_image($rel['picture'], $imageWidth, $imageHeight);
if ($img_info) {
$rel_out['image'] = $img_info;
}
$relations_out[] = $rel_out;
}
if (sizeof($relations_out)) {
$first = ($page - 1) * $perpage + 1;
$msg = "Retrieved relations {$first}-" . ($first + sizeof($relations_out)) . " of {$total} for user {$user->login_name}.";
} else {
$msg = "Retrieved zero relations.";
if ($page > $total_pages) {
$msg .= " Try specifying a page number between 1 and {$total_pages}.";
}
}
return array('success' => TRUE, 'msg' => $msg, 'login' => $user->login_name, 'totalPages' => $total_pages, 'resultsPerPage' => $perpage, 'totalResults' => $total, 'page' => $page, 'relations' => $relations_out);
}
示例15: handleRequest
/** !!
* Called by web/dynamic.php, which does the page generation.
*
* @param string $request_method Not used. But here for standards.
* @param array $request_data POST data to save.
*/
public function handleRequest($request_method, $request_data)
{
$msg = NULL;
$action = isset($request_data['do']) ? $request_data['do'] : NULL;
if ($action == 'delete') {
$this->delete_id = $this->relation_uid;
Relation::delete_relation($this->uid, $this->delete_id, PA::$network_info->network_id);
$this->cache_id = 'relation_private_' . $this->uid;
CachedTemplate::invalidate_cache($this->cache_id);
$this->cache_id = 'relation_public_' . $this->uid;
CachedTemplate::invalidate_cache($this->cache_id);
// invalidate cache of user who is being added in relation module
$this->cache_id = 'in_relation_private_' . $this->delete_id;
CachedTemplate::invalidate_cache($this->cache_id);
$this->cache_id = 'in_relation_public_' . $this->delete_id;
CachedTemplate::invalidate_cache($this->cache_id);
header('Location:' . PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $this->delete_id . '&delete=1');
}
//getting relations of logged in user
$this->all_relations = Relation::get_all_relations((int) $this->uid);
$this->relationship_level = 2;
//default relation level id is 2 for friend
foreach ($this->all_relations as $relation) {
if ($this->relation_uid == $relation['user_id']) {
$this->relationship_level = $relation['relation_type_id'];
$this->in_family = $relation['in_family'];
$this->status = $relation['status'];
if ($this->status == PENDING) {
if (PA::$extra['reciprocated_relationship'] == NET_YES && $action == 'add') {
$msg = sprintf(__('Your request for adding %s as a relation has already been sent'), $relation['display_name']);
}
}
}
}
try {
$this->user->load((int) $this->relation_uid);
$this->title = __('Edit Relationship') . ' - ' . $this->user->display_name;
//title of the web page
//picture and login relation
$this->relation_picture = $this->user->picture;
$this->login_name = $this->user->login_name;
$this->display_name = $this->user->display_name;
} catch (PAException $e) {
$mesg = $e->message;
$this->is_error = TRUE;
}
if (isset($request_data['submit'])) {
$this->rel_creater = PA::$user;
$this->relationship_level = $request_data['level'];
if (PA::$extra['reciprocated_relationship'] == NET_YES) {
if (Relation::getRelationData($this->relation_uid, $this->uid, PA::$network_info->network_id)) {
Relation::update_relation_status($this->relation_uid, $this->uid, APPROVED, PA::$network_info->network_id);
Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED);
$relation_obj = Relation::getRelationData($this->relation_uid, $this->uid, PA::$network_info->network_id);
PANotify::send("reciprocated_relation_estab", PA::$network_info, PA::$login_user, $relation_obj);
// recipient is network owner
$location = PA_ROUTE_USER_PRIVATE . '/msg=' . urlencode(__("The relationship request was approved."));
header('Location:' . PA::$url . $location);
exit;
}
$this->status = PENDING;
} else {
$this->status = APPROVED;
}
try {
$this->relation = Relation::get_relation($this->rel_creater->user_id, $this->relation_uid, PA::$network_info->network_id);
$this->edit = $this->relation ? TRUE : FALSE;
} catch (PAException $e) {
$this->edit = FALSE;
}
try {
if (isset($request_data['in_family'])) {
// If the user has checked the in_family checkbox.
Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, $this->status);
} else {
Relation::add_relation($this->uid, $this->relation_uid, $this->relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, NULL, $this->status);
}
$this->user = PA::$user;
// relationship establisher image
$relation_obj = Relation::getRelationData($this->uid, $this->relation_uid, PA::$network_info->network_id);
if ($this->edit == FALSE) {
if (PA::$extra['reciprocated_relationship'] == NET_YES) {
PANotify::send("friend_request_sent", PA::$user, PA::$login_user, $relation_obj);
} else {
PANotify::send("relation_added", PA::$network_info, PA::$login_user, $relation_obj);
// recipient is network owner
PANotify::send("relationship_created_with_other_member", PA::$user, PA::$login_user, $relation_obj);
//for rivers of people
$activity = 'user_friend_added';
//for rivers of people
$activities_extra['info'] = $this->display_name . ' added new friend with id =' . $request_data['uid'];
$extra = serialize($activities_extra);
$object = $this->relation_uid;
Activities::save(PA::$login_uid, $activity, $object, $extra);
//.........这里部分代码省略.........