public function addAction() { $success = false; $errors = array(); if (!self::$_install && $this->request->data) { Model::connection()->read(self::$_sql); if (!($success = UsersController::addUser($this->request->data['user'], $this->request->data['password'], $errors))) { $errors['User'] = "******"; } if ($success && !($success = PostsController::addPost("Post example", self::$_lorem, $errors))) { $errors['Post'] = "Post can't be created."; } if ($success) { self::$_install = true; } } return compact('success', 'errors'); }
public function addAction() { $success = false; $details = array(); if (!$this->request->is('post')) { $details['call'] = 'This action can only be called with post'; } else { if ($this->request->data) { if (!isset($this->request->data['id']) || !PostsController::postExist($this->request->data['id'])) { $details['post'] = 'This post doesn\'t exist'; } else { $captcha = isset($this->request->data['captcha']) ? $this->request->data['captcha'] : ""; if (CaptchasController::check($captcha, $details)) { $name = isset($this->request->data['name']) ? $this->request->data['name'] : ""; $email = isset($this->request->data['email']) ? $this->request->data['email'] : ""; $website = isset($this->request->data['website']) ? $this->request->data['website'] : ""; $body = isset($this->request->data['body']) ? $this->request->data['body'] : ""; $id = $this->request->data['id']; if ($success = self::addComment($name, $email, $website, $body, $id, $details)) { $details['_desc'] = "Your comment has been posted."; } } } } } if ($success == false) { $details['_title'] = "Comment can't be created."; } return compact('success', 'details'); }