public function __construct($controller, Git_GitRepositoryUrlManager $url_manager, Git_Mirror_MirrorDataMapper $mirror_data_mapper, GitPermissionsManager $permissions_manager) { parent::__construct($controller); $this->groupId = (int) $this->request->get('group_id'); $this->project = ProjectManager::instance()->getProject($this->groupId); $this->projectName = $this->project->getUnixName(); $this->userName = $this->user->getName(); $this->git_permissions_manager = $permissions_manager; $this->ugroup_manager = new UGroupManager(); $this->url_manager = $url_manager; $this->mirror_data_mapper = $mirror_data_mapper; }
public function sendMail(PFUser $user, Project $project, $tv3_id, $tracker_name) { $mail = new Codendi_Mail(); $breadcrumbs = array(); $breadcrumbs[] = '<a href="' . get_server_url() . '/projects/' . $project->getUnixName(true) . '" />' . $project->getPublicName() . '</a>'; $mail->getLookAndFeelTemplate()->set('breadcrumbs', $breadcrumbs); $mail->addAdditionalHeader("X-Codendi-Project", $project->getUnixName()); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setTo($user->getEmail()); $mail->setSubject('Output of your migration TV3 -> TV5'); $mail->setBody($this->getMailBody($tv3_id, $tracker_name)); $mail->send(); $this->purgeLogStack(); }
/** * @return string */ function service_replace_template_name_in_link($link, array $template, Project $project) { $link = preg_replace('#(/www/|/projects/|group=)' . $template['name'] . '(/|&|$)#', '$1' . $project->getUnixName() . '$2', $link); $link = preg_replace('/group_id=' . $template['id'] . '([^\\d]|$)/', 'group_id=' . $project->getGroupId() . '$1', $link); EventManager::instance()->processEvent(Event::SERVICE_REPLACE_TEMPLATE_NAME_IN_LINK, array('link' => &$link, 'template' => $template, 'project' => $project)); return $link; }
public function __construct(Project $project, PFUser $pfuser, $suffix) { parent::__construct($pfuser->toRow()); $this->setStatus(PFUser::STATUS_RESTRICTED); $this->setRealName(self::REAL_NAME); $this->setUserName(self::NAME_PREFIX . $project->getUnixName() . $suffix); $this->project = $project; }
public function __construct(Project $project, $count, $checked) { $this->label = $project->getUnixName(); $this->count = $count; $this->value = $project->getGroupId(); if ($checked) { $this->checked = 'checked="checked"'; } }
/** * Return SVN path the user is not allowed to see * * @param User $user * * @return string */ protected function getForbiddenPaths(User $user) { $forbidden = svn_utils_get_forbidden_paths($user->getName(), $this->project->getUnixName(false)); $where_forbidden = ""; foreach ($forbidden as $no_access => $v) { $where_forbidden .= " AND svn_dirs.dir not like '" . db_es(substr($no_access, 1)) . "%'"; } return $where_forbidden; }
/** * @param string $project */ public function __construct(Project $project) { $this->logger = new BackendLogger(); $this->project = $project; $this->project_name = $project->getUnixName(); $this->project_id = $project->getID(); $this->dao = new MediawikiDao(); $this->resource_restrictor = new MediawikiSiteAdminResourceRestrictor(new MediawikiSiteAdminResourceRestrictorDao(), ProjectManager::instance()); }
private function importLanguage(Project $project, $language) { $this->logger->info("Set language to {$language} for {$project->getUnixName()}"); try { $this->language_manager->saveLanguageOption($project, $language); } catch (Mediawiki_UnsupportedLanguageException $e) { $this->logger->warn("Could not set up the language for {$project->getUnixName()} mediawiki, {$language} is not sopported."); } }
protected function fetchReposConfig(Project $project, GitRepository $repository) { $repo_full_name = $this->repoFullName($repository, $project->getUnixName()); $repo_config = 'repo ' . $repo_full_name . PHP_EOL; $repo_config .= $this->fetchMailHookConfig($project, $repository); $repo_config .= $this->permissions_serializer->getForRepository($repository); $description = preg_replace("%\\s+%", ' ', $repository->getDescription()); $repo_config .= "{$repo_full_name} = \"{$description}\"" . PHP_EOL; return $repo_config . PHP_EOL; }
public function createProjectWithPermissionsOnly(Git_RemoteServer_GerritServer $server, Project $project, $admin_group_name) { try { $parent_project_name = $project->getUnixName(); $this->logger->info("Gerrit REST driver: Create parent project {$parent_project_name}"); $this->sendRequest($server, $this->guzzle_client->put($this->getGerritURL($server, '/projects/' . urlencode($parent_project_name)), $this->getRequestOptions(array(self::HEADER_CONTENT_TYPE => self::MIME_JSON)), json_encode(array('description' => "Migration of {$parent_project_name} from Tuleap", 'permissions_only' => true, 'owners' => array($admin_group_name))))); $this->logger->info("Gerrit: Permissions-only project {$parent_project_name} successfully initialized"); } catch (Exception $exception) { $this->throwGerritException("Gerrit: Permissions-only project {$parent_project_name} not created: " . $exception->getMessage()); } }
private function makeGerritProjectReadOnly(GitRepository $repository, Git_RemoteServer_GerritServer $server, Project $project) { try { $this->driver_factory->getDriver($server)->makeGerritProjectReadOnly($server, $project->getUnixName() . '/' . $repository->getName()); } catch (Exception $e) { $this->error($e->getMessage() . $e->getTraceAsString()); return false; } $this->done(); return true; }
/** * Check that the service is used and the plugin is allowed for project $project * if it is not the case then exit with an error * * @param Project $project * @param Codendi_Request $request * * @return bool true if success. Otherwise the process terminates. */ public function checkServiceEnabled(Project $project, Codendi_Request $request) { if ($project->usesService('plugin_tracker')) { return true; } header("HTTP/1.0 404 Not Found"); if (!$request->isAjax()) { $GLOBALS['Response']->addFeedback('error', "The project doesn't use the 'tracker v5' service"); $GLOBALS['HTML']->redirect('/projects/' . $project->getUnixName() . '/'); } exit; }
public function getSvnPath(User $user, Project $project, $svn_path) { $paths = array(); $repository_path = $GLOBALS['svn_prefix'] . '/' . $project->getUnixName(); $content = $this->getDirectoryListing($repository_path, $svn_path); foreach ($content as $line) { if ($this->svn_permissions_manager->userCanRead($user, $project, $line)) { $paths[] = $this->extractDirectoryContent($line, $svn_path); } } return array_filter($paths); }
/** * @param Project|string $project * @param MediawikiManager $mediawiki_manager * @param MediawikiLanguageManager $language_manager * @param MediawikiVersionManager $version_manager * @param MediawikiMLEBExtensionManager $mleb_manager */ public function __construct(Project $project, MediawikiManager $mediawiki_manager, MediawikiLanguageManager $language_manager, MediawikiVersionManager $version_manager, MediawikiMLEBExtensionManager $mleb_manager) { $this->logger = new BackendLogger(); $this->project = $project; $this->project_name = $project->getUnixName(); $this->project_id = $project->getID(); $this->dao = new MediawikiDao(); $this->mediawiki_manager = $mediawiki_manager; $this->language_manager = $language_manager; $this->version_manager = $version_manager; $this->mleb_manager = $mleb_manager; $this->resource_restrictor = new MediawikiSiteAdminResourceRestrictor(new MediawikiSiteAdminResourceRestrictorDao(), ProjectManager::instance()); }
/** * Get the HTML output for current binding * * @param Project $currentProject Project of the currently bound ugroup * @param ProjectUGroup $currentSource Currently bound ugroup * * @return String */ private function getCurrentBindingHTML(Project $currentProject = null, ProjectUGroup $currentSource = null) { if ($currentSource) { $currentBindHTML = ''; if ($currentSource && $currentProject->userIsAdmin()) { $currentBindHTML .= $GLOBALS['Language']->getText('project_ugroup_binding', 'current_binded', array('<a href="/project/admin/editugroup.php?group_id=' . $currentProject->getID() . '&ugroup_id=' . $currentSource->getId() . '&func=edit" ><b>' . $currentSource->getName() . '</b></a>', '<a href="/projects/' . $currentProject->getUnixName() . '" ><b>' . $currentProject->getPublicName() . '</b></a>')); } $currentBindHTML .= '<form action="" method="post"><input type="hidden" name="action" value="remove_binding" /><input type="submit" value="' . $GLOBALS['Language']->getText('project_ugroup_binding', 'remove_binding') . '"/></form>'; } else { $currentBindHTML = $GLOBALS['Language']->getText('project_ugroup_binding', 'no_binding'); } return $currentBindHTML; }
private function exportProjectInfo(Project $project, SimpleXMLElement $project_node) { $access_value = $project->isPublic() ? Project::ACCESS_PUBLIC : Project::ACCESS_PRIVATE; $project_node->addAttribute('unix-name', $project->getUnixName()); $project_node->addAttribute('full-name', $project->getPublicName()); $project_node->addAttribute('description', $project->getDescription()); $project_node->addAttribute('access', $access_value); $project_node->addChild('long-description', ''); $services_node = $project_node->addChild('services'); foreach ($project->getServices() as $service) { $service_node = $services_node->addChild('service'); $service_node->addAttribute('shortname', $service->getShortName()); $service_node->addAttribute('enabled', $service->isUsed()); } }
/** * Return a reference that match keyword and value * @param Project $project * @param String $keyword * @param String $value * @return Reference */ public function getReference(Project $project, $keyword, $value) { $reference = false; list($repository_name, $sha1) = $this->splitRepositoryAndSha1($value); $repository = $this->repository_factory->getRepositoryByPath($project->getId(), $project->getUnixName() . '/' . $repository_name . '.git'); if ($repository) { $args = array($repository->getId(), $sha1); $reference = $this->reference_manager->loadReferenceFromKeywordAndNumArgs($keyword, $project->getID(), count($args), $value); if ($reference) { $reference->setLink($reference->getLink() . '&p=' . $repository_name); $reference->replaceLink($args); } } return $reference; }
public function displayHeader($title, $breadcrumbs, $toolbar) { $GLOBALS['HTML']->setRenderedThroughService(true); $breadcrumbs = array_merge(array(array('title' => $this->project->getPublicName(), 'url' => '/projects/' . $this->project->getUnixName() . '/')), $breadcrumbs); foreach ($breadcrumbs as $b) { $classname = ''; if (isset($b['classname'])) { $classname = 'class="breadcrumb-step-' . $b['classname'] . '"'; } $GLOBALS['HTML']->addBreadcrumb('<a href="' . $b['url'] . '" ' . $classname . '>' . $b['title'] . '</a>'); } foreach ($toolbar as $t) { $class = isset($t['class']) ? 'class="' . $t['class'] . '"' : ''; $item_title = isset($t['short_title']) ? $t['short_title'] : $t['title']; $GLOBALS['HTML']->addToolbarItem('<a href="' . $t['url'] . '" ' . $class . '>' . $item_title . '</a>'); } $params = array('title' => $title, 'group' => $this->project->group_id, 'toptab' => $this->getId()); if ($pv = (int) HTTPRequest::instance()->get('pv')) { $params['pv'] = (int) $pv; } $this->displayDuplicateInheritanceWarning(); site_project_header($params); }
/** * Update the http_domain and service when renaming the group * @param Project $project * @param String $new_name * @return Boolean */ public function renameProject($project, $new_name) { //Update 'groups' table $sql = ' UPDATE groups SET unix_group_name= ' . $this->da->quoteSmart($new_name) . ' , http_domain=REPLACE (http_domain,' . $this->da->quoteSmart($project->getUnixName(false)) . ',' . $this->da->quoteSmart($new_name) . ') WHERE group_id= ' . $this->da->quoteSmart($project->getID()); $res_groups = $this->update($sql); //Update 'service' table if ($res_groups) { $sql_summary = ' UPDATE service SET link= REPLACE (link,' . $this->da->quoteSmart($project->getUnixName()) . ',' . $this->da->quoteSmart(strtolower($new_name)) . ') WHERE short_name="summary" AND group_id= ' . $this->da->quoteSmart($project->getID()); $res_summary = $this->update($sql_summary); if ($res_summary) { $sql_homePage = ' UPDATE service SET link= REPLACE (link,' . $this->da->quoteSmart($project->getUnixName()) . ',' . $this->da->quoteSmart(strtolower($new_name)) . ') WHERE short_name="homepage" AND group_id= ' . $this->da->quoteSmart($project->getID()); return $this->update($sql_homePage); } } return false; }
/** * Rename anon ftp project homedir (following project unix_name change) * * @param Project $project a project * @param String $newName a new name * * @return boolean */ public function renameAnonFtpDirectory($project, $newName) { if (is_dir($GLOBALS['ftp_anon_dir_prefix'] . '/' . $project->getUnixName(false))) { return rename($GLOBALS['ftp_anon_dir_prefix'] . '/' . $project->getUnixName(false), $GLOBALS['ftp_anon_dir_prefix'] . '/' . $newName); } else { return true; } }
public function renameProject(Project $project, $newName) { if (is_dir(Git_Backend_Interface::GIT_ROOT_PATH . '/' . $project->getUnixName())) { return rename(Git_Backend_Interface::GIT_ROOT_PATH . '/' . $project->getUnixName(), Git_Backend_Interface::GIT_ROOT_PATH . '/' . $newName); } return true; }
private function getProjectLink(Project $project) { return '/projects/' . $project->getUnixName() . '/'; }
private function updateMediawikiDirectory(Project $project) { $logger = new BackendLogger(); $project_id_dir = forge_get_config('projects_path', 'mediawiki') . "/" . $project->getID(); if (is_dir($project_id_dir)) { return true; } $project_name_dir = forge_get_config('projects_path', 'mediawiki') . "/" . $project->getUnixName(); if (is_dir($project_name_dir)) { exec("mv {$project_name_dir} {$project_id_dir}"); return true; } $logger->error('Project Rename: Can\'t find mediawiki directory for project: ' . $project->getID()); return false; }
public function renameProject(Project $project, $newName) { $oldPath = $this->da->quoteSmart($project->getUnixName() . '/'); $newPath = $this->da->quoteSmart($newName . '/'); $sql = 'UPDATE ' . $this->getTable() . ' SET ' . self::REPOSITORY_PATH . ' = REPLACE (' . self::REPOSITORY_PATH . ',' . $oldPath . ',' . $newPath . ') ' . ' WHERE ' . self::FK_PROJECT_ID . ' = ' . $this->da->escapeInt($project->getId()); return $this->update($sql); }
private function createDirectory(Project $project) { $this->getProftpdSystemEventManager()->queueDirectoryCreate($project->getUnixName()); $this->getProftpdSystemEventManager()->queueACLUpdate($project->getUnixName()); }
public function __construct(Project $project) { $this->project_name = util_unconvert_htmlspecialchars($project->getPublicName()); $this->project_uri = '/projects/' . $project->getUnixName(); }
private function importContent(Project $project, SimpleXMLElement $xml_element, $extraction_path) { $this->logger->info("Importing project in project " . $project->getUnixName()); $this->importUgroups($project, $xml_element); $svn = new SVNXMLImporter($this->logger, $this->xml_validator); $svn->import($project, $xml_element, $extraction_path); $frs = new FRSXMLImporter($this->logger, $this->xml_validator, new FRSPackageFactory(), new FRSReleaseFactory(), new FRSFileFactory(), $this->user_finder, new UGroupManager()); $frs->import($project, $xml_element, $extraction_path); $this->logger->info("Ask to plugin to import data from XML"); $this->event_manager->processEvent(Event::IMPORT_XML_PROJECT, array('logger' => $this->logger, 'project' => $project, 'xml_content' => $xml_element, 'extraction_path' => $extraction_path, 'user_finder' => $this->user_finder)); $this->logger->info("Finish importing project in project " . $project->getUnixName()); }
/** * * @param Git_RemoteServer_GerritServer $server * @param Project $project * @param String $admin_group_name * @return String Gerrit project name */ public function createProjectWithPermissionsOnly(Git_RemoteServer_GerritServer $server, Project $project, $admin_group_name) { $project_parent_name = $project->getUnixName(); $command = implode(' ', array(self::COMMAND, 'create-project --permissions-only', $project_parent_name, '--owner', $admin_group_name)); return $this->actionCreateProject($server, $command, $project_parent_name); }
private function deleteGerritProject(GitRepository $repository, Git_RemoteServer_GerritServer $server, Project $project, $backend) { try { $this->driver_factory->getDriver($server)->deleteProject($server, $project->getUnixName() . '/' . $repository->getName()); $backend->setGerritProjectAsDeleted($repository); } catch (Exception $e) { $this->error($e->getMessage() . $e->getTraceAsString()); return false; } $this->done(); return true; }
public function userCanRead(User $user, Project $project, $svnpath) { include_once 'www/svn/svn_utils.php'; return svn_utils_check_access($user->getUserName(), $project->getUnixName(), $svnpath); }