Browse Source

Merge with fe0a59ce2a0823b99f67d4d0fbf1b87356600fbb

Ivan Tcholakov 15 years ago
parent
commit
9338a0dc4d

+ 0 - 1
main/admin/course_list.php

@@ -109,7 +109,6 @@ function get_course_data($from, $number_of_items, $column, $direction)
 	while ($course = Database::fetch_row($res))
 	{
 		//place colour icons in front of courses
-		//$course[1] = get_course_visibility_icon($course[10]).'<a href="../course_home/course_home.php?cidReq='.$course[0].'">'.$course[1].'</a>'; // This is not the preferable way to go to the homepage.
 		$course[1] = get_course_visibility_icon($course[10]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[11].'/index.php">'.$course[1].'</a>';
 
 		$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');

+ 16 - 15
main/admin/subscribe_user2course.php

@@ -218,10 +218,11 @@ if ($use_extra_fields) {
 	}		
 }
 
+$target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
 $sql = "SELECT user_id,lastname,firstname,username
 		FROM $tbl_user
-		WHERE user_id<>2 AND lastname LIKE '".$first_letter_user."%' $where_filter
-		ORDER BY ". (count($users) > 0 ? "(user_id IN(".implode(',', $users).")) DESC," : "")." lastname";
+		WHERE user_id<>2 AND ".$target_name." LIKE '".$first_letter_user."%' $where_filter
+		ORDER BY ". (count($users) > 0 ? "(user_id IN(".implode(',', $users).")) DESC," : "")." ".$target_name;
 
 global $_configuration;	
 if ($_configuration['multiple_access_urls']==true) {	
@@ -231,8 +232,8 @@ if ($_configuration['multiple_access_urls']==true) {
 		$sql = "SELECT u.user_id,lastname,firstname,username  FROM ".$tbl_user ." u 			
 		INNER JOIN $tbl_user_rel_access_url user_rel_url 
 		ON (user_rel_url.user_id = u.user_id)						
-		WHERE u.user_id<>2 AND access_url_id =  $access_url_id AND (lastname LIKE '".$first_letter_user."%' )  $where_filter
-		ORDER BY ". (count($users) > 0 ? "(u.user_id IN(".implode(',', $users).")) DESC," : "")." lastname";			
+		WHERE u.user_id<>2 AND access_url_id =  $access_url_id AND (".$target_name." LIKE '".$first_letter_user."%' ) $where_filter
+		ORDER BY ". (count($users) > 0 ? "(u.user_id IN(".implode(',', $users).")) DESC," : "")." ".$target_name;			
 	}
 }
 
@@ -337,13 +338,13 @@ if (is_array($extra_field_list)) {
    <tr>
     <td width="40%" align="center">
      <select name="UserList[]" multiple="multiple" size="20" style="width:230px;">
-		<?php
+<?php
 		foreach ($db_users as $user) {
-		?>
-			  <option value="<?php echo $user['user_id']; ?>" <?php if(in_array($user['user_id'],$users)) echo 'selected="selected"'; ?>><?php echo $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')'; ?></option>
-		<?php
-		}
-		?>
+?>
+	  <option value="<?php echo $user['user_id']; ?>" <?php if(in_array($user['user_id'],$users)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; ?></option>
+<?php
+}
+?>
     </select>
    </td>
    <td width="20%" valign="middle" align="center">
@@ -351,12 +352,12 @@ if (is_array($extra_field_list)) {
    </td>
    <td width="40%" align="center">
     <select name="CourseList[]" multiple="multiple" size="20" style="width:230px;">
-		<?php
+<?php
 		foreach ($db_courses as $course) {
-		?>
-			 <option value="<?php echo $course['code']; ?>" <?php if(in_array($course['code'],$courses)) echo 'selected="selected"'; ?>><?php echo '('.$course['visual_code'].') '.$course['title']; ?></option>
-		<?php
-		}
+?>
+	 <option value="<?php echo $course['code']; ?>" <?php if(in_array($course['code'],$courses)) echo 'selected="selected"'; ?>><?php echo '('.$course['visual_code'].') '.$course['title']; ?></option>
+<?php
+}
 ?>
     </select>
    </td>

+ 27 - 11
main/admin/user_add.php

@@ -73,16 +73,32 @@ $tool_name = get_lang('AddUsers');
 // Create the form
 $form = new FormValidator('user_add');
 $form->addElement('header', '', $tool_name);
-// Lastname
-$form->addElement('text','lastname',get_lang('LastName'));
-$form->applyFilter('lastname','html_filter');
-$form->applyFilter('lastname','trim');
-$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
-// Firstname
-$form->addElement('text','firstname',get_lang('FirstName'));
-$form->applyFilter('firstname','html_filter');
-$form->applyFilter('firstname','trim');
-$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+if (api_is_western_name_order())
+{
+	// Firstname
+	$form->addElement('text','firstname',get_lang('FirstName'));
+	$form->applyFilter('firstname','html_filter');
+	$form->applyFilter('firstname','trim');
+	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+	// Lastname
+	$form->addElement('text','lastname',get_lang('LastName'));
+	$form->applyFilter('lastname','html_filter');
+	$form->applyFilter('lastname','trim');
+	$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
+}
+else
+{
+	// Lastname
+	$form->addElement('text','lastname',get_lang('LastName'));
+	$form->applyFilter('lastname','html_filter');
+	$form->applyFilter('lastname','trim');
+	$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
+	// Firstname
+	$form->addElement('text','firstname',get_lang('FirstName'));
+	$form->applyFilter('firstname','html_filter');
+	$form->applyFilter('firstname','trim');
+	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+}
 // Official code
 $form->addElement('text', 'official_code', get_lang('OfficialCode'),array('size' => '40'));
 $form->applyFilter('official_code','html_filter');
@@ -146,7 +162,7 @@ if(is_array($drh_list))
 {
 	foreach($drh_list as $drh)
 	{
-		$drh_select->addOption($drh['lastname'].' '.$drh['firstname'],$drh['user_id']);
+		$drh_select->addOption(api_get_person_name($drh['firstname'], $drh['lastname']), $drh['user_id']);
 	}
 }
 $form->addElement('html', '</div>');

+ 29 - 14
main/admin/user_edit.php

@@ -99,17 +99,32 @@ $form = new FormValidator('user_add','post','','',array('style' => 'width: 60%;
 $form->addElement('header', '', $tool_name);
 $form->addElement('hidden','user_id',$user_id);
 
-// Lastname
-$form->addElement('text','lastname',get_lang('LastName'));
-$form->applyFilter('lastname','html_filter');
-$form->applyFilter('lastname','trim');
-$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
-
-// Firstname
-$form->addElement('text','firstname',get_lang('FirstName'));
-$form->applyFilter('firstname','html_filter');
-$form->applyFilter('firstname','trim');
-$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+if (api_is_western_name_order())
+{
+	// Firstname
+	$form->addElement('text','firstname',get_lang('FirstName'));
+	$form->applyFilter('firstname','html_filter');
+	$form->applyFilter('firstname','trim');
+	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+	// Lastname
+	$form->addElement('text','lastname',get_lang('LastName'));
+	$form->applyFilter('lastname','html_filter');
+	$form->applyFilter('lastname','trim');
+	$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
+}
+else
+{
+	// Lastname
+	$form->addElement('text','lastname',get_lang('LastName'));
+	$form->applyFilter('lastname','html_filter');
+	$form->applyFilter('lastname','trim');
+	$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
+	// Firstname
+	$form->addElement('text','firstname',get_lang('FirstName'));
+	$form->applyFilter('firstname','html_filter');
+	$form->applyFilter('firstname','trim');
+	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+}
 
 // Official code
 $form->addElement('text', 'official_code', get_lang('OfficialCode'),array('size' => '40'));
@@ -186,7 +201,7 @@ if (count($drh_list) == 0) {
 
 foreach($drh_list as $drh)
 {
-	$drh_select->addOption($drh['lastname'].' '.$drh['firstname'],$drh['user_id']);
+	$drh_select->addOption(api_get_person_name($drh['firstname'], $drh['lastname']), $drh['user_id']);
 }
 $form->addElement('html', '</div>');
 
@@ -335,7 +350,7 @@ if( $form->validate())
         {
         	mkpath($picture_location);
         }
-	    $picture_infos=getimagesize($_FILES['picture']['tmp_name']);
+		$picture_infos=@getimagesize($_FILES['picture']['tmp_name']);
 		$type=$picture_infos[2];
 		$small_temp = UserManager::resize_picture($_FILES['picture']['tmp_name'], 22); //small picture
 		$medium_temp = UserManager::resize_picture($_FILES['picture']['tmp_name'], 85); //medium picture
@@ -487,7 +502,7 @@ $image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'i
 $image_size = @getimagesize(api_url_to_local_path($image_file));
 
 $img_attributes = 'src="'.$image_file.'?rand='.time().'" '
-    .'alt="'.$user_data['lastname'].' '.$user_data['firstname'].'" '
+    .'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
     .'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
 
 if ($image_size[0] > 300) //limit display width to 300px

+ 7 - 7
main/admin/user_fields.php

@@ -172,15 +172,15 @@ if(1)
 	$table = new SortableTableFromArrayConfig($extra_fields, 5, 50, '', $column_show, $column_order, 'ASC');
 	$table->set_additional_parameters($parameters);
 	$table->set_header(0, '', false);
-	$table->set_header(1, get_lang('FieldLabel'));
-	$table->set_header(2, get_lang('FieldType'));
+	$table->set_header(1, get_lang('FieldLabel'), false);
+	$table->set_header(2, get_lang('FieldType'), false);
 	$table->set_header(3, get_lang('FieldTitle'),false);
 	$table->set_header(4, get_lang('FieldDefaultValue'),false);
-	$table->set_header(5, get_lang('FieldOrder'));
-	$table->set_header(6, get_lang('FieldVisibility'));
-	$table->set_header(7, get_lang('FieldChangeability'));
-	$table->set_header(8, get_lang('FieldFilter'));	
-	$table->set_header(9, get_lang('Modify'));
+	$table->set_header(5, get_lang('FieldOrder'), false);
+	$table->set_header(6, get_lang('FieldVisibility'), false);
+	$table->set_header(7, get_lang('FieldChangeability'), false);
+	$table->set_header(8, get_lang('FieldFilter'), false);	
+	$table->set_header(9, get_lang('Modify'), false);
 	$table->set_column_filter(5, 'order_filter');
 	$table->set_column_filter(6, 'modify_visibility');
 	$table->set_column_filter(7, 'modify_changeability');

+ 3 - 3
main/admin/user_information.php

@@ -50,7 +50,7 @@ if( ! isset($_GET['user_id']))
 	api_not_allowed();	
 }
 $user = api_get_user_info($_GET['user_id']);
-$tool_name = $user['firstName'].' '.$user['lastName'].(empty($user['official_code'])?'':' ('.$user['official_code'].')');
+$tool_name = api_get_person_name($user['firstName'], $user['lastName']).(empty($user['official_code'])?'':' ('.$user['official_code'].')');
 Display::display_header($tool_name);
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
@@ -85,7 +85,7 @@ $height += 30;
 $width += 30;
 $window_name = 'window'.uniqid('');
 $onclick = $window_name."=window.open('".$fullurl."','".$window_name."','alwaysRaised=yes, alwaysLowered=no,alwaysOnTop=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=".$width.",height=".$height.",left=200,top=20'); return false;";
-echo '<a href="#" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
+echo '<a href="javascript: void(0);" onclick="'.$onclick.'" ><img src="'.$fullurl.'" '.$resizing.' alt="'.$alt.'"/></a><br />';
 
 echo '<p>'. ($user['status'] == 1 ? get_lang('Teacher') : get_lang('Student')).'</p>';
 echo '<p>'.Display :: encrypted_mailto_link($user['mail'], $user['mail']).'</p>';
@@ -142,7 +142,7 @@ if(count($sessions)>0){
 		$personal_course_list = array();
 		
 		$id_session = $enreg['id'];
-		$personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF(session_course.id_coach = ".$user_id.",'2', '5')
+		$personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF(session_course.id_coach = ".$user_id.",'2', '5')
 									 FROM $tbl_session_course as session_course
 									 INNER JOIN $tbl_course AS course
 									 	ON course.code = session_course.course_code

+ 18 - 6
main/admin/user_list.php

@@ -173,8 +173,12 @@ function login_user($user_id) {
 	$lastname = $result['lastname'];
 	$user_id = $result['user_id'];
 
-	//$message = "Attempting to login as ".$firstname." ".$lastname." (id ".$user_id.")";
-	$message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname,$user_id);
+	//$message = "Attempting to login as ".api_get_person_name($firstname, $lastname)." (id ".$user_id.")";
+	if (api_is_western_name_order()) {
+		$message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname,$user_id);
+	} else {
+		$message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $user_id);
+	}
 
 	$loginFailed = false;
 	$uidReset = false;
@@ -323,8 +327,11 @@ function get_user_data($from, $number_of_items, $column, $direction)
 	$sql = "SELECT
                  u.user_id				AS col0,
                  u.official_code		AS col1,
-				 u.lastname 			AS col2,
-                 u.firstname 			AS col3,
+				 ".(api_is_western_name_order() 
+                 ? "u.firstname 			AS col2,
+                 u.lastname 			AS col3,"
+                 : "u.lastname 			AS col2,
+                 u.firstname 			AS col3,")."
                  u.username				AS col4,
                  u.email				AS col5,
                  u.status				AS col6,
@@ -721,8 +728,13 @@ else
 	$table->set_additional_parameters($parameters);
 	$table->set_header(0, '', false);
 	$table->set_header(1, get_lang('OfficialCode'));
-	$table->set_header(2, get_lang('LastName'));
-	$table->set_header(3, get_lang('FirstName'));
+	if (api_is_western_name_order()) {
+		$table->set_header(2, get_lang('FirstName'));
+		$table->set_header(3, get_lang('LastName'));
+	} else {
+		$table->set_header(2, get_lang('LastName'));
+		$table->set_header(3, get_lang('FirstName'));
+	}
 	$table->set_header(4, get_lang('LoginName'));
 	$table->set_header(5, get_lang('Email'));
 	$table->set_header(6, get_lang('Status'));

+ 185 - 179
main/auth/inscription.php

@@ -81,201 +81,207 @@ if (api_get_setting('allow_terms_conditions')=='true') {
 	$display_all_form=true;
 }
 if ($display_all_form===true) {
+
+	if (api_is_western_name_order()) {
+		//	FIRST NAME and LAST NAME
+		$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+		$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40));
+	} else {
+		//	LAST NAME and FIRST NAME
+		$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40));
+		$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+	}
+	$form->applyFilter(array('lastname', 'firstname'), 'trim');
+	$form->addRule('lastname',  get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
+	//	EMAIL
+	$form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
+	if (api_get_setting('registration', 'email') == 'true')
+		$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('email', get_lang('EmailWrong'), 'email');
+	if (api_get_setting('openid_authentication')=='true') {
+		$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40));	
+	}
+	/*
+	//	OFFICIAL CODE
+	if (CONFVAL_ASK_FOR_OFFICIAL_CODE) {
+		$form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40));
+		if (api_get_setting('registration', 'officialcode') == 'true')
+			$form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
+	}
+	*/
+	//	USERNAME
+	$form->addElement('text', 'username', get_lang('UserName'), array('size' => 20));
+	$form->applyFilter('username','trim');
+	$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('username', get_lang('UsernameWrong'), 'username');
+	$form->addRule('username', get_lang('UserTaken'), 'username_available');
+	$form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'),'20'), 'maxlength',20);
+	//	PASSWORD
+	$form->addElement('password', 'pass1', get_lang('Pass'),         array('size' => 40));
+	$form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 40));
+	$form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required');
+	$form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare');
+	if (CHECK_PASS_EASY_TO_FIND)
+		$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
+
+	//	PHONE
+	$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 40));
+	if (api_get_setting('registration', 'phone') == 'true')
+		$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
 	
