本文整理汇总了PHP中Relation::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::get方法的具体用法?PHP Relation::get怎么用?PHP Relation::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get()
{
$val = parent::get();
if (is_null($val)) {
return CrudModel::createInstance($this->config['model']);
}
return $val;
}
示例2: addNetworkData
private function addNetworkData($network)
{
$network_owner = new User();
$network_owner->load((int) $network->owner_id);
$network_owner_info = $this->getUserProfile($network_owner, 'network.owner');
$this->template_vars = array_merge($this->template_vars, $network_owner_info);
$this->template_vars["%network.icon_image%"] = uihelper_resize_mk_img($network->inner_logo_image, 219, 35, DEFAULT_NETWORK_ICON, 'alt="' . $network->name . '"');
$this->template_vars['%network.name%'] = $network->name;
$this->template_vars['%network.description%'] = $network->description;
$this->template_vars['%network.member_count%'] = $network->member_count;
$this->template_vars['%network.join_url%'] = UrlHelper::url_for(PA::$url . '/network_action.php', array('action' => 'join', 'nid' => $network->network_id));
$this->template_vars['%network.join_link%'] = UrlHelper::link_to(PA::$url . '/network_action.php', $this->template_vars['%network.join_url%'], null, array('action' => 'join', 'nid' => $network->network_id));
$this->template_vars['%network.url%'] = UrlHelper::url_for(PA_ROUTE_HOME_PAGE);
$this->template_vars['%network.link%'] = UrlHelper::link_to(PA_ROUTE_HOME_PAGE, $network->name);
$this->template_vars['%network.member_moderation_url%'] = UrlHelper::url_for(PA::$url . '/' . FILE_NETWORK_MANAGE_USER);
$this->template_vars['%network.member_moderation_link%'] = UrlHelper::link_to(PA::$url . '/' . FILE_NETWORK_MANAGE_USER, $this->template_vars['%network.member_moderation_url%']);
$this->template_vars['%network.reci_relation_count%'] = Relation::get(array('cnt' => true), 'status =\'' . APPROVED . '\' AND network_uid=' . $network->network_id);
}
示例3: render_for_ajax
function render_for_ajax()
{
$op = $this->params["op"];
if ($op != 'paging' && empty(PA::$login_user)) {
return __("Login required");
}
switch ($op) {
case "add_friend":
do {
$extra = array();
if (isset(PA::$network_info->extra)) {
$extra = unserialize(PA::$network_info->extra);
}
$status = APPROVED;
if (@$extra['reciprocated_relationship'] == NET_YES) {
$status = PENDING;
}
$added = FALSE;
try {
Relation::add_relation(PA::$login_user->user_id, $this->user->user_id, 2, NULL, NULL, NULL, NULL, NULL, NULL, $status);
$added = TRUE;
} catch (PAException $e) {
$this->err = __("There was a problem with adding the relation: ") . $e->getMessage();
$added = FALSE;
}
if ($added) {
if ($status == PENDING) {
$this->note = __("You have requested to be friends.");
} else {
$this->note = __("Friend added successfully.");
}
}
// and now for Notifications etc
// relationship establisher image
$rel_creater_picture = uihelper_resize_mk_user_img(PA::$login_user->picture, 80, 80, 'alt="' . PA::$login_user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
if (@$extra['reciprocated_relationship'] == NET_YES) {
// defining array to be sent, to fill message fram
$params = array('first_name' => PA::$login_user->first_name, 'last_name' => PA::$login_user->last_name, 'user_id' => PA::$login_user->id, 'approve_deny_url' => PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=in_relations&uid=' . $this->uid, 'invited_user_name' => $this->user->login_name, 'requestor_image' => $rel_creater_picture, 'to' => $this->user->email, 'requested_user_id' => $this->user->user_id, 'config_site_name' => PA::$site_name);
// send notification
auto_email_notification_members('relationship_requested', $params);
} else {
$params = array('related_uid' => $this->uid, 'related_user' => $this->user->first_name, 'user_name' => PA::$login_user->login_name, 'user_id' => PA::$login_user->user_id, 'user_image' => $rel_creater_picture, 'to' => $this->user->email, 'my_friends_url' => PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=in_relations&uid=' . $this->uid, 'user_url' => PA::$url . '/' . FILE_USER_BLOG . '?uid=' . PA::$login_user->user_id, 'config_site_name' => PA::$site_name);
auto_email_notification('relation_added', $params);
auto_email_notification_members('relationship_created_with_other_member', $params);
// for rivers of people
$activity = 'user_friend_added';
$extra = serialize(array('info' => PA::$login_user->login_name . ' added new relation with id = ' . $this->uid));
Activities::save(PA::$login_uid, $activity, $this->uid, $extra, array($activity));
}
} while (0);
break;
case "deny_friend":
// deny and remove are essentially equivalent
// deny and remove are essentially equivalent
case "remove_friend":
do {
$user_id = PA::$login_user->user_id;
$remove_id = (int) $this->params['remove_id'];
if ($op == "deny_friend") {
try {
$res = Relation::delete_relation($remove_id, $user_id);
// relation reversed
$this->note = __("You denied the friend request successfully.");
} catch (PAException $e) {
$this->err = __("There was a problem with denying the relation: ") . $e->getMessage();
}
} else {
// remove
try {
$res = Relation::delete_relation($user_id, $remove_id);
$this->note = __("You removed the friend successfully.");
} catch (PAException $e) {
$this->err = __("There was a problem removing the relation: ") . $e->getMessage();
}
// make sure we don't leave the relation existing in the other direction
try {
$res2 = Relation::delete_relation($remove_id, $user_id);
// relation reversed
} catch (PAException $e) {
$this->err = __("There was a problem removing the reversed relation: ") . $e->getMessage();
}
}
if ($res) {
$requested_user = User::map_ids_to_logins((int) $remove_id);
$requested_user_name = $requested_user[$remove_id];
// defining array of values to fill message fram
$params = array('user_id' => $user_id, 'first_name' => PA::$login_user->first_name, 'last_name' => PA::$login_user->last_name, 'to' => $this->params['related_email'], 'requested_user_id' => $remove_id, 'requested_user_name' => $requested_user_name, 'network_name' => PA::$network_info->name, 'config_site_name' => PA::$site_name);
// send notification
auto_email_notification_members('relationship_denied', $params);
}
} while (0);
break;
case "approve_friend":
do {
$user_id = PA::$login_user->user_id;
$relation_id = (int) $this->params['approve_id'];
$status = APPROVED;
try {
$result = Relation::update_relation_status($user_id, $relation_id, $status);
if ($result) {
//.........这里部分代码省略.........
示例4: User
$result = Relation::update_relation_status($user_id, $relation_id, $status);
if ($result) {
// if relationship has been made then send mail to the requestor
Relation::add_relation($user_id, $relation_id);
$from = $_SESSION['user']['email'];
$requested_user = User::map_ids_to_logins($relation_id);
if ($network_info->type == MOTHER_NETWORK_TYPE) {
$network_owner_id = SUPER_USER_ID;
} else {
$network_owner_id = $network_info->owner_id;
}
$net_user = new User();
$net_user->load((int) $network_owner_id);
$relation_type = $relation_type = Relation::lookup_relation_type(Relation::get_relation($relation_id, $user_id));
$params['cnt'] = TRUE;
$rel_count = Relation::get($params, 'status =\'' . APPROVED . '\'');
$friend_list_url = PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=in_relations&uid=' . $relation_id;
$user_url = url_for(FILE_USER_BLOG, array('login' => $requested_user[$relation_id]));
$member_moderation_url = PA::$url . '/' . FILE_NETWORK_MANAGE_USER;
$array_of_data = array('first_name' => $_SESSION['user']['first_name'], 'last_name' => $_SESSION['user']['last_name'], 'user_name' => $_SESSION['user']['name'], 'invited_user_id' => $relation_id, 'user_id' => $user_id, 'invited_user_name' => $requested_user[$relation_id], 'relation_type' => $relation_type, 'network_name' => $network_info->name, 'member_count' => $network_info->member_count, 'reci_relation_count' => $rel_count, 'network_owner_name' => $net_user->first_name, 'to' => $_POST['related_email'], 'mail_type' => 'friend_response', 'user_url' => $user_url, 'friend_list_url' => $friend_list_url, 'member_moderation_url' => $member_moderation_url, 'config_site_name' => $config_site_name);
// send mail to proper notification
auto_email_notification_members('invitation_accept', $array_of_data);
// add check for network owner's notification
$extra = unserialize($network_info->extra);
if ($extra['notify_owner']['relation_added']['value'] != NET_NONE) {
// send mail to network owner
$to = $net_user->email;
$mail_type = 'reciprocated_relation_estab';
$check = pa_mail($to, $mail_type, $array_of_data);
}
}