function Docman_MetadataComparator($srcGroupId, $dstGroupId, $themePath)
 {
     $this->docmanIcons = new Docman_Icons($themePath . '/images/ic/');
     $pm = ProjectManager::instance();
     $this->srcGo = $pm->getProject($srcGroupId);
     $this->dstGo = $pm->getProject($dstGroupId);
 }
예제 #2
0
 /**
  * Constructor
  */
 public function __construct($params, ProjectManager $project_manager = null)
 {
     $this->params = $params;
     $this->_validated_input = array();
     $this->_last_access_to_input = array();
     $this->project_manager = $project_manager ? $project_manager : ProjectManager::instance();
 }
예제 #3
0
function survey_header($params)
{
    global $group_id, $is_admin_page, $Language;
    $params['toptab'] = 'survey';
    $params['group'] = $group_id;
    $pm = ProjectManager::instance();
    $project = $pm->getProject($group_id);
    if (!$project->usesSurvey()) {
        exit_error($Language->getText('global', 'error'), $Language->getText('survey_s_utils', 's_off'));
    }
    site_project_header($params);
    echo "<P><B>";
    // Admin link is displayed only if the user is a project administrator
    if (user_ismember($group_id, 'A')) {
        echo "<A HREF=\"/survey/admin/?group_id={$group_id}\">" . $Language->getText('survey_s_utils', 'admin') . "</A>";
    }
    if ($is_admin_page && $group_id && user_ismember($group_id, 'A')) {
        echo " | <A HREF=\"/survey/admin/add_survey.php?group_id={$group_id}\">" . $Language->getText('survey_admin_index', 'add_s') . "</A>";
        echo " | <A HREF=\"/survey/admin/edit_survey.php?func=browse&group_id={$group_id}\">" . $Language->getText('survey_admin_browse_survey', 'edit_s') . "</A>";
        echo " | <A HREF=\"/survey/admin/add_question.php?group_id={$group_id}\">" . $Language->getText('survey_admin_index', 'add_q') . "</A>";
        echo " | <A HREF=\"/survey/admin/edit_question.php?func=browse&group_id={$group_id}\">" . $Language->getText('survey_admin_browse_question', 'edit_q') . "</A>";
        echo " | <A HREF=\"/survey/admin/show_results.php?group_id={$group_id}\">" . $Language->getText('survey_s_utils', 'show_r') . "</A>";
    }
    if (isset($params['help'])) {
        if (user_ismember($group_id, 'A')) {
            echo ' | ';
        }
        echo help_button($params['help'], false, $Language->getText('global', 'help'));
    }
    echo "</B><P>";
}
 public function getContent()
 {
     $request =& HTTPRequest::instance();
     $group_id = $request->get('group_id');
     $pm = ProjectManager::instance();
     $project = $pm->getProject($group_id);
     $res_admin = db_query("SELECT user.user_id AS user_id,user.user_name AS user_name, user.realname as realname " . "FROM user,user_group " . "WHERE user_group.user_id=user.user_id AND user_group.group_id=" . db_ei($group_id) . " AND " . "user_group.admin_flags = 'A'");
     if (db_numrows($res_admin) > 0) {
         $user_helper = UserHelper::instance();
         $hp = Codendi_HTMLPurifier::instance();
         $em = EventManager::instance();
         echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_admins') . ':</span><br />';
         while ($row_admin = db_fetch_array($res_admin)) {
             $display_name = '';
             $em->processEvent('get_user_display_name', array('user_id' => $row_admin['user_id'], 'user_name' => $row_admin['user_name'], 'realname' => $row_admin['realname'], 'user_display_name' => &$display_name));
             if (!$display_name) {
                 $display_name = $hp->purify($user_helper->getDisplayNameFromUserId($row_admin['user_id']));
             }
             echo '<a href="/users/' . $row_admin['user_name'] . '/">' . $display_name . '</a><br />';
         }
     }
     echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_members') . ':</span><br />';
     // count of developers on this project
     $res_count = db_query("SELECT user_id FROM user_group WHERE group_id=" . db_ei($group_id));
     echo db_numrows($res_count);
     echo ' <a href="/project/memberlist.php?group_id=' . $group_id . '">[' . $GLOBALS['Language']->getText('include_project_home', 'view_members') . ']</a>';
 }
 function generate()
 {
     global $Language;
     $request =& HTTPRequest::instance();
     if ($data = $request->get('data')) {
         if (isset($data['users']['generate']) && $data['users']['generate']) {
             $um = UserManager::instance();
             $nb_wanted = isset($data['users']['nb']) ? (int) $data['users']['nb'] : 1;
             $users = $this->_getUsersData();
             reset($users);
             $nb_done = 0;
             while ((list(, $user) = each($users)) && $nb_wanted > $nb_done) {
                 if (!$um->getUserByUserName($user['name'])) {
                     require_once 'account.php';
                     account_create($user['name'], 'codendi', '', $user['realname'], '', '*****@*****.**', 'A', '', 0, 0, 'Europe/Paris', 'en_US', 'A');
                     $nb_done++;
                 }
             }
         }
         if (isset($data['projects']['generate']) && $data['projects']['generate']) {
             $nb_wanted = isset($data['projects']['nb']) ? (int) $data['projects']['nb'] : 1;
             $projects = $this->_getProjectsData();
             reset($projects);
             $nb_done = 0;
             while ((list(, $project) = each($projects)) && $nb_wanted > $nb_done) {
                 if (!group_get_object_by_name($project['name'])) {
                     $projectCreator = new ProjectCreator(ProjectManager::instance(), ReferenceManager::instance());
                     $projectCreator->create(array('project' => array('form_unix_name' => $project['name'], 'form_full_name' => $project['name'], 'form_short_description' => $project['description'], 'form_purpose' => $project['description'], 'form_required_sw' => '', 'form_patents' => '', 'form_comments' => '', 'built_from_template' => 100, 'is_test' => false, 'is_public' => true, 'trove' => array())));
                     $nb_done++;
                 }
             }
         }
     }
 }
