public function current_version()
 {
     try {
         return Version::find('first', array('order' => 'created_at DESC', 'conditions' => array('package_id' => $this->id)));
     } catch (NimbleRecordNotFound $e) {
         return false;
     }
 }
 public function testDeleteBobsPackage()
 {
     $_SERVER['SERVER_NAME'] = 'bob.localhost.com';
     $count = Version::count();
     $p = Package::find_by_name('bobs_other_package');
     $v = Version::find('first', array('package_id' => $p->id, 'version' => '0.0.1'));
     $this->delete('delete', array(), array('id' => $v->package_id, 'version' => $v->id), array('user' => User::find_by_username('bob')->id));
     $this->assertEquals($count - 1, Version::count(array('cache' => false)));
     $this->assertFalse(Version::exists('id', $v->id));
     $this->assertRedirect(url_for('PackageController', 'show', $p->id));
 }
 function _detectProjectId()
 {
     $project_id = null;
     if (isset($this->controller->params['project_id'])) {
         $project_id = $this->controller->params['project_id'];
     }
     if ($this->controller->name == 'Versions') {
         $version_id = $this->controller->params['pass'][0];
         App::uses('Version', 'Model');
         $version = new Version();
         $bind = array('belongsTo' => array('Project' => array('className' => 'Project')));
         $version->bindModel($bind);
         $version_row = $version->find('first', array('condtions' => array('id' => $version_id)));
         $project_id = $version_row['Project']['identifier'];
     }
     return $project_id;
 }
 public function delete()
 {
     $this->login_user();
     try {
         $package = Package::find($_GET['id']);
         $version = Version::find($_GET['version']);
     } catch (NimbleRecordNotFound $e) {
         $this->redirect_to('/');
     }
     if ($version->package_id == $package->id && $package->user_id == $this->user->id) {
         $file = $package->file_path($version->version);
         @unlink($file);
         Nimble::flash('notice', "Version: {$version->version} was deleted");
         $version->delete();
         $this->redirect_to(url_for('PackageController', 'show', $package->user->username, $package->name));
     } else {
         $this->redirect_to('/');
     }
 }
 /**
  * index
  */
 public function index()
 {
     switch ($this->format) {
         case 'xml':
             if ($this->user->active == 0) {
                 exit;
             }
             $this->layout = false;
             $this->render('channel/index.xml');
             $this->header('Content-Type: text/xml', 200);
             $this->current_version = Version::find('first', array('select' => 'versions.*', 'joins' => 'INNER JOIN packages on versions.package_id = packages.id INNER JOIN users ON users.id = packages.user_id', 'order' => 'versions.version DESC'));
             $date = DateHelper::from_db($this->current_version->created_at);
             $date = date(DATE_RFC822, $date);
             $this->header("Last-Modified: {$date}");
             break;
         default:
             $this->packages = $this->user->packages;
             $this->header('Content-Type: text/html', 200);
             break;
     }
 }
Esempio n. 6
0
 public function compare()
 {
     //$this->output->enable_profiler(true);
     $this->load->model('Version');
     $this->form_validation->set_rules('version_before', 'Version', 'required|integer');
     $this->form_validation->set_rules('version_after', 'Version', 'required|integer');
     $data = array();
     if ($this->form_validation->run() === true) {
         $version_before = Version::find($this->input->post('version_before'));
         $version_after = Version::find($this->input->post('version_after'));
         if ($version_before !== false && $version_after !== false) {
             $comparison = $version_after->compare_to($version_before);
             /*
             echo '<pre>';
             var_dump($comparison);
             echo '</pre>';
             */
             $data['comparison'] = $comparison;
         }
     }
     $this->layout->add_basic_assets()->menu()->action_view($data);
 }
 private function load_release()
 {
     $this->package = Package::find('first', array('conditions' => array('name' => $_GET['name'], 'user_id' => $this->user->id)));
     $date = DateHelper::from_db($this->package->updated_at);
     $date = date(DATE_RFC822, $date);
     $this->header("Last-Modified: {$date}");
     $this->version = Version::find('first', array('conditions' => array('version' => $_GET['version'], 'package_id' => $this->package->id)));
     $this->data = unserialize($this->version->meta);
 }
Esempio n. 8
0
 public function tag()
 {
     if (empty($_GET['url'])) {
         exit;
     }
     # TODO
     $versions = Version::find(array("placeholders" => true, "where" => array("tags like" => "%: \"" . $_GET['url'] . "\"\n%")));
     $this->display("extend/tag", array("versions" => new Paginator($versions, 25), "tag" => fix($_GET['url'])), fix(_f("Versions tagged with \"%s\"", $_GET['url'], "extend")));
 }
Esempio n. 9
0
 /**
  * Links a plugin to an application
  * GET /application/{appid}/link
  *
  * @param  int  $appid
  * @return Response
  */
 public function storeLink($appid, $pluginid)
 {
     intval($pluginid);
     intval($appid);
     $rules = ['version' => 'required|integer'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator->messages());
     }
     if (Version::find(Input::get('version')) && Application::find($appid)) {
         Application::find($appid)->versions()->attach(Input::get('version'));
         return Redirect::action('application.show', [$appid])->withSuccess('Plugin connected.');
     } else {
         return Redirect::action('application.index')->withErrors(['Version or application does not exist.']);
     }
 }
 private function load_release()
 {
     $this->package = Package::find('first', array('conditions' => array('name' => $_GET['name'], 'user_id' => $this->user->id)));
     $this->version = Version::find('first', array('conditions' => array('version' => $_GET['version'], 'package_id' => $this->package->id)));
     $this->data = unserialize($this->version->meta);
 }
Esempio n. 11
0
 /**
  * Remove the specified resource from storage.
  * DELETE /version/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($pluginid, $versionid)
 {
     intval($versionid);
     intval($versionid);
     Version::find($versionid)->delete();
     return Redirect::action('PluginController@show', [$pluginid])->withSuccess('Version removed.');
 }