Exemple #1
0
  * Creating the factory  and the criteria to delete the picture
  * The user must be the owner
  */
 $album_factory = new Xoopsyogurt_imagesHandler($xoopsDB);
 $criteria_img = new Criteria('cod_img', $cod_img);
 $uid = intval($xoopsUser->getVar('uid'));
 $criteria_uid = new Criteria('uid_owner', $uid);
 $criteria = new CriteriaCompo($criteria_img);
 $criteria->add($criteria_uid);
 $objects_array = $album_factory->getObjects($criteria);
 $image_name = $objects_array[0]->getVar('url');
 $avatar_image = $xoopsUser->getVar('user_avatar');
 /**
  * Try to delete  
  */
 if ($album_factory->deleteAll($criteria)) {
     if ($xoopsModuleConfig['physical_delete'] == 1) {
         //unlink($xoopsModuleConfig['path_upload']."\/".$image_name);
         unlink(XOOPS_ROOT_PATH . '/uploads' . '/' . $image_name);
         unlink(XOOPS_ROOT_PATH . '/uploads' . '/resized_' . $image_name);
         /**
          * Delete the thumb (avatar now has another name)
          */
         //if ($avatar_image!=$image_name){
         unlink(XOOPS_ROOT_PATH . '/uploads' . '/thumb_' . $image_name);
         //}
     }
     redirect_header('album.php', 2, _MD_YOGURT_DELETED);
 } else {
     redirect_header('album.php', 2, _MD_YOGURT_NOCACHACA);
 }