예제 #6
0
 public function __construct()
 {
     $this->project_manager = ProjectManager::instance();
     $this->user_manager = UserManager::instance();
     $this->project_helper = new \DataInit\ProjectHelper();
     $GLOBALS['Language'] = new BaseLanguage('en_US', 'en_US');
 }
예제 #7
0
 /**
  * Constructor
  */
 function PHPWikiService($id)
 {
     global $LANG, $is_wiki_page;
     //used so the search box will add the necessary element to the pop-up box
     $is_wiki_page = 1;
     /* 
      * Check given id 
      */
     $this->gid = (int) $id;
     if (empty($this->gid)) {
         exit_no_group();
     }
     $pm = ProjectManager::instance();
     $go = $pm->getProject($this->gid);
     if (!$go) {
         exit_no_group();
     }
     $this->wiki = new PHPWiki($this->gid);
     // Check access right
     $this->checkPermissions();
     // If Wiki for project doesn't exist, propose creation ... if user is project admin or wiki admin
     if (!$this->wiki->exist()) {
         if (!user_ismember($this->gid, 'W2') && !user_ismember($this->gid, 'A')) {
             exit_wiki_empty();
         }
     }
     // Set language for phpWiki
     if ($this->wiki->getLanguage_id()) {
         define('DEFAULT_LANGUAGE', $this->wiki->getLanguage_id());
         $LANG = $this->wiki->getLanguage_id();
     }
 }
 function getContent()
 {
     $request = HTTPRequest::instance();
     $user = UserManager::instance()->getCurrentUser();
     //group id of the user is member
     $projects_id_user = $user->getProjects();
     $html = '';
     $pm = ProjectManager::instance();
     foreach ($projects_id_user as $project_id) {
         $project = $pm->getProject($project_id);
         $project_unix_name = $project->getUnixName();
         $project_public_name = $project->getPublicName();
         $members_id_array = $project->getMembersUserNames();
         if (sizeof($members_id_array) > 1) {
             list($hide_now, $count_diff, $hide_url) = my_hide_url('im_group', $project_id, $request->get('hide_item_id'), count($members_id_array), $request->get('hide_im_group'));
             $html .= $hide_url;
             $html .= '<b>' . $project_public_name . '</b><br>';
             if (!$hide_now) {
                 $html .= '<div style="padding-left:20px;">';
                 foreach ($members_id_array as $member) {
                     $html .= $this->plugin->getDisplayPresence($member['user_id'], $member['user_name'], $member['realname']);
                     $html .= '<br>';
                 }
                 $html .= '</div>';
             }
         }
     }
     return $html;
 }
 function _getItemVersionLink($version, $noLink = false)
 {
     $html = '';
     if ($version !== null) {
         $title = '';
         $url = '';
         $itemType = Docman_ItemFactory::getItemTypeForItem($this->item);
         if ($itemType == PLUGIN_DOCMAN_ITEM_TYPE_EMBEDDEDFILE || $itemType == PLUGIN_DOCMAN_ITEM_TYPE_FILE) {
             $vFactory =& new Docman_VersionFactory();
             $v = $vFactory->getSpecificVersion($this->item, $version);
             if ($v) {
                 $url = Docman_View_View::buildUrl($this->url, array('action' => 'show', 'id' => $this->item->getId(), 'version_number' => $v->getNumber()));
                 if ($v->getLabel()) {
                     $title .= $this->hp->purify($v->getLabel()) . ' - ';
                 }
             }
         } elseif ($itemType == PLUGIN_DOCMAN_ITEM_TYPE_WIKI) {
             $project_id = $this->item->getGroupId();
             $project = ProjectManager::instance()->getProject($project_id);
             $pagename = urlencode($this->item->getPagename());
             if ($project && $project->usesService('plugin_phpwiki')) {
                 $url = '/plugins/phpwiki/index.php?group_id=' . $project_id . '&pagename=' . $pagename . '&version=' . $version;
             } else {
                 $url = '/wiki/index.php?group_id=' . $project_id . '&pagename=' . $pagename . '&version=' . $version;
             }
         }
         $title .= $GLOBALS['Language']->getText('plugin_docman', 'details_approval_version_link') . ' ' . $version;
         if ($noLink) {
             $html .= $title;
         } else {
             $html .= '<a href="' . $url . '">' . $title . '</a>';
         }
     }
     return $html;
 }
 function _title($params)
 {
     $pm = ProjectManager::instance();
     $this->srcGo = $pm->getProject($params['sSrcGroupId']);
     $this->dstGo = $pm->getProject($params['group_id']);
     echo '<h2>' . $this->_getTitle($params) . ' - ' . $GLOBALS['Language']->getText('plugin_docman', 'admin_md_import_title', array($this->srcGo->getPublicName())) . '</h2>';
 }
 function displayNotificationEmail()
 {
     $html = '';
     $html .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_title') . '</h3>';
     $atsm = new Docman_ApprovalTableNotificationCycle();
     $atsm->setItem($this->item);
     $atf =& Docman_ApprovalTableFactoriesFactory::getFromItem($this->item);
     $table = $atf->getTable(false);
     $atsm->setTable($table);
     $um =& UserManager::instance();
     $owner =& $um->getUserById($table->getOwner());
     $atsm->setOwner($owner);
     $atsm->sendNotifReviewer($owner);
     $html .= $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_subject') . ' ' . $atsm->getNotificationSubject() . "\n";
     $html .= '<p class="docman_approval_email">';
     if (ProjectManager::instance()->getProject($this->item->getGroupId())->getTruncatedEmailsUsage()) {
         $html .= $GLOBALS['Language']->getText('plugin_docman', 'truncated_email');
     } else {
         $html .= htmlentities(quoted_printable_decode($atsm->getNotificationBodyText()), ENT_COMPAT, 'UTF-8');
     }
     $html .= '</p>';
     $backurl = $this->url . '&action=approval_create&id=' . $this->item->getId();
     $html .= '<a href="' . $backurl . '">' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_back') . '</a>';
     return $html;
 }
