load($login_uid);
if ($profile_type == 'basic') {
$first_name = stripslashes(trim($_POST['first_name']));
$last_name = stripslashes(trim($_POST['last_name']));
$email_address = trim($_POST['email_address']);
$pass = trim($_POST['pass']);
$conpass = trim($_POST['conpass']);
$zipcode = trim($_POST['zip_code']);
if (empty($first_name)) {
$msg = "Fields marked with * can not be empty, First name can not be empty.";
$error_first_name = TRUE;
$error = TRUE;
}
else if (empty($email_address)) {
$msg = "Fields marked with * can not be empty, Email field is mandatory.";
$error_email = TRUE;
$error = TRUE;
}
else if (!empty($zipcode) && is_numeric($zipcode) == FALSE) {
$msg = "Zipcode must be in numeric characters.";
$error_zipcode = TRUE;
$error = TRUE;
}
else if (strlen($_POST['user_caption']) > 21 ) {
$msg = "Slogen must be less then 20 characters .";
$error_slogen = TRUE;
$error = TRUE;
}
else if (strlen($_POST['sub_caption']) > 31 ) {
$msg = " Sub-Slogen must be then 30 characters .";
$error_sub_slogen = TRUE;
$error = TRUE;
}
else {
if ((!empty($pass) && $pass != $conpass) || (!empty($conpass) && $pass != $conpass)) {
if (empty($conpass)) {
$msg = " Confirm Password can't leave blank .";
$error_conf_password = TRUE;
$error = TRUE;
} else {
$msg = "Passwords do not match.";
$error_password_conf = TRUE;
$error = TRUE;
}
}
if (!empty($pass) && strlen($pass) > 15) {
$msg = "The password must be less than 15 characters.";
$error_password_l = TRUE;
$error = TRUE;
}
if (!empty($pass) && strlen($pass) <5) {
$msg = "The password must be greater than 5 characters.";
$error_password_g = TRUE;
$error = TRUE;
}
}
$array_of_errors = array("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, "error_zipcode"=>$error_zipcode,"error_conf_password"=>$error_conf_password);
if ($error != TRUE) {
if (!empty($pass)) {
$user->password = md5($pass);
}
$user->first_name = $first_name;
$user->last_name = $last_name;
$user->email = $email_address;
$user->zipcode = $zipcode;
if (!empty($_FILES['userfile']['name'])) {
$uploadfile = $uploaddir.basename($_FILES['userfile']['name']);
$myUploadobj = new FileUploader; //creating instance of file.
$image_type = 'image';
$file = $myUploadobj->upload_file($uploaddir,'userfile',true,true,$image_type);
if( $file == false) {
$msg = $myUploadobj->error;
$error = TRUE;
}
else {
$user->picture = $file;
}
}
try {
$user->save();
// editing data in user profile data also -- for searching making more easier
$data_array = array(0 => array('uid'=>$user->user_id, 'name'=>'first_name', 'value'=>"$user->first_name", 'type'=>BASIC, 'perm'=>1), 1 => array('uid'=>$user->user_id, 'name'=>'last_name', 'value'=>"$user->last_name", 'type'=>BASIC, 'perm'=>1));
$user->save_user_profile($data_array, BASIC);
$_SESSION['user']['first_name'] = $first_name;
$_SESSION['user']['last_name'] = $last_name;
} catch (PAException $e) {
$msg = "$e->message";
$save_error = TRUE;
}
}
if ($error == TRUE || $save_error == TRUE) {
//print $msg; exit;
$msg = 'Sorry: you are unable to save data.
Reason: '."$msg";
}
else {
// invalidate the cache for user profile
/* $user_id = $_SESSION['user']['id'];
$file = "$current_theme_path/user_profile.tpl?uid=$user_id";
CachedTemplate::invalidate_cache($file);*/
header("Location: edit_profile.php?updated=1");
}
}
// general data -- start
// user general info
$user_data_general = array();
$user_generaldata = User::load_user_profile($login_uid, $login_uid, GENERAL);
for ($i=0; $i'; print_r($_POST); exit;
$information_type = GENERAL;
$field = array('dob', 'sex', 'country', 'state', 'city', 'user_caption', 'sub_caption', 'user_tags', 'postal_code','outputthis_username','outputthis_password');
$day = trim($_POST['day']);
$month = trim($_POST['month']);
$year = trim($_POST['year']);
$outputthis_username = trim($_POST['outputthis_username']);
$outputthis_password = trim($_POST['outputthis_password']);
$birthdate = "$day-$month-$year";
if ($_POST['day'] && $_POST['month'] && $_POST['year'] && $_POST['day']!=0 && $_POST['month']!=0) {
$day = ($day < 10) ? '0'.$day : $day;
$month = ($month < 10) ? '0'.$month : $month;
$dob = $year.'-'.$month.'-'.$day;//YYYY-MM-DD will be format for savind the date of birth
}
else {
$dob = '';
}
$sex = trim($_POST['sex']);
if ($_POST['postal_code']) {
$postal_code = trim($_POST['postal_code']);
}
if ($_POST['country']) {
$country = trim($_POST['country']);
}
if (!empty($_POST['state']) && $_POST['state'] != 'Other') {
$state = trim($_POST['state']);
}
else if(!empty($_POST['state_other'])) {
$state = trim($_POST['state_other']);
}
$city = trim($_POST['city']);
if ($_POST['user_caption']) {
$user_caption = trim($_POST['user_caption']);
}
if ($_POST['sub_caption']) {
$sub_caption = trim($_POST['sub_caption']);
}
if ($_POST['user_tags']) {
$user_tags = trim($_POST['user_tags']);
}
if ((!empty($day) || !empty($month) || !empty($year)) && (empty($day) || empty($month) || empty($year))){
$msg = "Birthday field given is wrong, please fill valid date.";
$error = TRUE;
}
if (($_POST['month']) && ($_POST['day']) && ($_POST['year'])) {
$dob_validation = checkdate ($_POST['month'], $_POST['day'], $_POST['year']);
}
if ((($_POST['month']) || ($_POST['day']) || ($_POST['year'])) && $dob_validation == '0') {
$msg = "The Date of Birth is invalid.";
$error = TRUE;
}
//check for invalid zipcode in general profile.
if (isset($postal_code) && !empty($postal_code) && !is_numeric($postal_code)) {
$msg = MessagesHandler::get_message(3000);
$error = TRUE;
}
if ($error != TRUE) {
$tags = explode(',', $_POST['user_tags']);
foreach ($tags as $term) {
$tr = trim($term);
if ($tr) {
$terms[] = $tr;
}
}
//here we can define fields which has permission to everybody
$permission_all = array();
for ($i=0; $i'; print_r($array_user_data); exit;
try {
$user->save_user_profile($array_user_data, $information_type);
//$user->save();
Tag::add_tags_to_user($user->user_id, $terms);
} catch (PAException $e) {
$msg = "$e->message";
$save_error = TRUE;
}
}
if ($error == TRUE || $save_error == TRUE) {
$msg = 'Sorry: you are unable to save data.
Reason: '."$msg";
}
else {
// invalidate the cache for user profile
header("Location: edit_profile.php?type=general&updated=1");
}
}
$user_picture = $user->picture;
if ($user->picture) {
$img_path = $base_url."/files/".$user->picture;
}
else {
$img_path = $base_url."/images/default.jpg";
}
$user_data = array();
$user_generaldata = User::load_user_profile($login_uid, $login_uid, GENERAL);
for ($i=0; $isave_user_profile($array_user_data, $information_type);
}
catch (PAException $e) {
$msg = "$e->message";
$save_error = TRUE;
}
if ($save_error == TRUE) {
$msg1 = "Sorry: you are unable to save data.
Reason: ".$msg;
}
else {
header("Location: edit_profile.php?type=personal&updated=1");
}
}
$user_personaldata = User::load_user_profile($login_uid, $login_uid, PERSONAL);
for ($i=0; $iupload_file($uploaddir,'user_cv',true,true,$file_type);
if( $file == false) {
$msg_pro = $myUploadobj->error;
$error = TRUE;
}
else {
$user_cv = $file;
$_POST['user_cv'] = $user_cv;
}
}
else {
$user_cv = $user_professional_data['user_cv'];
$_POST['user_cv'] = $user_cv;
}
for ($i=0; $isave_user_profile($array_user_data, $information_type);
}
catch (PAException $e) {
$msg_pro = "$e->message";
$save_error = TRUE;
}
}
if ($save_error == TRUE || $error == TRUE) {
$msg2 = "Sorry: you are unable to save data.
Reason: ".$msg_pro;
}
else {
header("Location: edit_profile.php?type=professional&updated=1");
}
}
$user_professionaldata = User::load_user_profile($login_uid, $login_uid, PROFESSIONAL);
for ($i=0; $iload($login_uid);
$login_name = $user->login_name;
$first_name = $user->first_name;
$last_name = $user->last_name;
$email = $user->email;
$zipcode = $user->zipcode;
$user_picture = $user->picture;
function setup_module($column, $moduleName, $obj) {
global $setting_data,$setting_data_enable, $login_uid, $flickr_id, $delicious_id;
global $msg, $msg2, $array_of_errors, $login_name, $first_name, $last_name, $email, $zipcode, $user_picture, $user_data, $user_personal_data, $user_professional_data;
switch ($column) {
case 'left':
$obj->mode = PRI;
if ( $moduleName == 'EnableModule' ) {
$obj->setting_data = $setting_data_enable;
$obj->Paging['show'] = 5 ;
}
$obj->uid = $login_uid;
break;
case 'middle':
$obj->content_id = $_REQUEST['cid'];
$obj->mode = PRI;
$obj->uid = $login_uid;
if ($moduleName == 'EditProfileModule') {
$obj->array_of_errors = $array_of_errors;
$obj->login_name = $login_name;
$obj->first_name = $first_name;
$obj->last_name = $last_name;
$obj->email = $email;
$obj->zipcode = $zipcode;
$obj->user_picture = $user_picture;
$obj->user_data = $user_data;
$obj->user_personal_data = $user_personal_data;
$obj->user_professional_data = $user_professional_data;
}
break;
}
}
$page = new PageRenderer("setup_module", PAGE_EDIT_PROFILE, sprintf(__("%s - Edit your profile - %s"), $login_user->get_name(), $network_info->name), "container_one_column.tpl", "header_user.tpl", NULL, PRI ,$network_info);
$page->add_header_html(js_includes('edit_profile.js'));
$theme_details = get_user_theme($login_uid);
if (is_array($theme_details['css_files'])) {
foreach ($theme_details['css_files'] as $key => $value) {
$page->add_header_css($value);
}
}
$css_path = $current_theme_path.'/modal.css';
$page->add_header_css($css_path);
if ( @$_GET['updated'] == 1) {
$uploaded_msg = " Profile updated successfully";
$msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl");
$msg_tpl->set('message', $uploaded_msg);
$m = $msg_tpl->fetch();
$page->add_module("middle", "top", $m);
}
if ( !empty($msg) || !empty($msg1) || !empty($msg2)) {
$uploaded_msg = " Profile updated successfully";
$msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl");
$msg_tpl->set('message', $msg.$msg1.$msg2);
$m = $msg_tpl->fetch();
$page->add_module("middle", "top", $m);
}
// see if we have a user defined CSS
$user_data_ui =
sanitize_user_data(User::load_user_profile($uid,$uid, 'ui'));
if (isset($user_data_ui['newcss'])) {
$usercss = '';
$page->add_header_html($usercss);
}
// user general info
$user_data_general = array();
$user_generaldata =
User::load_user_profile($uid, (int)$_SESSION['user']['id'], GENERAL);
$user_data_general = sanitize_user_data ($user_generaldata);
// set caption value
if (isset($user_data_general['user_caption'])) {
$caption1 = chop_string($user_data_general['user_caption'], 20);
} else {
$caption1 = chop_string($user->first_name." ".$user->last_name, 20);
}
$page->header->set('caption1', $caption1);
$page->header->set('caption2', chop_string(@$user_data_general['sub_caption'], 40));
$page->header->set('caption_image', @$user_data_general['user_caption_image']);
$page->header->set('desktop_image_action', @$user_data_general['desktop_image_action']);
$page->header->set('theme_details', $theme_details);
$page->header->set('display_image', $user_data_general['desktop_image_display']);
echo $page->render();
?>