//for publishing time
            $announcement->announcement_time = time();
            $announcement->is_active = 1;
            if ($aid) {
                $announcement->content_id = $aid;
            }
            $announcement->save();
            if ($announcement->status == ARCHIVED) {
                $error_msg = "Announcement could not be made live, it is saved as Archieved";
            }
            $error_msg .= "<br>Announcement has been made succesfully";
            $form_data = NULL;
            if (!$aid) {
                //send notification only if announcement is created
                $params['aid'] = $res['aid'];
                auto_email_notification('announcement', $params);
            }
            header("location : {$base_url}/network_announcement.php");
        }
        //if no error
    }
    // $_post
}
// else end
function setup_module($column, $module, $obj)
{
    global $paging, $configure_permission, $form_data;
    if (!$configure_permission) {
        return 'skip';
    }
    $obj->Paging["page"] = $paging["page"];
 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 render_for_ajax()
 {
     $op = $this->params["op"];
     if ($op != 'paging' && empty(PA::$login_user)) {
         return __("Login required");
     }
     switch ($op) {
         case "send_message":
             // actual message sending
             do {
                 require_once PA::$path . "/web/includes/videoplay/common.php";
                 // videoplay-specific stuff
                 // TODO find a more compatoble way to generalize this from videoplay!
                 $subject = trim(strip_tags($this->params["subject"]));
                 if (empty($subject)) {
                     $this->err = "Please give your message a subject.";
                     break;
                 }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = "Please enter a message!";
                     break;
                 }
                 $all_recipients = $this->params["recipients"];
                 if (empty($all_recipients)) {
                     $this->err = "The message has no recipiets!";
                     break;
                 }
                 $login_names = preg_split("/,\\s*/", $all_recipients);
                 $found = array();
                 // user id of all the valid login names
                 $valid_recipients = array();
                 // login name of all the valid login names.
                 $invalid_recipients = array();
                 // names of all the invalid recipients.
                 foreach ($login_names as $login_name) {
                     try {
                         $u = new User();
                         $u->load($login_name);
                         $valid_recipients[$u->user_id] = $u;
                         $valid_recipients['login_names'] = $u->login_name;
                         $valid_recipients['fnames'][] = $u->first_name;
                         $valid_recipients['emails'][] = $u->email;
                     } catch (PAException $e) {
                         $invalid_recipients[] = $login_name;
                     }
                 }
                 $in_reply_to = (int) $this->params['reply_to'] ? (int) $this->params['reply_to'] : 0;
                 $is_draft = FALSE;
                 // validation done - now save the comment
                 $sender_id = PA::$login_user->user_id;
                 if (count($valid_recipients)) {
                     $is_draft = FALSE;
                     // TODO: ensure that we can handle multiple recipients!
                     Message::add_message($sender_id, $valid_recipients['ids'], $valid_recipients['login_names'], $subject, $body, $is_draft, $in_reply_to);
                     // this is to ALSO send out emails
                     for ($counter = 0; $counter < count($valid_recipients['ids']); $counter++) {
                         $params = array('first_name_sender' => PA::$login_user->first_name, 'first_name_recipient' => $valid_recipients['fname'][$counter], 'sender_id' => $sender_id, 'recipient_id' => $valid_recipients['ids'][$counter], 'recipient_email' => $valid_recipients['emails'][$counter], 'sender_url' => url_for('user_blog', array('login' => PA::$login_user->login_name)), 'my_messages_url' => PA::$url . '/' . FILE_MYMESSAGE);
                         auto_email_notification('msg_waiting', $params);
                     }
                     $this->mode = "view_conversations";
                     unset($this->params['view']);
                     $this->note = __("Message sent - thank you for participating!");
                 }
                 $this->send_success = $valid_recipients;
                 $this->send_fail = $invalid_recipients;
                 if (count($invalid_recipients)) {
                     $this->err = __("Couldn't send message, some recipients are not valid.") . implode(', ', $invalid_recipients);
                     break;
                 }
             } while (0);
             break;
         default:
             // just ignore any others
             break;
     }
     return $this->render();
 }