예제 #12
0
function svn_data_get_revision_detail($group_id, $commit_id, $rev_id = 0, $order = '')
{
    $order_str = "";
    if ($order) {
        if ($order != 'filename') {
            // SQLi Warning: no real possibility to escape $order here.
            // We rely on a proper filtering of user input by calling methods.
            $order_str = " ORDER BY " . $order;
        } else {
            $order_str = " ORDER BY dir, file";
        }
    }
    //check user access rights
    $pm = ProjectManager::instance();
    $project = $pm->getProject($group_id);
    $forbidden = svn_utils_get_forbidden_paths(user_getname(), $project->getSVNRootPath());
    $where_forbidden = "";
    if (!empty($forbidden)) {
        while (list($no_access, ) = each($forbidden)) {
            $where_forbidden .= " AND svn_dirs.dir not like '%" . db_es(substr($no_access, 1)) . "%' ";
        }
    }
    // if the subversion revision id is given then it akes precedence on
    // the internal commit_id (this is to make it easy for users to build
    // URL to access a revision
    if ($rev_id) {
        // To be done -> get the commit ID from the svn-commit table
        $sql = "SELECT svn_commits.description, svn_commits.date, svn_commits.revision, svn_checkins.type,svn_checkins.commitid,svn_dirs.dir,svn_files.file " . "FROM svn_dirs, svn_files, svn_checkins, svn_commits " . "WHERE svn_checkins.fileid=svn_files.id " . "AND svn_checkins.dirid=svn_dirs.id " . "AND svn_checkins.commitid=svn_commits.id " . "AND svn_commits.revision=" . db_ei($rev_id) . " " . "AND svn_commits.group_id=" . db_ei($group_id) . " " . $where_forbidden . $order_str;
    } else {
        $sql = "SELECT svn_commits.description, svn_commits.date, svn_commits.revision, svn_checkins.type,svn_checkins.commitid,svn_dirs.dir,svn_files.file " . "FROM svn_dirs, svn_files, svn_checkins, svn_commits " . "WHERE svn_checkins.fileid=svn_files.id " . "AND svn_checkins.dirid=svn_dirs.id " . "AND svn_checkins.commitid=svn_commits.id " . "AND svn_commits.id=" . db_ei($commit_id) . " " . $where_forbidden . $order_str;
    }
    $result = db_query($sql);
    return $result;
}
예제 #13
0
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
* 
* 
* 
*/
function service_create_service($arr, $group_id, $template, $force_enable = false)
{
    // Convert link to real values
    // NOTE: if you change link variables here, change them also in src/www/project/admin/servicebar.php and src/www/include/Layout.class.php
    $link = $arr['link'];
    $pm = ProjectManager::instance();
    if ($template['system']) {
        $link = str_replace('$projectname', $pm->getProject($group_id)->getUnixName(), $link);
        $link = str_replace('$sys_default_domain', $GLOBALS['sys_default_domain'], $link);
        $link = str_replace('$group_id', $group_id, $link);
        if ($GLOBALS['sys_force_ssl']) {
            $sys_default_protocol = 'https';
        } else {
            $sys_default_protocol = 'http';
        }
        $link = str_replace('$sys_default_protocol', $sys_default_protocol, $link);
    } else {
        //for non-system templates
        $link = service_replace_template_name_in_link($link, $template, $pm->getProject($group_id));
    }
    $is_used = isset($template['is_used']) ? $template['is_used'] : $arr['is_used'];
    $server_id = isset($template['server_id']) ? $template['server_id'] : $arr['server_id'];
    $sql = "INSERT INTO service (group_id, label, description, short_name, link, is_active, is_used, scope, rank, location, server_id, is_in_iframe) VALUES (" . db_ei($group_id) . ", '" . db_es($arr['label']) . "', '" . db_es($arr['description']) . "', '" . db_es($arr['short_name']) . "', '" . db_es($link) . "', " . db_ei($arr['is_active']) . ", " . ($force_enable ? 1 : db_ei($is_used)) . ", '" . db_es($arr['scope']) . "', " . db_ei($arr['rank']) . ",  '" . db_es($arr['location']) . "', " . db_ei($server_id) . ", " . db_ei($arr['is_in_iframe']) . ")";
    $result = db_query($sql);
    if ($result) {
        // activate corresponding references
        $reference_manager =& ReferenceManager::instance();
        if ($arr['short_name'] != "") {
            $reference_manager->addSystemReferencesForService($template['id'], $group_id, $arr['short_name']);
        }
        return true;
    } else {
        return false;
    }
}
    protected function aCreationValidator($request_data, $required_custom_descriptions) {
        $request = aRequest()->withParams($request_data)->build();
        $creation_request = new Project_OneStepCreation_OneStepCreationRequest($request, ProjectManager::instance());
        $validator = new Project_OneStepCreation_OneStepCreationValidator($creation_request, $required_custom_descriptions);

        return $validator;
    }
