Пример #1
0
 public function execute(&$params)
 {
     $options =& $this->config['options'];
     $notif = new Notification();
     $notif->user = $this->parseOption('user', $params);
     $notif->createdBy = 'API';
     $notif->createDate = time();
     // file_put_contents('triggerLog.txt',"\n".$notif->user,FILE_APPEND);
     // if($this->parseOption('type',$params) == 'auto') {
     // if(!isset($params['model']))
     // return false;
     // $notif->modelType = get_class($params['model']);
     // $notif->modelId = $params['model']->id;
     // $notif->type = $this->getNotifType();
     // } else {
     $notif->type = 'custom';
     $notif->text = $this->parseOption('text', $params);
     // }
     if ($notif->save()) {
         return array(true, "");
     } else {
         $errors = $notif->getErrors();
         return array(false, array_shift($errors));
     }
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 private function createNotification()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $ntf = new Notification();
         $ntf->customSetAttributes($this->arguments);
         if ($ntf->save()) {
             $transaction->commit();
             Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_EXITO, "message" => "notificacion con id = {$ntf->id} ingresada con exito")));
         } else {
             $transaction->rollback();
             Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => $ntf->getErrors())));
         }
     } catch (\Exception $e) {
         $transaction->rollback();
         Yii::log($e->getMessage(), DBLog::LOG_LEVEL_ERROR);
         Response::error(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => Yii::app()->params["httpErrorCode500Message"])));
     }
 }
Пример #3
0
 protected function sendMailProgres($vid)
 {
     //kirim email pada saat team memberikan progres
     // $project = Project::model()->findByPk($idp)->id_member;
     // $member =
     $sql = "SELECT \n\t\tpv.view_name,p.id_member,p.project_name, m.email ,m.name\n\t\tFROM\n\t\tproject p\n\t\tINNER JOIN\n\t\tproject_views pv\n\t\tON \n\t\tp.id = pv.project_id\n\t\tINNER JOIN\n\t\tmember m\n\t\tON\n\t\tm.id = p.id_member\n\t\tWHERE\n\t\tpv.id= '{$vid}'";
     $model = Yii::app()->db->createCommand($sql)->queryRow();
     try {
         Yii::import('ext.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->view = "new_progres";
         $params = array('model' => $model);
         $message->setBody($params, 'text/html');
         $message->subject = "Notification New Progres!";
         $message->addTo($model[email]);
         $message->from = Yii::app()->params['adminEmail'];
         if (Yii::app()->mail->send($message)) {
             $notif = new Notification();
             $notif->tanggal = date('Y-m-d H:i:s');
             $notif->judul = "Progres Notification";
             $notif->keterangan = "Hello the team already sent the progres of <b>{$model['view_name']}</b> on <b>{$model['project_name']}</b>'s Project. ";
             $notif->id_member = $model[id_member];
             $notif->url = "vvfy.me";
             $notif->is_baca = "0";
             if ($notif->save()) {
                 return true;
             } else {
                 return print_r($notif->getErrors());
             }
         }
     } catch (Exception $e) {
         // return false;
     }
     //akhir
 }
Пример #4
0
 public function execute(&$params)
 {
     $options =& $this->config['options'];
     $event = new Events();
     $notif = new Notification();
     $user = $this->parseOption('user', $params);
     $type = $this->parseOption('type', $params);
     if ($type === 'auto') {
         if (!isset($params['model'])) {
             return array(false, '');
         }
         $notif->modelType = get_class($params['model']);
         $notif->modelId = $params['model']->id;
         $notif->type = $this->getNotifType();
         $event->associationType = get_class($params['model']);
         $event->associationId = $params['model']->id;
         $event->type = $this->getEventType();
         if ($params['model']->hasAttribute('visibility')) {
             $event->visibility = $params['model']->visibility;
         }
         // $event->user = $this->parseOption('user',$params);
     } else {
         $text = $this->parseOption('text', $params);
         $notif->type = 'custom';
         $notif->text = $text;
         $event->type = 'feed';
         $event->subtype = $type;
         $event->text = $text;
         if ($user == 'auto' && isset($params['model']) && $params['model']->hasAttribute('assignedTo') && !empty($params['model']->assignedTo)) {
             $event->user = $params['model']->assignedTo;
         } elseif (!empty($user)) {
             $event->user = $user;
         } else {
             $event->user = '******';
         }
     }
     if (!$this->parseOption('createNotif', $params)) {
         if (!$notif->save()) {
             return array(false, array_shift($notif->getErrors()));
         }
     }
     if ($event->save()) {
         return array(true, "");
     } else {
         return array(false, array_shift($event->getErrors()));
     }
 }
Пример #5
0
 public function execute(&$params)
 {
     $options =& $this->config['options'];
     $event = new Events();
     $notif = new Notification();
     $user = $this->parseOption('feed', $params);
     $author = $this->parseOption('user', $params);
     $type = $this->parseOption('type', $params);
     $visibility = $this->parseOption('visibility', $params);
     // Unfinsihed automatic event type detection feature
     //        if($type === 'auto'){
     //            if(!isset($params['model']))
     //                return array (false, '');
     //            $notif->modelType = get_class($params['model']);
     //            $notif->modelId = $params['model']->id;
     //            $notif->type = $this->getNotifType();
     //
     //            $event->associationType = get_class($params['model']);
     //            $event->associationId = $params['model']->id;
     //            $event->type = $this->getEventType();
     //            if($params['model']->hasAttribute('visibility'))
     //                $event->visibility = $params['model']->visibility;
     //            // $event->user = $this->parseOption('user',$params);
     //        } else{
     $text = $this->parseOption('text', $params);
     $notif->type = 'custom';
     $notif->text = $text;
     $event->type = 'feed';
     $event->subtype = $type;
     $event->text = $text;
     $event->visibility = $visibility;
     if ($author == 'auto' && isset($params['model']) && $params['model']->hasAttribute('assignedTo') && !empty($params['model']->assignedTo)) {
         $event->user = $params['model']->assignedTo;
     } else {
         $event->user = $author;
     }
     if (!empty($user)) {
         if ($user == 'auto' && isset($params['model']) && $params['model']->hasAttribute('assignedTo') && !empty($params['model']->assignedTo)) {
             $associatedUser = $params['model']->assignedTo;
         } else {
             $associatedUser = $user;
         }
         $associatedUser = User::model()->findByAttributes(array('username' => $associatedUser));
         if ($associatedUser) {
             $event->associationType = 'User';
             $event->associationId = $associatedUser->id;
             $notif->modelType = 'Profile';
             $notif->modelId = $event->associationId;
             $notif->type = 'social_post';
             $notif->createdBy = $event->user;
             $notif->user = $associatedUser->username;
         }
     }
     if (!$this->parseOption('createNotif', $params)) {
         if (!$notif->save()) {
             $errors = $notif->getErrors();
             return array(false, array_shift($errors));
         }
     }
     if ($event->save()) {
         return array(true, "");
     } else {
         $errors = $event->getErrors();
         return array(false, array_shift($errors));
     }
 }