本文整理汇总了PHP中Message::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::model方法的具体用法?PHP Message::model怎么用?PHP Message::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
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));
}
}
示例2: actionIndex
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);
}
示例3: actionIndex
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);
}
示例4: actionCreate
/**
* 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));
}
示例5: actionMessage_view
public function actionMessage_view()
{
$id = $_GET['id'];
$message = Message::model()->findByPk($id);
$this->data['message'] = $message;
$this->render('message_view', $this->data);
}
示例6: countUnchecked
/**
* $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)));
}
}
示例7: loadModel
/**
* 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;
}
示例8: loadMessage
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;
}
示例9: actionReadMessage
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));
}
示例10: search
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));
}
示例11: run
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));
}
示例12: actionIndex
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);
}
示例13: afterSave
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;
}
示例14: actionSent
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));
}
示例15: getLast15
/**
* @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 ));
}