PANotify::send("friend_request_approved", $recip_obj, PA::$network_info, $relation_obj); 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) {
/** !! * 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); } } //invalidate cache of logged in user's relation module $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->relation_uid; CachedTemplate::invalidate_cache($this->cache_id); $this->cache_id = 'in_relation_public_' . $this->relation_uid; CachedTemplate::invalidate_cache($this->cache_id); if (PA::$extra['reciprocated_relationship'] == NET_NO) { if ($request_data['do']) { $location = PA_ROUTE_USER_PUBLIC . '/' . $this->relation_uid . "&msg=" . urlencode(__("Relationship estabilished.")); } } else { $location = PA_ROUTE_USER_PRIVATE . '/msg_id=' . urlencode(__("Your request has been sent for approval")); } header('Location:' . PA::$url . $location); } catch (PAException $e) { $message = $e->message; } } $msg_array = array(); $msg_array['failure_msg'] = $msg; $msg_array['success_msg'] = NULL; $redirect_url = NULL; $query_str = NULL; set_web_variables($msg_array, $redirect_url, $query_str); }