예제 #15
0
 /**
  * Constructor.
  *
  * @param Integer $groupId     Project Id
  * @param Integer $weeksNumber Statistics duration in weeks
  *
  * @return Void
  */
 public function __construct($groupId, $weeksNumber)
 {
     $dao = new GitDao();
     // TODO: Optionally include presonal forks in repo list
     $allRepositories = $dao->getProjectRepositoryList($groupId);
     $um = UserManager::instance();
     $user = $um->getCurrentUser();
     $repoFactory = new GitRepositoryFactory($dao, ProjectManager::instance());
     foreach ($allRepositories as $repo) {
         $repository = $repoFactory->getRepositoryById($repo['repository_id']);
         if ($repository->userCanRead($user)) {
             $this->repoList[] = $repository;
         }
     }
     $this->displayChart = false;
     $this->weeksNumber = min($weeksNumber, self::MAX_WEEKSNUMBER);
     // Init some class properties according to 'weeks number' parameter
     $today = $_SERVER['REQUEST_TIME'];
     $startPeriod = strtotime("-{$this->weeksNumber} weeks");
     $weekInSeconds = self::WEEKS_IN_SECONDS;
     for ($i = $startPeriod + $weekInSeconds; $i < $today + $weekInSeconds; $i += $weekInSeconds) {
         $this->dates[] = date('M d', $i);
         $this->weekNum[] = intval(date('W', $i));
         $this->year[] = intval(date('Y', $i));
     }
 }
