Example #1
0
function docman_header($title, $pagehead, $style = 'xyz')
{
    global $group_id, $HTML, $sys_use_docman;
    if (!$sys_use_docman) {
        exit_disabled();
    }
    $project =& group_get_object($group_id);
    if (!$project || !is_object($project)) {
        exit_no_group();
    }
    if (!$project->usesDocman()) {
        exit_error(_('Error'), _('This project has turned off the Doc Manager.'));
    }
    site_project_header(array('title' => $title, 'group' => $group_id, 'toptab' => 'docman'));
    $menu_text = array();
    $menu_links = array();
    $menu_text[] = _('Submit new documentation');
    $menu_links[] = '/docman/new.php?group_id=' . $group_id;
    $menu_text[] = _('View Documentation');
    $menu_links[] = '/docman/index.php?group_id=' . $group_id;
    $menu_text[] = _('Search in documents');
    $menu_links[] = '/docman/search.php?group_id=' . $group_id;
    if (session_loggedin()) {
        $perm =& $project->getPermission(session_get_user());
        if ($perm && is_object($perm) && !$perm->isError() && $perm->isDocEditor()) {
            $menu_text[] = _('Admin');
            $menu_links[] = '/docman/admin/index.php?group_id=' . $group_id;
        }
    }
    echo $HTML->subMenu($menu_text, $menu_links);
}
 /**
  * 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();
     }
 }
Example #3
0
function display_groups_option($group_id = false, $checkedval = 'xyxy')
{
    if (!$group_id) {
        exit_no_group();
    } else {
        $query = "select doc_group, groupname " . "from doc_groups " . "where group_id = {$group_id} " . "order by groupname";
        $result = db_query($query);
        echo html_build_select_box($result, 'doc_group', $checkedval);
    }
    //end else
}
function pm_header($params)
{
    // XXX ogi: What to do with these?
    global $group_id, $is_pm_page, $words, $group_project_id, $HTML, $order, $pg, $sys_use_pm;
    if (!$sys_use_pm) {
        exit_disabled();
    }
    //required by site_project_header
    $params['group'] = $group_id;
    $params['toptab'] = 'pm';
    //only projects can use the bug tracker, and only if they have it turned on
    $project =& group_get_object($group_id);
    if (!$project || !is_object($project)) {
        exit_no_group();
    }
    if (!$project->usesPm()) {
        exit_error(_('Error'), _('This Project Has Turned Off The Task Manager'));
    }
    site_project_header($params);
    $labels = array();
    $links = array();
    if ($group_project_id) {
        $labels[] = ($pg ? $pg->getName() . ': ' : '') . _('Browse tasks');
        $links[] = '/pm/task.php?group_id=' . $group_id . '&group_project_id=' . $group_project_id . '&func=browse';
        if (session_loggedin()) {
            $labels[] = _('Add task');
            $links[] = '/pm/task.php?group_id=' . $group_id . '&group_project_id=' . $group_project_id . '&func=addtask';
        }
        if ($group_project_id) {
            $gantt_width = 820;
            $gantt_height = 680;
            $gantt_url = "/pm/task.php?group_id={$group_id}&group_project_id={$group_project_id}&func=ganttpage";
            $gantt_title = _('Gantt Chart');
            $gantt_winopt = 'scrollbars=yes,resizable=yes,toolbar=no,height=' . $gantt_height . ',width=' . $gantt_width;
            $labels[] = $gantt_title;
            $links[] = $gantt_url . '" onclick="window.open(this.href, \'' . preg_replace('/\\s/', '_', $gantt_title) . '\', \'' . $gantt_winopt . '\'); return false;';
        }
        //upload/download as CSV files
        $labels[] = _('Download as CSV');
        $links[] = '/pm/task.php?group_id=' . $group_id . '&group_project_id=' . $group_project_id . '&func=downloadcsv';
        $labels[] = _('Upload CSV');
        $links[] = '/pm/task.php?group_id=' . $group_id . '&group_project_id=' . $group_project_id . '&func=uploadcsv';
    }
    if ($pg && is_object($pg) && $pg->userIsAdmin()) {
        $labels[] = _('Reporting');
        $links[] = '/pm/reporting/?group_id=' . $group_id;
        $labels[] = _('Admin');
        $links[] = '/pm/admin/?group_id=' . $group_id . '&group_project_id=' . $group_project_id . '&update_pg=1';
    }
    if (!empty($labels)) {
        echo $HTML->subMenu($labels, $links);
    }
}
 function PHPWikiServiceAdmin($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;
     $this->gid = (int) $id;
     if (empty($this->gid)) {
         exit_no_group();
     }
     if (!user_ismember($this->gid, 'W2')) {
         exit_permission_denied();
     }
     $this->wiki = new PHPWiki($this->gid);
     // If Wiki for project doesn't exist, propose creation...
     if (!$this->wiki->exist()) {
         header('Location: ' . PHPWIKI_PLUGIN_BASE_URL . '/index.php?group_id=' . $this->gid . '&view=install');
     }
     // Set language for phpWiki
     if ($this->wiki->getLanguage_id()) {
         define('DEFAULT_LANGUAGE', $this->wiki->getLanguage_id());
         $LANG = $this->wiki->getLanguage_id();
     }
 }
Example #6
0
function frs_header($params)
{
    global $group_id, $HTML, $sys_use_frs;
    /*
    	Does this site use FRS?
    */
    if (!$sys_use_frs) {
        exit_disabled();
    }
    $project =& group_get_object($group_id);
    if (!$project || !is_object($project)) {
        exit_no_group();
    }
    $params['toptab'] = 'frs';
    $params['group'] = $group_id;
    site_project_header($params);
    if (session_loggedin()) {
        $perm =& $project->getPermission(session_get_user());
        if ($perm && is_object($perm) && !$perm->isError() && $perm->isReleaseTechnician()) {
            echo $HTML->subMenu(array(_('Files'), _('Admin')), array('/frs/?group_id=' . $group_id, '/frs/admin/?group_id=' . $group_id));
        }
    }
}
Example #7
0
/**
 * GForge Mailing Lists Facility
 *
 * Portions Copyright 1999-2001 (c) VA Linux Systems
 * The rest Copyright 2003 (c) Guillaume Smet
 *
 * @version   $Id$
 *
 */
