}
function &group_get_object_by_publicname($groupname) {
- $res=db_query_params ('SELECT * FROM groups WHERE group_name ILIKE $1',
- array (htmlspecialchars ($groupname))) ;
+ $res=db_query_params ('SELECT * FROM groups WHERE lower(group_name) LIKE $1',
+ array (htmlspecialchars (strtolower ($groupname)))) ;
return group_get_object(db_result($res,0,'group_id'),$res);
}
*/
var $membersArr;
- /**
- * Permissions data row from db.
- *
- * @var array $perm_data_array.
- */
- var $perm_data_array;
-
/**
* Whether the use is an admin/super user of this project.
*
/**
* Associative array of data for plugins.
*
- * @var array $plugins_array.
+ * @var array $plugins_data.
*/
- var $plugins_array;
+ var $plugins_data;
+
+
+ /**
+ * Associative array of data for the group menu.
+ *
+ * @var array $menu_data.
+ */
+ var $menu_data;
/**
* Group - Group object constructor - use group_get_object() to instantiate.
* @param string Machine on which group's home directory located.
* @param string Domain which serves group's WWW.
* @return status.
- * @access public.
+ * @access public
*/
function updateAdmin(&$user, $is_public, $type_id, $unix_box, $http_domain) {
$perm =& $this->getPermission($user);
* @param string Machine on which group's home directory located.
* @param string Domain which serves group's WWW.
* @return int status.
- * @access public.
+ * @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,
$send_all_docs=0;
}
+ $homepage = ltrim($homepage);
if (!$homepage) {
$homepage=$GLOBALS['sys_default_domain'].'/projects/'.$this->getUnixName().'/';
}
* @param object User requesting operation (for access control).
* @param string Status value.
* @return boolean success.
- * @access public.
+ * @access public
*/
function setStatus(&$user, $status) {
global $SYS;
$allowed_status_changes = array(
'AH'=>1,'AD'=>1,'DA'=>1,'PA'=>1,'PD'=>1,
'IP'=>1,'HA'=>1,'HD'=>1
- );
+ );
// Check that status transition is valid
if ($this->getStatus() != $status
}
}
+ function setUsesSCM ($booleanparam) {
+ db_begin () ;
+ $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 () ;
+ } else {
+ db_rollback ();
+ return false;
+ }
+ }
+
/**
* enablePserver - whether or not this group has opted to enable Pserver.
*
* @return string database result.
*/
function setTags($tags) {
- global $Language;
-
db_begin();
$sql='DELETE FROM project_tags WHERE group_id=$1';
$res=db_query_params($sql, array($this->getID()));
$res = db_query_params ('DELETE FROM doc_groups WHERE group_id=$1',
array ($this->getID())) ;
//echo 'doc_groups'.db_error();
+
+ //
+ // Delete Tags
+ //
+ $res=db_query_params('DELETE FROM project_tags WHERE group_id=$1', array($this->getID()));
+
//
// Delete group history
//
/**
* addUser - controls adding a user to a group.
*
- * @param string Unix name of the user to add OR integer user_id.
+ * @param string Unix name of the user to add OR integer user_id.
* @param int The role_id this user should have.
* @return boolean success.
- * @access public.
+ * @access public
*/
function addUser($user_identifier,$role_id) {
global $SYS;
* @param string The name of the field.
* @param string The Old Value for this $field_name.
* @return database result handle.
- * @access public.
+ * @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)
* Setup unix accounts for group members. Can be called even
* if members are already active.
*
- * @access private.
+ * @access private
*/
function activateUsers() {
-
+
/*
- Activate member(s) of the project
+ Activate member(s) of the project
*/
$member_res = db_query_params ('SELECT user_id, role_id FROM user_group WHERE group_id=$1',
array ($this->getID())) ;
$rows = db_numrows($member_res);
-
+
if ($rows > 0) {
for ($i=0; $i<$rows; $i++) {
return false;
}
$f = new Forum($this);
- if (!$f->create(_('Developers'),_('Project Developer Discussion'),0,'',1,0)) {
+ if (!$f->create(_('Developers-Discussion'),_('Project Developer Discussion'),0,'',1,0)) {
$this->setError(sprintf (_('F%d: %s'), 3, $f->getErrorMessage()));
db_rollback();
setup_gettext_from_context();
if (db_numrows($admin_group) > 0) {
$idadmin_group = db_result($admin_group,0,'user_id');
} else {
- $idadmin_group = 1;
+ $idadmin_group = $user->getID();
+ db_query_params ('INSERT INTO user_group (user_id, group_id, admin_flags) VALUES ($1, $2, $3)',
+ array ($idadmin_group,
+ $this->getID(),
+ 'A')) ;
}
$role = new Role($this);
$this->sendApprovalEmail();
$this->addHistory('Approved', 'x');
- //plugin webcal
- //change assistant for webcal
-
+ //
+ // Plugin can make approve operation there
+ //
+ //
$params[0] = $idadmin_group ;
$params[1] = $this->getID();
- plugin_hook('change_cal_permission_default',$params);
+ plugin_hook('group_approve',$params);
return true;
}
* sendApprovalEmail - Send new project email.
*
* @return boolean success.
- * @access public.
+ * @access public
*/
function sendApprovalEmail() {
$res_admins = db_query_params ('
* @param int The id of the response to use.
* @param string The rejection message.
* @return completion status.
- * @access public.
+ * @access public
*/
function sendRejectionEmail($response_id, $message="zxcv") {
$res_admins = db_query_params ('
* submitted.
*
* @return boolean success.
- * @access public.
+ * @access public
*/
function sendNewProjectNotificationEmail() {
// Get the user who wants to register the project
}
-
-
+ /**
+ * getRoles - Get the roles of the group.
+ *
+ * @return array of Role id of this group.
+ */
+ function getRolesId () {
+
+ $rolesId = Array();
+
+ $roles_group_res = db_query_params ('SELECT role_id FROM role WHERE group_id=$1',
+ array ($this->getID()));
+ if (!$roles_group_res) {
+ $this->setError('Error: Roles from group id '. $this->getID() . ' ' .db_error());
+ return false;
+ } else {
+ for ($i=0; $i<db_numrows($roles_group_res); $i++) {
+ $rolesId[$i] = db_result($roles_group_res,$i,'role_id');
+ }
+ }
+
+ return $rolesId;
+ }
+
+ /**
+ * getUnixStatus - Status of activation of unix account.
+ *
+ * @return char (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
+ *
+ * @return boolean success.
+ */
+ function setUnixStatus($status) {
+ global $SYS;
+ db_begin();
+ $res = db_query_params ('UPDATE groups SET unix_status=$1 WHERE group_id=$2',
+ array ($status,
+ $this->getID())) ;
+
+ if (!$res) {
+ $this->setError(sprintf(_('ERROR - Could Not Update Group Unix Status: %s'),db_error()));
+ db_rollback();
+ return false;
+ } else {
+ if ($status == 'A') {
+ if (!$SYS->sysCheckCreateGroup($this->getID())) {
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ } else {
+ if ($SYS->sysCheckGroup($this->getID())) {
+ if (!$SYS->sysRemoveGroup($this->getID())) {
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ }
+ }
+
+ $this->data_array['unix_status']=$status;
+ db_commit();
+ return true;
+ }
+ }
+
+ /**
+ * getUsers - Get the users of a group
+ *
+ * @return array of user's objects.
+ */
+ function getUsers() {
+ $users = Array();
+
+ $users_group_res = db_query_params ('SELECT u.user_id FROM users u, user_group ug WHERE ug.group_id=$1 AND ug.user_id=u.user_id AND u.status=$2',
+ array ($this->getID(),
+ 'A'));
+ if (!$users_group_res) {
+ $this->setError('Error: Enable to get users from group '. $this->getID() . ' ' .db_error());
+ return false;
+ }
+
+ for ($i=0; $i<db_numrows($users_group_res); $i++) {
+ $users[$i] = new GFUser(db_result($users_group_res,$i,'user_id'),false);
+ }
+
+ return $users;
+ }
}
/**
}
}
-/**
- * getUnixStatus - Status of activation of unix account.
- *
- * @return char (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
- *
- * @return boolean success.
- */
-function setUnixStatus($status) {
- global $SYS;
- db_begin();
- $res = db_query_params ('UPDATE groups SET unix_status=$1 WHERE group_id=$2',
- array ($status,
- $this->getID())) ;
-
- if (!$res) {
- $this->setError(sprintf(_('ERROR - Could Not Update Group Unix Status: %s'),db_error()));
- db_rollback();
- return false;
- } else {
- if ($status == 'A') {
- if (!$SYS->sysCheckCreateGroup($this->getID())) {
- $this->setError($SYS->getErrorMessage());
- db_rollback();
- return false;
- }
- } else {
- if ($SYS->sysCheckGroup($this->getID())) {
- if (!$SYS->sysRemoveGroup($this->getID())) {
- $this->setError($SYS->getErrorMessage());
- db_rollback();
- return false;
- }
- }
- }
-
- $this->data_array['unix_status']=$status;
- db_commit();
- return true;
- }
-}
// Local Variables:
// mode: php