<?php
/**
- * Group object
+ * FusionForge groups
*
- * Sets up database results and preferences for a group and abstracts this info.
+ * Copyright 1999-2001, VA Linux Systems, Inc.
*
- * Foundry.class.php and Project.class.php call this.
+ * This file is part of FusionForge.
*
- * Project.class.php contains all the deprecated API from the old group.php file
- *
- * DEPENDS on user.php being present and setup properly
- *
- * GENERALLY YOU SHOULD NEVER INSTANTIATE THIS OBJECT DIRECTLY
- * USE group_get_object() to instantiate properly
- *
- * @version $Id$
- * @author Tim Perdue <tperdue@valinux.com>
- * @date 2000-08-28
- *
- * This file is part of GForge.
- *
- * GForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
*/
-require_once('common/tracker/ArtifactTypes.class.php');
-require_once('common/tracker/ArtifactTypeFactory.class.php');
-require_once('common/forum/Forum.class.php');
-require_once('common/forum/ForumFactory.class.php');
-require_once('common/pm/ProjectGroup.class.php');
-require_once('common/pm/ProjectGroupFactory.class.php');
-require_once('common/include/Role.class.php');
-require_once('common/frs/FRSPackage.class.php');
-require_once('common/docman/DocumentGroup.class.php');
-require_once('common/mail/MailingList.class.php');
-require_once('common/mail/MailingListFactory.class.php');
-require_once('common/survey/SurveyFactory.class.php');
-require_once('common/survey/SurveyQuestionFactory.class.php');
-require_once('www/include/BaseLanguage.class.php');
+require_once $gfcommon.'tracker/ArtifactTypes.class.php';
+require_once $gfcommon.'tracker/ArtifactTypeFactory.class.php';
+require_once $gfcommon.'forum/Forum.class.php';
+require_once $gfcommon.'forum/ForumFactory.class.php';
+require_once $gfcommon.'pm/ProjectGroup.class.php';
+require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
+require_once $gfcommon.'include/Role.class.php';
+require_once $gfcommon.'frs/FRSPackage.class.php';
+require_once $gfcommon.'docman/DocumentGroup.class.php';
+require_once $gfcommon.'mail/MailingList.class.php';
+require_once $gfcommon.'mail/MailingListFactory.class.php';
+require_once $gfcommon.'survey/SurveyFactory.class.php';
+require_once $gfcommon.'survey/SurveyQuestionFactory.class.php';
+require_once $gfcommon.'include/gettext.php';
//the license_id of "Other/proprietary" license
define('GROUP_LICENSE_OTHER',126);
* @param string The 'other' license to use if any.
* @param string The purpose of the group.
*/
- function create(&$user, $full_name, $unix_name, $description, $license, $license_other, $purpose, $unix_box='shell1', $scm_box='cvs1') {
+ function create(&$user, $full_name, $unix_name, $description, $license, $license_other, $purpose, $unix_box='shell1', $scm_box='cvs1', $is_public=1) {
// $user is ignored - anyone can create pending group
if ($this->getID()!=0) {
register_purpose,
register_time,
license_other,
+ enable_anonscm,
rand_hash
)
VALUES (
'".htmlspecialchars($full_name)."',
- 1,
+ '$is_public',
'$unix_name',
'".htmlspecialchars($description)."',
'$unix_name.".$GLOBALS['sys_default_domain']."',
'".htmlspecialchars($purpose)."',
".time().",
'".htmlspecialchars($license_other)."',
+ '$is_public',
'".md5($random_num)."'
)
");
db_rollback();
return false;
}
+
+ $hook_params = array ();
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ $hook_params['group_name'] = $full_name;
+ $hook_params['unix_group_name'] = $unix_name;
+ plugin_hook ("group_create", $hook_params);
+
db_commit();
$this->sendNewProjectNotificationEmail();
return true;
");
if (!$res || db_affected_rows($res) < 1) {
- $this->setError(_('ERROR: DB: Could not change group properties: %s'),db_error()));
+ $this->setError(_('ERROR: DB: Could not change group properties: %s'),db_error());
db_rollback();
return false;
}
$use_pm,$use_pm_depend_box,$use_scm,$use_news,$use_docman,
$new_doc_address,$send_all_docs,$logo_image_id,
$enable_pserver,$enable_anonscm,
- $use_ftp,$use_tracker,$use_frs,$use_stats) {
+ $use_ftp,$use_tracker,$use_frs,$use_stats,$is_public) {
$perm =& $this->getPermission($user);
use_scm='$use_scm',
use_news='$use_news',
use_docman='$use_docman',
+ is_public='$is_public',
new_doc_address='$new_doc_address',
send_all_docs='$send_all_docs',
";
return false;
}
+ $hook_params = array ();
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ $hook_params['group_homepage'] = $homepage;
+ $hook_params['group_name'] = htmlspecialchars($group_name);
+ $hook_params['group_description'] = htmlspecialchars($short_description);
+ plugin_hook ("group_update", $hook_params);
+
// Log the audit trail
$this->addHistory('Changed Public Info', '');
}
}
+ $hook_params = array ();
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ $hook_params['status'] = $status;
+ plugin_hook ("group_setstatus", $hook_params);
+
db_commit();
// Log the audit trail
if (!$res) {
return false;
}
+
+ $hook_params = array ();
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ plugin_hook ("group_delete", $hook_params);
+
if (isset($GLOBALS['sys_upload_dir']) && $this->getUnixName()) {
exec('/bin/rm -rf '.$GLOBALS['sys_upload_dir'].'/'.$this->getUnixName().'/');
}
/*
get user id for this user's unix_name
*/
- if (eregi('[^0-9]',$user_unix_name)) {
- $res_newuser = db_query("SELECT * FROM users WHERE user_name='". strtolower($user_unix_name) ."'");
- } else {
+ if (preg_match('/^\d/',$user_unix_name)) {
$res_newuser = db_query("SELECT * FROM users WHERE user_id='". intval($user_unix_name) ."'");
+ } else {
+ $res_newuser = db_query("SELECT * FROM users WHERE user_name='". strtolower($user_unix_name) ."'");
}
if (db_numrows($res_newuser) > 0) {
//
db_rollback();
return false;
}
+
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ $hook_params['user'] = &user_get_object($user_id);
+ $hook_params['user_id'] = $user_id;
+ plugin_hook ("group_adduser", $hook_params);
+
//
// audit trail
//
$this->setError(sprintf(_('Role: %s'),$role->getErrorMessage()));
return false;
}
+
+ $hook_params['group'] = $this;
+ $hook_params['group_id'] = $this->getID();
+ $hook_params['user'] = &user_get_object($user_id);
+ $hook_params['user_id'] = $user_id;
+ plugin_hook ("group_removeuser", $hook_params);
+
$this->addHistory('Updated User',$user_id);
return true;
}
INNER JOIN user_group ON users.user_id=user_group.user_id
WHERE user_group.group_id='".$this->getID()."'");
while ($arr =& db_fetch_array($res)) {
- $this->membersArr[] =& new User($arr['user_id'],$arr);
+ $this->membersArr[] =& new GFUser($arr['user_id'],$arr);
}
}
return $this->membersArr;
db_rollback();
return false;
} else if ($ats->isError()) {
- $this->setError(sprintf (_('ATS%d: %s'), 1, $ats->getErrorMessage());
+ $this->setError(sprintf (_('ATS%d: %s'), 1, $ats->getErrorMessage()));
db_rollback();
return false;
}
if (!$ats->createTrackers()) {
- $this->setError(sprintf (_('ATS%d: %s'), 2, $ats->getErrorMessage());
+ $this->setError(sprintf (_('ATS%d: %s'), 2, $ats->getErrorMessage()));
db_rollback();
return false;
}
//
$f = new Forum($this);
if (!$f->create('Open-Discussion','General Discussion',1,'',1,0)) {
- $this->setError(sprintf (_('F%d: %s'), 1, $f->getErrorMessage());
+ $this->setError(sprintf (_('F%d: %s'), 1, $f->getErrorMessage()));
db_rollback();
return false;
}
$f = new Forum($this);
if (!$f->create('Help','Get Public Help',1,'',1,0)) {
- $this->setError(sprintf (_('F%d: %s'), 2, $f->getErrorMessage());
+ $this->setError(sprintf (_('F%d: %s'), 2, $f->getErrorMessage()));
db_rollback();
return false;
}
$f = new Forum($this);
if (!$f->create('Developers','Project Developer Discussion',0,'',1,0)) {
- $this->setError(sprintf (_('F%d: %s'), 3, $f->getErrorMessage());
+ $this->setError(sprintf (_('F%d: %s'), 3, $f->getErrorMessage()));
db_rollback();
return false;
}
}
}
- //
- //
- // Create MailingList
- //
- //
- $mlist = new MailingList($this);
$admin_group = db_query("SELECT user_id FROM user_group
WHERE group_id=".$this->getID()." AND admin_flags='A'");
if (db_numrows($admin_group) > 0) {
$idadmin_group = db_result($admin_group,0,'user_id');
- }
- if (!$mlist->create('commits','Commits',1,$idadmin_group)) {
- $this->setError(sprintf(_('ML: %s'),$mlist->getErrorMessage()));
- db_rollback();
- return false;
+ } else {
+ $idadmin_group = 1;
}
+ //
+ //
+ // Create MailingList
+ //
+ //
+ if ($GLOBALS['sys_use_mail']) {
+ $mlist = new MailingList($this);
+ if (!$mlist->create('commits','Commits',1,$idadmin_group)) {
+ $this->setError(sprintf(_('ML: %s'),$mlist->getErrorMessage()));
+ db_rollback();
+ return false;
+ }
+ }
+
db_commit();
$this->sendApprovalEmail();
$admin =& user_get_object($row_admins['user_id']);
setup_gettext_for_user ($admin) ;
- // $2 $2 $3 $4 $5 $6
- $message=stripcslashes(sprintf(_('Your project registration for %7$s has been approved.
+ $message=stripcslashes(sprintf(_('Your project registration for %4$s has been approved.
Project Full Name: %1$s
Project Unix Name: %2$s
services, and directory layout of the account.
If you visit your
-own project page in %7$s while logged in, you will find
+own project page in %4$s while logged in, you will find
additional menu functions to your left labeled \'Project Admin\'.
-We highly suggest that you now visit %7$s and create a public
+We highly suggest that you now visit %4$s and create a public
description for your project. This can be done by visiting your project
page while logged in, and selecting \'Project Admin\' from the menus
-on the left (or by visiting http://%3$s/project/admin/?group_id=%6$s
+on the left (or by visiting %3$s
after login).
Your project will also not appear in the Trove Software Map (primary
-list of projects hosted on %7$s which offers great flexibility in
+list of projects hosted on %4$s which offers great flexibility in
browsing and search) until you categorize it in the project administration
screens. So that people can find your project, you should do this now.
Visit your project while logged in, and select \'Project Admin\' from the
menus on the left.
-Enjoy the system, and please tell others about %7$s. Let us know
+Enjoy the system, and please tell others about %4$s. Let us know
if there is anything we can do to help you.
--- the %7$s crew'), $this->getPublicName(), $this->getUnixName(), $GLOBALS['sys_default_domain'], $GLOBALS['sys_shell_host'], $GLOBALS['sys_scm_host'], $this->getID(), $GLOBALS['sys_name']));
+-- the %4$s crew'),
+ $this->getPublicName(),
+ $this->getUnixName(),
+ util_make_url ('/project/admin/?group_id='.$this->getID()),
+ $GLOBALS['sys_name']));
util_send_message($row_admins['email'], sprintf(_('%1$s Project Approved'), $GLOBALS['sys_name']), $message);
* @access public.
*/
function sendNewProjectNotificationEmail() {
+ // Get the user who wants to register the project
+ $res = db_query("SELECT u.user_id
+ FROM users u, user_group ug
+ WHERE ug.group_id='".$this->getID()."' AND u.user_id=ug.user_id;");
+
+ if (db_numrows($res) < 1) {
+ $this->setError(_("Could not find user who has submitted the project."));
+ return false;
+ }
+
+ $submitter =& user_get_object(db_result($res,0,'user_id'));
+
$res = db_query("SELECT users.email, users.language, users.user_id
FROM users,user_group
if (db_numrows($res) < 1) {
$this->setError(_("There is no administrator to send the mail."));
return false;
- } else {
- for ($i=0; $i<db_numrows($res) ; $i++) {
- $admin_email = db_result($res,$i,'email') ;
- $admin =& user_get_object(db_result($res,$i,'user_id'));
- setup_gettext_for_user ($admin) ;
+ }
- $message=stripcslashes(sprintf(_('New %1$s Project Submitted
+ for ($i=0; $i<db_numrows($res) ; $i++) {
+ $admin_email = db_result($res,$i,'email') ;
+ $admin =& user_get_object(db_result($res,$i,'user_id'));
+ setup_gettext_for_user ($admin) ;
+
+ $message=stripcslashes(sprintf(_('New %1$s Project Submitted
Project Full Name: %2$s
Submitted Description: %3$s
License: %4$s
+Submitter: %6$s (%7$s)
Please visit the following URL to approve or reject this project:
-http://%5$s/admin/approve-pending.php'), $GLOBALS['sys_name'], $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), $this->getLicenseName(), $GLOBALS['sys_default_domain']));
- util_send_message($admin_email, sprintf(_('New %1$s Project Submitted'), $GLOBALS['sys_name']), $message);
- setup_gettext_from_browser () ;
- }
+%5$s'),
+ $GLOBALS['sys_name'],
+ $this->getPublicName(),
+ util_unconvert_htmlspecialchars($this->getRegistrationPurpose()),
+ $this->getLicenseName(),
+ util_make_url ('/admin/approve-pending.php'),
+ $submitter->getRealName(),
+ $submitter->getUnixName()));
+ util_send_message($admin_email, sprintf(_('New %1$s Project Submitted'), $GLOBALS['sys_name']), $message);
+ setup_gettext_from_browser () ;
}
- // Get the email of the user who wants to register the project
- $res = db_query("SELECT u.email, u.language, u.user_id
- FROM users u, user_group ug
- WHERE ug.group_id='".$this->getID()."' AND u.user_id=ug.user_id;");
- if (db_numrows($res) < 1) {
- $this->setError(_("Cound not find user who has submitted the project."));
- return false;
- } else {
- for ($i=0; $i<db_numrows($res) ; $i++) {
- $email = db_result($res, $i, 'email');
- $user =& user_get_object(db_result($res,$i,'user_id'));
- setup_gettext_for_user ($user) ;
+ $email = $submitter->getEmail() ;
+ setup_gettext_for_user ($submitter) ;
- $message=stripcslashes(sprintf(_('New %1$s Project Submitted
+ $message=stripcslashes(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.'), $GLOBALS['sys_name'], $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), $this->getLicenseName(), $GLOBALS['sys_default_domain']));
- util_send_message($email, sprintf(_('New %1$s Project Submitted'), $GLOBALS['sys_name']), $message);
- setup_gettext_from_browser () ;
- }
- }
+ util_send_message($email, sprintf(_('New %1$s Project Submitted'), $GLOBALS['sys_name']), $message);
+ setup_gettext_from_browser () ;
-
- return true;
+ return true;
}
}