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(); }