Example #1
0
 /**
  * Get the dialog id
  * @param int $user_one
  * @return null|\Modules\User\Models\Dialog
  */
 public function getDialogId($user_one)
 {
     $sql = 'SELECT c_id
             FROM [prefix]_users_dialog
             WHERE user_one=' . $user_one . ' 
             ORDER BY c_id DESC limit 1';
     $row = $this->db()->queryRow($sql);
     if (empty($row)) {
         return null;
     }
     $dialogModel = new DialogModel();
     $dialogModel->setCId($row['c_id']);
     return $dialogModel;
 }
Example #2
0
 public function dialogviewAction()
 {
     $DialogMapper = new DialogMapper();
     $ilchdate = new IlchDate();
     $c_id = $this->getRequest()->getParam('id');
     $user = $DialogMapper->getDialogCheckByCId($c_id);
     if ($this->getUser()->getId() != $user->getUserTwo()) {
         $user_two = $user->getUserOne();
     } else {
         $user_two = $user->getUserTwo();
     }
     if ($this->getUser()->getId() == $user_two) {
         if ($this->getRequest()->isPost()) {
             $u_id_fk = $this->getUser()->getId();
             $text = trim($this->getRequest()->getPost('text'));
             $model = new DialogModel();
             $model->setCId($c_id);
             $model->setId($u_id_fk);
             $model->setTime($ilchdate->toDb());
             $model->setText($text);
             $DialogMapper->save($model);
             $this->redirect(array('action' => 'dialogview', 'id' => $c_id));
         }
         $this->getView()->set('inbox', $DialogMapper->getDialogMessage($c_id));
     } else {
         $this->redirect(array('action' => 'dialog'));
     }
 }