/** * The message loader. It loads a message from his identifier. * * @access public * @param integer $msg_id the message identifier. * @return The Message object or false if something wrong. * @since 0.6 * @see Message */ function loadMessage($msg_id) { jincimport('utility.servicelocator'); $servicelocator = ServiceLocator::getInstance(); $logger = $servicelocator->getLogger(); $query = 'SELECT m.id, m.body, m.subject, m.plaintext, ' . 'm.attachment, m.bulkmail, m.news_id, m.tem_id ' . 'FROM #__jinc_message m ' . 'LEFT JOIN #__jinc_newsletter n ON m.news_id = n.id ' . 'WHERE m.id = ' . (int) $msg_id; $logger->debug('MessageFactory: Executing query: ' . $query); $dbo = JFactory::getDBO(); $dbo->setQuery($query); // Loading message information from database if ($result = $dbo->loadAssocList()) { $message = $result[0]; } else { return false; } // Choosing message type to return if ($message['bulkmail']) { $logger->finer('MessageFactory: Bulk Message Building'); $msgObj = new BulkMessage($msg_id); } else { $logger->finer('MessageFactory: Personal Message Building'); $msgObj = new PersonalMessage($msg_id); } // Setting message properties $attachments = new JRegistry(''); $attachments->loadString($message['attachment']); $msgObj->set('attachment', $attachments); $msgObj->set('body', $message['body']); $msgObj->set('plaintext', $message['plaintext']); $msgObj->set('subject', $message['subject']); $msgObj->set('news_id', $message['news_id']); $msgObj->set('tem_id', $message['tem_id']); return $msgObj; }
/** * View thread * @param int $id userid */ public function actionView($id) { $dataProvider = new CActiveDataProvider('PersonalMessage', array('criteria' => array('scopes' => array('byInterlocutorId' => $id), 'order' => 'id DESC'))); $message = new PersonalMessage(); $message->recipient_id = $id; if (isset($_POST['PersonalMessage'])) { $message->attributes = $_POST['PersonalMessage']; $message->sender_id = $this->_userId; $message->recipient_id = $id; $lastMessage = PersonalMessage::model()->byInterlocutorId($id)->find(); if ($lastMessage !== null && $lastMessage->thread_id != 0) { $message->thread_id = $lastMessage->thread_id; } if ($message->save()) { if ($message->thread_id == 0) { $message->thread_id = $message->id; $message->save(false, array('thread_id')); } $this->refresh(); } } $this->render('view', array('dataProvider' => $dataProvider, 'message' => $message)); }
$json .= '"grade":' . json_encode($v->grado) . ','; $json .= '"date":' . json_encode($v->data) . ','; $json .= '"hour":' . json_encode($v->ora) . ','; $json .= '"bio":' . json_encode($v->bio) . ','; $json .= '"avatar":' . json_encode($v->avatar); $json .= '},'; } echo trim($json, ',') . ']}'; } } elseif ($action == 'countuser') { echo '{"response":' . json_encode($user->countUser()) . '}'; } elseif ($action == 'countaccess') { echo '{"response":' . json_encode($user->config[0]->totalevisitatori) . '}'; } elseif ($action == 'countpm') { require_once 'core/class.PersonalMessage.php'; $pm = new PersonalMessage(); echo '{"response":' . json_encode($pm->countPM()) . '}'; } elseif ($action == 'registration' && $nickname !== '' && $password !== '' && $email !== '') { if ($user->isLogged()) { echo '{"response":"2"}'; } if (strlen($password) > 4 || strlen($nickname) > 4) { if ($user->config[0]->validazioneaccount == 1) { $codice = $user->getCode(); // Validazione account $array = array($nickname, $password, $email, 6, date('d-m-y'), date('G:m:s'), $codice, $user->config[0]->skin); if ($user->createUser($array)) { $user->sendMail($email, $user->config[0]->nomesito . ' @ Validazione account per ' . $nickname . '.', 'Ciao ' . $nickname . ', dal momento che ti sei registrato, il sistema ha bisogno di essere sicuro che la tua email sia valida. Per validarla ti basta cliccare il seguente link: ' . $user->config[0]->url_index . '/registrazione.php?codice=' . $codice . '
public function deleteAd($minititolo) { return parent::query("DELETE FROM {$this->prefix}annunci WHERE minititolo='{$minititolo}'") ? true : false; }
/** * Delete message * * @param int $id message ID */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { $model = PersonalMessage::model()->haveAccess($this->_userId)->findByPk($id); if ($model !== null) { $this->_userId == $model->sender_id ? $model->ds = 1 : ($model->dr = 1); if (Yii::app()->getModule('pm')->reallyDelete && $model->ds && $model->dr) { $model->delete(); } else { $model->save(false, array('dr', 'ds')); } if (!isset($_GET['ajax'])) { Yii::app()->user->setFlash('success', PmModule::t('Message has been succsefully deleted.')); $this->redirect(array('/pm/default/listincoming')); } } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }