Ejemplo n.º 1
0
 public function onSetAnswer(FrontController $sender, Statement $st)
 {
     $users = $st->getSubscribers();
     if ($users) {
         require_once ST_DIR . '/Classes/Mailer.php';
         $mailer = new Mailer();
         $vars = array('answer' => strip_tags($st->getAnswer()), 'st_link' => FrontController::getURLByRoute('view', array('id' => $st->getId()), true), 'title' => $st->getTitle(), 'status' => $st->getStatusName());
         foreach ($users as $user) {
             $vars['username'] = $user->name;
             $vars['unSubscribeLink'] = $this->_getSubscribeLink($user->email, $user->user_id, $st->getId());
             $mailer->sendMail('SubscribeStatementSetAnswer', $user->email, $vars);
         }
     }
 }
Ejemplo n.º 2
0
 public function renderStatement(Statement $st, $template)
 {
     $vars = array('id' => $st->getId(), 'st-url' => FrontController::getURLByRoute('view', array('id' => $st->getId())), 'title' => $st->getTitle(), 'teaser' => $st->getTeaser(), 'text' => $st->getText(), 'username' => $st->getUsername(), 'answer' => nl2br($st->getAnswer()), 'answer_name' => $st->getAnswerName(), 'plus_count' => $st->getPlusCount(), 'minus_count' => $st->getMinusCount(), 'comm_num' => $st->getCommNum(), 'status' => t($st->getStatusName()), 'status_icon' => $st->getStatus(), 'date' => date('j.m.Y H:i', $st->getDate()), 'category' => $st->getCategoryName(), 'rate' => $st->getPlusCount() - $st->getMinusCount(), 'comments' => $st->getComments(), 'new_comments' => $st->getNewComment(), 'type' => t($st->getTypeName()), 'type_icon' => $st->getType(), 'edit_link' => FrontController::getURLByRoute('editStatement', array('id' => $st->getId())));
     $blocks = array();
     if ($st->getIsset()) {
         $blocks['isset'] = true;
     }
     if ($st->getAnswerId()) {
         $blocks['answer'] = true;
     }
     if (in_array($this->_user->user_group, FrontController::$config['moder_groups']) || in_array($this->_user->user_id, FrontController::$config['moders'])) {
         $blocks['moder'] = true;
     }
     return $this->render($template, $vars, $blocks);
 }
Ejemplo n.º 3
0
 /**
  * Delete the reference and push the change to the database
  *
  * @param string $summary summary for the change
  * @throws Exception
  */
 public function deleteAndSave($summary = '')
 {
     $id = $this->statement->getId();
     if ($id === null) {
         throw new Exception('Statement has no Id. Please save the statement first.');
     }
     if ($this->hash !== null) {
         $this->statement->getEntity()->getApi()->removeReferences($id, array($this->hash), $this->statement->getEntity()->getLastRevisionId(), $summary);
     }
     $this->statement->removeReference($this);
 }
Ejemplo n.º 4
0
 public function setStatement(Statement $st)
 {
     $this->_statement = $st;
     $this->_original_data['id'] = $st->getId();
     $this->_original_data['answer'] = $st->getAnswer();
     $this->_original_data['text'] = $this->getParse()->decodeBBCodes($st->getText(), false);
     $this->_original_data['title'] = $st->getTitle();
     $this->_original_data['type'] = $st->getType();
     $this->_original_data['category'] = $st->getCategory();
     $this->_original_data['status'] = $st->getStatus();
 }
Ejemplo n.º 5
0
 public function saveStatement($statement)
 {
     if (!$statement instanceof Statement) {
         $statement = new Statement($statement);
     }
     $requestCfg = array('headers' => array('Content-Type' => 'application/json'), 'content' => json_encode($statement->asVersion($this->version), JSON_UNESCAPED_SLASHES));
     if ($statement->hasAttachmentsWithContent()) {
         $this->_buildAttachmentContent($requestCfg, $statement->getAttachments());
     }
     $method = 'POST';
     if ($statement->hasId()) {
         $method = 'PUT';
         $requestCfg['params'] = array('statementId' => $statement->getId());
     }
     $response = $this->sendRequest($method, 'statements', $requestCfg);
     if ($response->success) {
         if (!$statement->hasId()) {
             $parsed_content = json_decode($response->content, true);
             $statement->setId($parsed_content[0]);
         }
         //
         // save statement either returns no content when there is an id
         // or returns the id when there wasn't, either way the caller
         // may have called us with a statement configuration rather than
         // a Statement object, so provide them back the Statement object
         // as the content in either case on success
         //
         $response->content = $statement;
     }
     return $response;
 }
Ejemplo n.º 6
0
 public function onNewComment(FrontController $sender, Comment $comment, Statement $st)
 {
     $vars = array('username' => $comment->getUsername(), 'text' => strip_tags($comment->getText()), 'st_link' => FrontController::getURLByRoute('@view', array('id' => $st->getId()), true), 'title' => $st->getTitle());
     $this->getMailer()->sendMail('newComment', $this->_getModerEmails(), $vars);
 }
Ejemplo n.º 7
0
 protected function _getVars()
 {
     return array('statement_id' => $this->_st->getId());
 }