Example #1
0
 private function getTrackersV3ForProject(Project $project)
 {
     if ($project->usesService('tracker')) {
         require_once 'common/tracker/ArtifactTypeFactory.class.php';
         $atf = new ArtifactTypeFactory($project);
         return $atf->getArtifactTypes();
     }
     return null;
 }
Example #2
0
<?php

//
//  get the Group object
//
$group =& group_get_object($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('Error', 'Could Not Get ArtifactTypeFactory');
}
$at_arr =& $atf->getArtifactTypes();
//required params for site_project_header();
$params['group'] = $group_id;
$params['toptab'] = 'tracker';
echo site_project_header($params);
$perm =& $group->getPermission(session_get_user());
if ($perm->isArtifactAdmin()) {
    $menu_text = array();
    $menu_links = array();
    $menu_text[] = _('Admin');
    $menu_links[] = '/tracker/admin/?group_id=' . $group_id;
    echo $HTML->subMenu($menu_text, $menu_links);
}
if (!$at_arr || count($at_arr) < 1) {
    echo "<h1>" . _('No Accessible Trackers Found') . "</h1>";
    echo "<p><strong>" . sprintf(_('No trackers have been set up, or you cannot view them.<p><span class="important">The Admin for this project will have to set up data types using the %1$s admin page %2$s</span>'), '<a href="' . util_make_url('/tracker/admin/?group_id=' . $group_id) . '">', '</a>') . "</strong>";
} else {
    echo '<p>' . _('Choose a tracker and you can browse/edit/add items to it.') . '<p>';
Example #3
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;
    }
}
Example #4
0
 $pm = ProjectManager::instance();
 $group = $pm->getProject($group_id);
 if (!$group || !is_object($group) || $group->isError()) {
     exit_no_group();
 }
 //
 //	Create the ArtifactType object
 //
 $ath = new ArtifactTypeHtml($group);
 if (!$ath || !is_object($ath)) {
     exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'not_create_at'));
 }
 if ($ath->isError()) {
     exit_error($Language->getText('global', 'error'), $ath->getErrorMessage());
 }
 $atf = new ArtifactTypeFactory($group);
 $func = $request->getValidated('func', 'string', '');
 switch ($func) {
     case 'create':
         if (!user_isloggedin()) {
             exit_not_logged_in();
             return;
         }
         if (!user_ismember($group_id, 'A')) {
             exit_permission_denied();
             return;
         }
         if (browser_is_netscape4()) {
             exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'browser_not_supported', $Language->getText('tracker_index', 'a_tracker')));
             return;
         }
 private function initTrackerV3ModuleFromTemplate(Group $group, Group $template_group, $ugroup_mapping)
 {
     $group_id = $group->getID();
     $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_group->getID(), $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 = $this->reference_manager->createReference($ref, true);
                 // Force reference creation because default trackers use reserved keywords
             }
         }
     }
     return array($tracker_mapping, $report_mapping);
 }
