*
* 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;
$section,
$reference,
$value)) ;
+ $this->perms_array[$section][$reference] = $value;
}
function getSettingsForProject ($project) {
$result = array () ;
$group_id = $project->getID() ;
- $sections = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm') ;
+ $sections = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker') ;
foreach ($sections as $section) {
$result[$section][$group_id] = $this->getVal ($section, $group_id) ;
}
$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) ;
+ }
}
- $sections[] = 'tracker' ;
+ array_push ($sections,'tracker');
+ $sections_forum = array('forum_admin', 'new_forum');
+ foreach ($sections_forum as $section_forum) {
+ $result[$section_forum][$group_id] = $this->getVal ($section_forum, $group_id) ;
+ }
+ $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) ;
+ }
}
- $sections[] = 'forum' ;
+ array_push ($sections,'forum');
+
+ $sections_pm = array('pm_admin', 'new_pm');
+ foreach ($sections_pm as $section_pm) {
+ $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) ;
+ }
}
- $sections[] = 'pm' ;
+ array_push ($sections,'pm') ;
// Add settings not yet listed so far (probably plugins)
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.
*
$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']) ) {