public function actionCreate($u_id, $cb = null)
 {
     $user = Users::model()->loadModel($u_id);
     $this->pageTitle = 'Send Message to ' . $user->name;
     $model = new MsgMessage(MsgMessage::SCENARIO_PRIVATE_MESSAGE);
     $model->to_ids = $user->id;
     $modelClassName = $model->getClassName();
     if (isset($_POST[$modelClassName])) {
         $model->attributes = $_POST[$modelClassName];
         $error_message = CActiveForm::validate($model);
         $error_message_decoded = CJSON::decode($error_message);
         $redirectLink = !empty($cb) ? $cb : $this->createUrl('index');
         if (!empty($error_message_decoded)) {
             echo CJSON::encode(array('success' => false, 'message' => $error_message));
             Yii::app()->end();
         }
         $model->save(FALSE);
         echo CJSON::encode(array('success' => true, 'message' => Lang::t('Message successfully sent.'), 'redirectUrl' => $redirectLink));
         Yii::app()->end();
     }
     $this->renderPartial('_colorboxForm', array('model' => $model), FALSE, TRUE);
 }
Exemple #2
0
 /**
  * Get recipient list for a message
  */
 public function getRecipientList()
 {
     $recipient_ids = MsgMessage::model()->getScaler('to_ids', '`id`=:t1', array(':t1' => $this->message_id));
     if (!empty($recipient_ids)) {
         $recipient = Users::model()->getColumnData("concat(`first_name`,' ',`last_name`)", "`id` IN({$recipient_ids})");
         if (!empty($recipient_ids)) {
             return implode(',', $recipient);
         }
     }
     return FALSE;
 }