|
@@ -17,7 +17,7 @@ require_once('Transform.php');
|
|
|
* @author Wei Zhuo
|
|
|
* @version $Id: ImageManager.php,v 1.4 2006/12/21 21:28:00 thierrybo Exp $
|
|
|
*/
|
|
|
-class ImageManager
|
|
|
+class ImageManager
|
|
|
{
|
|
|
/**
|
|
|
* Configuration array.
|
|
@@ -33,7 +33,7 @@ class ImageManager
|
|
|
* Constructor. Create a new Image Manager instance.
|
|
|
* @param array $config configuration array, see config.inc.php
|
|
|
*/
|
|
|
- function ImageManager($config)
|
|
|
+ function ImageManager($config)
|
|
|
{
|
|
|
$this->config = $config;
|
|
|
}
|
|
@@ -42,7 +42,7 @@ class ImageManager
|
|
|
* Get the base directory.
|
|
|
* @return string base dir, see config.inc.php
|
|
|
*/
|
|
|
- function getBaseDir()
|
|
|
+ function getBaseDir()
|
|
|
{
|
|
|
Return $this->config['base_dir'];
|
|
|
}
|
|
@@ -51,11 +51,11 @@ class ImageManager
|
|
|
* Get the base URL.
|
|
|
* @return string base url, see config.inc.php
|
|
|
*/
|
|
|
- function getBaseURL()
|
|
|
+ function getBaseURL()
|
|
|
{
|
|
|
Return $this->config['base_url'];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function isValidBase()
|
|
|
{
|
|
|
return is_dir($this->getBaseDir());
|
|
@@ -65,7 +65,7 @@ class ImageManager
|
|
|
* Get the tmp file prefix.
|
|
|
* @return string tmp file prefix.
|
|
|
*/
|
|
|
- function getTmpPrefix()
|
|
|
+ function getTmpPrefix()
|
|
|
{
|
|
|
Return $this->config['tmp_prefix'];
|
|
|
}
|
|
@@ -73,12 +73,12 @@ class ImageManager
|
|
|
/**
|
|
|
* Get the sub directories in the base dir.
|
|
|
* Each array element contain
|
|
|
- * the relative path (relative to the base dir) as key and the
|
|
|
+ * the relative path (relative to the base dir) as key and the
|
|
|
* full path as value.
|
|
|
* @return array of sub directries
|
|
|
* <code>array('path name' => 'full directory path', ...)</code>
|
|
|
*/
|
|
|
- function getDirs()
|
|
|
+ function getDirs()
|
|
|
{
|
|
|
if(is_null($this->dirs))
|
|
|
{
|
|
@@ -98,7 +98,7 @@ class ImageManager
|
|
|
* @return array of accessiable sub-directories
|
|
|
* <code>array('path name' => 'full directory path', ...)</code>
|
|
|
*/
|
|
|
- function _dirs($base, $path)
|
|
|
+ function _dirs($base, $path)
|
|
|
{
|
|
|
$base = Files::fixPath($base);
|
|
|
$dirs = array();
|
|
@@ -107,7 +107,7 @@ class ImageManager
|
|
|
return $dirs;
|
|
|
|
|
|
$d = @dir($base);
|
|
|
-
|
|
|
+
|
|
|
$in_group = api_is_in_group();
|
|
|
if ($in_group)
|
|
|
{
|
|
@@ -117,18 +117,18 @@ class ImageManager
|
|
|
}
|
|
|
|
|
|
$user_id = api_get_user_id();
|
|
|
- while (false !== ($entry = $d->read()))
|
|
|
+ while (false !== ($entry = $d->read()))
|
|
|
{
|
|
|
//If it is a directory, and it doesn't start with
|
|
|
// a dot, and if is it not the thumbnail directory
|
|
|
- if(is_dir($base.$entry)
|
|
|
+ if(is_dir($base.$entry)
|
|
|
&& substr($entry,0,1) != '.'
|
|
|
&& strpos($entry, '_DELETED_') === false
|
|
|
&& strpos($entry, 'chat_files') === false
|
|
|
&& strpos($entry, 'css') === false
|
|
|
&& strpos($entry, 'HotPotatoes_files') === false
|
|
|
&& ($in_group || (!$in_group && strpos($entry, '_groupdocs') === false))
|
|
|
- && $this->isThumbDir($entry) == false)
|
|
|
+ && $this->isThumbDir($entry) == false)
|
|
|
{
|
|
|
$relative = Files::fixPath($path.$entry);
|
|
|
$fullpath = Files::fixPath($base.$entry);
|
|
@@ -139,17 +139,17 @@ class ImageManager
|
|
|
}
|
|
|
global $_course;
|
|
|
if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
- $base_dir = substr($fullpath, 0, strpos($fullpath,'/document/')+9); //
|
|
|
- $new_dir = substr($fullpath, strlen($base_dir),-1); //
|
|
|
+ $base_dir = substr($fullpath, 0, strpos($fullpath,'/document/')+9); //
|
|
|
+ $new_dir = substr($fullpath, strlen($base_dir),-1); //
|
|
|
$doc_id = DocumentManager::get_document_id($_course, $new_dir );
|
|
|
$visible_status= api_get_item_visibility($_course,TOOL_DOCUMENT,$doc_id);
|
|
|
}
|
|
|
|
|
|
//Teachers can access to hidden files and directories as they can in the tool documents
|
|
|
- /*
|
|
|
- if ($visible_status=='0' || $visible_status=='-1') {
|
|
|
+ /*
|
|
|
+ if ($visible_status=='0' || $visible_status=='-1') {
|
|
|
continue;
|
|
|
- }
|
|
|
+ }
|
|
|
*/
|
|
|
|
|
|
/* if (strpos($fullpath, '/shared_folder/') !== false) {
|
|
@@ -175,13 +175,13 @@ class ImageManager
|
|
|
* @param string $path relative path to be base path.
|
|
|
* @return array of file and path information.
|
|
|
* <code>array(0=>array('relative'=>'fullpath',...), 1=>array('filename'=>fileinfo array(),...)</code>
|
|
|
- * fileinfo array: <code>array('url'=>'full url',
|
|
|
- * 'relative'=>'relative to base',
|
|
|
- * 'fullpath'=>'full file path',
|
|
|
+ * fileinfo array: <code>array('url'=>'full url',
|
|
|
+ * 'relative'=>'relative to base',
|
|
|
+ * 'fullpath'=>'full file path',
|
|
|
* 'image'=>imageInfo array() false if not image,
|
|
|
* 'stat' => filestat)</code>
|
|
|
*/
|
|
|
- function getFiles($path)
|
|
|
+ function getFiles($path)
|
|
|
{
|
|
|
$files = array();
|
|
|
$dirs = array();
|
|
@@ -208,17 +208,17 @@ class ImageManager
|
|
|
|
|
|
// check templates files in bd
|
|
|
$tbl_system_template = Database :: get_main_table(TABLE_MAIN_SYSTEM_TEMPLATE);
|
|
|
-
|
|
|
+
|
|
|
$sql = "SELECT image FROM $tbl_system_template ";
|
|
|
$res = Database::query($sql,__FILE__,__LINE__);
|
|
|
|
|
|
- $files_templates = array();
|
|
|
-
|
|
|
+ $files_templates = array();
|
|
|
+
|
|
|
while ($row = Database::fetch_row($res)) {
|
|
|
$files_templates[] = $row[0];
|
|
|
- }
|
|
|
-
|
|
|
- while (false !== ($entry = $d->read()))
|
|
|
+ }
|
|
|
+
|
|
|
+ while (false !== ($entry = $d->read()))
|
|
|
{
|
|
|
|
|
|
if (in_array($entry,$files_templates)) continue;
|
|
@@ -252,16 +252,16 @@ class ImageManager
|
|
|
if($is_dir && $this->isThumbDir($entry) == false) {
|
|
|
global $_course;
|
|
|
if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
- //checking visibility
|
|
|
- $base_dir = substr($dir_entry, 0, strpos($dir_entry,'/document/')+9);
|
|
|
- $new_dir = substr($dir_entry, strlen($base_dir),-1); //
|
|
|
+ //checking visibility
|
|
|
+ $base_dir = substr($dir_entry, 0, strpos($dir_entry,'/document/')+9);
|
|
|
+ $new_dir = substr($dir_entry, strlen($base_dir),-1); //
|
|
|
$doc_id = DocumentManager::get_document_id($_course, $new_dir );
|
|
|
- $visible_status= api_get_item_visibility($_course,TOOL_DOCUMENT,$doc_id);
|
|
|
- }
|
|
|
-
|
|
|
+ $visible_status= api_get_item_visibility($_course,TOOL_DOCUMENT,$doc_id);
|
|
|
+ }
|
|
|
+
|
|
|
//Teachers can access to hidden files and directories as they can in the tool documents
|
|
|
/*
|
|
|
- if ($visible_status=='0' || $visible_status=='-1') {
|
|
|
+ if ($visible_status=='0' || $visible_status=='-1') {
|
|
|
continue;
|
|
|
}
|
|
|
*/
|
|
@@ -270,7 +270,7 @@ class ImageManager
|
|
|
$count = $this->countFiles($full);
|
|
|
$dirs[$relative] = array('fullpath'=>$full,'entry'=>$entry,'count'=>$count);
|
|
|
}
|
|
|
- else if(is_file($fullpath.$entry) && $this->isThumb($entry)==false && $this->isTmpFile($entry) == false)
|
|
|
+ else if(is_file($fullpath.$entry) && $this->isThumb($entry)==false && $this->isTmpFile($entry) == false)
|
|
|
{
|
|
|
$img = $this->getImageInfo($fullpath.$entry);
|
|
|
|
|
@@ -279,15 +279,15 @@ class ImageManager
|
|
|
global $_course;
|
|
|
if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
//checking visibility
|
|
|
- $base_dir = substr($fullpath.$entry, 0, strpos($fullpath.$entry,'/document/')+9);
|
|
|
- $new_dir = substr($fullpath.$entry, strlen($base_dir));
|
|
|
+ $base_dir = substr($fullpath.$entry, 0, strpos($fullpath.$entry,'/document/')+9);
|
|
|
+ $new_dir = substr($fullpath.$entry, strlen($base_dir));
|
|
|
$doc_id = DocumentManager::get_document_id($_course, $new_dir );
|
|
|
- $visible_status= api_get_item_visibility($_course,TOOL_DOCUMENT,$doc_id);
|
|
|
+ $visible_status= api_get_item_visibility($_course,TOOL_DOCUMENT,$doc_id);
|
|
|
}
|
|
|
|
|
|
//Teachers can access to hidden files and directories as they can in the tool documents
|
|
|
/*
|
|
|
- if ($visible_status=='0' || $visible_status=='-1') {
|
|
|
+ if ($visible_status=='0' || $visible_status=='-1') {
|
|
|
continue;
|
|
|
}
|
|
|
*/
|
|
@@ -305,29 +305,29 @@ class ImageManager
|
|
|
$d->close();
|
|
|
ksort($dirs);
|
|
|
ksort($files);
|
|
|
-
|
|
|
+
|
|
|
Return array($dirs, $files);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Count the number of files and directories in a given folder
|
|
|
* minus the thumbnail folders and thumbnails.
|
|
|
*/
|
|
|
- function countFiles($path)
|
|
|
+ function countFiles($path)
|
|
|
{
|
|
|
$total = 0;
|
|
|
|
|
|
- if(is_dir($path))
|
|
|
+ if(is_dir($path))
|
|
|
{
|
|
|
$d = @dir($path);
|
|
|
|
|
|
- while (false !== ($entry = $d->read()))
|
|
|
+ while (false !== ($entry = $d->read()))
|
|
|
{
|
|
|
//echo $entry."<br>";
|
|
|
if(substr($entry,0,1) != '.'
|
|
|
&& $this->isThumbDir($entry) == false
|
|
|
&& $this->isTmpFile($entry) == false
|
|
|
- && $this->isThumb($entry) == false)
|
|
|
+ && $this->isThumb($entry) == false)
|
|
|
{
|
|
|
$total++;
|
|
|
}
|
|
@@ -340,10 +340,10 @@ class ImageManager
|
|
|
/**
|
|
|
* Get image size information.
|
|
|
* @param string $file the image file
|
|
|
- * @return array of getImageSize information,
|
|
|
+ * @return array of getImageSize information,
|
|
|
* false if the file is not an image.
|
|
|
*/
|
|
|
- function getImageInfo($file)
|
|
|
+ function getImageInfo($file)
|
|
|
{
|
|
|
Return @getImageSize($file);
|
|
|
}
|
|
@@ -353,7 +353,7 @@ class ImageManager
|
|
|
* @param string $file filename to be checked
|
|
|
* @return true if the file contains the thumbnail prefix, false otherwise.
|
|
|
*/
|
|
|
- function isThumb($file)
|
|
|
+ function isThumb($file)
|
|
|
{
|
|
|
$len = strlen($this->config['thumbnail_prefix']);
|
|
|
if(substr($file,0,$len)==$this->config['thumbnail_prefix'])
|
|
@@ -367,11 +367,11 @@ class ImageManager
|
|
|
* @param string $entry directory name
|
|
|
* @return true if it is a thumbnail directory, false otherwise
|
|
|
*/
|
|
|
- function isThumbDir($entry)
|
|
|
+ function isThumbDir($entry)
|
|
|
{
|
|
|
if($this->config['thumbnail_dir'] == false
|
|
|
|| strlen(trim($this->config['thumbnail_dir'])) == 0)
|
|
|
- Return false;
|
|
|
+ Return false;
|
|
|
else
|
|
|
Return ($entry == $this->config['thumbnail_dir']);
|
|
|
}
|
|
@@ -381,13 +381,13 @@ class ImageManager
|
|
|
* @param string $file file name
|
|
|
* @return boolean true if it is a tmp file, false otherwise
|
|
|
*/
|
|
|
- function isTmpFile($file)
|
|
|
+ function isTmpFile($file)
|
|
|
{
|
|
|
$len = strlen($this->config['tmp_prefix']);
|
|
|
if(substr($file,0,$len)==$this->config['tmp_prefix'])
|
|
|
Return true;
|
|
|
else
|
|
|
- Return false;
|
|
|
+ Return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -396,10 +396,10 @@ class ImageManager
|
|
|
* @param string $fullpathfile the full path to the image file
|
|
|
* @return string of the thumbnail file
|
|
|
*/
|
|
|
- function getThumbName($fullpathfile)
|
|
|
+ function getThumbName($fullpathfile)
|
|
|
{
|
|
|
$path_parts = pathinfo($fullpathfile);
|
|
|
-
|
|
|
+
|
|
|
$thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename'];
|
|
|
|
|
|
if($this->config['safe_mode'] == true
|
|
@@ -422,15 +422,15 @@ class ImageManager
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Similar to getThumbName, but returns the URL, base on the
|
|
|
* given base_url in config.inc.php
|
|
|
- * @param string $relative the relative image file name,
|
|
|
+ * @param string $relative the relative image file name,
|
|
|
* relative to the base_dir path
|
|
|
* @return string the url of the thumbnail
|
|
|
*/
|
|
|
- function getThumbURL($relative)
|
|
|
+ function getThumbURL($relative)
|
|
|
{
|
|
|
$path_parts = pathinfo($relative);
|
|
|
$thumbnail = $this->config['thumbnail_prefix'].$path_parts['basename'];
|
|
@@ -465,12 +465,12 @@ class ImageManager
|
|
|
* @param string $path the relative path to be checked
|
|
|
* @return boolean true if the path exists, false otherwise
|
|
|
*/
|
|
|
- function validRelativePath($path)
|
|
|
+ function validRelativePath($path)
|
|
|
{
|
|
|
$dirs = $this->getDirs();
|
|
|
if($path == '/' || $path == '')
|
|
|
Return true;
|
|
|
- //check the path given in the url against the
|
|
|
+ //check the path given in the url against the
|
|
|
//list of paths in the system.
|
|
|
for($i = 0; $i < count($dirs); $i++)
|
|
|
{
|
|
@@ -478,28 +478,28 @@ class ImageManager
|
|
|
//we found the path
|
|
|
if($key == $path)
|
|
|
Return true;
|
|
|
-
|
|
|
+
|
|
|
next($dirs);
|
|
|
- }
|
|
|
+ }
|
|
|
Return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Process uploaded files, assumes the file is in
|
|
|
+ * Process uploaded files, assumes the file is in
|
|
|
* $_FILES['upload'] and $_POST['dir'] is set.
|
|
|
* The dir must be relative to the base_dir and exists.
|
|
|
* If 'validate_images' is set to true, only file with
|
|
|
* image dimensions will be accepted.
|
|
|
* @return null
|
|
|
*/
|
|
|
- function processUploads()
|
|
|
+ function processUploads()
|
|
|
{
|
|
|
if($this->isValidBase() == false)
|
|
|
return;
|
|
|
|
|
|
$relative = null;
|
|
|
|
|
|
- if(isset($_POST['dir']))
|
|
|
+ if(isset($_POST['dir']))
|
|
|
$relative = rawurldecode($_POST['dir']);
|
|
|
else
|
|
|
return;
|
|
@@ -512,7 +512,7 @@ class ImageManager
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Process upload files. The file must be an
|
|
|
+ * Process upload files. The file must be an
|
|
|
* uploaded file. If 'validate_images' is set to
|
|
|
* true, only images will be processed. Any duplicate
|
|
|
* file will be renamed. See Files::copyFile for details
|
|
@@ -520,12 +520,12 @@ class ImageManager
|
|
|
* @param string $relative the relative path where the file
|
|
|
* should be copied to.
|
|
|
* @param array $file the uploaded file from $_FILES
|
|
|
- * @return boolean true if the file was processed successfully,
|
|
|
+ * @return boolean true if the file was processed successfully,
|
|
|
* false otherwise
|
|
|
*/
|
|
|
function _processFiles($relative, $file)
|
|
|
{
|
|
|
- global $_course;
|
|
|
+ global $_course;
|
|
|
if($file['error']!=0)
|
|
|
{
|
|
|
return false;
|
|
@@ -587,29 +587,29 @@ class ImageManager
|
|
|
|
|
|
//no copy error
|
|
|
if (!is_int($result)) {
|
|
|
-
|
|
|
+
|
|
|
if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
//adding the document to the DB
|
|
|
global $to_group_id;
|
|
|
-
|
|
|
+
|
|
|
// looking for the /document/ folder
|
|
|
$document_path = substr($path, strpos($path,'/document/')+9, strlen($path)); // /shared_folder/4/name
|
|
|
$document_path.= $result;
|
|
|
-
|
|
|
- $dokeosFile = $file['name'];
|
|
|
+
|
|
|
+ $dokeosFile = $file['name'];
|
|
|
$dokeosFileSize = $file['size'];
|
|
|
if(!empty($group_properties['directory'])) {
|
|
|
$dokeosFolder=$group_properties['directory'].$dokeosFolder;//get Dokeos
|
|
|
}
|
|
|
-
|
|
|
- $doc_id = add_document($_course, $document_path,'file', $dokeosFileSize , $dokeosFile); //get Dokeos
|
|
|
- api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id);//get Dokeos
|
|
|
+
|
|
|
+ $doc_id = add_document($_course, $document_path,'file', $dokeosFileSize , $dokeosFile); //get Dokeos
|
|
|
+ api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id);//get Dokeos
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
if (!(api_is_platform_admin() || api_is_course_admin())) {
|
|
|
//setting invisible by default for the students
|
|
|
- api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id());
|
|
|
+ api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id());
|
|
|
}
|
|
|
*/
|
|
|
$dimensionsIndex = isset($_REQUEST['uploadSize']) ? $_REQUEST['uploadSize'] : 0;
|
|
@@ -638,12 +638,12 @@ class ImageManager
|
|
|
|
|
|
/**
|
|
|
* Get the URL of the relative file.
|
|
|
- * basically appends the relative file to the
|
|
|
+ * basically appends the relative file to the
|
|
|
* base_url given in config.inc.php
|
|
|
* @param string $relative a file the relative to the base_dir
|
|
|
* @return string the URL of the relative file.
|
|
|
*/
|
|
|
- function getFileURL($relative)
|
|
|
+ function getFileURL($relative)
|
|
|
{
|
|
|
Return Files::makeFile($this->getBaseURL(),$relative);
|
|
|
}
|
|
@@ -653,32 +653,32 @@ class ImageManager
|
|
|
* @param string $relative the relative file.
|
|
|
* @return string the full path, .ie. the base_dir + relative.
|
|
|
*/
|
|
|
- function getFullPath($relative)
|
|
|
+ function getFullPath($relative)
|
|
|
{
|
|
|
Return Files::makeFile($this->getBaseDir(),$relative);;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the default thumbnail.
|
|
|
- * @return string default thumbnail, empty string if
|
|
|
+ * @return string default thumbnail, empty string if
|
|
|
* the thumbnail doesn't exist.
|
|
|
*/
|
|
|
- function getDefaultThumb()
|
|
|
+ function getDefaultThumb()
|
|
|
{
|
|
|
if(is_file($this->config['default_thumbnail']))
|
|
|
Return $this->config['default_thumbnail'];
|
|
|
- else
|
|
|
+ else
|
|
|
Return '';
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * Get the thumbnail url to be displayed.
|
|
|
+ * Get the thumbnail url to be displayed.
|
|
|
* If the thumbnail exists, and it is up-to-date
|
|
|
- * the thumbnail url will be returns. If the
|
|
|
+ * the thumbnail url will be returns. If the
|
|
|
* file is not an image, a default image will be returned.
|
|
|
- * If it is an image file, and no thumbnail exists or
|
|
|
- * the thumbnail is out-of-date (i.e. the thumbnail
|
|
|
+ * If it is an image file, and no thumbnail exists or
|
|
|
+ * the thumbnail is out-of-date (i.e. the thumbnail
|
|
|
* modified time is less than the original file)
|
|
|
* then a thumbs.php?img=filename.jpg is returned.
|
|
|
* The thumbs.php url will generate a new thumbnail
|
|
@@ -689,7 +689,7 @@ class ImageManager
|
|
|
* actually thumbnail or a script to generate the
|
|
|
* thumbnail on the fly.
|
|
|
*/
|
|
|
- function getThumbnail($relative)
|
|
|
+ function getThumbnail($relative)
|
|
|
{
|
|
|
$fullpath = Files::makeFile($this->getBaseDir(),$relative);
|
|
|
|
|
@@ -698,7 +698,7 @@ class ImageManager
|
|
|
Return $this->getDefaultThumb();
|
|
|
|
|
|
$imgInfo = @getImageSize($fullpath);
|
|
|
-
|
|
|
+
|
|
|
//not an image
|
|
|
if(!is_array($imgInfo))
|
|
|
Return $this->getDefaultThumb();
|
|
@@ -710,7 +710,7 @@ class ImageManager
|
|
|
Return $this->getFileURL($relative);
|
|
|
|
|
|
$thumbnail = $this->getThumbName($fullpath);
|
|
|
-
|
|
|
+
|
|
|
//check for thumbnails, if exists and
|
|
|
// it is up-to-date, return the thumbnail url
|
|
|
if(is_file($thumbnail))
|
|
@@ -728,7 +728,7 @@ class ImageManager
|
|
|
* Delete and specified files.
|
|
|
* @return boolean true if delete, false otherwise
|
|
|
*/
|
|
|
- function deleteFiles()
|
|
|
+ function deleteFiles()
|
|
|
{
|
|
|
if(isset($_GET['delf']))
|
|
|
$this->_delFile(rawurldecode($_GET['delf']));
|
|
@@ -738,10 +738,10 @@ class ImageManager
|
|
|
* Delete and specified directories.
|
|
|
* @return boolean true if delete, false otherwise
|
|
|
*/
|
|
|
- function deleteDirs()
|
|
|
+ function deleteDirs()
|
|
|
{
|
|
|
if(isset($_GET['deld']))
|
|
|
- return $this->_delDir(rawurldecode($_GET['deld']));
|
|
|
+ return $this->_delDir(rawurldecode($_GET['deld']));
|
|
|
else
|
|
|
Return false;
|
|
|
}
|
|
@@ -751,7 +751,7 @@ class ImageManager
|
|
|
* @param string $relative the relative file.
|
|
|
* @return boolean true if deleted, false otherwise.
|
|
|
*/
|
|
|
- function _delFile($relative)
|
|
|
+ function _delFile($relative)
|
|
|
{
|
|
|
$fullpath = Files::makeFile($this->getBaseDir(),$relative);
|
|
|
//check that the file is an image
|
|
@@ -767,7 +767,7 @@ class ImageManager
|
|
|
//deleting from the DB
|
|
|
global $_course;
|
|
|
if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
- $document_path = substr($fullpath, strpos($fullpath,'/document/')+9, strlen($fullpath)); // /shared_folder/4/name
|
|
|
+ $document_path = substr($fullpath, strpos($fullpath,'/document/')+9, strlen($fullpath)); // /shared_folder/4/name
|
|
|
DocumentManager::delete_document($_course,$document_path,$fullpath);
|
|
|
}
|
|
|
Return Files::delFile($thumbnail);
|
|
@@ -781,17 +781,17 @@ class ImageManager
|
|
|
* @param string $relative the relative path to be deleted.
|
|
|
* @return boolean true if deleted, false otherwise.
|
|
|
*/
|
|
|
- function _delDir($relative)
|
|
|
+ function _delDir($relative)
|
|
|
{
|
|
|
$fullpath = Files::makePath($this->getBaseDir(),$relative);
|
|
|
//we can delete recursively even if there are images in the dir
|
|
|
-
|
|
|
+
|
|
|
//if($this->countFiles($fullpath) <= 0) {
|
|
|
// now we use the default delete_document function
|
|
|
//return Files::delFolder($fullpath,true); //delete recursively.
|
|
|
global $_course;
|
|
|
- if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
- $path_dir = substr($fullpath, strpos($fullpath,'/document/')+9,-1); //
|
|
|
+ if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
+ $path_dir = substr($fullpath, strpos($fullpath,'/document/')+9,-1); //
|
|
|
$base_dir = substr($fullpath, 0, strlen($fullpath) - strlen($path_dir)); //
|
|
|
return DocumentManager::delete_document($_course,$path_dir,$base_dir);
|
|
|
}
|
|
@@ -804,9 +804,9 @@ class ImageManager
|
|
|
{
|
|
|
Return false;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- /*
|
|
|
+
|
|
|
+ }
|
|
|
+ /*
|
|
|
}
|
|
|
else
|
|
|
Return false;
|
|
@@ -818,8 +818,8 @@ class ImageManager
|
|
|
* If in safe_mode, nothing happens.
|
|
|
* @return boolean true if created, false otherwise.
|
|
|
*/
|
|
|
- function processNewDir()
|
|
|
- {
|
|
|
+ function processNewDir()
|
|
|
+ {
|
|
|
if($this->config['safe_mode'] == true)
|
|
|
Return false;
|
|
|
|
|
@@ -827,29 +827,29 @@ class ImageManager
|
|
|
{
|
|
|
$newDir = rawurldecode($_GET['newDir']);
|
|
|
$dir = rawurldecode($_GET['dir']);
|
|
|
- $path = Files::makePath($this->getBaseDir(),$dir);
|
|
|
+ $path = Files::makePath($this->getBaseDir(),$dir);
|
|
|
$fullpath = Files::makePath($path, Files::escape($newDir));
|
|
|
if(is_dir($fullpath)) {
|
|
|
Return false;
|
|
|
} else {
|
|
|
//adding to the DB
|
|
|
// now the create_unexisting_directory will create the folder
|
|
|
- //$result = Files::createFolder($fullpath);
|
|
|
-
|
|
|
+ //$result = Files::createFolder($fullpath);
|
|
|
+
|
|
|
global $_course;
|
|
|
- if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
+ if (isset($_course['dbName']) && $_course<>'-1') {
|
|
|
//@todo make this str to functions
|
|
|
- $base_dir = substr($path, 0, strpos($path,'/document/')+9); //
|
|
|
- $new_dir = substr($fullpath, strlen($base_dir),-1); //
|
|
|
- $created_dir = create_unexisting_directory($_course, api_get_user_id(),0,0, $base_dir, $new_dir,$newDir);
|
|
|
- $doc_id = DocumentManager::get_document_id($_course, $new_dir );
|
|
|
+ $base_dir = substr($path, 0, strpos($path,'/document/')+9); //
|
|
|
+ $new_dir = substr($fullpath, strlen($base_dir),-1); //
|
|
|
+ $created_dir = create_unexisting_directory($_course, api_get_user_id(),0,0, $base_dir, $new_dir,$newDir);
|
|
|
+ $doc_id = DocumentManager::get_document_id($_course, $new_dir );
|
|
|
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Return Files::createFolder($fullpath);
|
|
|
- }
|
|
|
- return true;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|
|
|
}
|