-//	LAST NAME and FIRST NAME
-$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40));
-$form->applyFilter('lastname','trim');
-$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
-$form->applyFilter('firstname','trim');
-$form->addRule('lastname',  get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
-//	EMAIL
-$form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
-if (api_get_setting('registration', 'email') == 'true')
-	$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('email', get_lang('EmailWrong'), 'email');
-if (api_get_setting('openid_authentication')=='true') {
-	$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40));	
-}
-/*
-//	OFFICIAL CODE
-if (CONFVAL_ASK_FOR_OFFICIAL_CODE) {
-	$form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40));
-	if (api_get_setting('registration', 'officialcode') == 'true')
-		$form->addRule('official_code', get_lang('ThisFieldIsRequired'), 'required');
-}
-*/
-//	USERNAME
-$form->addElement('text', 'username', get_lang('UserName'), array('size' => 20));
-$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('username', get_lang('UsernameWrong'), 'username');
-$form->addRule('username', get_lang('UserTaken'), 'username_available');
-$form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'),'20'), 'maxlength',20);
-//	PASSWORD
-$form->addElement('password', 'pass1', get_lang('Pass'),         array('size' => 40));
-$form->addElement('password', 'pass2', get_lang('Confirmation'), array('size' => 40));
-$form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required');
-$form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare');
-if (CHECK_PASS_EASY_TO_FIND)
-	$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
-
-//	PHONE
-$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 40));
-if (api_get_setting('registration', 'phone') == 'true')
-	$form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required');
-	
-// PICTURE
-/*if (api_get_setting('profile', 'picture') == 'true') {
-	$form->addElement('file', 'picture', get_lang('AddPicture'));
-	$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
-	$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
-}*/
-
-//	LANGUAGE
-if (api_get_setting('registration', 'language') == 'true') {
-	$form->addElement('select_language', 'language', get_lang('Language'));
-}
-//	STUDENT/TEACHER
-if (api_get_setting('allow_registration_as_teacher') <> 'false') {
-	$form->addElement('radio', 'status', get_lang('Status'), get_lang('RegStudent'), STUDENT);
-	$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER);
-}
+	// PICTURE
+	/*if (api_get_setting('profile', 'picture') == 'true') {
+		$form->addElement('file', 'picture', get_lang('AddPicture'));
+		$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
+		$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
+	}*/
+
+	//	LANGUAGE
+	if (api_get_setting('registration', 'language') == 'true') {
+		$form->addElement('select_language', 'language', get_lang('Language'));
+	}
+	//	STUDENT/TEACHER
+	if (api_get_setting('allow_registration_as_teacher') <> 'false') {
+		$form->addElement('radio', 'status', get_lang('Status'), get_lang('RegStudent'), STUDENT);
+		$form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER);
+	}
 
