/** * Get All notifications of a user. * * @author Kuldeep Dangi <*****@*****.**> */ public function actionGetAllNotifications($userId) { $model = new Notifications(); $data = array(); $notifications = $model->getNotificationByUserId($userId); foreach ($notifications as $notification) { //print_r($notification); die; switch ($notification['type']) { case self::NOTIFICATION_TYPE_FOLLOW: $user = Users::model()->findByAttributes(array('user_id' => $notification['byUserId'])); if ($user) { $data[] = array('type' => $notification['type'], 'user_id' => $user->user_id, 'username' => $user->username, 'first_name' => $user->firstname, 'last_name' => $user->lastname, 'datetime' => strtotime($notification['created_at'])); } case self::NOTIFICATION_TYPE_WISHLISTCOMMENT: $user = Users::model()->findByPk($notification['byUserId']); $userFeed = UserFeed::model()->findByPk($notification['notify_comment']); if ($user && $userFeed) { $data[] = array('type' => $notification['type'], 'user_id' => $user->user_id, 'username' => $user->username, 'first_name' => $user->firstname, 'last_name' => $user->lastname, 'datetime' => strtotime($notification['created_at']), 'wishlistId' => $userFeed->user_feed_id, 'wishlistTitle' => $userFeed->comment); } case self::NOTIFICATION_TYPE_WISHLISTUPLOAD: $user = Users::model()->findByPk($notification['byUserId']); $userFeed = UserFeed::model()->findByPk($notification['notify_comment']); if ($user && $userFeed) { $data[] = array('type' => $notification['type'], 'user_id' => $user->user_id, 'username' => $user->username, 'first_name' => $user->firstname, 'last_name' => $user->lastname, 'datetime' => strtotime($notification['created_at']), 'noteId' => $notification['notify_extension'], 'wishlistId' => $userFeed->user_feed_id, 'wishlistTitle' => $userFeed->comment); } } } $this->result['success'] = true; $this->result['data'] = $data; $this->sendResponse($this->result); }
/** * Load model of a Feed. * * @author Kuldeep Dangi <*****@*****.**> */ public function loadModel($id) { $model = UserFeed::model()->findByPk($id); return $model; }