}
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_data;
+
+
+ /**
+ * Associative array of data for the group menu.
+ *
+ * @var array $menu_data.
*/
- var $plugins_array;
+ var $menu_data;
/**
* Group - Group object constructor - use group_get_object() to instantiate.
function create(&$user, $group_name, $unix_name, $description, $purpose, $unix_box='shell1', $scm_box='cvs1', $is_public=1, $send_mail=true) {
// $user is ignored - anyone can create pending group
+ global $SYS;
if ($this->getID()!=0) {
$this->setError(_('Group::create: Group object already exists'));
return false;
} else if (!account_groupnamevalid($unix_name)) {
$this->setError(_('Invalid Unix name'));
return false;
+ } else if (!$SYS->sysUseUnixName($unix_name)) {
+ $this->setError(_('Unix name already taken'));
+ return false;
} else if (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'));
* @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();
$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;
+ }
+
+ /**
+ * getMenu - get an array that contains data for the group menu
+ *
+ * @param string contains the name of the selected menu item
+ * @return array array containing:
+ * 'titles': array that stores the titles of the menu entries
+ * 'dirs': array that stores the URLs of the menu entries
+ * 'start': URL of the starting page of the project
+ * 'admindirs': array that stores the URLs of the admin pages
+ * for the menu entries, if accessible, false otherwise
+ * 'selected': number of the menu entry selected by $toptab
+ * 'last_toptab': required internally: stores the
+ * value of $toptab for the last call to getMenu()
+ */
+ function &getMenu($toptab = "") {
+ // rebuild menu if it has never been built before, or
+ // if the toptab was set differently
+ if (!isset($this->menu_data)
+ || ($toptab != "")
+ || ($toptab != $this->menu_data['last_toptab']))
+ {
+ $selected = 0;
+ $group = $this->getId();
+
+ $this->menu_data = array () ;
+ $this->menu_data['titles'] = array();
+ $this->menu_data['dirs'] = array();
+ $this->menu_data['admindirs'] = array();
+
+ // Summary
+ $this->menu_data['titles'][] = _('Summary');
+ if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
+ $dir = util_make_url ('/project/?group_id=' . $group);
+ } else {
+ $dir = util_make_url ('/projects/' . $this->getUnixName() .'/');
+ }
+ $this->menu_data['dirs'][] = $dir;
+ $this->menu_data['admindirs'][] = false;
+ if ($toptab == "home") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ // setting 'start' allows to change the
+ // projects start page
+ $this->menu_data['start'] = $dir;
+
+ // Project Admin
+ $perm =& $this->getPermission( session_get_user() );
+ if ($perm->isAdmin()) {
+ $this->menu_data['titles'][] = _('Admin');
+ $this->menu_data['dirs'][] = util_make_url ('/project/admin/?group_id=' . $group);
+ $this->menu_data['admindirs'][] = false;
+ if ($toptab == "admin") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+ /* Homepage
+ // check for use_home_tab?
+ $TABS_DIRS[]='http://'. $this->getHomePage();
+ $TABS_TITLES[]=_('Home Page');
+ */
+
+ // Project Activity tab
+ $this->menu_data['titles'][] = _('Activity');
+ $this->menu_data['dirs'][] = util_make_url ('/activity/?group_id=' . $group);
+ $this->menu_data['admindirs'][] = false;
+ if ($toptab == "activity") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+
+ // Forums
+ if ($this->usesForum()) {
+ $this->menu_data['titles'][] = _('Forums');
+ $this->menu_data['dirs'][] = util_make_url ('/forum/?group_id=' . $group);
+ if ($perm->isAdmin() || $perm->isForumAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url('/forum/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "forums") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+ // Artifact Tracking
+ if ($this->usesTracker()) {
+ $this->menu_data['titles'][] = _('Tracker');
+ $this->menu_data['dirs'][] = util_make_url ('/tracker/?group_id=' . $group);
+ if ($perm->isAdmin() || $perm->isArtifactAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url('/tracker/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "tracker" ||
+ $toptab == "bugs" ||
+ $toptab == "support" ||
+ $toptab == "patch") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+
+ // Mailing Lists
+ if ($this->usesMail()) {
+ $this->menu_data['titles'][] = _('Lists');
+ $this->menu_data['dirs'][] = util_make_url ('/mail/?group_id=' . $group);
+ if ($perm->isAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url('/mail/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "mail") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+
+ }
+
+ // Project/Task Manager
+ if ($this->usesPm()) {
+ $this->menu_data['titles'][] = _('Tasks');
+ $this->menu_data['dirs'][] = util_make_url ('/pm/?group_id=' . $group);
+ if ($perm->isAdmin() || $perm->isPMAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url ('/pm/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "pm") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+
+ }
+
+ // Doc Manager
+ if ($this->usesDocman()) {
+ $this->menu_data['titles'][] = _('Docs');
+ $this->menu_data['dirs'][] = util_make_url ('/docman/?group_id=' . $group);
+ if ($perm->isAdmin() || $perm->isDocEditor()) {
+ $this->menu_data['admindirs'][] = util_make_url ('/docman/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "docman") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+
+ }
+
+ // Surveys
+ if ($this->usesSurvey()) {
+ $this->menu_data['titles'][] = _('Surveys');
+ $this->menu_data['dirs'][] = util_make_url ('/survey/?group_id=' . $group);
+ if ($perm->isAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url ('/survey/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "surveys") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+ // News
+ if ($this->usesNews()) {
+ $this->menu_data['titles'][] = _('News');
+ $this->menu_data['dirs'][] = util_make_url ('/news/?group_id=' . $group);
+ if ($perm->isAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url ('/news/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "news") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+ // SCM systems
+ if ($this->usesSCM()) {
+ $this->menu_data['titles'][] = _('SCM');
+ $this->menu_data['dirs'][] = util_make_url ('/scm/?group_id=' . $group);
+ // eval cvs_flags?
+ if ($perm->isAdmin()) {
+ $this->menu_data['admindirs'][] = util_make_url ('/scm/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "scm") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+ // groupmenu_after_scm hook
+ $hookParams = array();
+ $hookParams['group_id'] = $group ;
+ $hookParams['DIRS'] =& $this->menu_data['dirs'];
+ $hookParams['TITLES'] =& $this->menu_data['titles'];
+ $hookParams['toptab'] =& $toptab;
+ $hookParams['selected'] =& $selected;
+
+ plugin_hook ("groupmenu_scm", $hookParams) ;
+
+ // fill up admindirs
+ for ($i = 0;
+ $i < count($this->menu_data['dirs']) - count($this->menu_data['admindirs']);
+ $i++) {
+ $this->menu_data['admindirs'][] = false;
+ }
+
+ // Downloads
+ if ($this->usesFRS()) {
+ $this->menu_data['titles'][] = _('Files');
+ $this->menu_data['dirs'][] = util_make_url ('/frs/?group_id=' . $group);
+ if ($perm->isAdmin() || $perm->isReleaseTechnician()) {
+ $this->menu_data['admindirs'][] = util_make_url ('/frs/admin/?group_id='.$group);
+ } else {
+ $this->menu_data['admindirs'][] = false;
+ }
+ if ($toptab == "frs") {
+ $selected = (count($this->menu_data['dirs'])-1);
+ }
+ }
+
+ // groupmenu hook
+ $hookParams = array();
+ $hookParams['group'] = $group ;
+ $hookParams['DIRS'] =& $this->menu_data['dirs'];
+ $hookParams['TITLES'] =& $this->menu_data['titles'];
+ $hookParams['toptab'] =& $toptab;
+ $hookParams['selected'] =& $selected;
+
+ plugin_hook ("groupmenu", $hookParams) ;
+ // fill up admindirs
+ for ($i = 0;
+ $i < count($this->menu_data['dirs']) - count($this->menu_data['admindirs']);
+ $i++) {
+ $this->menu_data['admindirs'][] = false;
+ }
+ // store selected menu item (if any)
+ $this->menu_data['selected'] = $selected;
+ if ($toptab != "") {
+ $this->menu_data['last_toptab'] = $toptab;
+ }
+ }
+ return $this->menu_data ;
+ }
}
/**
}
}
-/**
- * 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