Beispiel #1
0
 public function actionIndex()
 {
     $event = new Events();
     $event->attributes = $_GET;
     if (!isset($_GET['content_id'])) {
         $content = Content::model()->findByAttributes(array('slug' => Cii::get($_GET, 'uri', NULL)));
         if ($content !== NULL) {
             $event->content_id = $content->id;
         }
     }
     if ($event->save()) {
         Yii::app()->end();
     }
     return $this->returnError(400, NULL, $event->getErrors());
 }
Beispiel #2
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()));
     }
 }
Beispiel #3
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));
     }
 }