Пример #1
0
 public static function validateMap($set, $beatmap)
 {
     try {
         $set = BeatmapSet::findOrFail($set);
     } catch (Exception $e) {
         return false;
     }
     if (!$beatmap) {
         return true;
     }
     $beatmaps = $set->beatmaps->toArray();
     $ids = array_column($beatmaps, 'beatmap_id');
     if (in_array($beatmap, $ids)) {
         return $beatmap;
     }
     if ($beatmap == 'first') {
         return $ids[0];
     }
     if ($beatmap == 'general' or $beatmap == 'nomination') {
         return;
     }
     return false;
 }
Пример #2
0
 /**
  * GET /api/$version/mod-comments/$id.
  *
  * @api
  *
  * @param int $id
  *
  * @return json
  */
 public function anyModComments($id = null)
 {
     if (!$id) {
         return $this->error('missing', 'beatmaps.modding');
     }
     try {
         $set = BeatmapSet::findOrFail($id);
     } catch (Exception $e) {
         return $this->error('missing', 'beatmaps.modding');
     }
     if ($set) {
         $updates = $this->getModChanges($id);
         $user = $this->user();
         $updated = false;
         foreach ($updates as $k => $v) {
             foreach ($v as $type => $value) {
                 if ($value) {
                     $updated = true;
                 }
             }
         }
         $updates['updated'] = $updated;
         $updates['set'] = $set->beatmapset_id;
         $updates['csrf'] = csrf_token();
         $updates['authed'] = $user ?: 0;
         $updates['bat'] = $user and $user->isBAT();
         $updates['time'] = time();
         return Response::json($updates);
     }
     return $this->error('missing', 'beatmaps.modding');
 }