/** * @see Action::execute() */ public function execute() { // call execute event parent::execute(); if ($this->source->enableCheckout && $this->checkoutRepository) { // load scm driver $className = ucfirst(Source::validateSCM($this->source->scm)); // check out repository require_once WCF_DIR . 'lib/system/scm/' . $className . '.class.php'; call_user_func(array($className, 'checkout'), $this->source->url, $this->source->sourceDirectory, array('username' => $this->source->username, 'password' => $this->source->password)); // set revision $revision = $this->source->getHeadRevision(); $this->source->update(null, null, null, null, null, null, null, $revision); } // rebuild package data if requested if ($this->rebuildPackageData) { require_once PB_DIR . 'lib/system/package/PackageHelper.class.php'; PackageHelper::readPackages($this->source); } // call executed event $this->executed(); // forward HeaderUtil::redirect('index.php?page=SourceView&sourceID=' . $this->source->sourceID . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * Updates the data of a source. * * @param string $name The name of the source * @param string $sourceDirectory Source directory used for files * @param string $buildDirectory Build directory contains all archives * @param string $scm Defines used SCM, may be 'git', 'none' and 'subversion' * @param string $url URL for accessing subversion * @param string $username Username neccessary if subversion repository is protected * @param string $password Password neccessary if subversion repository is protected * @param string $revision Currently used revision * @param boolean $trustServerCert Automaticly trust server certificate * @param boolean $enableCheckout Enables checkout ability * @param integer $position Position used to order sources */ public function update($name = null, $sourceDirectory = null, $buildDirectory = null, $scm = null, $url = null, $username = null, $password = null, $revision = null, $trustServerCert = null, $enableCheckout = null, $position = null) { $fields = array(); if ($name !== null) { $fields['name'] = $name; } if ($sourceDirectory !== null) { $fields['sourceDirectory'] = $sourceDirectory; } if ($buildDirectory !== null) { $fields['buildDirectory'] = $buildDirectory; } if ($scm !== null) { $fields['scm'] = Source::validateSCM($scm); } if ($url !== null) { $fields['url'] = $url; } if ($username !== null) { $fields['username'] = $username; } if ($password !== null) { $fields['password'] = $password; } if ($revision !== null) { $fields['revision'] = $revision; } if ($trustServerCert !== null) { $fields['trustServerCert'] = intval($trustServerCert); } if ($enableCheckout !== null) { $fields['enableCheckout'] = intval($enableCheckout); } if ($position !== null) { $fields['position'] = intval($position); } $this->updateData($fields); }
/** * Validates SCM and resets input fields if unused */ protected function validateSCM() { $this->scm = Source::validateSCM($this->scm); switch ($this->scm) { case 'none': // reset input if no SCM is active $this->username = $this->password = ''; $this->trustServerCert = $this->enableCheckout = 0; break; default: if (empty($this->url)) { throw new UserInputException('url', 'empty'); } break; } }