CakePHP Yöntem AT ALL Süreci Veri Will Not

0 Cevap php

Aşağıda benim kod hiç işlemez bir sorun var. Bu kaydetmek veya silmek olmaz. Ben bir başarı mesajı almak ama hiçbir şey kazandıracak ne de başka bir şey silecektir. Ben yöntem ayrılmış bir anahtar kelime olduğunu düşündüm ama sonra yeniden adlandırmak ve hala işe yaramadı çalıştı. Bu beni şaşkına gibi herhangi bir fikir derece mutluluk duyacağız.

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());
    }
}

0 Cevap