* FusionForge groups
*
* Copyright 1999-2001, VA Linux Systems, Inc.
- * Copyright 2009-2010, Roland Mas
+ * Copyright 2009-2013, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
* Copyright 2012-2013, Franck Villaume - TrivialDev
* IMPORTANT! That db result must contain all fields
* from groups table or you will have problems
*
- * @param int $group_id Required
- * @param int|bool $res Result set handle ("SELECT * FROM groups WHERE group_id=xx")
- * @return Group|bool A group object or false on failure
+ * @param int $group_id Required
+ * @param int|bool $res Result set handle ("SELECT * FROM groups WHERE group_id=xx")
+ * @return Group|bool A group object or false on failure
*/
function &group_get_object($group_id, $res = false) {
//create a common set of group objects
if ($res) {
//the db result handle was passed in
} else {
- $res = db_query_params('SELECT * FROM groups WHERE group_id=$1', array($group_id)) ;
+ $res = db_query_params('SELECT * FROM groups WHERE group_id=$1', array($group_id));
}
if (!$res || db_numrows($res) < 1) {
$GROUP_OBJ["_".$group_id."_"]=false;
foreach ($id_arr as $id) {
//
- // See if this ID already has been fetched in the cache
+ // See if this ID already has been fetched in the cache
//
if (!isset($GROUP_OBJ["_".$id."_"])) {
$fetch[] = $id;
}
if (count($fetch) > 0) {
$res=db_query_params('SELECT * FROM groups WHERE group_id = ANY ($1)',
- array(db_int_array_to_any_clause($fetch)));
+ array(db_int_array_to_any_clause($fetch)));
while ($arr = db_fetch_array($res)) {
$GROUP_OBJ["_".$arr['group_id']."_"] = new Group($arr['group_id'],$arr);
}
function &group_get_active_projects() {
$res = db_query_params('SELECT group_id FROM groups WHERE status=$1',
- array('A'));
+ array('A'));
+ return group_get_objects(util_result_column_to_array($res,0));
+}
+
+function &group_get_all_projects() {
+ $res = db_query_params ('SELECT group_id FROM groups',
+ array());
return group_get_objects(util_result_column_to_array($res,0));
}
function &group_get_template_projects() {
- $res=db_query_params ('SELECT group_id FROM groups WHERE is_template=1 AND status != $1',
- array ('D')) ;
- return group_get_objects (util_result_column_to_array($res,0)) ;
+ $res = db_query_params('SELECT group_id FROM groups WHERE is_template=1 AND status != $1',
+ array('D'));
+ return group_get_objects(util_result_column_to_array($res,0));
}
function &group_get_object_by_name($groupname) {
function &group_get_objects_by_name($groupname_arr) {
$res = db_query_params('SELECT group_id FROM groups WHERE unix_group_name = ANY ($1)',
- array(db_string_array_to_any_clause($groupname_arr)));
+ array(db_string_array_to_any_clause($groupname_arr)));
$arr =& util_result_column_to_array($res,0);
return group_get_objects($arr);
}
-function &group_get_object_by_publicname($groupname) {
+function group_get_object_by_publicname($groupname) {
$res = db_query_params('SELECT * FROM groups WHERE lower(group_name) LIKE $1',
- array(htmlspecialchars(strtolower($groupname))));
+ array(htmlspecialchars(strtolower($groupname))));
return group_get_object(db_result($res, 0, 'group_id'), $res);
}
/**
* get_public_active_projects_asc() - Get a list of rows for public active projects (initially in trove/full_list)
*
- * @param int Opional Maximum number of rows to limit query length
+ * @param int $max_query_limit Optional Maximum number of rows to limit query length
+ * @return array List of public active projects
*/
function get_public_active_projects_asc($max_query_limit = -1) {
$res_grp = db_query_params ('
SELECT group_id, group_name, unix_group_name, short_description, register_time
FROM groups
- WHERE status = $1 AND type_id=1 AND group_id>4 AND register_time > 0
+ WHERE status = $1 AND type_id=1 AND is_template=0 AND register_time > 0
ORDER BY group_name ASC
',
- array ('A'),
+ array('A'),
$max_query_limit);
$projects = array();
while ($row_grp = db_fetch_array($res_grp)) {
if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
- continue ;
+ continue;
}
$projects[] = $row_grp;
}
/**
* Group - Group object constructor - use group_get_object() to instantiate.
*
- * @param int|bool $id Required - Id of the group you want to instantiate.
- * @param int|bool $res Database result from select query OR associative array of all columns.
- * @return boolean Success or not
+ * @param int|bool $id Required - Id of the group you want to instantiate.
+ * @param int|bool $res Database result from select query OR associative array of all columns.
*/
function __construct($id = false, $res = false) {
$this->Error();
if (!$id) {
//setting up an empty object
//probably going to call create()
- return true;
+ return;
}
if (!$res) {
if (!$this->fetchData($id)) {
- return false;
+ return;
}
} else {
//
//function in class we extended
$this->setError(_('Group Not Found'));
$this->data_array=array();
- return false;
+ return;
} else {
//set up an associative array for use by other functions
$this->data_array = db_fetch_array_by_row($res, 0);
}
}
}
- return true;
+
}
/**
* fetchData - May need to refresh database fields if an update occurred.
*
- * @param int $group_id The group_id.
- * @return boolean success or not
+ * @param int $group_id The group_id.
+ * @return boolean success or not
*/
function fetchData($group_id) {
$res = db_query_params ('SELECT * FROM groups WHERE group_id=$1',
- array ($group_id));
+ array($group_id));
if (!$res || db_numrows($res) < 1) {
- $this->setError(sprintf(_('fetchData():: %s'),db_error()));
+ $this->setError(sprintf('fetchData():: %s', db_error()));
return false;
}
$this->data_array = db_fetch_array($res);
* This method should be called on empty Group object.
* It will add an entry for a pending group/project (status 'P')
*
- * @param object The User object.
- * @param string The full name of the user.
- * @param string The Unix name of the user.
- * @param string The new group description.
- * @param string The purpose of the group.
- * @param boolean Whether to send an email or not
- * @param int The id of the project this new project is based on
+ * @param object $user The User object.
+ * @param string $group_name The full name of the user.
+ * @param string $unix_name The Unix name of the user.
+ * @param string $description The new group description.
+ * @param string $purpose The purpose of the group.
+ * @param string $unix_box
+ * @param string $scm_box
+ * @param bool $is_public
+ * @param bool $send_mail Whether to send an email or not
+ * @param int $built_from_template The id of the project this new project is based on
* @return boolean success or not
*/
function create(&$user, $group_name, $unix_name, $description, $purpose, $unix_box = 'shell1',
- $scm_box = 'cvs1', $is_public = 1, $send_mail = true, $built_from_template = 0) {
+ $scm_box = 'cvs1', $is_public = true, $send_mail = true, $built_from_template = 0) {
// $user is ignored - anyone can create pending group
global $SYS;
if ($this->getID()!=0) {
- $this->setError(_('Group::create: Group object already exists'));
+ $this->setError(_('Group object already exists.'));
return false;
} elseif (!$this->validateGroupName($group_name)) {
return false;
} elseif (!account_groupnamevalid($unix_name)) {
- $this->setError(_('Invalid Unix name'));
+ $this->setError(_('Invalid Unix Name.'));
return false;
} elseif (!$SYS->sysUseUnixName($unix_name)) {
- $this->setError(_('Unix name already taken'));
+ $this->setError(_('Unix name already taken.'));
return false;
} elseif (db_numrows(db_query_params('SELECT group_id FROM groups WHERE unix_group_name=$1',
- array($unix_name))) > 0) {
- $this->setError(_('Unix name already taken'));
+ array($unix_name))) > 0) {
+ $this->setError(_('Unix name already taken.'));
return false;
} elseif (strlen($purpose)<10) {
- $this->setError(_('Please describe your Registration Purpose in a more comprehensive manner'));
+ $this->setError(_('Please describe your Registration Project Purpose and Summarization in a more comprehensive manner.'));
return false;
} elseif (strlen($purpose)>1500) {
- $this->setError(_('The Registration Purpose text is too long. Please make it smaller than 1500 bytes.'));
+ $this->setError(_('The Registration Project Purpose and Summarization text is too long. Please make it smaller than 1500 characters.'));
return false;
} elseif (strlen($description)<10) {
$this->setError(_('Describe in a more comprehensive manner your project.'));
built_from_template
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)',
- array (htmlspecialchars ($group_name),
- $unix_name,
- htmlspecialchars($description),
- $homepage,
- $homepage,
- 'P',
- $unix_box,
- $scm_box,
- htmlspecialchars($purpose),
- time(),
- md5(util_randbytes()),
- $built_from_template));
+ array(htmlspecialchars($group_name),
+ $unix_name,
+ htmlspecialchars($description),
+ $homepage,
+ $homepage,
+ 'P',
+ $unix_box,
+ $scm_box,
+ htmlspecialchars($purpose),
+ time(),
+ md5(util_randbytes()),
+ $built_from_template));
if (!$res || db_affected_rows($res) < 1) {
- $this->setError(sprintf(_('ERROR: Could not create group: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot create group: %s'),db_error()));
db_rollback();
return false;
}
$id = db_insertid($res, 'groups', 'group_id');
if (!$id) {
- $this->setError(sprintf(_('ERROR: Could not get group id: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot get group id: %s'),db_error()));
db_rollback();
return false;
}
$gjr = new GroupJoinRequest($this);
$gjr->create($user->getID(),
- 'Fake GroupJoinRequest to store the creator of a project',
- false);
+ 'Fake GroupJoinRequest to store the creator of a project',
+ false);
$hook_params = array();
$hook_params['group'] = $this;
*
* This function require site admin privilege.
*
- * @param object User requesting operation (for access control).
- * @param int Group type (1-project, 2-foundry).
- * @param string Machine on which group's home directory located.
- * @param string Domain which serves group's WWW.
- * @return status.
+ * @param object $user User requesting operation (for access control).
+ * @param int $type_id Group type (1-project, 2-foundry).
+ * @param string $unix_box Machine on which group's home directory located.
+ * @param string $http_domain Domain which serves group's WWW.
+ * @return bool status.
* @access public
*/
function updateAdmin(&$user, $type_id, $unix_box, $http_domain) {
SET type_id=$1, unix_box=$2, http_domain=$3
WHERE group_id=$4',
array($type_id,
- $unix_box,
- $http_domain,
- $this->getID()));
+ $unix_box,
+ $http_domain,
+ $this->getID()));
if (!$res || db_affected_rows($res) < 1) {
- $this->setError(_('ERROR: DB: Could not change group properties: %s'),db_error());
+ $this->setError(_('Error: Cannot change group properties: %s'),db_error());
db_rollback();
return false;
}
*
* Unlike updateAdmin(), this function accessible to project admin.
*
- * @param object User requesting operation (for access control).
- * @param boolean Whether group is publicly accessible (0/1).
- * @param string Project's license (string ident).
- * @param int Group type (1-project, 2-foundry).
- * @param string Machine on which group's home directory located.
- * @param string Domain which serves group's WWW.
- * @return int status.
- * @access public
+ * @param object $user User requesting operation (for access control).
+ * @param string $group_name
+ * @param string $homepage
+ * @param string $short_description
+ * @param bool $use_mail
+ * @param bool $use_survey
+ * @param bool $use_forum
+ * @param bool $use_pm
+ * @param bool $use_pm_depend_box
+ * @param bool $use_scm
+ * @param bool $use_news
+ * @param bool $use_docman
+ * @param string $new_doc_address
+ * @param bool $send_all_docs
+ * @param int $logo_image_id
+ * @param bool $use_ftp
+ * @param bool $use_tracker
+ * @param bool $use_frs
+ * @param bool $use_stats
+ * @param $tags
+ * @param bool $use_activity
+ * @param bool $is_public group is publicly accessible
+ * @return int status.
+ * @access public
*/
function update(&$user, $group_name, $homepage, $short_description, $use_mail, $use_survey, $use_forum,
$use_pm, $use_pm_depend_box, $use_scm, $use_news, $use_docman,
use_stats=$16,
use_activity=$17
WHERE group_id=$18',
- array(htmlspecialchars($group_name),
- $homepage,
- htmlspecialchars($short_description),
- $use_mail,
- $use_survey,
- $use_forum,
- $use_pm,
- $use_pm_depend_box,
- $use_scm,
- $use_news,
- $new_doc_address,
- $send_all_docs,
- $use_ftp,
- $use_tracker,
- $use_frs,
- $use_stats,
- $use_activity,
- $this->getID()));
+ array(htmlspecialchars($group_name),
+ $homepage,
+ htmlspecialchars($short_description),
+ $use_mail,
+ $use_survey,
+ $use_forum,
+ $use_pm,
+ $use_pm_depend_box,
+ $use_scm,
+ $use_news,
+ $new_doc_address,
+ $send_all_docs,
+ $use_ftp,
+ $use_tracker,
+ $use_frs,
+ $use_stats,
+ $use_activity,
+ $this->getID()));
if (!$res || db_affected_rows($res) < 1) {
$this->setError(sprintf(_('Error updating project information: %s'), db_error()));
return false;
}
+ // Log the audit trail
+ $this->addHistory('Changed Public Info', '');
+
+ if (!$this->fetchData($this->getID())) {
+ db_rollback();
+ return false;
+ }
+
$hook_params = array();
$hook_params['group'] = $this;
$hook_params['group_id'] = $this->getID();
return false;
}
- // Log the audit trail
- $this->addHistory('Changed Public Info', '');
-
- if (!$this->fetchData($this->getID())) {
- db_rollback();
- return false;
- }
db_commit();
return true;
}
* I: Incomplete
* D: Deleted
*
- * @param object User requesting operation (for access control).
- * @param string Status value.
+ * @param object $user User requesting operation (for access control).
+ * @param string $status Status value.
* @return boolean success.
* @access public
*/
WHERE group_id=$2', array($status, $this->getID()));
if (!$res || db_affected_rows($res) < 1) {
- $this->setError(sprintf(_('ERROR: DB: Could not change group status: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot change group status: %s'),db_error()));
db_rollback();
return false;
}
// Log the audit trail
if ($status != $this->getStatus()) {
- $this->addHistory('Status', $this->getStatus());
+ $this->addHistory(_('Status'), $this->getStatus());
}
$this->data_array['status'] = $status;
* @return boolean is_public.
*/
function isPublic() {
- $ra = RoleAnonymous::getInstance() ;
+ $ra = RoleAnonymous::getInstance();
return $ra->hasPermission('project_read', $this->getID());
}
/**
* setAsTemplate - Set the template status of a project
*
- * @param boolean is_template.
+ * @param boolean $booleanparam is_template.
+ * @return bool
*/
function setAsTemplate($booleanparam) {
db_begin();
/**
* setSCMBox - the hostname of the scm box where this project is located.
*
- * @param string The name of the new SCM_BOX
+ * @param string $scm_box The name of the new SCM_BOX
+ * @return bool
*/
function setSCMBox($scm_box) {
}
if ($scm_box) {
db_begin();
- $res = db_query_params('UPDATE groups SET scm_box=$1 WHERE group_id=$2', array($scm_box, $this->getID ()));
+ $res = db_query_params('UPDATE groups SET scm_box=$1 WHERE group_id=$2', array($scm_box, $this->getID()));
if ($res) {
$this->addHistory('scm_box', $this->data_array['scm_box']);
$this->data_array['scm_box'] = $scm_box;
return true;
} else {
db_rollback();
- $this->setError(_("Couldn't insert SCM_BOX to database"));
+ $this->setError(_("Could not insert SCM_BOX to database"));
return false;
}
} else {
- $this->setError(_("SCM Box can't be empty"));
+ $this->setError(_("SCM Box cannot be empty"));
return false;
}
}
return $this->data_array['register_purpose'];
}
-
/**
* getAdmins() - Get array of Admin user objects.
*
continue;
}
if ($role->getHomeProject() == NULL
- || $role->getHomeProject()->getID() != $this->getID()) {
+ || $role->getHomeProject()->getID() != $this->getID()) {
continue;
}
if ($res) {
$this->data_array['enable_pserver'] = $booleanparam;
db_commit();
+ return true;
} else {
db_rollback();
return false;
/**
* setUseSCM - Set the SCM usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUseSCM($booleanparam) {
db_begin();
- $booleanparam = $booleanparam ? 1 : 0 ;
+ $booleanparam = $booleanparam ? 1 : 0;
$res = db_query_params('UPDATE groups SET use_scm=$1 WHERE group_id=$2',
array($booleanparam, $this->getID()));
if ($res) {
$this->data_array['use_scm']=$booleanparam;
- db_commit () ;
- return true ;
+ db_commit();
+ return true;
} else {
- db_rollback () ;
- return false ;
+ db_rollback();
+ return false;
}
}
} else {
return false;
}
+
+ $hook_params = array();
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ $hook_params['group_homepage'] = $this->getHomePage();
+ $hook_params['group_name'] = $this->getPublicName();
+ $hook_params['group_description'] = $this->getDescription();
+ plugin_hook ("group_update", $hook_params);
}
/**
* setUseMail - Set the mailing-list usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUseMail($booleanparam) {
db_begin();
- $booleanparam = $booleanparam ? 1 : 0 ;
+ $booleanparam = $booleanparam ? 1 : 0;
$res = db_query_params('UPDATE groups SET use_mail=$1 WHERE group_id=$2',
array($booleanparam, $this->getID()));
if ($res) {
/**
* setUseForum - Set the forum usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUseForum($booleanparam) {
db_begin();
/**
* setUseFRS - Set the FRS usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUseFRS($booleanparam) {
db_begin();
$booleanparam = $booleanparam ? 1 : 0;
$res = db_query_params('UPDATE groups SET use_frs=$1 WHERE group_id=$2',
- array ($booleanparam, $this->getID()));
+ array($booleanparam, $this->getID()));
if ($res) {
$this->data_array['use_frs']=$booleanparam;
db_commit();
/**
* setUseTracker - Set the tracker usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUseTracker ($booleanparam) {
- db_begin () ;
- $booleanparam = $booleanparam ? 1 : 0 ;
+ db_begin();
+ $booleanparam = $booleanparam ? 1 : 0;
$res = db_query_params ('UPDATE groups SET use_tracker=$1 WHERE group_id=$2',
- array ($booleanparam, $this->getID()));
+ array($booleanparam, $this->getID()));
if ($res) {
$this->data_array['use_tracker']=$booleanparam;
- db_commit () ;
- return true ;
+ db_commit();
+ return true;
} else {
- db_rollback () ;
- return false ;
+ db_rollback();
+ return false;
}
}
/**
* setUseDocman - Set the docman usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUseDocman($booleanparam) {
db_begin();
/**
* setUsePM - Set the PM usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
+ * @return bool
*/
function setUsePM($booleanparam) {
db_begin();
* added for Codendi compatibility
* usesServices - returns true if the group uses a particular plugin or feature
*
- * @param string name of the plugin
+ * @param string $feature name of the plugin
* @return boolean whether plugin is being used or not
*/
function usesService($feature) {
/**
* setPluginUse - enables/disables plugins for the group
*
- * @param string name of the plugin
- * @param boolean the new state
+ * @param string $pluginname name of the plugin
+ * @param boolean $val the new state
* @return string database result
*/
function setPluginUse($pluginname, $val=true) {
if ($val) {
$res = db_query_params('INSERT INTO group_plugin (group_id, plugin_id) VALUES ($1, $2)',
array($this->getID(),
- $plugin_id));
+ $plugin_id));
return $res;
} else {
$res = db_query_params('DELETE FROM group_plugin WHERE group_id=$1 AND plugin_id=$2',
array($this->getID(),
- $plugin_id));
+ $plugin_id));
return $res;
}
- $this->normalizeAllRoles () ;
+ $this->normalizeAllRoles();
}
/**
return $this->data_array['send_all_docs'];
}
-
/**
* getHomePage - The URL for this project's home page.
*
*/
function getHomePage() {
if (!preg_match("/^[a-zA-Z][a-zA-Z0-9+.-]*:/",
- $this->data_array['homepage'])) {
+ $this->data_array['homepage'])) {
$this->data_array['homepage'] = util_url_prefix() .
- $this->data_array['homepage'];
+ $this->data_array['homepage'];
}
return $this->data_array['homepage'];
}
/**
* setTags - Set tags of this project.
*
+ * @param string $tags
* @return string database result.
*/
function setTags($tags) {
$res = db_query_params($sql, array($this->getID(), $tag));
if (!$res) {
$this->setError(_('Setting tags:') . ' ' .
- db_error());
+ db_error());
db_rollback();
return false;
}
return permission_get_object($this);
}
-
function delete($sure, $really_sure, $really_really_sure) {
if (!$sure || !$really_sure || !$really_really_sure) {
$this->setMissingParamsError(_('Please tick all checkboxes.'));
// unlink roles from this project
foreach ($this->getRoles() as $r) {
if ($r->getHomeProject() == NULL
- || $r->getHomeProject()->getID() != $this->getID()) {
+ || $r->getHomeProject()->getID() != $this->getID()) {
$r->unlinkProject($this);
}
}
// Delete group cvs stats
//
$res = db_query_params ('DELETE FROM stats_cvs_group WHERE group_id=$1',
- array ($this->getID())) ;
+ array($this->getID()));
if (!$res) {
$this->setError(_('Error Deleting SCM Statistics: ').db_error());
db_rollback();
$res = db_query_params('INSERT INTO deleted_groups (unix_group_name, delete_date, isdeleted) VALUES ($1, $2, $3)',
array($this->getUnixName(),
- time(),
- 0));
+ time(),
+ 0));
if (!$res) {
$this->setError(_('Error Deleting Project:').' '.db_error());
db_rollback();
//
// Delete reporting
//
- $res = db_query_params('DELETE FROM rep_group_act_monthly WHERE group_id=$1',
- array ($this->getID()));
+ db_query_params('DELETE FROM rep_group_act_monthly WHERE group_id=$1',
+ array($this->getID()));
//echo 'rep_group_act_monthly'.db_error();
- $res = db_query_params('DELETE FROM rep_group_act_weekly WHERE group_id=$1',
- array ($this->getID()));
+ db_query_params('DELETE FROM rep_group_act_weekly WHERE group_id=$1',
+ array($this->getID()));
//echo 'rep_group_act_weekly'.db_error();
- $res = db_query_params('DELETE FROM rep_group_act_daily WHERE group_id=$1',
- array ($this->getID()));
+ db_query_params('DELETE FROM rep_group_act_daily WHERE group_id=$1',
+ array($this->getID()));
//echo 'rep_group_act_daily'.db_error();
unset($this->data_array);
return true;
/**
* addUser - controls adding a user to a group.
*
- * @param string Unix name of the user to add OR integer user_id.
- * @param int The role_id this user should have.
+ * @param string $user_identifier Unix name of the user to add OR integer user_id.
+ * @param int $role_id The role_id this user should have.
* @return boolean success.
* @access public
*/
- function addUser($user_identifier,$role_id) {
+ function addUser($user_identifier, $role_id) {
global $SYS;
/*
Admins can add users to groups
get user id for this user's unix_name
*/
if (is_int ($user_identifier)) { // user_id or user_name
- $res_newuser = db_query_params ('SELECT * FROM users WHERE user_id=$1', array ($user_identifier)) ;
+ $res_newuser = db_query_params ('SELECT * FROM users WHERE user_id=$1', array($user_identifier));
} else {
- $res_newuser = db_query_params ('SELECT * FROM users WHERE user_name=$1', array ($user_identifier)) ;
+ $res_newuser = db_query_params ('SELECT * FROM users WHERE user_name=$1', array($user_identifier));
}
if (db_numrows($res_newuser) > 0) {
//
return false;
}
- $role->addUser(user_get_object($user_id)) ;
+ $role->addUser(user_get_object($user_id));
if (!$SYS->sysCheckCreateGroup($this->getID())){
$this->setError($SYS->getErrorMessage());
db_rollback();
//
// user doesn't exist
//
- $this->setError(_('ERROR: User does not exist'));
+ $this->setError(_('That user does not exist.'));
db_rollback();
return false;
}
*
* Users can remove themselves.
*
- * @param int The ID of the user to remove.
+ * @param int $user_id The ID of the user to remove.
* @return boolean success.
*/
function removeUser($user_id) {
global $SYS;
if ($user_id != user_getid()
- && !forge_check_perm('project_admin', $this->getID())) {
+ && !forge_check_perm('project_admin', $this->getID())) {
$this->setPermissionDeniedError();
return false;
}
}
}
if ($found_role == NULL) {
- $this->setError(sprintf(_('ERROR: User not removed: %s')));
+ $this->setError(sprintf(_('Error: User not removed: %s')));
db_rollback();
return false;
}
db_rollback();
return false;
}
-
+
//
// reassign open artifacts to id=100
//
FROM artifact_group_list
WHERE group_id=$1 AND status_id=1 AND assigned_to=$2)',
array($this->getID(),
- $user_id));
+ $user_id));
if (!$res) {
- $this->setError(_('ERROR: DB: artifact:').' '.db_error());
+ $this->setError(_('Error: artifact:').' '.db_error());
db_rollback();
return false;
}
AND pat.assigned_to_id=$2)
AND assigned_to_id=100',
array($this->getID(),
- $user_id));
+ $user_id));
if (!$res) {
- $this->setError(sprintf(_('ERROR: DB: project_assigned_to %d: %s'), 1, db_error()));
+ $this->setError(sprintf(_('Error: project_assigned_to %d: %s'), 1, db_error()));
db_rollback();
return false;
}
AND pt.status_id=1 AND pgl.group_id=$1)
AND assigned_to_id=$2',
array($this->getID(),
- $user_id));
+ $user_id));
if (!$res) {
- $this->setError(sprintf(_('ERROR: DB: project_assigned_to %d: %s'), 2, db_error()));
+ $this->setError(sprintf(_('Error: project_assigned_to %d: %s'), 2, db_error()));
db_rollback();
return false;
}
/**
* updateUser - controls updating a user's role in this group.
*
- * @param int The ID of the user.
- * @param int The role_id to set this user to.
+ * @param int $user_id The ID of the user.
+ * @param int $role_id The role_id to set this user to.
* @return boolean success.
*/
- function updateUser($user_id,$role_id) {
+ function updateUser($user_id, $role_id) {
if (!forge_check_perm ('project_admin', $this->getID())) {
$this->setPermissionDeniedError();
return false;
}
- $newrole = RBACEngine::getInstance()->getRoleById ($role_id) ;
+ $newrole = RBACEngine::getInstance()->getRoleById ($role_id);
if (!$newrole || !is_object($newrole)) {
$this->setError(_('Could Not Get Role'));
return false;
$this->setError(_('Wrong destination role'));
return false;
}
- $user = user_get_object ($user_id) ;
- $roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user) ;
- $found_role = NULL ;
+ $user = user_get_object ($user_id);
+ $roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user);
+ $found_role = NULL;
foreach ($roles as $role) {
if ($role->getHomeProject() && $role->getHomeProject()->getID() == $this->getID()) {
- $found_role = $role ;
- break ;
+ $found_role = $role;
+ break;
}
}
if ($found_role == NULL) {
- $this->setError(sprintf(_('ERROR: User not removed: %s')));
+ $this->setError(sprintf(_('Error: User not removed: %s')));
db_rollback();
return false;
}
- $found_role->removeUser ($user) ;
- $newrole->addUser ($user) ;
+ $found_role->removeUser ($user);
+ $newrole->addUser ($user);
$this->addHistory('Updated User',$user_id);
return true;
/**
* addHistory - Makes an audit trail entry for this project.
*
- * @param string The name of the field.
- * @param string The Old Value for this $field_name.
- * @return database result handle.
+ * @param string $field_name The name of the field.
+ * @param string $old_value The Old Value for this $field_name.
+ * @return resource database result handle.
* @access public
*/
function addHistory($field_name, $old_value) {
return db_query_params ('INSERT INTO group_history(group_id,field_name,old_value,mod_by,adddate)
VALUES ($1,$2,$3,$4,$5)',
- array ($this->getID(),
- $field_name,
- $old_value,
- user_getid(),
- time()));
+ array($this->getID(),
+ $field_name,
+ $old_value,
+ user_getid(),
+ time()));
}
/**
Activate member(s) of the project
*/
- $members = $this->getUsers (true) ;
+ $members = $this->getUsers (true);
foreach ($members as $member) {
- $roles = array () ;
+ $roles = array();
foreach (RBACEngine::getInstance()->getAvailableRolesForUser ($member) as $role) {
if ($role->getHomeProject() && $role->getHomeProject()->getID() == $this->getID()) {
- $roles[] = $role ;
+ $roles[] = $role;
}
+ }
+ foreach ($roles as $role) {
if (!$this->addUser($member->getUnixName(),$role->getID())) {
return false;
}
}
/**
- * getMembers - returns array of User objects for this project
+ * getMembers - returns array of User objects for this project
*
- * @return array of User objects for this group.
+ * @return array of User objects for this group.
*/
function getMembers() {
- return $this->getUsers (true) ;
+ return $this->getUsers (true);
}
/**
- * replaceTemplateStrings - fill-in some blanks with project name
+ * replaceTemplateStrings - fill-in some blanks with project name
*
- * @param string Template string
- * @return string String after replacements
+ * @param string $string Template string
+ * @return string String after replacements
*/
function replaceTemplateStrings($string) {
- $string = str_replace ('UNIXNAME', $this->getUnixName(), $string) ;
- $string = str_replace ('PUBLICNAME', $this->getPublicName(), $string) ;
- $string = str_replace ('DESCRIPTION', $this->getDescription(), $string) ;
- return $string ;
+ $string = str_replace ('UNIXNAME', $this->getUnixName(), $string);
+ $string = str_replace ('PUBLICNAME', $this->getPublicName(), $string);
+ $string = str_replace ('DESCRIPTION', $this->getDescription(), $string);
+ return $string;
}
/**
- * approve - Approve pending project.
+ * approve - Approve pending project.
*
- * @param object The User object who is doing the updating.
- * @access public
+ * @param object $user The User object who is doing the updating.
+ * @return bool
+ * @access public
*/
function approve(&$user) {
global $gfcommon,$gfwww;
$idadmin_group = NULL;
foreach (get_group_join_requests ($this) as $gjr) {
$idadmin_group = $gjr->getUserID();
- break ;
+ break;
}
if ($idadmin_group == NULL) {
$idadmin_group = $user->getID();
}
$id_mappings['role'][$oldrole->getID()] = $role->getID();
// Reuse the project_admin permission
- $role->setSetting ('project_admin', $this->getID(), $oldrole->getSetting ('project_admin', $template->getID())) ;
+ $role->setSetting ('project_admin', $this->getID(), $oldrole->getSetting ('project_admin', $template->getID()));
}
}
if (!$seen_admin_role) {
$role = new Role($this);
- $adminperms = array ('project_admin' => array ($this->getID() => 1)) ;
- $role_id = $role->create ('Admin', $adminperms, true) ;
+ $adminperms = array('project_admin' => array ($this->getID() => 1));
+ $role_id = $role->create ('Admin', $adminperms, true);
}
- $roles = $this->getRoles() ;
+ $roles = $this->getRoles();
foreach ($roles as $r) {
if ($r->getHomeProject() == NULL) {
continue;
$r->addUser(user_get_object ($idadmin_group));
}
}
-
+
// Temporarily switch to the submitter's identity
$saved_session = session_get_user();
session_set_internal($idadmin_group);
if ($template->usesTracker()) {
$oldatf = new ArtifactTypeFactory($template);
foreach ($oldatf->getArtifactTypes() as $o) {
- $t = new ArtifactType ($this) ;
- $t->create ($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->emailAll(),$o->getEmailAddress(),$o->getDuePeriod()/86400,0,$o->getSubmitInstructions(),$o->getBrowseInstructions()) ;
+ $t = new ArtifactType ($this);
+ $t->create ($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->emailAll(),$o->getEmailAddress(),$o->getDuePeriod()/86400,0,$o->getSubmitInstructions(),$o->getBrowseInstructions());
$id_mappings['tracker'][$o->getID()] = $t->getID();
$t->cloneFieldsFrom ($o->getID());
}
}
if (forge_get_config('use_forum')) {
- $this->setUseForum($template->usesForum()) ;
+ $this->setUseForum($template->usesForum());
if ($template->usesForum()) {
- $oldff = new ForumFactory($template) ;
+ $oldff = new ForumFactory($template);
foreach ($oldff->getForums() as $o) {
$f = new Forum($this);
$f->create($this->replaceTemplateStrings($o->getName()),$this->replaceTemplateStrings($o->getDescription()),$o->getSendAllPostsTo(),1);
}
if (forge_get_config('use_mail')) {
- $this->setUseMail($template->usesMail()) ;
+ $this->setUseMail($template->usesMail());
if ($template->usesMail()) {
$oldmlf = new MailingListFactory($template);
foreach ($oldmlf->getMailingLists() as $o) {
$ml = new MailingList($this);
- $nname = preg_replace ('/^'.$template->getUnixName().'-/','',$o->getName()) ;
+ $nname = preg_replace ('/^'.$template->getUnixName().'-/','',$o->getName());
- $ndescription = $this->replaceTemplateStrings($o->getDescription()) ;
+ $ndescription = $this->replaceTemplateStrings($o->getDescription());
$ml->create($nname, $ndescription, $o->isPublic());
}
}
$this->setUseSCM($template->usesSCM());
foreach ($template->getPlugins() as
- $plugin_id => $plugin_name) {
+ $plugin_id => $plugin_name) {
$this->setPluginUse($plugin_name);
}
} else {
/* use SCM choice from registration page */
foreach ($template->getPlugins() as
- $plugin_id => $plugin_name) {
+ $plugin_id => $plugin_name) {
if (substr($plugin_name, 3) == 'scm' &&
- $plugin_name != 'scmhook') {
+ $plugin_name != 'scmhook') {
/* skip copying scm plugins */
continue;
}
}
foreach ($template->getRoles() as $oldrole) {
- $newrole = RBACEngine::getInstance()->getRoleById ($id_mappings['role'][$oldrole->getID()]) ;
+ $newrole = RBACEngine::getInstance()->getRoleById ($id_mappings['role'][$oldrole->getID()]);
if ($oldrole->getHomeProject() != NULL
- && $oldrole->getHomeProject()->getID() == $template->getID()) {
- $newrole->setPublic ($oldrole->isPublic()) ;
+ && $oldrole->getHomeProject()->getID() == $template->getID()) {
+ $newrole->setPublic ($oldrole->isPublic());
}
- $oldsettings = $oldrole->getSettingsForProject ($template) ;
+ $oldsettings = $oldrole->getSettingsForProject ($template);
- $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', 'forum_admin', 'new_forum', 'pm_admin', 'new_pm');
foreach ($sections as $section) {
- $newrole->setSetting ($section, $this->getID(), $oldsettings[$section][$template->getID()]) ;
+ $newrole->setSetting ($section, $this->getID(), $oldsettings[$section][$template->getID()]);
}
- $sections = array ('tracker', 'pm', 'forum') ;
+ $sections = array('tracker', 'pm', 'forum');
foreach ($sections as $section) {
if (isset ($oldsettings[$section])) {
foreach ($oldsettings[$section] as $k => $v) {
// Only copy perms for tools that have been copied
if (isset ($id_mappings[$section][$k])) {
$newrole->setSetting ($section,
- $id_mappings[$section][$k],
- $v) ;
+ $id_mappings[$section][$k],
+ $v);
}
}
}
}
$lm = new WidgetLayoutManager();
- $lm->createDefaultLayoutForProject ($this->getID(), $template->getID()) ;
+ $lm->createDefaultLayoutForProject ($this->getID(), $template->getID());
- $params = array () ;
- $params['template'] = $template ;
- $params['project'] = $this ;
- $params['id_mappings'] = $id_mappings ;
- plugin_hook_by_reference ('clone_project_from_template', $params) ;
+ $params = array();
+ $params['template'] = $template;
+ $params['project'] = $this;
+ $params['id_mappings'] = $id_mappings;
+ plugin_hook_by_reference ('clone_project_from_template', $params);
} else {
// Disable everything
db_query_params ('UPDATE groups SET use_mail=0, use_survey=0, use_forum=0, use_pm=0, use_pm_depend_box=0, use_scm=0, use_news=0, use_docman=0, use_ftp=0, use_tracker=0, use_frs=0, use_stats=0 WHERE group_id=$1',
- array ($this->getID())) ;
+ array($this->getID()));
}
$this->normalizeAllRoles();
+ // empty members cache because the group creator is not yet in cache.
+ unset($this->membersArr);
$this->activateUsers();
// Delete fake join request
foreach (get_group_join_requests ($this) as $gjr) {
- $gjr->delete(true) ;
+ $gjr->delete(true);
}
// Switch back to user preference
db_commit();
$this->sendApprovalEmail();
- $this->addHistory('Approved', 'x');
+ $this->addHistory(_('Approved'), 'x');
//
// Plugin can make approve operation there
//
- $params[0] = $idadmin_group;
- $params[1] = $this->getID();
+ $params = array();
+ $params['group'] = $this;
+ $params['group_id'] = $this->getID();
plugin_hook('group_approved', $params);
return true;
}
-
-
/**
* sendApprovalEmail - Send new project email.
*
* @access public
*/
function sendApprovalEmail() {
- $admins = RBACEngine::getInstance()->getUsersByAllowedAction ('project_admin', $this->getID()) ;
+ $admins = RBACEngine::getInstance()->getUsersByAllowedAction ('project_admin', $this->getID());
if (count($admins) < 1) {
$this->setError(_("Group does not have any administrators."));
// send one email per admin
foreach ($admins as $admin) {
- setup_gettext_for_user ($admin) ;
+ setup_gettext_for_user ($admin);
$message=sprintf(_('Your project registration for %4$s has been approved.
if there is anything we can do to help you.
-- the %4$s crew'),
- htmlspecialchars_decode($this->getPublicName()),
- $this->getUnixName(),
- util_make_url ('/project/admin/?group_id='.$this->getID()),
- forge_get_config ('forge_name'));
+ htmlspecialchars_decode($this->getPublicName()),
+ $this->getUnixName(),
+ util_make_url ('/project/admin/?group_id='.$this->getID()),
+ forge_get_config ('forge_name'));
- util_send_message($admin->getEmail(), sprintf(_('%1$s Project Approved'), forge_get_config ('forge_name')), $message);
+ util_send_message($admin->getEmail(), sprintf(_('%s Project Approved'), forge_get_config ('forge_name')), $message);
setup_gettext_from_context();
}
return true;
}
-
/**
* sendRejectionEmail - Send project rejection email.
*
* This function sends out a rejection message to a user who
* registered a project.
*
- * @param int The id of the response to use.
- * @param string The rejection message.
- * @return boolean completion status.
+ * @param int $response_id The id of the response to use.
+ * @param string $message The rejection message.
+ * @return bool completion status.
* @access public
*/
function sendRejectionEmail($response_id, $message="zxcv") {
- $submitters = array () ;
+ $submitters = array();
foreach (get_group_join_requests ($this) as $gjr) {
$submitters[] = user_get_object($gjr->getUserID());
}
foreach ($submitters as $admin) {
setup_gettext_for_user($admin);
- $response=sprintf(_('Your project registration for %3$s has been denied.
-
-Project Full Name: %1$s
-Project Unix Name: %2$s
-
-Reasons for negative decision:
-
-'), $this->getPublicName(), $this->getUnixName(), forge_get_config('forge_name'));
+ $response = sprintf(_('Your project registration for %s has been denied.'), forge_get_config('forge_name')) . "\n\n"
+ . _('Project Full Name')._(': '). $this->getPublicName() . "\n"
+ . _('Project Unix Name')._(': '). $this->getUnixName() . "\n\n"
+ . _('Reasons for negative decision')._(': ') . "\n\n";
// Check to see if they want to send a custom rejection response
if ($response_id == 0) {
$response .= $message;
} else {
$response .= db_result(
- db_query_params('SELECT response_text FROM canned_responses WHERE response_id=$1', array ($response_id)),
+ db_query_params('SELECT response_text FROM canned_responses WHERE response_id=$1', array($response_id)),
0,
"response_text");
}
- util_send_message($admin->getEmail(), sprintf(_('%1$s Project Denied'), forge_get_config ('forge_name')), $response);
+ util_send_message($admin->getEmail(), sprintf(_('%s Project Denied'), forge_get_config ('forge_name')), $response);
setup_gettext_from_context();
}
return false;
}
- $admins = RBACEngine::getInstance()->getUsersByAllowedAction ('approve_projects', -1) ;
+ $admins = RBACEngine::getInstance()->getUsersByAllowedAction ('approve_projects', -1);
if (count($admins) < 1) {
$this->setError(_("There is no administrator to send the mail to."));
}
foreach ($admins as $admin) {
- $admin_email = $admin->getEmail () ;
- setup_gettext_for_user ($admin) ;
-
- $message = sprintf(_('New %1$s Project Submitted
+ $admin_email = $admin->getEmail();
+ setup_gettext_for_user ($admin);
-Project Full Name: %2$s
-Submitted Description: %3$s
-'),
- forge_get_config ('forge_name'),
- htmlspecialchars_decode($this->getPublicName()),
- htmlspecialchars_decode($this->getRegistrationPurpose()));
+ $message = sprintf(_('New %s Project Submitted'), forge_get_config ('forge_name')) . "\n\n"
+ . _('Project Full Name')._(': ').htmlspecialchars_decode($this->getPublicName()) . "\n"
+ . _('Submitted Description')._(': ').htmlspecialchars_decode($this->getRegistrationPurpose()) . "\n";
foreach ($submitters as $submitter) {
- $message .= sprintf(_('Submitter: %1$s (%2$s)
-'),
- $submitter->getRealName(),
- $submitter->getUnixName());
+ $message .= _('Submitter')._(': ').$submitter->getRealName().' ('.$submitter->getUnixName().')' . "\n\n";
}
- $message .= sprintf (_('
-Please visit the following URL to approve or reject this project:
-%1$s'),
- util_make_url ('/admin/approve-pending.php')) ;
- util_send_message($admin_email, sprintf(_('New %1$s Project Submitted'), forge_get_config ('forge_name')), $message);
+ $message .= "\n"
+ . _('Please visit the following URL to approve or reject this project')._(': '). "\n"
+ . util_make_url('/admin/approve-pending.php');
+ util_send_message($admin_email, sprintf(_('New %s Project Submitted'), forge_get_config('forge_name')), $message);
setup_gettext_from_context();
}
+ $email = $submitter->getEmail();
+ setup_gettext_for_user ($submitter);
- $email = $submitter->getEmail() ;
- setup_gettext_for_user ($submitter) ;
-
- $message=sprintf(_('New %1$s Project Submitted
-
-Project Full Name: %2$s
-Submitted Description: %3$s
+ $message = sprintf(_('New %s Project Submitted'), forge_get_config ('forge_name')) . "\n\n"
+ . _('Project Full Name')._(': ') . $this->getPublicName() . "\n"
+ . _('Submitted Description')._(': ') . util_unconvert_htmlspecialchars($this->getRegistrationPurpose()) . "\n\n"
+ . sprintf(_('The %s admin team will now examine your project submission. You will be notified of their decision.'),
+ forge_get_config ('web_host'));
-The %1$s admin team will now examine your project submission. You will be notified of their decision.'), forge_get_config ('forge_name'), $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), forge_get_config('web_host'));
-
- util_send_message($email, sprintf(_('New %1$s Project Submitted'), forge_get_config ('forge_name')), $message);
+ util_send_message($email, sprintf(_('New %s Project Submitted'), forge_get_config ('forge_name')), $message);
setup_gettext_from_context();
return true;
}
-
-
-
/**
* validateGroupName - Validate the group name
*
* @param string Group name.
*
- * @return boolean an error false and set an error is the group name is invalide otherwise return true
+ * @return boolean an error false and set an error is the group name is invalid otherwise return true
*/
function validateGroupName($group_name) {
if (strlen($group_name)<3) {
$this->setError(_('Group name is too short'));
return false;
- } elseif (strlen(htmlspecialchars($group_name))>50) {
+ } elseif (strlen(htmlspecialchars($group_name))>40) {
$this->setError(_('Group name is too long'));
return false;
} elseif (group_get_object_by_publicname($group_name)) {
return true;
}
-
/**
* getRolesId - Get Ids of the roles of the group.
*
$role_ids = array();
$res = db_query_params('SELECT role_id FROM pfo_role WHERE home_group_id=$1',
- array($this->getID()));
+ array($this->getID()));
while ($arr = db_fetch_array($res)) {
$role_ids[] = $arr['role_id'];
}
$res = db_query_params('SELECT role_id FROM role_project_refs WHERE group_id=$1',
- array($this->getID()));
+ array($this->getID()));
while ($arr = db_fetch_array($res)) {
$role_ids[] = $arr['role_id'];
}
/**
* getUnixStatus - Status of activation of unix account.
*
- * @return char (N)one, (A)ctive, (S)uspended or (D)eleted
+ * @return string Values: (N)one, (A)ctive, (S)uspended or (D)eleted
*/
function getUnixStatus() {
return $this->data_array['unix_status'];
/**
* setUnixStatus - Sets status of activation of unix account.
*
- * @param string The unix status.
- * N no_unix_account
- * A active
- * S suspended
- * D deleted
+ * @param string $status The unix status.
+ * N no_unix_account
+ * A active
+ * S suspended
+ * D deleted
*
* @return boolean success.
*/
global $SYS;
db_begin();
$res = db_query_params ('UPDATE groups SET unix_status=$1 WHERE group_id=$2',
- array ($status,
- $this->getID())) ;
+ array($status,
+ $this->getID()));
if (!$res) {
- $this->setError(sprintf(_('ERROR - Could Not Update Group Unix Status: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot Update Group Unix Status: %s'),db_error()));
db_rollback();
return false;
} else {
/**
* getUsers - Get the users of a group
*
+ * @param bool $onlylocal
* @return array of user's objects.
*/
function getUsers($onlylocal = true) {
if (!isset($this->membersArr)) {
- $this->membersArr = array () ;
+ $this->membersArr = array();
- $ids = array () ;
+ $ids = array();
foreach ($this->getRoles() as $role) {
if ($onlylocal
- && ($role->getHomeProject() == NULL || $role->getHomeProject()->getID() != $this->getID())) {
- continue ;
+ && ($role->getHomeProject() == NULL || $role->getHomeProject()->getID() != $this->getID())) {
+ continue;
}
foreach ($role->getUsers() as $user) {
- $ids[] = $user->getID() ;
+ $ids[] = $user->getID();
}
}
- $ids = array_unique ($ids) ;
+ $ids = array_unique ($ids);
foreach ($ids as $id) {
- $u = user_get_object ($id) ;
+ $u = user_get_object ($id);
if ($u->isActive()) {
- $this->membersArr[] = $u ;
+ $this->membersArr[] = $u;
}
}
}
array($status, $this->getID()));
if (!$res) {
- $this->setError(sprintf(_('ERROR - Could Not Update Group DocmanCreateOnline Status: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot Update Group DocmanCreateOnline Status: %s'),db_error()));
db_rollback();
return false;
} else {
/* if we activate search engine, we probably want to reindex */
$res = db_query_params('UPDATE groups SET use_webdav=$1 WHERE group_id=$2',
array($status,
- $this->getID()));
+ $this->getID()));
if (!$res) {
- $this->setError(sprintf(_('ERROR - Could Not Update Group UseWebdab Status: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot Update Group UseWebdab Status: %s'),db_error()));
db_rollback();
return false;
} else {
/* if we activate search engine, we probably want to reindex */
$res = db_query_params('UPDATE groups SET use_docman_search=$1, force_docman_reindex=$1 WHERE group_id=$2',
array($status,
- $this->getID()));
+ $this->getID()));
if (!$res) {
- $this->setError(sprintf(_('ERROR - Could Not Update Group UseDocmanSearch Status: %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot Update Group UseDocmanSearch Status: %s'),db_error()));
db_rollback();
return false;
} else {
/* if we activate search engine, we probably want to reindex */
$res = db_query_params('UPDATE groups SET force_docman_reindex=$1 WHERE group_id=$2',
array($status,
- $this->getID()));
+ $this->getID()));
if (!$res) {
- $this->setError(sprintf(_('ERROR - Could Not Update Group force_docman_reindex %s'),db_error()));
+ $this->setError(sprintf(_('Error: Cannot Update Group force_docman_reindex %s'),db_error()));
db_rollback();
return false;
} else {
return true;
}
}
-
}
/**
* group_getname() - get the group name
*
- * @param int The group ID
+ * @param int $group_id The group ID
+ * @return string
* @deprecated
*
*/
/**
* group_getunixname() - get the unixname for a group
*
- * @param int The group ID
+ * @param int $group_id The group ID
+ * @return string
* @deprecated
*
*/
/**
* group_get_result() - Get the group object result ID.
*
- * @param int The group ID
+ * @param int $group_id The group ID
+ * @return int
* @deprecated
*
*/
function getAllProjectTags($onlyvisible = true) {
$res = db_query_params('SELECT project_tags.name, groups.group_id FROM groups, project_tags WHERE groups.group_id = project_tags.group_id AND groups.status = $1 ORDER BY project_tags.name, groups.group_id',
- array('A'));
+ array('A'));
if (!$res || db_numrows($res) == 0) {
return false;
*
*/
class ProjectComparator {
- var $criterion = 'name' ;
+ var $criterion = 'name';
function Compare ($a, $b) {
switch ($this->criterion) {
case 'name':
default:
- $namecmp = strcoll ($a->getPublicName(), $b->getPublicName()) ;
+ $namecmp = strcoll ($a->getPublicName(), $b->getPublicName());
if ($namecmp != 0) {
- return $namecmp ;
+ return $namecmp;
}
/* If several projects share a same public name */
- return strcoll ($a->getUnixName(), $b->getUnixName()) ;
- break ;
+ return strcoll ($a->getUnixName(), $b->getUnixName());
+ break;
case 'unixname':
- return strcmp ($a->getUnixName(), $b->getUnixName()) ;
- break ;
+ return strcmp ($a->getUnixName(), $b->getUnixName());
+ break;
case 'id':
- $aid = $a->getID() ;
- $bid = $b->getID() ;
+ $aid = $a->getID();
+ $bid = $b->getID();
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
- break ;
+ break;
}
}
}
function sortProjectList (&$list, $criterion='name') {
- $cmp = new ProjectComparator () ;
- $cmp->criterion = $criterion ;
+ $cmp = new ProjectComparator();
+ $cmp->criterion = $criterion;
- return usort ($list, array ($cmp, 'Compare')) ;
+ return usort ($list, array($cmp, 'Compare'));
}
// Local Variables: