global $SYS;
$hp = $this->getHomeProject();
if ($hp != NULL && $hp->getID() == $project->getID()) {
- $this->setError(_("Can't link to home project"));
+ $this->setError(_("Cannot link to home project"));
return false;
}
global $SYS;
$hp = $this->getHomeProject();
if ($hp != NULL && $hp->getID() == $project->getID()) {
- $this->setError (_("Can't unlink from home project"));
+ $this->setError (_("Cannot unlink from home project"));
return false;
}
*
* If an update occurred and you need to access the updated info.
*
- * @return boolean success;
+ * @param int $role_id
+ * @return bool success
*/
function fetchData($role_id) {
unset($this->data_array);
function setSetting ($section, $reference, $value) {
$cur = $this->getSettingRaw($section, $reference);
if (($value == $cur) && ($cur != NULL)) {
- return true;
+ return;
}
$role_id = $this->getID () ;
- $res = db_query_params ('DELETE FROM pfo_role_setting WHERE role_id=$1 AND section_name=$2 AND ref_id=$3',
+ db_query_params ('DELETE FROM pfo_role_setting WHERE role_id=$1 AND section_name=$2 AND ref_id=$3',
array ($role_id,
$section,
$reference)) ;
- $res = db_query_params ('INSERT INTO pfo_role_setting (role_id, section_name, ref_id, perm_val) VALUES ($1, $2, $3, $4)',
+ db_query_params ('INSERT INTO pfo_role_setting (role_id, section_name, ref_id, perm_val) VALUES ($1, $2, $3, $4)',
array ($role_id,
$section,
$reference,
}
function getSettingsForProject ($project) {
- $result = array () ;
- $group_id = $project->getID() ;
+ $result = array();
+ $group_id = $project->getID();
$sections = array ('project_read', 'project_admin', 'frs', 'scm', 'docman', 'tracker_admin', 'new_tracker') ;
foreach ($sections as $section) {
$result[$section_forum][$group_id] = $this->getVal ($section_forum, $group_id) ;
}
$sections = array_merge($sections, $sections_forum);
-
+
$ff = new ForumFactory ($project) ;
if (!$ff->isError()) {
$fids = $ff->getAllForumIdsWithNews () ;
}
array_push ($sections,'pm') ;
-
// Add settings not yet listed so far (probably plugins)
// Currently handled:
// - global settings (ignored here)
* @return multitype:
*/
function getGlobalSettings () {
- $result = array () ;
+ $result = array();
$sections = array ('forge_admin', 'forge_stats', 'approve_projects', 'approve_news') ;
foreach ($sections as $section) {
/**
* getVal - get a value out of the array of settings for this role.
*
- * @param string The name of the role.
- * @param integer The ref_id (ex: group_artifact_id, group_forum_id) for this item.
+ * @param string $section The name of the role.
+ * @param integer $ref_id The ref_id (ex: group_artifact_id, group_forum_id) for this item.
* @return integer The value of this item.
*/
function getVal($section, $ref_id) {
- global $role_default_array;
if (!$ref_id) {
$ref_id=0;
}
/**
* &getRoleVals - get all the values and language text strings for this section.
*
+ * @param string $section
* @return array Assoc array of values for this section.
*/
function &getRoleVals($section) {
global $role_vals, $rbac_permission_names;
- setup_rbac_strings () ;
+ setup_rbac_strings();
//
// Optimization - save array so it is only built once per page view
/**
* update - update a role in the database.
*
- * @param string The name of the role.
- * @param array A multi-dimensional array of data in this format: $data['section_name']['ref_id']=$val
- * @param boolean Perform permission checking
+ * @param string $role_name The name of the role.
+ * @param array $data A multi-dimensional array of data in this format: $data['section_name']['ref_id']=$val
+ * @param boolean $check_perms Perform permission checking
* @return boolean True on success or false on failure.
*/
function update($role_name,$data,$check_perms=true) {
db_begin();
+ $role_id = $this->getID () ;
if ($role_name != $this->getName()) {
$this->setName($role_name) ;
}
+ $res = db_query_params ('DELETE FROM pfo_role_setting WHERE role_id=$1',
+ array ($role_id)) ;
+
+ $res = db_prepare ('INSERT INTO pfo_role_setting (role_id, section_name, ref_id, perm_val) VALUES ($1, $2, $3, $4)',
+ 'insert_into_pfo_role_setting');
+
foreach ($data as $sect => $refs) {
foreach ($refs as $refid => $value) {
- $this->setSetting ($sect, $refid, $value) ;
+ $res = db_execute ('insert_into_pfo_role_setting',
+ array ($role_id,
+ $sect,
+ $refid,
+ $value)) ;
}
}
+ $res = db_unprepare ('insert_into_pfo_role_setting');
+
$hook_params = array ();
$hook_params['role'] =& $this;
$hook_params['role_id'] = $this->getID();
$hook_params['data'] = $data;
plugin_hook ("role_update", $hook_params);
-
db_commit();
$this->fetchData($this->getID());
array ($this->getID(),
db_string_array_to_any_clause($sections))) ;
-
// Remove obsolete settings for multiple-instance tools
db_query_params ('DELETE FROM pfo_role_setting where role_id=$1 AND section_name=$2 and ref_id NOT IN (SELECT group_artifact_id FROM artifact_group_list WHERE group_id 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(),
return true ;
}
- function normalizeDataForSection (&$new_sa, $section) {
- if (array_key_exists ($section, $this->setting_array)) {
- $new_sa[$section][0] = $this->setting_array[$section][0] ;
- } elseif (array_key_exists ($this->data_array['role_name'], $this->defaults)
- && array_key_exists ($section, $this->defaults[$this->data_array['role_name']])) {
- $new_sa[$section][0] = $this->defaults[$this->data_array['role_name']][$section] ;
- } else {
- $new_sa[$section][0] = 0 ;
- }
- return $new_sa ;
- }
-
function normalizePermsForSection (&$new_pa, $section, $refid) {
if (array_key_exists ($section, $this->perms_array)
&& array_key_exists ($refid, $this->perms_array[$section])) {
$this->fetchData ($this->getID()) ;
$projects = $this->getLinkedProjects() ;
- $new_sa = array () ;
$new_pa = array () ;
// Add missing settings
$this->normalizePermsForSection ($new_pa, 'approve_projects', -1) ;
$this->normalizePermsForSection ($new_pa, 'approve_news', -1) ;
$this->normalizePermsForSection ($new_pa, 'forge_stats', -1) ;
-
+
$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) {
if (!$p->usesTracker()) {
}
// ...forum-related settings
- $new_sa['forum'] = array () ;
$new_pa['forum'] = array () ;
foreach ($projects as $p) {
if (!$p->usesForum()) {
}
// ...pm-related settings
- $new_sa['pm'] = array () ;
$new_pa['pm'] = array () ;
foreach ($projects as $p) {
if (!$p->usesPM()) {