/**
  * Overwrite delete to delete to the datasource defined in config
  *
  * {@inheritDoc}
  */
 public function delete($id = null, $cascade = true)
 {
     $this->setDataSourceWrite();
     $retval = parent::delete($id, $cascade);
     $this->setDataSourceRead();
     return $retval;
 }
 /**
  * Delete a contact
  * @param null $id
  * @param bool $cascade
  * @return bool
  */
 public function delete($id = null, $cascade = true)
 {
     if (isset($id)) {
         $this->dataSource->api->delete("contato/cod/{$id}");
         return true;
     }
     return parent::delete($id, $cascade);
 }
Ejemplo n.º 3
0
 public function delete($id = null, $cascade = true)
 {
     $sended = $this->field('sended', array('Post.id' => $id));
     if ($sended) {
         return false;
     }
     return parent::delete($id, $cascade);
 }
 /** delete */
 public function delete($dao)
 {
     $item = $dao->getItem();
     parent::delete($dao);
     if ($dao->getGroupId() == MIDAS_GROUP_ANONYMOUS_KEY) {
         $this->computePolicyStatus($item);
     }
 }
 /** delete */
 public function delete($dao)
 {
     $folder = $dao->getFolder();
     parent::delete($dao);
     if ($dao->getGroupId() == MIDAS_GROUP_ANONYMOUS_KEY) {
         $this->computePolicyStatus($folder);
     }
 }
Ejemplo n.º 6
0
 /**
  * Validation rules
  *
  * @var array
  */
 public function delete($id = null, $cascade = true)
 {
     if ($id == NULL) {
         $id = $this->id;
     }
     $x = $this->find('first', array('conditions' => array('Banner.id' => $id)));
     unlink('files/banner_image/' . $x['Banner']['image']);
     parent::delete($id, $cascade);
 }
Ejemplo n.º 7
0
 public function delete($id = null, $cascade = true)
 {
     if ($id == NULL) {
         $id = $this->id;
     }
     $x = $this->find('first', array('conditions' => array('Rug.id' => $id)));
     $this->removeDir("webroot/files/templates/" . $id);
     parent::delete($id, $cascade);
 }
Ejemplo n.º 8
0
 public function delete($id = null, $cascade = true)
 {
     if ($id == NULL) {
         $id = $this->id;
     }
     $x = $this->find('first', array('conditions' => array('Rugpng.id' => $id)));
     unlink($x['Rugpng']['path']);
     parent::delete($id, $cascade);
 }
Ejemplo n.º 9
0
 public function delete($id = null, $cascade = true)
 {
     if ($id == null) {
         $id = $this->id;
     }
     $path = $this->read(array('image'), $id);
     $vale = explode('ofood/', $path['Recipe']['image']);
     unlink($vale[1]);
     parent::delete($id, $cascade);
 }
Ejemplo n.º 10
0
 public function delete($id = null, $cascade = true)
 {
     if ($id == null) {
         $id = $this->id;
     }
     $path = $this->read(array('file'), $id);
     $unlink = explode('files/', $path[$this->alias]['file']);
     unlink('files/' . $unlink[1]);
     parent::delete($id, $cascade);
 }
Ejemplo n.º 11
0
 /**
  * handles the contact delete of adres
  *
  * @param integer $id 
  * @return boolean
  * @author Rajib 
  */
 public function delete($id)
 {
     $field_types = ClassRegistry::init('FieldType')->find('all');
     $fields = Set::extract($field_types, "/FieldType/class_name");
     foreach ($fields as $className) {
         //$this->{$className}->recursive = -1;
         ClassRegistry::init($className)->deleteAll(array('contact_id' => $id), false);
     }
     //this cascading enable HABTM delete of Group
     return parent::delete($id, true);
 }
Ejemplo n.º 12
0
 function delete($id = NULL, $cascade = true)
 {
     $this->id = $id;
     $media = $this->read();
     if (!$media) {
         return False;
     }
     $dir = $media['Media']['file_dir'];
     unlink(Configure::read('project_dir') . '/webroot/' . $dir . '/' . $media['Media']['file_name']);
     return parent::delete();
 }
