/**
  * @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;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     // call execute event
     parent::execute();
     WCF::getUser()->checkPermission('admin.source.canEditSources');
     // fetch data
     $source = new SourceEditor($this->sourceID);
     if (!$source->sourceID) {
         throw new IllegalLinkException();
     }
     $source->update($this->title);
     // call executed event
     $this->executed();
     // only called via ajax, so no header location
     exit;
 }
 /**
  * Creates a new 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	boolean		$trustServerCert	Automaticly trust server certificate
  * @param	boolean		$enableCheckout		Enables checkout ability
  * @param	integer		$position		Position used to order sources
  * @return 	SourceEditor
  */
 public static function create($name, $sourceDirectory, $buildDirectory, $scm, $url, $username, $password, $trustServerCert, $enableCheckout, $position)
 {
     // handle dir seperators
     $sourceDirectory = FileUtil::unifyDirSeperator($sourceDirectory);
     $buildDirectory = FileUtil::unifyDirSeperator($buildDirectory);
     // validate SCM
     $scm = self::validateSCM($scm);
     // save data
     $sourceID = self::insert($name, array('sourceDirectory' => $sourceDirectory, 'buildDirectory' => $buildDirectory, 'scm' => $scm, 'url' => $url, 'username' => $username, 'password' => $password, 'trustServerCert' => $trustServerCert, 'enableCheckout' => $enableCheckout));
     // get source
     $source = new SourceEditor($sourceID, null);
     // set position
     $source->setPosition($position);
     // create permissions
     $source->createPermissions();
     return $source;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // any numeric value is valid for $position thus we replace an empty value with null
     if (empty($this->position)) {
         $this->position = null;
     }
     // create source
     SourceEditor::create($this->name, $this->sourceDirectory, $this->buildDirectory, $this->scm, $this->url, $this->username, $this->password, $this->trustServerCert, $this->enableCheckout, $this->position);
     // call saved event
     $this->saved();
     // reset values
     $this->sourceDirectory = Source::getRandomDirectory('repository');
     $this->buildDirectory = Source::getRandomDirectory('build');
     $this->name = $this->scm = $this->url = $this->username = $this->password = '';
     $this->trustServerCert = 0;
     $this->enableCheckout = 1;
     $this->scm = 'none';
     WCF::getTPL()->assign('success', true);
 }