예제 #16
0
 /**
  * @static
  * @return ProjectManager
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
예제 #17
0
 public function __construct(array $emails, $wiki_name, $subject, $body, $goto_link, $project_id)
 {
     $project_manager = ProjectManager::instance();
     $this->project = $project_manager->getProject($project_id);
     $this->mail_enhancer = new MailEnhancer();
     $subject = '[' . $wiki_name . '] ' . $subject;
     $this->notification = new Notification($emails, $subject, '', $body, $goto_link, 'Wiki');
 }
예제 #18
0
파일: git-log.php 프로젝트: nterray/tuleap
/**
 * Store details about the push in the DB
 *
 * @param String  $repositoryLocation Name of the git repository
 * @param String  $identifier     Name of the gitshell user that performed the push, retrived from whoami output.
 * @param Integer $pushTimestamp  Date of the commit
 * @param Integer $commitsNumber  Number of commits
 * @param String  $gitoliteUser   Name of the gitolite user that performed the push, retrived from environment var $GL_USER.
 *
 * @return void
 */
function logGitPushes($repositoryLocation, $identifier, $pushTimestamp, $commitsNumber, $gitoliteUser)
{
    $repoFactory = new GitRepositoryFactory(new GitDao(), ProjectManager::instance());
    $repository = $repoFactory->getFromFullPath($repositoryLocation);
    if ($repository) {
        $repository->logGitPush($identifier, $pushTimestamp, $commitsNumber, $gitoliteUser);
    }
}
예제 #19
0
 public function itCreatesAProject()
 {
     $projectCreator = new ProjectCreator(ProjectManager::instance(), ReferenceManager::instance());
     $projectCreator->create('short-name', 'Long name', array('project' => array('form_short_description' => '', 'is_test' => false, 'is_public' => false, 'services' => array(), 'built_from_template' => 100)));
     ProjectManager::clearInstance();
     $project = ProjectManager::instance()->getProjectByUnixName('short-name');
     $this->assertEqual($project->getPublicName(), 'Long name');
 }
 function Docman_View_ItemDetailsSectionPaste(&$item, $url, &$controller, $itemToPaste, $mode)
 {
     parent::Docman_View_ItemDetailsSectionActions($item, $url, false, true, $controller);
     $this->itemToPaste = $itemToPaste;
     $pm = ProjectManager::instance();
     $this->srcGo = $pm->getProject($this->itemToPaste->getGroupId());
     $this->dstGo = $pm->getProject($item->getGroupId());
     $this->mode = $mode;
 }
