public function xRemoveSourcesAction() { $this->request->defineParams(array('sourceId' => array('type' => 'int'))); $source = Scalr_Dm_Source::init()->loadById($this->getParam('sourceId')); $this->user->getPermissions()->validate($source); // Check template usage $dsCount = $this->db->GetOne("SELECT COUNT(*) FROM dm_applications WHERE dm_source_id=?", array($this->getParam('sourceId'))); // If script used redirect and show error if ($dsCount > 0) { throw new Exception(_("Selected source is used by application(s) and cannot be removed")); } $source->delete(); $this->response->success(); }
public function DmSourceCreate($Type, $URL, $AuthLogin = null, $AuthPassword = null) { $source = Scalr_Model::init(Scalr_Model::DM_SOURCE); $authInfo = new stdClass(); if ($Type == Scalr_Dm_Source::TYPE_SVN) { $authInfo->login = $AuthLogin; $authInfo->password = $AuthPassword; $authType = Scalr_Dm_Source::AUTHTYPE_PASSWORD; } if (Scalr_Dm_Source::getIdByUrlAndAuth($URL, $authInfo)) { throw new Exception("Source already exists in database"); } $source->envId = $this->Environment->id; $source->url = $URL; $source->type = $Type; $source->authType = $authType; $source->setAuthInfo($authInfo); $source->save(); $response = $this->CreateInitialResponse(); $response->SourceID = $source->id; return $response; }