diff --git a/documentation/default.css b/documentation/default.css old mode 100755 new mode 100644 index dedbd05ab2..f0a17f0613 --- a/documentation/default.css +++ b/documentation/default.css @@ -3,7 +3,7 @@ (info@ws-webservice.de / webmaster@bibelcenter.de) updated on 2005-02-25 by Olivier Brouckaert (oli.brouckaert@dokeos.com) - update on 2005-03-01 by Wolfgang Schneider + update on 2005-03-01 by Wolfgang Schneider update on 2005-05-27 by Patrick Cool */ @@ -15,13 +15,13 @@ body { padding: 0; background-color: #fff; } -img { - border: none; +img { + border: none; } #outerframe { position: relative; /* do not remove, fixes a bug in IE */ - border: 1px solid #fff; + border: 1px solid #fff; background-color: #fff; } @@ -29,7 +29,7 @@ img { * html #outerframe {height: 1%;} /* End hide from IE5-mac */ -/***************************************************** +/***************************************************** * HEADER STYLES * *****************************************************/ #header { @@ -54,57 +54,57 @@ img { #header1 a:hover{ text-decoration: underline; } -#sitename { - margin: 0; +#sitename { + margin: 0; font-weight: bold; } #institution { - float: left; + float: left; font-weight: bold; } #my_courses { - float: right; + float: right; font-weight: bold; } /* Header 2: Containing My Courses, My Profile,... */ #header2 { font-size: 12px; padding: 4px; - background-color: #4271B5; - color: #fff; + background-color: #4271B5; + color: #fff; border-bottom: 1px solid white; } #header2 .banner_links { - margin: 0; + margin: 0; } -#header2 a { +#header2 a { text-decoration: none; - color: #fff; + color: #fff; background: transparent; font-weight:normal; font-size: 12px; } -#header2 input.logout { - /* makes an input appear like a link in this header */ - margin: 0; - padding: 0; - background-color: transparent; +#header2 input.logout { + /* makes an input appear like a link in this header */ + margin: 0; + padding: 0; + background-color: transparent; border: none; - color: #fff; + color: #fff; font-size: 12px; font-weight:normal; - font-family: verdana, arial, helvetica, sans-serif; + font-family: verdana, arial, helvetica, sans-serif; } #header2 a:hover, #header2 input.logout:hover { border-bottom: 1px solid #fff; } #logout { - float: right; - width:20%; + float: right; + width:20%; text-align:right; } /* Header 3: Containing breadcrumbs, online users, student/teacher view, help */ -#header3 { +.subnav { position: relative; /* to avoid the IE peekabo bug*/ font-size: 12px; font-weight: normal; @@ -113,16 +113,16 @@ img { color: #fff; border-bottom: 1px solid white; } -#header3 a { +.subnav a { color: #ffffff; text-decoration: none; font-weight:normal; } -#header3 a:hover{ +.subnav a:hover{ text-decoration: underline; } /* Header3Right: online users, student/teacher view, help */ -#Header3Right ul{ +.subnavRight ul{ position: relative; /* to avoid the IE peekabo bug*/ float: right; width: 50%; @@ -131,12 +131,12 @@ img { list-style-type: none; text-align: right; } -#Header3Right ul li { - display: inline; +.subnavRight ul li { + display: inline; } -#Header3Right ul li a { - padding: 4px 6px 4px 4px; - color:#fff; +.subnavRight ul li a { + padding: 4px 6px 4px 4px; + color:#fff; } /* Header 4: not used */ #header4 { @@ -157,7 +157,7 @@ img { text-align: right; } -/***************************************************** +/***************************************************** * FOOTER STYLES * *****************************************************/ #footer { @@ -170,7 +170,7 @@ img { float: right; } -/***************************************************** +/***************************************************** * MAIN STYLES * *****************************************************/ #main { @@ -209,7 +209,7 @@ img { background-color: #fff; font-size: 12px; color: #f00;} -/*** layout divs for course and tool pages (being tested in some pages) ****/ +/*** layout divs for course and tool pages (being tested in some pages) ****/ #contentfloatholder {/* also makes the right "sliding" tab */ /*background: url(../pics/sidebar-r.gif) repeat-y 100% 0; background: url(../pics/bg_fountain.jpg) no-repeat 100% 0; */ @@ -220,26 +220,26 @@ position: relative; #contentfloatholder:after { /* this is for NN6 to clear floats */ -content: "."; -display: block; +content: "."; +display: block; height: 0px; -clear: both; +clear: both; visibility: hidden; } #centerwrap { float: left; - width: 100%; - margin-right: -95%; - /* this needs to be less than 100% for Moz/Mac which thinks - it's empty otherwise. The difference is made up by putting a + width: 100%; + margin-right: -95%; + /* this needs to be less than 100% for Moz/Mac which thinks + it's empty otherwise. The difference is made up by putting a negative left margin on the left float: - Note IE/Mac doesn't like this method ~ it wants the 100% so it can - be fed in using IE only CSS below becasue IE/Win also works with the 100% method. + Note IE/Mac doesn't like this method ~ it wants the 100% so it can + be fed in using IE only CSS below becasue IE/Win also works with the 100% method. */ } -#center { margin: 0 0 0 180px; padding: 10px 0 40px 0; +#center { margin: 0 0 0 180px; padding: 10px 0 40px 0; min-height: 300px; } #left { float: left; width: 180px; padding: 20px 0 0 0; @@ -249,8 +249,8 @@ visibility: hidden; #leftnavbox { margin: 0; padding: 0; float:left;} #leftnavbox dl { width: 160px; margin: 12px auto 4px auto; padding: 0 0 10px 0; background: transparent; font-size: 12px; text-align: center; } -#leftnavbox dt { margin: 0; padding: 1px 2px; font-weight: bold; font-size: 12px; - text-align: center; color: #000; +#leftnavbox dt { margin: 0; padding: 1px 2px; font-weight: bold; font-size: 12px; + text-align: center; color: #000; border-bottom: 1px solid #fff; background: transparent; } #leftnavbox dd { margin: 0; padding: 0; color: #009; text-align: left; border-bottom:1px solid #fff; background: #ccf; } @@ -260,10 +260,10 @@ border-bottom:1px solid #fff; background: #ccf; } #leftnavlist a:visited {color:#eee; text-decoration: none; display: block; padding: 2px 5px 2px 10px; background: #4171B5; color: #eee; width:140px; } #leftnavlist a:hover { background: #fff; color:#4171B5; display: block;} -/* --- end of left side definition list menu section --- */ +/* --- end of left side definition list menu section --- */ + - /* various sections in course-home.php file */ #toolremove {width: 40%; color: #f00; font-weight: bold; margin: 10px auto; padding: 10px; border: 2px solid #f00;} @@ -311,20 +311,20 @@ border-bottom:1px solid #fff; background: #ccf; } -----------------------------------------------------*/ #agenda_list {width: 100%; margin: 0 auto; border: 1px solid #fff; border-collapse: collapse;} - -/*The caption of the calendar (displays the month and the << and >> links*/ + +/*The caption of the calendar (displays the month and the << and >> links*/ #agenda_list #title {background-color: #4171B5; font-weight: bold; font-size: 12px; color: #fff; text-align: left; padding: 2px 10px; text-align: center; border: 1px solid #264269;} #agenda_list #title a:link, #agenda_list #title a:visited {background-color: #4171B5; font-weight: bold; font-size: 12px; color: #fff; text-align: left; padding: 2px 10px;text-align: center;} #agenda_list #title a:hover {background-color: #4171B5; font-weight: bold; font-size: 12px; color: #ff0000; text-align: left; padding: 2px 10px;text-align: center;} - + /* The cells with the name of the days of the weeks (mon->sun)*/ #agenda_list .weekdays {background-color: #D3DFF1; text-align: center; font-weight: bold; border: 1px solid #264269; border-collapse: collapse;} - -/* The cells for the days (1->31) */ + +/* The cells for the days (1->31) */ #agenda_list .days_week {height: 40px; width: 12%; text-align: left; vertical-align: top; border: 1px solid #264269; border-collapse: collapse; background-color: #f5f5f5;} #agenda_list .days_weekend {height: 40px; width: 12%; text-align: left; vertical-align: top; @@ -336,29 +336,29 @@ border-bottom:1px solid #fff; background: #ccf; } #agenda_list .data {background-color: #eee; text-align: left; padding: 2px 10px; font-weight: bold; border: 0px solid #4171B5; border-collapse: collapse;} #agenda_list .datanotbold {background-color: #eee; text-align: left; padding: 2px 10px; - font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} + font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} #agenda_list .text {background-color: #fff; text-align: left; padding: 2px 10px; font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} -/*text in the cells: display of agenda items (invisible)*/ +/*text in the cells: display of agenda items (invisible)*/ #agenda_list .data_hidden {background-color: #eee; text-align: left; padding: 2px 10px; font-weight: bold; border: 0px solid #4171B5; border-collapse: collapse; color: #999999;} #agenda_list .datanotbold_hidden {background-color: #eee; text-align: left; padding: 2px 10px; - font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse; color: #999999;} + font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse; color: #999999;} #agenda_list .text_hidden {background-color: #fff; text-align: left; padding: 2px 10px; font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse; color: #999999;} - -/*text in the cells: display of agenda items (highlighted)*/ + +/*text in the cells: display of agenda items (highlighted)*/ #agenda_list .datanow {background-color: #FFCC00; text-align: left; padding: 2px 10px; font-weight: bold; border: 0px solid #4171B5; border-collapse: collapse;} #agenda_list .datanotboldnow {background-color: #FFCC00; text-align: left; padding: 2px 10px; - font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} + font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} #agenda_list .textnow {background-color: #fff; text-align: left; padding: 2px 10px; - font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} - + font-weight: normal; border: 0px solid #4171B5; border-collapse: collapse;} + /* --------------------------------------------------- styles for the mini agenda ------------------------------------------------------*/ +-----------------------------------------------------*/ #smallcalendar {width: 100%; margin: 0 auto; border: 1px solid #fff; border-collapse: collapse;} #smallcalendar .weekdays {background-color: #D3DFF1; text-align: center; @@ -368,15 +368,15 @@ border-bottom:1px solid #fff; background: #ccf; } #smallcalendar .days_weekend {background-color: #e6e6e6; text-align: center; font-size: 11px; border: 1px solid #fff; border-collapse: collapse;} #smallcalendar .days_today {width: 12%; text-align: center; - font-size: 11px; border: 1px solid #FA8500; border-collapse: collapse; background-color: #FFCA8D;} - + font-size: 11px; border: 1px solid #FA8500; border-collapse: collapse; background-color: #FFCA8D;} + /* --------------------------------------------------- styles for the personal agenda -----------------------------------------------------*/ .personal_agenda {color: #008000; } -.personal_agenda a:link, .personal_agenda a:visited {color: #008000; } +.personal_agenda a:link, .personal_agenda a:visited {color: #008000; } a.personal_agenda:link, a.personal_agenda:visited {color: #008000; } -.personal_agenda a:hover, .personal_agenda a:hover {color: #666666; } +.personal_agenda a:hover, .personal_agenda a:hover {color: #666666; } a.personal_agenda:hover, a.personal_agenda:hover {color: #666666; } @@ -394,12 +394,12 @@ a.personal_agenda:hover, a.personal_agenda:hover {color: #666666; } } .normal-message { border: 1px solid #FF8001; - color: #000; + color: #000; background-color: #FDC77E; } .error-message { border: 1px solid #3F70AC; - color: #000; + color: #000; background-color: #FDC273; } @@ -485,7 +485,7 @@ input.liteoption {font-weight : normal;} /* None-bold submit button */ select, input[type=checkbox], input[type=radio], -input[type=button], +input[type=button], input[type=submit] {cursor: pointer; font-size: 12px;} input[text] {font-size: 12px; } @@ -514,14 +514,14 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;} .xxsmall { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px} -/***************************************************** +/***************************************************** * DATA TABLE STYLES * *****************************************************/ .cell_header {background-color: #EEEEFF;font-weight:bold;text-align:left;padding-left:5px;} /* header cell in data table in tools */ .data_table{ border-collapse: collapse; - width: 100%; + width: 100%; padding: 5px; } .data_table th{ @@ -542,7 +542,7 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;} padding: 5px; vertical-align: top; border-bottom: 1px solid #b0b0b0; - border-right: 1px dotted #e1e1e1; + border-right: 1px dotted #e1e1e1; border-left: 1px dotted #e1e1e1; } @@ -551,12 +551,12 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;} .tool_list dd { margin: 0; padding: 4px 0 0 10px;} /* divs for category list / platform news on home page */ -.home_cats {width: 45%; float: left; +.home_cats {width: 45%; float: left; margin: 0; padding: 8px; background: #fff;} -.home_news {width: 45%; float: right; +.home_news {width: 45%; float: right; margin: 0; padding: 8px; background: #fff;} - + label.left { float: left; width: 15em; margin: 0 0 0.5em 0; } form br { clear: both; } @@ -578,7 +578,7 @@ div.admin_section { padding: 5px; margin: 10px 20px; } -div.admin_section h4 { +div.admin_section h4 { margin: 0; border-bottom: 1px solid gray; width: 100%; @@ -617,7 +617,7 @@ div.admin_section h4 { /* New Announcements Tool */ .announcements_datum -{ +{ font-size: 12px; font-style: italic; color: #666666; diff --git a/main/admin/course_add.php b/main/admin/course_add.php index c42856bbe9..4650d8c583 100644 --- a/main/admin/course_add.php +++ b/main/admin/course_add.php @@ -55,7 +55,7 @@ $form = new FormValidator('update_course'); $form->addElement('header', '', $tool_name); // Title -$form->add_textfield('title', get_lang('Title'), true, array ('size' => '60')); +$form->add_textfield('title', get_lang('Title'), true, array ('class' => 'span6')); $form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'trim'); diff --git a/main/admin/session_add.php b/main/admin/session_add.php index 31980d5508..ba64fa3d5a 100644 --- a/main/admin/session_add.php +++ b/main/admin/session_add.php @@ -140,39 +140,34 @@ $thisYear=date('Y'); $thisMonth=date('m'); $thisDay=date('d'); - $tool_name = get_lang('AddSession'); -//display the header Display::display_header($tool_name); if (!empty($return)) { Display::display_error_message($return,false); } -?> -
- - -'; echo ''.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).''; echo ''; -?> -
-
+?> + + +
+
-
+ +
-
-
+
+
-
+ +
- -
-
-
+
+
-
+ +
+ '.$tag_list.' + '; + + $form->addElement('html',$pre_html.$multi_select.$post ); + $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php'; + $complete_text = get_lang('StartToType'); + //if cache is set to true the jquery will be called 1 time + $jquery_ready_content.= <<addElement('select', 'extra_'.$field_details[1], $field_details[3], api_get_timezones(), ''); + if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]); + break; + case USER_FIELD_TYPE_SOCIAL_PROFILE: + // get the social network's favicon + $icon_path = UserManager::get_favicon_from_url($extra_data['extra_'.$field_details[1]], $field_details[4]); + // special hack for hi5 + $leftpad = '1.7'; $top = '0.4'; $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $leftpad = '3'; $top = '0';} + // print the input field + $form->addElement('text', 'extra_'.$field_details[1], $field_details[3], array('size' => 60, 'style' => 'background-image: url(\''.$icon_path.'\'); background-repeat: no-repeat; background-position: 0.4em '.$top.'em; padding-left: '.$leftpad.'em; ')); + $form->applyFilter('extra_'.$field_details[1], 'stripslashes'); + $form->applyFilter('extra_'.$field_details[1], 'trim'); + if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]); + break; + } +} + +// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function +$htmlHeadXtra[] =''; + + +if (api_get_setting('profile', 'apikeys') == 'true') { + $form->addElement('html', '
'); + $form->addElement('text', 'api_key_generate', get_lang('MyApiKey'), array('size' => 40, 'id' => 'id_api_key_generate')); + $form->addElement('html', '
'); + $form->addElement('button', 'generate_api_key', get_lang('GenerateApiKey'), array('id' => 'id_generate_api_key', 'onclick' => 'generate_open_id_form()')); //generate_open_id_form() +} +// SUBMIT +if (is_profile_editable()) { + $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"'); +} else { + $form->freeze(); +} + +$user_data = array_merge($user_data, $extra_data); +$form->setDefaults($user_data); + +/* FUNCTIONS */ + + +/** + * Can a user edit his/her profile? + * + * @return boolean Editability of the profile + */ +function is_profile_editable() { + return $GLOBALS['profileIsEditable']; +} + +/* + PRODUCTIONS FUNCTIONS +*/ + +/** + * Upload a submitted user production. + * + * @param $user_id User id + * @return The filename of the new production or FALSE if the upload has failed + */ +function upload_user_production($user_id) { + $image_path = UserManager::get_user_picture_path_by_id($user_id, 'system', true); + + $production_repository = $image_path['dir'].$user_id.'/'; + + if (!file_exists($production_repository)) { + @mkdir($production_repository, api_get_permissions_for_new_directories(), true); + } + $filename = replace_dangerous_char($_FILES['production']['name']); + $filename = disable_dangerous_file($filename); + + if (filter_extension($filename)) { + if (@move_uploaded_file($_FILES['production']['tmp_name'], $production_repository.$filename)) { + return $filename; + } + } + return false; // this should be returned if anything went wrong with the upload +} + +/** + * Check current user's current password + * @param char password + * @return bool true o false + * @uses Gets user ID from global variable + */ +function check_user_password($password){ + global $_user; + $user_id = api_get_user_id(); + if ($user_id != strval(intval($user_id)) || empty($password)) { return false; } + $table_user = Database :: get_main_table(TABLE_MAIN_USER); + $password = api_get_encrypted_password($password); + $sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND password='".$password."'"; + $result = Database::query($sql_password); + return Database::num_rows($result) != 0; +} +/** + * Check current user's current password + * @param char email + * @return bool true o false + * @uses Gets user ID from global variable + */ +function check_user_email($email){ + global $_user; + $user_id = api_get_user_id(); + if ($user_id != strval(intval($user_id)) || empty($email)) { return false; } + $table_user = Database :: get_main_table(TABLE_MAIN_USER); + $sql_password = "SELECT * FROM $table_user WHERE user_id='".$user_id."' AND email='".$email."'"; + $result = Database::query($sql_password); + return Database::num_rows($result) != 0; +} + +/* MAIN CODE */ +$filtered_extension = false; +$update_success = false; +$upload_picture_success = false; +$upload_production_success = false; +$msg_fail_changue_email = false; +$msg_is_not_password = false; + +if (!empty($_SESSION['change_email'])) { + $msg_fail_changue_email= ($_SESSION['change_email'] == 'success'); + unset($_SESSION['change_email']); +} elseif (!empty($_SESSION['is_not_password'])) { + $msg_is_not_password = ($_SESSION['is_not_password'] == 'success'); + unset($_SESSION['is_not_password']); +} elseif (!empty($_SESSION['profile_update'])) { + $update_success = ($_SESSION['profile_update'] == 'success'); + unset($_SESSION['profile_update']); +} elseif (!empty($_SESSION['image_uploaded'])) { + $upload_picture_success = ($_SESSION['image_uploaded'] == 'success'); + unset($_SESSION['image_uploaded']); +} elseif (!empty($_SESSION['production_uploaded'])) { + $upload_production_success = ($_SESSION['production_uploaded'] == 'success'); + unset($_SESSION['production_uploaded']); +} + + +if ($form->validate()) { + + $wrong_current_password = false; +// $user_data = $form->exportValues(); + $user_data = $form->getSubmitValues(); + + // set password if a new one was provided + if (!empty($user_data['password0'])) { + if (check_user_password($user_data['password0'])) { + if (!empty($user_data['password1'])) { + $password = $user_data['password1']; + } + } else { + $wrong_current_password = true; + $_SESSION['is_not_password'] = 'success'; + } + } + if (empty($user_data['password0']) && !empty($user_data['password1'])) { + $wrong_current_password = true; + $_SESSION['is_not_password'] = 'success'; + } + + if (!check_user_email($user_data['email']) && !empty($user_data['password0']) && !$wrong_current_password) { + $changeemail = $user_data['email']; + } + + if (!check_user_email($user_data['email']) && empty($user_data['password0'])){ + $_SESSION['change_email'] = 'success'; + } + + // Upload picture if a new one is provided + if ($_FILES['picture']['size']) { + if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) { + $user_data['picture_uri'] = $new_picture; + $_SESSION['image_uploaded'] = 'success'; + } + } elseif (!empty($user_data['remove_picture'])) { + // remove existing picture if asked + UserManager::delete_user_picture(api_get_user_id()); + $user_data['picture_uri'] = ''; + } + + //Remove production + if (is_array($user_data['remove_production'])) { + foreach (array_keys($user_data['remove_production']) as $production) { + UserManager::remove_user_production(api_get_user_id(), urldecode($production)); + } + if ($production_list = UserManager::build_production_list(api_get_user_id(), true, true)) { + $form->insertElementBefore($form->createElement('static', null, null, $production_list), 'productions_list'); + } + $form->removeElement('productions_list'); + $file_deleted = true; + } + + // upload production if a new one is provided + if ($_FILES['production']['size']) { + $res = upload_user_production(api_get_user_id()); + if (!$res) { + //it's a bit excessive to assume the extension is the reason why upload_user_production() returned false, but it's true in most cases + $filtered_extension = true; + } else { + $_SESSION['production_uploaded'] = 'success'; + } + } + + // remove values that shouldn't go in the database + unset($user_data['password0'],$user_data['password1'], $user_data['password2'], $user_data['MAX_FILE_SIZE'], + $user_data['remove_picture'], $user_data['apply_change'],$user_data['email'] ); + + // Following RFC2396 (http://www.faqs.org/rfcs/rfc2396.html), a URI uses ':' as a reserved character + // we can thus ensure the URL doesn't contain any scheme name by searching for ':' in the string + $my_user_openid = isset($user_data['openid']) ? $user_data['openid'] : ''; + if (!preg_match('/^[^:]*:\/\/.*$/', $my_user_openid)) { + //ensure there is at least a http:// scheme in the URI provided + $user_data['openid'] = 'http://'.$my_user_openid; + } + $extras = array(); + + //Checking the user language + $languages = api_get_languages(); + if (!in_array($user_data['language'], $languages['folder'])) { + $user_data['language'] = api_get_setting('platformLanguage'); + } + + //Only update values that are request by the "profile" setting + $profile_list = api_get_setting('profile'); + //Adding missing variables + + $available_values_to_modify = array(); + foreach($profile_list as $key => $status) { + if ($status == 'true') { + if ($key == 'name') { + $available_values_to_modify[] = 'firstname'; + $available_values_to_modify[] = 'lastname'; + } elseif ($key == 'picture') { + $available_values_to_modify[] = 'picture_uri'; + } else { + $available_values_to_modify[] = $key; + } + } + } + //Fixing missing variables + $available_values_to_modify = array_merge($available_values_to_modify, array('competences', 'diplomas', 'openarea', 'teach', 'openid')); + + // build SQL query + $sql = "UPDATE $table_user SET"; + unset($user_data['api_key_generate']); + foreach ($user_data as $key => $value) { + if (substr($key, 0, 6) == 'extra_') { //an extra field + $new_key = substr($key, 6); + // format array date to 'Y-m-d' or date time to 'Y-m-d H:i:s' + if (is_array($value) && isset($value['Y']) && isset($value['F']) && isset($value['d'])) { + if (isset($value['H']) && isset($value['i'])) { + // extra field date time + $time = mktime($value['H'],$value['i'],0,$value['F'],$value['d'],$value['Y']); + $extras[$new_key] = date('Y-m-d H:i:s',$time); + } else { + // extra field date + $time = mktime(0,0,0,$value['F'],$value['d'],$value['Y']); + $extras[$new_key] = date('Y-m-d',$time); + } + } else { + $extras[$new_key] = $value; + } + } else { + if (in_array($key, $available_values_to_modify)) { + $sql .= " $key = '".Database::escape_string($value)."',"; + } + } + } + + //changue email + if (isset($changeemail) && !isset($password) && in_array('email', $available_values_to_modify)) { + $sql .= " email = '".Database::escape_string($changeemail)."' "; + } elseif (isset($password) && isset($changeemail) && in_array('email', $available_values_to_modify) && in_array('password', $available_values_to_modify)) { + $sql .= " email = '".Database::escape_string($changeemail)."', "; + $password = api_get_encrypted_password($password); + $sql .= " password = '".Database::escape_string($password)."'"; + } elseif (isset($password) && !isset($changeemail) && in_array('password', $available_values_to_modify)) { + $password = api_get_encrypted_password($password); + $sql .= " password = '".Database::escape_string($password)."'"; + } else { + // remove trailing , from the query we have so far + $sql = rtrim($sql, ','); + } + $sql .= " WHERE user_id = '".api_get_user_id()."'"; + Database::query($sql); + + // User tag process + //1. Deleting all user tags + $list_extra_field_type_tag = UserManager::get_all_extra_field_by_type(USER_FIELD_TYPE_TAG); + if (is_array($list_extra_field_type_tag) && count($list_extra_field_type_tag)>0) { + foreach ($list_extra_field_type_tag as $id) { + UserManager::delete_user_tags(api_get_user_id(), $id); + } + } + + //2. Update the extra fields and user tags if available + if (is_array($extras) && count($extras)> 0) { + foreach ($extras as $key => $value) { + //3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function + $myres = UserManager::update_extra_field_value(api_get_user_id(), $key, $value); + } + } + + // re-init the system to take new settings into account + $uidReset = true; + include api_get_path(INCLUDE_PATH).'local.inc.php'; + $_SESSION['profile_update'] = 'success'; + header("Location: ".api_get_self()."?{$_SERVER['QUERY_STRING']}".($filtered_extension && strpos($_SERVER['QUERY_STRING'], '&fe=1') === false ? '&fe=1' : '')); + exit; +} + + +/* MAIN DISPLAY SECTION */ +// the header +Display::display_header(get_lang('ModifyProfile')); + +if (api_get_setting('allow_social_tool') != 'true') { + + if (api_get_setting('extended_profile') == 'true') { + echo '
'; + + if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') { + echo ''.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).' '.get_lang('ViewSharedProfile').''; + } + if (api_get_setting('allow_message_tool') == 'true') { + echo ''.Display::return_icon('inbox.png').' '.get_lang('Messages').''; + } + $show = isset($_GET['show']) ? '&show='.Security::remove_XSS($_GET['show']) : ''; + + if (isset($_GET['type']) && $_GET['type'] == 'extended') { + echo ''.Display::return_icon('edit.png', get_lang('EditNormalProfile'),'',16).' '.get_lang('EditNormalProfile').''; + } else { + echo ''.Display::return_icon('edit.png', get_lang('EditExtendProfile'),'',16).' '.get_lang('EditExtendProfile').''; + } + + echo '
'; + } +} + +if (!empty($file_deleted)) { + Display :: display_confirmation_message(get_lang('FileDeleted'), false); +} elseif (!empty($update_success)) { + $message = get_lang('ProfileReg'); + + if ($upload_picture_success) { + $message .= '
'.get_lang('PictureUploaded'); + } + + if ($upload_production_success) { + $message.='
'.get_lang('ProductionUploaded'); + } + + Display :: display_confirmation_message($message, false); +} + + +if (!empty($msg_fail_changue_email)){ + $errormail=get_lang('ToChangeYourEmailMustTypeYourPassword'); + Display :: display_error_message($errormail, false); +} + +if (!empty($msg_is_not_password)){ + $warning_msg = get_lang('CurrentPasswordEmptyOrIncorrect'); + Display :: display_warning_message($warning_msg, false); +} + +//User picture size is calculated from SYSTEM path +$image_syspath = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true); +$image_syspath['dir'].$image_syspath['file']; + +$image_size = api_getimagesize($image_syspath['dir'].$image_syspath['file']); + +//Web path +$image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', false, true); +$image_dir = $image_path['dir']; +$image = $image_path['file']; +$image_file = $image_dir.$image; +$img_attributes = 'src="'.$image_file.'?rand='.time().'" ' + .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" ' + .'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" '; +if ($image_size['width'] > 300) { + //limit display width to 300px + $img_attributes .= 'width="300" '; +} + +// get the path,width and height from original picture +$big_image = $image_dir.'big_'.$image; + +$big_image_size = api_getimagesize($big_image); +$big_image_width = $big_image_size['width']; +$big_image_height = $big_image_size['height']; +$url_big_image = $big_image.'?rnd='.time(); + +if (api_get_setting('allow_social_tool') == 'true') { + echo '
'; + echo '
'; + SocialManager::show_social_menu('home', null, api_get_user_id(), false); + echo '
'; + + echo '
'; + echo '
'; + //Useless link + /* + echo '
'; + if (api_get_setting('extended_profile') == 'true') { + $show = isset($_GET['show']) ? '&show='.Security::remove_XSS($_GET['show']) : ''; + if (isset($_GET['type']) && $_GET['type'] == 'reduced') { + echo ''; + } else { + echo ''; + } + } + echo '
';*/ + $form->display(); + echo '
'; + echo '
'; +} else { + // Style position:absolute has been removed for Opera-compatibility. + //echo '
'; + echo '
'; + + if ($image == 'unknown.jpg') { + echo ''; + } else { + echo ''; + } + echo '
'; + $form->display(); +} +Display :: display_footer(); diff --git a/main/inc/global_error_message.inc.php b/main/inc/global_error_message.inc.php index e27282e0e1..7fb8248127 100644 --- a/main/inc/global_error_message.inc.php +++ b/main/inc/global_error_message.inc.php @@ -183,9 +183,8 @@ if (is_int($global_error_code) && $global_error_code > 0) { Chamilo
-
-
-
+
+