/** * undocumented function * * @param string $id * @return void * @access public */ function admin_delete($id) { $filter = $this->Filter->find('first', array('conditions' => array('Filter.id' => $id), 'contain' => false, 'fields' => array('id', 'user_id'))); Assert::notEmpty($filter, '404'); Assert::true(AppModel::isOwn($filter, 'Filter'), '403'); $this->Filter->del($id); $msg = __('Filter deleted.', true); $this->Message->add($msg, 'ok', true, $this->referer()); }
/** * undocumented function * * @param string $comment * @return void * @access public */ static function isOwn($comment) { $isAuthor = $comment['Comment']['user_id'] == User::get('id'); $isOwned = false; if (!$isAuthor) { $models = $this->belongsTo; foreach ($models as $model => $data) { $row = $this->{$model}->find('first', array('conditions' => array($model . '.id' => $comment['Comment']['foreign_id']))); if (!empty($row) && AppModel::isOwn($row, $model)) { $isOwned = true; break; } } Assert::true($isOwned, '403'); } return true; }
/** * undocumented function * * @param string $segmentId * @param string $foreignId * @return void * @access public */ function admin_delete_item($segmentId, $foreignId) { $segment = $this->Segment->find('first', array('conditions' => array('id' => $segmentId), 'fields' => array('user_id'))); Assert::notEmpty($segment); Assert::true(AppModel::isOwn($segment, 'Segment'), '403'); $this->SegmentItem->deleteAll(array('segment_id' => $segmentId, 'foreign_id' => $foreignId)); $msg = 'The item was successfully removed from segment.'; $this->Message->add($msg, 'ok', true, $this->referer()); }