Ejemplo n.º 13
0
 function delete($id = null)
 {
     $upload = $this->findById($id);
     if (!$upload) {
         return false;
     }
     // Delete DB record first
     $deleted = parent::delete($id);
     // Delete the actual file
     $path = Configure::read('Wildflower.uploadDirectory') . DS . $upload[$this->name]['name'];
     $this->deleteFiles($path);
     return $deleted;
 }
Ejemplo n.º 14
0
 function delete($id = NULL, $cascade = true)
 {
     $attachment = $this->read();
     $dir = $attachment['Attachment']['file_dir'];
     //$folders = array('disp', 'thumbnails', 'thumbnails_mini');
     $folders = array('disp', 'thumbnails', 'cropped');
     foreach ($folders as $folder) {
         $filepath = Configure::read('project_dir') . '/webroot/' . $dir . '/' . $folder . '/' . $attachment['Attachment']['file_name'];
         if (file_exists($filepath)) {
             unlink($filepath);
         }
     }
     parent::delete();
 }
Ejemplo n.º 15
0
 function delete($id)
 {
     $upload = $this->findById($id);
     if (!$upload) {
         return $this->cakeError('object_not_found');
     }
     // Delete DB record first
     if (parent::delete($upload[$this->name]['id'])) {
         $path = Configure::read('Wildflower.uploadDirectory') . DS . $upload[$this->name]['name'];
         $this->_deleteFiles($path);
         return true;
     }
     return false;
 }
 /**
  * Deletes an attachment record and its physical file.
  *
  * @param   array   $attachment 
  * @param   string  $alias  The alias of the attachment being deleted.
  * @return  boolean
  * @access  public
  */
 public function delete($attachment, $alias)
 {
     if (isset($attachment['Thumbnail'][$alias])) {
         $thumbnails = $attachment['Thumbnail'][$alias];
         # Delete the associated thumbnails
         foreach ($thumbnails as $thumb) {
             $this->unlink(APP . $thumb['path']);
             $this->AttachmentThumbnail->delete($thumb['id']);
         }
     }
     # Delete the physical file and the attachment record
     $this->unlink(APP . $attachment[$alias]['path']);
     return parent::delete($attachment[$alias]['id']);
 }
Ejemplo n.º 17
0
 /** delete a Bitstream */
 public function delete($bitstream)
 {
     if (!$bitstream instanceof BitstreamDao) {
         throw new Zend_Exception('Must pass a bitstream dao');
     }
     $checksum = $bitstream->getChecksum();
     $path = $bitstream->getFullPath();
     $assetstore = $bitstream->getAssetstore();
     parent::delete($bitstream);
     if (file_exists($path) && $assetstore->getType() != MIDAS_ASSETSTORE_REMOTE && $this->getByChecksum($checksum) == false) {
         unlink($path);
     }
     $bitstream->saved = false;
     unset($bitstream->bitstream_id);
 }
Ejemplo n.º 18
0
 /** delete an assetstore (and all the items in it)*/
 public function delete($dao)
 {
     if (!$dao instanceof AssetstoreDao) {
         throw new Zend_Exception('Deleting an assetstore requires a valid instance of an AssetstoreDao.');
     }
     $bitreams = $dao->getBitstreams();
     $items = array();
     foreach ($bitreams as $bitstream) {
         $revision = $bitstream->getItemrevision();
         if (empty($revision)) {
             continue;
         }
         $item = $revision->getItem();
         if (empty($item)) {
             continue;
         }
         $items[$item->getKey()] = $item;
     }
     /** @var ItemModel $itemModel */
     $itemModel = MidasLoader::loadModel('Item');
     foreach ($items as $item) {
         $itemModel->delete($item);
     }
     parent::delete($dao);
 }
Ejemplo n.º 19
0
 /** delete an item */
 public function delete($dao)
 {
     if (!$dao instanceof ItemDao) {
         throw new Zend_Exception('You must pass an item dao to ItemModel::delete');
     }
     Zend_Registry::get('notifier')->callback('CALLBACK_CORE_ITEM_DELETED', array('item' => $dao));
     parent::delete($dao);
 }
