У меня проблема, мой код ниже не будет обрабатываться вообще. Это не будет сохранять или удалять. Я получаю сообщение об успехе, но ничего не спасет и не удалит ничего. Я думал, что метод был зарезервированным ключевым словом, но затем я попытался переименовать его, но он все еще не работал. Любое понимание было бы чрезвычайно оценено, поскольку это поставило меня в тупик.
function approve() {
$this->set('title', 'Approve Article');
if ($this->RequestHandler->isPost() || $this->RequestHandler->isPut()) {
if (empty($this->data['Article']['id'])) {
$this->Session->setFlash('No article was passed.', 'message_error');
} else {
$this->Article->set($this->data);
if ($this->Article->validates()) {
if ($this->data['Article']['approved']) {
$this->data['Article']['content'] = $this->Safe->filter($this->data['Article']['content']);
$role = $this->Auth->user('role');
if ($role == 'Admin')
$this->Article->set('updated', strtotime($this->data['Article']['updated']));
else
$this->Article->set('updated', time());
$this->Article->set('updated', time());
$this->Article->save();
// Status
$status['Status']['type'] = 'Gain';
$status['Status']['amount'] = 20;
$status['Status']['created'] = time();
$this->Status->add($this->data['Article']['account_id'], $status);
$this->Session->setFlash('The article was approved and status was added.', 'message_success');
} else {
$this->Article->delete($this->data['Article']['id']);
$this->Session->setFlash('The article was unapproved and deleted.', 'message_error');
}
} else {
$this->Session->setFlash('Form Errors', 'message_error');
}
}
}
$unapproved_articles = $this->Article->find('count', array('conditions' => array('Article.approved =' => 0)));
if ($unapproved_articles == 0) {
$this->Session->setFlash('There are no unapproved articles.', 'message_success');
} else {
$article = $this->Article->find('first', array('order' => array('Article.created DESC')));
$article['Article']['updated'] = date('d M Y', $article['Article']['updated']);
$this->set('article', $article);
$this->set('categories', $this->Category->dropdown());
$this->set('accounts', $this->Account->dropdown());
}
}