function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $create = $this->repository->getOption("CREATE"); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); if ($create == true) { if (!is_dir($path)) { @mkdir($path); } if (!is_dir($path)) { throw new AJXP_Exception("Cannot create root path for repository. Please check repository configuration or that your folder is writeable!"); } if ($recycle != "" && !is_dir($path . "/" . $recycle)) { @mkdir($path . "/" . $recycle); if (!is_dir($path . "/" . $recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } } } else { if (!is_dir($path)) { throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!"); } } $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $smbclientPath = $this->driverConf["SMBCLIENT"]; define('SMB4PHP_SMBCLIENT', $smbclientPath); $smbtmpPath = $this->driverConf["SMB_PATH_TMP"]; define('SMB4PHP_SMBTMP', $smbtmpPath); require_once $this->getBaseDir() . "/smb.php"; $create = $this->repository->getOption("CREATE"); $recycle = $this->repository->getOption("RECYCLE_BIN"); $this->detectStreamWrapper(true); $this->urlBase = "pydio://" . $this->repository->getId(); if ($recycle != "" && !is_dir($this->urlBase . "/" . $recycle)) { @mkdir($this->urlBase . "/" . $recycle); if (!is_dir($this->urlBase . "/" . $recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if (!function_exists('ssh2_connect')) { throw new Exception("You must have the php ssh2 extension active!"); } ConfService::setConf("PROBE_REAL_SIZE", false); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); $this->detectStreamWrapper(true); $this->urlBase = "pydio://" . $this->repository->getId(); restore_error_handler(); if (!file_exists($this->urlBase)) { if ($this->repository->getOption("CREATE")) { $test = @mkdir($this->urlBase); if (!$test) { throw new AJXP_Exception("Cannot create path ({$path}) for your repository! Please check the configuration."); } } else { throw new AJXP_Exception("Cannot find base path ({$path}) for your repository! Please check the configuration!"); } } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $wrapperData = $this->detectStreamWrapper(true); AJXP_Logger::debug("Detected wrapper data", $wrapperData); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); $consumerKey = $this->repository->getOption("CONSUMER_KEY"); $consumerSecret = $this->repository->getOption("CONSUMER_SECRET"); $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret); // TOKENS IN SESSION? if (!empty($_SESSION["OAUTH_DROPBOX_TOKENS"])) { return; } // TOKENS IN FILE ? $tokens = $this->getTokens($this->repository->getId()); if (!empty($tokens)) { $_SESSION["OAUTH_DROPBOX_TOKENS"] = $tokens; return; } // OAUTH NEGOCIATION if (isset($_SESSION['DROPBOX_NEGOCIATION_STATE'])) { $state = $_SESSION['DROPBOX_NEGOCIATION_STATE']; } else { $state = 1; } switch ($state) { case 1: $tokens = $oauth->getRequestToken(); //print_r($tokens); // Note that if you want the user to automatically redirect back, you can // add the 'callback' argument to getAuthorizeUrl. //echo "Step 2: You must now redirect the user to:\n"; $_SESSION['DROPBOX_NEGOCIATION_STATE'] = 2; $_SESSION['oauth_tokens'] = $tokens; throw new Exception("Please go to <a style=\"text-decoration:underline;\" target=\"_blank\" href=\"" . $oauth->getAuthorizeUrl() . "\">" . $oauth->getAuthorizeUrl() . "</a> to authorize the access to your dropbox. Then try again to switch to this repository."); case 2: $oauth->setToken($_SESSION['oauth_tokens']); $tokens = $oauth->getAccessToken(); $_SESSION['DROPBOX_NEGOCIATION_STATE'] = 3; $_SESSION['OAUTH_DROPBOX_TOKENS'] = $tokens; $this->setTokens($this->repository->getId(), $tokens); return; } throw new Exception("Impossible to find the tokens for accessing the dropbox repository"); }
/** * @param Repository $repoObject * @param boolean $registerStream * @return \AccessS3\S3Client */ protected static function getClientForRepository($repoObject, $registerStream = true) { require_once "aws.phar"; if (!isset(self::$clients[$repoObject->getId()])) { // Get a client $options = array('key' => $repoObject->getOption("API_KEY"), 'secret' => $repoObject->getOption("SECRET_KEY")); $signatureVersion = $repoObject->getOption("SIGNATURE_VERSION"); if (!empty($signatureVersion)) { $options['signature'] = $signatureVersion; } $baseURL = $repoObject->getOption("STORAGE_URL"); if (!empty($baseURL)) { $options["base_url"] = $baseURL; } $region = $repoObject->getOption("REGION"); if (!empty($region)) { $options["region"] = $region; } $proxy = $repoObject->getOption("PROXY"); if (!empty($proxy)) { $options['request.options'] = array('proxy' => $proxy); } $apiVersion = $repoObject->getOption("API_VERSION"); if ($apiVersion === "") { $apiVersion = "latest"; } //SDK_VERSION IS A GLOBAL PARAM ConfService::getConfStorageImpl()->_loadPluginConfig("access.s3", $globalOptions); $sdkVersion = $globalOptions["SDK_VERSION"]; //$repoObject->driverInstance->driverConf['SDK_VERSION']; if ($sdkVersion !== "v2" && $sdkVersion !== "v3") { $sdkVersion = "v2"; } if ($sdkVersion === "v3") { require_once __DIR__ . DIRECTORY_SEPARATOR . "class.pydioS3Client.php"; $s3Client = new \AccessS3\S3Client(["version" => $apiVersion, "region" => $region, "credentials" => $options]); $s3Client->registerStreamWrapper($repoObject->getId()); } else { $s3Client = Aws\S3\S3Client::factory($options); if ($repoObject->getOption("VHOST_NOT_SUPPORTED")) { // Use virtual hosted buckets when possible require_once "ForcePathStyleListener.php"; $s3Client->addSubscriber(new \Aws\S3\ForcePathStyleStyleListener()); } $s3Client->registerStreamWrapper(); } self::$clients[$repoObject->getId()] = $s3Client; } return self::$clients[$repoObject->getId()]; }
/** * @return AjxpWrapperProvider * @throws \Sabre\DAV\Exception\NotFound */ public function getAccessDriver() { if (!isset($this->accessDriver)) { //$RID = $this->repository->getId(); //ConfService::switchRootDir($RID); ConfService::getConfStorageImpl(); $this->accessDriver = ConfService::loadDriverForRepository($this->repository); if (!$this->accessDriver instanceof AjxpWrapperProvider) { throw new Sabre\DAV\Exception\NotFound($this->repository->getId()); } $this->accessDriver->detectStreamWrapper(true); } return $this->accessDriver; }
/** * initRepository */ public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } ConfService::setConf("PROBE_REAL_SIZE", false); require_once $this->getBaseDir() . "/SFTPPSL_StreamWrapper.php"; $create = $this->repository->getOption("CREATE"); $path = $this->repository->getOption("PATH"); $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); }
public function initRepository() { $wrapperData = $this->detectStreamWrapper(true); if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $recycle = $this->repository->getOption("RECYCLE_BIN"); ConfService::setConf("PROBE_REAL_SIZE", false); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $smbclientPath = $this->driverConf["SMBCLIENT"]; define('SMB4PHP_SMBCLIENT', $smbclientPath); require_once $this->getBaseDir() . "/smb.php"; $create = $this->repository->getOption("CREATE"); $recycle = $this->repository->getOption("RECYCLE_BIN"); $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); }
function init($options) { parent::init($options); $pServ = AJXP_PluginsService::getInstance(); $aPlugs = $pServ->getActivePlugins(); $accessPlugs = $pServ->getPluginsByType("access"); $this->repository = ConfService::getRepository(); foreach ($accessPlugs as $pId => $plug) { if (array_key_exists("access." . $pId, $aPlugs) && $aPlugs["access." . $pId] === true) { $this->accessDriver = $plug; if (!isset($this->accessDriver->repository)) { $this->accessDriver->init($this->repository); $this->accessDriver->initRepository(); $wrapperData = $this->accessDriver->detectStreamWrapper(true); } else { $wrapperData = $this->accessDriver->detectStreamWrapper(false); } $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); } } $this->metaStore = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore"); if ($this->metaStore !== false) { $this->metaStore->initMeta($this->accessDriver); } }
public function currentBaseUrl() { if (!isset($this->repository)) { throw new Exception("UserSelection::currentBaseUrl: cannot build nodes URL without a proper repository"); } return "pydio://" . $this->repository->getId(); }
function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if (isset($this->pluginConf["PROBE_REAL_SIZE"])) { // PASS IT TO THE WRAPPER ConfService::setConf("PROBE_REAL_SIZE", $this->pluginConf["PROBE_REAL_SIZE"]); } $create = $this->repository->getOption("CREATE"); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); if ($create == true) { if (!is_dir($path)) { @mkdir($path, 0755, true); } if (!is_dir($path)) { throw new AJXP_Exception("Cannot create root path for repository (" . $this->repository->getDisplay() . "). Please check repository configuration or that your folder is writeable!"); } if ($recycle != "" && !is_dir($path . "/" . $recycle)) { @mkdir($path . "/" . $recycle); if (!is_dir($path . "/" . $recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } } $dataTemplate = $this->repository->getOption("DATA_TEMPLATE"); if (!empty($dataTemplate) && is_dir($dataTemplate) && !is_file($path . "/.ajxp_template")) { $errs = array(); $succ = array(); $this->dircopy($dataTemplate, $path, $succ, $errs, false, false); touch($path . "/.ajxp_template"); } } else { if (!is_dir($path)) { throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!"); } } $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function isWriteable($dir, $type = "dir") { if ($this->getFilteredOption("USE_POSIX", $this->repository->getId()) == true && extension_loaded('posix')) { $real = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $dir); return posix_access($real, POSIX_W_OK); } return is_writable($dir); }
public function initRepository() { @(include_once "HTTP/WebDAV/Client.php"); if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if (!class_exists('HTTP_WebDAV_Client_Stream')) { throw new Exception("You must have Pear HTTP/WebDAV/Client package installed to use this access driver!"); } $create = $this->repository->getOption("CREATE"); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); ConfService::setConf("PROBE_REAL_SIZE", false); /* if ($create == true) { if(!is_dir($path)) @mkdir($path); if (!is_dir($path)) { throw new AJXP_Exception("Cannot create root path for repository (".$this->repository->getDisplay()."). Please check repository configuration or that your folder is writeable!"); } if ($recycle!= "" && !is_dir($path."/".$recycle)) { @mkdir($path."/".$recycle); if (!is_dir($path."/".$recycle)) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } } } else { if (!is_dir($path)) { throw new AJXP_Exception("Cannot find base path ($path) for your repository! Please check the configuration!"); } } */ $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if (!is_dir($this->urlBase)) { if (webdavAccessWrapper::$lastException) { throw webdavAccessWrapper::$lastException; } throw new AJXP_Exception("Cannot connect to the WebDAV server ({$path}). Please check the configuration!"); } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function isWriteable($dir, $type = "dir") { if ($this->getFilteredOption("USE_POSIX", $this->repository->getId()) == true && extension_loaded('posix')) { $real = AJXP_MetaStreamWrapper::getRealFSReference($dir); return posix_access($real, POSIX_W_OK); } //clearstatcache(); return is_writable($dir); }
public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $this->detectStreamWrapper(true); $this->urlBase = "pydio://" . $this->repository->getId(); if ($this->repository->getOption("MAILBOX") != "") { //$this->urlBase .= "/INBOX"; } /* if (!file_exists($this->urlBase)) { throw new AJXP_Exception("Cannot find base path for your repository! Please check the configuration!"); } */ }
/** * Repository Initialization * */ public function initRepository() { $this->detectStreamWrapper(true); if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $client = new Client(['base_url' => $this->repository->getOption("HOST")]); // Params $recycle = $this->repository->getOption("RECYCLE_BIN"); // Config ConfService::setConf("PROBE_REAL_SIZE", false); $this->urlBase = "pydio://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
/** * View the repository * */ function view() { if ($this->active_repository->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_repository->canView($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->addBreadcrumb(str_excerpt(clean($this->active_repository->getName()), 10), mobile_access_module_get_view_url($this->active_repository)); $this->addBreadcrumb(lang('View')); $per_page = 20; $page = intval(array_var($_GET, 'page')) > 0 ? array_var($_GET, 'page') : 1; list($commits, $pagination) = Commits::paginateByRepository($this->active_repository, $page, $per_page); $commits = group_by_date($commits); $this->smarty->assign(array('pagination' => $pagination, 'commits' => $commits, 'pagination_url' => assemble_url('mobile_access_view_repository', array('object_id' => $this->active_repository->getId(), 'project_id' => $this->active_project->getId())), 'page_back_url' => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId())))); }
public function setTokens($oauth_tokens) { $repositoryId = $this->repository->getId(); if (AuthService::usersEnabled()) { $userId = AuthService::getLoggedUser()->getId(); } else { $userId = "shared"; } return AJXP_Utils::saveSerialFile(AJXP_DATA_PATH . "/plugins/access.dropbox/" . $repositoryId . "_" . $userId . "_tokens", $oauth_tokens, true); }
public function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } require_once $this->getBaseDir() . "/openstack-sdk-php/vendor/autoload.php"; Bootstrap::useStreamWrappers(); Bootstrap::setConfiguration(array('username' => $this->repository->getOption("USERNAME"), 'password' => $this->repository->getOption("PASSWORD"), 'tenantid' => $this->repository->getOption("TENANT_ID"), 'endpoint' => $this->repository->getOption("ENDPOINT"), 'openstack.swift.region' => $this->repository->getOption("REGION"), 'transport.ssl.verify' => false)); $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); ConfService::setConf("PROBE_REAL_SIZE", false); $this->detectStreamWrapper(true); $this->urlBase = "pydio://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
function initRepository() { if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } if (!function_exists('ssh2_connect')) { throw new Exception("You must have the php ssh2 extension active!"); } $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if (!is_dir($this->urlBase)) { throw new AJXP_Exception("Cannot find base path ({$path}) for your repository! Please check the configuration!"); } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function init($options) { parent::init($options); $this->repository = ConfService::getRepository(); if (!is_a($this->repository->driverInstance, "AjxpWrapperProvider")) { return; } $this->accessDriver = $this->repository->driverInstance; $this->urlBase = "pydio://" . $this->repository->getId(); if (array_key_exists("meta.watch", AJXP_PluginsService::getInstance()->getActivePlugins())) { $this->watcher = AJXP_PluginsService::getInstance()->getPluginById("meta.watch"); } }
public function initRepository() { require_once $this->getBaseDir() . "/aS3StreamWrapper/lib/wrapper/aS3StreamWrapper.class.php"; if (!in_array("s3", stream_get_wrappers())) { $wrapper = new aS3StreamWrapper(); $wrapper->register(array('protocol' => 's3', 'acl' => AmazonS3::ACL_OWNER_FULL_CONTROL, 'key' => $this->repository->getOption("API_KEY"), 'secretKey' => $this->repository->getOption("SECRET_KEY"), 'region' => $this->repository->getOption("REGION"))); } if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $path = $this->repository->getOption("PATH"); $recycle = $this->repository->getOption("RECYCLE_BIN"); ConfService::setConf("PROBE_REAL_SIZE", false); $wrapperData = $this->detectStreamWrapper(true); $this->wrapperClassName = $wrapperData["classname"]; $this->urlBase = $wrapperData["protocol"] . "://" . $this->repository->getId(); if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
public function initRepository() { $this->detectStreamWrapper(true); if (is_array($this->pluginConf)) { $this->driverConf = $this->pluginConf; } else { $this->driverConf = array(); } $recycle = $this->repository->getOption("RECYCLE_BIN"); ConfService::setConf("PROBE_REAL_SIZE", false); $this->urlBase = "pydio://" . $this->repository->getId(); if ($recycle != "" && !is_dir($this->urlBase . "/" . $recycle . "/")) { @mkdir($this->urlBase . "/" . $recycle . "/", 0777, true); if (!is_dir($this->urlBase . "/" . $recycle . "/")) { throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!"); } else { $this->setHiddenAttribute(new AJXP_Node($this->urlBase . "/" . $recycle . "/")); } } if ($recycle != "") { RecycleBinManager::init($this->urlBase, "/" . $recycle); } }
function crossRepositoryCopy($httpVars) { ConfService::detectRepositoryStreams(true); $mess = ConfService::getMessages(); $selection = new UserSelection(); $selection->initFromHttpVars($httpVars); $files = $selection->getFiles(); $accessType = $this->repository->getAccessType(); $repositoryId = $this->repository->getId(); $origStreamURL = "ajxp.{$accessType}://{$repositoryId}"; $destRepoId = $httpVars["dest_repository_id"]; $destRepoObject = ConfService::getRepositoryById($destRepoId); $destRepoAccess = $destRepoObject->getAccessType(); $destStreamURL = "ajxp.{$destRepoAccess}://{$destRepoId}"; // Check rights if (AuthService::usersEnabled()) { $loggedUser = AuthService::getLoggedUser(); if (!$loggedUser->canRead($repositoryId) || !$loggedUser->canWrite($destRepoId)) { AJXP_XMLWriter::header(); AJXP_XMLWriter::sendMessage(null, "You do not have the right to access one of the repositories!"); AJXP_XMLWriter::close(); exit(1); } } $messages = array(); foreach ($files as $file) { $origFile = $origStreamURL . $file; $destFile = $destStreamURL . $httpVars["dest"] . "/" . basename($file); $origHandler = fopen($origFile, "r"); $destHandler = fopen($destFile, "w"); if ($origHandler === false || $destHandler === false) { $errorMessages[] = AJXP_XMLWriter::sendMessage(null, $mess[114] . " ({$origFile} to {$destFile})", false); continue; } while (!feof($origHandler)) { fwrite($destHandler, fread($origHandler, 4096)); } fflush($destHandler); fclose($origHandler); fclose($destHandler); $messages[] = $mess[34] . " " . SystemTextEncoding::toUTF8(basename($origFile)) . " " . $mess[73] . " " . SystemTextEncoding::toUTF8($destFile); } AJXP_XMLWriter::header(); if (count($errorMessages)) { AJXP_XMLWriter::sendMessage(null, join("\n", $errorMessages), true); } AJXP_XMLWriter::sendMessage(join("\n", $messages), null, true); AJXP_XMLWriter::close(); exit(0); }
public function filterFolder($folderName, $compare = "equals") { $hiddenFolders = $this->getFilteredOption("HIDE_FOLDERS", $this->repository->getId()); if (!empty($hiddenFolders)) { if (!is_array($hiddenFolders)) { $hiddenFolders = explode(",", $hiddenFolders); } foreach ($hiddenFolders as $search) { if ($compare == "equals" && strcasecmp($search, $folderName) == 0) { return true; } if ($compare == "contains" && strpos($folderName, "/" . $search) !== false) { return true; } } } return false; }
/** * @static * @param GitCommand $gitCommand * @param Repository $repository * @param Branch $branch * @param bool $deleteOnly * @return void */ public static function synchronize(GitCommand $gitCommand, Repository $repository, Branch $branch, $deleteOnly = false) { $branchGit = $gitCommand->getNoMergedBranchInfos($repository->getGitDir(), $branch->getBaseBranchName(), $branch->getName()); $branchModel = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByName($branch->getName())->findOne(); if ($branchModel) { if (is_null($branchGit)) { $branchModel->delete(); } elseif (!$branchModel->getIsBlacklisted() && !$deleteOnly) { $lastSynchronizationCommit = $branchModel->getLastCommit(); $branchModel->setCommitReference($branchGit['commit_reference']); $branchModel->setLastCommit($branchGit['last_commit']); $branchModel->setLastCommitDesc($branchGit['last_commit_desc']); $branchModel->save(); return FilePeer::synchronize($gitCommand, $branchModel, $lastSynchronizationCommit); } } return 0; }
/** * Delete user mapping * * @param void * @return null */ function repository_user_delete() { if (!$this->request->isAsyncCall()) { $this->httpError(HTTP_BAD_REQUEST, null, true); } // if if (!$this->request->isSubmitted()) { $this->httpError(HTTP_BAD_REQUEST, null, true); } // if $repository_user = array_var($_POST, 'repository_user'); $source_user = SourceUsers::findByRepositoryUser($repository_user, $this->active_repository->getId()); if (!instance_of($source_user, 'SourceUser')) { die('false'); } // if $deleted = $source_user->delete(); if ($deleted && !is_error($deleted)) { die('true'); } }
/** * @param Repository $repository * @param null $resolveUserId * @return String */ protected function computeIdentifier($repository, $resolveUserId = null) { $parts = array($repository->getId()); if ($repository->securityScope() == 'USER') { if ($resolveUserId != null) { $parts[] = $resolveUserId; } else { $parts[] = AuthService::getLoggedUser()->getId(); } } else { if ($repository->securityScope() == 'GROUP') { if ($resolveUserId != null) { $userObject = ConfService::getConfStorageImpl()->createUserObject($resolveUserId); if ($userObject != null) { $parts[] = $userObject->getGroupPath(); } } else { $parts[] = AuthService::getLoggedUser()->getGroupPath(); } } } return implode("-", $parts); }
/** * See static method * @param Repository $repository * @throws AJXP_Exception|Exception * @return AbstractAccessDriver */ public function loadRepositoryDriverREST(&$repository) { if (isset($repository->driverInstance)) { return $repository->driverInstance; } $accessType = $repository->getAccessType(); $pServ = AJXP_PluginsService::getInstance(); $plugInstance = $pServ->getPluginByTypeName("access", $accessType); // TRIGGER BEFORE INIT META $metaSources = $repository->getOption("META_SOURCES"); if (isset($metaSources) && is_array($metaSources) && count($metaSources)) { $keys = array_keys($metaSources); foreach ($keys as $plugId) { if ($plugId == "") { continue; } $instance = $pServ->getPluginById($plugId); if (!is_object($instance)) { continue; } if (!method_exists($instance, "beforeInitMeta")) { continue; } try { $instance->init(AuthService::filterPluginParameters($plugId, $metaSources[$plugId], $repository->getId())); $instance->beforeInitMeta($plugInstance, $repository); } catch (Exception $e) { AJXP_Logger::error(__CLASS__, 'Meta plugin', 'Cannot instanciate Meta plugin, reason : ' . $e->getMessage()); $this->errors[] = $e->getMessage(); } } } // INIT MAIN DRIVER $plugInstance->init($repository); try { $plugInstance->initRepository(); } catch (Exception $e) { throw $e; } AJXP_PluginsService::deferBuildingRegistry(); $pServ->setPluginUniqueActiveForType("access", $accessType); // TRIGGER INIT META $metaSources = $repository->getOption("META_SOURCES"); if (isset($metaSources) && is_array($metaSources) && count($metaSources)) { $keys = array_keys($metaSources); foreach ($keys as $plugId) { if ($plugId == "") { continue; } $split = explode(".", $plugId); $instance = $pServ->getPluginById($plugId); if (!is_object($instance)) { continue; } try { $instance->init(AuthService::filterPluginParameters($plugId, $metaSources[$plugId], $repository->getId())); if (!method_exists($instance, "initMeta")) { throw new Exception("Meta Source {$plugId} does not implement the initMeta method."); } $instance->initMeta($plugInstance); } catch (Exception $e) { AJXP_Logger::error(__CLASS__, 'Meta plugin', 'Cannot instanciate Meta plugin, reason : ' . $e->getMessage()); $this->errors[] = $e->getMessage(); } $pServ->setPluginActive($split[0], $split[1]); } } AJXP_PluginsService::flushDeferredRegistryBuilding(); if (count($this->errors) > 0) { $e = new AJXP_Exception("Error while loading repository feature : " . implode(",", $this->errors)); throw $e; } $repository->driverInstance = $plugInstance; if (isset($_SESSION["REPO_ID"]) && $_SESSION["REPO_ID"] == $repository->getId()) { $this->configs["REPOSITORY"] = $repository; if (is_array($this->configs["REPOSITORIES"])) { $this->configs["REPOSITORIES"][$_SESSION['REPO_ID']] = $repository; } } return $plugInstance; }