Exemplo n.º 1
0
 /**
  * Delete object
  * Sends JSON reply in the result and
  * closes the application
  */
 public function deleteAction()
 {
     $this->_checkCanDelete();
     $id = Request::post('id', 'integer', false);
     if (!$id) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     try {
         $object = new Db_Object($this->_objectName, $id);
     } catch (Exception $e) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $childCount = Model::factory('Mediacategory')->getCount(array('parent_id' => $id));
     if ($childCount) {
         Response::jsonError($this->_lang->REMOVE_CHILDREN);
     }
     if ($this->_configMain->get('vc_clear_on_delete')) {
         Model::factory('Vc')->removeItemVc($this->_objectName, $id);
     }
     $medialib = Model::factory('Medialib');
     $medialib->categoryRemoved($id);
     if (!$object->delete()) {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
     Response::jsonSuccess();
 }
Exemplo n.º 2
0
 /**
  * Remove users Group
  * @param integer $id
  * @return boolean
  */
 public function removeGroup($id)
 {
     $obj = new Db_Object($this->_name, $id);
     if (!$obj->delete()) {
         return false;
     }
     $cache = self::$_dataCache;
     /**
      * Invalidate cache
      */
     if ($cache) {
         $cache->remove('groups_list');
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Delete item from library
  * @param integer $id
  */
 public function remove($id, $log = true)
 {
     if (!$id) {
         return false;
     }
     $obj = new Db_Object($this->_name, $id);
     $data = $obj->getData();
     if (empty($data)) {
         return false;
     }
     $docRoot = Registry::get('main', 'config')->get('docroot');
     if (strlen($data['path'])) {
         @unlink($docRoot . $data['path']);
         if ($data['type'] == 'image') {
             $conf = $this->getConfig()->__toArray();
             foreach ($conf['image']['sizes'] as $k => $v) {
                 @unlink($docRoot . self::getImgPath($data['path'], $data['ext'], $k));
             }
         }
     }
     $obj->delete();
     return true;
 }
Exemplo n.º 4
0
Arquivo: Vc.php Projeto: vgrish/dvelum
 /**
  * (non-PHPdoc)
  * @see Backend_Controller_Crud::deleteAction()
  */
 public function deleteAction()
 {
     $id = Request::post('id', 'integer', false);
     try {
         $object = new Db_Object($this->_objectName, $id);
     } catch (Exception $e) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (!$id) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (!User::getInstance()->canDelete($this->_objectName)) {
         Response::jsonError($this->_lang->CANT_DELETE);
     }
     if ($this->_configMain->get('vc_clear_on_delete')) {
         Model::factory('Vc')->removeItemVc($this->_objectName, $id);
     }
     if (!$object->delete()) {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
     Response::jsonSuccess();
 }
Exemplo n.º 5
0
 /**
  * (non-PHPdoc)
  * @see Filestorage_Simple::remove()
  */
 public function remove($fileId)
 {
     if (!Db_Object::objectExists($this->_object, $fileId)) {
         return true;
     }
     try {
         $o = new Db_Object($this->_object, $fileId);
     } catch (Exception $e) {
         return false;
     }
     $path = $o->path;
     if (!$o->delete()) {
         return false;
     }
     return parent::remove($path);
 }