/**
  * Clears Up all User-related notifications
  * @param integer $id
  */
 public function clearAllUserChangesIFollow($id)
 {
     $change = ['and', 'follower' => $id, ['or', 'changed_photo' => 1, 'changed_linkedin' => 1, 'changed_github' => 1, ['not', ['created_api' => null]], ['not', ['changed_upvotes_apis' => null]], ['not', ['changed_downvotes_apis' => null]]]];
     FollowUserUser::updateAll(['changed_photo' => 0, 'changed_linkedin' => 0, 'changed_github' => 0, 'created_api' => null, 'changed_upvotes_apis' => null, 'changed_downvotes_apis' => null], $change);
 }
 /**
  * Finds the Number of Notifications that should be displayed to a follower. Both for APIs and Users.
  * @return int
  */
 public function getFollowingAPIsUsersNotifNum()
 {
     $myId = \Yii::$app->user->id;
     $followUserApis = FollowUserApi::findAll(['follower' => $myId]);
     $notifNum = 0;
     foreach ($followUserApis as $followUserApi) {
         if ($followUserApi->changed_name) {
             $notifNum++;
         }
         if ($followUserApi->changed_descr) {
             $notifNum++;
         }
         if ($followUserApi->changed_version) {
             $notifNum++;
         }
         if ($followUserApi->changed_upvotes) {
             $notifNum++;
         }
         if ($followUserApi->changed_downvotes) {
             $notifNum++;
         }
         if ($followUserApi->changed_proposed) {
             $notifNum++;
         }
         if ($followUserApi->changed_published) {
             $notifNum++;
         }
         if ($followUserApi->changed_privacy) {
             $notifNum++;
         }
         if ($followUserApi->changed_objects_number) {
             $notifNum++;
         }
     }
     $followUserUsers = FollowUserUser::findAll(['follower' => $myId]);
     foreach ($followUserUsers as $followUserUser) {
         if ($followUserUser->changed_photo) {
             $notifNum++;
         }
         if ($followUserUser->changed_linkedin) {
             $notifNum++;
         }
         if ($followUserUser->changed_github) {
             $notifNum++;
         }
         if ($followUserUser->created_api) {
             $notifNum++;
         }
         if ($followUserUser->changed_upvotes_apis) {
             $notifNum++;
         }
         if ($followUserUser->changed_downvotes_apis) {
             $notifNum++;
         }
     }
     return $notifNum;
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFollowUserUsers()
 {
     return $this->hasMany(FollowUserUser::className(), ['follower' => 'id']);
 }