-//	EXTENDED FIELDS
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mycomptetences') == 'true')
-{
-	$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mydiplomas') == 'true')
-{
-	$form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','myteach') == 'true')
-{
-	$form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mypersonalopenarea') == 'true')
-{
-	$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-}
-if (api_get_setting('extended_profile') == 'true')
-{
-	if (api_get_setting('extendedprofile_registrationrequired','mycomptetences') == 'true')
+	//	EXTENDED FIELDS
+	if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mycomptetences') == 'true')
 	{
-		$form->addRule('competences', get_lang('ThisFieldIsRequired'), 'required');
+		$form->add_html_editor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
 	}
-	if (api_get_setting('extendedprofile_registrationrequired','mydiplomas') == 'true')
+	if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mydiplomas') == 'true')
 	{
-		$form->addRule('diplomas', get_lang('ThisFieldIsRequired'), 'required');
+		$form->add_html_editor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
 	}
-	if (api_get_setting('extendedprofile_registrationrequired','myteach') == 'true')
+	if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','myteach') == 'true')
 	{
-		$form->addRule('teach', get_lang('ThisFieldIsRequired'), 'required');
+		$form->add_html_editor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
 	}
-	if (api_get_setting('extendedprofile_registrationrequired','mypersonalopenarea') == 'true')
+	if (api_get_setting('extended_profile') == 'true' AND api_get_setting('extendedprofile_registration','mypersonalopenarea') == 'true')
 	{
-		$form->addRule('openarea', get_lang('ThisFieldIsRequired'), 'required');
+		$form->add_html_editor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
 	}
-}
-// EXTRA FIELDS
-$extra = UserManager::get_extra_fields(0,50,5,'ASC');
-$extra_data = UserManager::get_extra_user_data(api_get_user_id(),true);
-foreach ($extra as $id => $field_details) {
-	if ($field_details[6] == 0) {
-		continue;
+	if (api_get_setting('extended_profile') == 'true')
+	{
+		if (api_get_setting('extendedprofile_registrationrequired','mycomptetences') == 'true')
+		{
+			$form->addRule('competences', get_lang('ThisFieldIsRequired'), 'required');
+		}
+		if (api_get_setting('extendedprofile_registrationrequired','mydiplomas') == 'true')
+		{
+			$form->addRule('diplomas', get_lang('ThisFieldIsRequired'), 'required');
+		}
+		if (api_get_setting('extendedprofile_registrationrequired','myteach') == 'true')
+		{
+			$form->addRule('teach', get_lang('ThisFieldIsRequired'), 'required');
+		}
+		if (api_get_setting('extendedprofile_registrationrequired','mypersonalopenarea') == 'true')
+		{
+			$form->addRule('openarea', get_lang('ThisFieldIsRequired'), 'required');
+		}
 	}
-	switch($field_details[2]) {
-		case USER_FIELD_TYPE_TEXT:
-			$form->addElement('text', 'extra_'.$field_details[1], $field_details[3], array('size' => 40));
-			$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;
-		case USER_FIELD_TYPE_TEXTAREA:
-			$form->add_html_editor('extra_'.$field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
-			//$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
-			$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;
-		case USER_FIELD_TYPE_RADIO:
-			$group = array();
-			foreach ($field_details[9] as $option_id => $option_details) {
-				$options[$option_details[1]] = $option_details[2];
-				$group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1],$option_details[2].'<br />',$option_details[1]);
-			}
-			$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);	
-			break;
-		case USER_FIELD_TYPE_SELECT:
-			$options = array();
-			foreach($field_details[9] as $option_id => $option_details) {
-				$options[$option_details[1]] = $option_details[2];
-			}
-			$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,'');	
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);			
-			break;
-		case USER_FIELD_TYPE_SELECT_MULTIPLE:
-			$options = array();
-			foreach ($field_details[9] as $option_id => $option_details) {
-				$options[$option_details[1]] = $option_details[2];
-			}
-			$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,array('multiple' => 'multiple'));
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);	
-			break;
-		case USER_FIELD_TYPE_DATE:
-			$form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
-			$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
-			$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
-			$form -> setDefaults($defaults);
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-			$form->applyFilter('theme', 'trim');
-			break;
-		case USER_FIELD_TYPE_DATETIME:
-			$form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
-			$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
-			$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
-			$form -> setDefaults($defaults);
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-			$form->applyFilter('theme', 'trim');
-			break;
-		case USER_FIELD_TYPE_DOUBLE_SELECT:
-			foreach ($field_details[9] as $key=>$element) {
-				if ($element[2][0] == '*') {
-					$values['*'][$element[0]] = str_replace('*','',$element[2]);
-				} else {
-					$values[0][$element[0]] = $element[2];
+	// EXTRA FIELDS
+	$extra = UserManager::get_extra_fields(0,50,5,'ASC');
+	$extra_data = UserManager::get_extra_user_data(api_get_user_id(),true);
+	foreach ($extra as $id => $field_details) {
+		if ($field_details[6] == 0) {
+			continue;
+		}
+		switch($field_details[2]) {
+			case USER_FIELD_TYPE_TEXT:
+				$form->addElement('text', 'extra_'.$field_details[1], $field_details[3], array('size' => 40));
+				$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;
+			case USER_FIELD_TYPE_TEXTAREA:
+				$form->add_html_editor('extra_'.$field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
+				//$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
+				$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;
+			case USER_FIELD_TYPE_RADIO:
+				$group = array();
+				foreach ($field_details[9] as $option_id => $option_details) {
+					$options[$option_details[1]] = $option_details[2];
+					$group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1],$option_details[2].'<br />',$option_details[1]);
 				}
-			}
-			
-			$group='';
-			$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1],'',$values[0],'');
-			$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*','',$values['*'],'');
-			$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
-			if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
-
-			// recoding the selected values for double : if the user has selected certain values, we have to assign them to the correct select form
-			if (key_exists('extra_'.$field_details[1], $extra_data)) {
-				// exploding all the selected values (of both select forms)
-				$selected_values = explode(';',$extra_data['extra_'.$field_details[1]]);
-				$extra_data['extra_'.$field_details[1]]  =array();
-				
-				// looping through the selected values and assigning the selected values to either the first or second select form
-				foreach ($selected_values as $key=>$selected_value) {
-					if (key_exists($selected_value,$values[0])) {
-						$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1]] = $selected_value;
+				$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);	
+				break;
+			case USER_FIELD_TYPE_SELECT:
+				$options = array();
+				foreach($field_details[9] as $option_id => $option_details) {
+					$options[$option_details[1]] = $option_details[2];
+				}
+				$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,'');	
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);			
+				break;
+			case USER_FIELD_TYPE_SELECT_MULTIPLE:
+				$options = array();
+				foreach ($field_details[9] as $option_id => $option_details) {
+					$options[$option_details[1]] = $option_details[2];
+				}
+				$form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,array('multiple' => 'multiple'));
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);	
+				break;
+			case USER_FIELD_TYPE_DATE:
+				$form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
+				$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
+				$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
+				$form -> setDefaults($defaults);
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				$form->applyFilter('theme', 'trim');
+				break;
+			case USER_FIELD_TYPE_DATETIME:
+				$form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration'));
+				$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
+				$defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
+				$form -> setDefaults($defaults);
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+				$form->applyFilter('theme', 'trim');
+				break;
+			case USER_FIELD_TYPE_DOUBLE_SELECT:
+				foreach ($field_details[9] as $key=>$element) {
+					if ($element[2][0] == '*') {
+						$values['*'][$element[0]] = str_replace('*','',$element[2]);
 					} else {
-						$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1].'*'] = $selected_value;
+						$values[0][$element[0]] = $element[2];
 					}
 				}