function mail_header($params)
{
    global $HTML, $group_id;
    if ($group_id) {
        //required for site_project_header
        $params['group'] = $group_id;
        $params['toptab'] = 'mail';
        $project =& group_get_object($group_id);
        if ($project && is_object($project)) {
            if (!$project->usesMail()) {
                exit_error(_('Error'), _('This Project Has Turned Off The Mailing Lists'));
            }
        }
        site_project_header($params);
        if (session_loggedin()) {
            $perm =& $project->getPermission(session_get_user());
            if ($perm && is_object($perm) && !$perm->isError() && $perm->isAdmin()) {
                echo $HTML->subMenu(array(_('Admin')), array('/mail/admin/?group_id=' . $group_id));
            }
        }
    } else {
        exit_no_group();
    }
}
Example #8
0
 /**
  * Display the submit form
  */
 public function displaySearch(Tracker_IDisplayTrackerLayout $layout, $request, $current_user)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $pm = ProjectManager::instance();
     $group_id = $request->get('group_id');
     $group = $pm->getProject($group_id);
     if (!$group || !is_object($group) || $group->isError()) {
         exit_no_group();
     }
     $breadcrumbs = array(array('title' => $GLOBALS['Language']->getText('plugin_tracker_browse', 'search_result'), 'url' => TRACKER_BASE_URL . '/?tracker=' . $this->getId()));
     $this->displayHeader($layout, $this->name, $breadcrumbs);
     $html = '';
     $words = $request->get('words');
     $criteria = 'OR';
     if ($request->exist('exact') && $request->get('exact') == '1') {
         $criteria = 'AND';
     }
     $offset = 0;
     if ($request->exist('offset')) {
         $offset = $request->get('offset');
     }
     $limit = 25;
     $tracker_artifact_dao = new Tracker_ArtifactDao();
     $dar = $tracker_artifact_dao->searchByKeywords($this->getId(), $words, $criteria, $offset, $limit);
     $rows_returned = $tracker_artifact_dao->foundRows();
     $no_rows = false;
     if ($dar->rowCount() < 1 || $rows_returned < 1) {
         $no_rows = true;
         $html .= '<h2>' . $GLOBALS['Language']->getText('search_index', 'no_match_found', $hp->purify($words, CODENDI_PURIFIER_CONVERT_HTML)) . '</h2>';
     } else {
         $html .= '<h3>' . $GLOBALS['Language']->getText('search_index', 'search_res', array($hp->purify($words, CODENDI_PURIFIER_CONVERT_HTML), $rows_returned)) . '</h3>';
         $title_arr = array();
         $art_field_fact = Tracker_FormElementFactory::instance();
         $artifact_factory = Tracker_ArtifactFactory::instance();
         $user_helper = UserHelper::instance();
         $summary_field = $this->getTitleField();
         if ($summary_field && $summary_field->userCanRead()) {
             $title_arr[] = $GLOBALS['Language']->getText('plugin_tracker_search_index', 'artifact_title');
         }
         $submitted_field = $art_field_fact->getFormElementByName($this->getId(), 'submitted_by');
         if ($submitted_field && $submitted_field->userCanRead()) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'submitted_by');
         }
         $date_field = $art_field_fact->getFormElementByName($this->getId(), 'open_date');
         if ($date_field && $date_field->userCanRead()) {
             $title_arr[] = $GLOBALS['Language']->getText('search_index', 'date');
         }
         $status_field = $this->getStatusField();
         if ($status_field && $status_field->userCanRead()) {
             $title_arr[] = $GLOBALS['Language']->getText('global', 'status');
         }
         $html .= html_build_list_table_top($title_arr);
         $nb_artifacts = 0;
         while ($row = $dar->getRow()) {
             $nb_artifacts++;
             $artifact_id = $row['artifact_id'];
             $artifact = $artifact_factory->getArtifactById($artifact_id);
             if ($artifact->userCanView()) {
                 $html .= '<tr class="' . html_get_alt_row_color($nb_artifacts) . '">';
                 if ($summary_field->userCanRead()) {
                     $html .= '<td><a href="' . TRACKER_BASE_URL . '/?aid=' . $artifact_id . '"><img src="' . util_get_image_theme('msg.png') . '" border="0" height="12" width="10"> ' . $artifact->getTitle() . '</a></td>';
                 }
                 if ($submitted_field->userCanRead()) {
                     $html .= '<td>' . $hp->purify($user_helper->getDisplayNameFromUserId($artifact->getSubmittedBy())) . '</td>';
                 }
                 if ($date_field->userCanRead()) {
                     $html .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $artifact->getSubmittedOn()) . '</td>';
                 }
                 if ($status_field->userCanRead()) {
                     $html .= '<td>' . $artifact->getStatus() . '</td>';
                 }
                 $html .= '</tr>';
             }
         }
         $html .= '</table>';
     }
     // Search result pagination
     if (!$no_rows && ($rows_returned > $nb_artifacts || $offset != 0)) {
         $html .= '<br />';
         $url_params = array('exact' => $request->get('exact') === '1' ? 1 : 0, 'group_id' => $this->getGroupId(), 'tracker' => $this->getId(), 'type_of_search' => 'tracker', 'words' => urlencode($words), 'offset' => $offset - $limit);
         $html .= '<table class="boxitem" width="100%" cellpadding="5" cellspacing="0">';
         $html .= '<tr>';
         $html .= '<td align="left">';
         if ($offset != 0) {
             $html .= '<span class="normal"><b>';
             $html .= '<a href="/search/?' . http_build_query($url_params);
             $html .= '">' . "<b><img src=\"" . util_get_image_theme('t2.png') . "\" height=15 width=15 border=0 align=middle> " . $GLOBALS['Language']->getText('search_index', 'prev_res') . " </a></b></span>";
         } else {
             $html .= '&nbsp;';
         }
         $html .= '</td><td align="right">';
         if ($rows_returned > $nb_artifacts && $rows_returned > $offset + $limit) {
             $url_params['offset'] = $offset + $limit;
             $html .= '<span class="normal"><b>';
             $html .= '<a href="/search/?' . http_build_query($url_params);
             $html .= '"><b>' . $GLOBALS['Language']->getText('search_index', 'next_res') . ' <img src="' . util_get_image_theme('t.png') . '" height="15" width="15" border="0" align="middle"></a></b></span>';
         } else {
             $html .= '&nbsp;';
         }
         $html .= '</td></tr>';
         $html .= '</table>';
     }
     echo $html;
     $this->displayFooter($layout);
 }