예제 #4
0
                    $User->load($login_name);
                    $valid_recipients['id'][] = $User->user_id;
                    $valid_recipients['name'][] = $User->login_name;
                    $valid_recipients['fname'][] = $User->first_name;
                    $valid_recipients['email'][] = $User->email;
                } catch (PAException $e) {
                    $invalid_recipients[] = $login_name;
                }
            }
            $message = null;
            if (count($valid_recipients)) {
                $is_draft = FALSE;
                Message::add_message($login_uid, $valid_recipients['id'], $valid_recipients['name'], $subject, $body, $is_draft, $in_reply_to);
                for ($counter = 0; $counter < count($valid_recipients['id']); $counter++) {
                    $params = array('first_name_sender' => $_SESSION['user']['first_name'], 'first_name_recipient' => $valid_recipients['fname'][$counter], 'sender_id' => $login_uid, 'recipient_id' => $valid_recipients['id'][$counter], 'recipient_email' => $valid_recipients['email'][$counter], 'sender_url' => url_for('user_blog', array('login' => $_SESSION['user']['name'])), 'my_messages_url' => PA::$url . '/' . FILE_MYMESSAGE);
                    auto_email_notification('msg_waiting', $params);
                }
                $message = 'Message sent successfully to ' . implode(",", $valid_recipients['name']) . '<br />';
            }
            if (count($invalid_recipients)) {
                //some of the recipients are invalid. So displaying the error message for them.
                $message .= 'Message sending failed for ' . implode(",", $invalid_recipients) . ' as user(s) doesn\'t exist';
                $error = true;
            } else {
                // message sent successfully to all the recipients. Redirecting user to inbox.
                header("Location: {$base_url}/mymessage.php?msg=message_sent");
                exit;
            }
        }
    }
}
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;
    }
}
예제 #6
0
 }
 $content_author_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
 $network_owner_name = User::map_ids_to_logins($network_info->owner_id);
 $params['cid'] = $permalink_cid;
 $params['first_name'] = $user->first_name;
 $params['user_id'] = $user->user_id;
 $params['user_image'] = $content_author_image;
 $params['content_title'] = $_POST["blog_title"];
 $params['network_name'] = $network_info->name;
 $params['content_url'] = PA::$url . '/' . FILE_CONTENT . '?cid=' . $permalink_cid;
 $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
    $nid = (int) $_GET['nid'];
    $error = 0;
    if (!$nid) {
        $error = 1;
    }
    try {
        //$location = "http://".$redirect_url.'.'.PA::$domain_suffix.'/web/homepage.php';
        if ($_SESSION['user']['id']) {
            $suc = Network::join($nid, $_SESSION['user']['id']);
            $network = new Network();
            $network->set_params(array('network_id' => $nid));
            $netinfo = $network->get();
            $netinfo = $netinfo[0];
            $msg = "You have successfully joined the '" . stripslashes($netinfo->name) . "' network. Click <a href='http://" . $netinfo->address . "." . PA::$domain_suffix . BASE_URL_REL . "/homepage.php'>here</a> to go to the network.";
            $params['uid'] = $_SESSION['user']['id'];
            auto_email_notification('some_joins_a_network', $params);
        } else {
            //$msg = "Please login first to join the network.";
            header("Location: {$base_url}/login.php?error=1&return=" . urlencode($_SERVER['REQUEST_URI']));
        }
    } catch (PAException $e) {
        $msg .= $e->message;
    }
}
default_exception();
$parameter = '<script type="text/javascript" language="javascript" src="' . $current_theme_path . '/base_javascript.js"></script></script>
<script type="text/javascript" language="javascript" src="' . $current_theme_path . '/javascript/prototype.js"></script>
<script type="text/javascript" language="javascript" src="' . $current_theme_path . '/javascript/scriptaculous.js"></script>';
html_header("Networks in category", $parameter);
$setting_data = ModuleSetting::load_setting(PAGE_NETWORKS_CATEGORY, $uid);
$leftModulesFromDB = $setting_data['left'];
예제 #8
0
function save_post($cid = NULL, $ccid = NULL, $is_album = FALSE, $display_on = 1)
{
    global $user, $network_info;
    $extra = unserialize($network_info->extra);
    $micro_content_post = new SBMicroContent();
    $micro_content_post->set_mc_type($_REQUEST['sb_mc_type']);
    $content = $micro_content_post->format_structured_content();
    $micro_content_post->body = $content;
    $micro_content_post->author_id = $_SESSION['user']['id'];
    $micro_content_post->allow_comments = 1;
    $micro_content_post->trackbacks = $_REQUEST['trackback'];
    $micro_content_post->is_active = 1;
    if ($cid) {
        $micro_content_post->content_id = $cid;
        $condition = array('content_id' => $cid);
        $is_active = ACTIVE;
        if ($extra['network_content_moderation'] == NET_YES) {
            $content = Content::load_all_content_for_moderation(NULL, $condition);
            if (!empty($content)) {
                $is_active = $content[0]['is_active'];
            }
        }
        $micro_content_post->is_active = $is_active;
    }
    if (!$ccid) {
        //independent post which is not part of any contentcollection
        $ccid = -1;
    }
    $micro_content_post->parent_collection_id = $ccid;
    $micro_content_post->display_on = $display_on;
    $sb_content = array();
    $sb_content = SBMicroContent::get_sbtype_id($_REQUEST['sb_mc_type'], $with_name = true);
    $micro_content_post->sbtype_id = $sb_content["sbtype_id"];
    $micro_content_post->title = $_POST[$sb_content["titlefield"]];
    //echo '<pre>';print_r($content);
    $micro_content_post->save();
    $return_array = array('title' => $_POST[$sb_content["titlefield"]], 'body' => $content, 'content_id' => $micro_content_post->content_id);
    if ($ccid != -1 && !$is_album) {
        // Code for checking groups with moderated content.
        //fix me change it for using ContentCollection::get_collection_type()
        $collection = ContentCollection::load_collection($micro_content_post->parent_collection_id, $micro_content_post->author_id);
        //$collection->assert_user_access($_SESSION['user']['id']);
        if ($collection->is_moderated) {
            $Group = new Group();
            $Group->collection_id = $micro_content_post->parent_collection_id;
            $Group->moderate_content($micro_content_post->content_id);
            $return_array['is_moderated'] = 1;
        }
    }
    $permalink_cid = $micro_content_post->content_id;
    $content_author_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
    $params['cid'] = $permalink_cid;
    $params['first_name'] = $user->first_name;
    $params['user_id'] = $user->user_id;
    $params['user_image'] = $content_author_image;
    $params['content_title'] = $micro_content_post->title;
    $params['network_name'] = $network_info->name;
    auto_email_notification('content_posted', $params);
    if ($_POST['route_to_pa_home'] == 1) {
        auto_email_notification('content_posted_to_comm_blog', $params);
    }
    if ($extra['network_content_moderation'] == NET_YES && $network_info->owner_id != $user->user_id) {
        Network::moderate_network_content(-1, $permalink_cid);
        // -1 for contents; not a part of any collection
        $return_array['msg'] = 1004;
    }
    return $return_array;
}
예제 #9
0
         $approve_deny_url = $base_url . '/view_all_members.php?view_type=in_relations&uid=' . $user->user_id;
         // defining array to be sent, to fill message frame
         $params = array('first_name' => $_SESSION['user']['first_name'], 'last_name' => $_SESSION['user']['last_name'], 'user_id' => $_SESSION['user']['id'], 'approve_deny_url' => $approve_deny_url, 'invited_user_name' => $user->login_name, 'requestor_image' => $rel_creater_picture, 'to' => $user->email, 'requested_user_id' => $user->user_id, 'config_site_name' => $config_site_name);
         // send notification
         auto_email_notification_members('relationship_requested', $params);
     } else {
         $params['related_uid'] = $relation_uid;
         $params['related_user'] = $user->first_name;
         $params['user_name'] = $rel_creater->login_name;
         $params['user_id'] = $rel_creater->user_id;
         $params['user_image'] = $rel_creater_picture;
         $params['to'] = $user->email;
         $params['my_friends_url'] = PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=in_relations&uid=' . $relation_uid;
         $params['user_url'] = PA::$url . '/' . FILE_USER_BLOG . '?uid=' . $rel_creater->user_id;
         $params['config_site_name'] = $config_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';
         //for rivers of people
         $activities_extra['info'] = $login_name . ' added new friend with id =' . $relation_uid;
         $extra = serialize($activities_extra);
         $object = $relation_uid;
         Activities::save($login_uid, $activity, $object, $extra, $activities_array);
     }
 }
 //invalidate cache of logged in user's relation module
 $cache_id = 'relation_private_' . $uid;
 CachedTemplate::invalidate_cache($cache_id);
 $cache_id = 'relation_public_' . $uid;
 CachedTemplate::invalidate_cache($cache_id);
