function addsubmitAction()
 {
     if ($this->request->isPost() !== false) {
         $activities = new Activities();
         $system_id = $this->request->getPost('system_id');
         $activities->start_hour = $this->request->getPost('start_hour');
         $activities->finish_hour = $this->request->getPost('finish_hour');
         $activities->description = $this->request->getPost('description');
         $activities->date = $this->request->getPost('date');
         $activities->system_id = $system_id;
         $activities->modules_id = $this->request->getPost('modules_id');
         $activities->bugs_id = $this->request->getPost('bugs_id');
         $activities->employees_id = 105;
         #	print_r($this->request->getPost());
         #	exit();
         if ($activities->save() == false) {
             foreach ($activities->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Add New Activity Success');
             $this->response->redirect('activity/system/' . $system_id);
         }
     }
 }
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a video in group id =' . $_GET['gid'];
            break;
        case 'Audios':
            $activity = 'group_audio_upload';
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a audio in group id =' . $_GET['gid'];
            break;
        default:
            break;
    }
    $activities_extra['collection_id'] = $upload['collection_id'];
    $activities_extra['content_id'] = $upload['content_id'];
    $extra = serialize($activities_extra);
    $object = $_GET['gid'];
    Activities::save($login_uid, $activity, $object, $extra);
}
// Code for Re-Direction  After Successfull deletion
if (!empty($success_delete) || !empty($success)) {
    $gid = $_GET['gid'];
    $type = $_GET['type'];
    $location = $ret_url . "&msg_id={$msg_id}";
    header("Location: {$location}");
    exit;
}
$setting_data = array('middle' => array('UploadMediaModule'));
/* This function is a Callback function which initialize the value for the BLOCK MODULES */
function setup_module($column, $moduleName, $obj)
{
    /* in this module we have to set user_id , group_id, as well as netwrok_id */
    global $uid, $type, $album_id;
 $params['content_moderation_url'] = PA::$url . '/' . FILE_NETWORK_MANAGE_CONTENT;
 $params['config_site_name'] = $config_site_name;
 $params['network_owner_name'] = $network_owner_name[$network_info->owner_id];
 auto_email_notification('content_posted', $params);
 if ($_POST['route_to_pa_home'] == 1) {
     auto_email_notification('content_posted_to_comm_blog', $params);
 }
 //for rivers of people
 $activity = 'user_post_a_blog';
 $activity_extra['info'] = $user->first_name . 'posted a new blog';
 $activity_extra['blog_name'] = $params['content_title'];
 $activity_extra['blog_id'] = $permalink_cid;
 $activity_extra['blog_url'] = $params['content_url'];
 $extra = serialize($activity_extra);
 $object = $permalink_cid;
 Activities::save($user->user_id, $activity, $object, $extra, $activities_array);
 //save post in groups
 $routed_to_groups = route2groups();
 // save post to outputthis
 route_to_outputthis($_POST["blog_title"], $_POST["description"]);
 //we have saved it in all the locations lets redirect it to various locations
 if ($_GET['ccid']) {
     $gid = $_GET['ccid'];
     $group = ContentCollection::load_collection((int) $gid, $login_uid);
     $is_member = Group::get_user_type((int) $login_uid, (int) $gid);
     if ($is_member == NOT_A_MEMBER) {
         $msg = "&msg_id=7028";
     } else {
         if ($group->reg_type == REG_MODERATED) {
             $msg = "&msg_id=1004";
         } else {
 private function handleGET_join($request_data)
 {
     require_once "api/Activities/Activities.php";
     global $error_msg;
     if (PA::$login_uid && !empty($this->shared_data['group_info'])) {
         $group = $this->shared_data['group_info'];
         if (!Group::member_exists((int) $request_data['gid'], (int) PA::$login_uid)) {
             $user = PA::$login_user;
             $login_name = $user->login_name;
             $group_invitation_id = !empty($request_data['GInvID']) ? $request_data['GInvID'] : null;
             try {
                 $user_joined = $group->join((int) PA::$login_uid, $user->email, $group_invitation_id);
                 // for rivers of people
                 $activity = 'group_joined';
                 //for rivers of people
                 $activity_extra['info'] = $login_name . ' joined a new group';
                 $activity_extra['group_name'] = $group->title;
                 $activity_extra['group_id'] = $request_data['gid'];
                 $extra = serialize($activity_extra);
                 $object = $request_data['gid'];
                 Activities::save(PA::$login_uid, $activity, $object, $extra);
                 if (!empty($group_invitation_id)) {
                     // if group is joined through group invitation
                     $Ginv = Invitation::load($group_invitation_id);
                     $gid = $Ginv->inv_collection_id;
                     $user_obj = new User();
                     $user_obj->load((int) $Ginv->user_id);
                     $group = ContentCollection::load_collection((int) $gid, $Ginv->user_id);
                     $user_type = Group::get_user_type($user_obj->user_id, $gid);
                     if ($group->reg_type == REG_MODERATED && $user_type == OWNER) {
                         $group->collection_id = $gid;
                         $group->approve(PA::$login_uid, 'user');
                     }
                     $user_accepting_ginv_obj = new User();
                     $user_accepting_ginv_obj->load((int) PA::$login_uid);
                     $Ginv->inv_user_id = PA::$login_uid;
                     PANotify::send("invite_accept_group", $user_obj, $user_accepting_ginv_obj, $Ginv);
                 }
             } catch (PAException $e) {
                 if ($e->code == GROUP_NOT_INVITED) {
                     $error_msg = $e->message;
                     //          header("Location: groups_home.php");
                     //          exit;
                 }
                 $error_msg = $e->message;
             }
         } else {
             $error_msg = sprintf(__("You are already a member of \"%s\""), stripslashes($group->title));
         }
         if (@$user_joined) {
             // deal with TypedGroup Relations
             require_once "api/Entity/TypedGroupEntityRelation.php";
             $uid = PA::$login_uid;
             $gid = $group->collection_id;
             $type = @$request_data['relation'];
             try {
                 TypedGroupEntityRelation::set_relation($uid, $gid, $type);
             } catch (PAException $e) {
                 $error_msg = $e->getMessage();
             }
             $gid = (int) $request_data['gid'];
             if (!Group::member_exists($gid, (int) PA::$login_uid) && $group->reg_type == REG_MODERATED) {
                 // if it is a manual join not an invited join
                 $mail_type = 'group_join_request';
                 $error_msg = sprintf(__("Your request to join \"%s\" has been submitted to the owner of the group."), stripslashes($group->title));
             } else {
                 $mail_type = 'group_join';
                 $error_msg = sprintf(__("You have joined \"%s\" successfully."), stripslashes($group->title));
             }
             PANotify::send($mail_type, $group, PA::$login_user, array());
             if ($type == 'child') {
                 // if user type == child remove LoginUser and GroupMember roles
                 PA::$login_user->delete_user_role();
                 // then assign 'Child' role only
                 $_extra = serialize(array('user' => false, 'network' => false, 'groups' => array($gid)));
                 $user_roles[] = array('role_id' => CHILD_MEMBER_ROLE, 'extra' => $_extra);
                 PA::$login_user->set_user_role($user_roles);
             }
         }
     } else {
         // redirect to login
         $msg = urlencode(__("You need to be logged in to join a group."));
         header("Location: " . PA::$url . "/login.php?" . $msg . "&return=" . urlencode($_SERVER['REDIRECT_URL'] . '?' . @$_SERVER['REDIRECT_QUERY_STRING']));
     }
 }
function route2groups()
{
    global $user, $is_edit;
    $extra = unserialize(PA::$network_info->extra);
    $tags = preg_split('/\\s*,\\s*/', strtolower($_POST['tags']));
    $tags = array_unique($tags);
    $net_owner = new User();
    $net_owner->load((int) PA::$network_info->owner_id);
    $valid_post_types = array('BlogPost', 'Contribution', 'Suggestion');
    $type = isset($_POST) && isset($_POST['blog_type']) && in_array($_POST['blog_type'], $valid_post_types) ? $_POST['blog_type'] : 'BlogPost';
    //find tag entry
    $terms = array();
    foreach ($tags as $term) {
        $tr = trim($term);
        if ($tr) {
            $terms[] = $tr;
        }
    }
    if (!empty($_POST['route_to_pa_home']) && $_POST['route_to_pa_home'] == 1) {
        $display_on_homepage = DISPLAY_ON_HOMEPAGE;
        //its zero
    } else {
        $display_on_homepage = NO_DISPLAY_ON_HOMEPAGE;
        //This will not show up on homepage - flag has opposite values
    }
    if (is_array($_POST['route_targets_group'])) {
        if (in_array(-2, $_POST['route_targets_group'])) {
            //-2 means Select none of group
            // no need to post in any group
        } elseif (in_array(-1, $_POST['route_targets_group'])) {
            //-1 means select all the groups
            // post in all the groups
            $group_array = explode(',', $_POST['Allgroups']);
            foreach ($group_array as $gid) {
                // post to all the groups
                $_group = Group::load_group_by_id((int) $gid);
                $login_required_str = null;
                if ($_group->access_type == ACCESS_PRIVATE) {
                    $login_required_str = '&login_required=true';
                }
                switch ($type) {
                    case 'BlogPost':
                    default:
                        $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Contribution':
                        $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Suggestion':
                        $res = Suggetion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                }
                $permalink_cid = $res['cid'];
                // NOTE: would this notification message be sent for each group ???
                $content_obj = Content::load_content((int) $permalink_cid);
                PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
                // notify network owner (maybe group owner would be better?)
                if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
                    PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
                }
                //-------
                //for rivers of people
                $activity = 'group_post_a_blog';
                $activity_extra['info'] = $user->first_name . 'posted a new blog';
                $activity_extra['blog_name'] = $_POST["blog_title"];
                $activity_extra['blog_id'] = $permalink_cid;
                $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
                $extra = serialize($activity_extra);
                $object = $gid;
                // update status to unverified
                $group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
                if ($group->reg_type == REG_MODERATED) {
                    Network::moderate_network_content((int) $gid, $permalink_cid);
                } else {
                    if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
                        Network::moderate_network_content($gid, $permalink_cid);
                    }
                }
                if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
                    //Write to activity log only when moderation is off
                    Activities::save($user->user_id, $activity, $object, $extra);
                }
            }
        } else {
            // post in selected groups
            foreach ($_POST['route_targets_group'] as $gid) {
                //only send to selected groups
                $_group = Group::load_group_by_id((int) $gid);
                $login_required_str = null;
                if ($_group->access_type == ACCESS_PRIVATE) {
                    $login_required_str = '&login_required=true';
                }
                switch ($type) {
                    case 'BlogPost':
                    default:
                        $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Contribution':
                        $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Suggestion':
                        $res = Suggestion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                }
                $permalink_cid = $res['cid'];
                $content_obj = Content::load_content((int) $permalink_cid);
                PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
                // notify network owner (maybe group owner would be better?)
                if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
                    PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
                }
                //for rivers of people
                $activity = 'group_post_a_blog';
                $activity_extra['info'] = $user->first_name . 'posted a new blog';
                $activity_extra['blog_name'] = $_POST["blog_title"];
                $activity_extra['blog_id'] = $permalink_cid;
                $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
                $extra = serialize($activity_extra);
                $object = $gid;
                // update status to unverified
                $group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
                if ($group->reg_type == REG_MODERATED) {
                    Network::moderate_network_content((int) $gid, $permalink_cid);
                } else {
                    if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
                        Network::moderate_network_content($gid, $permalink_cid);
                    }
                }
                if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
                    //Write to activity log only when moderation is off
                    Activities::save($user->user_id, $activity, $object, $extra);
                }
            }
        }
    }
    return TRUE;
}
 function handlePOST_submitComment($request_data)
 {
     global $error_msg;
     if ($request_data['action'] == 'submitComment' && !empty(PA::$login_uid)) {
         $ccid_string = "";
         if (!empty($request_data['ccid'])) {
             $ccid_string = "&ccid=" . $request_data['ccid'];
         }
         $error_msg = "";
         if (strlen(trim(strip_tags($request_data['comment']))) == 0) {
             $error_msg = "Your comment contains some illegal characters. Please try again.<br>";
         }
         if (trim($request_data['comment']) == '') {
             $error_msg = "Comment can not be left blank<br>";
         }
         if (isset($request_data['name']) && trim($request_data['name']) == '') {
             $error_msg .= "Please enter name<br>";
         }
         if (isset($request_data['email']) && trim($request_data['email']) == '') {
             $error_msg .= "Please enter email address";
         } else {
             if (isset($request_data['email']) && !validate_email($request_data['email'])) {
                 $error_msg .= "Please enter a valid email address";
             }
         }
         /*
               if(strlen($error_msg) > 0) {
                 $location = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $request_data["cid"];
                 $this->controller->redirect($location);
               }
         */
         /* Function for Filtering the POST data Array */
         filter_all_post($request_data);
         if (empty($error_msg)) {
             // no errors occured
             $comment = new Comment();
             $id = trim($request_data['cid']);
             $comment->content_id = $id;
             $comment->subject = '';
             $comment->comment = trim($request_data['comment']);
             if (PA::$login_uid) {
                 $user = new User();
                 $user->load((int) PA::$login_uid);
                 $comment->user_id = $user->user_id;
                 $comment->name = '';
                 $comment->email = '';
                 $comment->homepage = '';
                 unset($request_data['err']);
             } else {
                 $comment->name = trim($request_data['name']);
                 $comment->email = trim($request_data['email']);
                 if (!empty($request_data['homepage'])) {
                     $comment->homepage = validate_url(trim($request_data['homepage']));
                 } else {
                     $comment->homepage = "";
                 }
             }
             // In old method
             $comment->parent_type = TYPE_CONTENT;
             $comment->parent_id = $id;
             if ($comment->spam_check()) {
                 $error_msg = "Sorry, your comment cannot be posted as it looks like spam.  Try removing any links to possibly suspect sites, and re-submitting.";
                 Logger::log("Comment rejected by spam filter", LOGGER_ACTION);
             } else {
                 $error_msg = 'Your comment has been posted successfully';
                 $comment->save();
                 if ($comment->spam_state != SPAM_STATE_OK) {
                     $error_msg = "Sorry, your comment cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites.  Please check the links in your post, and that your name and e-mail address are correct.";
                 } else {
                     //for rivers of people
                     $activity = 'user_post_a_comment';
                     $activity_extra['info'] = $user->display_name . 'has left a comment';
                     $activity_extra['comment_id'] = $comment->comment_id;
                     $activity_extra['content_url'] = PA::$url . PA_ROUTE_CONTENT . "/cid={$id}";
                     $extra = serialize($activity_extra);
                     Activities::save($user->user_id, $activity, $comment->comment_id, $extra);
                     //TO DO: comment should be posted to contents of other network rather then just mother network
                     //$params['cid'] = $comment->content_id;
                     //auto_email_notification('comment_posted', $params );
                     //** when uncommenting the above line, don't forget to uncomment the include of auto_email_notify.php at the top of this file too!
                     unset($request_data);
                     //invalidate cache of content block as it is modified now
                     if (PA::$network_info) {
                         $nid = '_network_' . PA::$network_info->network_id;
                     } else {
                         $nid = '';
                     }
                     //unique name
                     $cache_id = 'content_' . $id . $nid;
                     CachedTemplate::invalidate_cache($cache_id);
                 }
             }
         }
     }
 }
 /** !!
  * This handles the data that is POSTed back to the page upon
  * submission of the form. There is a lot happening in here,
  * but it basically looks at the submitted data, figures out
  * what it is supposed to do with it (based on if the group is
  * being created or modified), then creates a new group or
  * updates the current data using the {@link handle_entity() } method.
  *
  * @param array $request_data  All of the data POSTed back to the form.
  */
 public function handlePOST($request_data)
 {
     require_once "web/includes/classes/CNFileUploader.php";
     require_once "api/CNActivities/CNActivities.php";
     require_once "api/cnapi_constants.php";
     if ($request_data['addgroup']) {
         filter_all_post($request_data);
         $groupname = trim($request_data['groupname']);
         $body = trim($request_data['groupdesc']);
         $tag_entry = trim($request_data['group_tags']);
         $group_category = $request_data['group_category'];
         $header_image = NULL;
         $header_image_action = @$request_data['header_image_action'];
         $display_header_image = @$request_data['display_header_image'];
         $collection_id = NULL;
         $this->extra = NULL;
         if ($request_data['ccid']) {
             $collection_id = (int) $request_data['ccid'];
             $group = new Group();
             $group->load($collection_id);
             // preserve group info we are not editing in this module
             // load group extra
             $extra = $group->extra;
             if (!empty($extra)) {
                 $this->extra = unserialize($extra);
             }
             $header_image = $group->header_image;
             $header_image_action = $group->header_image_action;
             $display_header_image = $group->display_header_image;
         }
         $access = 0;
         // default access is 0 means public
         $reg_type = $request_data['reg_type'];
         if ($reg_type == REG_INVITE) {
             // if reg. type = "Invite" access is PRIVATE
             $access = ACCESS_PRIVATE;
         }
         $is_moderated = 0;
         // is moderated is 0 means contents appear immediately
         $group_tags = $request_data['group_tags'];
         if (empty($request_data['groupname'])) {
             $error_msg = 90222;
         } else {
             if (empty($group_category) && empty($error_msg)) {
                 $error_msg = 90224;
             } else {
                 if (empty($error_msg)) {
                     try {
                         if (empty($_FILES['groupphoto']['name'])) {
                             $upfile = $request_data['file'];
                         } else {
                             $myUploadobj = new FileUploader();
                             //creating instance of file.
                             $image_type = 'image';
                             $file = $myUploadobj->upload_file(PA::$upload_path, 'groupphoto', true, true, $image_type);
                             if ($file == false) {
                                 throw new CNException(GROUP_PARAMETER_ERROR, __("File upload error: ") . $myUploadobj->error);
                             }
                             $upfile = $file;
                             $avatar_uploaded = TRUE;
                         }
                         $exception_message = NULL;
                         $result = Group::save_new_group($collection_id, $_SESSION['user']['id'], $groupname, $body, $upfile, $group_tags, $group_category, $access, $reg_type, $is_moderated, $header_image, $header_image_action, $display_header_image, $this->extra);
                         $ccid = $result;
                         $exception_message = 'Group creation failed: ' . $result;
                         if (!is_numeric($result)) {
                             throw new CNException(GROUP_CREATION_FAILED, $exception_message);
                         } else {
                             if (@$avatar_uploaded) {
                                 Storage::link($upfile, array("role" => "avatar", "group" => (int) $result));
                             }
                             if (@$header_uploaded) {
                                 Storage::link($header_image, array("role" => "header", "group" => (int) $result));
                             }
                             $this->gid = $this->id = $result;
                             if (empty($request_data['gid'])) {
                                 $mail_type = $activity = 'group_created';
                                 $act_text = ' created a new group';
                             } else {
                                 $mail_type = $activity = 'group_settings_updated';
                                 $act_text = ' changed group settings ';
                             }
                             $group = new Group();
                             $group->load((int) $this->gid);
                             PANotify::send($mail_type, PA::$network_info, PA::$login_user, $group);
                             // notify network onwer
                             $_group_url = PA::$url . PA_ROUTE_GROUP . '/gid=' . $result;
                             $group_owner = new User();
                             $group_owner->load((int) $_SESSION['user']['id']);
                             $activity_extra['info'] = $group_owner->first_name . $act_text;
                             $activity_extra['group_name'] = $groupname;
                             $activity_extra['group_id'] = $result;
                             $activity_extra['group_url'] = $_group_url;
                             $extra = serialize($activity_extra);
                             $object = $result;
                             if ($reg_type != REG_INVITE) {
                                 Activities::save($group_owner->user_id, $activity, $object, $extra);
                             }
                             // if we reached here than the group is created
                             if (empty($request_data['gid'])) {
                                 // when a new group is created
                                 // so, we need to assign group admin role to group owner now:
                                 $role_extra = array('user' => false, 'network' => false, 'groups' => array($this->gid));
                                 $user_roles[] = array('role_id' => GROUP_ADMIN_ROLE, 'extra' => serialize($role_extra));
                                 $group_owner->set_user_role($user_roles);
                             }
                             if (!empty(PA::$config->useTypedGroups) && !empty($request_data['type'])) {
                                 $this->gid = $this->id;
                                 switch ($request_data['op']) {
                                     case 'create_entity':
                                     case 'edit_entity':
                                         $this->handleEntity($request_data);
                                         break;
                                 }
                             }
                         }
                     } catch (CNException $e) {
                         if ($e->code == GROUP_PARAMETER_ERROR) {
                             $error_msg = $e->message;
                             if (empty($groupname)) {
                                 $error_msg = 90222;
                             } else {
                                 if (empty($group_category)) {
                                     $error_msg = 90224;
                                 }
                             }
                         } else {
                             $error_msg = $e->message;
                         }
                     }
                 }
             }
         }
     }
     //if form is posted
     $msg_array = array();
     $msg_array['failure_msg'] = @$error_msg;
     $msg_array['success_msg'] = !empty($this->id) ? 90231 : 90221;
     $redirect_url = PA::$url . PA_ROUTE_GROUP;
     $query_str = "?gid=" . @$result;
     set_web_variables($msg_array, $redirect_url, $query_str);
 }
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a video in group id =' . $_GET['gid'];
            break;
        case 'Audios':
            $activity = 'group_audio_upload';
            //for rivers of people
            $activities_extra['info'] = $login_name . ' uploaded a audio in group id =' . $_GET['gid'];
            break;
        default:
            break;
    }
    $activities_extra['collection_id'] = $upload[collection_id];
    $activities_extra['content_id'] = $upload[content_id];
    $extra = serialize($activities_extra);
    $object = $_GET['gid'];
    Activities::save($login_uid, $activity, $object, $extra, $activities_array);
}
// Code for Re-Direction  After Successfull deletion
if (!empty($success_delete) || !empty($success)) {
    $gid = $_GET['gid'];
    $type = $_GET['type'];
    $location = "{$base_url}/group_media_gallery.php?type={$type}&msg_id={$msg_id}&gid={$gid}";
    header("Location: {$location}");
    exit;
}
$setting_data = array('middle' => array('UploadMediaModule'));
/* This function is a Callback function which initialize the value for the BLOCK MODULES */
function setup_module($column, $moduleName, $obj)
{
    /* in this module we have to set user_id , group_id, as well as netwrok_id */
    global $uid, $type, $album_id;
 /** !!
  * 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);
 }
示例#10
0
 function render_for_ajax()
 {
     $op = $this->params["op"];
     // if (empty(PA::$login_user) && $op != "paging") return __("Login required");
     switch ($op) {
         case "flagthis":
             if (empty(PA::$login_user)) {
                 $this->err = __("Please log in or register to flag a review!");
                 break;
             }
             // file the abuse report
             try {
                 list($foo, $review_id) = split(':', $this->params['flag']);
                 $abuse_obj = new ReportAbuse();
                 $abuse_obj->parent_type = 'review';
                 $abuse_obj->parent_id = $review_id;
                 $abuse_obj->reporter_id = PA::$login_uid;
                 // TODO: possibly make this user input
                 $abuse_obj->body = "This review was flagged.";
                 $id = $abuse_obj->save();
                 $this->note = "Your abuse report was filed.";
             } catch (PAException $e) {
                 $this->err = __("There was a problem flagging this review: ") . $e->message;
             }
             break;
         case "add_review":
             do {
                 if (empty(PA::$login_user)) {
                     $this->err = __("Please log in or register to add a review!");
                     break;
                 }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = __("Please enter a review!");
                     break;
                 }
                 // validation done - now save the review
                 $rev = new Review();
                 $rev->author_id = PA::$login_user->user_id;
                 $rev->subject_type = $this->params["subject_type"];
                 $rev->subject_id = $this->params["subject_id"];
                 $rev->title = "";
                 // $title;
                 $rev->body = $body;
                 if (!$rev->save()) {
                     $this->err = __("Save failed.");
                     break;
                 }
                 $this->note = __("Review added - thank you for participating!");
                 // handle tags
                 $tags = trim($this->params["tags"]);
                 if (!empty($tags)) {
                     $tags_array = preg_split('/\\s*,\\s*/', $tags);
                     ItemTags::save_tags_for_item(PA::$login_user->user_id, $this->params["subject_type"], $this->params["subject_id"], $tags_array);
                 }
                 // for rivers of people
                 $activity = 'user_post_a_review';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a review.', 'subject_type' => $rev->subject_type, 'subject_id' => $rev->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } while (0);
             break;
         default:
             // just ignore unknown ops
             break;
     }
     return $this->render();
 }
    $task = Roles::check_permission_by_value(PA::$login_uid, 'manage_content');
    if (($network_extra['network_content_moderation'] == NET_YES && $network_details->owner_id != PA::$login_uid || $moderation) && PA::$login_uid != SUPER_USER_ID) {
        Network::moderate_network_content($new_video->parent_collection_id, $new_video->content_id);
        // is_active = 2 for unverified content
        //     $location .= 1005;
    } else {
        //To send mail to all the members of the organization
        $params['content_type'] = 'Video';
        $params['content_title'] = $new_video->title;
        $params['first_name'] = PA::$user->first_name;
        $params['content_url'] = $redirect_url . '/' . FILE_MEDIA_FULL_VIEW . '?type=Videos&display=videos&cid=' . $new_video->content_id . '&uid=' . PA::$login_uid;
        $params['nid'] = PA::$network_info->network_id;
        //To show this video in recent in system log
        $activity = 'user_video_upload';
        //for rivers of people
        $activity_extra['info'] = PA::$user->first_name . ' uploaded a image in album id = 
		      ' . $new_video->parent_collection_id;
        $activity_extra['content_id'] = $new_video->content_id;
        $extra = serialize($activity_extra);
        Activities::save(PA::$login_uid, $activity, $new_video->content_id, $extra, $activities_array);
        //     $location .= 2003;
    }
    // Here we redirect with successful messages
    header("Location: {$location}");
    exit;
} else {
    $redirector = PA::$url . '/media/gallery/Videos/uid=' . PA::$login_uid;
    header("Location: {$redirector}");
    exit;
    // Code when video is not successfully uploaded
}
 function render_for_ajax()
 {
     $this->anon = TRUE;
     if (!empty(PA::$login_user)) {
         $login_id = PA::$login_user->user_id;
         $this->anon = FALSE;
     }
     switch ($this->params["op"]) {
         case "add_fan":
             if ($this->anon) {
                 $this->err = __("Please log in or register to add yourself as a fan!");
                 break;
             }
             $this->subject_type = $this->params['subject_type'];
             $this->subject_id = $this->params['subject_id'];
             // actual add of fan goes here
             try {
                 $fan = new Fan();
                 $fan->subject_type = $this->subject_type;
                 $fan->subject_id = $this->subject_id;
                 $fan->user_id = PA::$login_user->user_id;
                 $fan->user_displayname = @PA::$login_user->display_login_name ? PA::$login_user->display_login_name : PA::$login_user->login_name;
                 $fan->user_fullname = @PA::$login_user->first_name . " " . @PA::$login_user->last_name;
                 $fan->save();
                 $this->note = __("You are now a fan - thank you for participating!");
                 // for rivers of people
                 $activity = 'user_add_fanof';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' became a fan.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } catch (PAException $e) {
                 $this->err = __("There was a problem adding as a fan: ") . $e->getMessage();
             }
             break;
         case "remove_fan":
             if ($this->anon) {
                 $this->err = __("Please log in or register to remove yourself as a fan!");
                 break;
             }
             $this->subject_type = $this->params['subject_type'];
             $this->subject_id = $this->params['subject_id'];
             // actual removal of fan goes here
             try {
                 Fan::remove(PA::$login_user->user_id, $this->subject_type, $this->subject_id);
                 $this->note = __("You are no longer a fan - thank you for participating!");
                 // for rivers of people
                 $activity = 'user_remove_fanof';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' is no longer a fan.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } catch (PAException $e) {
                 $this->err = __("There was a problem removing as a fan: ") . $e->getMessage();
             }
             break;
         default:
             // just ignore unknown ops
             break;
     }
     return $this->render();
 }
示例#13
0
 function render_for_ajax()
 {
     $op = $this->params["op"];
     // if ($op != 'paging' && empty(PA::$login_user)) return __("Login required");
     switch ($op) {
         case "flagthis":
             if (empty(PA::$login_user)) {
                 $this->err = __("Please log in or register to flag a comment!");
                 break;
             }
             // file the abuse report
             try {
                 list($foo, $comment_id) = split(':', $this->params['flag']);
                 $abuse_obj = new ReportAbuse();
                 $abuse_obj->parent_type = 'comment';
                 $abuse_obj->parent_id = $comment_id;
                 $abuse_obj->reporter_id = PA::$login_uid;
                 // TODO: possibly make this user input
                 $abuse_obj->body = "This comment was flagged.";
                 $id = $abuse_obj->save();
                 $this->note = "Your abuse report was filed.";
             } catch (PAException $e) {
                 $this->err = __("There was a problem flagging this comment: ") . $e->message;
             }
             break;
         case "add_comment":
             do {
                 if (empty(PA::$login_user)) {
                     $this->err = __("Please log in or register to post enter a comment!");
                     break;
                 }
                 // $title = trim($this->params["title"]);
                 // if (empty($title)) { $this->err = "Please give your comment a title."; break; }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = "Please enter a comment!";
                     break;
                 }
                 // validation done - now save the comment
                 $comm = new Comment2();
                 $comm->author_id = PA::$login_user->user_id;
                 $comm->subject_type = $this->params["subject_type"];
                 $comm->subject_id = $this->params["subject_id"];
                 $comm->title = $title;
                 $comm->body = $body;
                 if (!$comm->save()) {
                     $this->err = __("Save failed.");
                     break;
                 }
                 $this->note = __("Comment added - thank you for participating!");
                 // for rivers of people
                 $activity = 'user_post_a_comment';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a comment.', 'subject_type' => $comm->subject_type, 'subject_id' => $comm->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } while (0);
             break;
         default:
             // just ignore any others
             break;
     }
     return $this->render();
 }
示例#14
0
 function render_for_ajax()
 {
     $this->anon = TRUE;
     if (!empty(PA::$login_user)) {
         $login_id = PA::$login_user->user_id;
         $this->anon = FALSE;
     }
     switch ($this->params["op"]) {
         /*
         case "add_oneliner":
           Oneliners::create(
             @(int)$login_id, 
             $this->params['genre'], 
             (int)$this->params['rating'], 
             $this->params['body'], 
             TRUE); // change to FALSE for production once we have approval UI
           $this->note = __("Your One-liner submission was received - thank you for participating!")
             . " \n" . __("Your submisssion will appear if it is approved by our staff.");
           break;
         */
         case "add_rating":
             if ($this->anon) {
                 $this->err = __("Please log in or register to add ratings!");
                 break;
             }
             $rating = new Rating();
             $this->subject_type = $this->params['subject_type'];
             $this->subject_id = $this->params['subject_id'];
             $rating->set_rating_type($this->subject_type);
             $rating->set_type_id($this->subject_id);
             $rating->set_rating((int) $this->params['rating']);
             $rating->set_max_rating(5);
             $rating->set_user_id(@(int) $login_id);
             try {
                 $rating->rate();
                 // for rivers of people
                 $activity = 'user_post_a_rating';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a rating.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } catch (PAException $e) {
                 return $e->getMessage();
                 break;
             }
             $this->note = __("Rating was added - thank you for participating!");
             // $this->add_oneliner = true; // flag it so we can ask for Onle-liner
             break;
         default:
             // just ignore unknown ops
             break;
     }
     return $this->render();
 }
 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) {
                         // if relationship has been made then send mail to the requestor
                         $this->note = __("You approved the friend request successfully.");
                         Relation::add_relation($user_id, $relation_id);
                         // for rivers of people
                         // notif approval
                         $activity = 'user_friend_approved';
                         $extra = serialize(array('info' => PA::$login_user->login_name . ' approved  relation with id = ' . $relation_id));
                         Activities::save(PA::$login_uid, $activity, $relation_id, $extra, array($activity));
                         // notify the originator direction also
                         $activity = 'user_friend_added';
                         $ou = new User();
                         $ou->load((int) $relation_id);
                         $extra = serialize(array('info' => $ou->login_name . ' added new relation with id = ' . PA::$login_user->login_name));
                         Activities::save($relation_id, $activity, PA::$login_uid, $extra, array($activity));
                         $from = PA::$login_user->email;
                         $requested_user = User::map_ids_to_logins($relation_id);
                         if (PA::$network_info->type == MOTHER_NETWORK_TYPE) {
                             $network_owner_id = SUPER_USER_ID;
                         } else {
                             $network_owner_id = PA::$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;
                         $params = array('first_name' => PA::$login_user->first_name, 'last_name' => PA::$login_user->last_name, 'user_name' => PA::$login_user->login_name, 'invited_user_id' => $relation_id, 'user_id' => $user_id, 'invited_user_name' => $requested_user[$relation_id], 'relation_type' => $relation_type, 'network_name' => PA::$network_info->name, 'member_count' => PA::$network_info->member_count, 'reci_relation_count' => $rel_count, 'network_owner_name' => $net_user->first_name, 'to' => $this->params['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' => PA::$site_name);
                         // send mail to proper notification
                         auto_email_notification_members('invitation_accept', $params);
                         // add check for network owner's notification
                         $extra = unserialize(PA::$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, $params);
                         }
                     }
                 } catch (PAException $e) {
                     $this->err = __("There was a problem with adding the relation: ") . $e->getMessage();
                 }
             } while (0);
             break;
         default:
             // just ignore any others
             $this->note = "Unknown operation {$op}.";
             break;
     }
     return $this->render();
 }