Ejemplo n.º 20
0
 /**
  * Remove the current node from the tree, and reparent all children up one level.
  *
  * If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
  * after the children are reparented.
  *
  * @param AppModel $Model Model instance
  * @param mixed $id The ID of the record to remove
  * @param boolean $delete whether to delete the node after reparenting children (if any)
  * @return boolean true on success, false on failure
  */
 function removefromtree(&$Model, $id = null, $delete = false)
 {
     if (is_array($id)) {
         extract(array_merge(array('id' => null), $id));
     }
     extract($this->settings[$Model->alias]);
     list($node) = array_values($Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $id), 'fields' => array($Model->primaryKey, $left, $right, $parent), 'recursive' => $recursive)));
     if ($node[$right] == $node[$left] + 1) {
         if ($delete) {
             return $Model->delete($id);
         } else {
             $Model->id = $id;
             return $Model->saveField($parent, null);
         }
     } elseif ($node[$parent]) {
         list($parentNode) = array_values($Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $node[$parent]), 'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive)));
     } else {
         $parentNode[$right] = $node[$right] + 1;
     }
     $db =& ConnectionManager::getDataSource($Model->useDbConfig);
     $Model->updateAll(array($parent => $db->value($node[$parent], $parent)), array($parent => $node[$Model->primaryKey]));
     $Model->id = $id;
     $this->__sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
     $this->__sync($Model, 2, '-', '> ' . $node[$right]);
     if ($delete) {
         $sub_tree = $Model->find('list', array('conditions' => array($left . ' >= ' . $node[$left], $right . ' <= ' . $node[$right]), 'fields' => array('id', 'parent_id')));
         foreach ($sub_tree as $sChild => $sParent) {
             $Model->del($sChild);
         }
         return true;
     } else {
         /*
          * this could feasibly create a lot of new trees.. worst case
          * performance slightly worse than original
          */
         $edge = $this->__getPartition($Model, $scope, $recursive);
         if ($node[$right] == $edge) {
             $edge = $edge - 2;
         }
         $Model->id = $id;
         return $Model->save(array($left => $edge, $right => $edge + 1, $parent => null), array('callbacks' => false));
     }
 }
Ejemplo n.º 21
0
 /** Delete a community */
 public function delete($communityDao)
 {
     if (!$communityDao instanceof CommunityDao) {
         throw new Zend_Exception('Error in param: communityDao should be a CommunityDao.');
     }
     Zend_Registry::get('notifier')->callback('CALLBACK_CORE_COMMUNITY_DELETED', array('community' => $communityDao));
     $group_model = MidasLoader::loadModel('Group');
     $groups = $group_model->findByCommunity($communityDao);
     foreach ($groups as $group) {
         $group_model->delete($group);
     }
     $folder_model = MidasLoader::loadModel('Folder');
     $folder = $communityDao->getFolder();
     $folder_model->delete($folder);
     $feed_model = MidasLoader::loadModel('Feed');
     $feeds = $communityDao->getFeeds();
     foreach ($feeds as $feed) {
         $feed_model->delete($feed);
     }
     $ciModel = MidasLoader::loadModel('CommunityInvitation');
     $invitations = $communityDao->getInvitations();
     foreach ($invitations as $invitation) {
         $ciModel->delete($invitation);
     }
     parent::delete($communityDao);
     unset($communityDao->community_id);
     $communityDao->saved = false;
 }
