/** * Short description for 'getDevelopmentVersion' * * Long description (if any) ... * * @return unknown Return description (if any) ... */ public function getDevelopmentVersion() { return Helpers\Version::getDevelopmentToolVersion($this->id); }
/** * Apply a license * * @return void */ public function savelicenseTask() { $id = Request::getInt('toolid', 0, 'post'); $error = ''; if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller)); } $hztv = \Components\Tools\Helpers\Version::getDevelopmentToolVersion($id); $this->license_choice = array('text' => Request::getVar('license', ''), 'template' => Request::getVar('templates', 'c1'), 'authorize' => Request::getInt('authorize', 0)); $hztv->codeaccess = Request::getVar('t_code', '@OPEN'); $action = Request::getWord('action', 'dev'); // Closed source if ($hztv->codeaccess == '@DEV') { $reason = Request::getVar('reason', ''); if (!$reason) { $this->view->license_choice = $this->license_choice; $this->view->code = $hztv->codeaccess; // display license page with error $this->setError(Lang::txt('COM_TOOLS_LICENSE_CLOSED_SOURCE_NEED_REASON')); $this->licenseTask(); return; } else { $path = DS . 'site/protected'; if (is_dir(PATH_APP . $path)) { $log = 'By: ' . User::get('name') . ' (' . User::get('username') . ') ' . "\n"; $log .= 'Tool: ' . $hztv->toolname . ' (id #' . $id . ')' . ' - ' . $hztv->instance . "\n"; $log .= 'Time : ' . date('c') . "\n"; $log .= 'Reason for closed source: ' . "\n"; $log .= $reason . "\n"; $log .= '-----------------------------------------' . "\n"; // Log reason for closed source $this->_writeToFile($log, PATH_APP . $path . DS . 'closed_source_reasons.txt', true); } // code for saving license $hztv->license = NULL; // save version info $hztv->update(); //@FIXME: look $this->_setTracAccess($hztv->toolname, $hztv->codeaccess, null); if ($action != 'confirm') { $this->_msg = Lang::txt('COM_TOOLS_NOTICE_CHANGE_LICENSE_SAVED'); $this->statusTask(); } else { $this->finalizeTask(); } return; } } // Open source if (\Components\Tools\Models\Tool::validateLicense($this->license_choice, $hztv->codeaccess, $error)) { // code for saving license $hztv->license = strip_tags($this->license_choice['text']); // save version info $hztv->update(); //@FIXME: look $this->_setTracAccess($hztv->toolname, $hztv->codeaccess, null); if ($action != 'confirm') { $this->_msg = Lang::txt('COM_TOOLS_NOTICE_CHANGE_LICENSE_SAVED'); $this->statusTask(); } else { $this->finalizeTask(); } } else { $this->view->code = $hztv->codeaccess; $this->view->license_choice = $this->license_choice; // display license page with error $this->setError($error); $this->licenseTask(); } }
/** * Install the tool * * @return void */ public function installTask() { // Set the layout (note: all the views for this controller use the same layout) $this->view->setLayout('display'); // Create a Tool object $obj = new \Components\Tools\Tables\Tool($this->database); // Do we have an alias? if ($alias = Request::getVar('app', '')) { $this->_toolid = $obj->getToolId($alias); } // Do we have a tool ID if (!$this->_toolid) { App::abort(403, Lang::txt('COM_TOOLS_ERROR_TOOL_NOT_FOUND')); return; } // Get the tool status $obj->getToolStatus($this->_toolid, $this->_option, $status, 'dev'); // Check for a status if (count($status) <= 0) { App::abort(500, Lang::txt('COM_TOOLS_ERR_CANNOT_RETRIEVE')); return; } // Github connection? if ($status['github']) { $command = '/usr/bin/sudo -u apps ' . PATH_CORE . '/components/com_tools/scripts/git2svn.sh -g ' . $status['github'] . ' -s ' . $status['toolname'] . ' -c ' . PATH_CORE . '/..'; if (!$this->_invokeScript($command, Lang::txt('Github repository connection successful'))) { $this->setError(Lang::txt('Github connection error')); } } // Build the exec command $command = '/usr/bin/sudo -u apps /usr/bin/installtool -type raw -hubdir ' . PATH_CORE . '/../ ' . $status['toolname']; error_log($command); // Invoke the script if (!$this->getError() && $this->_invokeScript($command, Lang::txt('COM_TOOLS_NOTICE_REV_INSTALLED'))) { // Extract revision number $rev = explode('installed revision: ', $this->getMessage()); if (!isset($rev[1]) || !intval($rev[1])) { $this->setError(Lang::txt('COM_TOOLS_ERR_CANNOT_SAVE_REVISION_INFO')); } else { // Update the revision number $hztv = \Components\Tools\Helpers\Version::getDevelopmentToolVersion($this->_toolid); $hztv->revision = intval($rev[1]); if (!$hztv->update()) { $this->setError(Lang::txt('COM_TOOLS_ERROR_SAVING_REVISION_UPDATE')); } } } // Set errors to view if ($this->getError()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } } // Set messages to view $this->view->messages = $this->getMessages(); // Output HTML if (!($no_html = Request::getInt('no_html', 0))) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=pipeline&task=status&app=' . $alias)); return; } $this->view->display(); }