Example #1
0
 /**
  * Adds the given tags for the given user id.
  *
  * @param integer $uid The uid of the user for whom tags are to be added.
  * @param array $tags contains the tags to be added for the given user.
  */
 static function add_tags_to_user($uid, $tags)
 {
     Logger::log("Enter: function Tag::add_tags_to_user");
     if (!User::user_exist((int) $uid)) {
         throw new PAException(USER_NOT_FOUND, "The user does not exist");
     }
     //Load the updated_tags_id by inserting the given tags to database
     //If the tag is already present in database then it will retrieve that value
     //Else this function will enter the tag into the database and then retrieve the value of tag_id and tag_name.
     if ($tags) {
         $tags_id = Tag::load_tag_ids($tags);
     }
     $sql = 'DELETE FROM {tags_users} WHERE user_id = ?';
     $data = array($uid);
     Dal::query($sql, $data);
     if ($tags_id) {
         foreach ($tags_id as &$value) {
             $sql = 'INSERT into {tags_users} (tag_id, user_id) values (?, ?)';
             $data = array($value, $uid);
             Dal::query($sql, $data);
         }
     }
     Logger::log("Exit: function Tag::add_tags_to_user");
     return;
 }
Example #2
0
 /**
  function Save()
  Required parameters :- Parent type, Parent id, Body of report and Reporter id
  @return Report id if data is successfully saved.
 */
 public function save()
 {
     Logger::log("Enter: function ReportAbuse::save");
     if (empty($this->parent_type)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Parent type is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'parent type is Empty.');
     }
     if (empty($this->parent_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Parent id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Parent id is missing.');
     }
     if (empty($this->body)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: body of Report abuse is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Body of Report can\'t be empty.');
     }
     if (empty($this->reporter_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Reporter id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Log into People Aggregator before sending report');
     }
     if (!User::user_exist((int) $this->reporter_id)) {
         Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
         throw new PAException(USER_NOT_FOUND, 'User does not exist.');
     }
     if (!$this->is_valid_type($this->parent_type)) {
         Logger::log(" Throwing exception INVALID_ARGUMENTS | Message: Not a valid parent type", LOGGER_ERROR);
         throw new PAException(INVALID_ARGUMENTS, 'parent type is invalid');
     }
     $sql = "INSERT INTO {report_abuse}\n      (parent_type, parent_id, reporter_id, body, created)\n      VALUES (?, ?, ?, ?, ?)";
     $this->created = time();
     $data = array($this->parent_type, $this->parent_id, $this->reporter_id, $this->body, $this->created);
     Dal::query($sql, $data);
     $this->report_id = Dal::insert_id();
     Logger::log("Exit: function ReportAbuse::save");
     return $this->report_id;
 }
 /**
  function Save()
  Required parameters :- Sender id, recipient id and body 
  @return testimonial id if data is successfully saved.
 */
 public function save()
 {
     Logger::log("Enter: function Testimonials::save");
     if (empty($this->sender_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: sender id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'sender id is missing.');
     }
     if (empty($this->recipient_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: recipient id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'recipient id is missing.');
     }
     if (empty($this->body)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: body of testimonial is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Body of testimonial can\'t be empty.');
     }
     if ($this->sender_id == $this->recipient_id) {
         Logger::log(" Throwing exception INVALID_TESTIMONIAL | Message: sender id and recipient id is same", LOGGER_ERROR);
         throw new PAException(INVALID_ARGUMENTS, 'you can\'t write testimonial for your self');
     }
     if (!User::user_exist((int) $this->recipient_id)) {
         Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
         throw new PAException(USER_NOT_FOUND, 'User does not exist.');
     }
     $this->status = PENDING;
     $this->is_active = ACTIVE;
     $this->created = time();
     $this->changed = time();
     $sql = "INSERT INTO testimonials \n      (sender_id, recipient_id, body, status, is_active, created, changed) \n      VALUES (?, ?, ?, ?, ?, ?, ?)";
     $data = array($this->sender_id, $this->recipient_id, $this->body, $this->status, $this->is_active, $this->created, $this->changed);
     Dal::query($sql, $data);
     $this->testimonial_id = Dal::insert_id();
     Logger::log("Exit: function Testimonials::save");
     return $this->testimonial_id;
 }