예제 #21
0
 public function __construct()
 {
     $this->project_manager = ProjectManager::instance();
     $this->user_manager = UserManager::instance();
     $this->user_permissions_dao = new UserPermissionsDao();
     $this->project_creator = new ProjectCreator($this->project_manager, new Rule_ProjectName(), new Rule_ProjectFullName());
     $GLOBALS['Language'] = new BaseLanguage('en_US', 'en_US');
     $GLOBALS['sys_lf'] = '\\n';
 }
예제 #22
0
 /**
  * Declares itself as accepting RDF XML on /projects/...
  * @param unknown_type $params
  */
 function project_rdf_metadata(&$params)
 {
     # TODO : create another resource
     $group_id = $params['group'];
     $new_prefixes = array('admssw' => 'http://purl.org/adms/sw/', 'rad' => 'http://www.w3.org/ns/radion#', 'schema' => 'http://schema.org/');
     foreach ($new_prefixes as $s => $u) {
         if (!isset($params['prefixes'][$u])) {
             $params['prefixes'][$u] = $s;
         }
     }
     $res = $params['in_Resource'];
     // we could save the type doap:Project in such case, as there's an equivalence, but not sure all consumers do reasoning
     $types = array('doap:Project', 'admssw:SoftwareProject');
     rdfutils_setPropToUri($res, 'rdf:type', $types);
     $tags_list = NULL;
     if (forge_get_config('use_project_tags')) {
         $group = group_get_object($group_id);
         $tags_list = $group->getTags();
     }
     // connect to FusionForge internals
     $pm = ProjectManager::instance();
     $project = $pm->getProject($group_id);
     $tags = array();
     if ($tags_list) {
         $tags = split(', ', $tags_list);
         // reuse the same as dcterms:subject until further specialization of adms.sw keywords
         $res->setProp('rad:keyword', $tags);
     }
     $project_description = $project->getDescription();
     if ($project_description) {
         // it seems that doap:description is not equivalent to dcterms:description, so repeat
         $res->setProp('dcterms:description', $project_description);
     }
     $res->setProp('rdfs:comment', "Generated with the doaprdf and admssw plugins of fusionforge");
     rdfutils_setPropToUri($res, 'dcterms:isPartOf', util_make_url("/projects"));
     $admins = $project->getAdmins();
     $members = $project->getUsers();
     $contributors_uris = array();
     foreach ($admins as $u) {
         $contributor_uri = util_make_url_u($u->getUnixName(), $u->getID());
         $contributor_uri = rtrim($contributor_uri, '/');
         $contributor_uri = $contributor_uri . '#person';
         if (!in_array($contributor_uri, $contributors_uris)) {
             $contributors_uris[] = $contributor_uri;
         }
     }
     foreach ($members as $u) {
         $contributor_uri = util_make_url_u($u->getUnixName(), $u->getID());
         $contributor_uri = rtrim($contributor_uri, '/');
         $contributor_uri = $contributor_uri . '#person';
         if (!in_array($contributor_uri, $contributors_uris)) {
             $contributors_uris[] = $contributor_uri;
         }
     }
     rdfutils_setPropToUri($res, 'schema:contributor', $contributors_uris);
     $params['out_Resources'][] = $res;
 }
 function visitWiki(&$item, $params = array())
 {
     $project_id = $item->getGroupId();
     $project = ProjectManager::instance()->getProject($project_id);
     $pagename = urlencode($item->getPagename());
     if ($project && $project->usesService('plugin_phpwiki')) {
         return '/plugins/phpwiki/?group_id=' . $project_id . '&pagename=' . $pagename;
     }
     return '/wiki/?group_id=' . $project_id . '&pagename=' . $pagename;
 }
 function Widget_ProjectLatestFileReleases()
 {
     $this->Widget('projectlatestfilereleases');
     $request =& HTTPRequest::instance();
     $pm = ProjectManager::instance();
     $project = $pm->getProject($request->get('group_id'));
     if ($project && $this->canBeUsedByProject($project)) {
         $this->content = $project->getService(Service::FILE)->getSummaryPageContent();
     }
 }