예제 #10
0
             $params['group_owner_id'] = $group_owner->user_id;
             $params['group_owner_image'] = $group_owner_image;
             $params['group_name'] = $groupname;
             $params['network_name'] = $network_info->name;
             $params['network_url'] = $base_url;
             $params['group_url'] = PA::$url . '/' . FILE_GROUP . '?gid=' . $result;
             $params['group_owner_url'] = url_for(FILE_USER_BLOG, array('login' => $group_owner->login_name));
             $params['config_site_name'] = $config_site_name;
             $network_owner = new User();
             if ($network_info->type == MOTHER_NETWORK_TYPE) {
                 $network_owner->load(SUPER_USER_ID);
             } else {
                 $network_owner->load((int) $network_info->owner_id);
             }
             $params['network_owner_name'] = $network_owner->first_name;
             auto_email_notification('group_created', $params);
             //for rivers of people
             $activity = 'group_created';
             $activity_extra['info'] = $group_owner->first_name . 'created a new group ';
             $activity_extra['group_name'] = $groupname;
             $activity_extra['group_id'] = $result;
             $activity_extra['group_url'] = $params['group_url'];
             $extra = serialize($activity_extra);
             $object = $result;
             Activities::save($group_owner->user_id, $activity, $object, $extra, $activities_array);
         }
     }
 } catch (PAException $e) {
     if ($e->code == GROUP_PARAMETER_ERROR) {
         $error_msg = $e->message;
         if (empty($groupname)) {
예제 #11
0
 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();
 }
예제 #12
0
 function register($params, $network_info = NULL)
 {
     $this->newuser = new User();
     // filter input parameters (this is the same as filter_all_post())
     $params = Validation::get_input_filter(FALSE)->process($params);
     $login_name = trim($params['login_name']);
     $first_name = trim($params['first_name']);
     $last_name = trim(@$params['last_name']);
     // not mandatory
     $email = trim($params['email']);
     $password = trim($params['password']);
     $confirm_password = trim($params['confirm_password']);
     $validate_array = array('login_name' => 'Login name', 'first_name' => 'First name', 'password' => 'Password', 'confirm_password' => 'Confirm password', 'email' => 'Email');
     $this->msg = '';
     $this->error = FALSE;
     foreach ($validate_array as $key => $value) {
         if (empty($params[$key])) {
             $this->msg .= "\n" . $value . " is mandatory";
             $this->error = TRUE;
         }
     }
     if (strlen($this->msg) > 0) {
         $this->msg = "\n" . "Fields marked with * must not be left empty" . $this->msg;
     }
     $error_login = FALSE;
     if (empty($login_name)) {
         $error_login = TRUE;
         $this->error = TRUE;
     }
     if (is_numeric($login_name)) {
         // Here we check the login name  is numeric or not
         if (strlen($this->msg) > 0) {
             $this->msg .= "\n";
         }
         $this->msg .= "Login name must not be numeric";
         $error_login = TRUE;
         $this->error = TRUE;
     }
     if (is_numeric($first_name)) {
         // Here we check the first  name  is numeric or not
         if (strlen($this->msg) > 0) {
             $this->msg .= "\n";
         }
         $this->msg .= "First name must not be numeric";
         $error_login = TRUE;
         $this->error = TRUE;
     }
     if (is_numeric($last_name)) {
         // Here we check the last name  is numeric or not
         if (strlen($this->msg) > 0) {
             $this->msg .= "\n";
         }
         $this->msg .= "Last name must not be numeric";
         $error_login = TRUE;
         $this->error = TRUE;
     }
     // if error occur than no need to checks these errors
     if (!$this->error) {
         if (!Validation::validate_email($email)) {
             $email_invalid = TRUE;
             $this->array_of_errors['error_email'] = $email_invalid;
             $this->error = TRUE;
             $this->msg .= " E-mail address ({$email}) is not valid";
         }
         if ($password != $confirm_password) {
             $this->msg .= "\nPassword and Confirm Password do not match.";
             $error_password_conf = TRUE;
             $this->error = TRUE;
         }
         if (strlen($password) > 15) {
             $this->msg .= "\nThe password must be less than 15 characters.";
             $error_password_l = TRUE;
             $this->error = TRUE;
         }
         if (strlen($password) < 5) {
             $this->msg .= "\nThe password must be longer than 5 characters.";
             $error_password_g = TRUE;
             $this->error = TRUE;
         }
     }
     if (User::user_exist($login_name)) {
         $this->msg = "Login name {$login_name} is already taken";
         $error_login = TRUE;
         $this->error = TRUE;
     } elseif (User::user_existed($login_name)) {
         $this->msg = "Login name {$login_name} has been used in the past; it belongs to a deleted user.";
         $error_login = $this->error = TRUE;
     }
     $this->array_of_errors = array("error_login" => $error_login, "error_first_name" => @$error_first_name, "error_email" => @$error_email, "error_password_conf" => @$error_password_conf, "error_password_l" => @$error_password_l, "error_password_g" => @$error_password_g);
     if ($this->error != TRUE) {
         $this->newuser->login_name = $login_name;
         //TODO: change to md5
         $this->newuser->password = $password;
         $this->newuser->first_name = $first_name;
         $this->newuser->last_name = $last_name;
         $this->newuser->email = $email;
         if (!empty($params['user_filename'])) {
             $user_fn_base = basename($params['user_filename']);
             if (file_exists(PA::$upload_path . $user_fn_base)) {
                 $this->newuser->picture = $user_fn_base;
             }
         }
         if ($this->error != TRUE) {
             try {
                 $save_error = FALSE;
                 $extra = unserialize($network_info->extra);
                 if ($extra['email_validation'] == NET_NO) {
                     // if email validation not required
                     $this->newuser->is_active = ACTIVE;
                 } else {
                     $this->newuser->is_active = UNVERIFIED;
                 }
                 $this->newuser->save();
                 // saving data in user profile data also -- for searching making more easier
                 $data_array = array(0 => array('uid' => $this->newuser->user_id, 'name' => 'first_name', 'value' => $this->newuser->first_name, 'type' => BASIC, 'perm' => 1), 1 => array('uid' => $this->newuser->user_id, 'name' => 'last_name', 'value' => $this->newuser->last_name, 'type' => BASIC, 'perm' => 1));
                 $this->newuser->save_user_profile($data_array, BASIC);
                 // saving default notification for user from network notification setting
                 $user_notification = array();
                 $profile = array();
                 $user_notification = $extra['notify_members'];
                 $user_notification['msg_waiting_blink'] = $extra['msg_waiting_blink'];
                 $profile['settings']['name'] = 'settings';
                 $profile['settings']['value'] = serialize($user_notification);
                 $this->newuser->save_profile_section($profile, 'notifications');
                 // default notification for user ends
                 $desktop_images = User_Registration::get_default_desktopimage($this->newuser->user_id, $network_info);
                 // code for adding default desktop image for user
                 if ($desktop_images == "") {
                     $desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
                     $rand_key = array_rand($desktop_images);
                     $desk_img = $desktop_images[$rand_key];
                 } else {
                     $desk_img = $desktop_images;
                 }
                 $data_array = array(0 => array('uid' => $this->newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1));
                 //}
                 $this->newuser->save_user_profile($data_array, GENERAL);
                 if ($extra['email_validation'] == NET_NO) {
                     //if email validation is not required
                     // creating message basic folders
                     Message::create_basic_folders($this->newuser->user_id);
                     // adding default relation
                     if ($this->newuser->user_id != SUPER_USER_ID) {
                         User_Registration::add_default_relation($this->newuser->user_id, $network_info);
                     }
                     // adding default media as well as album
                     User_Registration::add_default_media($this->newuser->user_id, '', $network_info);
                     User_Registration::add_default_media($this->newuser->user_id, '_audio', $network_info);
                     User_Registration::add_default_media($this->newuser->user_id, '_video', $network_info);
                     User_Registration::add_default_blog($this->newuser->user_id);
                     //adding default link categories & links
                     User_Registration::add_default_links($this->newuser->user_id);
                     // adding header image
                     User_Registration::add_default_header($this->newuser->user_id);
                     // Making user member of a network if he is registering to PA from a network
                     if (!empty($network_info) && $network_info->type != PRIVATE_NETWORK_TYPE) {
                         Network::join($network_info->network_id, $this->newuser->user_id);
                         $params['uid'] = $this->newuser->user_id;
                         auto_email_notification('some_joins_a_network', $params);
                     }
                 }
             } catch (PAException $e) {
                 $this->msg = $e->message;
                 if ($e->code == USER_EMAIL_NOT_UNIQUE) {
                     $this->msg = "Email Address has already been taken, please enter other email address.";
                 }
                 $save_error = TRUE;
                 if ($e->message == "The email address is invalid.") {
                     $email_invalid = TRUE;
                     $this->array_of_errors['error_email'] = $email_invalid;
                 }
             }
         }
     }
     if ($this->error == TRUE || $save_error == TRUE) {
         $this->msg = "Sorry! your registration failed. " . $this->msg;
         return FALSE;
     }
     // success!
     return TRUE;
 }
예제 #13
0
function route2groups()
{
    global $login_uid, $user, $network_info;
    $extra = unserialize($network_info->extra);
    $tags = explode(',', $_POST['tags']);
    //find tag entry
    foreach ($tags as $term) {
        $tr = trim($term);
        if ($tr) {
            $terms[] = $tr;
        }
    }
    if ($_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
                $res = BlogPost::save_blogpost(0, $login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                $permalink_cid = $res['cid'];
                $content_author_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
                $params['cid'] = $permalink_cid;
                $params['first_name'] = $user->first_name;
                $params['user_id'] = $user->user_id;
                $params['user_image'] = $content_author_image;
                $params['content_title'] = $_POST["blog_title"];
                $params['network_name'] = $network_info->name;
                auto_email_notification('content_posted', $params);
                if ($_POST['route_to_pa_home'] == 1) {
                    auto_email_notification('content_posted_to_comm_blog', $params);
                }
            }
            // update status to unverified
            if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && $network_info->owner_id != $user->user_id) {
                Network::moderate_network_content($gid, $permalink_cid);
            }
        } else {
            // post in selected groups
            foreach ($_POST['route_targets_group'] as $gid) {
                //only send to selected groups
                $res = BlogPost::save_blogpost(0, $login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                $permalink_cid = $res['cid'];
                $content_author_image = uihelper_resize_mk_user_img($user->picture, 80, 80, 'alt="' . $user->first_name . '" align="left" style="padding: 0px 12px 12px 0px;"');
                $params['cid'] = $permalink_cid;
                $params['first_name'] = $user->first_name;
                $params['user_id'] = $user->user_id;
                $params['user_image'] = $content_author_image;
                $params['content_title'] = $_POST["blog_title"];
                $params['network_name'] = $network_info->name;
                auto_email_notification('content_posted', $params);
                if ($_POST['route_to_pa_home'] == 1) {
                    auto_email_notification('content_posted_to_comm_blog', $params);
                }
                // update status to unverified
                if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && $network_info->owner_id != $user->user_id) {
                    Network::moderate_network_content($gid, $permalink_cid);
                }
            }
        }
    }
    return TRUE;
}