Example #4
0
 /**
  * Add the friend in the database by giving their user_id as relations_id.
  * @param int $relation_id This is user id of the user to whom user is adding as a friend
  * if this relation_id is given as -1, it is a external relation (flickr friend etc)
  * in that case the extra parameters MUST be supplied
  * in_family parameter added  by gurpreet to mark whether the person added is in family.
  */
 public static function add_relation($user_id, $relation_id, $relation_type_id = 2, $network = NULL, $network_uid = NULL, $display_name = NULL, $thumbnail_url = NULL, $profile_url = NULL, $in_family = null, $status = APPROVED)
 {
     // status added 04/01/2007
     Logger::log("Enter: function Relation::add_relation\n");
     if (!$relation_id) {
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required variable relation id is not specified");
     }
     if ($relation_id < 0 && !$network_uid) {
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required variable network_uid is not specified");
     }
     if ($relation_id == $user_id) {
         throw new PAException(USER_INVALID, "User is invalid to be added as friend. User can not add himself as a friend");
     }
     // make sure that the user to be added is active
     // but only if it is an internal user
     // relations from external networs have a
     // $relation_id of -1
     if ((int) $relation_id > 0) {
         $user_exist = User::user_exist((int) $relation_id);
         if ($user_exist == FALSE) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new PAException(USER_NOT_FOUND, 'User does not exist.');
         }
     }
     try {
         // Delete an existing relation
         if (is_null($network_uid)) {
             $sql = 'DELETE FROM {relations} WHERE user_id = ? AND relation_id = ? AND network_uid IS ?';
         } else {
             $sql = 'DELETE FROM {relations} WHERE user_id = ? AND relation_id = ? AND network_uid = ?';
         }
         $data = array($user_id, $relation_id, $network_uid);
         Dal::query($sql, $data);
         // Insert relation_id for corresponding user_id
         $sql = 'INSERT into {relations} 
     (user_id, relation_id, relationship_type,
     network, network_uid, display_name,
     thumbnail_url, profile_url, in_family, status) 
     values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
         $data = array($user_id, $relation_id, $relation_type_id, $network, $network_uid, $display_name, $thumbnail_url, $profile_url, $in_family, $status);
         Dal::query($sql, $data);
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (PAException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: function Relation::add_relation");
 }
 public function save()
 {
     Logger::log("Enter: EventAssociation::save");
     // check for complete info
     if (empty($this->event_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: event_id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'event_id is missing.');
     }
     if (empty($this->assoc_target_type)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: assoc_target_type is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'assoc_target_type is missing.');
     }
     if (empty($this->assoc_target_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: assoc_target_id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'assoc_target_id is missing.');
     }
     if (empty($this->assoc_target_name)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: assoc_target_name is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'assoc_target_name is missing.');
     }
     // depending on assoc_target_type check if network|group|user exists
     switch ($this->assoc_target_type) {
         case "network":
             // network of assoc_target_id exists?
             // this check should maybe be part of the Network class?
             $res = Dal::query("SELECT COUNT(*) FROM {networks} \n          WHERE network_id=? AND is_active=1", array($this->assoc_target_id));
             if (!$res->numRows()) {
                 Logger::log(" Throwing exception NETWORK_NOT_FOUND | Message: Network does not exist", LOGGER_ERROR);
                 throw new PAException(NETWORK_NOT_FOUND, 'Network does not exist.');
             }
             break;
         case "group":
             // group of assoc_target_id exists?
             $res = Dal::query("SELECT COUNT(*) FROM {groups} \n          WHERE group_id=?", array($this->assoc_target_id));
             if (!$res->numRows()) {
                 Logger::log(" Throwing exception GROUP_NAME_NOT_EXIST | Message: Group does not exist", LOGGER_ERROR);
                 throw new PAException(GROUP_NAME_NOT_EXIST, 'Group does not exist.');
             }
             break;
         case "user":
             // user of assoc_target_id exists?
             if (!User::user_exist($this->assoc_target_id)) {
                 Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
                 throw new PAException(USER_NOT_FOUND, 'User does not exist.');
             }
             break;
         default:
             // oh-oh, not a valid assoc_target_type!!
             Logger::log(" Throwing exception BAD_PARAMETER | Message: " . $this->assoc_target_type . " is not a valid assoc_target_type", LOGGER_ERROR);
             throw new PAException(BAD_PARAMETER, $this->assoc_target_type . " is not a valid assoc_target_type");
             break;
     }
     // check to prevent duplicate associations
     if (EventAssociation::assoc_exists($this->assoc_target_type, $this->assoc_target_id, $this->event_id)) {
         Logger::log(" Throwing exception BAD_PARAMETER | Message: " . "There already is an EventAsssociation for this network, group or user.", LOGGER_ERROR);
         throw new PAException(BAD_PARAMETER, "The Event is already associated to this " . $this->assoc_target_type . ".");
     }
     if (!Event::exists($this->event_id)) {
         Logger::log(" Throwing exception EVENT_NOT_EXIST | Message: Event does not exist", LOGGER_ERROR);
         throw new PAException(EVENT_NOT_EXIST, 'Event does not exist.');
     }
     // load the Event if not already loaded
     if (!$this->event) {
         $this->load_event($this->event_id);
     }
     // serialize assoc_data for storage
     $assoc_data = "";
     if (!empty($this->assoc_data)) {
         $assoc_data = serialize($this->assoc_data);
     }
     // are we creating a new one?
     if (!$this->assoc_id) {
         // do we have a real User set as owner?
         if (!User::user_exist($this->user_id)) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new PAException(USER_NOT_FOUND, 'User does not exist.');
         }
         // do we have an Event?
         if (!Event::exists($this->event->event_id)) {
             Logger::log(" Throwing exception EVENT_NOT_EXIST | Message: Event does not exist", LOGGER_ERROR);
             throw new PAException(EVENT_NOT_EXIST, 'Event does not exist.');
         }
         $sql = "INSERT INTO events_associations \n      (event_id, user_id, assoc_target_type, assoc_target_id, assoc_target_name, event_title, start_time, end_time, assoc_data) \n      VALUES (?,?,?,?,?,?,?,?,?)";
         $data = array($this->event->event_id, $this->user_id, $this->assoc_target_type, $this->assoc_target_id, $this->assoc_target_name, $this->event->event_title, $this->event->start_time, $this->event->end_time, $assoc_data);
     } else {
         $sql = "UPDATE {events_associations} SET " . "event_id = ?, user_id = ?, assoc_target_type = ?, assoc_target_id = ?,\n           assoc_target_name = ?, event_title = ?, start_time = ?, end_time = ?,\n           assoc_data = ?" . "WHERE assoc_id = ?";
         $data = array($this->event->event_id, $this->user_id, $this->assoc_target_type, $this->assoc_target_id, $this->assoc_target_name, $this->event->event_title, $this->event->start_time, $this->event->end_time, $assoc_data, $this->assoc_id);
     }
     // write to DB
     try {
         Dal::query($sql, $data);
         if (!$this->assoc_id) {
             $this->assoc_id = Dal::insert_id();
         }
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (PAException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: EventAssociation::save");
 }
     $error = TRUE;
     $msg .= '<br> Email address is not valid';
 }
 if (strlen($login_name) < 3 and !empty($login_name)) {
     $msg = "The username must be greater than 3 characters.";
     $error = TRUE;
 }
 if (strlen($password) > 15) {
     $msg = "The password must be less than 15 characters.";
     $error = TRUE;
 }
 if (strlen($password) < 5) {
     $msg = "The password must be greater than 5 characters.";
     $error = TRUE;
 }
 if (User::user_exist($login_name)) {
     $msg = "Username {$login_name} is already taken";
     $error = TRUE;
 }
 // saving value if create user fails for any reason
 $vartoset = array('login_name', 'email', 'first_name', 'last_name', 'radiobutton', 'action');
 filter_all_post($_POST);
 //filters all data of html
 for ($i = 0; $i < count($vartoset); $i += 1) {
     $var = $vartoset[$i];
     if (!empty($_POST[$var])) {
         $form_data[$var] = $_POST[$var];
     }
 }
 if ($error == FALSE) {
     $newuser->login_name = $login_name;
 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;
 }
     if (empty($_POST['a1'])) {
         //$message[] = __('Nothing Wrong');
     } else {
         $networks_data['a1'] = $_POST['a1'];
     }
     if (empty($_POST['a2'])) {
         //$message[] = __('Nothing wrong 2');
     } else {
         $networks_data['a2'] = $_POST['a2'];
     }
 } else {
     if ($section == 'showcase') {
         if (empty($_POST['featured_user_name'])) {
             $message[] = __('No Featured User!');
         } else {
             if (User::user_exist($_POST['featured_user_name'])) {
                 $thisUser = new User();
                 $thisUser->load($_POST['featured_user_name']);
                 $networks_data['featured_user_name'] = $thisUser->login_name;
                 $networks_data['auto_user_id'] = $thisUser->user_id;
                 $networks_data['auto_user_picture_url'] = $thisUser->picture;
             } else {
                 $message[] = __("Featured User Not Found!");
             }
         }
         if (empty($_POST['featured_group_id'])) {
             $message[] = __('No Featured Group!');
         } else {
             $networks_data['featured_group_id'] = $_POST['featured_group_id'];
         }
         if (empty($_POST['featured_video_id'])) {
 public function save()
 {
     Logger::log("Enter: Event::save");
     // check for complete info
     if (empty($this->event_title)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: event_title is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Please supply an Event Title.');
     }
     $this->title = $this->event_title;
     if (empty($this->start_time)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: start_time is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Please specify the Start Time.');
     }
     if (empty($this->end_time)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: end_time is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Please specify the End Time.');
     }
     // serialize event_data for storage
     $event_data = "";
     if (!empty($this->event_data)) {
         $event_data = serialize($this->event_data);
     }
     // make end_time sane (can only be same or after start_time)
     if (strtotime($this->end_time) <= strtotime($this->start_time)) {
         $this->end_time = $this->start_time;
     }
     $this->author_id = $this->user_id;
     $this->body = $this->event_data['description'];
     // are we creating a new one?
     if (!$this->event_id) {
         /*
         if (empty($this->content_id)) {
             Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: content_id is empty", LOGGER_ERROR);
             throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Content id is missing.');
         }
         */
         // do we have a real User set as owner?
         if (!User::user_exist((int) $this->user_id)) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new PAException(USER_NOT_FOUND, 'User does not exist.');
         }
         // save a Content
         parent::save();
         $sql = "INSERT INTO events \n      (content_id, user_id, event_title, start_time, end_time, event_data) \n      VALUES (?, ?, ?, ?, ?, ?)";
         $data = array($this->content_id, $this->user_id, $this->event_title, $this->start_time, $this->end_time, $event_data);
     } else {
         // save as Content
         parent::save();
         $sql = "UPDATE {events} SET " . "event_title = ?, start_time = ?, end_time = ?, event_data = ? " . "WHERE event_id = ?";
         $data = array($this->event_title, $this->start_time, $this->end_time, $event_data, $this->event_id);
     }
     // write to DB
     try {
         Dal::query($sql, $data);
         if (!$this->event_id) {
             // newly created
             $this->event_id = Dal::insert_id();
         } else {
             // update any existing EventAssociations
             EventAssociation::update_assocs_for_event($this);
         }
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (PAException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: Event::save");
 }
 /**
  * gets all threads in category if category_id is set by method set_category_id()
  * gets all replies of message if parent_message_id is set by method set_parent_message_id()
  * @access public
  * @param set_category_id(category_id),set_parent_message_id(parent_message_id)
  */
 public function get($count = FALSE, $show = 'ALL', $page = 0, $sort_by = 'changed', $direction = 'DESC')
 {
     Logger::log("Enter: function MessageBoard::get_threads_of_category");
     //find count
     if ($count) {
         $sql = "SELECT count(*) AS CNT FROM {boardmessages} WHERE parent_id = ? AND parent_type = ?";
         $data = array($this->parent_id, $this->parent_type);
         $res = Dal::query($sql, $data);
         $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
         return $row->CNT;
     }
     //find count EOF
     $order_by = $sort_by . ' ' . $direction;
     if ($show == 'ALL') {
         $limit = '';
     } else {
         if (!empty($show)) {
             $start = ($page - 1) * $show;
             $limit = 'LIMIT ' . $start . ',' . $show;
         }
     }
     $sql = " SELECT * FROM {boardmessages} WHERE parent_id = ? AND parent_type = ? ORDER BY {$order_by} {$limit} ";
     $data = array($this->parent_id, $this->parent_type);
     $res = Dal::query($sql, $data);
     $arr_boardmessges = array();
     if ($this->parent_type == PARENT_TYPE_MESSAGE) {
         $arr_boardmessges[0] = $this->get_by_id($this->parent_id);
     }
     if ($res->numRows() > 0) {
         $i = 1;
         while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
             $user_value = User::user_exist((int) $row->user_id);
             if ($user_value) {
                 $total_replies = $this->get_children_count($row->boardmessage_id, PARENT_TYPE_MESSAGE);
                 $arr_boardmessges[$i] = array('boardmessage_id' => $row->boardmessage_id, 'title' => $row->title, 'body' => $row->body, 'created' => $row->created, 'total_replies' => $total_replies, 'user_id' => $row->user_id, 'user_name' => $row->user_name, 'email' => $row->email, 'allow_anonymous' => $row->allow_anonymous, 'homepage' => $row->homepage, 'user_picture' => '');
                 if ($row->user_id != -1 and $row->user_id != '') {
                     $user = new User();
                     $user->load((int) $row->user_id);
                     $arr_boardmessges[$i]['user_name'] = $user->login_name;
                     $arr_boardmessges[$i]['email'] = $user->email;
                     $arr_boardmessges[$i]['user_picture'] = $user->picture;
                 }
                 $i++;
             }
         }
     }
     return $arr_boardmessges;
     Logger::log("Exit: function MessageBoard::get_threads_of_category");
 }
function peopleaggregator_deleteUser($args)
{
    $errorMessage = null;
    $userid = null;
    // check admin password, throw exception if it is not set
    global $admin_password;
    if (!$admin_password) {
        header('HTTP/1.1 412 Precondition Failed');
        throw new PAException(OPERATION_NOT_PERMITTED, "deleteUser API method may not be called without an admin password defined in the Application Configuration File");
    } else {
        if (!isset($args['adminPassword']) || !$args['adminPassword']) {
            header('HTTP/1.1 412 Precondition Failed');
            throw new PAException(OPERATION_NOT_PERMITTED, "deleteUser API method may not be called without an admin password");
        } else {
            if ($admin_password != $args['adminPassword']) {
                header('HTTP/1.1 401 Unauthorized');
                throw new PAException(USER_INVALID_PASSWORD, "adminPassword incorrect");
            }
        }
    }
    $login = $args['login'];
    $userid = User::user_exist($login);
    if ($userid) {
        $user = new User();
        // hard delete user
        $user->delete($userid, true);
    } else {
        throw new PAException(USER_NOT_FOUND, "User {$login} was not found");
    }
    return array('success' => TRUE, 'msg' => "Deleted user {$login}");
}
        }
    }
}
// add_assoc_users
$add_assoc_user_errors = array();
//declaring array so as to avoid notices for undefined variables
if (isset($_POST['add_assoc_users'])) {
    $ed = get_event_data();
    if (empty($_POST['assoc_users'])) {
        $add_assoc_user_errors[] = __("No users given");
    } else {
        // split the passed value into login_names
        $login_names = preg_split("/\\s*,\\s*/", $_POST['assoc_users']);
        // see if each is a valid login_nmae and remember errors
        foreach ($login_names as $n => $name) {
            $add_uid = (int) User::user_exist($name);
            if ($add_uid) {
                // try to add EventAssociation for this user_id
                try {
                    $ea = new EventAssociation();
                    $ea->event_id = $ed['event_id'];
                    $ea->user_id = PA::$login_user->user_id;
                    $ea->assoc_target_type = 'user';
                    $ea->assoc_target_id = $add_uid;
                    $ea->assoc_target_name = $name;
                    $ea->save();
                } catch (CNException $err) {
                    $add_assoc_user_errors[] = __("There was a problem associating the event:") . "<br />" . $err->getMessage();
                }
            } else {
                $add_assoc_user_errors[] = sprintf(__("%s is not a user"), $name);
 private function handlePOST_addChild($request_data)
 {
     global $error_msg;
     $error = FALSE;
     $login_name = trim($_POST['login_name']);
     $first_name = stripslashes(trim($_POST['first_name']));
     $last_name = stripslashes(trim($_POST['last_name']));
     $email = trim($_POST['email']);
     $password = trim($_POST['password']);
     $use_parent_email = $_POST['use_parent_email'];
     //echo "<pre>".print_r($_POST, 1)."</pre>"; die();
     if (!isset($_POST['state'])) {
         if (isset($_POST['stateOther'])) {
             $_POST['state'] = $_POST['stateOther'];
         }
     }
     if (isset($_POST['stateOther'])) {
         unset($_POST['stateOther']);
     }
     $msg = NULL;
     if (!Validation::validate_email($email) && !empty($_POST['email'])) {
         $email_invalid = TRUE;
         $error = TRUE;
         $msg .= '<br> Email address is not valid';
     }
     if (User::user_exist($login_name)) {
         $msg = "Username {$login_name} is already taken";
         $error = TRUE;
     }
     if ($error == FALSE) {
         $newuser = new User();
         $newuser->login_name = $login_name;
         $newuser->password = $password;
         $newuser->first_name = $first_name;
         $newuser->last_name = $last_name;
         $newuser->email = $email;
         $newuser->is_active = ACTIVE;
         if (!empty($_FILES['userfile']['name'])) {
             $myUploadobj = new FileUploader();
             //creating instance of file.
             $image_type = 'image';
             $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
             if ($file == false) {
                 $msg = $myUploadobj->error;
                 $error = TRUE;
             } else {
                 $newuser->picture = $file;
             }
         }
         if ($error == FALSE) {
             try {
                 if ($use_parent_email) {
                     $newuser->save($check_unique_email = false);
                 } else {
                     $newuser->save($check_unique_email = true);
                 }
                 if (!empty($file)) {
                     Storage::link($file, array("role" => "avatar", "user" => $newuser->user_id));
                 }
                 // creating message basic folders
                 Message::create_basic_folders($newuser->user_id);
                 // adding default relation
                 if ($newuser->user_id != SUPER_USER_ID) {
                     User_Registration::add_default_relation($newuser->user_id, PA::$network_info);
                 }
                 // adding default media as well as album
                 User_Registration::add_default_media($newuser->user_id, '', PA::$network_info);
                 User_Registration::add_default_media($newuser->user_id, '_audio', PA::$network_info);
                 User_Registration::add_default_media($newuser->user_id, '_video', PA::$network_info);
                 User_Registration::add_default_blog($newuser->user_id);
                 //adding default link categories & links
                 User_Registration::add_default_links($newuser->user_id);
                 // code for adding default desktop image for user
                 $desk_img = uihelper_add_default_desktopimage($newuser->user_id);
                 if (empty($desk_img)) {
                     $desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
                     $rand_key = array_rand($desktop_images);
                     $desk_img = $desktop_images[$rand_key];
                 }
                 $states = array_values(PA::getStatesList());
                 $countries = array_values(PA::getCountryList());
                 $profile_keys = array('dob_day', 'dob_month', 'dob_year', 'homeAddress1', 'homeAddress2', 'city', 'state', 'country', 'postal_code', 'phone', 'use_parent_email');
                 $profile_data = array();
                 filter_all_post($_POST);
                 //filters all data of html
                 foreach ($profile_keys as $k => $pkey) {
                     if (!empty($_POST[$pkey])) {
                         if ($pkey == 'state' && $_POST[$pkey] >= 0) {
                             $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $states[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
                         } else {
                             if ($pkey == 'country' && $_POST[$pkey] >= 0) {
                                 $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $countries[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
                             } else {
                                 $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $_POST[$pkey], 'type' => GENERAL, 'perm' => 1);
                             }
                         }
                         $profile_data[] = $prof_rec;
                     }
                 }
                 $profile_data[] = array('uid' => $newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1);
                 //     echo "<pre>".print_r($profile_data,1)."</pre>";
                 $newuser->save_user_profile($profile_data, GENERAL);
                 //if new user is created in a network then he must set as a joined user
                 if (!empty(PA::$network_info)) {
                     $by_admin = true;
                     Network::join(PA::$network_info->network_id, $newuser->user_id, NETWORK_MEMBER, $by_admin);
                     // $by_admin = true overrides the
                     // user_waiting status if it would get set
                     // this is an admin action, so we want it to happen in any case
                 }
                 $user_joined = $this->family->join((int) $newuser->user_id, $newuser->email, null);
                 if ($user_joined) {
                     // deal with TypedGroup Relations
                     require_once "api/Entity/TypedGroupEntityRelation.php";
                     $type = 'child';
                     TypedGroupEntityRelation::set_relation($newuser->user_id, $this->family->collection_id, $type);
                     if ($type == 'child') {
                         // if user type == child remove LoginUser and GroupMember roles
                         $newuser->delete_user_role();
                         // then assign 'Child' role only
                         $_extra = serialize(array('user' => false, 'network' => false, 'groups' => array($this->family->collection_id)));
                         $user_roles[] = array('role_id' => CHILD_MEMBER_ROLE, 'extra' => $_extra);
                         $newuser->set_user_role($user_roles);
                     }
                 }
                 $msg = __("Child's account was successfully created");
             } catch (PAException $e) {
                 $msg = $e->message;
             }
         }
         // end if
     }
     //end if
     $error_msg = $msg;
 }
Example #14
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;
 }