コード例 #1
0
ファイル: Jevents_module.php プロジェクト: rasstroen/metro
 function likeEvent($like = 1)
 {
     global $current_user;
     $current_user = new CurrentUser();
     if (!$current_user->id) {
         return;
     }
     $id = $_POST['id'];
     if ($like) {
         $res = MongoDatabase::eventLike($id, $current_user->id);
     } else {
         $res = MongoDatabase::eventUnlike($id, $current_user->id);
     }
     $this->data['result'] = $res;
     $event_owner = $res['event_owner'];
     if ($res && $like && $id && $event_owner != $current_user->id) {
         // перетаскиваем запись к себе на стену
         $followerIds = $current_user->getFollowers();
         $followerIds[$current_user->id] = $current_user->id;
         MongoDatabase::pushEvents($current_user->id, $followerIds, $id, time(), $event_owner);
     }
     if (!$like && $id && $event_owner != $current_user->id) {
         // разонравилась. удаляем эту запись с моей стены
         $followerIds = $current_user->getFollowers();
         $followerIds[$current_user->id] = $current_user->id;
         MongoDatabase::removeWallItem(array_keys($followerIds), $id, $event_owner);
     }
 }