*
* Copyright 2004, GForge, LLC
* Copyright 2009-2010, Roland Mas
+ * Copyright 2012, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
'docman' => array (0, 1, 2, 3, 4),
'frs' => array (0, 1, 2, 3),
-// 'webcal' => array(0, 1, 2),
);
// Global permissions
'new_tracker' => 15,
'pm_admin' => 1,
'new_pm' => 7,
- 'webcal' => 2,
),
'Senior Developer' => array( 'project_read' => 1,
'frs' => 2,
'new_tracker' => 15,
'pm_admin' => 1,
'new_pm' => 7,
- 'webcal' => 2,
),
'Junior Developer' => array( 'project_read' => 1,
'frs' => 2,
'new_forum' => 3,
'new_tracker' => 11,
'new_pm' => 3,
- 'webcal' => 2,
),
'Doc Writer' => array( 'project_read' => 1,
'frs' => 2,
'new_forum' => 3,
'new_tracker' => 9,
'new_pm' => 1,
- 'webcal' => 2,
),
'Support Tech' => array( 'project_read' => 1,
'frs' => 2,
'new_tracker' => 11,
'pm_admin' => 1,
'new_pm' => 7,
- 'webcal' => 2,
),
);
}
$section,
$reference,
$value)) ;
+ $this->perms_array[$section][$reference] = $value;
}
function getSettingsForProject ($project) {
}
$atf = new ArtifactTypeFactory ($project) ;
- $tids = $atf->getAllArtifactTypeIds () ;
- foreach ($tids as $tid) {
- $result['tracker'][$tid] = $this->getVal ('tracker', $tid) ;
+ if (!$atf->isError()) {
+ $tids = $atf->getAllArtifactTypeIds () ;
+ foreach ($tids as $tid) {
+ $result['tracker'][$tid] = $this->getVal ('tracker', $tid) ;
+ }
}
array_push ($sections,'tracker');
$sections = array_merge($sections, $sections_forum);
$ff = new ForumFactory ($project) ;
- $fids = $ff->getAllForumIds () ;
- foreach ($fids as $fid) {
- $result['forum'][$fid] = $this->getVal ('forum', $fid) ;
+ if (!$ff->isError()) {
+ $fids = $ff->getAllForumIdsWithNews () ;
+ foreach ($fids as $fid) {
+ $result['forum'][$fid] = $this->getVal ('forum', $fid) ;
+ }
}
array_push ($sections,'forum');
$result[$section_pm][$group_id] = $this->getVal ($section_pm, $group_id) ;
}
$sections = array_merge($sections, $sections_pm);
+
$pgf = new ProjectGroupFactory ($project) ;
- $pgids = $pgf->getAllProjectGroupIds () ;
- foreach ($pgids as $pgid) {
- $result['pm'][$pgid] = $this->getVal ('pm', $pgid) ;
+ if (!$pgf->isError()) {
+ $pgids = $pgf->getAllProjectGroupIds () ;
+ foreach ($pgids as $pgid) {
+ $result['pm'][$pgid] = $this->getVal ('pm', $pgid) ;
+ }
}
array_push ($sections,'pm') ;
return $result ;
}
- /**
- * TODO: Enter description here ...
- * @param unknown_type $section
- * @param unknown_type $reference
- * @return number|boolean
- */
- function getSetting($section, $reference) {
- $r = $this->getSettingRaw($section, $reference);
- if ($r == NULL) {
- return 0;
- }
- return $r;
- }
-
- function getSettingRaw($section, $reference) {
- if (isset ($this->perms_array[$section][$reference])) {
- $value = $this->perms_array[$section][$reference] ;
- } else {
- $value = 0 ;
+ /**
+ * TODO: Enter description here ...
+ * @param unknown_type $section
+ * @param unknown_type $reference
+ * @return number|boolean
+ */
+ function getSetting($section, $reference) {
+ $value = $this->getSettingRaw($section, $reference);
+ if ($value == NULL) {
+ $value = 0;
}
+
$min = PHP_INT_MAX ;
$mask = 0 ;
}
}
+ function getSettingRaw($section, $reference) {
+ if (isset ($this->perms_array[$section][$reference])) {
+ return $this->perms_array[$section][$reference] ;
+ }
+ }
+
/**
* getVal - get a value out of the array of settings for this role.
*
db_begin () ;
// Remove obsolete project-wide settings
- $sections = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm', 'webcal') ;
+ $sections = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm') ;
db_query_params ('DELETE FROM pfo_role_setting where role_id=$1 AND section_name=ANY($2) and ref_id NOT IN (SELECT home_group_id FROM pfo_role WHERE role_id=$1 AND home_group_id IS NOT NULL UNION SELECT group_id from role_project_refs WHERE role_id=$1)',
array ($this->getID(),
db_string_array_to_any_clause($sections))) ;
// Add missing settings
// ...project-wide settings
- $arr = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm', 'webcal') ;
+ $arr = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm') ;
foreach ($projects as $p) {
foreach ($arr as $section) {
$this->normalizePermsForSection ($new_pa, $section, $p->getID()) ;
$new_pa['tracker'] = array () ;
foreach ($projects as $p) {
$atf = new ArtifactTypeFactory ($p) ;
- $trackerids = $atf->getAllArtifactTypeIds () ;
- foreach ($trackerids as $tid) {
- 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()] ;
+ if (!$atf->isError()) {
+ $trackerids = $atf->getAllArtifactTypeIds () ;
+ foreach ($trackerids as $tid) {
+ 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()] ;
+ }
}
}
}
$new_sa['forum'] = array () ;
$new_pa['forum'] = array () ;
foreach ($projects as $p) {
+ if (!$p->usesForum()) {
+ continue;
+ }
$ff = new ForumFactory ($p) ;
- $fids = $ff->getAllForumIds () ;
+ $fids = $ff->getAllForumIdsWithNews () ;
foreach ($fids as $fid) {
if (array_key_exists ('forum', $this->perms_array)
&& array_key_exists ($fid, $this->perms_array['forum']) ) {