本文整理汇总了PHP中Relation::delete_relation方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::delete_relation方法的具体用法?PHP Relation::delete_relation怎么用?PHP Relation::delete_relation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::delete_relation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
if (PA::$extra['reciprocated_relationship'] == NET_YES) {
Relation::add_relation($relation_id, $user_id, DEFAULT_RELATIONSHIP_TYPE, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED);
PANotify::send("reciprocated_relation_estab", PA::$network_info, PA::$login_user, $relation_obj);
// recipient is network owner
}
}
} catch (CNException $e) {
throw $e;
}
} else {
if (@$_POST['btn_deny']) {
$user_id = (int) $_GET['uid'];
$relation_id = (int) $_POST['related_id'];
try {
$relation_obj = Relation::getRelationData($relation_id, $user_id, PA::$network_info->network_id);
if (Relation::delete_relation($relation_id, $user_id, PA::$network_info->network_id)) {
// if relation deleted successfully, send a notification to the requestor
$recip_obj = new User();
$recip_obj->load((int) $relation_id);
PANotify::send("friend_request_denial", $recip_obj, PA::$network_info, $relation_obj);
}
} catch (CNException $e) {
throw $e;
}
}
}
function setup_module($column, $moduleName, $obj)
{
global $uid, $paging, $user, $view_type;
switch ($column) {
case 'left':
示例2: dirname
require_once dirname(__FILE__) . '/../../config.inc';
require_once "{$path_prefix}/api/PAException/PAException.php";
require_once "{$path_prefix}/api/Relation/Relation.php";
require_once "{$path_prefix}/api/Logger/Logger.php";
if ($_SESSION['user']['id']) {
$uid = (int) $_SESSION['user']['id'];
} else {
// ah-ah no WAY :)
$msg = "ERROR: User not logged in.";
echo $msg;
Logger::log($msg . " in " . __FILE__);
exit;
}
if (isset($_POST['del'])) {
try {
Relation::delete_relation($uid, '-1', $_POST['network_uid'], $_POST['network']);
} catch (PAException $e) {
$msg = "ERROR: There was a problem with deleting the relation<br>" . $e->getMessage();
echo $msg;
Logger::log($msg . " in " . __FILE__);
exit;
}
// if we get here, all is ok
echo '<a href="javascript://" onclick="addrelation(this);">add to Widget</a>';
} else {
// try and add the relation
try {
Relation::add_relation($uid, -1, 2, $_POST['network'], $_POST['network_uid'], $_POST['display_name'], $_POST['thumbnail_url'], $_POST['profile_url']);
} catch (PAException $e) {
$msg = "ERROR: There was a problem with adding the relation<br>" . $e->getMessage();
echo $msg;
示例3: peopleaggregator_deleteUserRelation
function peopleaggregator_deleteUserRelation($args)
{
$token = $args['authToken'];
$dest_login = $args['login'];
$user = User::from_auth_token($token);
$dest_user = new User();
$dest_user->load($dest_login);
// actually delete the relation. this will throw a
// RELATION_NOT_EXIST exception if the relation doesn't exist.
Relation::delete_relation($user->user_id, $dest_user->user_id);
return array('success' => TRUE, 'msg' => 'Deleted relation');
}
示例4: 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);
//.........这里部分代码省略.........
示例5: unserialize
require_once "{$path_prefix}/api/ImageResize/ImageResize.php";
include_once "{$path_prefix}/api/ModuleSetting/ModuleSetting.php";
require_once "{$path_prefix}/web/includes/functions/auto_email_notify.php";
require_once "{$path_prefix}/web/includes/functions/mailing.php";
require_once "{$path_prefix}/web/includes/constants.php";
require_once "user_page_functions.php";
require_once PA::$path . "/api/Activities/Activities.php";
require_once PA::$path . "/api/api_constants.php";
global $current_theme_path, $network_info, $base_url, $config_site_name;
$extra = unserialize($network_info->extra);
// for query count
global $query_count_on_page;
$query_count_on_page = 0;
if ($_GET['action'] == 'delete') {
$delete_id = $_GET['uid'];
Relation::delete_relation($_SESSION['user']['id'], $delete_id);
$cache_id = 'relation_private_' . $_SESSION['user']['id'];
CachedTemplate::invalidate_cache($cache_id);
$cache_id = 'relation_public_' . $_SESSION['user']['id'];
CachedTemplate::invalidate_cache($cache_id);
// invalidate cache of user who is being added in relation module
$cache_id = 'in_relation_private_' . $delete_id;
CachedTemplate::invalidate_cache($cache_id);
$cache_id = 'in_relation_public_' . $delete_id;
CachedTemplate::invalidate_cache($cache_id);
header("Location: user.php?uid={$delete_id}&delete=1");
}
$is_error = FALSE;
$edit = FALSE;
$uid = $_SESSION['user']['id'];
if (empty($_GET['uid'])) {
示例6: 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) {
//.........这里部分代码省略.........
示例7: pa_mail
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);
}
}
} catch (PAException $e) {
throw $e;
}
} else {
if (@$_POST['btn_deny']) {
$user_id = (int) $_GET['uid'];
$relation_id = (int) $_POST['related_id'];
try {
if (Relation::delete_relation($relation_id, $user_id)) {
// if relation deleted successfully, send a notification to the requestor
$requested_user = User::map_ids_to_logins((int) $relation_id);
$requested_user_name = $requested_user[$relation_id];
// defining array of values to fill message frame
$params = array('user_id' => $_SESSION['user']['id'], 'first_name' => $_SESSION['user']['first_name'], 'last_name' => $_SESSION['user']['last_name'], 'to' => $_POST['related_email'], 'requested_user_id' => $relation_id, 'requested_user_name' => $requested_user_name, 'config_site_name' => $config_site_name);
// send notification
auto_email_notification_members('relationship_denied', $params);
}
} catch (PAException $e) {
throw $e;
}
}
}
function setup_module($column, $moduleName, $obj)
{