예제 #1
0
 private function fetch_modversion($mod, $version)
 {
     $response = array();
     $version = ModVersion::where("mod_id", "=", $mod->id)->where("version", "=", $version)->first();
     if (empty($version)) {
         return array("error" => "Mod version does not exist");
     }
     $response['md5'] = $version->md5;
     $response['url'] = Config::get('solder.mirror_url') . 'mods/' . $version->mod->name . '/' . $version->mod->name . '-' . $version->version . '.zip';
     return $response;
 }
예제 #2
0
 /**
  * AJAX Methods for Modpack Manager
  **/
 public function action_modify($action = null)
 {
     if (empty($action)) {
         return Response::error('500');
     }
     switch ($action) {
         case "version":
             $affected = DB::table('build_modversion')->where('id', '=', Input::get('pivot_id'))->update(array('modversion_id' => Input::get('version')));
             return Response::json(array('success' => 'Rows Affected: ' . $affected));
             break;
         case "delete":
             $affected = DB::table('build_modversion')->where('id', '=', Input::get('pivot_id'))->delete();
             return Response::json(array('success' => 'Rows Affected: ' . $affected));
             break;
         case "add":
             $build = Build::find(Input::get('build'));
             $mod = Mod::where('name', '=', Input::get('mod-name'))->first();
             $ver = ModVersion::where('mod_id', '=', $mod->id)->where('version', '=', Input::get('mod-version'))->first();
             $build->modversions()->attach($ver->id);
             return Response::json(array('pretty_name' => $mod->pretty_name, 'version' => $ver->version));
             break;
         case "recommended":
             $modpack = Modpack::find(Input::get('modpack'));
             $new_version = Input::get('recommended');
             $modpack->recommended = $new_version;
             $modpack->save();
             return Response::json(array("success" => "Updated " . $modpack->name . "'s recommended  build to " . $new_version, "version" => $new_version));
             break;
         case "latest":
             $modpack = Modpack::find(Input::get('modpack'));
             $new_version = Input::get('latest');
             $modpack->latest = $new_version;
             $modpack->save();
             return Response::json(array("success" => "Updated " . $modpack->name . "'s latest  build to " . $new_version, "version" => $new_version));
             break;
         case "published":
             $build = Build::find(Input::get('build'));
             $published = Input::get('published');
             $build->is_published = $published ? true : false;
             $build->save();
             return Response::json(array("success" => "Updated build " . $build->version . "'s published status."));
     }
 }
예제 #3
0
 private function getBuildMods($build, $mods)
 {
     $version_ids = array();
     foreach ($mods as $name => $version) {
         $mod = Mod::where('name', '=', $name)->first();
         if (!empty($mod)) {
             $version = ModVersion::where('mod_id', '=', $mod->id)->where('version', '=', $version)->first();
             if (!empty($version)) {
                 array_push($version_ids, $version->id);
             }
         } else {
             Log::write("Notice", "Mod with name " . $name . " does not exist in ModLibrary.");
         }
     }
     $build->modversions()->sync($version_ids);
     return true;
 }