* fix bug for delete useless file.
This commit is contained in:
@@ -48,6 +48,7 @@ class actionModel extends model
|
||||
|
||||
/* Process action. */
|
||||
$action = $this->loadModel('file')->processImgURL($action, 'comment', $this->post->uid);
|
||||
$this->file->autoDelete($this->post->uid);
|
||||
|
||||
/* Get product and project for this object. */
|
||||
$productAndProject = $this->getProductAndProject($action->objectType, $objectID);
|
||||
|
||||
+25
-9
@@ -654,13 +654,7 @@ class fileModel extends model
|
||||
{
|
||||
foreach($_SESSION['album'][$uid] as $i => $imageID)
|
||||
{
|
||||
if(!isset($imageIdList[$imageID]))
|
||||
{
|
||||
$file = $this->getById($imageID);
|
||||
$this->dao->delete()->from(TABLE_FILE)->where('id')->eq($imageID)->exec();
|
||||
@unlink($file->realPath);
|
||||
unset($_SESSION['album'][$uid][$i]);
|
||||
}
|
||||
if(isset($imageIdList[$imageID])) $_SESSION['album']['used'][$uid][$imageID] = $imageID;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
@@ -779,8 +773,6 @@ class fileModel extends model
|
||||
if(isset($_SESSION['album'][$uid]) and $_SESSION['album'][$uid])
|
||||
{
|
||||
$this->dao->update(TABLE_FILE)->data($data)->where('id')->in($_SESSION['album'][$uid])->exec();
|
||||
if(dao::isError()) return false;
|
||||
unset($_SESSION['album'][$uid]);
|
||||
return !dao::isError();
|
||||
}
|
||||
}
|
||||
@@ -804,4 +796,28 @@ class fileModel extends model
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto delete useless image.
|
||||
*
|
||||
* @param int $uid
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function autoDelete($uid)
|
||||
{
|
||||
if(!empty($_SESSION['album'][$uid]))
|
||||
{
|
||||
foreach($_SESSION['album'][$uid] as $i => $imageID)
|
||||
{
|
||||
if(!isset($_SESSION['album']['used'][$uid][$imageID]))
|
||||
{
|
||||
$file = $this->getById($imageID);
|
||||
$this->dao->delete()->from(TABLE_FILE)->where('id')->eq($imageID)->exec();
|
||||
@unlink($file->realPath);
|
||||
}
|
||||
}
|
||||
unset($_SESSION['album'][$uid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user