user_edit.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <?php // $Id: user_edit.php 20035 2009-04-23 21:49:20Z cfasanando $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. Copyright (c) Bart Mollet, Hogeschool Gent
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * @package dokeos.admin
  23. ==============================================================================
  24. */
  25. // name of the language file that needs to be included
  26. $language_file=array('admin','registration');
  27. $cidReset=true;
  28. include('../inc/global.inc.php');
  29. $this_section=SECTION_PLATFORM_ADMIN;
  30. api_protect_admin_script();
  31. $htmlHeadXtra[] = '
  32. <script language="JavaScript" type="text/JavaScript">
  33. <!--
  34. function enable_expiration_date() { //v2.0
  35. document.user_add.radio_expiration_date[0].checked=false;
  36. document.user_add.radio_expiration_date[1].checked=true;
  37. }
  38. function display_drh_list(){
  39. if(document.getElementById("status_select").value=='.STUDENT.')
  40. {
  41. document.getElementById("drh_list").style.display="block";
  42. }
  43. else
  44. {
  45. document.getElementById("drh_list").style.display="none";
  46. document.getElementById("drh_select").options[0].selected="selected";
  47. }
  48. }
  49. function show_image(image,width,height) {
  50. width = parseInt(width) + 20;
  51. height = parseInt(height) + 20;
  52. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \' , resizable=0\');
  53. }
  54. //-->
  55. </script>';
  56. require_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
  57. require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
  58. require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  59. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  60. require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
  61. require_once(api_get_path(INCLUDE_PATH).'lib/mail.lib.inc.php');
  62. $user_id=isset($_GET['user_id']) ? intval($_GET['user_id']) : intval($_POST['user_id']);
  63. $noPHP_SELF=true;
  64. $tool_name=get_lang('ModifyUserInfo');
  65. $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
  66. $interbreadcrumb[]=array('url' => "user_list.php","name" => get_lang('UserList'));
  67. $table_user = Database::get_main_table(TABLE_MAIN_USER);
  68. $table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
  69. $sql = "SELECT u.*, a.user_id AS is_admin FROM $table_user u LEFT JOIN $table_admin a ON a.user_id = u.user_id WHERE u.user_id = '".$user_id."'";
  70. $res = api_sql_query($sql,__FILE__,__LINE__);
  71. if(mysql_num_rows($res) != 1)
  72. {
  73. header('Location: user_list.php');
  74. exit;
  75. }
  76. $user_data = mysql_fetch_array($res,MYSQL_ASSOC);
  77. $user_data['platform_admin'] = is_null($user_data['is_admin']) ? 0 : 1;
  78. $user_data['send_mail'] = 0;
  79. $user_data['old_password'] = $user_data['password'];
  80. unset($user_data['password']);
  81. $user_data = array_merge($user_data, Usermanager :: get_extra_user_data($user_id,true));
  82. // Create the form
  83. $form = new FormValidator('user_add','post','','',array('style' => 'width: 60%; float: '.($text_dir=='rtl'?'right;':'left;')));
  84. $form->addElement('header', '', $tool_name);
  85. $form->addElement('hidden','user_id',$user_id);
  86. // Lastname
  87. $form->addElement('text','lastname',get_lang('LastName'));
  88. $form->applyFilter('lastname','html_filter');
  89. $form->applyFilter('lastname','trim');
  90. $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
  91. // Firstname
  92. $form->addElement('text','firstname',get_lang('FirstName'));
  93. $form->applyFilter('firstname','html_filter');
  94. $form->applyFilter('firstname','trim');
  95. $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
  96. // Official code
  97. $form->addElement('text', 'official_code', get_lang('OfficialCode'),array('size' => '40'));
  98. $form->applyFilter('official_code','html_filter');
  99. $form->applyFilter('official_code','trim');
  100. // Email
  101. $form->addElement('text', 'email', get_lang('Email'),array('size' => '40'));
  102. $form->addRule('email', get_lang('EmailWrong'), 'email');
  103. $form->addRule('email', get_lang('EmailWrong'), 'required');
  104. // OpenID
  105. if(api_get_setting('openid_authentication')=='true')
  106. {
  107. $form->addElement('text', 'openid', get_lang('OpenIDURL'),array('size' => '40'));
  108. }
  109. // Phone
  110. $form->addElement('text','phone',get_lang('PhoneNumber'));
  111. // Picture
  112. $form->addElement('file', 'picture', get_lang('AddPicture'));
  113. $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
  114. $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
  115. if (strlen($user_data['picture_uri']) > 0 )
  116. {
  117. $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
  118. }
  119. // Username
  120. $form->addElement('text', 'username', get_lang('LoginName'),array('maxlength'=>20));
  121. $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
  122. $form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username');
  123. $form->addRule('username', '', 'maxlength',20);
  124. $form->addRule('username', get_lang('UserTaken'), 'username_available', $user_data['username']);
  125. // Password
  126. $form->addElement('radio','reset_password',get_lang('Password'),get_lang('DontResetPassword'),0);
  127. if(count($extAuthSource) > 0)
  128. {
  129. $group[] =& HTML_QuickForm::createElement('radio','reset_password',null,get_lang('ExternalAuthentication').' ',3);
  130. $auth_sources = array();
  131. foreach($extAuthSource as $key => $info)
  132. {
  133. $auth_sources[$key] = $key;
  134. }
  135. $group[] =& HTML_QuickForm::createElement('select','auth_source',null,$auth_sources);
  136. $group[] =& HTML_QuickForm::createElement('static','','','<br />');
  137. $form->addGroup($group, 'password', null, '',false);
  138. }
  139. $form->addElement('radio','reset_password',null,get_lang('AutoGeneratePassword'),1);
  140. $group = array();
  141. $group[] =& HTML_QuickForm::createElement('radio', 'reset_password',null,null,2);
  142. $group[] =& HTML_QuickForm::createElement('password', 'password',null,null);
  143. $form->addGroup($group, 'password', null, '',false);
  144. // Status
  145. $status = api_get_status_langvars();
  146. $form->addElement('select','status',get_lang('Status'),$status,'id="status_select" onchange="display_drh_list()"');
  147. //Language
  148. $form->addElement('select_language', 'language', get_lang('Language'));
  149. $display = $user_data['status'] == STUDENT || $_POST['status'] == STUDENT ? 'block' : 'none';
  150. $form->addElement('html','<div id="drh_list" style="display:'.$display.';">');
  151. $drh_select = $form->addElement('select','hr_dept_id',get_lang('Drh'),array(),'id="drh_select"');
  152. $drh_list = UserManager :: get_user_list(array('status'=>DRH),array('lastname','firstname'));
  153. if (count($drh_list) == 0) {
  154. $drh_select->addOption('- '.get_lang('ThereIsNotStillAResponsible').' -',0);
  155. } else {
  156. $drh_select->addOption('- '.get_lang('SelectAResponsible').' -',0);
  157. }
  158. foreach($drh_list as $drh)
  159. {
  160. $drh_select->addOption($drh['lastname'].' '.$drh['firstname'],$drh['user_id']);
  161. }
  162. $form->addElement('html', '</div>');
  163. // Platform admin
  164. // Only when changing another user!
  165. if($user_id != $_SESSION['_uid'])
  166. {
  167. $group = array();
  168. $group[] =& HTML_QuickForm::createElement('radio', 'platform_admin',null,get_lang('Yes'),1);
  169. $group[] =& HTML_QuickForm::createElement('radio', 'platform_admin',null,get_lang('No'),0);
  170. if ($user_data['status']<>5) {
  171. $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), '&nbsp;',false);
  172. }
  173. }
  174. // Send email
  175. $group = array();
  176. $group[] =& HTML_QuickForm::createElement('radio', 'send_mail',null,get_lang('Yes'),1);
  177. $group[] =& HTML_QuickForm::createElement('radio', 'send_mail',null,get_lang('No'),0);
  178. $form->addGroup($group, 'mail', get_lang('SendMailToNewUser'), '&nbsp;',false);
  179. // Registration Date
  180. $form->addElement('static','registration_date', get_lang('RegistrationDate'), $user_data['registration_date']);
  181. if(! $user_data['platform_admin'] )
  182. {
  183. // Expiration Date
  184. $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
  185. $group = array ();
  186. $group[] = & $form->createElement('radio', 'radio_expiration_date', null, get_lang('On'), 1);
  187. $group[] = & $form->createElement('datepicker', 'expiration_date',null, array ('form_name' => $form->getAttribute('name'), 'onChange'=>'enable_expiration_date()'));
  188. $form->addGroup($group, 'max_member_group', null, '', false);
  189. // Active account or inactive account
  190. $form->addElement('radio','active',get_lang('ActiveAccount'),get_lang('Active'),1);
  191. $form->addElement('radio','active','',get_lang('Inactive'),0);
  192. }
  193. // EXTRA FIELDS
  194. $extra = UserManager::get_extra_fields(0,50,5,'ASC');
  195. foreach($extra as $id => $field_details)
  196. {
  197. if($field_details[6] == 0)
  198. {
  199. continue;
  200. }
  201. switch($field_details[2])
  202. {
  203. case USER_FIELD_TYPE_TEXT:
  204. $form->addElement('text', 'extra_'.$field_details[1], $field_details[3], array('size' => 40));
  205. $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
  206. $form->applyFilter('extra_'.$field_details[1], 'trim');
  207. break;
  208. case USER_FIELD_TYPE_TEXTAREA:
  209. $form->add_html_editor('extra_'.$field_details[1], $field_details[3], false);
  210. //$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
  211. $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
  212. $form->applyFilter('extra_'.$field_details[1], 'trim');
  213. break;
  214. case USER_FIELD_TYPE_RADIO:
  215. $group = array();
  216. foreach($field_details[9] as $option_id => $option_details)
  217. {
  218. $options[$option_details[1]] = $option_details[2];
  219. $group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1],$option_details[2].'<br />',$option_details[1]);
  220. }
  221. $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
  222. break;
  223. case USER_FIELD_TYPE_SELECT:
  224. $options = array();
  225. foreach($field_details[9] as $option_id => $option_details)
  226. {
  227. $options[$option_details[1]] = $option_details[2];
  228. }
  229. $form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,'');
  230. break;
  231. case USER_FIELD_TYPE_SELECT_MULTIPLE:
  232. $options = array();
  233. foreach($field_details[9] as $option_id => $option_details)
  234. {
  235. $options[$option_details[1]] = $option_details[2];
  236. }
  237. $form->addElement('select','extra_'.$field_details[1],$field_details[3],$options,array('multiple' => 'multiple'));
  238. break;
  239. case USER_FIELD_TYPE_DATE:
  240. $form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'user_add'));
  241. $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
  242. $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
  243. $form -> setDefaults($defaults);
  244. $form->applyFilter('theme', 'trim');
  245. break;
  246. case USER_FIELD_TYPE_DATETIME:
  247. $form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'user_add'));
  248. $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900);
  249. $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
  250. $form -> setDefaults($defaults);
  251. $form->applyFilter('theme', 'trim');
  252. break;
  253. }
  254. }
  255. // Submit button
  256. $form->addElement('style_submit_button', 'submit',get_lang('ModifyInformation'),'class="save"');
  257. // Set default values
  258. $expiration_date=$user_data['expiration_date'];
  259. if ($expiration_date=='0000-00-00 00:00:00')
  260. {
  261. $user_data['radio_expiration_date']=0;
  262. $user_data['expiration_date']=array();
  263. $user_data['expiration_date']['d']=date('d');
  264. $user_data['expiration_date']['F']=date('m');
  265. $user_data['expiration_date']['Y']=date('Y');
  266. }
  267. else
  268. {
  269. $user_data['radio_expiration_date']=1;
  270. $user_data['expiration_date']=array();
  271. $user_data['expiration_date']['d']=substr($expiration_date,8,2);
  272. $user_data['expiration_date']['F']=substr($expiration_date,5,2);
  273. $user_data['expiration_date']['Y']=substr($expiration_date,0,4);
  274. }
  275. $form->setDefaults($user_data);
  276. // Validate form
  277. if( $form->validate())
  278. {
  279. $user = $form->exportValues();
  280. $picture_element = & $form->getElement('picture');
  281. $picture = $picture_element->getValue();
  282. $picture_uri = '';
  283. //get the picture directory
  284. $picture_paths = UserManager::get_user_picture_path_by_id($user_id,'system',true);
  285. $picture_location = $picture_paths['dir'];
  286. $big_picture_location = $picture_paths['dir'];
  287. if (strlen($picture['name']) > 0)
  288. {
  289. $picture_uri = uniqid('').'_'.replace_dangerous_char($picture['name']);
  290. if(!file_exists($picture_location))
  291. {
  292. mkpath($picture_location);
  293. }
  294. $picture_location .= $picture_uri;
  295. $big_picture_location .= 'big_'.$picture_uri;
  296. // get the picture and resize it 100x150
  297. $temp = new image($_FILES['picture']['tmp_name']);
  298. $picture_infos=getimagesize($_FILES['picture']['tmp_name']);
  299. $thumbwidth = IMAGE_THUMBNAIL_WIDTH;
  300. if (empty($thumbwidth) or $thumbwidth==0) {
  301. $thumbwidth=150;
  302. }
  303. $divizor = ($picture_infos[0] > 0)?$picture_infos[0]:1;
  304. $new_height = round(($thumbwidth/$divizor)*$picture_infos[1]);
  305. $temp->resize($thumbwidth,$new_height,0);
  306. $type=$picture_infos[2];
  307. // original picture
  308. $big_temp = new image($_FILES['picture']['tmp_name']);
  309. switch (!empty($type)) {
  310. case 2 : $temp->send_image('JPG',$picture_location);
  311. $big_temp->send_image('JPG',$big_picture_location);
  312. break;
  313. case 3 : $temp->send_image('PNG',$picture_location);
  314. $big_temp->send_image('JPG',$big_picture_location);
  315. break;
  316. case 1 : $temp->send_image('GIF',$picture_location);
  317. $big_temp->send_image('JPG',$big_picture_location);
  318. break;
  319. }
  320. }
  321. elseif(isset($user['delete_picture']))
  322. {
  323. @unlink($picture_location.$user_data['picture_uri']);
  324. }
  325. if (strlen($picture['name']) == 0){
  326. $picture_uri = $user_data['picture_uri'];
  327. }
  328. $lastname = $user['lastname'];
  329. $firstname = $user['firstname'];
  330. $official_code = $user['official_code'];
  331. $email = $user['email'];
  332. $phone = $user['phone'];
  333. $username = $user['username'];
  334. $status = intval($user['status']);
  335. $picture = $_FILES['picture'];
  336. $platform_admin = intval($user['platform_admin']);
  337. $send_mail = intval($user['send_mail']);
  338. $reset_password = intval($user['reset_password']);
  339. $hr_dept_id = intval($user['hr_dept_id']);
  340. $language=$user['language'];
  341. if ($user['radio_expiration_date']=='1' && ! $user_data['platform_admin'] )
  342. {
  343. $expiration_date=$user['expiration_date'];
  344. }
  345. else
  346. {
  347. $expiration_date='0000-00-00 00:00:00';
  348. }
  349. $active = $user_data['platform_admin'] ? 1 : intval($user['active']);
  350. if( $reset_password == 0)
  351. {
  352. $password = null;
  353. $auth_source = $user_data['auth_source'];
  354. }
  355. elseif($reset_password == 1)
  356. {
  357. $password = api_generate_password();
  358. $auth_source = PLATFORM_AUTH_SOURCE;
  359. }
  360. elseif($reset_password == 2)
  361. {
  362. $password = $user['password'];
  363. $auth_source = PLATFORM_AUTH_SOURCE;
  364. }
  365. elseif($reset_password == 3)
  366. {
  367. $password = $user['password'];
  368. $auth_source = $user['auth_source'];
  369. }
  370. UserManager::update_user($user_id,$firstname,$lastname,$username,$password,$auth_source,$email,$status,$official_code,$phone,$picture_uri,$expiration_date, $active, null, $hr_dept_id,null,$language);
  371. if(api_get_setting('openid_authentication')=='true' && !empty($user['openid']))
  372. {
  373. $up = UserManager::update_openid($user_id,$user['openid']);
  374. }
  375. if($user_id != $_SESSION['_uid'])
  376. {
  377. if($platform_admin == 1)
  378. {
  379. $sql = "INSERT IGNORE INTO $table_admin SET user_id = '".$user_id."'";
  380. api_sql_query($sql,__FILE__,__LINE__);
  381. }
  382. else
  383. {
  384. $sql = "DELETE FROM $table_admin WHERE user_id = '".$user_id."'";
  385. api_sql_query($sql,__FILE__,__LINE__);
  386. }
  387. }
  388. $extras = array();
  389. foreach($user as $key => $value)
  390. {
  391. if(substr($key,0,6)=='extra_') //an extra field
  392. {
  393. $myres = UserManager::update_extra_field_value($user_id,substr($key,6),$value);
  394. }
  395. }
  396. if (!empty ($email) && $send_mail)
  397. {
  398. $recipient_name = $firstname.' '.$lastname;
  399. $emailsubject = '['.get_setting('siteName').'] '.get_lang('YourReg').' '.get_setting('siteName');
  400. $sender_name = get_setting('administratorName').' '.get_setting('administratorSurname');
  401. $email_admin = get_setting('emailAdministrator');
  402. if ($_configuration['multiple_access_urls']==true) {
  403. $access_url_id = api_get_current_access_url_id();
  404. if ($access_url_id != -1 ){
  405. $url = api_get_access_url($access_url_id);
  406. $emailbody=get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ". get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
  407. }
  408. }
  409. else {
  410. $emailbody=get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ". get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". get_setting('siteName') ." ". get_lang('Is') ." : ". $_configuration['root_web'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator');
  411. }
  412. $emailbody = get_lang('Dear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('YouAreReg')." ". get_setting('siteName') ." ".get_lang('Settings')." ". $username;
  413. // Send password by e-mail if it has been modified, even if encrypted in DB (it doesn't make sense to send an e-mail with login info without the password, even if the password is encrypted)
  414. if($reset_password > 0)
  415. {
  416. $emailbody .= "\n".get_lang('Pass')." : ".stripslashes($password);
  417. }
  418. @api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name,$email_admin);
  419. }
  420. $tok = Security::get_token();
  421. header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);
  422. exit();
  423. }
  424. Display::display_header($tool_name);
  425. // USER PICTURE
  426. $image_path = UserManager::get_user_picture_path_by_id($user_id,'web');
  427. $image_dir = $image_path['dir'];
  428. $image = $image_path['file'];
  429. $image_file = ($image != '' ? $image_dir.$image : api_get_path(WEB_CODE_PATH).'img/unknown.jpg');
  430. $image_size = @getimagesize($image_file);
  431. $img_attributes = 'src="'.$image_file.'?rand='.time().'" '
  432. .'alt="'.$user_data['lastname'].' '.$user_data['firstname'].'" '
  433. .'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; padding:5px;" ';
  434. if ($image_size[0] > 300) //limit display width to 300px
  435. $img_attributes .= 'width="300" ';
  436. // get the path,width and height from original picture
  437. $big_image = $image_dir.'big_'.$image;
  438. $big_image_size = @getimagesize($big_image);
  439. $big_image_width= $big_image_size[0];
  440. $big_image_height= $big_image_size[1];
  441. $url_big_image = $big_image.'?rnd='.time();
  442. if ($image=='') {
  443. echo '<img '.$img_attributes.' />';
  444. } else {
  445. echo '<input type="image" '.$img_attributes.' onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
  446. }
  447. // Display form
  448. $form->display();
  449. /*
  450. ==============================================================================
  451. FOOTER
  452. ==============================================================================
  453. */
  454. Display::display_footer();
  455. ?>