From d7ac1ce93b34b34a028c2dec36712539c19ad9e5 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Fri, 4 Sep 2009 14:42:51 +0300 Subject: [PATCH] Bug #3646 and Issue #306 - Documents, Drobbox: Fixing person name order to be dependable on the internationalization settings, other minor corrections. --- main/document/document.inc.php | 8 ++++---- main/document/document.php | 28 +++++++++++++------------- main/dropbox/dropbox_class.inc.php | 2 +- main/dropbox/dropbox_functions.inc.php | 20 +++++++++--------- main/dropbox/dropbox_init.inc.php | 4 ++-- main/dropbox/dropbox_submit.php | 8 ++++---- main/dropbox/index.php | 1 + 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/main/document/document.inc.php b/main/document/document.inc.php index 04c4bfa7a5..eecabe83e6 100644 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -102,7 +102,7 @@ function build_directory_selector($folders,$curdirpath,$group_dir='',$changeRend elseif(strstr($folder_titles[$folder], 'sf_user_')) { $userinfo=Database::get_user_info_from_id(substr($folder_titles[$folder],8)); - $folder_titles[$folder]=$userinfo['lastname'].', '.$userinfo['firstname']; + $folder_titles[$folder]=api_get_person_name($userinfo['firstname'], $userinfo['lastname']); } $label = str_repeat('   ',count($path_parts)-2).' — '.$folder_titles[$folder]; @@ -189,7 +189,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility $url=$www.$path; } //files that we want opened in a new window - if($ext=='txt') //add here + if($ext=='txt' || $ext=='log' || $ext=='css' || $ext=='js') //add here { $target='_blank'; } @@ -211,7 +211,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility elseif(strstr($tooltip_title, 'sf_user_')) { $userinfo=Database::get_user_info_from_id(substr($tooltip_title,8)); - $tooltip_title_alt=$userinfo['lastname'].', '.$userinfo['firstname']; + $tooltip_title_alt=api_get_person_name($userinfo['firstname'], $userinfo['lastname']); } else { @@ -271,7 +271,7 @@ function build_document_icon_tag($type, $path) { $icon = '../upload/users/'.substr($basename,8).'/'.$image_path['file']; } - $basename = $userinfo['lastname'].', '.$userinfo['firstname']; + $basename = api_get_person_name($userinfo['firstname'], $userinfo['lastname']); } else { diff --git a/main/document/document.php b/main/document/document.php index e2363ca7af..9b426e3a57 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -318,7 +318,7 @@ for ($i=0; $i<$array_len;$i++) elseif(strstr($dir_array[$i], 'sf_user_')) { $userinfo=Database::get_user_info_from_id(substr($dir_array[$i], 8)); - $dir_array[$i]=$userinfo['lastname'].', '.$userinfo['firstname']; + $dir_array[$i]=api_get_person_name($userinfo['firstname'], $userinfo['lastname']); } $url_dir='document.php?&curdirpath='.$dir_acum.$dir_array[$i]; @@ -370,7 +370,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY ======================================*/ $my_get_move=Security::remove_XSS($_GET['move']); if (isset($_GET['move']) && $_GET['move']!='') - { + { if (!$is_allowed_to_edit) { if(DocumentManager::check_readonly($_course,$_user['user_id'],$my_get_move)) @@ -606,7 +606,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY $template_text .= ''; $template_text .= ''; //show the form - Display::display_normal_message($template_text,false); + Display::display_normal_message($template_text,false); } elseif(isset($_GET['add_as_template']) && isset($_POST['create_template'])) { @@ -636,26 +636,26 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY // upload dir $upload_dir = api_get_path(SYS_CODE_PATH).'upload/template_thumbnails/'; - + // resize image to max default and end upload require_once (api_get_path(LIBRARY_PATH).'image.lib.php'); $temp = new image($_FILES['template_image']['tmp_name']); - $picture_infos=getimagesize($_FILES['template_image']['tmp_name']); - + $picture_infos = @getimagesize($_FILES['template_image']['tmp_name']); + $max_width_for_picture = 100; - + if ($picture_infos[0]>$max_width_for_picture) { $thumbwidth = $max_width_for_picture; if (empty($thumbwidth) or $thumbwidth==0) { $thumbwidth=$max_width_for_picture; } $new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]); - + $temp->resize($thumbwidth,$new_height,0); } - + $type=$picture_infos[2]; - + switch (!empty($type)) { case 2 : $temp->send_image('JPG',$upload_dir.$new_file_name); break; @@ -668,7 +668,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY } DocumentManager::set_document_as_template($title, $description, $document_id_for_template, $course_code, $user_id, $new_file_name); - Display::display_confirmation_message(get_lang('DocumentSetAsTemplate')); + Display::display_confirmation_message(get_lang('DocumentSetAsTemplate')); } if(isset($_GET['remove_as_template'])) { @@ -741,12 +741,12 @@ if(isset($docs_and_folders) && is_array($docs_and_folders)) $document_name=$id['title']; } else { $document_name=basename($id['path']); - //Juan Carlos Ra�a get lastname and firstname when folder is in shared_folder + //Juan Carlos Raña: Get firstname and lastname when folder is in shared_folder. //TODO: check if is also necessary (above else) if(strstr($document_name, 'sf_user_')) { $userinfo=Database::get_user_info_from_id(substr($document_name, 8)); - $document_name=$userinfo['lastname'].', '.$userinfo['firstname']; + $document_name=api_get_person_name($userinfo['firstname'], $userinfo['lastname']); } elseif(strstr($document_name, 'shared_folder')) { @@ -764,7 +764,7 @@ if(isset($docs_and_folders) && is_array($docs_and_folders)) if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') { if (!empty($id['insert_user_id'])) { $user_info=UserManager::get_user_info_by_id($id['insert_user_id']); - $user_name=$user_info['firstname'].' '.$user_info['lastname']; + $user_name=api_get_person_name($user_info['firstname'], $user_info['lastname']); $user_link='
'.get_lang('Owner').': '.display_user_link_document($id['insert_user_id'],$user_name).'
'; } } diff --git a/main/dropbox/dropbox_class.inc.php b/main/dropbox/dropbox_class.inc.php index 1b38d30bf8..899df9f088 100644 --- a/main/dropbox/dropbox_class.inc.php +++ b/main/dropbox/dropbox_class.inc.php @@ -104,7 +104,7 @@ class Dropbox_Work { $this->filesize = $filesize; $this->title = $title; $this->description = $description; - $this->author = $_user['firstName'].' '.$_user['lastName']; + $this->author = api_get_person_name($_user['firstName'], $_user['lastName']); $this->last_upload_date = date("Y-m-d H:i:s",time()); // Check if object exists already. If it does, the old object is used diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index 5f17bda486..d044058075 100644 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -584,9 +584,9 @@ function display_add_form() } } - foreach ($complete_user_list_for_dropbox as $k => $e) - $complete_user_list_for_dropbox[$k] = $e + - array('lastcommafirst' => $e['lastname'] . ', ' . $e['firstname']); + foreach ($complete_user_list_for_dropbox as $k => $e) { + $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname'])); + } $complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst'); @@ -685,7 +685,7 @@ function getUserNameFromId ( $id) // RH: Mailing: return 'Mailing ' + id return dropbox_lang("mailingAsUsername", "noDLTT") . $mailingId; } $id = intval($id); - $sql = "SELECT CONCAT(lastname,' ', firstname) AS name + $sql = "SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ', lastname)" : "CONCAT(lastname,' ', firstname)")." AS name FROM " . dropbox_cnf("tbl_user") . " WHERE user_id='$id'"; $result = Database::query($sql,__FILE__,__LINE__); @@ -829,7 +829,7 @@ function dropbox_lang($variable, $notrans = 'DLTT') /** * Function that finds a given config setting * -* @author Ren� Haentjens, Ghent University +* @author René Haentjens, Ghent University */ function dropbox_cnf($variable) { @@ -1020,10 +1020,10 @@ function store_add_dropbox() { include_once(api_get_path(LIBRARY_PATH) . 'usermanager.lib.php'); $recipent_temp=UserManager :: get_user_info_by_id($recipient_id); - api_mail($recipent_temp['lastname'].' '.$recipent_temp['firstname'],$recipent_temp['email'], + api_mail(api_get_person_name($recipent_temp['firstname'].' '.$recipent_temp['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $recipent_temp['email'], get_lang('NewDropboxFileUploaded'), - get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".$_user['firstName']." ".$_user['lastName']."\n". get_lang('Email') ." : ".$_user['mail'], $_user['firstName']." ".$_user['lastName'],$_user['mail']); - //get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator'),api_get_setting('administratorName')." ".api_get_setting('administratorSurname'),api_get_setting('emailAdministrator')); + get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS)."\n". get_lang('Email') ." : ".$_user['mail'], api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_user['mail']); + //get_lang('NewDropboxFileUploadedContent').' '.api_get_path(WEB_CODE_PATH).'dropbox/index.php?cidReq='.$_course['sysCode']."\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS)."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName')." ".api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS), api_get_setting('emailAdministrator')); } } @@ -1057,7 +1057,7 @@ function display_user_link($user_id, $name='') $sql="SELECT * FROM $table_user WHERE user_id='".Database::escape_string($user_id)."'"; $result=Database::query($sql,__FILE__,__LINE__); $row=Database::fetch_array($result); - return "".$row['firstname']." ".$row['lastname'].""; + return "".api_get_person_name($row['firstname'], $row['lastname']).""; } else { @@ -1300,7 +1300,7 @@ function zip_download_alternative($files) // Step 1: create the overview file and add it to the zip $overview_file_content=generate_html_overview($files, array('filename'), array('title')); - $overview_file=$temp_zip_dir.'overview'.$_user['firstname'].$_user['lastname'].'.html'; + $overview_file=$temp_zip_dir.'overview'.replace_dangerous_char(api_is_western_name_order() ? $_user['firstname'].$_user['lastname'] : $_user['lastname'].$_user['firstname'], 'strict').'.html'; $handle=fopen($overview_file,'w'); fwrite($handle,$overview_file_content); // todo: find a different solution for this because even 2 seconds is no guarantee. diff --git a/main/dropbox/dropbox_init.inc.php b/main/dropbox/dropbox_init.inc.php index f1d1904128..ed6ea1be21 100644 --- a/main/dropbox/dropbox_init.inc.php +++ b/main/dropbox/dropbox_init.inc.php @@ -115,7 +115,7 @@ if ($_GET['action']=='add') ----------------------------------------------------------- */ -$javascript = "