예제 #25
0
 private function getServices()
 {
     $services = array();
     $template = \ProjectManager::instance()->getProject(100);
     foreach ($template->getServices() as $key => $service) {
         $is_used = $service->isActive() && $service->isUsed();
         $services[$service->getId()]['is_used'] = $is_used;
     }
     return $services;
 }
 public function getContent()
 {
     $html = '';
     $uh = UserHelper::instance();
     $request = HTTPRequest::instance();
     $hp = Codendi_HTMLPurifier::instance();
     $user = UserManager::instance()->getCurrentUser();
     $pm = ProjectManager::instance();
     $project_ids = $user->getProjects();
     foreach ($project_ids as $project_id) {
         $project = $pm->getProject($project_id);
         if ($project->usesSVN()) {
             list($hide_now, $count_diff, $hide_url) = my_hide_url('my_svn_group', $project_id, $request->get('hide_item_id'), count($project_ids), $request->get('hide_my_svn_group'));
             $html .= $hide_url;
             $html .= '<strong>' . $project->getPublicName() . '</strong>';
             if (!$hide_now) {
                 list($latest_revisions, $nb_revisions) = svn_get_revisions($project, 0, $this->_nb_svn_commits, '', $user->getUserName(), '', '', 0, false);
                 if (db_numrows($latest_revisions) > 0) {
                     $i = 0;
                     while ($data = db_fetch_array($latest_revisions)) {
                         $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">';
                         $html .= '<div style="font-size:0.98em;">';
                         $html .= '<a href="' . $this->_getLinkToCommit($project->getGroupId(), $data['revision']) . '">rev #' . $data['revision'] . '</a>';
                         $html .= ' ' . $GLOBALS['Language']->getText('my_index', 'my_latest_svn_commit_on') . ' ';
                         //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp
                         $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date']));
                         $html .= ' ' . $GLOBALS['Language']->getText('my_index', 'my_latest_svn_commit_by') . ' ';
                         if (isset($data['whoid'])) {
                             $name = $uh->getDisplayNameFromUserId($data['whoid']);
                         } else {
                             $name = $uh->getDisplayNameFromUserName($data['who']);
                         }
                         $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML);
                         $html .= '</div>';
                         $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">';
                         $html .= util_make_links(substr($data['description'], 0, 255), $project->getGroupId());
                         if (strlen($data['description']) > 255) {
                             $html .= '&nbsp;[...]';
                         }
                         $html .= '</div>';
                         $html .= '</div>';
                     }
                     $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">';
                     $html .= '<a href="' . $this->_getLinkToMore($project->getGroupId(), $user->getUserName()) . '">[ More ]</a>';
                     $html .= '</div>';
                 } else {
                     $html .= '<div></div>';
                 }
             } else {
                 $html .= '<div></div>';
             }
         }
     }
     return $html;
 }
 function Widget_ProjectLatestNews()
 {
     $this->Widget('projectlatestnews');
     $request =& HTTPRequest::instance();
     $pm = ProjectManager::instance();
     $project = $pm->getProject($request->get('group_id'));
     if ($project && $this->canBeUsedByProject($project)) {
         require_once 'www/news/news_utils.php';
         $this->content = news_show_latest($request->get('group_id'), 10, false);
     }
 }
 function getLatestRevisions()
 {
     if (!$this->latest_revisions) {
         $pm = ProjectManager::instance();
         $project = $pm->getProject($this->group_id);
         if ($project && $this->canBeUsedByProject($project)) {
             list($this->latest_revisions, ) = svn_get_revisions($project, 0, 5, '', '', '', '', 0, false);
         }
     }
     return $this->latest_revisions;
 }