Example #6
0
<form name="form_selection">
<table>
<tr valign="center"><td>
<div align="center">
<?php 
//
//	get the Group object
//
$group_id = $request->getValidated('group_id', 'GroupId');
$pm = ProjectManager::instance();
$group = $pm->getProject($group_id);
if (!$group || !is_object($group) || $group->isError()) {
    exit_no_group();
}
$count = 0;
$atf = new ArtifactTypeFactory($group);
$trackers_array = $atf->getArtifactTypesFromId($group_id);
if ($trackers_array !== false) {
    echo '<select name="artifact_type_id" size="5">';
    $hp = Codendi_HTMLPurifier::instance();
    foreach ($trackers_array as $tracker) {
        echo '<option value="' . (int) $tracker->getId() . '">' . $hp->purify($tracker->getName()) . '</option>';
        $count++;
    }
}
if ($count > 0) {
    ?>
</select>
</td>
<td>
<input type="button" name="selection" value="Select" onClick="doSelection(form_selection)">
 private function getTrackersv3ForProject(Project $project)
 {
     $artifact_type_factory = new ArtifactTypeFactory($project);
     return $artifact_type_factory->getArtifactTypes();
 }
Example #8
0
 function normalizeData()
 {
     // From the PFO spec
     $this->removeObsoleteSettings();
     $this->fetchData($this->getID());
     $projects = $this->getLinkedProjects();
     $new_sa = array();
     $new_pa = array();
     // Add missing settings
     // ...project-wide settings
     if (USE_PFO_RBAC) {
         $arr = array('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm', 'webcal');
         foreach ($projects as $p) {
             foreach ($arr as $section) {
                 $this->normalizePermsForSection($new_pa, $section, $p->getID());
             }
         }
         $this->normalizePermsForSection($new_pa, 'forge_admin', -1);
         $this->normalizePermsForSection($new_pa, 'approve_projects', -1);
         $this->normalizePermsForSection($new_pa, 'approve_news', -1);
         $this->normalizePermsForSection($new_pa, 'forge_stats', -1);
     } else {
         $arr = array('projectadmin', 'frs', 'scm', 'docman', 'forumadmin', 'trackeradmin', 'newtracker', 'pmadmin', 'newpm', 'webcal');
         foreach ($arr as $section) {
             $this->normalizeDataForSection($new_sa, $section);
         }
     }
     $hook_params = array();
     $hook_params['role'] =& $this;
     $hook_params['new_sa'] =& $new_sa;
     $hook_params['new_pa'] =& $new_pa;
     plugin_hook("role_normalize", $hook_params);
     // ...tracker-related settings
     $new_sa['tracker'] = array();
     $new_pa['tracker'] = array();
     foreach ($projects as $p) {
         $atf = new ArtifactTypeFactory($p);
         $trackerids = $atf->getAllArtifactTypeIds();
         foreach ($trackerids as $tid) {
             if (USE_PFO_RBAC) {
                 if (array_key_exists('tracker', $this->perms_array) && array_key_exists($tid, $this->perms_array['tracker'])) {
                     $new_pa['tracker'][$tid] = $this->perms_array['tracker'][$tid];
                 } elseif (array_key_exists('new_tracker', $this->perms_array) && array_key_exists($p->getID(), $this->perms_array['new_tracker'])) {
                     $new_pa['tracker'][$tid] = $new_pa['new_tracker'][$p->getID()];
                 }
             } else {
                 if (array_key_exists('tracker', $this->setting_array) && array_key_exists($tid, $this->setting_array['tracker'])) {
                     $new_sa['tracker'][$tid] = $this->setting_array['tracker'][$tid];
                 } else {
                     $new_sa['tracker'][$tid] = $new_sa['newtracker'][0];
                 }
             }
         }
     }
     // ...forum-related settings
     $new_sa['forum'] = array();
     $new_pa['forum'] = array();
     foreach ($projects as $p) {
         $ff = new ForumFactory($p);
         $fids = $ff->getAllForumIds();
         foreach ($fids as $fid) {
             if (USE_PFO_RBAC) {
                 if (array_key_exists('forum', $this->perms_array) && array_key_exists($fid, $this->perms_array['forum'])) {
                     $new_pa['forum'][$fid] = $this->perms_array['forum'][$fid];
                 } elseif (array_key_exists('new_forum', $this->perms_array) && array_key_exists($p->getID(), $this->perms_array['new_forum'])) {
                     $new_pa['forum'][$fid] = $new_pa['new_forum'][$p->getID()];
                 }
             } else {
                 if (array_key_exists('forum', $this->setting_array) && array_key_exists($fid, $this->setting_array['forum'])) {
                     $new_sa['forum'][$fid] = $this->setting_array['forum'][$fid];
                 } else {
                     $new_sa['forum'][$fid] = $new_sa['newforum'][0];
                 }
             }
         }
     }
     // ...pm-related settings
     $new_sa['pm'] = array();
     $new_pa['pm'] = array();
     foreach ($projects as $p) {
         $pgf = new ProjectGroupFactory($p);
         $pgids = $pgf->getAllProjectGroupIds();
         foreach ($pgids as $gid) {
             if (USE_PFO_RBAC) {
                 if (array_key_exists('pm', $this->perms_array) && array_key_exists($gid, $this->perms_array['pm'])) {
                     $new_pa['pm'][$gid] = $this->perms_array['pm'][$gid];
                 } elseif (array_key_exists('new_pm', $this->perms_array) && array_key_exists($p->getID(), $this->perms_array['new_pm'])) {
                     $new_pa['pm'][$gid] = $new_pa['new_pm'][$p->getID()];
                 }
             } else {
                 if (array_key_exists('pm', $this->setting_array) && array_key_exists($gid, $this->setting_array['pm'])) {
                     $new_sa['pm'][$gid] = $this->setting_array['pm'][$gid];
                 } else {
                     $new_sa['pm'][$gid] = $new_sa['newpm'][0];
                 }
             }
         }
     }
     // Save
     if (USE_PFO_RBAC) {
         $this->update($this->getName(), $new_pa, false);
     } else {
         $this->update($this->getName(), $new_sa);
     }
     return true;
 }
Example #9
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 #10
0
 /**
  * artifacttype_to_soap : return the soap ArtifactType structure giving an PHP ArtifactType Object.
  * @access private
  * 
  * WARNING : We check the permissions here : only the readable trackers and the readable fields are returned.
  *
  * @param Object{ArtifactType} $at the artifactType to convert.
  * @return the SOAPArtifactType corresponding to the ArtifactType Object
  */
 function artifacttype_to_soap($at)
 {
     global $ath;
     $user_id = UserManager::instance()->getCurrentUser()->getId();
     $return = array();
     // number of opend artifact are not part of ArtifactType, so we have to get it with ArtifactTypeFactory (could need some refactoring maybe)
     $atf = new ArtifactTypeFactory($at->getGroup());
     $arr_count = $atf->getStatusIdCount($at->getID());
     if ($arr_count) {
         $open_count = array_key_exists('open_count', $arr_count) ? $arr_count['open_count'] : -1;
         $count = array_key_exists('count', $arr_count) ? $arr_count['count'] : -1;
     } else {
         $open_count = -1;
         $count = -1;
     }
     $field_sets = array();
     $ath = new ArtifactType($at->getGroup(), $at->getID());
     if (!$ath || !is_object($ath)) {
         return new SoapFault(get_artifact_type_fault, 'ArtifactType could not be created', 'getArtifactTypes');
     }
     if ($ath->isError()) {
         return new SoapFault(get_artifact_type_fault, $ath->getErrorMessage(), 'getArtifactTypes');
     }
     // Check if this tracker is valid (not deleted)
     if (!$ath->isValid()) {
         return new SoapFault(get_artifact_type_fault, 'This tracker is no longer valid.', 'getArtifactTypes');
     }
     // Check if the user can view this tracker
     if ($ath->userCanView($user_id)) {
         $art_fieldset_fact = new ArtifactFieldSetFactory($at);
         if (!$art_fieldset_fact || !is_object($art_fieldset_fact)) {
             return new SoapFault(get_artifact_field_factory_fault, 'Could Not Get ArtifactFieldSetFactory', 'getFieldSets');
         } elseif ($art_fieldset_fact->isError()) {
             return new SoapFault(get_artifact_field_factory_fault, $art_fieldset_fact->getErrorMessage(), 'getFieldSets');
         }
         $result_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields();
         foreach ($result_fieldsets as $fieldset_id => $result_fieldset) {
             $fields = array();
             $fields_in_fieldset = $result_fieldset->getAllUsedFields();
             $group_id = $at->Group->getID();
             $group_artifact_id = $at->getID();
             while (list($key, $field) = each($fields_in_fieldset)) {
                 if ($field->userCanRead($group_id, $group_artifact_id, $user_id)) {
                     $availablevalues = array();
                     $result = $field->getFieldPredefinedValues($at->getID(), false, false, false, false);
                     $rows = db_numrows($result);
                     $cols = db_numfields($result);
                     for ($j = 0; $j < $rows; $j++) {
                         $field_status = $cols > 2 ? db_result($result, $j, 6) : '';
                         // we don't send hidden values (status == 'H')
                         if ($field_status != 'H') {
                             $availablevalues[] = array('field_id' => $field->getID(), 'group_artifact_id' => $at->getID(), 'value_id' => db_result($result, $j, 0), 'value' => SimpleSanitizer::unsanitize(db_result($result, $j, 1)), 'description' => SimpleSanitizer::unsanitize($cols > 2 ? db_result($result, $j, 4) : ''), 'order_id' => $cols > 2 ? db_result($result, $j, 5) : 0, 'status' => $field_status);
                         }
                     }
                     // For bound-values select boxes, we add the none value.
                     if (($field->isMultiSelectBox() || $field->isSelectBox()) && $field->isBound()) {
                         $availablevalues[] = array('field_id' => $field->getID(), 'group_artifact_id' => $at->getID(), 'value_id' => 100, 'value' => 'None', 'description' => '', 'order_id' => 10, 'status' => 'P');
                     }
                     if ($field->isMultiSelectBox()) {
                         $defaultvalue = implode(",", $field->getDefaultValue());
                     } else {
                         $defaultvalue = $field->getDefaultValue();
                     }
                     $fields[] = array('field_id' => $field->getID(), 'group_artifact_id' => $at->getID(), 'field_set_id' => $field->getFieldSetID(), 'field_name' => SimpleSanitizer::unsanitize($field->getName()), 'data_type' => $field->getDataType(), 'display_type' => $field->getDisplayType(), 'display_size' => $field->getDisplaySize(), 'label' => SimpleSanitizer::unsanitize($field->getLabel()), 'description' => SimpleSanitizer::unsanitize($field->getDescription()), 'scope' => $field->getScope(), 'required' => $field->getRequired(), 'empty_ok' => $field->getEmptyOk(), 'keep_history' => $field->getKeepHistory(), 'special' => $field->getSpecial(), 'value_function' => implode(",", $field->getValueFunction()), 'available_values' => $availablevalues, 'default_value' => $defaultvalue, 'user_can_submit' => $field->userCanSubmit($group_id, $group_artifact_id, $user_id), 'user_can_read' => $field->userCanRead($group_id, $group_artifact_id, $user_id), 'user_can_update' => $field->userCanUpdate($group_id, $group_artifact_id, $user_id), 'is_standard_field' => $field->isStandardField());
                 }
             }
             $field_sets[] = array('field_set_id' => $result_fieldset->getID(), 'group_artifact_id' => $result_fieldset->getArtifactTypeID(), 'name' => SimpleSanitizer::unsanitize($result_fieldset->getName()), 'label' => SimpleSanitizer::unsanitize($result_fieldset->getLabel()), 'description' => SimpleSanitizer::unsanitize($result_fieldset->getDescription()), 'description_text' => SimpleSanitizer::unsanitize($result_fieldset->getDescriptionText()), 'rank' => $result_fieldset->getRank(), 'fields' => $fields);
         }
         // We add the field dependencies
         $field_dependencies = artifactrules_to_soap($at);
         $sql = "SELECT COALESCE(sum(af.filesize) / 1024,NULL,0) as total_file_size" . " FROM artifact_file af, artifact a, artifact_group_list agl" . " WHERE (af.artifact_id = a.artifact_id)" . " AND (a.group_artifact_id = agl.group_artifact_id)" . " AND (agl.group_artifact_id =" . db_ei($at->getID()) . ")";
         $result = db_query($sql);
         $return = array('group_artifact_id' => $at->data_array['group_artifact_id'], 'group_id' => $at->data_array['group_id'], 'name' => SimpleSanitizer::unsanitize($at->data_array['name']), 'description' => SimpleSanitizer::unsanitize($at->data_array['description']), 'item_name' => $at->data_array['item_name'], 'open_count' => $at->userHasFullAccess() ? $open_count : -1, 'total_count' => $at->userHasFullAccess() ? $count : -1, 'total_file_size' => db_result($result, 0, 0), 'field_sets' => $field_sets, 'field_dependencies' => $field_dependencies);
     }
     return $return;
 }
Example #11
0
 /**
  *  update - use this to update this ArtifactType in the database.
  *
  *  @param	string	The item name.
  *  @param	string	The item description.
  *  @param	int		Days before this item is considered overdue.
  *  @param	int		Days before stale items time out.
  *  @param	bool	(1) true (0) false - whether the resolution box should be shown.
  *  @param	string	Free-form string that project admins can place on the submit page.
  *  @param	string	Free-form string that project admins can place on the browse page.
  *  @param	bool	instantiate_for_new_projects (1) true (0) false - instantiate this tracker template for new projects
  *  @return true on success, false on failure.
  */
 function update($name, $description, $itemname, $allow_copy, $submit_instructions, $browse_instructions, $instantiate_for_new_projects)
 {
     global $Language;
     if (!$this->userIsAdmin()) {
         $this->setError('ArtifactType: ' . $Language->getText('tracker_common_canned', 'perm_denied'));
         return false;
     }
     if (!$name || !$description || !$itemname || trim($name) == "" || trim($description) == "" || trim($itemname) == "") {
         $this->setError('ArtifactType: ' . $Language->getText('tracker_common_type', 'name_requ'));
         return false;
     }
     if (!eregi("^[a-zA-Z0-9_]+\$", $itemname)) {
         $hp = Codendi_HTMLPurifier::instance();
         $this->setError($Language->getText('tracker_common_type', 'invalid_shortname', $hp->purify($itemname, CODENDI_PURIFIER_CONVERT_HTML)));
         return false;
     }
     $group_id = $this->Group->getID();
     $old_name = $this->getName();
     if ($old_name != $name) {
         $atf = new ArtifactTypeFactory($this->Group);
         if ($atf->isNameExists($name, $group_id)) {
             $this->setError($Language->getText('tracker_common_type', 'name_already_exists', $itemname));
             return false;
         }
     }
     $allow_copy = !$allow_copy ? 0 : $allow_copy;
     $instantiate_for_new_projects = !$instantiate_for_new_projects ? 0 : $instantiate_for_new_projects;
     $old_item_name = $this->getItemName();
     if ($old_item_name != $itemname) {
         $reference_manager = ReferenceManager::instance();
         if (!$reference_manager->checkKeyword($itemname)) {
             $this->setError($Language->getText('tracker_common_type', 'invalid_shortname', $itemname));
             return false;
         }
         if ($reference_manager->_isKeywordExists($itemname, $group_id)) {
             $this->setError($Language->getText('tracker_common_type', 'shortname_already_exists', $itemname));
             return false;
         }
         //Update table 'reference'
         $reference_dao = $this->getReferenceDao();
         $result = $reference_dao->update_keyword($old_item_name, $itemname, $this->Group->getID());
         //Update table 'cross_reference'
         $reference_dao = $this->getCrossReferenceDao();
         $result = $reference_dao->updateTargetKeyword($old_item_name, $itemname, $this->Group->getID());
         $result2 = $reference_dao->updateSourceKeyword($old_item_name, $itemname, $this->Group->getID());
     }
     //Update table 'artifact_group_list'
     $reference_dao = $this->getArtifactGroupListDao();
     $result = $reference_dao->updateArtifactGroupList($this->getID(), $this->Group->getID(), $name, $description, $itemname, $allow_copy, $submit_instructions, $browse_instructions, $instantiate_for_new_projects);
     if (!$result) {
         $this->setError('ArtifactType::Update(): ' . db_error());
         return false;
     } else {
         $this->fetchData($this->getID());
         return true;
     }
 }
Example #12
0
 function delete($sure, $really_sure, $really_really_sure)
 {
     if (!$sure || !$really_sure || !$really_really_sure) {
         $this->setMissingParamsError();
         return false;
     }
     if ($this->getID() == $GLOBALS['sys_news_group'] || $this->getID() == 1 || $this->getID() == $GLOBALS['sys_stats_group'] || $this->getID() == $GLOBALS['sys_peer_rating_group']) {
         $this->setError(_('Cannot Delete System Group'));
         return false;
     }
     $perm =& $this->getPermission(session_get_user());
     if (!$perm || !is_object($perm)) {
         $this->setPermissionDeniedError();
         return false;
     } elseif ($perm->isError()) {
         $this->setPermissionDeniedError();
         return false;
     } elseif (!$perm->isSuperUser()) {
         $this->setPermissionDeniedError();
         return false;
     }
     db_begin();
     //
     //	Remove all the members
     //
     $members =& $this->getMembers();
     for ($i = 0; $i < count($members); $i++) {
         $this->removeUser($members[$i]->getID());
     }
     //
     //	Delete Trackers
     //
     $atf = new ArtifactTypeFactory($this);
     $at_arr =& $atf->getArtifactTypes();
     for ($i = 0; $i < count($at_arr); $i++) {
         if (!is_object($at_arr[$i])) {
             printf(_("Not Object: ArtifactType: %d"), $i);
             continue;
         }
         $at_arr[$i]->delete(1, 1);
     }
     //
     //	Delete Forums
     //
     $ff = new ForumFactory($this);
     $f_arr =& $ff->getForums();
     for ($i = 0; $i < count($f_arr); $i++) {
         if (!is_object($f_arr[$i])) {
             printf(_("Not Object: Forum: %d"), $i);
             continue;
         }
         $f_arr[$i]->delete(1, 1);
         //echo 'ForumFactory'.db_error();
     }
     //
     //	Delete Subprojects
     //
     $pgf = new ProjectGroupFactory($this);
     $pg_arr =& $pgf->getProjectGroups();
     for ($i = 0; $i < count($pg_arr); $i++) {
         if (!is_object($pg_arr[$i])) {
             printf(_("Not Object: ProjectGroup: %d"), $i);
             continue;
         }
         $pg_arr[$i]->delete(1, 1);
         //echo 'ProjectGroupFactory'.db_error();
     }
     //
     //	Delete FRS Packages
     //
     //$frspf = new FRSPackageFactory($this);
     $res = db_query("SELECT * FROM frs_package WHERE group_id='" . $this->getID() . "'");
     //echo 'frs_package'.db_error();
     //$frsp_arr =& $frspf->getPackages();
     while ($arr = db_fetch_array($res)) {
         //if (!is_object($pg_arr[$i])) {
         //	echo "Not Object: ProjectGroup: ".$i;
         //	continue;
         //}
         $frsp = new FRSPackage($this, $arr['package_id'], $arr);
         $frsp->delete(1, 1);
     }
     //
     //	Delete news
     //
     $news_group =& group_get_object($GLOBALS['sys_news_group']);
     $res = db_query("SELECT forum_id FROM news_bytes WHERE group_id='" . $this->getID() . "'");
     for ($i = 0; $i < db_numrows($res); $i++) {
         $Forum = new Forum($news_group, db_result($res, $i, 'forum_id'));
         if (!$Forum->delete(1, 1)) {
             printf(_("Could Not Delete News Forum: %d"), $Forum->getID());
         }
     }
     $res = db_query("DELETE FROM news_bytes WHERE group_id='" . $this->getID() . "'");
     //
     //	Delete docs
     //
     $res = db_query("DELETE FROM doc_data WHERE group_id='" . $this->getID() . "'");
     //echo 'doc_data'.db_error();
     $res = db_query("DELETE FROM doc_groups WHERE group_id='" . $this->getID() . "'");
     //echo 'doc_groups'.db_error();
     //
     //	Delete group history
     //
     $res = db_query("DELETE FROM group_history WHERE group_id='" . $this->getID() . "'");
     //echo 'group_history'.db_error();
     //
     //	Delete group plugins
     //
     $res = db_query("DELETE FROM group_plugin WHERE group_id='" . $this->getID() . "'");
     //echo 'group_plugin'.db_error();
     //
     //	Delete group cvs stats
     //
     $res = db_query("DELETE FROM stats_cvs_group WHERE group_id='" . $this->getID() . "'");
     //echo 'stats_cvs_group'.db_error();
     //
     //	Delete Surveys
     //
     $sf = new SurveyFactory($this);
     $s_arr =& $sf->getSurveys();
     for ($i = 0; $i < count($s_arr); $i++) {
         if (!is_object($s_arr[$i])) {
             printf(_("Not Object: Survey: %d"), $i);
             continue;
         }
         $s_arr[$i]->delete();
         //echo 'SurveyFactory'.db_error();
     }
     //
     //	Delete SurveyQuestions
     //
     $sqf = new SurveyQuestionFactory($this);
     $sq_arr =& $sqf->getSurveyQuestions();
     for ($i = 0; $i < count($sq_arr); $i++) {
         if (!is_object($sq_arr[$i])) {
             printf(_("Not Object: SurveyQuestion: %d"), $i);
             continue;
         }
         $sq_arr[$i]->delete();
         //echo 'SurveyQuestionFactory'.db_error();
     }
     //
     //	Delete Mailing List Factory
     //
     $mlf = new MailingListFactory($this);
     $ml_arr =& $mlf->getMailingLists();
     for ($i = 0; $i < count($ml_arr); $i++) {
         if (!is_object($ml_arr[$i])) {
             printf(_("Not Object: MailingList: %d"), $i);
             continue;
         }
         if (!$ml_arr[$i]->delete(1, 1)) {
             $this->setError(_('Could not properly delete the mailing list'));
         }
         //echo 'MailingListFactory'.db_error();
     }
     //
     //	Delete trove
     //
     $res = db_query("DELETE FROM trove_group_link WHERE group_id='" . $this->getID() . "'");
     $res = db_query("DELETE FROM trove_agg WHERE group_id='" . $this->getID() . "'");
     //
     //	Delete counters
     //
     $res = db_query("DELETE FROM project_sums_agg WHERE group_id='" . $this->getID() . "'");
     //echo 'project_sums_agg'.db_error();
     $res = db_query("INSERT INTO deleted_groups (\n\t\tunix_group_name,delete_date,isdeleted) VALUES \n\t\t('" . $this->getUnixName() . "','" . time() . "','0')");
     //echo 'InsertIntoDeleteQueue'.db_error();
     $res = db_query("DELETE FROM groups WHERE group_id='" . $this->getID() . "'");
     //echo 'DeleteGroup'.db_error();
     db_commit();
     if (!$res) {
         return false;
     }
     $hook_params = array();
     $hook_params['group'] = $this;
     $hook_params['group_id'] = $this->getID();
     plugin_hook("group_delete", $hook_params);
     if (isset($GLOBALS['sys_upload_dir']) && $this->getUnixName()) {
         exec('/bin/rm -rf ' . $GLOBALS['sys_upload_dir'] . '/' . $this->getUnixName() . '/');
     }
     if (isset($GLOBALS['sys_ftp_upload_dir']) && $this->getUnixName()) {
         exec('/bin/rm -rf ' . $GLOBALS['sys_ftp_upload_dir'] . '/' . $this->getUnixName() . '/');
     }
     //
     //	Delete reporting
     //
     $res = db_query("DELETE FROM rep_group_act_weekly WHERE group_id='" . $this->getID() . "'");
     //echo 'rep_group_act_weekly'.db_error();
     $res = db_query("DELETE FROM rep_group_act_monthly WHERE group_id='" . $this->getID() . "'");
     //echo 'rep_group_act_monthly'.db_error();
     $res = db_query("DELETE FROM rep_group_act_daily WHERE group_id='" . $this->getID() . "'");
     //echo 'rep_group_act_daily'.db_error();
     unset($this->data_array);
     return true;
 }
 function getContent()
 {
     $html_my_artifacts = '<table style="width:100%">';
     if ($atf = new ArtifactTypeFactory(false)) {
         $my_artifacts = $atf->getMyArtifacts(user_getid(), $this->_artifact_show);
         if (db_numrows($my_artifacts) > 0) {
             $html_my_artifacts .= $this->_display_artifacts($my_artifacts, 0);
         }
     } else {
         $html_my_artifacts = $GLOBALS['Language']->getText('my_index', 'err_artf');
     }
     $html_my_artifacts .= '<TR><TD COLSPAN="3">' . ($this->_artifact_show == 'N' || db_numrows($my_artifacts) > 0 ? '&nbsp;' : $GLOBALS['Language']->getText('global', 'none')) . '</TD></TR>';
     $html_my_artifacts .= '</table>';
     $html_my_artifacts .= $this->getPriorityColorsKey();
     return $html_my_artifacts;
 }
Example #14
0
         if (!$ath->delay($delay_date)) {
             if ($ath->isError()) {
                 exit_error($Language->getText('global', 'error'), $ath->getErrorMessage() . " | " . $Language->getText('tracker_admin_restore', 'delay_failed'));
             }
             exit_error($Language->getText('global', 'error'), $Language->getText('tracker_admin_restore', 'delay_failed'));
         } else {
             $feedback = $Language->getText('tracker_admin_restore', 'delayed_deletion');
         }
     }
     break;
 case 'delete':
     // Create field factory
     if ($group = $pm->getProject($request->getValidated('group_id', 'GroupId'))) {
         $atid = $request->getValidated('atid', 'uint');
         $ath = new ArtifactType($group, $atid);
         $atf = new ArtifactTypeFactory($group);
         $art_field_fact = new ArtifactFieldFactory($ath);
         // Then delete all the fields informations
         if (!$art_field_fact->deleteFields($atid)) {
             exit_error($Language->getText('global', 'error'), $art_field_fact->getErrorMessage());
             return false;
         }
         // Then delete all the reports informations
         // Create field factory
         $art_report_fact = new ArtifactReportFactory();
         if (!$art_report_fact->deleteReports($atid)) {
             exit_error($Language->getText('global', 'error'), $art_report_fact->getErrorMessage());
             return false;
         }
         // Delete the artifact type itself
         if (!$atf->deleteArtifactType($atid)) {
 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;
     }
 }