Ejemplo n.º 22
0
 /**
  * delete
  *
  * @param mixed $id ページID
  * @param boolean $cascade Set to true to delete records that depend on this record
  * @return boolean True on success
  */
 public function delete($id = null, $cascade = true)
 {
     // メッセージ用にデータを取得
     $page = $this->read(null, $id);
     /* 削除処理 */
     if (parent::delete($id, $cascade)) {
         // ページテンプレートを削除
         $this->delFile($page);
         // 公開状態だった場合、サイトマップのキャッシュを削除
         // 公開期間のチェックは行わず確実に削除
         if ($page['Page']['status']) {
             clearViewCache();
         }
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 23
0
 /**
  * Remove the current node from the tree, and reparent all children up one level.
  *
  * If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
  * after the children are reparented.
  *
  * @param AppModel $model
  * @param mixed $id The ID of the record to remove
  * @param boolean $delete whether to delete the node after reparenting children (if any)
  * @return boolean true on success, false on failure
  * @access public
  */
 function removefromtree(&$model, $id = null, $delete = false)
 {
     if (empty($id)) {
         $id = $model->id;
     }
     extract($this->settings[$model->alias]);
     list($node) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $id), 'fields' => array($model->primaryKey, $left, $right, $parent), 'recursive' => -1)));
     if ($node[$right] == $node[$left] + 1) {
         if ($delete) {
             $model->delete();
         } else {
             return false;
         }
     } elseif ($node[$parent]) {
         list($parentNode) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $node[$parent]), 'fields' => array($model->primaryKey, $left, $right), 'recursive' => -1)));
     } else {
         $parentNode[$right] = $node[$right] + 1;
     }
     $model->updateAll(array($parent => $node[$parent]), array($parent => $node[$model->primaryKey]));
     $this->__sync($model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
     $this->__sync($model, 2, '-', '> ' . $node[$right]);
     $model->id = $id;
     if ($delete) {
         $model->updateAll(array($model->escapeField($left) => null, $model->escapeField($right) => null, $model->escapeField($parent) => null), array($model->escapeField() => $id));
         return $model->delete($id);
     } else {
         $edge = $this->__getMax($model, $scope, $right);
         if ($node[$right] == $edge) {
             $edge = $edge - 2;
         }
         $model->id = $id;
         return $model->save(array($left => $edge + 1, $right => $edge + 2, $parent => null));
     }
 }
 /** delete */
 public function delete($dao)
 {
     parent::delete($dao);
 }
Ejemplo n.º 25
0
 /**
  * Deletes a user and all record of their existence, including:
  * -Community invitations
  * -Policies (folder, item, and feed)
  * -User's folder tree
  * -Group memberships
  * -Itemrevision upload records (replace with superadmin)
  * -Feeds
  * Issues the CALLBACK_CORE_USER_DELETED signal that modules can use to handle user deletion events,
  * passing the argument 'userDao'. Signal is emitted before any core data is deleted.
  */
 public function delete($user)
 {
     Zend_Registry::get('notifier')->callback('CALLBACK_CORE_USER_DELETED', array('userDao' => $user));
     // Delete any community invitations for this user
     /** @var CommunityInvitationModel $ciModel */
     $ciModel = MidasLoader::loadModel('CommunityInvitation');
     $invitations = $user->getInvitations();
     foreach ($invitations as $invitation) {
         // Must call removeInvitation instead of delete so the corresponding feed is also deleted
         $ciModel->removeInvitation($invitation->getCommunity(), $user);
     }
     // Delete this user's folder tree recursively
     /** @var FolderModel $folderModel */
     $folderModel = MidasLoader::loadModel('Folder');
     $folderModel->delete($user->getFolder());
     // Delete remaining folder policies for the user
     /** @var FolderpolicyuserModel $folderpolicyuserModel */
     $folderpolicyuserModel = MidasLoader::loadModel('Folderpolicyuser');
     $folderpolicies = $user->getFolderpolicyuser();
     foreach ($folderpolicies as $folderpolicy) {
         $folderpolicyuserModel->delete($folderpolicy);
     }
     // Delete remaining item policies for the user
     /** @var ItempolicyuserModel $itempolicyuserModel */
     $itempolicyuserModel = MidasLoader::loadModel('Itempolicyuser');
     $itempolicies = $user->getItempolicyuser();
     foreach ($itempolicies as $itempolicy) {
         $itempolicyuserModel->delete($itempolicy);
     }
     // Delete all user's feeds
     /** @var FeedModel $feedModel */
     $feedModel = MidasLoader::loadModel('Feed');
     $feeds = $user->getFeeds();
     foreach ($feeds as $feed) {
         $feedModel->delete($feed);
     }
     // Delete remaining feed policies for the user
     /** @var FeedpolicyuserModel $feedpolicyuserModel */
     $feedpolicyuserModel = MidasLoader::loadModel('Feedpolicyuser');
     $feedpolicies = $user->getFeedpolicyuser();
     foreach ($feedpolicies as $feedpolicy) {
         $feedpolicyuserModel->delete($feedpolicy);
     }
     // Remove the user from all groups
     /** @var GroupModel $groupModel */
     $groupModel = MidasLoader::loadModel('Group');
     $groups = $user->getGroups();
     foreach ($groups as $group) {
         $groupModel->removeUser($group, $user);
     }
     // Remove references to this user as the uploader of item revisions (replace with superadmin)
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $adminId = $settingModel->getValueByName('adminuser');
     /** @var ItemRevisionModel $itemRevisionModel */
     $itemRevisionModel = MidasLoader::loadModel('ItemRevision');
     $itemRevisions = $user->getItemrevisions();
     foreach ($itemRevisions as $revision) {
         $revision->setUserId($adminId);
         $itemRevisionModel->save($revision);
     }
     // Delete the user record
     parent::delete($user);
 }
