function register($params, $network_info = NULL) { $core_id = null; $picture = null; $picture_dimensions = null; $avatar = null; $avatar_dimensions = null; $avatar_small = null; $avatar_small_dimensions = null; $this->newuser = new User(); // set API call variable $this->newuser->api_call = $this->api_call; // filter input parameters (this is the same as filter_all_post()) $params = Validation::get_input_filter(FALSE)->process($params); $this->error = false; $mother_network_info = Network::get_mothership_info(); $mother_extra = unserialize($mother_network_info->extra); if (@$mother_extra['captcha_required'] == NET_YES) { // added by Z.Hron - if captcha is required //Providing the capcha check if (md5(strtoupper($_POST['txtNumber'])) != $_SESSION['image_random_value']) { $_SESSION['image_is_logged_in'] = true; $_SESSION['image_random_value'] = ''; $error_login = true; $this->error = true; $this->msg .= "\nPlease enter correct code"; } } if (!$this->error) { $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']); if ($this->api_call == true) { $core_id = $params['core_id']; // TODO: validate URL $picture = trim($params['profile_picture_url']); $picture_dimensions = $params['profile_picture_dimensions']; $avatar = trim($params['profile_avatar_url']); $avatar_dimensions = $params['profile_avatar_dimensions']; $avatar_small = trim($params['profile_avatar_small_url']); $avatar_small_dimensions = $params['profile_avatar_small_dimensions']; } $date_created = !empty($params['date_created']) ? $params['date_created'] : null; $_years = PA::getYearsList(); $dob_day = !empty($params['dob_day']) ? trim($params['dob_day']) : null; // General data (why? should be personal) $dob_month = !empty($params['dob_month']) ? trim($params['dob_month']) : null; // General data (why? should be personal) $dob_year = !empty($params['dob_year']) ? $_years[(int) trim($params['dob_year'])] : null; // General data (why? should be personal) $homeAddress1 = !empty($params['homeAddress1']) ? trim($params['homeAddress1']) : null; // General data $homeAddress2 = !empty($params['homeAddress2']) ? trim($params['homeAddress2']) : null; // General data $city = !empty($params['city']) ? trim($params['city']) : null; // General data $state = null; if ($params['state'] == -1) { // State/Province: Other selected $state = !empty($params['stateOther']) ? trim($params['stateOther']) : null; // General data } else { if ($params['state'] > 0) { // one of US States selected $state = !empty($params['state']) ? $this->states[(int) $params['state']] : null; // General data } } $country = $params['country'] > 0 ? $this->countries[(int) $params['country']] : null; // General data $postal_code = !empty($params['postal_code']) ? trim($params['postal_code']) : null; // General data $phone = !empty($params['phone']) ? trim($params['phone']) : null; // General data $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; header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED)); } } if (strlen($this->msg) > 0) { $this->msg = "\n" . "Fields marked with * must not be left empty" . $this->msg; } } //$error_login = FALSE; if (!$this->error) { 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 ($this->error == TRUE) { header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED)); } } // if error occur than no need to check 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 is not valid.'); header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED)); } // Calculating Allowed Domains if (file_exists(PA::$project_dir . "/config/domain_names.txt")) { $domain_names_file = PA::$project_dir . "/config/domain_names.txt"; } elseif (file_exists(PA::$core_dir . "/config/domain_names.txt")) { $domain_names_file = PA::$core_dir . "/config/domain_names.txt"; } else { throw new Exception("Allowed Domains configuration file \"/config/domain_names.txt\" not found"); } $allowed_domains = preg_split("/\\s+/", file_get_contents($domain_names_file)); // Calcutating user domain $user_email = explode('@', $email); $user_domain = strtolower($user_email[1]); $found = 0; foreach ($allowed_domains as $i => $d) { if (!preg_match('/\\W/', $d)) { continue; } // make proper regex $rx = preg_replace('/\\*/', '[^\\.]*', $d); if (preg_match("/{$rx}/", $user_domain)) { $found++; } } if (!$found) { // show error $email_invalid = TRUE; $this->array_of_errors['error_email'] = $email_invalid; $this->error = TRUE; $this->msg .= __('The domain of your E-mail address is not in the list of allowed domains.'); header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED)); } if ($password != $confirm_password) { $this->msg .= "\nPassword and Confirm Password do not match."; $error_password_conf = TRUE; $this->error = TRUE; } if ($this->api_call == true) { // dont check maximum password length if this is an API call // this is so that the API call can accept an encrypted password } else { // this is not an API request, so check password length normally if (strlen($password) > PA::$password_max_length) { $this->msg .= sprintf(__("\nThe password must be less than %d characters."), PA::$password_max_length); $error_password_l = TRUE; $this->error = TRUE; header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED)); } } if (strlen($password) < PA::$password_min_length) { $this->msg .= sprintf(__("\nThe password must be longer than %d characters."), PA::$password_min_length); $error_password_g = TRUE; $this->error = TRUE; header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_PRECONDITION_FAILED)); } } if (!$this->error) { if (User::user_exist($login_name)) { $this->msg = "Login name {$login_name} is already taken"; $error_login = TRUE; $this->error = TRUE; header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_CONFLICT)); } 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; header(HttpStatusCodes::httpHeaderFor(HttpStatusCodes::HTTP_CONFLICT)); } $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 ($date_created) { // for users inserted via import accounts script! $this->newuser->created = $date_created; } if ($this->api_call == true) { $this->newuser->core_id = $core_id; if ($picture != null && $picture != '') { $this->newuser->picture = $picture; $this->newuser->picture_dimensions = $picture_dimensions; } else { $this->newuser->picture_dimensions = User::image_dimensions_to_array(0, 0); } if ($avatar != null && $avatar != '') { $this->newuser->avatar = $avatar; $this->newuser->avatar_dimensions = $avatar_dimensions; } else { $this->newuser->avatar_dimensions = User::image_dimensions_to_array(0, 0); } if ($avatar_small != null && $avatar_small != '') { $this->newuser->avatar_small = $avatar_small; $this->newuser->avatar_small_dimensions = $avatar_small_dimensions; } else { $this->newuser->avatar_small_dimensions = User::image_dimensions_to_array(0, 0); } } else { $this->newuser->picture = Storage::validateFileId(@$params['user_filename']); } } if ($this->error != TRUE) { try { $save_error = FALSE; $extra = unserialize($network_info->extra); if ($mother_extra['email_validation'] == NET_NO || $this->api_call == true) { // if email validation not required $this->newuser->is_active = ACTIVE; } else { $this->newuser->is_active = UNVERIFIED; } $this->newuser->save(); if ($this->newuser->picture) { Storage::link($this->newuser->picture, array("role" => "avatar", "user" => $this->newuser->user_id)); } /* The following code should now be obsolete as this is done in User->save() */ // saving data in user profile data also -- for searching making more easier $data_array = array(array('uid' => $this->newuser->user_id, 'name' => 'first_name', 'value' => $this->newuser->first_name, 'type' => BASIC, 'perm' => 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' => NONE), 1 => array('uid' => $this->newuser->user_id, 'name' => 'dob_day', 'value' => $dob_day, 'type' => GENERAL, 'perm' => NONE), 2 => array('uid' => $this->newuser->user_id, 'name' => 'dob_month', 'value' => $dob_month, 'type' => GENERAL, 'perm' => NONE), 3 => array('uid' => $this->newuser->user_id, 'name' => 'dob_year', 'value' => $dob_year, 'type' => GENERAL, 'perm' => NONE), 4 => array('uid' => $this->newuser->user_id, 'name' => 'dob', 'value' => $dob_year . '-' . $dob_month . '-' . $dob_day, 'type' => GENERAL, 'perm' => NONE), 5 => array('uid' => $this->newuser->user_id, 'name' => 'homeAddress1', 'value' => $homeAddress1, 'type' => GENERAL, 'perm' => NONE), 6 => array('uid' => $this->newuser->user_id, 'name' => 'homeAddress2', 'value' => $homeAddress2, 'type' => GENERAL, 'perm' => NONE), 7 => array('uid' => $this->newuser->user_id, 'name' => 'city', 'value' => $city, 'type' => GENERAL, 'perm' => NONE), 8 => array('uid' => $this->newuser->user_id, 'name' => 'state', 'value' => $state, 'type' => GENERAL, 'perm' => NONE), 9 => array('uid' => $this->newuser->user_id, 'name' => 'country', 'value' => $country, 'type' => GENERAL, 'perm' => NONE), 10 => array('uid' => $this->newuser->user_id, 'name' => 'postal_code', 'value' => $postal_code, 'type' => GENERAL, 'perm' => NONE), 11 => array('uid' => $this->newuser->user_id, 'name' => 'phone', 'value' => $phone, 'type' => GENERAL, 'perm' => NONE)); //} $this->newuser->save_user_profile($data_array, GENERAL); if ($mother_extra['email_validation'] == NET_NO || $this->api_call == true) { //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) { $user_type = null; $register_by_admin = false; if ($this->api_call == true) { // since this is an API call, default this member as a // NETWORK_MEMBER since they already registered $user_type = NETWORK_MEMBER; // since this is an API call, act like it is registration by admin $register_by_admin = true; } Network::join($network_info->network_id, $this->newuser->user_id, $user_type, $register_by_admin); if ($this->api_call == false) { // only send notification of network if this is NOT an API call PANotify::send("network_join", $network_info, $this->newuser, array()); } } } } catch (CNException $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! // give Login User permissions to new user is moved to Network::join() now! /* $this->newuser->set_user_role(array(LOGINUSER_ROLE)); */ return TRUE; }
PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj); } } if ($no_reg_user == TRUE) { $error_msg .= "No registered member in this network"; } else { $error_msg .= " Bulletin has been sent "; } } else { if (!empty($_POST['send_to_me_only'])) { // test send to admin user if (!$error_msg) { // if no errors $subject = $_POST['title']; $bull_message = $_POST['bulletin_body']; PANotify::send("bulletin_sent", $user, PA::$network_info, array('bulletin.message' => $bull_message, 'bulletin.subject' => $subject)); $error_msg = "Bulletin has been sent to you."; } } else { if (!empty($_POST['preview'])) { // if preview is selected. $subject = $_POST['title']; $bull_message = nl2br($_POST['bulletin_body']); $container_html = 'default_email_container.tpl'; $email_container = new Template('config/email_containers/' . $container_html); $email_container->set('subject', $subject); $email_container->set('message', $bull_message); $preview_msg = $email_container->fetch(); } } }
$new_invite = new Invitation(); $new_invite->inv_id = $invitation_id; $new_invite->inv_user_id = $_SESSION['user']['id']; $new_invite->accept(); $inv_obj = Invitation::load($invitation_id); $user_obj = new User(); $user_obj->load((int) $inv_obj->user_id); $user_accepting_inv_obj = new User(); $user_accepting_inv_obj->load((int) $_SESSION['user']['id']); $relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $user_accepting_inv_obj->user_id, PA::$network_info->network_id); $relation_type = Relation::lookup_relation_type($relation_type_id); $new_invite->inv_relation_type = $relation_type; PANotify::send("invitation_accept", $user_obj, $user_accepting_inv_obj, $new_invite); if (!Network::member_exists(PA::$network_info->network_id, (int) $_SESSION['user']['id'])) { Network::join(PA::$network_info->network_id, $_SESSION['user']['id']); PANotify::send("network_join", PA::$network_info, $user_accepting_inv_obj, array()); } header("Location: " . PA::$url . PA_ROUTE_USER_PRIVATE . '/' . "msg_id=7016"); exit; } catch (CNException $e) { $msg = $e->message; } } } else { $msg = $token_arr[0] == FALSE ? $token_arr[1] : 7018; header("Location: " . PA_ROUTE_HOME_PAGE . "/msg={$msg}"); exit; } } $ConfigurableText = new ConfigurableText(); $render_text_array = $ConfigurableText->load(NULL, 1);
function uihelper_upload_gallery_for_group($uid, $type, $k = 0) { require_once "api/User/User.php"; require_once "api/Tag/Tag.php"; require_once "api/Album/Album.php"; require_once "api/Image/Image.php"; require_once "api/Audio/Audio.php"; require_once "api/Video/Video.php"; require_once "web/includes/classes/CNFileUploader.php"; $logged_in_user = get_login_user(); $user = new User(); $media_count_no = $k; $error_file = NULL; $uploaded = False; if ($type == '') { $file_type = "image"; $alb_type = IMAGE_ALBUM; $new_img = new Image(); $new_img->file_perm = @$_POST['image_perm']; } elseif ($type == '_audio') { $file_type = "audio"; $alb_type = AUDIO_ALBUM; $new_img = new Audio(); $new_img->file_perm = @$_POST['audio_perm']; } elseif ($type == '_video') { $file_type = "video"; $alb_type = VIDEO_ALBUM; $new_img = new Video(); $new_img->file_perm = @$_POST['video_perm']; } //file uploading start $file_name_dynamic = "userfile{$type}" . "_" . "{$k}"; $file_name_dynamic_type = $file_name_dynamic; //"$file_name_dynamic"."$type"; $newname = $_FILES[$file_name_dynamic_type]['name']; $uploadfile = PA::$upload_path . basename($_FILES[$file_name_dynamic_type]['name']); $myUploadobj = new FileUploader(); //creating instance of file. $image_type = "{$file_type}"; $value = $file_name_dynamic_type; $file = $myUploadobj->upload_file(PA::$upload_path, $value, true, true, $image_type); if ($file == false) { $msg = $myUploadobj->error; $error = TRUE; } else { $new_img->file_name = "{$file}"; $error_file = FALSE; } // file uploading end if (empty($error)) { try { $user->load((int) $uid); $action = !empty($_GET['action']) ? $_GET['action'] : 'upload'; $colls = Album::load_all($uid, $alb_type); if (isset($_POST['submit' . $type]) && $action != 'delete' && $error_file == FALSE) { $new_img->author_id = $uid; if ($type == '_audio') { $new_img->type = AUDIO; } elseif ($type == '_video') { $new_img->type = VIDEO; } else { $new_img->type = IMAGE; } if (empty($_POST['caption' . $type][$k])) { $ext = explode(".", $newname); $_POST['caption' . $type][$k] = $ext[0]; } $new_img->title = stripslashes(trim($_POST['caption' . $type][$k])); $new_img->title = strip_tags($new_img->title); $new_img->file_perm = ANYONE; $new_img->excerpt = stripslashes(trim($_POST['caption' . $type][$k])); $new_img->excerpt = strip_tags($new_img->excerpt); if (empty($_POST['body' . $type][$k])) { $new_img->body = ''; $new_img->body = strip_tags($new_img->body); } else { $new_img->body = stripslashes(trim($_POST['body' . $type][$k])); $new_img->body = strip_tags($new_img->body); } $new_img->allow_comments = 1; $new_img->parent_collection_id = $_POST['group_id']; $new_img->save(); if (!empty($_POST['tags' . $type][$media_count_no])) { $tag_array = Tag::split_tags($_POST['tags' . $type][$media_count_no]); Tag::add_tags_to_content($new_img->content_id, $tag_array); } } else { throw new CNException(USER_NOT_FOUND, 'unable to upload file.'); } if (!empty($msg)) { $uploaded = FALSE; } else { $uploaded = TRUE; if (isset($_REQUEST['gid'])) { $mail_type = "group_media_uploaded"; $new_img->group_id = $_REQUEST['gid']; } else { $mail_type = "media_uploaded"; } PANotify::send($mail_type, PA::$network_info, PA::$login_user, $new_img); } } catch (CNException $e) { $msg = "{$e->message}"; $error = TRUE; } } $array_of_error_message = array(@$error, @$msg, @$error_file, @$uploaded, 'collection_id' => $new_img->parent_collection_id, 'content_id' => $new_img->content_id); return $array_of_error_message; }
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'])); } }
uihelper_add_default_media($_SESSION['user']['id'], '_audio'); uihelper_add_default_media($_SESSION['user']['id'], '_video'); uihelper_add_default_blog($_SESSION['user']['id']); } } catch (PAException $e) { $msg = "{$e->message}"; } $network = new Network(); $network->set_params(array('network_id' => $nid)); $netinfo = $network->get(); $netinfo = $netinfo[0]; $requester = new User(); $requester->load((int) $_SESSION['user']['id']); $recipient = type_cast($netinfo, 'Network'); // defined in helper_functions.php PANotify::send("network_join", $recipient, $requester, array()); $redirect_url = "http://" . $netinfo->address . "." . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_HOME_PAGE . "/msg=7001"; header("Location:{$redirect_url}"); exit; // $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 network."; } else { //$msg = "Please login first to join the network."; header("Location: " . PA::$url . "/login.php?error=1&return=" . urlencode($_SERVER['REQUEST_URI'])); } } else { if ($_GET['action'] == 'leave') { try { if ($_SESSION['user']['id']) { $suc = Network::leave((int) PA::$network_info->network_id, (int) $_SESSION['user']['id']); if ($suc) { $_SESSION['user']['action'] = 'leave network';
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_submitAbuse($request_data) { global $error_msg; if ($request_data['action'] == 'submitAbuse' && !empty(PA::$login_uid)) { filter_all_post($request_data); $abuse = trim($request_data['abuse']); $type = isset($request_data['type']) && $request_data['type'] == 'comment' ? 'comment' : 'content'; $mail_type = $type == 'comment' ? "report_abuse_on_comment" : "report_abuse_on_content"; if (!empty($abuse)) { $extra = $this->shared_data['extra']; $network_info = $this->shared_data['network_info']; $error_msg = ""; try { // Saving the abuse report $report_abuse_obj = new ReportAbuse(); $report_abuse_obj->parent_type = $type == 'comment' ? TYPE_COMMENT : TYPE_CONTENT; $report_abuse_obj->parent_id = $request_data['cid']; $report_abuse_obj->reporter_id = PA::$login_uid; $report_abuse_obj->body = $request_data['abuse']; $id = $report_abuse_obj->save(); } catch (PAException $e) { $error_msg = $e->message; } $ccid_string = ""; PANotify::send($mail_type, PA::$network_info, PA::$login_user, $report_abuse_obj); $error_msg = 9002; /* if(!empty($request_data['gid'])) { $group = new Group(); $group->load((int)$request_data['gid']); PANotify::send("report_abuse_grp_owner", $group, PA::$login_user, $report_abuse_obj); } */ try { if (!empty($this->shared_data['content']) && !empty($this->shared_data['collection'])) { $content = $this->shared_data['content']; $collection = $this->shared_data['collection']; if ($content && $content->parent_collection_id != -1) { if ($this->shared_data['is_group_content']) { $mail_type = $type == 'comment' ? "report_abuse_on_comment_grp_owner" : "report_abuse_grp_owner"; PANotify::send($mail_type, $this->shared_data['collection'], PA::$login_user, $report_abuse_obj); $error_msg = 9002; } } } } catch (PAException $e) { $error_msg = $e->message; } } else { $error_msg = 9004; } } }
/** !! * 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); }
} } } catch (CNException $e) { throw $e; } } else { if (@$_POST['btn_deny']) { $user_id = (int) $_GET['uid']; $relation_id = (int) $_POST['related_id']; try { $relation_obj = Relation::getRelationData($relation_id, $user_id, PA::$network_info->network_id); if (Relation::delete_relation($relation_id, $user_id, PA::$network_info->network_id)) { // if relation deleted successfully, send a notification to the requestor $recip_obj = new User(); $recip_obj->load((int) $relation_id); PANotify::send("friend_request_denial", $recip_obj, PA::$network_info, $relation_obj); } } catch (CNException $e) { throw $e; } } } function setup_module($column, $moduleName, $obj) { global $uid, $paging, $user, $view_type; switch ($column) { case 'left': $obj->mode = PUB; if ($moduleName == 'NRecentCommentsModule') { $obj->cid = @$_REQUEST['cid']; $obj->block_type = HOMEPAGE;
break; } $permalink_cid = $post_saved['cid']; if (PA::is_moderated_content() && PA::$network_info->owner_id != $user->user_id) { Network::moderate_network_content(-1, $permalink_cid); // -1 for contents; not a part of any collection $error_msg = "&err=" . urlencode(MessagesHandler::get_message(1004)); } $login_required_str = null; if (PA::is_moderated_content()) { $login_required_str = '&login_required=true'; } $content_obj = CNContent::load_content((int) $permalink_cid); PANotify::send("content_posted", PA::$network_info, $user, $content_obj); 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 = 'user_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 = $permalink_cid; if (!PA::is_moderated_content()) { //Write to activity log only when moderation is off Activities::save($user->user_id, $activity, $object, $extra); } if (empty(PA::$config->simple['omit_routing'])) { //save post in groups
function handle_join() { $error_inv = false; $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, PA::$network_info)) { // registration failed return; } // If the user is joining a network other than the if ($mother_network_info->network_id != PA::$network_info->network_id) { Network::join(1, $this->reg_user->newuser->user_id, NETWORK_MEMBER); } if ($extra['email_validation'] == NET_NO || $this->silent) { // silent registration - no email validation! // Success! if (!$this->silent) { 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); $_SESSION['login_source'] = 'password'; // password recently entered, so enable access to edit profile PANotify::send("new_user_registered", PA::$network_info, $this->reg_user->newuser, array()); } 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 (PA::$network_info->type == PRIVATE_NETWORK_TYPE) { $user_type = NULL; if (PA::$network_info->owner_id == $inv_obj->user_id) { $user_type = NETWORK_MEMBER; } Network::join(PA::$network_info->network_id, $this->reg_user->newuser->user_id, $user_type); } $msg = 7016; $relation_type = null; $relationship_level = 2; //default relation level id is 2 for friend try { $relation_type_id = Relation::get_relation((int) $inv_obj->user_id, (int) $this->reg_user->newuser->user_id, PA::$network_info->network_id); } catch (PAException $e) { Relation::add_relation((int) $inv_obj->user_id, (int) $this->reg_user->newuser->user_id, $relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED); $relation_type = Relation::lookup_relation_type($relation_type_id); } $new_invite->inv_relation_type = $relation_type; if (!$this->silent) { PANotify::send("invitation_accept", $user_obj, $this->reg_user->newuser, $new_invite); } } 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 = PA_ROUTE_HOME_PAGE . '/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; $relationship_level = 2; //default relation level id is 2 for friend try { $relation_type_id = Relation::get_relation((int) $Ginv->user_id, (int) $this->reg_user->newuser->user_id, PA::$network_info->network_id); } catch (PAException $e) { Relation::add_relation((int) $Ginv->user_id, (int) $this->reg_user->newuser->user_id, $relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED); Relation::add_relation((int) $this->reg_user->newuser->user_id, (int) $Ginv->user_id, $relationship_level, PA::$network_info->address, PA::$network_info->network_id, NULL, NULL, NULL, true, APPROVED); } } catch (PAException $e) { $this->reg_user->msg = "{$e->message}"; $this->reg_user->error = TRUE; print $this->reg_user->msg; } $redirect_url = PA_ROUTE_GROUP . "/gid={$gid}&action=join&GInvID={$group_invitation_id}"; } else { //else redirect registered user to its page. $redirect_url = PA_ROUTE_USER_PRIVATE . '/' . "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 $msg = 5003; $redirect_url = PA_ROUTE_USER_PRIVATE . '/' . "msg_id={$msg}"; } 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; } } $user_type = NETWORK_WAITING_MEMBER; Network::join(PA::$network_info->network_id, $this->reg_user->newuser->user_id, $user_type); if (!$this->silent) { $activation_url = PA::$url . '/mail_action.php?action=activate&token=' . $token . $invitation; PAMail::send("activate_account", $this->reg_user->newuser, PA::$network_info, array('account.activation_url' => $activation_url)); } global $app; $er_msg = urlencode("Check your email for activation code."); $app->redirect(PA::$url . PA_ROUTE_SYSTEM_MESSAGE . "?show_msg=7013&msg_type=info&redirect_url=" . urlencode(PA::$url . '/' . FILE_LOGIN)); } //end if email validation is set }
/** !! * 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); }
$id = $report_abuse_obj->save(); } catch (PAException $e) { $error_message = $e->message; } $ccid_string = ""; if (!empty($_POST['ccid'])) { $ccid_string = "&ccid=" . $_POST['ccid']; } $abuse = trim($_POST['abuse']); if (!empty($abuse)) { PANotify::send("report_abuse_on_content", PA::$network_info, PA::$login_user, $report_abuse_obj); 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) { PANotify::send("report_abuse_grp_owner", $collection, PA::$login_user, $report_abuse_obj); $error_message = 9002; } } } catch (PAException $e) { //catch none } $_POST = array(); } else { $error_message = 9004; } } if (!empty($error_message)) { $location = PA::$url . PA_ROUTE_CONTENT . "/cid=" . $_GET["cid"] . "&err=" . urlencode($error_message) . $ccid_string; }
function initializeModule($request_method, $request_data) { if (empty($this->shared_data['group_info'])) { return 'skip'; } $this->group_details = $this->shared_data['group_info']; if (empty($request_data['gid'])) { return 'skip'; } // sanity check // we do this check only if the user is not already permitted to manage ads $gp_access = PermissionsHandler::can_group_user(PA::$login_uid, $request_data['gid'], array('permissions' => 'manage_groups')); if (!$gp_access) { return 'skip'; } // user shoudn't have gotten here in the first place, just don't show anything $error_msg = false; if ($request_method == 'POST') { $value_to_validate = array('title' => 'Title', 'bulletin_body' => 'Bulletin body'); foreach ($value_to_validate as $key => $value) { $request_data[$key] = trim($request_data[$key]); if (empty($request_data[$key])) { $error_msg .= $value . ' can not be empty<br>'; } } if (!$error_msg) { // if no errors yet $subject = $request_data['title']; $bull_message = $request_data['bulletin_body']; $group = new Group(); $group->load($request_data['gid']); if (!empty($request_data['bulletins'])) { // send to all members $gms = $group->get_members(); foreach ($gms as $i => $m) { $u = new User(); $u->load((int) $m['user_id']); $to_members[] = $u; } } else { if (!empty($request_data['send_to_me_only'])) { // test send to admin user $to_members = array(PA::$login_user); } } $this->sent_to = array(); // send it if (!empty($to_members)) { foreach ($to_members as $recipient) { $this->sent_to[] = $recipient->display_name; PANotify::send("group_bulletin_sent", $recipient, $group, array('bulletin.message' => $bull_message, 'bulletin.subject' => $subject)); } } // wannt a preview with that? if (!empty($request_data['preview'])) { // if preview is selected. $container_html = 'default_email_container.tpl'; $email_container = new Template('config/email_containers/' . $container_html); $email_container->set('subject', $subject); $email_container->set('message', $bull_message); $this->preview_msg = $email_container->fetch(); } } } }