function show() { $this->setXmlNode('modules', 'module'); $mod = new MessageModule(); if (!$this->input['fid']) { $sort = $mod->fetch(); $info = array(); foreach ($sort as $k => $r) { $info[$r['fid']] = $k; } foreach ($this->settings['message_module_type'] as $k => $v) { if ($info[$k]) { if ($k == 1) { $r = array('id' => $k, "name" => $v, "fid" => 0, "depth" => 0, 'input_k' => '_type', 'attr' => 'attr', 'is_last' => 1); } else { $r = array('id' => $k, "name" => $v, "fid" => 0, "depth" => 0, 'input_k' => '_type', 'attr' => 'attr'); } } else { $r = array('id' => $k, "name" => $v, "fid" => 0, "depth" => 0, 'input_k' => '_type', 'attr' => 'attr', 'is_last' => 1); } $this->addItem($r); } } else { if (intval($this->input['fid']) != 1) { $mod->set('fid=' . intval($this->input['fid'])); $sort = $mod->fetch(); foreach ($sort as $k => $r) { $this->addItem($r); } } } $this->output(); }
public function actionCompose($id = null) { $message = new Message(); if (Yii::app()->request->getPost('Message')) { $receiverName = Yii::app()->request->getPost('receiver'); $message->attributes = Yii::app()->request->getPost('Message'); $message->sender_id = Yii::app()->user->getId(); if ($message->save()) { Yii::app()->user->setFlash('messageModule', MessageModule::t('Message has been sent')); $this->redirect($this->createUrl('inbox/')); } else { if ($message->hasErrors('receiver_id')) { $message->receiver_id = null; $receiverName = ''; } } } else { if ($id) { $receiver = call_user_func(array(call_user_func(array(Yii::app()->getModule('message')->userModel, 'model')), 'findByPk'), $id); if ($receiver) { $receiverName = call_user_func(array($receiver, Yii::app()->getModule('message')->getNameMethod)); $message->receiver_id = $receiver->id; } } } $this->render(Yii::app()->getModule('message')->viewPath . '/compose', array('model' => $message, 'receiverName' => isset($receiverName) ? $receiverName : null)); }
public function actionDelete($id = null) { if (!$id) { $messagesData = Yii::app()->request->getParam('Message'); $counter = 0; if ($messagesData) { foreach ($messagesData as $messageData) { if (isset($messageData['selected'])) { $message = Message::model()->findByPk($messageData['id']); if ($message->deleteByUser(Yii::app()->user->getId())) { $counter++; } } } } if ($counter) { Yii::app()->user->setFlash('messageModule', MessageModule::t('{count} message' . ($counter > 1 ? 's' : '') . ' has been deleted', array('{count}' => $counter))); } $this->redirect(Yii::app()->request->getUrlReferrer()); } else { $message = Message::model()->findByPk($id); if (!$message) { throw new CHttpException(404, MessageModule::t('Message not found')); } $folder = $message->receiver_id == Yii::app()->user->getId() ? 'inbox/' : 'sent/'; if ($message->deleteByUser(Yii::app()->user->getId())) { Yii::app()->user->setFlash('messageModule', MessageModule::t('Message has been deleted')); } $this->redirect($this->createUrl($folder)); } }
public function init() { if (!class_exists($this->userModel)) { throw new Exception(MessageModule::t("Class {userModel} not defined", array('{userModel}' => $this->userModel))); } foreach (array('getNameMethod', 'getSuggestMethod') as $methodName) { if (!$this->{$methodName}) { throw new Exception(MessageModule::t("Property MessageModule::{methodName} not defined", array('{methodName}' => $methodName))); } if (!method_exists($this->userModel, $this->{$methodName})) { throw new Exception(MessageModule::t("Method {userModel}::{methodName} not defined", array('{userModel}' => $this->userModel, '{methodName}' => $this->{$methodName}))); } } // this method is called when the module is being created // you may place code here to customize the module or the application // import the module-level models and components $this->setImport(array('message.models.*', 'message.components.*')); }
public function actionView() { $messageId = (int) Yii::app()->request->getParam('message_id'); $viewedMessage = Message::model()->findByPk($messageId); if (!$viewedMessage) { throw new CHttpException(404, MessageModule::t('Message not found')); } $userId = Yii::app()->user->getId(); if ($viewedMessage->sender_id != $userId && $viewedMessage->receiver_id != $userId) { throw new CHttpException(403, MessageModule::t('You can not view this message')); } if ($viewedMessage->sender_id == $userId && $viewedMessage->deleted_by == Message::DELETED_BY_SENDER || $viewedMessage->receiver_id == $userId && $viewedMessage->deleted_by == Message::DELETED_BY_RECEIVER) { throw new CHttpException(404, MessageModule::t('Message not found')); } $message = new Message(); $isIncomeMessage = $viewedMessage->receiver_id == $userId; if ($isIncomeMessage) { $message->subject = preg_match('/^Re:/', $viewedMessage->subject) ? $viewedMessage->subject : 'Re: ' . $viewedMessage->subject; $message->receiver_id = $viewedMessage->sender_id; } else { $message->receiver_id = $viewedMessage->receiver_id; } if (Yii::app()->request->getPost('Message')) { $message->attributes = Yii::app()->request->getPost('Message'); $message->sender_id = $userId; if ($message->save()) { Yii::app()->user->setFlash('success', MessageModule::t('Message has been sent')); if ($isIncomeMessage) { $this->redirect($this->createUrl('inbox/')); } else { $this->redirect($this->createUrl('sent/')); } } } if ($isIncomeMessage) { $viewedMessage->markAsRead(); } $this->render(Yii::app()->getModule('message')->viewPath . '/view', array('viewedMessage' => $viewedMessage, 'message' => $message)); }
<?php echo $form->error($model, 'subject'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'body'); ?> <?php echo $form->textArea($model, 'body'); ?> <?php echo $form->error($model, 'body'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton(MessageModule::t("Send")); ?> </div> <?php $this->endWidget(); ?> </div> <?php $this->renderPartial(Yii::app()->getModule('message')->viewPath . '/_suggest');
<div class="row"> <?php echo $form->labelEx($model, Yii::t('messages', 'Message')); ?> <?php echo $form->textArea($model, 'body', array('class' => 'txtarea')); ?> <?php echo $form->error($model, 'body'); ?> </div> <div style="margin:10px 0 0 0px"> <?php echo CHtml::submitButton(MessageModule::t("Send"), array('class' => 'formbut')); ?> </div> <?php $this->endWidget(); ?> </div> <?php $this->renderPartial(Yii::app()->getModule('message')->viewPath . '/_suggest'); ?> </div> </div></td>
<?php echo $form->textField($message, 'subject'); ?> <?php echo $form->error($message, 'subject'); ?> </div> <div class="row"> <?php echo $form->labelEx($message, 'body'); ?> <?php echo $form->textArea($message, 'body'); ?> <?php echo $form->error($message, 'body'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton(MessageModule::t("Reply")); ?> </div> <?php $this->endWidget(); ?> </div>
</td> <td><a href="<?php echo $this->createUrl('view/', array('message_id' => $message->id)); ?> "><?php echo $message->subject; ?> </a></td> <td><span class="date"><?php echo date(Yii::app()->getModule('message')->dateFormat, strtotime($message->created_at)); ?> </span></td> </tr> <?php } ?> </table> <div class="row buttons"> <?php echo CHtml::submitButton(MessageModule::t("Delete Selected")); ?> </div> <?php $this->endWidget(); ?> <?php $this->widget('CLinkPager', array('pages' => $messagesAdapter->getPagination())); }
<?php echo $form->error($message, 'subject'); ?> </div> <?php echo $form->labelEx($message, 'body'); ?> <div class="input"> <?php echo $form->textArea($message, 'body'); ?> <?php echo $form->error($message, 'body'); ?> </div> <div class="buttons"> <button class="btn primary"><?php echo MessageModule::t("Reply"); ?> </button> </div> <?php $this->endWidget(); ?> </div> </div> </div>
</div> <?php echo $form->labelEx($model, 'body'); ?> <div class="input"> <?php echo $form->textArea($model, 'body'); ?> <?php echo $form->error($model, 'body'); ?> </div> <div class="buttons"> <button class="btn primary"><?php echo MessageModule::t("Send"); ?> </button> </div> <?php $this->endWidget(); ?> </div> </div> </div> <?php $this->renderPartial(Yii::app()->getModule('message')->viewPath . '/_suggest');
echo $message->subject; ?> </a></td> <td><span class="date"><?php echo date(Yii::app()->getModule('message')->dateFormat, strtotime($message->created_at)); ?> </span></td> </tr> <?php } ?> </table> <div> <button class="btn danger"><?php echo MessageModule::t("Delete Selected"); ?> </button> </div> <?php $this->endWidget(); ?> <div class="pagination"> <?php $this->widget('CLinkPager', array('header' => '', 'pages' => $messagesAdapter->getPagination(), 'htmlOptions' => array('class' => 'pager'))); ?> </div> <?php } ?>
public function getAccessMessage() { if (Yii::app()->user->message) { return true; } else { throw new CHttpException(401, MessageModule::t('ACCESS_DENIED_USER')); } }
<?php echo $form->labelEx($message, 'body'); ?> <div class="input"> <?php echo $form->textArea($message, 'body'); ?> <?php echo $form->error($message, 'body'); ?> </div> <div class="buttons"> <button class="btn btn-primary"><i class="icon-white icon-repeat"></i> <?php echo MessageModule::t("Reply"); ?> </button> <button class="btn btn-danger"><i class="icon-white icon-remove"></i> <?php echo MessageModule::t("Delete"); ?> </button> </div> <?php $this->endWidget(); ?> </div> </div> </div>
function messageDispatch($op, $mvc = false) { if (isset($_POST['undo'])) { $op = 'message'; } if (isset($_POST['okselector'])) { $op = 'writemessage'; } if (isset($_POST['cancelselector'])) { $op = 'message'; } if (isset($_POST['back_recipients'])) { $op = 'addmessage'; } $module = new MessageModule($mvc); switch ($op) { case "message": $module->message(); break; case "addmessage": $module->addmessage(); break; case "writemessage": $module->writemessage(); break; case "delmessage": $module->delmessage(); break; case "readmessage": $module->readmessage(); break; case "download": $module->download(); break; } }
if ($my_fr->addFriend($id_friend, MF_WAITING, $message_request)) { $value = array('re' => true); } else { $value = array('re' => false); } require_once _base_ . '/lib/lib.json.php'; $json = new Services_JSON(); $output = $json->encode($value); aout($output); break; case "send_message": require_once $GLOBALS['where_framework'] . '/lib/lib.message.php'; $module_name = importVar('module_name'); $platform = importVar('platform'); $recipient = importVar('send_to'); $message_subject = importVar('message_subject'); $message_text = importVar('message_text'); $lang =& DoceboLanguage::createInstance('standard', 'framework'); $lang->setGlobal(); $lang =& DoceboLanguage::createInstance($module_name, $platform); if (MessageModule::quickSendMessage(getLogUserId(), $recipient, $message_subject, $message_text)) { $value = array('re' => true); } else { $value = array('re' => false); } require_once _base_ . '/lib/lib.json.php'; $json = new Services_JSON(); $output = $json->encode($value); aout($output); break; }