コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('mods')->delete();
     $testmod = Mod::create(array('pretty_name' => 'TestMod', 'name' => 'testmod', 'description' => 'This is a test mod for Solder', 'author' => 'Technic', 'link' => 'http://solder.io'));
     DB::table('modversions')->delete();
     $testmodversion = Modversion::create(array('mod_id' => $testmod->id, 'version' => '0.1', 'md5' => 'fb6582e4d9c9bc208181907ecc108eb1'));
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('mods')->delete();
     $testmod = Mod::create(array('pretty_name' => 'TestMod', 'name' => 'testmod', 'description' => 'This is a test mod for Solder', 'author' => 'Technic', 'link' => 'http://solder.io'));
     DB::table('modversions')->delete();
     $testmodversion = Modversion::create(array('mod_id' => $testmod->id, 'version' => '1.0', 'md5' => 'bdbc6c6cc48c7b037e4aef64b58258a3', 'filesize' => '295'));
 }
コード例 #3
0
 public function getIndex()
 {
     $builds = Build::where('is_published', '=', '1')->orderBy('updated_at', 'desc')->take(5)->get();
     $modversions = Modversion::whereNotNull('md5')->orderBy('updated_at', 'desc')->take(5)->get();
     $rawChangeLog = UpdateUtils::getLatestChangeLog();
     $changelogJson = array_key_exists('error', $rawChangeLog) ? $rawChangeLog : array_slice($rawChangeLog, 0, 10);
     return View::make('dashboard.index')->with('modversions', $modversions)->with('builds', $builds)->with('changelog', $changelogJson);
 }
コード例 #4
0
 private function fetchModversion($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;
 }
コード例 #5
0
 public function anyDeleteVersion($ver_id = null)
 {
     if (Request::ajax()) {
         if (empty($ver_id)) {
             return Response::json(array('status' => 'error', 'reason' => 'Missing Post Data'));
         }
         $ver = Modversion::find($ver_id);
         if (empty($ver)) {
             return Response::json(array('status' => 'error', 'reason' => 'Could not pull mod version from database'));
         }
         $old_id = $ver->id;
         $old_version = $ver->version;
         $ver->delete();
         return Response::json(array('status' => 'success', 'version' => $old_version, 'version_id' => $old_id));
     }
     return Response::view('errors.missing', array(), 404);
 }
コード例 #6
0
 /**
  * AJAX Methods for Modpack Manager
  **/
 public function anyModify($action = null)
 {
     if (!Request::ajax()) {
         return Response::view('errors.missing', array(), 404);
     }
     if (empty($action)) {
         return Response::view('errors.500', array(), 500);
     }
     switch ($action) {
         case "version":
             $version_id = Input::get('version');
             $modversion_id = Input::get('modversion_id');
             $affected = DB::table('build_modversion')->where('build_id', '=', Input::get('build_id'))->where('modversion_id', '=', $modversion_id)->update(array('modversion_id' => $version_id));
             if ($affected == 0) {
                 if ($modversion_id != $version_id) {
                     $status = 'failed';
                 } else {
                     $status = 'aborted';
                 }
             } else {
                 $status = 'success';
             }
             return Response::json(array('status' => $status, 'reason' => 'Rows Affected: ' . $affected));
             break;
         case "delete":
             $affected = DB::table('build_modversion')->where('build_id', '=', Input::get('build_id'))->where('modversion_id', '=', Input::get('modversion_id'))->delete();
             $status = 'success';
             if ($affected == 0) {
                 $status = 'failed';
             }
             return Response::json(array('status' => $status, 'reason' => '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();
             $affected = DB::table('build_modversion')->where('build_id', '=', $build->id)->where('modversion_id', '=', $ver->id)->get();
             $duplicate = !empty($affected);
             if ($duplicate) {
                 return Response::json(array('status' => 'failed', 'reason' => 'Duplicate Modversion found'));
             } else {
                 $build->modversions()->attach($ver->id);
                 return Response::json(array('status' => 'success', '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();
             Cache::forget('modpack.' . $modpack->slug);
             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();
             Cache::forget('modpack.' . $modpack->slug);
             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."));
         case "private":
             $build = Build::find(Input::get('build'));
             $private = Input::get('private');
             $build->private = $private ? true : false;
             $build->save();
             return Response::json(array("success" => "Updated build " . $build->version . "'s private status."));
     }
 }