00001 <?PHP
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 $page_title = i18n("Edit user: ##0##", array($viewUser));
00018 $tabwidget->tabbar->setCurrent(i18n("Edit"));
00019 if (!profileEditAllowed($viewUser))
00020 {
00021 $tabwidget->contents = i18n("You do not have the correct priviledges to edit this user");
00022 $page_content = $tabwidget->renderTabWidget();
00023 }
00024 else
00025 {
00026 if ($_REQUEST["action"] == "avatarcrop")
00027 {
00028 $image = getAvatar( $viewUser );
00029 $ext = checkImageMimetype( $image );
00030 $dest_image = substr( $image, 0, strlen( $image ) - 4 ) . "-thumb" . substr( $image, -4 );
00031
00044 $url = thisPageURL( false, true, array( "action" => "avatarcrop", "theme" => "empty") );
00045 $margin = 10;
00046
00047 if(!isset($_POST['step'])) $title = '1';
00048 else $title = $_POST['step'];
00049
00050 $page_content = '
00051 <html>
00052 <head>
00053 <title>' . i18n("Cropping avatar - step ##0##", array($title)) . '</title>
00054 </head>
00055 <body style="margin: '.$margin.'px;">';
00056
00057 if(!isset($_POST['tx']) && !isset($_POST['fx']))
00058 {
00059 $page_content .= '
00060 <form method="post" action="'.$url.'">
00061 <input type="image" src="'. siteURL(true) . $image .'"><p>';
00062 if(!isset($_POST['x']))
00063 {
00064 $page_content .= '
00065 <input type="hidden" name="step" value="2">
00066 ' . i18n("Click to mark the first corner of the selection rectangle.") . " " . i18n("You will be able to review the result before cropping");
00067 }else{
00068 $page_content .= '
00069 <input type="hidden" name="step" value="3">
00070 <input type="hidden" name="fx" value="'.$_POST['x'].'">
00071 <input type="hidden" name="fy" value="'.$_POST['y'].'">
00072 ' . i18n("Click to mark the second corner of the selection rectangle.") . ' | <a href="'.$url.'">' . i18n("Start over") . '</a> ' . " " . i18n("You will be able to review the result before cropping");
00073 }
00074 $page_content .= '
00075 </form>
00076 ';
00077 }
00078
00079 if(isset($_POST['fx']))
00080 {
00081 $page_content .= '
00082 <form method="post" action="'.$url.'">
00083 <input type="hidden" name="step" value="4">
00084 <input type="image" src="'. siteURL(true) . $image .'">
00085 <input type="hidden" name="tx" value="'.$_POST['fx'].'">
00086 <input type="hidden" name="ty" value="'.$_POST['fy'].'">
00087 <input type="hidden" name="width" value="'.($_POST['x']-$_POST['fx']).'">
00088 <input type="hidden" name="height" value="'.($_POST['y']-$_POST['fy']).'"><p>
00089 <div style="position: absolute;
00090 left:'.($_POST['fx']+$margin).'px;
00091 top: '.($_POST['fy']+$margin).'px;
00092 width: '.($_POST['x']-$_POST['fx']).'px;
00093 height: '.($_POST['y']-$_POST['fy']).'px;
00094 border: 1px solid #fff;">
00095 </div>
00096 ' . i18n("Click the image to crop. The rectangle shown on the picture is the rectangle that will be cropped.") . '| <a href="'.$url.'">' . i18n("Start over") . '</a>
00097 </form>';
00098 }
00099
00100 if(isset($_POST['tx']))
00101 {
00102
00103 cropImage( $image, $dest_image, $_POST["tx"], $_POST["ty"], $_POST["width"], $_POST["height"] );
00104
00105
00106 scaleImage( $dest_image, $dest_image, $profile_options["thumbnail_width"], $profile_options["thumbnail_height"] );
00107
00108
00109 chmod($dest_image, 0664);
00110
00111 header("Location: " . globalIDtoURL("user/$viewUser/edit/user_avatar"));
00112 }
00113 }
00114 else
00115 {
00116 if( $_REQUEST["profiles_view"] != "" ) saveUserInfo($viewUser, "profiles_view", $_REQUEST["profiles_view"]);
00117 if( $_REQUEST["profiles_contact"] != "" ) saveUserInfo($viewUser, "profiles_contact", $_REQUEST["profiles_contact"]);
00118 if( $_REQUEST["profiles_mypage"] != "" ) saveUserInfo($viewUser, "profiles_mypage", $_REQUEST["profiles_mypage"]);
00119
00120 if( $_REQUEST["new_profile"] != "") saveUserInfo($viewUser, "profile", stripslashes($_REQUEST["new_profile"]));
00121 if( $_REQUEST["new_realname"] != "") saveUserInfo($viewUser, "name", stripslashes($_REQUEST["new_realname"]));
00122 if( array_key_exists( "new_signature", $_REQUEST ) ) saveUserInfo( $viewUser, "signature", stripslashes($_REQUEST["new_signature"]) );
00123
00124 if( $_REQUEST["new_email"] != "" && validateEmail(stripslashes($_REQUEST["new_email"])) )
00125 saveUserInfo($viewUser, "email", stripslashes($_REQUEST["new_email"]));
00126 else if( $_REQUEST["new_email"] != "" && !validateEmail(stripslashes($_REQUEST["new_email"])) )
00127 $email_errormessage = i18n("Your email address is not valid");
00128
00129 $userinfo["profiles_view"] = getUserInfo($viewUser, "profiles_view");
00130 if ($userinfo["profiles_view"] == i18n("No ##0## information\n", array("profiles_view"))) $userinfo["profiles_view"] = $profile_options["profiles_view"];
00131 $userinfo["profiles_contact"] = getUserInfo($viewUser, "profiles_contact");
00132 if ($userinfo["profiles_contact"] == i18n("No ##0## information\n", array("profiles_contact"))) $userinfo["profiles_contact"] = $profile_options["profiles_contact"];
00133 $userinfo["profiles_mypage"] = getUserInfo($viewUser, "profiles_mypage");
00134 if ($userinfo["profiles_mypage"] == i18n("No ##0## information\n", array("profiles_mypage"))) $userinfo["profiles_mypage"] = $profile_options["profiles_mypage"];
00135 $userinfo["profile"] = getUserInfo($viewUser, "profile");
00136 $userinfo["contactinfo"] = unserialize(getUserInfo($viewUser, "contactinfo"));
00137 $userinfo["name"] = getUserInfo($viewUser, "name");
00138 $userinfo["email"] = getUserInfo($viewUser, "email");
00139 $userinfo["signature"] = getUserInfo($viewUser, "signature", "" );
00140
00141 if( is_array($_REQUEST["contact"]) )
00142 {
00143 foreach ($_REQUEST["contact"] as $key => $value) {
00144 if (eregi($profile_options["contact_fields"][$key]["regexp"], stripslashes($value)) || $value == "")
00145 $userinfo["contactinfo"][$key] = stripslashes($value);
00146 else
00147 $contact_errormessage[$key] = i18n("The entered contact information is not valid!");
00148 }
00149 saveUserInfo($viewUser, "contactinfo", serialize($userinfo["contactinfo"]));
00150 }
00151
00152 if( $_REQUEST["new_password"] != "" && $_REQUEST["new_password2"] != "" )
00153 {
00154 if ($_REQUEST["new_password"] == $_REQUEST["new_password2"])
00155 $usermanager->changeadd($viewUser, $_REQUEST["new_password"]);
00156 else
00157 $password_errormessage = i18n("The two password must match!");
00158 }
00159
00160 if( $_REQUEST["avatardelete"] )
00161 unlink_multiple("$userinfo_folder/$viewUser/avatar*");
00162
00163 if ((is_array($_FILES["uploadedfile"]) && $_REQUEST["upload_avatar"]) || $_REQUEST["action"] == "avatarresize") {
00164 $errorHandler = new errorHandler( thisPageURL() );
00165 if ($_REQUEST["action"] == "avatarresize") {
00166 $uploadFile = getAvatar( $viewUser );
00167 $ext = checkImageMimetype( $uploadFile );
00168 $thumbAvatar = substr( $uploadFile, 0, strlen( $uploadFile ) ) . "-thumb" . $ext;
00169 if (file_exists($thumbAvatar))
00170 unlink($thumbAvatar);
00171 $continue = true;
00172 } else {
00173 unlink_multiple("$userinfo_folder/$viewUser/avatar*");
00174
00175 if ( checkImageMimetype( $_FILES['uploadedfile']['tmp_name'] ) == false )
00176 {
00177 $continue = false;
00178 $upload_wrongfilesuffix = true;
00179 }
00180 else
00181 {
00182 $uploadFile = "$userinfo_folder/$viewUser/avatar." . checkImageMimetype( $_FILES['uploadedfile']['tmp_name'] );
00183 $thumbAvatar = "$userinfo_folder/$viewUser/avatar-thumb." . checkImageMimetype( $_FILES['uploadedfile']['tmp_name'] );
00184 $continue = move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadFile);
00185 }
00186 }
00187 if ($continue) {
00188 $errorHandler->handle( i18n( "Resizing ##0##", array( $filename ) ), scaleImage( $uploadFile, $uploadFile, $profile_options["avatar_maxwidth"], $profile_options["avatar_maxheight"] ) );
00189 if( !$profile_options['thumbnail_disable'] )
00190 $errorHandler->handle( i18n( "Thumbnailing ##0##", array( $filename ) ), scaleImage( $uploadFile, $thumbAvatar, $profile_options["thumbnail_width"], $profile_options["thumbnail_height"] ) );
00191
00192 chmod($uploadFile, 0664);
00193 if( file_exists( $thumbAvatar ) )
00194 chmod($thumbAvatar, 0664);
00195
00196 header("Location: " . globalIDtoURL("user/$viewUser/edit/user_avatar") );
00197 } else {
00198 if ($upload_wrongfilesuffix) {
00199 $errorHandler->handle(
00200 i18n("Error during avatar upload"),
00201 i18n("The file is in an unknown format. The following formats are supported") . ":
00202 png (Portable Network Graphics)
00203 , jpg, jpeg (Joint Pictures Expert Group)
00204 , gif (Graphics Interchange Format)");
00205 } else {
00206 switch ($_FILES['uploadedfile']['error']) {
00207 case 1:
00208 $theError = "The uploaded file exceeds the upload_max_filesize directive in php.ini. Please contact your host and rectify this (or better yet, select a smaller file. Most often, this directive states 2MB as the maximum upload size, however as we have 1MB as the maxium here, they have obviously changed it).";
00209 break;
00210 case 2:
00211 $theError = "The uploaded file exceeds 1MB in size, and is too large to upload in this manner.";
00212 break;
00213 case 3:
00214 $theError = "The uploaded file was only partially uploaded.";
00215 break;
00216 case 4:
00217 $theError = "No file was uploaded.";
00218 break;
00219 }
00220 $errorHandler->handle(
00221 i18n("The following error occurred during upload of your avatar"),
00222 $theError);
00223 }
00224 $tabwidget->contents = $errorHandler->render();
00225 }
00226 }
00227
00228 if( !is_array( $contact_errormessage ) && $_POST["save_profileinfo"] )
00229 $tabwidget->contents .= renderInformationBox( i18n("Success"), i18n("The profile information was saved successfully") );
00230
00231
00232 $avatarfile = getAvatar( $viewUser );
00233 $avatarthumbfile = getAvatarThumbnail( $viewUser );
00234 list($avatarwidth,$avatarheight) = getimagesize($avatarthumbfile);
00235 $avatarfile = siteURL(true) . $avatarfile;
00236 $avatarthumbfile = siteURL(true) . $avatarthumbfile;
00237
00238 global $permissionlevels_array;
00239 foreach($permissionlevels_array as $key => $value) {
00240 if ($userinfo["profiles_view"] == $key) { $default = " selected"; } else { $default = ""; }
00241 $permissionlevels_view .= "<option value=\"$key\"$default>$value</option>";
00242 if ($userinfo["profiles_contact"] == $key) { $default = " selected"; } else { $default = ""; }
00243 $permissionlevels_contact .= "<option value=\"$key\"$default>$value</option>";
00244 if ($userinfo["profiles_mypage"] == $key) { $default = " selected"; } else { $default = ""; }
00245 $permissionlevels_mypage .= "<option value=\"$key\"$default>$value</option>";
00246 }
00247
00248 $edit_section["general_information"] = ( $_REQUEST["edit_section"] == "" ) ? "on" : "off";
00249 $edit_section["view_options"] = "off";
00250 $edit_section["contact_information"] = "off";
00251 $edit_section["user_avatar"] = "off";
00252 $edit_section["profile"] = "off";
00253
00254 $edit_section[ $_REQUEST["edit_section"] ] = "on";
00255
00256 foreach( $edit_section as $key => $value )
00257 {
00258 if( $value == "on" )
00259 {
00260 $edit_section[$key] = "<img style=\"vertical-align: middle;\" border=\"0\" src=\"" . siteURL(true) . "$setup_folder/images/selection-on.png\" width=\"10\" height=\"10\" alt=\"x\" /><strong>";
00261 $edit_sectionend[$key] = "</strong>";
00262 }
00263 else
00264 {
00265 $edit_section[$key] = "<img style=\"vertical-align: middle;\" border=\"0\" src=\"" . siteURL(true) . "$setup_folder/images/selection-off.png\" width=\"10\" height=\"10\" alt=\"o\" />";
00266 $edit_sectionend[$key] = "";
00267 }
00268 }
00269
00270 $tabwidget->addCommand( i18n("##0## General information##1##", array($edit_section["general_information"], $edit_sectionend["general_information"]) ), i18n("General information"), globalIDtoURL("user/$viewUser/edit") );
00271 $tabwidget->addCommand( i18n("##0## Profile##1##", array($edit_section["profile"], $edit_sectionend["profile"]) ), i18n("Profile"), globalIDtoURL("user/$viewUser/edit/profile") );
00272 $tabwidget->addCommand( i18n("##0## User avatar##1##", array($edit_section["user_avatar"], $edit_sectionend["user_avatar"]) ), i18n("User avatar"), globalIDtoURL("user/$viewUser/edit/user_avatar") );
00273 $tabwidget->addCommand( i18n("##0## Contact information##1##", array($edit_section["contact_information"], $edit_sectionend["contact_information"]) ), i18n("Contact information"), globalIDtoURL("user/$viewUser/edit/contact_information") );
00274 $tabwidget->addCommand( i18n("##0## View options##1##", array($edit_section["view_options"], $edit_sectionend["view_options"]) ), i18n("View options"), globalIDtoURL("user/$viewUser/edit/view_options") );
00275
00276 $tabwidget->contents .= "
00277 <form enctype=\"multipart/form-data\" action=\"" . globalIDtoURL("user/$viewUser/edit/{$_REQUEST['edit_section']}") . "\" method=\"post\">
00278 <table class=\"setup\">";
00279
00280 switch( $_REQUEST["edit_section"] )
00281 {
00282 case "view_options":
00283 $tabwidget->contents .= "
00284 <tr class=\"setup\">
00285 <td class=\"setup\" width=\"50%\">" . i18n("##0##'s profile is viewable by", array( getUserInfo( $viewUser, "name" ) ) ) . "</td>
00286 <td class=\"setup\" width=\"50%\"><select style=\"width: 100%;\" name=\"profiles_view\">$permissionlevels_view</select></td>
00287 </tr>
00288 <tr class=\"setup\">
00289 <td class=\"setup\">" . i18n("##0## can be contacted by", array( getUserInfo( $viewUser, "name" ) ) ) . "</td>
00290 <td class=\"setup\"><select style=\"width: 100%;\" name=\"profiles_contact\">$permissionlevels_contact</select></td>
00291 </tr>
00292 <tr class=\"setup\">
00293 <td class=\"setup\">" . i18n("##0##'s personal page can be viewed by", array( getUserInfo( $viewUser, "name" ) ) ) . "</td>
00294 <td class=\"setup\"><select style=\"width: 100%;\" name=\"profiles_mypage\">$permissionlevels_mypage</select></td>
00295 </tr>";
00296 break;
00297 case "contact_information":
00298 $tabwidget->contents .= "
00299 <tr class=\"setup\">
00300 <td width=\"50%\" class=\"setup\">
00301 " . i18n("Email address") . ":<span class=\"error\">$email_errormessage</span><br />
00302 <small class=\"comment\">" . i18n("The email address you wish to use, for example johndoe@site.com") . "</small>
00303 </td>
00304 <td width=\"50%\" class=\"setup\">
00305 <input style=\"width: 100%\" type=\"text\" name=\"new_email\" value=\"{$userinfo['email']}\" />
00306 </td>
00307 </tr>";
00308 if( is_array( $profile_options["contact_fields"] ) )
00309 {
00310 foreach ($profile_options["contact_fields"] as $key => $value) {
00311 $tabwidget->contents .= "
00312 <tr class=\"setup\">
00313 <td class=\"setup\">
00314 " . i18n("$key") . ":<span class=\"error\">" . $contact_errormessage[$key] . "</span><br />
00315 <small class=\"comment\">" . i18n($value["description"]) . "</small>
00316 </td>
00317 <td class=\"setup\">
00318 <input style=\"width: 100%\" type=\"text\" name=\"contact[$key]\" value=\"" . $userinfo['contactinfo'][$key] . "\" />
00319 </td>
00320 </tr>";
00321 }
00322 }
00323 break;
00324 case "user_avatar":
00325 $tabwidget->contents .= "
00326 <tr class=\"setup\">
00327 <td width=\"50%\" class=\"setup\">
00328 " . i18n("User avatar") . ":<br />
00329 <small class=\"comment\">" . i18n("The user avatar can be a maximum width of ##0## pixels and a maximum height of ##1##", array($profile_options['avatar_maxwidth'], $profile_options['avatar_maxheight'])) . "</small><br />
00330 " . i18n("Upload avatar") . ":<br />
00331 <small class=\"comment\">" . i18n("Select a file for uploading as your avatar. This must be one of either jpg, gif or png format, and be of smaller filesize than ##0##. The image will be resized as required.", array(ini_get("upload_max_filesize"))) . "</small>
00332 <input style=\"width: 100%\" type=\"file\" name=\"uploadedfile\" />
00333 </td>
00334 <td width=\"50%\" class=\"setup\">
00335 <div align=\"center\">
00336 <a style=\"border: none;\" href=\"$avatarfile\" target=\"_blank\"><img border=\"0\" src=\"$avatarthumbfile?x=" . (uniqid((double)microtime()*1000000,1)) . "\" width=\"$avatarwidth\" height=\"$avatarheight\" alt=\"" . i18n("##0##'s avatar", array($userinfo['name'])) . "\" /></a><br />
00337 </div>
00338 </td>
00339 </tr>
00340 <tr class=\"setup\">
00341 <td width=\"50%\" class=\"setup\">
00342 <div align=\"center\">
00343 <input type=\"submit\" name=\"upload_avatar\" value=\"" . i18n("Upload the avatar") . "\" />
00344 </div>
00345 </td>
00346 <td width=\"50%\" class=\"setup\">
00347 <div align=\"center\">
00348 <input type=\"submit\" name=\"avatardelete\" value=\"" . i18n("Delete the avatar") . "\" />
00349 </div>
00350 </td>
00351 </tr>";
00352
00353 if( !$profile_options["thumbnail_disable"] )
00354 $tabwidget->contents .= "
00355 <tr class=\"setup\">
00356 <td class=\"setup\">
00357 " . i18n("Select avatar thumbnail") . ":<br />
00358 <small class=\"comment\">" . i18n("You can select two types of thumbnail for your avatar, either you select the full size picture and scale it down to the thumbnail size (the default), or you can crop your way to the section of the image you wish to use as the thumbnail (if this cropped section is larger than the allowed thumbnail size, it will then be scaled down accordingly)") . "</small>
00359 </td>
00360 <td class=\"setup\">
00361 <div class=\"wikicenteralign\">
00362 <a class=\"command\" href=\"" . thisPageURL( false, true, array( "action" => "avatarresize", "edit_section" => "user_avatar" ) ) . "\">[" . i18n("Resize full size picture") . "]</a>
00363 <br /><br />
00364 <a class=\"command\" href=\"" . thisPageURL( false, true, array( "action" => "avatarcrop", "theme" => "empty", "edit_section" => "user_avatar" ) ) . "\">[" . i18n("Crop and Resize") . "]</a>
00365 </div>
00366 </td>
00367 </tr>";
00368 break;
00369 case "profile":
00370 $tabwidget->contents .= "
00371 $formatting_toolbar
00372 <tr class=\"setup\">
00373 <td class=\"setup\" colspan=\"2\">
00374 <textarea rows=\"15\" cols=\"70\" style=\"width: 100%;\" id=\"edit\" name=\"new_profile\">{$userinfo['profile']}</textarea>
00375 " . generate_pagehelplink() . "
00376 </td>
00377 </tr>";
00378 break;
00379 default:
00380 $tabwidget->contents .= "
00381 <tr class=\"setup\">
00382 <td class=\"setup\" width=\"50%\">
00383 " . i18n("Username") . ":<br />
00384 <small class=\"comment\">" . i18n("If you wish to change your username, please contact ##0##the site administrator##1##", array("<a href=\"" . globalIDtoURL("user/admin/contact") . "\">", "</a>")) . "</small>
00385 </th>
00386 <td class=\"setup\">" . $viewUser . "</th>
00387 </tr>
00388 <tr class=\"setup\">
00389 <td class=\"setup\">
00390 " . i18n("Password") . ":<span class=\"error\">$password_errormessage</span><br />
00391 <small class=\"comment\">" . i18n("You only need to type in a password if you wish to change your existing one. A password, at least 8 characters long. Repeat the password in the two boxes. Preferably comprised of a mix of upper and lower case characters and numbers, for example ##0##", array(makeRandomPassword())) . "</small>
00392 </td>
00393 <td class=\"setup\">
00394 <input style=\"width: 100%\" type=\"password\" name=\"new_password\" value=\"{$_REQUEST['new_password']}\" />
00395 <input style=\"width: 100%\" type=\"password\" name=\"new_password2\" value=\"{$_REQUEST['new_password2']}\" />
00396 </td>
00397 </tr>
00398 <tr class=\"setup\">
00399 <td class=\"setup\">
00400 " . i18n("Full name") . ":<br />
00401 <small class=\"comment\">" . i18n("Your full name, for example John Doe") . "</small>
00402 </td>
00403 <td class=\"setup\">
00404 <input style=\"width: 100%\" type=\"text\" name=\"new_realname\" value=\"{$userinfo['name']}\" />
00405 </td>
00406 </tr>
00407 <tr class=\"setup\">
00408 <td class=\"setup\">
00409 " . i18n("Signature") . ":<br />
00410 <small class=\"comment\">" . i18n("The signature you wish to use for when you create comments") . "</small>
00411 </td>
00412 <td class=\"setup\">
00413 <textarea rows=\"3\" cols=\"70\" style=\"width: 100%\" name=\"new_signature\">{$userinfo['signature']}</textarea>
00414 </td>
00415 </tr>";
00416 }
00417
00418 $tabwidget->contents .= ( $_REQUEST["edit_section"] == "user_avatar" ) ? "
00419 </table>
00420 </form>" : "
00421 <tr class=\"setup\">
00422 <td class=\"setup\"><input type=\"submit\" name=\"save_profileinfo\" value=\"" . i18n("Save details") . "\" /></td>
00423 <td class=\"setup wikirightalign\"><input type=\"reset\" value=\"" . i18n("Reset") . "\" /></td>
00424 </tr>
00425 </table>
00426 </form>
00427 ";
00428 $page_content = $tabwidget->renderTabWidget();
00429 }
00430 }
00431 ?>