Ejemplo n.º 26
0
function sess_gc($lifetime)
{
    $Session = new AppModel('Session');
    $Session->delete(array('updated_at < ' => date('Y-m-d H:i:s', time() - $lifetime)));
    return TRUE;
}
Ejemplo n.º 27
0
 public function delete($id = null, $cascade = true)
 {
     $this->request = array('uri' => array('host' => 'api.cosm.com', 'path' => 'v2/feeds/' . $id . '.json'), 'header' => array('X-ApiKey' => Configure::read('cosm.apikey')));
     return parent::delete($id, $cascade);
 }
Ejemplo n.º 28
0
 /**
  * Remove the current node from the tree, and reparent all children up one level.
  *
  * If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
  * after the children are reparented.
  *
  * @param AppModel $Model Model instance
  * @param mixed $id The ID of the record to remove
  * @param boolean $delete whether to delete the node after reparenting children (if any)
  * @return boolean true on success, false on failure
  * @access public
  * @link http://book.cakephp.org/view/1354/removeFromTree
  */
 function removefromtree(&$Model, $id = null, $delete = false)
 {
     if (is_array($id)) {
         extract(array_merge(array('id' => null), $id));
     }
     extract($this->settings[$Model->alias]);
     list($node) = array_values($Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $id), 'fields' => array($Model->primaryKey, $left, $right, $parent), 'recursive' => $recursive)));
     if ($node[$right] == $node[$left] + 1) {
         if ($delete) {
             return $Model->delete($id);
         } else {
             $Model->id = $id;
             return $Model->saveField($parent, null);
         }
     } elseif ($node[$parent]) {
         list($parentNode) = array_values($Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $node[$parent]), 'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive)));
     } else {
         $parentNode[$right] = $node[$right] + 1;
     }
     $db =& ConnectionManager::getDataSource($Model->useDbConfig);
     $Model->updateAll(array($parent => $db->value($node[$parent], $parent)), array($parent => $node[$Model->primaryKey]));
     $this->__sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
     $this->__sync($Model, 2, '-', '> ' . $node[$right]);
     $Model->id = $id;
     if ($delete) {
         $Model->updateAll(array($Model->escapeField($left) => 0, $Model->escapeField($right) => 0, $Model->escapeField($parent) => null), array($Model->escapeField() => $id));
         return $Model->delete($id);
     } else {
         $edge = $this->__getMax($Model, $scope, $right, $recursive);
         if ($node[$right] == $edge) {
             $edge = $edge - 2;
         }
         $Model->id = $id;
         return $Model->save(array($left => $edge + 1, $right => $edge + 2, $parent => null), array('callbacks' => false));
     }
 }
Ejemplo n.º 29
0
 /** Delete a group */
 public function delete($group)
 {
     if (!$group instanceof GroupDao) {
         throw new Zend_Exception('Should be a group.');
     }
     $users = $group->getUsers();
     foreach ($users as $user) {
         $this->removeUser($group, $user);
     }
     /** @var FeedpolicygroupModel $feedpolicygroupModel */
     $feedpolicygroupModel = MidasLoader::loadModel('Feedpolicygroup');
     $feedpolicygroupModel->deleteGroupPolicies($group);
     /** @var ItempolicygroupModel $itempolicygroupModel */
     $itempolicygroupModel = MidasLoader::loadModel('Itempolicygroup');
     $itempolicygroupModel->deleteGroupPolicies($group);
     /** @var FolderpolicygroupModel $folderpolicygroupModel */
     $folderpolicygroupModel = MidasLoader::loadModel('Folderpolicygroup');
     $folderpolicygroupModel->deleteGroupPolicies($group);
     /** @var NewUserInvitationModel $newUserInvitationModel */
     $newUserInvitationModel = MidasLoader::loadModel('NewUserInvitation');
     $newUserInvitationModel->deleteByGroup($group);
     parent::delete($group);
     unset($group->group_id);
     $group->saved = false;
 }