*
* 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;
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-require "PFO-RBAC.interface.php";
+require 'PFO-RBAC.interface.php';
define ('USE_PFO_RBAC', true);
'pm_admin' => array(0, 1),
'forum_admin' => array(0, 1),
- 'tracker' => array(0, 1, 3, 5, 7),
+ 'tracker' => array(0, 1, 9, 11, 13, 15),
'pm' => array(0, 1, 3, 5, 7),
'forum' => array(0, 1, 2, 3, 4),
- 'new_tracker' => array(0, 1, 3, 5, 7),
+ 'new_tracker' => array(0, 1, 9, 11, 13, 15),
'new_pm' => array(0, 1, 3, 5, 7),
'new_forum' => array(0, 1, 2, 3, 4),
'docman' => array (0, 1, 2, 3, 4),
'frs' => array (0, 1, 2, 3),
-// 'webcal' => array(0, 1, 2),
);
// Global permissions
'forum_admin' => 1,
'new_forum' => 3,
'tracker_admin' => 1,
- 'new_tracker' => 7,
+ 'new_tracker' => 15,
'pm_admin' => 1,
'new_pm' => 7,
- 'webcal' => 2,
),
'Senior Developer' => array( 'project_read' => 1,
'frs' => 2,
'forum_admin' => 1,
'new_forum' => 3,
'tracker_admin' => 1,
- 'new_tracker' => 7,
+ 'new_tracker' => 15,
'pm_admin' => 1,
'new_pm' => 7,
- 'webcal' => 2,
),
'Junior Developer' => array( 'project_read' => 1,
'frs' => 2,
'scm' => 2,
'docman' => 2,
'new_forum' => 3,
- 'new_tracker' => 3,
+ 'new_tracker' => 11,
'new_pm' => 3,
- 'webcal' => 2,
),
'Doc Writer' => array( 'project_read' => 1,
'frs' => 2,
'docman' => 4,
'new_forum' => 3,
- 'new_tracker' => 1,
+ 'new_tracker' => 9,
'new_pm' => 1,
- 'webcal' => 2,
),
'Support Tech' => array( 'project_read' => 1,
'frs' => 2,
'docman' => 1,
'new_forum' => 3,
'tracker_admin' => 1,
- 'new_tracker' => 3,
+ '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.
*
case 'manager':
return (($value & 4) != 0) ;
break ;
+ case 'submit':
+ return (($value & 8) != 0) ;
+ break ;
+ /*
+ * bit4 (value & 16) is reserved
+ * for tracker item vote from Evolvis
+ */
}
break ;
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']) ) {
}
public function addUser ($user) {
- return $this->addUsers (array ($user)) ;
+ if (!$this->addUsers (array ($user))) {
+ return false;
+ }
+ $hook_params['user'] = $user;
+ $hook_params['role'] = $this;
+ plugin_hook ("role_adduser", $hook_params);
+
+ return true;
}
public function removeUsers($users) {
}
public function removeUser ($user) {
- return $this->removeUsers (array ($user)) ;
+ if(!$this->removeUsers (array ($user))){
+ return false;
+ }
+ $hook_params['user'] = $user;
+ $hook_params['role'] = $this;
+ plugin_hook ("role_removeuser", $hook_params);
+
+ return true;
}
public function getUsers() {
// mode: php
// c-file-style: "bsd"
// End:
-
-?>