* 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;
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)) ;
+ 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)) ;
+ array('D'));
+ return group_get_objects(util_result_column_to_array($res,0));
}
function &group_get_object_by_name($groupname) {
/**
* 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) {
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()));
return false;
* 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 object already exists'));
+ $this->setError(_('Group object already exists.'));
return false;
} elseif (!$this->validateGroupName($group_name)) {
return false;
$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'));
+ $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),
+ array(htmlspecialchars($group_name),
$unix_name,
htmlspecialchars($description),
$homepage,
*
* 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) {
*
* 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,
* 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
*/
* @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) {
/**
* 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 $this->data_array['register_purpose'];
}
-
/**
* getAdmins() - Get array of Admin user objects.
*
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;
}
}
return false;
}
- $hook_params = array ();
+ $hook_params = array();
$hook_params['group'] = $this;
$hook_params['group_id'] = $this->getID();
$hook_params['group_homepage'] = $this->getHomePage();
/**
* 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) {
/**
* 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) {
/**
* setUsePM - Set the PM usage
*
- * @param boolean enabled/disabled
+ * @param boolean $booleanparam enabled/disabled
* @return bool
*/
function setUsePM($booleanparam) {
* 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) {
$plugin_id));
return $res;
}
- $this->normalizeAllRoles () ;
+ $this->normalizeAllRoles();
}
/**
return $this->data_array['send_all_docs'];
}
-
/**
* getHomePage - The URL for this project's home page.
*
/**
* setTags - Set tags of this project.
*
+ * @param string $tags
* @return string database result.
*/
function setTags($tags) {
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.'));
// 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();
//
// 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) {
}
}
if ($found_role == NULL) {
- $this->setError(sprintf(_('ERROR: User not removed: %s')));
+ $this->setError(sprintf(_('Error: User not removed: %s')));
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(),
+ array($this->getID(),
$field_name,
$old_value,
user_getid(),
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) {
}
/**
- * 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 User $user The User object who is doing the updating.
- * @return bool
- * @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;
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());
}
}
}
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()) ;
+ $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) {
if (isset ($id_mappings[$section][$k])) {
$newrole->setSetting ($section,
$id_mappings[$section][$k],
- $v) ;
+ $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();
// Delete fake join request
foreach (get_group_join_requests ($this) as $gjr) {
- $gjr->delete(true) ;
+ $gjr->delete(true);
}
// Switch back to user preference
//
// Plugin can make approve operation there
//
- $params = array () ;
- $params['group'] = $this ;
+ $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.
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();
}
* 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
-
-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'));
+ $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'));
- 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;
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.
*
/**
* 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 $status The unix status.
- * N no_unix_account
- * A active
- * S suspended
- * D deleted
+ * 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: Cannot Update Group Unix Status: %s'),db_error()));
/**
* 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 ;
+ 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;
}
}
}
/* 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: Cannot Update Group UseWebdab Status: %s'),db_error()));
return true;
}
}
-
}
/**
* group_getname() - get the group name
*
- * @param int The group ID
- * @return string
+ * @param int $group_id The group ID
+ * @return string
* @deprecated
*
*/
/**
* group_getunixname() - get the unixname for a group
*
- * @param int The group ID
- * @return string
+ * @param int $group_id The group ID
+ * @return string
* @deprecated
*
*/
/**
* group_get_result() - Get the group object result ID.
*
- * @param int The group ID
- * @return int
+ * @param int $group_id The group ID
+ * @return int
* @deprecated
*
*/
*
*/
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: