/**
  * deny the invitation
  * @access public
  * @param int $inv_id invitation ID
  */
 public function deny()
 {
     Logger::log("Enter: Invitation::deny() | Args:  \$inv_id = {$inv_id}");
     $res = Dal::query("SELECT user_id FROM {invitations} WHERE inv_id = ?", array($this->inv_id));
     if ($res->numRows()) {
         $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
         $u = new User();
         $u->load((int) $row->user_id);
         $user = new User();
         $user->load((int) $this->inv_user_id);
         // data for passing in common mail method
         $array_of_data = array('first_name' => $user->first_name, 'last_name' => $user->last_name, 'user_name' => $user->login_name, 'user_id' => $user->user_id, 'group_name' => $this->inv_group_name);
     }
     $res = Dal::query("UPDATE {invitations} SET inv_status= ? WHERE inv_id = ?", array(INVITATION_DENIED, $this->inv_id));
     if ($this->inv_collection_id == -1) {
         $mail_type = "invite_deny_pa";
     } else {
         $mail_type = "invite_deny_group";
     }
     // calling common mailing method
     $check = pa_mail($u->email, $mail_type, $array_of_data);
     Logger::log("Exit: Invitation::deny()");
 }
 function switch_destination($destination)
 {
     $this->no_id = "";
     if (empty($this->mail_type)) {
         $this->mail_type = '';
         //none
     }
     if (empty($this->network_owner)) {
         // sometime group_owner param passed as recepient in this var - VERY BAD!
         $net_owner = new User();
         $net_owner->load((int) PA::$network_info->owner_id);
         $this->network_owner = $net_owner->login_name;
     }
     // checking whether subject or message is set or not
     $msg_data = EmailMessages::get($this->mail_type, $this->mail_sub_msg_array);
     $this->subject = @$msg_data['subject'];
     $this->message = @$msg_data['message'];
     if (empty($this->subject)) {
         $this->subject = 'none';
     }
     if (empty($this->message)) {
         $this->message = 'Message for internal mail is under construction. <br /><br /> We\'ll back with appropriate message soon!!!';
     }
     if ($this->mail_type == 'friend_request') {
         $mail_from = $_SESSION['user']['email'];
     }
     switch ($destination) {
         case NET_EMAIL:
             //external mail
             $check = pa_mail($this->to, $this->mail_type, $this->mail_sub_msg_array, @$mail_from);
             break;
         case NET_MSG:
             //internal messageing
             Message::add_message($this->from, $this->no_id, $this->network_owner, $this->subject, $this->message);
             $sender = new User();
             $sender->load((int) $this->from);
             $sender_id = $sender->user_id;
             $sender_name = $sender->login_name;
             $recipient_id = User::map_logins_to_ids($this->network_owner);
             $_sender_url = url_for('user_blog', array('login' => $sender->login_name));
             $sender_url = "<a href=\"{$_sender_url}\">{$_sender_url}</a>";
             $my_messages_url = '<a href="' . PA::$url . '/' . FILE_MYMESSAGE . '">' . PA::$url . '/' . FILE_MYMESSAGE . '</a>';
             $recipient_obj = new User();
             foreach ($recipient_id as $key => $value) {
                 $recipient_obj->load((int) $value);
             }
             // send msg waiting blink message
             $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => PA::$site_name);
             auto_email_notification('msg_waiting', $params);
             break;
         case NET_BOTH:
             // via both option
             // FIXME: $mail_from seems not be set on peepagg
             try {
                 $check = pa_mail($this->to, $this->mail_type, $this->mail_sub_msg_array, @$mail_from);
             } catch (PAEXception $e) {
                 Logger::log(__FILE__ . ": pa_mail: " . $e->getMessage());
             }
             Message::add_message($this->from, $this->no_id, $this->network_owner, $this->subject, $this->message);
             $sender = new User();
             $sender->load((int) $this->from);
             $sender_id = $sender->user_id;
             $sender_name = $sender->login_name;
             $recipient_id = User::map_logins_to_ids($this->network_owner);
             $_sender_url = url_for('user_blog', array('login' => $sender->login_name));
             $sender_url = "<a href=\"{$_sender_url}\">{$_sender_url}</a>";
             $my_messages_url = '<a href="' . PA::$url . '/' . FILE_MYMESSAGE . '">' . PA::$url . '/' . FILE_MYMESSAGE . '</a>';
             $recipient_obj = new User();
             foreach ($recipient_id as $key => $value) {
                 $recipient_obj->load((int) $value);
             }
             // send msg waiting blink message
             $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => PA::$site_name);
             // chnaged by Martin: this is NET_BOTH, the user is already recieving it as email
             // so why do we also trigger the ms_waiting here?
             // auto_email_notification('msg_waiting', $params);
             break;
     }
 }
function switch_destination($destination)
{
    global $to, $mail_type, $mail_sub_msg_array, $from, $no_id, $network_owner, $subject, $message, $config_site_name;
    // these should be instance vars, not globals!
    $no_id = "";
    if (empty($mail_type)) {
        $mail_type = '';
        //none
    }
    // checking whether subject or message is set or not
    $msg_data = EmailMessages::get($mail_type, $mail_sub_msg_array);
    $subject = $msg_data['subject'];
    $message = $msg_data['message'];
    if (empty($subject)) {
        $subject = 'none';
    }
    if (empty($message)) {
        $message = 'Message for internal mail is under construction. <br /><br /> We\'ll back with appropriate message soon!!!';
    }
    if ($mail_type == 'friend_request') {
        $mail_from = $_SESSION['user']['email'];
    }
    switch ($destination) {
        case NET_EMAIL:
            //external mail
            $check = pa_mail($to, $mail_type, $mail_sub_msg_array, @$mail_from);
            break;
        case NET_MSG:
            //internal messageing
            Message::add_message($from, $no_id, $network_owner, $subject, $message);
            $sender = new User();
            $sender->load((int) $from);
            $sender_id = $sender->user_id;
            $sender_name = $sender->login_name;
            $recipient_id = User::map_logins_to_ids($network_owner);
            $sender_url = url_for('user_blog', array('login' => $sender->login_name));
            $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE;
            $recipient_obj = new User();
            foreach ($recipient_id as $key => $value) {
                $recipient_obj->load((int) $value);
            }
            // send msg waiting blink message
            $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => $config_site_name);
            auto_email_notification('msg_waiting', $params);
            break;
        case NET_BOTH:
            // via both option
            // FIXME: $mail_from seems not be set on peepagg
            $check = pa_mail($to, $mail_type, $mail_sub_msg_array, @$mail_from);
            Message::add_message($from, $no_id, $network_owner, $subject, $message);
            $sender = new User();
            $sender->load((int) $from);
            $sender_id = $sender->user_id;
            $sender_name = $sender->login_name;
            $recipient_id = User::map_logins_to_ids($network_owner);
            $sender_url = url_for('user_blog', array('login' => $sender->login_name));
            $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE;
            $recipient_obj = new User();
            foreach ($recipient_id as $key => $value) {
                $recipient_obj->load((int) $value);
            }
            // send msg waiting blink message
            $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => $config_site_name);
            auto_email_notification('msg_waiting', $params);
            break;
    }
}
        $subject = $_POST['title'];
        $message = nl2br($_POST['bulletin_body']);
        // say $container_html is '/default_email_container.tpl'
        $container_html = 'default_email_container.tpl';
        $email_container =& new Template($path_prefix . '/web/Themes/Beta/email_container/' . $container_html);
        $email_container->set('subject', $subject);
        $email_container->set('message', $message);
        $preview_msg = $email_container->fetch();
    } else {
        if (@$_POST['send_to_me_only']) {
            filter_all_post($_POST);
            $subject = $_POST['title'];
            $message = nl2br($_POST['bulletin_body']);
            $owner_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
            $send_to_me_array = array('user_id' => $user->user_id, 'subject' => $subject, 'message' => $message, 'owner_image' => $owner_image, 'user_name' => $user->first_name, 'config_site_name' => $config_site_name);
            $check = pa_mail($user->email, 'bulletins', $send_to_me_array, $user->email);
            $error_msg = "Bulletin has been sent to you.";
        }
    }
}
function setup_module($column, $module, $obj)
{
    global $configure_permission, $preview_msg;
    if (!$configure_permission) {
        return 'skip';
    }
    switch ($module) {
        case 'NetworkBulletinsModule':
            $obj->preview_msg = $preview_msg;
            break;
    }
Beispiel #5
0
                $user = new User();
                $user->load((int) $login_uid);
                $invitee_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
                $group_icon_image = uihelper_resize_mk_img('files/' . $group->picture, 219, 35, 'files/' . DEFAULT_NETWORK_ICON, 'alt="' . $group->title . '"');
                $user_type = Group::get_user_type($login_uid, $gid);
                if ($user_type == OWNER) {
                    $mail_type = 'invite_group';
                } else {
                    if ($user_type == MEMBER) {
                        $mail_type = 'invite_group_by_member';
                    }
                }
                $group_url = $base_url . '/group.php?gid=' . $inv->inv_collection_id;
                $invitee_url = url_for('user_blog', array('login' => $user->login_name));
                $array_of_data = array('first_name' => $user->first_name, 'last_name' => $user->last_name, 'user_name' => $user->login_name, 'user_id' => $user->user_id, 'message' => $inv->inv_message, 'group_name' => $inv->inv_group_name, 'accept_url' => $inv->accept_url, 'register_url' => $inv->register_url, 'invited_user_name' => $inv->inv_user_first_name, 'invitee_image' => $invitee_image, 'group_id' => $inv->inv_collection_id, 'group_description' => $group->description, 'group_icon_image' => $group_icon_image, 'group_url' => $group_url, 'network_name' => $network_info->name, 'invitee_url' => $invitee_url, 'config_site_name' => $config_site_name);
                $check = pa_mail($inv->inv_email, $mail_type, $array_of_data, $user->email);
                $succ_msg .= $valid_user_first_emails[$counter] . ', ';
                if ($counter == $valid_cnt - 1) {
                    $succ_msg = substr($succ_msg, 0, -2);
                    //$msg_1[] = "Invitation has been sent successfully to -" . $succ_msg;
                }
            }
        }
        // end for : invitation to multiple email
    }
}
//..do invite
if (!empty($msg)) {
    $msg = array_reverse($msg);
    for ($counter = 0; $counter < count($msg); $counter++) {
        $message .= $msg[$counter] . "<br />";
 $newuser->save();
 // saving data in user profile data also -- for searching making more easier
 $data_array = array(0 => array('uid' => $newuser->user_id, 'name' => 'first_name', 'value' => "{$newuser->first_name}", 'type' => BASIC, 'perm' => 1), 1 => array('uid' => $newuser->user_id, 'name' => 'last_name', 'value' => "{$newuser->last_name}", 'type' => BASIC, 'perm' => 1));
 $newuser->save_user_profile($data_array, BASIC);
 // creating message basic folders
 Message::create_basic_folders($newuser->user_id);
 //token creation
 $expires = 3600 * 24 * 5;
 //5days
 $token = $newuser->get_auth_token($expires);
 $user_url = $base_url . '/mail_action.php?token=' . $token . '&action=user';
 $edit_url = $base_url . '/mail_action.php?token=' . $token . '&action=profile';
 $array_of_data = array('first_name' => $newuser->first_name, 'network_name' => $network_info->name, 'user_name' => $newuser->login_name, 'password' => $password, 'user_id' => $_SESSION['user']['id'], 'user_url' => $user_url, 'edit_url' => $edit_url, 'greeting_msg' => $_POST['greeting_msg'], 'config_site_name' => $config_site_name);
 $inv_user_email = $newuser->email;
 $mail_type = 'create_new_user_by_admin';
 $check = pa_mail($inv_user_email, $mail_type, $array_of_data, $_SESSION['user']['email']);
 // adding default relation
 if ($newuser->user_id != SUPER_USER_ID) {
     User_Registration::add_default_relation($newuser->user_id, $network_info);
 }
 // adding default media as well as album
 User_Registration::add_default_media($newuser->user_id, '', $network_info);
 User_Registration::add_default_media($newuser->user_id, '_audio', $network_info);
 User_Registration::add_default_media($newuser->user_id, '_video', $network_info);
 User_Registration::add_default_blog($newuser->user_id);
 //adding default link categories & links
 User_Registration::add_default_links($newuser->user_id);
 // code for adding default desktop image for user
 $desk_img = uihelper_add_default_desktopimage($newuser->user_id);
 if (empty($desk_img)) {
     $desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
Beispiel #7
0
 function handle_join()
 {
     global $network_info;
     $invitation_id = isset($_REQUEST['InvID']) ? $_REQUEST['InvID'] : null;
     $group_invitation_id = isset($_REQUEST['GInvID']) ? $_REQUEST['GInvID'] : null;
     $mother_network_info = Network::get_mothership_info();
     $extra = unserialize($mother_network_info->extra);
     if (!$this->reg_user->register($_POST, $network_info)) {
         // registration failed
         return;
     }
     if ($extra['email_validation'] == NET_NO) {
         // Success!
         register_session($this->reg_user->newuser->login_name, $this->reg_user->newuser->user_id, $this->reg_user->newuser->role, $this->reg_user->newuser->first_name, $this->reg_user->newuser->last_name, $this->reg_user->newuser->email, $this->reg_user->newuser->picture);
         if ($invitation_id) {
             // if an invitation to join a network
             $this->inv_error = "";
             $is_valid = Invitation::validate_invitation_id($invitation_id);
             if (!$is_valid) {
                 $msg = 7017;
                 // invalid network invitation
             }
             if (empty($msg)) {
                 try {
                     // try to except invitation
                     $new_invite = new Invitation();
                     $new_invite->inv_id = $invitation_id;
                     $new_invite->inv_user_id = $this->reg_user->newuser->user_id;
                     $new_invite->accept();
                     $inv_obj = Invitation::load($invitation_id);
                     $user_obj = new User();
                     $user_obj->load((int) $inv_obj->user_id);
                     //if invitation is for private network
                     if ($network_info->type == PRIVATE_NETWORK_TYPE) {
                         $user_type = NULL;
                         if ($network_info->owner_id == $inv_obj->user_id) {
                             $user_type = NETWORK_MEMBER;
                         }
                         Network::join($network_info->network_id, $this->reg_user->newuser->user_id, $user_type);
                     }
                     $msg = 7016;
                     $relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $this->reg_user->newuser->user_id);
                     $relation_type = Relation::lookup_relation_type($relation_type_id);
                     $invited_user_url = url_for('user_blog', array('login' => $this->reg_user->newuser->login_name));
                     // data for passing in common mail method
                     $array_of_data = array('first_name' => $this->reg_user->newuser->first_name, 'last_name' => $this->reg_user->newuser->last_name, 'user_name' => $this->reg_user->newuser->login_name, 'user_id' => $this->reg_user->newuser->user_id, 'invited_user_id' => $inv_obj->user_id, 'invited_user_name' => $user_obj->login_name, 'mail_type' => 'invite_accept_pa', 'to' => $user_obj->email, 'network_name' => $network_info->name, 'relation_type' => $relation_type, 'config_site_name' => PA::$site_name, 'invited_user_url' => $invited_user_url);
                     auto_email_notification_members('invitation_accept', $array_of_data);
                 } catch (PAException $e) {
                     $this->inv_error = $e->message;
                     $this->reg_user->msg = "{$e->message}";
                     $error_inv = TRUE;
                 }
                 if ($error_inv == TRUE) {
                     // if invitation fails, then do login again
                     header("Location: " . PA::$url . "/login.php?msg=" . $this->reg_user->msg . "&return={$return_url}");
                     exit;
                 }
             }
             $redirect_url = 'homepage.php?msg=' . $msg;
         } else {
             if ($group_invitation_id) {
                 // if an invitation to join a group
                 // User registration is in response to a group invitation, so
                 // now that the user is registered, handle the group invitation.
                 try {
                     $is_valid_ginv = Invitation::validate_group_invitation_id($group_invitation_id);
                     if (!$is_valid_ginv) {
                         $msg = 3001;
                     }
                 } catch (PAException $e) {
                     $this->inv_error = "{$e->message}";
                 }
                 if (empty($msg)) {
                     //if group invitation is valid, and no error yet
                     try {
                         $new_invite = new Invitation();
                         $new_invite->inv_id = $group_invitation_id;
                         $new_invite->inv_user_id = $this->reg_user->newuser->user_id;
                         $new_invite->accept();
                         //get collection_id
                         $Ginv = Invitation::load($group_invitation_id);
                         $gid = $Ginv->inv_collection_id;
                     } catch (PAException $e) {
                         $this->reg_user->msg = "{$e->message}";
                         $this->reg_user->error = TRUE;
                         print $this->reg_user->msg;
                     }
                     $redirect_url = "group.php?gid={$gid}&action=join&GInvID={$group_invitation_id}";
                 } else {
                     //else redirect registered user to its page.
                     $redirect_url = "user.php?msg_id={$msg}";
                 }
                 // end of if group invitation is valid
             }
         }
         if (empty($redirect_url)) {
             // if no url is set yet
             // not a group invitation, so redirect to private user page when done
             $redirect_url = "user.php";
         }
         header("Location: " . PA::$url . "/{$redirect_url}");
         exit;
     } else {
         $expires = LONG_EXPIRES;
         // for 15 days
         $user = new User();
         $user->login_name = $this->reg_user->newuser->login_name;
         $user->password = $this->reg_user->newuser->password;
         $token = $user->get_auth_token($expires);
         if (!empty($invitation_id)) {
             $invitation = '&InvID=' . $invitation_id;
         } else {
             if (!empty($group_invitation_id)) {
                 $invitation = '&GInvID=' . $group_invitation_id;
             } else {
                 $invitation = NULL;
             }
         }
         $name = $user->login_name;
         $activation_url = PA::$url . '/mail_action.php?action=activate&token=' . $token . $invitation;
         $subject = 'Hi ' . $this->reg_user->newuser->login_name . '!  Please activate your ' . PA::$site_name . ' account.';
         $message = "Hi {$name} , \n Activate your people aggregator account by clicking the following link: \n {$activation_url}";
         $to = $this->reg_user->newuser->email;
         $mail_type = 'activate_account';
         $array_of_data = array('subject' => $subject, 'message' => $message);
         // send mail
         $check = pa_mail($to, $mail_type, $array_of_data);
         // redirect to home page.
         header("Location: " . PA::$url . "/homepage.php?msg=7013");
         exit;
     }
     //end if email validation is set
 }
        try {
            $content = Content::load_content((int) $_REQUEST['cid'], (int) PA::$login_uid);
            if ($content->parent_collection_id != -1) {
                $collection = ContentCollection::load_collection((int) $content->parent_collection_id, PA::$login_uid);
                if ($collection->type == GROUP_COLLECTION_TYPE) {
                    $group_owner_id = Group::get_admin_id((int) $content->parent_collection_id);
                    $group_owner = new User();
                    $group_owner->load((int) $group_owner_id['user_id']);
                    $to_group_owner = $group_owner->email;
                    $mail_type = 'report_abuse_grp_owner';
                    $mail_sub_msg_array['login_name'] = $group_owner->login_name;
                    $mail_sub_msg_array['group_name'] = $collection->title;
                    $mail_sub_msg_array['delete_url'] .= '&gid=' . $content->parent_collection_id;
                    $mail_sub_msg_array['group_url'] .= $base_url . '/group.php?gid=' . $content->parent_collection_id;
                    $mail_sub_msg_array['config_site_name'] = $config_site_name;
                    $check = pa_mail($to_group_owner, $mail_type, $mail_sub_msg_array);
                    $error_message = 9002;
                }
            }
        } catch (PAException $e) {
            //catch none
        }
        $_POST = array();
    } else {
        $error_message = 9004;
    }
}
if (!empty($error_message)) {
    $location = $base_url . "/content.php?cid=" . $_GET["cid"] . "&err=" . urlencode($error_message) . $ccid_string;
}
/**
Beispiel #9
0
 public static function send_email_to_change_password($email)
 {
     Logger::log("Enter: function User::send_email");
     global $base_url;
     global $config_site_name;
     $email_exist = User::get_user_data($email);
     if ($email_exist['email_exist'] == TRUE) {
         $first_name = $email_exist['first_name'];
         $last_name = $email_exist['last_name'];
         $user_name = $email_exist['login_name'];
         $password = $email_exist['password'];
         $user_id = $email_exist['user_id'];
         $status = 0;
         $forgot_password_id = md5(uniqid(rand()));
         //print "FORGOT::".$forgot_password_id; exit;
         // insert data into the database
         $sql = 'INSERT into {forgot_password} (user_id, forgot_password_id, status) values (?, ?, ?)';
         $data = array($user_id, $forgot_password_id, $status);
         $res = Dal::query($sql, $data);
         //print "FORGOT after::".$forgot_password_id; print_r($sql); exit;
         $change_password_url = PA::$url . '/' . FILE_CHANGE_PASSWORD . '?log_nam=' . $user_name . '&amp;uid=' . $user_id . '&amp;forgot_password_id=' . $forgot_password_id;
         $array_of_data = array('first_name' => $first_name, 'last_name' => $last_name, 'config_site_name' => $config_site_name, 'user_name' => $user_name, 'user_id' => $user_id, 'change_password_url' => $change_password_url);
         // calling common mailing method using flag (type=forgot_password)
         $check = pa_mail($email, 'forgot_password', $array_of_data);
         if ($check == FALSE) {
             Logger::log("Throwing exception MAIL_FUNCTION_FAILED | Mail is not sent to friend ", LOGGER_ERROR);
             throw new PAException(MAIL_FUNCTION_FAILED, "Mail is not sent to friend");
         }
     }
     Logger::log("Exit: function User::send_email");
 }
 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();
 }
            $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);
            }
        }
    } 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