Index: branches/1.1dev/lib/Upload.inc.php
===================================================================
--- branches/1.1dev/lib/Upload.inc.php	(revision 91)
+++ branches/1.1dev/lib/Upload.inc.php	(revision 105)
@@ -17,9 +17,9 @@
 class Upload {
     
-    // General object parameters.
-    var $_params = array(
-        'display_messages' => true,
-        'allow_overwriting' => false,
-    );
+    // Display error messages to the user?
+    var $display_messages = true;
+    
+    // Existing files with the same name will be overwritten?
+    var $allow_overwriting = false;
 
     // Disk path where new image(s) will be uploaded.
@@ -213,33 +213,4 @@
         'zip'     => 'application/zip'
     );
-    
-    /**
-     * Set (or overwrite existing) parameters by passing an array of new parameters.
-     *
-     * @access public
-     *
-     * @param  array    $params     Array of parameters (key => val pairs).
-     */
-    function setParam($params=null)
-    {
-        if (isset($params) && is_array($params)) {
-            // Set parameters for this object.
-            $this->_params = array_merge($this->_params, $params);
-        }
-    }
-
-    /**
-     * Return the value of a parameter.
-     *
-     * @access  public
-     *
-     * @param   string  $param      The key of the parameter to return.
-     *
-     * @return  mixed               Parameter value.
-     */
-    function getParam($param)
-    {
-        return $this->_params[$param];
-    }
 
     /**
@@ -269,5 +240,5 @@
         if (!isset($this->upload_directory_path)) {
             logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
-            if ($this->getParam('display_messages')) {
+            if ($this->display_messages) {
                 raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__);
             }
@@ -277,5 +248,5 @@
         if (!isset($_FILES[$form_name])) {
             logMsg(sprintf(_("Form element %s not posted."), $form_name), LOG_ERR, __FILE__, __LINE__);
-            if ($this->getParam('display_messages')) {
+            if ($this->display_messages) {
                 raiseMsg(_("There was a problem with the file upload. Please try again."), MSG_ERR, __FILE__, __LINE__);
             }
@@ -308,5 +279,5 @@
             $file_path_name = '';
 
-            if ('' == trim($files['tmp_name'][$i])) {
+            if ('' == trim($files['name'][$i])) {
                 // User may not have attached a file.
                 continue;
@@ -315,5 +286,5 @@
             // Check The php upload error messages.
             if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it exceeds the maximum allowed upload filesize of %s."), $files['name'][$i], ini_get('upload_max_filesize')), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -323,5 +294,5 @@
             }
             if (UPLOAD_ERR_FORM_SIZE === $files['error'][$i]) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it exceeds the maximum allowed upload filesize of %s."), $files['name'][$i], $_POST['MAX_FILE_SIZE']), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -331,5 +302,5 @@
             }
             if (UPLOAD_ERR_PARTIAL === $files['error'][$i]) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it was only partially uploaded."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -339,5 +310,5 @@
             }
             if (UPLOAD_ERR_NO_FILE === $files['error'][$i]) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: no file was uploaded."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -347,5 +318,5 @@
             }
             if (UPLOAD_ERR_NO_TMP_DIR === $files['error'][$i]) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: temporary upload directory missing."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -357,5 +328,5 @@
             // Check to be sure it's an uploaded file.
             if (!is_uploaded_file($files['tmp_name'][$i])) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -367,5 +338,5 @@
             // Check to be sure the file is not empty.
             if ($files['size'][$i] < 1) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it contains zero bytes."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -377,5 +348,5 @@
             // Check to be sure the file has a valid file extension.
             if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->valid_file_extensions)) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognised type. Files must have one of the following file extensions: %s."), $files['name'][$i], join(', ', $this->valid_file_extensions)), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -386,6 +357,6 @@
             
             // Check to be sure the file has a unique file name.
-            if (!$this->getParam('allow_overwriting') && $this->exists($files['name'][$i])) {
-                if ($this->getParam('display_messages')) {
+            if (!$this->allow_overwriting && $this->exists($files['name'][$i])) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: a file with that name already exists."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -401,5 +372,5 @@
                     // Valid custom file name.
             	    $file_name = $custom_file_name;
-                    if ($this->getParam('display_messages')) {
+                    if ($this->display_messages) {
                         raiseMsg(sprintf(_("The file <strong>%s</strong> has been renamed to <strong>%s</strong>."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__);
                     }
@@ -415,5 +386,5 @@
                     // Valid custom file name.
             		$file_name = $custom_file_name[$i];
-                    if ($this->getParam('display_messages')) {
+                    if ($this->display_messages) {
                         raiseMsg(sprintf(_("The file <strong>%s</strong> has been renamed to <strong>%s</strong>."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__);
                     }
@@ -442,11 +413,12 @@
             if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
                 chmod($file_path_name, $this->dest_file_perms);
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> uploaded successfully."), $files['name'][$i]), MSG_SUCCESS, __FILE__, __LINE__);
                 }
                 if (!isset($custom_file_name) && $files['name'][$i] != $file_name) {
                     // Notify user if uploaded file name was modified (unless a custom file name will be used anyways).
-                    if ($this->getParam('display_messages')) {
+                    if ($this->display_messages) {
                         raiseMsg(sprintf(_("The file <strong>%s</strong> was renamed to <strong>%s</strong>."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__);
+                        logMsg(sprintf('File successfully renamed: %s -> %s', $files['tmp_name'][$i], $file_path_name), LOG_DEBUG, __FILE__, __LINE__);
                     }
                 }
@@ -458,5 +430,5 @@
                 continue;
             } else {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -488,5 +460,5 @@
             logMsg(sprintf('Deleted file: %s', $file_path_name), LOG_DEBUG, __FILE__, __LINE__);
         } else {
-            if ($this->getParam('display_messages')) {
+            if ($this->display_messages) {
                 raiseMsg(sprintf(_("The file <strong>%s</strong> could not be deleted."), $file_name), MSG_ERROR, __FILE__, __LINE__);
             }
@@ -511,5 +483,5 @@
         if (file_exists($old_file_path_name)) {
             if (!rename($old_file_path_name, $new_file_path_name)) {
-                if ($this->getParam('display_messages')) {
+                if ($this->display_messages) {
                     raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_ERR, __FILE__, __LINE__);
                 }
@@ -518,5 +490,5 @@
             }
         } else {
-            if ($this->getParam('display_messages')) {
+            if ($this->display_messages) {
                 raiseMsg(sprintf(_("Couldn't rename nonexistant file <strong>%s</strong>."), $old_name), MSG_ERR, __FILE__, __LINE__);
             }
@@ -553,6 +525,5 @@
     function cleanFileName($file_name)
     {
-        $bad  = 'çêîòËéíñôèì
-åæëïó@';
+        $bad  = 'Ã¡Ã©Ã­Ã³ÃºÃ ÃšÃ¬Ã²Ã¹Ã€Ã«Ã¯Ã¶ÃŒÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ¢ÃªÃ®ÃŽÃ»ÃÃÃÃÃÃ±Ã§Ã@';
         $good = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncCa';
         $file_name = trim($file_name);