-			}
-			break;
-		case USER_FIELD_TYPE_DIVIDER:
-			$form->addElement('static',$field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
-			break;
+
+				$group='';
+				$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1],'',$values[0],'');
+				$group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*','',$values['*'],'');
+				$form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
+				if ($field_details[7] == 0)	$form->freeze('extra_'.$field_details[1]);
+
+				// recoding the selected values for double : if the user has selected certain values, we have to assign them to the correct select form
+				if (key_exists('extra_'.$field_details[1], $extra_data)) {
+					// exploding all the selected values (of both select forms)
+					$selected_values = explode(';',$extra_data['extra_'.$field_details[1]]);
+					$extra_data['extra_'.$field_details[1]]  =array();
+
+					// looping through the selected values and assigning the selected values to either the first or second select form
+					foreach ($selected_values as $key=>$selected_value) {
+						if (key_exists($selected_value,$values[0])) {
+							$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1]] = $selected_value;
+						} else {
+							$extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1].'*'] = $selected_value;
+						}
+					}
+				}
+				break;
+			case USER_FIELD_TYPE_DIVIDER:
+				$form->addElement('static',$field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
+				break;
+		}
 	}
-}
 
 }
 //------------ Terms and conditions

+ 18 - 8
main/auth/profile.php

@@ -165,9 +165,15 @@ if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true') {
 	$form->applyFilter('theme', 'trim');
 }
 