예제 #29
0
 public function __construct(GitPlugin $plugin)
 {
     parent::__construct();
     $this->userManager = UserManager::instance();
     $this->projectManager = ProjectManager::instance();
     $this->factory = new GitRepositoryFactory(new GitDao(), $this->projectManager);
     $matches = array();
     if (preg_match_all('/^\\/plugins\\/git\\/index.php\\/(\\d+)\\/([^\\/][a-zA-Z]+)\\/([a-zA-Z\\-\\_0-9]+)\\/\\?{0,1}.*/', $_SERVER['REQUEST_URI'], $matches)) {
         $this->request->set('group_id', $matches[1][0]);
         $this->request->set('action', $matches[2][0]);
         $repo_id = 0;
         //repository id is passed
         if (preg_match('/^([0-9]+)$/', $matches[3][0]) === 1) {
             $repo_id = $matches[3][0];
         } else {
             //get repository by name and group id to retrieve repo id
             $repo = new GitRepository();
             $repo->setName($matches[3][0]);
             $repo->setProject($this->projectManager->getProject($matches[1][0]));
             try {
                 $repo->load();
             } catch (Exception $e) {
                 $this->addError('Bad request');
                 $this->redirect('/');
             }
             $repo_id = $repo->getId();
         }
         $this->request->set('repo_id', $repo_id);
     }
     $this->plugin = $plugin;
     $valid = new Valid_GroupId('group_id');
     $valid->required();
     if ($this->request->valid($valid)) {
         $this->groupId = (int) $this->request->get('group_id');
     }
     $valid = new Valid_String('action');
     $valid->required();
     if ($this->request->valid($valid)) {
         $this->action = $this->request->get('action');
     }
     if (empty($this->action)) {
         $this->action = 'index';
     }
     if (empty($this->groupId)) {
         $this->addError('Bad request');
         $this->redirect('/');
     }
     $this->projectName = $this->projectManager->getProject($this->groupId)->getUnixName();
     if (!PluginManager::instance()->isPluginAllowedForProject($this->plugin, $this->groupId)) {
         $this->addError($this->getText('project_service_not_available'));
         $this->redirect('/projects/' . $this->projectName . '/');
     }
     $this->permittedActions = array();
 }
 function getLatestRevisions()
 {
     if (!$this->latest_revisions) {
         $pm = ProjectManager::instance();
         $project = $pm->getProject($this->group_id);
         if ($project && $this->canBeUsedByProject($project)) {
             $get_commits_callback = $this->commits_callback;
             list($this->latest_revisions, ) = $get_commits_callback($project, 0, 5);
         }
     }
     return $this->latest_revisions;
 }