Exemplo n.º 1
0
 /** Receives the form submission from the new action and creates the new object. */
 public function actionCreate()
 {
     // create a new message
     $messages = new Messages();
     $name = $messages->generateNewName($this->request->getPost());
     if (empty($name)) {
         $this->flashFail = 'The message cannot be blank';
         $this->redirectTo('topics/new');
     }
     $stamp = date("Y-m-d H:i:s", mktime());
     $save['name'] = $this->userRow['name'];
     // create new topic
     $save['name'] = $this->request->getPost('name');
     $save['created_at'] = $save['updated_at'] = $stamp;
     $save['created_by'] = $this->userRow['name'];
     $save['is_archived'] = 0;
     $topicId = $this->topics->save($save);
     // create new message... read by us
     $newId = $messages->save(array('topics_id' => $topicId, 'created_at' => $stamp, 'name' => $name, 'user' => $this->userRow['name'], 'read_by' => "!{$this->userRow['id']}!"));
     // create new mailer
     //$mailer = new Mailer();
     // save the text
     $nodes = new Nodes();
     $nodes->saveMessage(0, $this->request->getPost(0), $topicId, $newId, $this->userRow['name'], $mailer);
     // send email to all recipients
     //$users = new Users();
     //foreach ($users->select('email')->findAll() as $user) $recipients[] = $user['email'];
     //$mailer->sendMessage($recipients, $newId, $topicId, $this->topics);
     // redirect to the new message
     $this->redirectTo("messages/show/{$topicId}/{$newId}");
 }