Example #9
0
/**
* create_project
* 
* Create a new project
*
* @param  data  
*/
function create_project($data, $do_not_exit = false)
{
    srand((double) microtime() * 1000000);
    $random_num = rand(0, 1000000);
    // Make sure default project privacy status is defined. If not
    // then default to "public"
    if (!isset($GLOBALS['sys_is_project_public'])) {
        $GLOBALS['sys_is_project_public'] = 1;
    }
    if (isset($GLOBALS['sys_disable_subdomains']) && $GLOBALS['sys_disable_subdomains']) {
        $http_domain = $GLOBALS['sys_default_domain'];
    } else {
        $http_domain = $data['project']['form_unix_name'] . '.' . $GLOBALS['sys_default_domain'];
    }
    //Verify if the approbation of the new project is automatic or not
    $auto_approval = ForgeConfig::get('sys_project_approval', 1) ? PROJECT_APPROVAL_BY_ADMIN : PROJECT_APPROVAL_AUTO;
    if (isset($data['project']['is_public'])) {
        $access = $data['project']['is_public'] ? Project::ACCESS_PUBLIC : Project::ACCESS_PRIVATE;
    } else {
        $access = ForgeConfig::get('sys_is_project_public') ? Project::ACCESS_PUBLIC : Project::ACCESS_PRIVATE;
    }
    // make group entry
    $insert_data = array('group_name' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_full_name'])) . "'", 'access' => "'" . $access . "'", 'unix_group_name' => "'" . db_es($data['project']['form_unix_name']) . "'", 'http_domain' => "'" . db_es($http_domain) . "'", 'status' => "'P'", 'unix_box' => "'shell1'", 'cvs_box' => "'cvs1'", 'license' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_license'])) . "'", 'license_other' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_license_other'])) . "'", 'short_description' => "'" . htmlspecialchars(mysql_real_escape_string($data['project']['form_short_description'])) . "'", 'register_time' => time(), 'rand_hash' => "'" . md5($random_num) . "'", 'built_from_template' => db_ei($data['project']['built_from_template']), 'type' => $data['project']['is_test'] ? 3 : 1);
    $sql = 'INSERT INTO groups(' . implode(', ', array_keys($insert_data)) . ') VALUES (' . implode(', ', array_values($insert_data)) . ')';
    $result = db_query($sql);
    if (!$result) {
        exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'upd_fail', array($GLOBALS['sys_email_admin'], db_error())));
    } else {
        $group_id = db_insertid($result);
        // insert descriptions
        $descfieldsinfos = getProjectsDescFieldsInfos();
        for ($i = 0; $i < sizeof($descfieldsinfos); $i++) {
            if (isset($data['project']["form_" . $descfieldsinfos[$i]["group_desc_id"]]) && $data['project']["form_" . $descfieldsinfos[$i]["group_desc_id"]] != '') {
                $sql = "INSERT INTO group_desc_value (group_id, group_desc_id, value) VALUES ('" . db_ei($group_id) . "','" . db_ei($descfieldsinfos[$i]["group_desc_id"]) . "','" . db_escape_string(trim($data['project']["form_" . $descfieldsinfos[$i]["group_desc_id"]])) . "')";
                $result = db_query($sql);
                if (!$result) {
                    list($host, $port) = explode(':', $GLOBALS['sys_default_domain']);
                    exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'ins_desc_fail', array($host, db_error())));
                }
            }
        }
        // insert trove categories
        if (isset($data['project']['trove'])) {
            foreach ($data['project']['trove'] as $root => $values) {
                foreach ($values as $value) {
                    db_query("INSERT INTO trove_group_link (trove_cat_id,trove_cat_version," . "group_id,trove_cat_root) VALUES (" . db_ei($value) . "," . time() . "," . db_ei($group_id) . "," . db_ei($root) . ")");
                }
            }
        }
        // define a module
        $project_manager = ProjectManager::instance();
        $result = db_query("INSERT INTO filemodule (group_id,module_name) VALUES ('{$group_id}','" . $project_manager->getProject($group_id)->getUnixName() . "')");
        if (!$result) {
            list($host, $port) = explode(':', $GLOBALS['sys_default_domain']);
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'ins_file_fail', array($host, db_error())));
        }
        // make the current user a project admin as well as admin
        // on all Codendi services
        $result = db_query("INSERT INTO user_group (user_id,group_id,admin_flags,bug_flags,forum_flags,project_flags,patch_flags,support_flags,doc_flags,file_flags,wiki_flags,svn_flags,news_flags) VALUES (" . user_getid() . "," . $group_id . "," . "'A'," . "2," . "2," . "2," . "2," . "2," . "2," . "2," . "2," . "2," . "2)");
        // news_flags
        if (!$result) {
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'set_owner_fail', array($GLOBALS['sys_email_admin'], db_error())));
        }
        // clear the user data to take into account this new group.
        $user = UserManager::instance()->getCurrentUser();
        $user->clearGroupData();
        // Instanciate all services from the project template that are 'active'
        $group = $project_manager->getProject($group_id);
        if (!$group || !is_object($group)) {
            exit_no_group();
        }
        //set up the group_id
        $_REQUEST['group_id'] = $_GET['group_id'] = $group_id;
        $request =& HTTPRequest::instance();
        $request->params['group_id'] = $_REQUEST['group_id'];
        $template_id = $group->getTemplate();
        $template_group = $project_manager->getProject($template_id);
        if (!$template_group || !is_object($template_group) || $template_group->isError()) {
            exit_no_group();
        }
        $system_template = $template_group->getStatus() == 's' || $template_group->getStatus() == 'S';
        if (!$system_template) {
            $template_name = $template_group->getUnixName();
        }
        $sql = "SELECT * FROM service WHERE group_id={$template_id} AND is_active=1";
        $result = db_query($sql);
        while ($arr = db_fetch_array($result)) {
            if (isset($data['project']['services'][$arr['service_id']]['is_used'])) {
                $is_used = $data['project']['services'][$arr['service_id']]['is_used'];
            } else {
                $is_used = '0';
                if ($arr['short_name'] == 'admin' || $arr['short_name'] == 'summary') {
                    $is_used = '1';
                }
            }
            $server_id = isset($data['project']['services'][$arr['service_id']]['server_id']) && $data['project']['services'][$arr['service_id']]['server_id'] ? $data['project']['services'][$arr['service_id']]['server_id'] : 'null';
            if (!service_create_service($arr, $group_id, array('system' => $system_template, 'name' => $system_template ? '' : $template_name, 'id' => $template_id, 'is_used' => $is_used, 'server_id' => $server_id))) {
                exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'cant_create_service') . '<br>' . db_error());
            }
        }
        //Add the import of the message to requester from the parent project if defined
        $dar = $project_manager->getMessageToRequesterForAccessProject($template_id);
        if ($dar && !$dar->isError() && $dar->rowCount() == 1) {
            $row = $dar->getRow();
            $result = $project_manager->setMessageToRequesterForAccessProject($group_id, $row['msg_to_requester']);
        } else {
            $result = $project_manager->setMessageToRequesterForAccessProject($group_id, 'member_request_delegation_msg_to_requester');
        }
        if (!$result) {
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'cant_copy_msg_to_requester'));
        }
        //Copy forums from template project
        $sql = "SELECT forum_name, is_public, description FROM forum_group_list WHERE group_id={$template_id} ";
        $result = db_query($sql);
        while ($arr = db_fetch_array($result)) {
            $fid = forum_create_forum($group_id, $arr['forum_name'], $arr['is_public'], 1, $arr['description'], $need_feedback = false);
            if ($fid != -1) {
                forum_add_monitor($fid, user_getid());
            }
        }
        //copy cvs infos
        $sql = "SELECT cvs_tracker, cvs_watch_mode, cvs_preamble, cvs_is_private FROM groups WHERE group_id={$template_id} ";
        $result = db_query($sql);
        $arr = db_fetch_array($result);
        $query = "UPDATE groups \n                  SET cvs_tracker='" . db_ei($arr['cvs_tracker']) . "',\n                      cvs_watch_mode='" . db_ei($arr['cvs_watch_mode']) . "' ,\n                      cvs_preamble='" . db_escape_string($arr['cvs_preamble']) . "',\n                      cvs_is_private = " . db_escape_int($arr['cvs_is_private']) . "\n                  WHERE group_id = '{$group_id}'";
        $result = db_query($query);
        if (!$result) {
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'cant_copy_cvs_infos'));
        }
        //copy svn infos
        $current_timestamp = db_escape_int($_SERVER['REQUEST_TIME']);
        $sql = "INSERT INTO svn_accessfile_history (version_number, group_id, version_date)\n                VALUES (1, {$group_id}, {$current_timestamp})";
        $result = db_query($sql);
        if (!$result) {
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'cant_copy_svn_infos'));
        }
        $sql = "SELECT svn_tracker, svn_preamble, svn_mandatory_ref, svn_commit_to_tag_denied FROM groups WHERE group_id={$template_id} ";
        $result = db_query($sql);
        $arr = db_fetch_array($result);
        $query = "UPDATE groups, svn_accessfile_history\n                  SET svn_tracker='" . db_ei($arr['svn_tracker']) . "',\n                      svn_mandatory_ref='" . db_ei($arr['svn_mandatory_ref']) . "',\n                      svn_preamble='" . db_escape_string($arr['svn_preamble']) . "',\n                      svn_commit_to_tag_denied='" . db_ei($arr['svn_commit_to_tag_denied']) . "',\n                      svn_accessfile_version_id = svn_accessfile_history.id\n                  WHERE groups.group_id = {$group_id}\n                      AND groups.group_id = svn_accessfile_history.group_id";
        $result = db_query($query);
        if (!$result) {
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'cant_copy_svn_infos'));
        }
        // Activate other system references not associated with any service
        $reference_manager =& ReferenceManager::instance();
        $reference_manager->addSystemReferencesWithoutService($template_id, $group_id);
        //Copy ugroups
        $ugroup_mapping = array();
        ugroup_copy_ugroups($template_id, $group_id, $ugroup_mapping);
        $sql_ugroup_mapping = ' ugroup_id ';
        if (is_array($ugroup_mapping) && count($ugroup_mapping)) {
            $sql_ugroup_mapping = ' CASE ugroup_id ';
            foreach ($ugroup_mapping as $key => $val) {
                $sql_ugroup_mapping .= ' WHEN ' . $key . ' THEN ' . $val;
            }
            $sql_ugroup_mapping .= ' ELSE ugroup_id END ';
        }
        //Copy packages from template project
        $sql = "SELECT package_id, name, status_id, rank, approve_license FROM frs_package WHERE group_id = {$template_id}";
        if ($result = db_query($sql)) {
            while ($p_data = db_fetch_array($result)) {
                $template_package_id = $p_data['package_id'];
                $sql = sprintf("INSERT INTO frs_package(group_id, name, status_id, rank, approve_license) VALUES (%s, '%s', %s, %s, %s)", $group_id, db_escape_string($p_data['name']), db_ei($p_data['status_id']), db_ei($p_data['rank']), db_ei($p_data['approve_license']));
                $rid = db_query($sql);
                if ($rid) {
                    $package_id = db_insertid($rid);
                    $sql = "INSERT INTO permissions(permission_type, object_id, ugroup_id) \n                      SELECT permission_type, {$package_id}, {$sql_ugroup_mapping}\n                      FROM permissions\n                      WHERE permission_type = 'PACKAGE_READ'\n                        AND object_id = {$template_package_id}";
                    db_query($sql);
                }
            }
        }
        //Set up some mailing lists
        //will be done at some point. needs to communicate with geocrawler
        // TBD
        // Generic Trackers Creation
        $tracker_mapping = array();
        $report_mapping = array();
        if (TrackerV3::instance()->available()) {
            $atf = new ArtifactTypeFactory($template_group);
            //$tracker_error = "";
            // Add all trackers from template project (tracker templates) that need to be instanciated for new trackers.
            $res = $atf->getTrackerTemplatesForNewProjects();
            while ($arr_template = db_fetch_array($res)) {
                $ath_temp = new ArtifactType($template_group, $arr_template['group_artifact_id']);
                $report_mapping_for_this_tracker = array();
                $new_at_id = $atf->create($group_id, $template_id, $ath_temp->getID(), db_escape_string($ath_temp->getName()), db_escape_string($ath_temp->getDescription()), $ath_temp->getItemName(), $ugroup_mapping, $report_mapping_for_this_tracker);
                if (!$new_at_id) {
                    $GLOBALS['Response']->addFeedback('error', $atf->getErrorMessage());
                } else {
                    $report_mapping = $report_mapping + $report_mapping_for_this_tracker;
                    $tracker_mapping[$ath_temp->getID()] = $new_at_id;
                    // Copy all the artifacts from the template tracker to the new tracker
                    $ath_new = new ArtifactType($group, $new_at_id);
                    // not now. perhaps one day
                    //if (!$ath_new->copyArtifacts($ath_temp->getID()) ) {
                    //$GLOBALS['Response']->addFeedback('info', $ath_new->getErrorMessage());
                    //}
                    // Create corresponding reference
                    $ref = new Reference(0, strtolower($ath_temp->getItemName()), $GLOBALS['Language']->getText('project_reference', 'reference_art_desc_key'), '/tracker/?func=detail&aid=$1&group_id=$group_id', 'P', 'tracker', ReferenceManager::REFERENCE_NATURE_ARTIFACT, '1', $group_id);
                    $result = $reference_manager->createReference($ref, true);
                    // Force reference creation because default trackers use reserved keywords
                }
            }
        }
        // Clone wiki from the template
        $clone = new WikiCloner($template_id, $group_id);
        // check if the template project has a wiki initialised
        if ($clone->templateWikiExists() and $clone->newWikiIsUsed()) {
            //clone wiki.
            $clone->CloneWiki();
        }
        //Create the summary page
        $lm = new WidgetLayoutManager();
        $lm->createDefaultLayoutForProject($group_id, $template_id);
        //Create project specific references if template is not default site template
        if (!$system_template) {
            $reference_manager =& ReferenceManager::instance();
            $reference_manager->addProjectReferences($template_id, $group_id);
        }
        // Copy Truncated email option
        $sql = "UPDATE groups AS g1\n                JOIN groups AS g2\n                  ON g2.group_id = " . db_ei($template_id) . "\n                SET g1.truncated_emails = g2.truncated_emails\n                WHERE g1.group_id = " . db_ei($group_id);
        db_query($sql);
        $result = db_query($query);
        if (!$result) {
            exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('register_confirmation', 'cant_copy_truncated_emails'));
        }
        // Raise an event for plugin configuration
        $em =& EventManager::instance();
        $em->processEvent('register_project_creation', array('reportMapping' => $report_mapping, 'trackerMapping' => $tracker_mapping, 'ugroupsMapping' => $ugroup_mapping, 'group_id' => $group_id, 'template_id' => $template_id));
        if ($auto_approval == PROJECT_APPROVAL_AUTO) {
            $project_manager->activate($group);
        }
        return $group_id;
    }
}
 function getContent()
 {
     $request =& HTTPRequest::instance();
     $group_id = $request->get('group_id');
     $pm = ProjectManager::instance();
     $project = $pm->getProject($group_id);
     if ($project->usesHomePage()) {
         print "<A ";
         if (substr($project->getHomePage(), 0, 1) != "/") {
             // Absolute link -> open new window on click
             print "target=_blank ";
         }
         print 'href="' . $project->getHomePage() . '">';
         html_image("ic/home16b.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'homepage')));
         print '&nbsp;' . $GLOBALS['Language']->getText('include_project_home', 'proj_home') . '</A>';
     }
     // ################## forums
     if ($project->usesForum()) {
         print '<HR SIZE="1" width="99%" NoShade><A href="' . $project->getForumPage() . '">';
         html_image("ic/notes16.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'public_forums')));
         print '&nbsp;' . $GLOBALS['Language']->getText('include_project_home', 'public_forums') . '</A>';
         $res_count = db_query("SELECT count(forum.msg_id) AS count FROM forum,forum_group_list WHERE " . "forum_group_list.group_id={$group_id} AND forum.group_forum_id=forum_group_list.group_forum_id " . "AND forum_group_list.is_public=1");
         $row_count = db_fetch_array($res_count);
         $pos = strpos($project->getForumPage(), '/forum/');
         if ($pos === 0) {
             print ' ( ' . $GLOBALS['Language']->getText('include_project_home', 'msg', $row_count['count']) . ' ';
             $res_count = db_query("SELECT count(*) AS count FROM forum_group_list WHERE group_id={$group_id} " . "AND is_public=1");
             $row_count = db_fetch_array($res_count);
             print $GLOBALS['Language']->getText('include_project_home', 'forums', $row_count['count']) . " )\n";
         }
         /*
             $sql="SELECT * FROM forum_group_list WHERE group_id='$group_id' AND is_public=1";
             $res2 = db_query ($sql);
             $rows = db_numrows($res2);
             for ($j = 0; $j < $rows; $j++) {
                 echo '<BR> &nbsp; - <A HREF="forum.php?forum_id='.db_result($res2, $j, 'group_forum_id').'&et=0">'.
                     db_result($res2, $j, 'forum_name').'</A> ';
                 //message count
                 echo '('.db_result(db_query("SELECT count(*) FROM forum WHERE group_forum_id='".db_result($res2, $j, 'group_forum_id')."'"),0,0).' msgs)';
             }
         */
     }
     // ##################### Doc Manager (only for Active)
     if ($project->usesDocman()) {
         print '
         <HR SIZE="1" width="99%" NoShade>
         <A href="/docman/?group_id=' . $group_id . '">';
         html_image("ic/docman16b.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'doc')));
         print '&nbsp;' . $GLOBALS['Language']->getText('include_project_home', 'doc_man') . '</A>';
         /*
             $res_count = db_query("SELECT count(*) AS count FROM support WHERE group_id=$group_id");
             $row_count = db_fetch_array($res_count);
             $res_count = db_query("SELECT count(*) AS count FROM support WHERE group_id=$group_id AND support_status_id='1'");
             $row_count2 = db_fetch_array($res_count);
             print " ( <B>$row_count2[count]</B>";
             print " open requests, <B>$row_count[count]</B> total )";
         */
     }
     // ##################### Mailing lists (only for Active)
     if ($project->usesMail()) {
         print '<HR SIZE="1" width="99%" NoShade><A href="' . $project->getMailPage() . '">';
         html_image("ic/mail16b.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'mail_lists')));
         print '&nbsp;' . $GLOBALS['Language']->getText('include_project_home', 'mail_lists') . '</A>';
         $res_count = db_query("SELECT count(*) AS count FROM mail_group_list WHERE group_id={$group_id} AND is_public=1");
         $row_count = db_fetch_array($res_count);
         print ' ( ' . $GLOBALS['Language']->getText('include_project_home', 'public_mail_lists', $row_count['count']) . ' )';
     }
     // ######################### Wiki (only for Active)
     if ($project->usesWiki()) {
         print '<HR SIZE="1" width="99%" NoShade><A href="' . $project->getWikiPage() . '">';
         html_image("ic/wiki.png", array('width' => '18', 'height' => '12', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'wiki')));
         print ' ' . $GLOBALS['Language']->getText('include_project_home', 'wiki') . '</A>';
         $wiki = new Wiki($group_id);
         $pos = strpos($project->getWikiPage(), '/wiki/');
         if ($pos === 0) {
             echo ' ( ' . $GLOBALS['Language']->getText('include_project_home', 'nb_wiki_pages', $wiki->getProjectPageCount()) . ' )';
         }
     }
     // ######################### Surveys (only for Active)
     if ($project->usesSurvey()) {
         print '<HR SIZE="1" width="99%" NoShade><A href="/survey/?group_id=' . $group_id . '">';
         html_image("ic/survey16b.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'surveys')));
         print ' ' . $GLOBALS['Language']->getText('include_project_home', 'surveys') . '</A>';
         $sql = "SELECT count(*) from surveys where group_id='{$group_id}' AND is_active='1'";
         $result = db_query($sql);
         echo ' ( ' . $GLOBALS['Language']->getText('include_project_home', 'nb_surveys', db_result($result, 0, 0)) . ' )';
     }
     // ######################### CVS (only for Active)
     if ($project->usesCVS()) {
         print '<HR SIZE="1" width="99%" NoShade><A href="' . $project->getCvsPage() . '">';
         html_image("ic/cvs16b.png", array('width' => '20', 'height' => '20', 'alt' => 'CVS'));
         print ' ' . $GLOBALS['Language']->getText('include_project_home', 'cvs_repo') . '</A>';
         // LJ Cvs checkouts added
         $sql = "SELECT SUM(cvs_commits) AS commits, SUM(cvs_adds) AS adds, SUM(cvs_checkouts) AS checkouts from stats_project where group_id='{$group_id}'";
         $result = db_query($sql);
         $cvs_commit_num = db_result($result, 0, 0);
         $cvs_add_num = db_result($result, 0, 1);
         $cvs_co_num = db_result($result, 0, 2);
         if (!$cvs_commit_num) {
             $cvs_commit_num = 0;
         }
         if (!$cvs_add_num) {
             $cvs_add_num = 0;
         }
         if (!$cvs_co_num) {
             $cvs_co_num = 0;
         }
         $uri = session_make_url('/cvs/viewvc.php/?root=' . $project->getUnixName(false) . '&roottype=cvs');
         echo ' ( ' . $GLOBALS['Language']->getText('include_project_home', 'commits', $cvs_commit_num) . ', ' . $GLOBALS['Language']->getText('include_project_home', 'adds', $cvs_add_num) . ', ' . $GLOBALS['Language']->getText('include_project_home', 'co', $cvs_co_num) . ' )';
         if ($cvs_commit_num || $cvs_add_num || $cvs_co_num) {
             echo '<br> &nbsp; - <a href="' . $uri . '">' . $GLOBALS['Language']->getText('include_project_home', 'browse_cvs') . '</a>';
         }
     }
     // ######################### Subversion (only for Active)
     if ($project->usesService('svn')) {
         print '<HR SIZE="1" width="99%" NoShade><A href="' . $project->getSvnPage() . '">';
         html_image("ic/svn16b.png", array('width' => '20', 'height' => '20', 'alt' => 'Subversion'));
         print ' ' . $GLOBALS['Language']->getText('include_project_home', 'svn_repo') . '</A>';
         $sql = "SELECT SUM(svn_access_count) AS accesses from group_svn_full_history where group_id='{$group_id}'";
         $result = db_query($sql);
         $svn_accesses = db_result($result, 0, 0);
         if (!$svn_accesses) {
             $svn_accesses = 0;
         }
         echo ' ( ' . $GLOBALS['Language']->getText('include_project_home', 'accesses', $svn_accesses) . ' )';
         if ($svn_accesses) {
             $uri = session_make_url('/svn/viewvc.php/?root=' . $project->getUnixName(false) . '&roottype=svn');
             echo '<br> &nbsp; - <a href="' . $uri . '">' . $GLOBALS['Language']->getText('include_project_home', 'browse_svn') . '</a>';
         }
     }
     // ######################### File Releases (only for Active)
     if ($project->usesFile()) {
         echo $project->services['file']->getPublicArea();
     }
     // ######################### Trackers (only for Active)
     if ($project->usesTracker()) {
         print '<HR SIZE="1" width="99%" NoShade><A href="' . $project->getTrackerPage() . '">';
         html_image("ic/tracker20w.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'trackers')));
         print ' ' . $GLOBALS['Language']->getText('include_project_home', 'trackers') . '</A>';
         //
         //  get the Group object
         //
         $pm = ProjectManager::instance();
         $group = $pm->getProject($group_id);
         if (!$group || !is_object($group) || $group->isError()) {
             exit_no_group();
         }
         $atf = new ArtifactTypeFactory($group);
         if (!$group || !is_object($group) || $group->isError()) {
             exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('include_project_home', 'no_arttypefact'));
         }
         // Get the artfact type list
         $at_arr = $atf->getArtifactTypes();
         if (!$at_arr || count($at_arr) < 1) {
             echo '<br><i>' . $GLOBALS['Language']->getText('include_project_home', 'no_trackers_accessible') . '</i>';
         } else {
             for ($j = 0; $j < count($at_arr); $j++) {
                 if ($at_arr[$j]->userCanView()) {
                     echo '<br><i>-&nbsp;
                 <a href="/tracker/?atid=' . $at_arr[$j]->getID() . '&group_id=' . $group_id . '&func=browse">' . $at_arr[$j]->getName() . '</a></i>';
                 }
             }
         }
     }
     // ######################## AnonFTP (only for Active)
     if ($project->isActive()) {
         print '<HR SIZE="1" width="99%" NoShade>';
         list($host, $port) = explode(':', $GLOBALS['sys_default_domain']);
         if ($GLOBALS['sys_disable_subdomains']) {
             $ftp_subdomain = "";
         } else {
             $ftp_subdomain = $project->getUnixName() . ".";
         }
         print "<A href=\"ftp://" . $ftp_subdomain . $host . "/pub/" . $project->getUnixName(false) . "/\">";
         // keep the first occurence in lower case
         print html_image("ic/ftp16b.png", array('width' => '20', 'height' => '20', 'alt' => $GLOBALS['Language']->getText('include_project_home', 'anon_ftp_space')));
         print $GLOBALS['Language']->getText('include_project_home', 'anon_ftp_space') . '</A>';
     }
     // ######################## Plugins
     $areas = array();
     $params = array('project' => &$project, 'areas' => &$areas);
     $em =& EventManager::instance();
     $em->processEvent(Event::SERVICE_PUBLIC_AREAS, $params);
     foreach ($areas as $area) {
         print '<HR SIZE="1" width="99%" NoShade>';
         print $area;
     }
 }
 /**
  * createProject
  *
  * Create a new project
  *
  * Insert in group table
  * Insert group_desc_value, trove_group_link
  * Create filemodule in DB
  * Assign an admin user
  * Copy from template:
  * - activate the same services (using the ame server id and options)
  * - send message to the project requested (pepend on template values)
  * - create forums with the same name and public status
  * - copy CVS properties
  * - copy SVN settings and start .SVNAccessFile hisr=tiry
  * - add system references withut services
  * - copy ugroups and save mapping for further import
  * - copy FRS packages with permissions
  * - copy trackers
  * - copy wiki
  * - copy layout summary page
  * - Add the template as a project reference
  * - Copy Truncated email option
  * - Raise an event for plugin configuration
  *
  * @param  data ProjectCreationData
  */
 protected function createProject(ProjectCreationData $data)
 {
     $admin_user = UserManager::instance()->getCurrentUser();
     $group_id = $this->createGroupEntry($data);
     if ($group_id === false) {
         return;
     }
     $this->setCategories($data, $group_id);
     $this->initFileModule($group_id);
     $this->setProjectAdmin($group_id, $admin_user);
     // Instanciate all services from the project template that are 'active'
     $group = $this->projectManager->getProject($group_id);
     if (!$group || !is_object($group)) {
         exit_no_group();
     }
     $this->fakeGroupIdIntoHTTPParams($group_id);
     $template_id = $group->getTemplate();
     $template_group = $this->projectManager->getProject($template_id);
     if (!$template_group || !is_object($template_group) || $template_group->isError()) {
         exit_no_group();
     }
     $this->activateServicesFromTemplate($group_id, $template_group, $data);
     $this->setMessageToRequesterFromTemplate($group_id, $template_id);
     $this->initForumModuleFromTemplate($group_id, $template_id);
     $this->initCVSModuleFromTemplate($group_id, $template_id);
     $this->initSVNModuleFromTemplate($group_id, $template_id);
     // Activate other system references not associated with any service
     $this->reference_manager->addSystemReferencesWithoutService($template_id, $group_id);
     //Copy ugroups
     $ugroup_mapping = array();
     ugroup_copy_ugroups($template_id, $group_id, $ugroup_mapping);
     $this->initFRSModuleFromTemplate($group_id, $template_id, $ugroup_mapping);
     list($tracker_mapping, $report_mapping) = $this->initTrackerV3ModuleFromTemplate($group, $template_group, $ugroup_mapping);
     $this->initWikiModuleFromTemplate($group_id, $template_id);
     $this->initLayoutFromTemplate($group_id, $template_id);
     //Create project specific references if template is not default site template
     if (!$template_group->isSystem()) {
         $this->reference_manager->addProjectReferences($template_id, $group_id);
     }
     $this->copyEmailOptionsFromTemplate($group_id, $template_id);
     // Raise an event for plugin configuration
     $em = EventManager::instance();
     $em->processEvent('register_project_creation', array('reportMapping' => $report_mapping, 'trackerMapping' => $tracker_mapping, 'ugroupsMapping' => $ugroup_mapping, 'group_id' => $group_id, 'template_id' => $template_id));
     $this->autoActivateProject($group);
     return $group_id;
 }
Example #12
0
/**
 * Remove a user from a project
 *
 * @param Integer $groupId      Project id
 * @param Integer $userId       User id
 * @param Boolean $adminAction  Default value set to true, manage the displayed message according to the person that asked for the action (admin/self remove) 
 */
function account_remove_user_from_group($groupId, $userId, $adminAction = true)
{
    $pm = ProjectManager::instance();
    $res = db_query("DELETE FROM user_group WHERE group_id='{$groupId}' AND user_id='{$userId}' AND admin_flags <> 'A'");
    if (!$res || db_affected_rows($res) < 1) {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_index', 'user_not_removed'));
    } else {
        // Raise an event
        $em = EventManager::instance();
        $em->processEvent('project_admin_remove_user', array('group_id' => $groupId, 'user_id' => $userId));
        //
        //  get the Group object
        //
        $group = $pm->getProject($groupId);
        if (!$group || !is_object($group) || $group->isError()) {
            exit_no_group();
        }
        $atf = new ArtifactTypeFactory($group);
        if (!$group || !is_object($group) || $group->isError()) {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_index', 'not_get_atf'));
        }
        // Get the artfact type list
        $at_arr = $atf->getArtifactTypes();
        if ($at_arr && count($at_arr) > 0) {
            for ($j = 0; $j < count($at_arr); $j++) {
                if (!$at_arr[$j]->deleteUser($userId)) {
                    $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_index', 'del_tracker_perm_fail', $at_arr[$j]->getName()));
                }
            }
        }
        // Remove user from ugroups attached to this project
        if (!ugroup_delete_user_from_project_ugroups($groupId, $userId)) {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_index', 'del_user_from_ug_fail'));
        }
        $name = user_getname($userId);
        if ($adminAction) {
            $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('project_admin_index', 'user_removed') . ' (' . $name . ')');
        } else {
            $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('project_admin_index', 'self_user_remove') . ' (' . $group->getPublicName() . ')');
        }
        group_add_history('removed_user', user_getname($userId) . " ({$userId})", $groupId);
        return true;
    }
    return false;
}
Example #13
0
/**
 *
 *   Method of easily enforcing permissions
 *   Page will terminate with error message if you fail checks
 *
 */
function session_require($req)
{
    if (!user_isloggedin()) {
        exit_permission_denied();
    }
    /*
    	SF Admins always have permission
    */
    if (user_is_super_user()) {
        return true;
    }
    if ($req['group']) {
        $group =& group_get_object($req['group']);
        if (!$group) {
            exit_no_group();
        }
        if ($req['admin_flags']) {
            //$query .= " AND admin_flags = '$req[admin_flags]'";
            if (!$group->userIsAdmin()) {
                exit_permission_denied();
            }
        } else {
            if (!$group->userIsMember()) {
                exit_permission_denied();
            }
        }
    } else {
        if ($req['isloggedin']) {
            //no need to check as long as the check is present at top of function
        } else {
            exit_permission_denied();
        }
    }
}
 /**
  * @access
  * @param
  * @return
  */
 function validate()
 {
     // Validate Group id
     $pm = ProjectManager::instance();
     $go = $pm->getProject($this->gid);
     if (!$go) {
         exit_no_group();
     }
     // Validate filename
     if (!is_dir($this->basedir . '/' . $this->getFilesystemName())) {
         return false;
         //      print "error ".$this->basedir.'/'.$this->filename;
     }
     return true;
 }
 function _display_artifacts($list_trackers, $print_box_begin)
 {
     $request = HTTPRequest::instance();
     $vItemId = new Valid_UInt('hide_item_id');
     $vItemId->required();
     if ($request->valid($vItemId)) {
         $hide_item_id = $request->get('hide_item_id');
     } else {
         $hide_item_id = null;
     }
     $vArtifact = new Valid_WhiteList('hide_artifact', array(0, 1));
     $vArtifact->required();
     if ($request->valid($vArtifact)) {
         $hide_artifact = $request->get('hide_artifact');
     } else {
         $hide_artifact = null;
     }
     $j = $print_box_begin;
     $html_my_artifacts = "";
     $html = "";
     $html_hdr = "";
     $aid_old = 0;
     $atid_old = 0;
     $group_id_old = 0;
     $count_aids = 0;
     $group_name = "";
     $tracker_name = "";
     $artifact_types = array();
     $pm = ProjectManager::instance();
     while ($trackers_array = db_fetch_array($list_trackers)) {
         $atid = $trackers_array['group_artifact_id'];
         $group_id = $trackers_array['group_id'];
         // {{{ check permissions
         //create group
         $group = $pm->getProject($group_id);
         if (!$group || !is_object($group) || $group->isError()) {
             exit_no_group();
         }
         //Create the ArtifactType object
         if (!isset($artifact_types[$group_id])) {
             $artifact_types[$group_id] = array();
         }
         if (!isset($artifact_types[$group_id][$atid])) {
             $artifact_types[$group_id][$atid] = array();
             $artifact_types[$group_id][$atid]['at'] = new ArtifactType($group, $atid);
             $artifact_types[$group_id][$atid]['user_can_view_at'] = $artifact_types[$group_id][$atid]['at']->userCanView();
             $artifact_types[$group_id][$atid]['user_can_view_summary_or_aid'] = null;
         }
         //Check if user can view artifact
         if ($artifact_types[$group_id][$atid]['user_can_view_at'] && $artifact_types[$group_id][$atid]['user_can_view_summary_or_aid'] !== false) {
             if (is_null($artifact_types[$group_id][$atid]['user_can_view_summary_or_aid'])) {
                 $at = $artifact_types[$group_id][$atid]['at'];
                 //Create ArtifactFieldFactory object
                 if (!isset($artifact_types[$group_id][$atid]['aff'])) {
                     $artifact_types[$group_id][$atid]['aff'] = new ArtifactFieldFactory($at);
                 }
                 $aff = $artifact_types[$group_id][$atid]['aff'];
                 //Retrieve artifact_id field
                 $field = $aff->getFieldFromName('artifact_id');
                 //Check if user can read it
                 $user_can_view_aid = $field->userCanRead($group_id, $atid);
                 //Retrieve percent_complete field
                 $field = $aff->getFieldFromName('percent_complete');
                 //Check if user can read it
                 $user_can_view_percent_complete = $field && $field->userCanRead($group_id, $atid);
                 //Retriebe summary field
                 $field = $aff->getFieldFromName('summary');
                 //Check if user can read it
                 $user_can_view_summary = $field->userCanRead($group_id, $atid);
                 $artifact_types[$group_id][$atid]['user_can_view_summary_or_aid'] = $user_can_view_aid || $user_can_view_summary;
             }
             if ($artifact_types[$group_id][$atid]['user_can_view_summary_or_aid']) {
                 //work on the tracker of the last round if there was one
                 if ($atid != $atid_old && $count_aids != 0) {
                     list($hide_now, $count_diff, $hide_url) = my_hide_url('artifact', $atid_old, $hide_item_id, $count_aids, $hide_artifact);
                     $html_hdr = ($j ? '<tr class="boxitem"><td colspan="3">' : '') . $hide_url . '<A HREF="/tracker/?group_id=' . $group_id_old . '&atid=' . $atid_old . '">' . $group_name . " - " . $tracker_name . '</A>&nbsp;&nbsp;&nbsp;&nbsp;';
                     $count_new = max(0, $count_diff);
                     $html_hdr .= my_item_count($count_aids, $count_new) . '</td></tr>';
                     $html_my_artifacts .= $html_hdr . $html;
                     $count_aids = 0;
                     $html = '';
                     $j++;
                 }
                 if ($count_aids == 0) {
                     //have to call it to get at least the hide_now even if count_aids is false at this point
                     $hide_now = my_hide('artifact', $atid, $hide_item_id, $hide_artifact);
                 }
                 $group_name = $trackers_array['group_name'];
                 $tracker_name = $trackers_array['name'];
                 $aid = $trackers_array['artifact_id'];
                 $summary = $trackers_array['summary'];
                 $atid_old = $atid;
                 $group_id_old = $group_id;
                 // If user is assignee and submitter of an artifact, it will
                 // appears 2 times in the result set.
                 if ($aid != $aid_old) {
                     $count_aids++;
                 }
                 if (!$hide_now && $aid != $aid_old) {
                     // Form the 'Submitted by/Assigned to flag' for marking
                     $AS_flag = my_format_as_flag2($trackers_array['assignee'], $trackers_array['submitter']);
                     //get percent_complete if this field is used in the tracker
                     $percent_complete = '';
                     if ($user_can_view_percent_complete) {
                         $sql = "SELECT afvl.value " . "FROM artifact_field_value afv,artifact_field af, artifact_field_value_list afvl, artifact_field_usage afu " . "WHERE af.field_id = afv.field_id AND af.field_name = 'percent_complete' " . "AND afv.artifact_id = {$aid} " . "AND afvl.group_artifact_id = {$atid} AND af.group_artifact_id = {$atid} " . "AND afu.group_artifact_id = {$atid} AND afu.field_id = af.field_id AND afu.use_it = 1 " . "AND afvl.field_id = af.field_id AND afvl.value_id = afv.valueInt";
                         $res = db_query($sql);
                         if (db_numrows($res) > 0) {
                             $percent_complete = '<TD class="small">' . db_result($res, 0, 'value') . '</TD>';
                         }
                     }
                     $html .= '
                         <TR class="' . get_priority_color($trackers_array['severity']) . '"><TD class="small"><A HREF="/tracker/?func=detail&group_id=' . $group_id . '&aid=' . $aid . '&atid=' . $atid . '">' . $aid . '</A></TD>' . '<TD class="small"' . ($percent_complete ? '>' : ' colspan="2">');
                     if ($user_can_view_summary) {
                         $html .= stripslashes($summary);
                     }
                     $html .= '&nbsp;' . $AS_flag . '</TD>' . $percent_complete . '</TR>';
                 }
                 $aid_old = $aid;
             }
         }
     }
     //work on the tracker of the last round if there was one
     if ($atid_old != 0 && $count_aids != 0) {
         list($hide_now, $count_diff, $hide_url) = my_hide_url('artifact', $atid_old, $hide_item_id, $count_aids, $hide_artifact);
         $html_hdr = ($j ? '<tr class="boxitem"><td colspan="3">' : '') . $hide_url . '<A HREF="/tracker/?group_id=' . $group_id_old . '&atid=' . $atid_old . '">' . $group_name . " - " . $tracker_name . '</A>&nbsp;&nbsp;&nbsp;&nbsp;';
         $count_new = max(0, $count_diff);
         $html_hdr .= my_item_count($count_aids, $count_new) . '</td></tr>';
         $html_my_artifacts .= $html_hdr . $html;
     }
     return $html_my_artifacts;
 }
Example #16
0
 /**
  * Remove Project members from a project
  *
  * @param Project $project Affected project
  *
  * @return Boolean
  */
 public function removeProjectMembers($project)
 {
     if (!$project || !is_object($project) || $project->isError()) {
         exit_no_group();
     }
     $dao = new UserGroupDao(CodendiDataAccess::instance());
     return $dao->removeProjectMembers($project->getID());
 }
Example #17
0
require_once '../../env.inc.php';
require_once $gfwww . 'include/pre.php';
require_once $gfwww . 'pm/include/ProjectGroupHTML.class.php';
require_once $gfcommon . 'pm/ProjectGroupFactory.class.php';
require_once $gfcommon . 'pm/ProjectCategory.class.php';
if (!session_loggedin()) {
    exit_not_logged_in();
}
$group_id = getIntFromRequest('group_id');
$group_project_id = getIntFromRequest('group_project_id');
if (!$group_id) {
    exit_no_group();
}
$g =& group_get_object($group_id);
if (!$g || !is_object($g)) {
    exit_no_group();
} elseif ($g->isError()) {
    exit_error('Error', $g->getErrorMessage());
}
$perm =& $g->getPermission(session_get_user());
$update_cat = getStringFromRequest('update_cat');
$add_cat = getStringFromRequest('add_cat');
$delete = getStringFromRequest('delete');
$id = getIntFromRequest('id');
if (getStringFromRequest('post_changes')) {
    /*
    	Update the database
    */
    $pg = new ProjectGroup($g, $group_project_id);
    if (!$pg || !is_object($pg)) {
        exit_error('Error', 'Unable to create ProjectCategory Object');
Example #18
0
function forum_header($params)
{
    global $HTML, $group_id, $forum_name, $forum_id, $sys_news_group, $f, $sys_use_forum, $group_forum_id;
    if ($group_forum_id) {
        $forum_id = $group_forum_id;
    }
    if (!$sys_use_forum) {
        exit_disabled();
    }
    $params['group'] = $group_id;
    $params['toptab'] = 'forums';
    /*
    bastardization for news
    Show icon bar unless it's a news forum
    */
    if ($group_id == $sys_news_group) {
        //this is a news item, not a regular forum
        if ($forum_id) {
            // Show this news item at the top of the page
            $sql = "SELECT submitted_by, post_date, group_id, forum_id, summary, details FROM news_bytes WHERE forum_id='{$forum_id}'";
            $result = db_query($sql);
            // checks which group the news item belongs to
            $params['group'] = db_result($result, 0, 'group_id');
            $params['toptab'] = 'news';
            $HTML->header($params);
            echo '<table><tr><td valign="top">';
            if (!$result || db_numrows($result) < 1) {
                echo '<h3>' . _('Error - this news item was not found') . '</h3>';
            } else {
                $user = user_get_object(db_result($result, 0, 'submitted_by'));
                $group =& group_get_object($params['group']);
                if (!$group || !is_object($group) || $group->isError()) {
                    exit_no_group();
                }
                echo '
				<strong>' . _('Posted by') . ':</strong> ' . $user->getRealName() . '<br />
				<strong>' . _('Date') . ':</strong> ' . date(_('Y-m-d H:i'), db_result($result, 0, 'post_date')) . '<br />
				<strong>' . _('Summary') . ':</strong>' . util_make_link('/forum/forum.php?forum_id=' . db_result($result, 0, 'forum_id') . '&group_id=' . $group_id, db_result($result, 0, 'summary')) . '<br/>
				<strong>' . _('Project') . ':</strong>' . util_make_link_g($group->getUnixName(), db_result($result, 0, 'group_id'), $group->getPublicName()) . '<br />
				<p>
				' . util_make_links(nl2br(db_result($result, 0, 'details')));
                echo '</p>';
            }
            echo '</td><td valign="top" width="35%">';
            echo $HTML->boxTop(_('Latest News'));
            echo news_show_latest($params['group'], 5, false);
            echo $HTML->boxBottom();
            echo '</td></tr></table>';
        } else {
            site_project_header($params);
        }
    } else {
        site_project_header($params);
    }
    $menu_text = array();
    $menu_links = array();
    if ($f) {
        if ($f->userIsAdmin()) {
            $menu_text[] = _('Admin');
            $menu_links[] = '/forum/admin/?group_id=' . $group_id;
        }
        if ($forum_id) {
            $menu_text[] = _('Discussion Forums:') . ' ' . $f->getName();
            $menu_links[] = '/forum/forum.php?forum_id=' . $forum_id;
        }
    } else {
        $gg =& group_get_object($group_id);
        $perm =& $gg->getPermission(session_get_user());
        if ($perm->isForumAdmin()) {
            $menu_text[] = _('Admin');
            $menu_links[] = '/forum/admin/?group_id=' . $group_id;
        }
    }
    if (count($menu_text) > 0) {
        echo $HTML->subMenu($menu_text, $menu_links);
    }
    if (session_loggedin()) {
        if ($f) {
            if ($f->isMonitoring()) {
                echo util_make_link('/forum/monitor.php?forum_id=' . $forum_id . '&amp;group_id=' . $group_id . '&amp;stop=1', html_image('ic/xmail16w.png', '20', '20', array()) . ' ' . _('Stop Monitoring')) . ' | ';
            } else {
                echo util_make_link('/forum/monitor.php?forum_id=' . $forum_id . '&amp;group_id=' . $group_id . '&amp;start=1', html_image('ic/mail16w.png', '20', '20', array()) . ' ' . _('Monitor Forum')) . ' | ';
            }
            echo util_make_link('/forum/save.php?forum_id=' . $forum_id . '&amp;group_id=' . $group_id, html_image('ic/save.png', '24', '24', array()) . ' ' . _('Save Place')) . ' | ';
        }
    }
    if ($f && $forum_id) {
        echo util_make_link('/forum/new.php?forum_id=' . $forum_id . '&amp;group_id=' . $group_id, html_image('ic/write16w.png', '20', '20', array('alt' => _('Start New Thread'))) . ' ' . _('Start New Thread'));
    }
}