Ejemplo n.º 1
0
 public static function notify($receiver, $message, $url, $sender = null)
 {
     if ($sender == null) {
         $sender = Yii::app()->user->getId();
     }
     $notif = new Notificacao();
     $notif->sender = $sender;
     $notif->receiver = $receiver;
     $notif->message = $message;
     $notif->url = $url;
     return $notif->save();
 }
 /**
  * 
  * Edita um passo
  * @param integer $id - Identifica o passo
  */
 public function actionUpdatePasso($id)
 {
     $model = new AtividadePasso();
     $model = AtividadePasso::model()->findByPk($id);
     if ($model == null) {
         throw new CHttpException('404', 'Passo não encontrado');
     }
     $this->layout = false;
     if (isset($_POST['AtividadePasso'])) {
         $model->attributes = $_POST['AtividadePasso'];
         if ($model->save()) {
             $sender_id = Yii::app()->user->getId();
             $sender = Yii::app()->user->getName();
             if ($sender_id != $model->cod_pessoa) {
                 $notify = new Notificacao();
                 $notify->sender = $sender_id;
                 $notify->receiver = $model->cod_pessoa;
                 $notify->message = "<b>{$sender}</b> atualizou o passo <b>{$model->descricao}</b>";
                 $notify->url = $this->createUrl('view', array('id' => $model->cod_atividade));
                 $notify->save(false);
                 unset($notify);
             }
             $this->renderPartial('/atividade/passo/_view', array('model' => $model));
             Yii::app()->end();
         }
     }
     $this->render('/atividade/passo/_form_modal', array('model' => $model));
 }
Ejemplo n.º 3
0
 private function broadCast($id, $msg)
 {
     $model = $this->loadModel($id);
     $sender_id = Yii::app()->user->getId();
     $sender = Pessoa::model()->findByPk($sender_id)->nome;
     $message = "<b>{$sender}</b> {$msg} <b>{$model->nome}</b>";
     $url = $this->createUrl('view', array('id' => $model->cod_projeto));
     $receivers = array();
     $receivers[$model->cod_professor] = $model->coordenador;
     $receivers[$model->cod_pos_grad] = $model->vice_coordenador;
     $receivers[$model->cod_grad] = $model->fiscal;
     foreach ($model->pessoas as $p) {
         $receivers[$p->cod_pessoa] = $p;
     }
     //Não manda mensagem para o proprio criador da notificacao
     if (isset($receivers[$sender_id])) {
         unset($receivers[$sender_id]);
     }
     foreach ($receivers as $pessoa) {
         $ntf = new Notificacao();
         $ntf->sender = $sender_id;
         $ntf->message = $message;
         $ntf->url = $url;
         $ntf->receiver = $pessoa->cod_pessoa;
         $ntf->save(false);
     }
 }