removed mods directory from the ATutor codebase
[atutor.git] / mods / photo_album / classes / image_upload.class.php
diff --git a/mods/photo_album/classes/image_upload.class.php b/mods/photo_album/classes/image_upload.class.php
deleted file mode 100644 (file)
index c5bd9fa..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-<?php\r
-/*==============================================================\r
-  Photo Album\r
- ==============================================================\r
-  Copyright (c) 2006 by Dylan Cheon & Kelvin Wong\r
-  Institute for Assistive Technology / University of Victoria\r
-  http://www.canassist.ca/                                    \r
-                                                               \r
-  This program is free software. You can redistribute it and/or\r
-  modify it under the terms of the GNU General Public License  \r
-  as published by the Free Software Foundation.                \r
- ==============================================================\r
- */\r
-// $Id:\r
-\r
-/**\r
- * @desc       This file handles all the image upload operations\r
- * @author     Dylan Cheon & Kelvin Wong\r
- * @copyright  2006, Institute for Assistive Technology / University of Victoria \r
- * @link       http://www.canassist.ca/                                    \r
- * @license GNU\r
- */\r
-\r
-require_once(PATH.'classes/phpThumb_1.7.2/phpthumb.class.php');\r
-require_once(PATH.'classes/phpThumb_1.7.2/phpthumb.functions.php');\r
-require_once(PATH.'classes/pa.class.php');\r
-require_once(PATH.'define.php');\r
-\r
-/**\r
- * @desc       image upload class to upload an image\r
- * @see                class Pa\r
- */\r
-\r
-class IMAGE_UPLOAD extends PA{\r
-       var $name='';\r
-       var $file_size=0;\r
-       var $file_tmp_src='';\r
-       var $file_type='';\r
-       var $thumb_image_name='';\r
-       var $view_image_name='';\r
-       var $image_copy_required=true;\r
-       var $user_input_error=0;\r
-       var $user_input_array=Array();\r
-       var $temp_folder_path='';\r
-       \r
-       /**\r
-        * @desc        image upload constructor\r
-        * @param       Array   $file_array                     array which contains the image file information (name, size, tmp_src, etc)\r
-        * @param       String  $temp_folder_path       temp folder path string to copy the image file in.\r
-        */\r
-       function IMAGE_UPLOAD($file_array, $temp_folder_path){\r
-               parent::init();\r
-               $this->setVariable('temp_folder_path', $temp_folder_path);\r
-               $this->checkImageFile($file_array);\r
-               if (($this->getVariable('user_input_error')==0) && ($this->getVariable('image_copy_required')==true)){  //no error, so process image copy operation\r
-                       $this->setVariable('name', $file_array['name']);\r
-                       $this->copyViewImage();\r
-                       $this->copyThumbImage();\r
-               }       \r
-       }\r
-       \r
-       /**\r
-        * @desc        This function checks the given file array is properly set up\r
-        * @param       Array   $file   file array\r
-        */\r
-       function checkImageFile(&$file){\r
-               $this->checkImageEmpty($file['name']);\r
-               $this->checkValidType($file['type']);\r
-               $this->checkValidNameLength($file['name']);\r
-               $this->checkValidEscape($file['name']);\r
-               $this->checkValidSize($file['size']);           \r
-               $this->setVariable('file_tmp_src', $file['tmp_name']);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * @desc        This function checks whether the image is submitted empty or not\r
-        * @param       String  $file   image name\r
-        */\r
-       function checkImageEmpty(&$file){\r
-               if (empty($file)){\r
-                       $this->storeUserError("file_empty");\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function stores the user input error \r
-        * @param       String  $string         error string\r
-        */\r
-       function storeUserError($string){\r
-               $error_count=$this->getVariable('user_input_error');\r
-               $error_array=&$this->user_input_array;\r
-               $error_array[$error_count]=&$string;\r
-               $this->setVariable('user_input_error', $error_count+1);\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function checks whether the image size is valid\r
-        * @param       int     $file   image size\r
-        */\r
-       function checkValidSize($file){\r
-               $max_size=get_max_file_size(PA::getVariable('course_id'));\r
-               if ($max_size==-1){\r
-                       global $_config;\r
-                       $max_size=$_config['max_file_size'];\r
-               } \r
-               if ($file > $max_size){\r
-                       $this->storeUserError('file_size');\r
-               } else {\r
-                       $this->setVariable('file_size', $file);\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function checks whether the image file name uses invalid escape characters or not\r
-        * @param       String  $file   image file name\r
-        */\r
-       function checkValidEscape(&$file){\r
-               if (ereg(INVALID_ESCAPE, $file)){\r
-                       $this->storeUserError('file_escape');\r
-               }\r
-       }       \r
-       \r
-       /**\r
-        * @desc        This function checks whether the image file name length is valid\r
-        * @param       String  $file   image name\r
-        */\r
-       function checkValidNameLength(&$file){\r
-               if (count($file)>MAX_FILENAME_LENGTH){\r
-                       $this->storeUserError('file_length');\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function checks whether the image type is valid\r
-        * @param       String  $type   image type string\r
-        */\r
-       function checkValidType($type){\r
-               global $IMAGE_TYPE;\r
-               if (in_array($type, $IMAGE_TYPE)){\r
-                       $this->setVariable('file_type', $type);\r
-               } else {\r
-                       $this->storeUserError('file_type');\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function sets the string value for the class object\r
-        * @param       String  $string         string name to be set\r
-        * @param       mixed   $value          string value \r
-        */\r
-       function setVariable($string, $value){\r
-               switch ($string){\r
-                       case 'mode_edit':\r
-                       case 'image_copy_required':\r
-                               if (is_bool($value)){\r
-                                       $this->{$string}=$value;\r
-                               } else {\r
-                                       parent::storeError("string ".$string." is not boolean");\r
-                               }\r
-                       break;\r
-                       case 'file_type':\r
-                       case 'file_tmp_src':\r
-                       case 'name':\r
-                       case 'thumb_image_name':\r
-                       case 'view_image_name':\r
-                       case 'temp_folder_path':\r
-                               if (is_string($value)){\r
-                                       $this->{$string}=$value;\r
-                               } else {\r
-                                       parent::storeError("string ".$string." is not string");\r
-                               }       \r
-                       break;\r
-                       case 'user_input_error':\r
-                               if (is_int($value)){\r
-                                       $this->{$string}=$value;\r
-                               } else {\r
-                                       parent::storeError("string ".$string." is not int");\r
-                               }\r
-                       break;\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function creates a full-sized image of the image file and copies it to the temp folder\r
-        */\r
-       function copyViewImage(){\r
-               $temp_folder_path=$this->getVariable('temp_folder_path');\r
-               $view_image_name=modify_image_name($temp_folder_path, $this->getVariable('name'));\r
-               $this->setVariable('view_image_name', $view_image_name);        \r
-               image_to_this_location($view_image_name, $this->getVariable('file_tmp_src'), $temp_folder_path);\r
-               $thumb=new phpThumb();\r
-               $view_image_path=AT_CONTENT_DIR.$temp_folder_path.$view_image_name;\r
-               $thumb->setSourceFilename($view_image_path);\r
-               $size=getimagesize($view_image_path);\r
-               /* set size for view image */\r
-               if ($size[0]>MAX_IMAGE_WIDTH){\r
-                       $thumb->w=MAX_IMAGE_WIDTH;\r
-               }\r
-               if (defined(MAX_IMAGE_HEIGHT) && $size[1]> MAX_IMAGE_HEIGHT){\r
-                       $thumb->h=MAX_IMAGE_HEIGHT;\r
-               }\r
-               \r
-               $thumb->iar='l';\r
-               $thumb->config_output_format='jpeg';\r
-               \r
-               /* generate for view image */   \r
-               if ($thumb->GenerateThumbnail()){\r
-                       if ($view_image_path){\r
-                               if (!$thumb->RenderToFile($view_image_path)){\r
-                                       parent::storeError("render operation failed for view image");   \r
-                               }\r
-                       } else {\r
-                               parent::storeError("view image path does not exist");\r
-                       }\r
-               } else {\r
-                       parent::storeError("View generateThumbnail operation is failed");\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * @desc        This function creates a thumbnail image of the image file and stores it in the temp folder\r
-        */     \r
-       function copyThumbImage(){\r
-               $temp_folder_path=$this->getVariable('temp_folder_path');\r
-               $thumb_image_name=insert_into_image_name($this->getVariable('view_image_name'), THUMB_EXT);\r
-               $thumb_image_name=modify_image_name($temp_folder_path, $thumb_image_name);\r
-               $this->setVariable('thumb_image_name', $thumb_image_name);\r
-               $thumb=new phpThumb();\r
-               $view_image_path=AT_CONTENT_DIR.$temp_folder_path.$this->getVariable('view_image_name');\r
-               $thumb->setSourceFilename($view_image_path);\r
-               $size=getimagesize($view_image_path);\r
-               /* set size for thumb image */\r
-               $thumb->iar='l';\r
-               $thumb->config_output_format='jpeg';\r
-               \r
-               /* set size for thumb image */\r
-               $thumb->h=THUMB_IMAGE_HEIGHT;\r
-               $thumb->w=THUMB_IMAGE_WIDTH;\r
-               \r
-               /* generate for thumb image */  \r
-               $thumb_image_path=AT_CONTENT_DIR.$temp_folder_path.$thumb_image_name;\r
-               if ($thumb->GenerateThumbnail()){\r
-                       if ($view_image_path){\r
-                               if (!$thumb->RenderToFile($thumb_image_path)){\r
-                                       parent::storeError("render operation failed for thumb image");  \r
-                               }\r
-                       } else {\r
-                               parent::storeError("view image path does not exist");\r
-                       }\r
-               } else {\r
-                       parent::storeError("Thumb generateThumbnail operation is failed");\r
-               }\r
-       }\r
-}      \r
-?>\r