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 actionIndex() { $shop_id = Yii::app()->request->getParam('shop_id'); if (!$shop_id) { Error::output(Error::ERR_NO_SHOPID); } //获取该店的留言 $criteria = new CDbCriteria(); $criteria->order = 't.order_id DESC'; $criteria->condition = 't.shop_id=:shop_id AND t.status=:status'; $criteria->params = array(':shop_id' => $shop_id, ':status' => 1); $messageMode = Message::model()->with('members', 'shops', 'replys')->findAll($criteria); $message = array(); foreach ($messageMode as $k => $v) { $message[$k] = $v->attributes; $message[$k]['shop_name'] = $v->shops->name; $message[$k]['user_name'] = $v->members->name; $message[$k]['create_time'] = date('Y-m-d H:i:s', $v->create_time); $message[$k]['status_text'] = Yii::app()->params['message_status'][$v->status]; $message[$k]['status_color'] = Yii::app()->params['status_color'][$v->status]; $_replys = Reply::model()->with('members')->findAll(array('condition' => 'message_id=:message_id', 'params' => array(':message_id' => $v->id))); if (!empty($_replys)) { foreach ($_replys as $kk => $vv) { $message[$k]['replys'][$kk] = $vv->attributes; $message[$k]['replys'][$kk]['create_time'] = date('Y-m-d H:i:s', $vv->create_time); $message[$k]['replys'][$kk]['user_name'] = $vv->user_id == -1 ? '前台妹子说' : $vv->members->name; } } } Out::jsonOutput($message); }
public function actionIndex() { $id = $_REQUEST['id']; $this->data['cur_moduleid'] = $id; $module = Yii::app()->cache->get("module_" . $id); if ($module == false) { $module = $this->connection->createCommand("select * from xm_module where module_id = " . $id)->queryRow(); Yii::app()->cache->set("module_" . $id, $module); } $this->data['module'] = $module; /*右侧导航栏*/ $topid = $this->getTopIdFromIDEN($module['iden']); $modulequeue = Yii::app()->cache->get("modulequeue_" . $topid); if ($modulequeue == false) { $modulequeue = $this->getQueueModulesById($topid); Yii::app()->cache->set("modulequeue_" . $topid, $modulequeue); } $this->data['modulequeue'] = $modulequeue; $criteria = new CDbCriteria(); $criteria->addCondition('module_id=' . $id, 'AND'); $criteria->order = "createtime desc"; $count = Message::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $articles = Message::model()->findAll($criteria); $this->data['pages'] = $pager; $this->data['list'] = $articles; Yii::app()->params['TITLE'] = $module['category']; Yii::app()->params['APPKEYWORDS'] = $module['category']; Yii::app()->params['APPDESCRIPTION'] = $module['category']; $this->render('index', $this->data); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id, $category, $language = '') { $this->model = new Text(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($this->model); $this->model = Text::model()->find(array('join' => 'LEFT JOIN Message as m ON m.id = t.id', 'select' => 't.id, m.id as messageid, t.category, t.message, m.language, m.translation as translation', 'condition' => 't.id = ' . $id)); $this->model->category = $category; $this->model->language = $language; if (!$this->model->language) { $this->model->language = 'en'; } //$this->model->id = $id; //$this->model = $this->model->search(); if (isset($_POST['Text'])) { if (!$this->model->messageid) { $model = new Message(); } else { $model = Message::model()->find(array('condition' => 't.id = ' . $this->model->messageid . " AND language = '" . $this->model->language . "'")); } $model->attributes = $_POST['Text']; if ($model->save()) { $this->redirect(array('admin')); } } $this->render('create', array('model' => $this->model)); }
public function actionMessage_view() { $id = $_GET['id']; $message = Message::model()->findByPk($id); $this->data['message'] = $message; $this->render('message_view', $this->data); }
/** * $userId2发给$userId1而$userId1未读的私信,如果userId2为0,即返回$userId1所有未读的私信 * Enter description here ... * @param unknown_type $userId1 * @param unknown_type $userId2 */ public function countUnchecked($userId1, $userId2 = 0) { if ($userId2) { return Message::model()->count(array('condition' => 'isChecked=0 and toUserId=:userId1 and fromUserId=:userId2', 'params' => array(':userId1' => $userId1, ':userId2' => $userId2))); } else { return Message::model()->count(array('condition' => 'isCHecked=0 and toUserId=:userId', 'params' => array(':userId' => $userId1))); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Message the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Message::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function loadMessage($lang = null) { if (null == $lang) { $lang = Yii::app()->getLanguage(); } $message = Message::model()->findByPk(array('id' => $this->id, 'language' => $lang)); return null === $message ? new Message() : $message; }
public function actionReadMessage() { if (!($id = Yii::app()->request->getPost('id'))) { throw new CHttpException(400, 'Bad request.'); } if (!($model = Message::model()->findByPk($id))) { throw new CHttpException(404, 'Not found.'); } $model->markAsRead(Yii::app()->user->id); echo CJSON::encode(array('result' => true)); }
function search() { $criteria = new CDbCriteria(); $criteria->with = array('mt'); $criteria->addCondition('not exists (select `id` from `' . Message::model()->tableName() . '` `m` where `m`.`language`=:lang and `m`.id=`t`.`id`)'); $criteria->compare('t.id', $this->id); $criteria->compare('t.category', $this->category); $criteria->compare('t.message', $this->message); $criteria->params[':lang'] = $this->language; return new CActiveDataProvider(get_class($this), array('criteria' => $criteria)); }
public function run() { if (Yii::app()->user->isGuest) { return; } // выводим только количество новых сообщений для пользователя $messages = Message::model()->new()->countByAttributes(array('id_to' => Yii::app()->user->id)); if ($messages) { echo "({$messages})"; } //$this->render('new_messages', array('messages' => $messages)); }
public function actionIndex() { $criteria = new CDbCriteria(); $count = Message::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $messages = Message::model()->findAll($criteria); $this->data['pages'] = $pager; $this->data['list'] = $messages; $this->render('index', $this->data); }
protected function afterSave() { if (false !== parent::afterSave()) { if ($this->isNewRecord) { // новое сообщение, надо об этом уведомить заинтересованных по longpool $Message = Message::model()->findByPk($this->message_id); Yii::log("MessageReaded afterSave Message=[" . print_r($Message, true) . "]", "info"); $this->notifyInterestedPersonsViaLongPool('read', $Message->model, $Message->model_id, $Message->user_id, $Message->message_id); } return true; } return false; }
public function actionSent() { // auth manager if (!$this->module->authManager && (!$this->module->sentbox || $this->module->readOnly && !$this->module->isAdmin())) { $this->redirect(array('message/inbox')); } $this->module->registerConfig($this->getAction()->getId()); $this->module->getClientScript()->registerScriptFile($this->module->getAssetsUrl() . '/js/jquery.colors.js'); $this->module->getClientScript()->registerScriptFile($this->module->getAssetsUrl() . '/js/mailbox.js', CClientScript::POS_END); if (isset($_POST['convs'])) { $this->buttonAction('sent'); } $dataProvider = new CActiveDataProvider(Message::model()->sent($this->module->getUserId())); $this->render('mailbox', array('dataProvider' => $dataProvider)); }
/** * @return array customized attribute labels (name=>label) */ public function getLast15() { $count = Message::model()->count(); if ($count < 15) { $count = 0; } else { $count -= 15; } $criteria = new CDbCriteria(); $criteria->order = '`time` asc'; $criteria->offset = $count; $criteria->limit = '15'; return Message::model()->findAll($criteria); // new CActiveDataProvider('Message', array( 'criteria' => $criteria )); }
public function actionView($idMessage = 0) { $isAjax = Yii::app()->request->isAjaxRequest; if ($isAjax) { $idMessage = $_POST['idMessage']; } $item = Message::model()->findByPk($idMessage); $alias = ['{name}' => $item->subject]; $this->pageTitle = Yii::t('page-title', 'Views message `{name}`', $alias); if ($isAjax) { $this->layout = '//layouts/modal'; echo json_encode(['html' => $this->render('view', ['item' => $item, 'isAjax' => true], true)]); } else { $this->render('view', ['item' => $item]); } }
/** * Updates a message * @param integer $id */ public function actionUpdate($id) { if (null == $id || !is_numeric($id)) { throw new CHttpException(404, 'The requested page does not exist.'); } $model = Message::model()->findByPk(array('id' => $id, 'language' => Yii::app()->getLanguage())); if (isset($_POST['Message'])) { $resp = array('color' => '#FF6600', 'background_color' => '#FFFFCC', 'position' => 'top', 'removebutton' => 0); $model->attributes = $_POST['Message']; if ($model->save()) { $resp['message'] = Yii::t('translate', 'Message successfully updated'); $resp['id'] = $model->id; } else { $errors = $this->errors($model); $resp['message'] = Yii::t('translate', '<p>Unable to update the message. Something went wrong!<p/>' . implode('<br/>', $errors)); } echo $this->je($resp); } else { throw new CHttpException(400); } }
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)); }
<div class="form"> <?php echo CHtml::beginForm(); ?> <table> <thead> <th><?php echo MessageSource::model()->getAttributeLabel('category'); ?> </th> <th><?php echo MessageSource::model()->getAttributeLabel('message'); ?> </th> <th><?php echo Message::model()->getAttributeLabel('translation'); ?> </th> <?php echo $google ? CHtml::tag('th') : null; ?> </thead> <tbody> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => new CArrayDataProvider($models), 'pager' => array('id' => TranslateModule::translator()->languageKey . '-pager', 'class' => 'CLinkPager'), 'viewData' => array('messages' => $messages, 'google' => $google), 'itemView' => '_form')); ?> </tbody> </table> <?php echo CHtml::submitButton(TranslateModule::t('Translate')); ?>
public function actionIndex() { $helloWorlMessage = Message::model()->findByPK(2); $this->message = $helloWorlMessage->content; $this->render('index', array('content' => $this->message)); }
/** * 微讯列表 */ public function actionInbox() { $model = Message::model()->listMessage(); $this->render('inbox', array('model' => $model)); }
<?php $this->breadcrumbs = array('系统信息'); ?> <?php echo TbHtml::well('概况', array('size' => TbHtml::WELL_SIZE_SMALL)); ?> <p><strong>未读信息</strong></p> <p>留言反馈: <?php echo CHtml::link(Feedback::model()->count(array('condition' => "status='1'")), array('feedback/admin')); ?> 短信息: <?php echo CHtml::link(Message::model()->count(array('condition' => "status='1'")), array('message/index')); ?> </p> <?php echo TbHtml::well('服务器信息', array('size' => TbHtml::WELL_SIZE_SMALL)); ?> <p>系统版本 : <?php echo Fircms::VERSION; ?> </p> <p>操作系统 : <?php echo PHP_OS; ?>
<?php /* list.php Copyright Stefan Fisk 2012. */ /* @var $this CommentController */ $this->pageTitle = CHtml::encode(Yii::t('app', 'Messages')); $this->layout = '//layouts/tabs'; $this->beginWidget('application.widgets.OuterBoxWidget', array('class' => 'messages', 'title' => Yii::t('app', 'Conversations'), 'color' => '#00AEEF')); ?> <ol class="threads"> <?php $lastMessages = Message::model()->findAllBySql(<<<EOD SELECT * FROM ( SELECT *, CASE WHEN sender_id = :user_id THEN recipient_id ELSE sender_id END AS thread_recipient_id FROM ( SELECT * FROM message WHERE sender_id = :user_id OR recipient_id = :user_id ORDER BY creation_time DESC )
public function notifyInterestedPersonsViaLongPool($type, $model, $model_id, $user_id, $message_id, $arrMore = null) { if ('Response' == $model) { if (isset(Yii::app()->params['comet_messages_url_publisher']) && strlen(Yii::app()->params['comet_messages_url_publisher']) > 0) { if ('file' == $type) { if (is_array($arrMore) && isset($arrMore['photo_id']) && $arrMore['photo_id']) { // nothing to do here } else { return; } } // response to/from company , this thread all user_id // user_id message.model .model_id // response .from_company_id .to_company_id .user_id // site_user_user .company_id $Response = Response::model()->findByPk($model_id); // вспомогательный массив для добавления пользователей на оповещение $arrPersons = ['from' => ['id' => $Response->from_company_id, 'count' => 0], 'to' => ['id' => $Response->to_company_id, 'count' => 0]]; $arrUsers = []; $arrUsers[$Response->user_id] = Yii::app()->userManager->tokenStorage->getCometMessagesToken($Response->user_id); $messages = Message::model()->findAllByAttributes(['model' => 'Response', 'model_id' => $model_id]); foreach ($messages as $msg) { if (!isset($arrUsers[$msg->user_id])) { $arrUsers[$msg->user_id] = Yii::app()->userManager->tokenStorage->getCometMessagesToken($msg->user_id); $user_company_id = $msg->user->company_id; if ($user_company_id == $arrPersons['from']['id']) { $arrPersons['from']['count']++; } else { $arrPersons['to']['count']++; } } } // проверить что есть пользователи от обоих компаний, если нет, то надо добавить foreach ($arrPersons as $kp => $kv) { if (0 == $kv['count']) { $Users = User::model()->findAllByAttributes(['company_id' => $kv['id']]); foreach ($Users as $userCheck) { if (!isset($arrUsers[$userCheck->id])) { $arrUsers[$userCheck->id] = Yii::app()->userManager->tokenStorage->getCometMessagesToken($userCheck->id); } } } } if ('message' == $type || 'file' == $type) { // убрать того, кто отправил if (isset($arrUsers[$user_id])) { unset($arrUsers[$user_id]); } } Yii::log("notifyInterestedPersonsViaLongPool arrUsers=[" . print_r($arrUsers, true) . "]", "info"); $arrData = []; if ('message' == $type) { // DB request to get create field data, now is 'NOW()' $curMessage = Message::model()->findByPk($message_id); $User = $curMessage->user; $arrData['last_name'] = $User->last_name; $arrData['first_name'] = $User->first_name; $arrData['create'] = $curMessage->create; $arrData['message'] = $curMessage->message; } $arrData['type'] = $type; $arrData['message_id'] = $message_id; $arrData['model'] = $model; $arrData['model_id'] = $model_id; $arrData['user_id'] = $user_id; if ('file' == $type) { $arrData = array_merge($arrData, $arrMore); } static::sendMessageToLongPool($arrUsers, $arrData); } } }
/** * 女神的消息 * * @param int $user_id * @param int $goddess_id * @param int $token */ public function actionGoddessMess() { // 参数检查 if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['goddess_id'])) { $this->_return('MSG_ERR_LESS_PARAM'); } $now = date("Y-m-d H:i:s"); $user_id = trim(Yii::app()->request->getParam('user_id')); $token = trim(Yii::app()->request->getParam('token')); $goddess_id = trim(Yii::app()->request->getParam('goddess_id')); if (!is_numeric($user_id)) { $this->_return('MSG_ERR_FAIL_PARAM'); } //用户不存在 返回错误 if ($user_id < 1) { $this->_return('MSG_ERR_NO_USER'); } $result = array(); //验证token if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) { $message = Message::model()->noReadGoddessMessList($user_id, $goddess_id); foreach ($message as $v) { //女神的详细信息 $heroineInfo = Goddess::model()->getGoddessInfo($v['heroine_id']); $tem['id'] = $v['m_id']; $tem['type'] = (int) $v['msg_type']; $tem['text'] = $v['msg_text']; $tem['image'] = $v['msg_image']; $tem['url'] = $v['msg_url']; $tem['time'] = $v['create_ts']; $tem['goddess_id'] = $v['heroine_id']; #女神id $tem['goddess_name'] = $heroineInfo['nickname']; #女神名字 $tem['goddess_face'] = $heroineInfo['faceurl']; #头像地址 $result[] = $tem; //将消息内的图片,信息关联 Message::model()->readMess($user_id, $v['m_id']); //更新消息状态为已读 Message::model()->updateMessType($user_id, $v['m_id'], 1); //读消息 $memo = $v['m_id'] . '|' . $v['msg_type']; Log::model()->_goddess_log($user_id, $goddess_id, 'READ_MESSAGE', date('Y-m-d H:i:s'), $memo); } $this->_return('MSG_SUCCESS', $result); } else { //token 错误 $this->_return('MSG_ERR_TOKEN'); } }
/** * Executes any command triggered on the admin page. */ protected function processAdminCommand() { //print_r($_POST);die(); if (isset($_POST['Save'])) { //check that ALL translations are in this translation.. $sources = SourceMessage::model()->findAll(); foreach ($sources as $source) { $existstest = Message::model()->find(array('condition' => 'language=\'' . $_POST['langcode'] . '\' AND id=' . $source->id)); if ($existstest === null) { $trans = new Message(); $trans->id = $source->id; $trans->translation = '-dirty-' . $source->message; $trans->language = $model->language; $trans->save(); } else { if (isset($_POST['Message'][$source->id])) { } } } //do the actual reading of data from the form $messages = Message::model()->findAll(array('condition' => 'language=\'' . $_POST['langcode'] . '\'')); foreach ($messages as $message) { if (isset($_POST['Message'][$message->id])) { $message->attributes = $_POST['Message'][$message->id]; $message->save(); } //delete no longer used posts. if (!isset($message->source)) { $message->delete(); } } } elseif (isset($_POST['Delete'])) { SourceMessage::model()->dbConnection->createCommand("DELETE FROM Message WHERE language='" . $_POST['langcode'] . "'")->execute(); $foundOption = Options::model()->find('name=:name AND userId=:id AND companyId=:compid', array(':name' => "Language.Version." . $_POST['langcode'], ':id' => 0, ':compid' => 0)); if ($foundOption !== null) { $foundOption->delete(); } unset($_POST['langcode']); } elseif (isset($_POST['Export'])) { $dom = new DomDocument(); $dom->encoding = 'utf-8'; $root = $dom->createElement("lazy8webportlang"); $root->setAttribute("version", "1.00"); $language = $dom->createElement("language"); $language->setAttribute("langcode", $_POST['langcode']); $exportLang = Message::model()->with('source')->findAll(array('condition' => "language='" . $_POST['langcode'] . "'", 'together' => true, 'order' => "message")); foreach ($exportLang as $export) { if (isset($export->source)) { $message = $dom->createElement("message"); $message->setAttribute("category", $export->source->category); $message->setAttribute("key", html_entity_decode($export->source->message)); $this->appendTextNode($dom, $message, "translation", $export->translation); $language->appendChild($message); } } $root->appendChild($language); $dom->appendChild($root); $dom->formatOutput = true; $thefile = $dom->saveXML(); // set headers header("Pragma: no-cache"); header("Expires: 0"); header("Content-Description: File Transfer"); header("Content-Type: text/xml"); header("Content-Disposition: attachment; filename=\"lazy8webExport.Language." . $_POST['langcode'] . "." . date('Y-m-d_H.i.s') . ".xml\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . strlen($thefile)); //flush(); print $thefile; return; //we may not send any more to the screen or it will mess up the file we just sent! } elseif (isset($_POST['langcode'])) { $this->editinglanguage = $_POST['langcode']; } }
echo Yii::t('extensions', 'View Extensions'); ?> " class='tooltip'><?php echo CHtml::encode($row->title); ?> </a></td> <td><?php echo CHtml::encode($row->alias); ?> </td> <td><?php echo CHtml::encode($row->description); ?> </td> <td><?php echo Message::model()->getLanguageNames($row->language); ?> </td> <td><?php echo Yii::app()->func->adminYesNoImage($row->readonly, array('extensions/catreadonly', 'id' => $row->id)); ?> </td> <td><?php echo Yii::app()->format->number($row->count); ?> </td> <td> <!-- Icons --> <a href="<?php echo Yii::app()->urlManager->createUrl('extensions/category/' . $row->alias, array('lang' => false)); ?>
public function actionLookMenu() { $shop_id = Yii::app()->request->getParam('shop_id'); if (!isset($shop_id)) { throw new CHttpException(404, Yii::t('yii', '请选择就餐类别')); } $resident_flag = Yii::app()->request->getParam('resident_flag'); if (isset($resident_flag)) { throw new CHttpException(404, Yii::t('yii', '常驻员工每天每餐仅每次仅允许订购一份!!')); } //查询出改商店的一些详细信息 $shopData = Shops::model()->findByPk($shop_id); if (!$shopData) { throw new CHttpException(404, Yii::t('yii', '您选择的餐类不存在!')); } $shopData = CJSON::decode(CJSON::encode($shopData)); //判断改商家有没有下市场 if (intval($shopData['status']) != 2) { throw new CHttpException(404, Yii::t('yii', '您选择的餐类已经下市!')); } //根据订单历史纪录查询当天是否已经存在同样的中餐、晚餐订单记录 //店铺->中餐、晚餐 //菜单->地点 //LCF $member_id = Yii::app()->user->member_userinfo['id']; $criteria = new CDbCriteria(); $today = strtotime(date('Y-m-d')); $criteria->order = 't.create_time DESC'; $criteria->select = '*'; $criteria->condition = 'food_user_id=:food_user_id AND shop_id = :shop_id AND create_time > :create_time AND status < :status'; $criteria->params = array(':food_user_id' => $member_id, ':shop_id' => $shop_id, ':create_time' => $today, ':status' => 3); //查询结果 $todayOrderCount = FoodOrder::model()->count($criteria); $memberInfo = Members::model()->find('id=:id', array(':id' => Yii::app()->user->member_userinfo['id'])); if ($memberInfo->resident == 1 && $todayOrderCount >= 1) { throw new CHttpException(404, Yii::t('yii', '你今天已经订过该餐了!!常驻员工每天每餐仅每次仅允许订购一份!!')); } //根据店铺id查询出该店铺的菜单 $menuData = Menus::model()->with('food_sort', 'image', 'shops')->findAll(array('condition' => 't.shop_id=:shop_id AND t.status=:status', 'params' => array(':shop_id' => $shop_id, ':status' => 2))); $data = array(); foreach ($menuData as $k => $v) { $data[$k] = $v->attributes; $data[$k]['index_pic'] = $v->index_pic ? Yii::app()->params['img_url'] . $v->image->filepath . $v->image->filename : ''; $data[$k]['sort_name'] = $v->food_sort->name; $data[$k]['shop_name'] = $v->shops->name; $data[$k]['create_time'] = Yii::app()->format->formatDate($v->create_time); $data[$k]['status'] = Yii::app()->params['menu_status'][$v->status]; $data[$k]['price'] = $v->price; } //获取该店的留言 $criteria = new CDbCriteria(); $criteria->order = 't.order_id DESC'; $criteria->condition = 't.shop_id=:shop_id AND t.status=:status'; $criteria->params = array(':shop_id' => $shop_id, ':status' => 1); $count = Message::model()->count($criteria); //构建分页 $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['pagesize']; $pages->applyLimit($criteria); $messageMode = Message::model()->with('members', 'shops', 'replys')->findAll($criteria); $message = array(); foreach ($messageMode as $k => $v) { $message[$k] = $v->attributes; $message[$k]['shop_name'] = $v->shops->name; $message[$k]['user_name'] = $v->members->name; $message[$k]['create_time'] = date('Y-m-d H:i:s', $v->create_time); $message[$k]['status_text'] = Yii::app()->params['message_status'][$v->status]; $message[$k]['status_color'] = Yii::app()->params['status_color'][$v->status]; $_replys = Reply::model()->with('members')->findAll(array('condition' => 'message_id=:message_id', 'params' => array(':message_id' => $v->id))); if (!empty($_replys)) { foreach ($_replys as $kk => $vv) { $message[$k]['replys'][$kk] = $vv->attributes; $message[$k]['replys'][$kk]['create_time'] = date('Y-m-d H:i:s', $vv->create_time); $message[$k]['replys'][$kk]['user_name'] = $vv->user_id == -1 ? '行政MM说' : $vv->members->name; } } } $this->render('lookmenu', array('menus' => $data, 'shop' => $shopData, 'pages' => $pages, 'message' => $message)); }
<div id="parent_Sect"> <?php $this->renderPartial('leftside'); ?> <div id="parent_rightSect"> <div class="parentright_innercon"> <h1><?php echo Yii::t('studentportal', 'Inbox'); ?> </h1> <?php $msg = Message::model()->findAll('receiver_id=:x', array(':x' => 12)); ?> <div class="inbox_filter"> <ul> <li style="margin:3px 0 0 0px;"><input type="checkbox" id="checkbox-1-1" class="regular-checkbox" /><label for="checkbox-1-1"></label></li> <li><a href="#"><?php echo Yii::t('studentportal', 'Mark as Read'); ?> </a></li> <li><a href="#"><?php echo Yii::t('studentportal', 'Mark as Unread'); ?> </a></li> <li><a href="#"><?php echo Yii::t('studentportal', 'Delete'); ?> </a></li> <li><a href="#"><?php
public function actionAcceptFriend($id) { $friendship = Friend::model()->find('User_ID = :User_ID AND Friend_User_ID = :Friend_User_ID AND Status = :Status', array(':User_ID' => $id, ':Friend_User_ID' => Yii::app()->user->id, ':Status' => FriendStatus::AwaitingApproval)); if ($friendship != null) { $friendship->Status = FriendStatus::Friend; $friendship->save(); $notification = Message::model()->find('`From` = :From AND `To` = :To AND Type = :Type', array(':From' => $id, ':To' => Yii::app()->user->id, ':Type' => MessageType::FriendRequest)); if ($notification != null) { $notification->Deleted = 1; $notification->save(); } $friend = User::model()->findByPk(Yii::app()->user->id); $friendLink = CHtml::link($friend->fullName, array('/user/view', 'id' => Yii::app()->user->id)); Message::SendNotification($id, "{$friendLink} has accepted your homie request!"); } $this->redirect(array('/user/view', 'id' => Yii::app()->user->id, 's' => AccountSections::Notifications)); }