-//	LAST NAME and FIRST NAME
-$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40));
-$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+if (api_is_western_name_order()) {
+	//	FIRST NAME and LAST NAME
+	$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+	$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40));
+} else {
+	//	LAST NAME and FIRST NAME
+	$form->addElement('text', 'lastname',  get_lang('LastName'),  array('size' => 40));
+	$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
+}
 if (api_get_setting('profile', 'name') !== 'true')
 	$form->freeze(array('lastname', 'firstname'));
 $form->applyFilter(array('lastname', 'firstname'), 'stripslashes');
@@ -470,7 +476,7 @@ function upload_user_image($user_id)
 	}
 	
 	// get the picture and resize only if the picture is bigger width
-	$picture_infos=getimagesize($_FILES['picture']['tmp_name']);	
+	$picture_infos=@getimagesize($_FILES['picture']['tmp_name']);	
 	$type=$picture_infos[2];
 	$small_temp = UserManager::resize_picture($_FILES['picture']['tmp_name'], 22); //small picture
 	$medium_temp = UserManager::resize_picture($_FILES['picture']['tmp_name'], 85); //medium picture
@@ -724,12 +730,12 @@ if (isset($_GET['show'])) {
 	
 	if ((api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') ||(api_get_setting('allow_social_tool')=='true')) {
 		$interbreadcrumb[]= array (
-		'url' => '#',
+		'url' => 'javascript: void(0);',
 		'name' => get_lang('SocialNetwork')
 		);
 	} elseif ((api_get_setting('allow_social_tool')=='false' && api_get_setting('allow_message_tool')=='true')) {
 		$interbreadcrumb[]= array (
-		'url' => '#',
+		'url' => 'javascript: void(0);',
 		'name' => get_lang('MessageTool')
 		);	
 	}
@@ -793,7 +799,7 @@ $image_dir = $image_path['dir'];
 $image = $image_path['file'];
 $image_file = $image_dir.$image;
 $img_attributes = 'src="'.$image_file.'?rand='.time().'" '
-	.'alt="'.$user_data['lastname'].' '.$user_data['firstname'].'" '
+	.'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[0] > 300) {
 	//limit display width to 300px
@@ -808,7 +814,11 @@ $big_image_width= $big_image_size[0];
 $big_image_height= $big_image_size[1];
 $url_big_image = $big_image.'?rnd='.time();
 
-echo '<div id="image-message-container" style="float:right;display:inline;position:absolute;padding:3px;width:250px;" >';
+// Modified by Ivan Tcholakov, 14-AUG-2009.
+// The position:absolute style has been removed for Opera-compatibility.
+//echo '<div id="image-message-container" style="float:right;display:inline;position:absolute;padding:3px;width:250px;" >';
+echo '<div id="image-message-container" style="float:right;display:inline;padding:3px;width:250px;" >';
+//
 if ($image=='unknown.jpg') {
 	echo '<img '.$img_attributes.' />';
 } else {