5 * Sets up database results and preferences for a group and abstracts this info.
7 * Foundry.class and Project.class call this.
9 * Project.class contains all the deprecated API from the old group.php file
11 * DEPENDS on user.php being present and setup properly
13 * GENERALLY YOU SHOULD NEVER INSTANTIATE THIS OBJECT DIRECTLY
14 * USE group_get_object() to instantiate properly
17 * @author Tim Perdue <tperdue@valinux.com>
20 * This file is part of GForge.
22 * GForge is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
27 * GForge is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with GForge; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 require_once('common/tracker/ArtifactTypes.class');
38 require_once('common/tracker/ArtifactTypeFactory.class');
39 require_once('common/forum/Forum.class');
40 require_once('common/forum/ForumFactory.class');
41 require_once('common/pm/ProjectGroup.class');
42 require_once('common/pm/ProjectGroupFactory.class');
43 require_once('common/include/Role.class');
44 require_once('common/frs/FRSPackage.class');
45 require_once('common/docman/DocumentGroup.class');
46 require_once('common/mail/MailingList.class');
47 require_once('common/mail/MailingListFactory.class');
48 require_once('common/survey/SurveyFactory.class');
49 require_once('common/survey/SurveyQuestionFactory.class');
50 require_once('www/include/BaseLanguage.class');
52 //the license_id of "Other/proprietary" license
53 define('GROUP_LICENSE_OTHER',126);
55 $LICENSE_NAMES=array();
58 * group_get_licences() - get the licenses list
60 * @return array list of licenses
62 function & group_get_licenses() {
63 global $LICENSE_NAMES;
64 if(empty($LICENSE_NAMES)) {
65 $result = db_query('select * from licenses');
66 while($data = db_fetch_array($result)) {
67 $LICENSE_NAMES[$data['license_id']] = $data['license_name'];
70 return $LICENSE_NAMES;
76 * group_get_object() - Get the group object.
78 * group_get_object() is useful so you can pool group objects/save database queries
79 * You should always use this instead of instantiating the object directly.
81 * You can now optionally pass in a db result handle. If you do, it re-uses that query
82 * to instantiate the objects.
84 * IMPORTANT! That db result must contain all fields
85 * from groups table or you will have problems
88 * @param int Result set handle ("SELECT * FROM groups WHERE group_id=xx")
89 * @return a group object or false on failure
91 function &group_get_object($group_id,$res=false) {
92 //create a common set of group objects
93 //saves a little wear on the database
95 //automatically checks group_type and
96 //returns appropriate object
99 if (!isset($GROUP_OBJ["_".$group_id."_"])) {
101 //the db result handle was passed in
103 $res=db_query("SELECT * FROM groups WHERE group_id='$group_id'");
105 if (!$res || db_numrows($res) < 1) {
106 $GROUP_OBJ["_".$group_id."_"]=false;
109 check group type and set up object
111 if (db_result($res,0,'type_id')==1) {
113 $GROUP_OBJ["_".$group_id."_"]= new Group($group_id,$res);
116 $GROUP_OBJ["_".$group_id."_"]=false;
120 return $GROUP_OBJ["_".$group_id."_"];
123 function &group_get_objects($id_arr) {
126 // Note: if we don't do this, the result may be corrupted
130 for ($i=0; $i<count($id_arr); $i++) {
132 // See if this ID already has been fetched in the cache
137 if (!isset($GROUP_OBJ["_".$id_arr[$i]."_"])) {
138 $fetch[]=$id_arr[$i];
140 $return[] =& $GROUP_OBJ["_".$id_arr[$i]."_"];
143 if (count($fetch) > 0) {
144 $res=db_query("SELECT * FROM groups WHERE group_id IN ('".implode($fetch,'\',\'') ."')");
145 while ($arr =& db_fetch_array($res)) {
146 $GROUP_OBJ["_".$arr['group_id']."_"] = new Group($arr['group_id'],$arr);
147 $return[] =& $GROUP_OBJ["_".$arr['group_id']."_"];
153 function &group_get_object_by_name($groupname) {
154 $res=db_query("SELECT * FROM groups WHERE unix_group_name='$groupname'");
155 return group_get_object(db_result($res,0,'group_id'),$res);
158 function &group_get_objects_by_name($groupname_arr) {
159 $sql="SELECT group_id FROM groups WHERE unix_group_name IN ('".implode($groupname_arr,'\',\'')."')";
161 $arr =& util_result_column_to_array($res,0);
162 return group_get_objects($arr);
165 class Group extends Error {
167 * Associative array of data from db.
169 * @var array $data_array.
174 * array of User objects.
176 * @var array $membersArr.
181 * Permissions data row from db.
183 * @var array $perm_data_array.
185 var $perm_data_array;
188 * Whether the use is an admin/super user of this project.
190 * @var bool $is_admin.
195 * Artifact types result handle.
197 * @var int $types_res.
202 * Associative array of data for plugins.
204 * @var array $plugins_array.
209 * Group - Group object constructor - use group_get_object() to instantiate.
211 * @param int Required - group_id of the group you want to instantiate.
212 * @param int Database result from select query OR associative array of all columns.
214 function Group($id=false, $res=false) {
217 //setting up an empty object
218 //probably going to call create()
222 if (!$this->fetchData($id)) {
227 // Assoc array was passed in
229 if (is_array($res)) {
230 $this->data_array =& $res;
232 if (db_numrows($res) < 1) {
233 //function in class we extended
234 $this->setError('Group Not Found');
235 $this->data_array=array();
238 //set up an associative array for use by other functions
239 db_reset_result($res);
240 $this->data_array =& db_fetch_array($res);
245 $systemGroups = array(GROUP_IS_NEWS, GROUP_IS_STATS, GROUP_IS_PEER_RATINGS);
246 if(!$this->isPublic() && !in_array($id, $systemGroups)) {
247 $perm =& $this->getPermission(session_get_user());
249 if (!$perm || !is_object($perm) || !$perm->isMember()) {
250 // cannot use $Language as it is not created yet
251 $this->setError('Permission denied', ERROR__PERMISSION_DENIED_ERROR);
259 * fetchData - May need to refresh database fields if an update occurred.
261 * @param int The group_id.
263 function fetchData($group_id) {
264 $res = db_query("SELECT * FROM groups WHERE group_id='$group_id'");
265 if (!$res || db_numrows($res) < 1) {
266 $this->setError('fetchData():: '.db_error());
269 $this->data_array =& db_fetch_array($res);
274 * create - Create new group.
276 * This method should be called on empty Group object.
278 * @param object The User object.
279 * @param string The full name of the user.
280 * @param string The Unix name of the user.
281 * @param string The new group description.
282 * @param int The ID of the license to use.
283 * @param string The 'other' license to use if any.
284 * @param string The purpose of the group.
286 function create(&$user, $full_name, $unix_name, $description, $license, $license_other, $purpose, $unix_box='shell1', $scm_box='cvs1') {
289 // $user is ignored - anyone can create pending group
291 if ($this->getID()!=0) {
292 $this->setError("Group::create: Group object already exists");
294 } else if (strlen($full_name)<3) {
295 $this->setError($Language->getText('register','invalid_full_name'));
297 } else if (!account_groupnamevalid($unix_name)) {
298 $this->setError($Language->getText('register','invalid_unix_name'));
300 } else if (db_numrows(db_query("SELECT group_id FROM groups WHERE unix_group_name='$unix_name'")) > 0) {
301 $this->setError($Language->getText('register','unix_group_name_already_taken'));
303 } else if (strlen($purpose)<10) {
304 $this->setError($Language->getText('register','describe_registration'));
306 } else if (strlen($purpose)>1500) {
307 $this->setError($Language->getText('register','describe_registration'));
309 } else if (strlen($description)<10) {
310 $this->setError($Language->getText('register','comprehensive_description'));
312 } else if (!$license) {
313 $this->setError($Language->getText('register','no_license_chosen'));
315 } else if ($license!=GROUP_LICENSE_OTHER && $license_other) {
316 $this->setError($Language->getText('register','conflicting_licenses_choice'));
318 } else if ($license==GROUP_LICENSE_OTHER && strlen($license_other)<50) {
319 $this->setError($Language->getText('register','more_license_description'));
323 srand((double)microtime()*1000000);
324 $random_num = rand(0,1000000);
346 '".htmlspecialchars($full_name)."',
349 '".htmlspecialchars($description)."',
350 '$unix_name.".$GLOBALS['sys_default_domain']."',
351 '$unix_name.".$GLOBALS['sys_default_domain']."',
356 '".htmlspecialchars($purpose)."',
358 '".htmlspecialchars($license_other)."',
359 '".md5($random_num)."'
363 if (!$res || db_affected_rows($res) < 1) {
364 $this->setError('ERROR: Could not create group: '.db_error());
369 $id = db_insertid($res, 'groups', 'group_id');
371 $this->setError('ERROR: Could not get group id: '.db_error());
377 // Now, make the user an admin
379 $sql="INSERT INTO user_group ( user_id, group_id, admin_flags,
380 cvs_flags, artifact_flags, forum_flags, role_id)
381 VALUES ( ".$user->getID().", '$id', 'A', 1, 2, 2, 1)";
384 if (!$res || db_affected_rows($res) < 1) {
385 $this->setError('ERROR: Could not add admin to newly created group: '.db_error());
390 if (!$this->fetchData($id)) {
395 $this->sendNewProjectNotificationEmail();
402 * updateAdmin - Update core properties of group object.
404 * This function require site admin privilege.
406 * @param object User requesting operation (for access control).
407 * @param bool Whether group is publicly accessible (0/1).
408 * @param string Project's license (string ident).
409 * @param int Group type (1-project, 2-foundry).
410 * @param string Machine on which group's home directory located.
411 * @param string Domain which serves group's WWW.
415 function updateAdmin(&$user, $is_public, $license, $type_id, $unix_box, $http_domain) {
418 $perm =& $this->getPermission($user);
420 if (!$perm || !is_object($perm)) {
421 $this->setError($Language->getText('general','permnotget'));
425 if (!$perm->isSuperUser()) {
426 $this->setError($Language->getText('general','permdenied'));
434 SET is_public='$is_public',
435 license='$license',type_id='$type_id',
436 unix_box='$unix_box',http_domain='$http_domain'
437 WHERE group_id='".$this->getID()."'
440 if (!$res || db_affected_rows($res) < 1) {
441 $this->setError('ERROR: DB: Could not change group properties: '.db_error());
446 // Log the audit trail
447 if ($is_public != $this->isPublic()) {
448 $this->addHistory('is_public', $this->isPublic());
450 if ($license != $this->data_array['license']) {
451 $this->addHistory('license', $this->data_array['license']);
453 if ($type_id != $this->data_array['type_id']) {
454 $this->addHistory('type_id', $this->data_array['type_id']);
456 if ($unix_box != $this->data_array['unix_box']) {
457 $this->addHistory('unix_box', $this->data_array['unix_box']);
459 if ($http_domain != $this->data_array['http_domain']) {
460 $this->addHistory('http_domain', $this->data_array['http_domain']);
463 if (!$this->fetchData($this->getID())) {
472 * update - Update number of common properties.
474 * Unlike updateAdmin(), this function accessible to project admin.
476 * @param object User requesting operation (for access control).
477 * @param bool Whether group is publicly accessible (0/1).
478 * @param string Project's license (string ident).
479 * @param int Group type (1-project, 2-foundry).
480 * @param string Machine on which group's home directory located.
481 * @param string Domain which serves group's WWW.
482 * @return int status.
485 function update(&$user, $group_name,$homepage,$short_description,$use_mail,$use_survey,$use_forum,
486 $use_pm,$use_pm_depend_box,$use_scm,$use_news,$use_docman,
487 $new_doc_address,$send_all_docs,$logo_image_id,
488 $enable_pserver,$enable_anonscm,
489 $use_ftp,$use_tracker,$use_frs,$use_stats) {
492 $perm =& $this->getPermission($user);
494 if (!$perm || !is_object($perm)) {
495 $this->setError($Language->getText('general','permnotget'));
499 if (!$perm->isAdmin()) {
500 $this->setError($Language->getText('general','permdenied'));
504 // Validate some values
506 $this->setError('Invalid Group Name');
510 if ($new_doc_address) {
511 $invalid_mails = validate_emails($new_doc_address);
512 if (count($invalid_mails) > 0) {
513 $this->setError('New Doc Address(es) Appeared Invalid: '.implode(',',$invalid_mails));
518 // in the database, these all default to '1',
519 // so we have to explicity set 0
532 if (!$use_pm_depend) {
544 if (!$send_all_tasks) {
559 if (!$send_all_docs) {
564 $homepage=$GLOBALS['sys_default_domain'].'/projects/'.$this->getUnixName().'/';
567 if (strlen($short_description)>255) {
568 $this->setError('Error updating project information: Maximum length for Project Description is 255 chars.');
574 //XXX not yet actived logo_image_id='$logo_image_id',
578 group_name='".htmlspecialchars($group_name)."',
579 homepage='$homepage',
580 short_description='".htmlspecialchars($short_description)."',
581 use_mail='$use_mail',
582 use_survey='$use_survey',
583 use_forum='$use_forum',
585 use_pm_depend_box='$use_pm_depend_box',
587 use_news='$use_news',
588 use_docman='$use_docman',
589 new_doc_address='$new_doc_address',
590 send_all_docs='$send_all_docs',
592 if ($enable_pserver != '') {
594 enable_pserver='$enable_pserver',
597 if ($enable_anonscm != '') {
599 enable_anonscm='$enable_anonscm',
604 use_tracker='$use_tracker',
606 use_stats='$use_stats'
607 WHERE group_id='".$this->getID()."'
609 $res = db_query($sql);
611 if (!$res || db_affected_rows($res) < 1) {
612 $this->setError('Error updating project information: '.db_error());
617 // Log the audit trail
618 $this->addHistory('Changed Public Info', '');
620 if (!$this->fetchData($this->getID())) {
629 * getID - Simply return the group_id for this object.
631 * @return int group_id.
634 return $this->data_array['group_id'];
638 * getType() - Foundry, project, etc.
640 * @return int The type flag from the database.
643 return $this->data_array['type_id'];
648 * getStatus - the status code.
650 * Statuses char include I,H,A,D.
652 function getStatus() {
653 return $this->data_array['status'];
657 * setStatus - set the status code.
659 * Statuses include I,H,A,D.
661 * @param object User requesting operation (for access control).
662 * @param string Status value.
663 * @return boolean success.
666 function setStatus(&$user, $status) {
667 global $Language,$SYS;
669 $perm =& $this->getPermission($user);
670 if (!$perm || !is_object($perm)) {
671 $this->setPermissionDeniedError();
673 } elseif (!$perm->isSuperUser()) {
674 $this->setPermissionDeniedError();
678 // Projects in 'A' status can only go to 'H' or 'D'
679 // Projects in 'D' status can only go to 'A'
680 // Projects in 'P' status can only go to 'A' OR 'D'
681 // Projects in 'I' status can only go to 'P'
682 // Projects in 'H' status can only go to 'A' OR 'D'
683 $allowed_status_changes = array(
684 'AH'=>1,'AD'=>1,'DA'=>1,'PA'=>1,'PD'=>1,
685 'IP'=>1,'HA'=>1,'HD'=>1
688 // Check that status transition is valid
689 if ($this->getStatus() != $status
690 && !$allowed_status_changes[$this->getStatus().$status]) {
691 $this->setError('Invalid Status Change');
697 $res = db_query("UPDATE groups
699 WHERE group_id='". $this->getID()."'");
701 if (!$res || db_affected_rows($res) < 1) {
702 $this->setError('ERROR: DB: Could not change group status: '.db_error());
708 // Activate system group, if not yet
709 if (!$SYS->sysCheckGroup($this->getID())) {
710 if (!$SYS->sysCreateGroup($this->getID())) {
711 $this->setError($SYS->getErrorMessage());
716 if (!$this->activateUsers()) {
721 /* Otherwise, the group is not active, and make sure that
722 System group is not active either */
723 } else if ($SYS->sysCheckGroup($this->getID())) {
724 if (!$SYS->sysRemoveGroup($this->getID())) {
725 $this->setError($SYS->getErrorMessage());
733 // Log the audit trail
734 if ($status != $this->getStatus()) {
735 $this->addHistory('status', $this->getStatus());
738 $this->data_array['status'] = $status;
743 * isProject - Simple boolean test to see if it's a project or not.
745 * @return boolean is_project.
747 function isProject() {
748 if ($this->getType()==1) {
756 * isPublic - Simply returns the is_public flag from the database.
758 * @return boolean is_public.
760 function isPublic() {
761 return $this->data_array['is_public'];
765 * isActive - Database field status of 'A' returns true.
767 * @return boolean is_active.
769 function isActive() {
770 if ($this->getStatus()=='A') {
778 * getUnixName - the unix_name
780 * @return string unix_name.
782 function getUnixName() {
783 return strtolower($this->data_array['unix_group_name']);
787 * getPublicName - the full-length public name.
789 * @return string The group_name.
791 function getPublicName() {
792 return $this->data_array['group_name'];
796 * getRegisterPurpose - the text description of the purpose of this project.
798 * @return string The description.
800 function getRegisterPurpose() {
801 return $this->data_array['register_purpose'];
805 * getDescription - the text description of this project.
807 * @return string The description.
809 function getDescription() {
810 return $this->data_array['short_description'];
814 * getStartDate - the unix time this project was registered.
816 * @return int (unix time) of registration.
818 function getStartDate() {
819 return $this->data_array['register_time'];
823 * getLogoImageID - the id of the logo in the database for this project.
825 * @return int The ID of logo image in db_images table (or 100 if none).
827 function getLogoImageID() {
828 return $this->data_array['logo_image_id'];
832 * getUnixBox - the hostname of the unix box where this project is located.
834 * @return string The name of the unix machine for the group.
836 function getUnixBox() {
837 return $this->data_array['unix_box'];
841 * getSCMBox - the hostname of the scm box where this project is located.
843 * @return string The name of the unix machine for the group.
845 function getSCMBox() {
846 return $this->data_array['scm_box'];
849 * setSCMBox - the hostname of the scm box where this project is located.
851 * @param string The name of the new SCM_BOX
853 function setSCMBox($scm_box) {
858 $sql = "UPDATE groups SET scm_box = '$scm_box' WHERE group_id = ".$this->getID();
859 $res = db_query($sql);
861 $this->addHistory('scm_box', $this->data_array['scm_box']);
862 $this->data_array['scm_box']=$scm_box;
867 $this->setError('Couldn\'t insert SCM_BOX to database');
871 $this->setError($Language->getText('admin','scm_box_empty'));
877 * getDomain - the hostname.domain where their web page is located.
879 * @return string The name of the group [web] domain.
881 function getDomain() {
882 return $this->data_array['http_domain'];
886 * getLicense - the license they chose.
888 * @return int ident of group license.
890 function getLicense() {
891 return $this->data_array['license'];
895 * getLicenseName - the name of the license
897 * @return string license name
899 function getLicenseName() {
900 $licenses =& group_get_licenses();
901 if(isset($licenses[$this->data_array['license']])) {
902 return $licenses[$this->data_array['license']];
909 * getLicenseOther - optional string describing license.
911 * @return string The custom license.
913 function getLicenseOther() {
914 if ($this->getLicense() == GROUP_LICENSE_OTHER) {
915 return $this->data_array['license_other'];
922 * getRegistrationPurpose - the text description of the purpose of this project.
924 * @return string The application for project hosting.
926 function getRegistrationPurpose() {
927 return $this->data_array['register_purpose'];
932 * getAdmins() - Get array of Admin user objects.
934 * @return array Array of User objects.
936 function &getAdmins() {
937 // this function gets all group admins in order to send Jabber and mail messages
938 $q = "SELECT user_id FROM user_group WHERE admin_flags = 'A' AND group_id = ".$this->getID();
940 $user_ids=util_result_column_to_array($res);
941 return user_get_objects($user_ids);
946 Common Group preferences for tools
951 * enableAnonSCM - whether or not this group has opted to enable Anonymous SCM.
953 * @return boolean enable_scm.
955 function enableAnonSCM() {
956 if ($this->isPublic() && $this->usesSCM()) {
957 return $this->data_array['enable_anonscm'];
963 function SetUsesAnonSCM ($booleanparam) {
965 $booleanparam = $booleanparam ? 1 : 0 ;
966 $sql = "UPDATE groups SET enable_anonscm = $booleanparam WHERE group_id = ".$this->getID() ;
967 $res = db_query($sql);
969 $this->data_array['enable_anonscm']=$booleanparam;
978 * enablePserver - whether or not this group has opted to enable Pserver.
980 * @return boolean enable_pserver.
982 function enablePserver() {
983 if ($this->usesSCM()) {
984 return $this->data_array['enable_pserver'];
990 function SetUsesPserver ($booleanparam) {
992 $booleanparam = $booleanparam ? 1 : 0 ;
993 $sql = "UPDATE groups SET enable_pserver = $booleanparam WHERE group_id = ".$this->getID() ;
994 $res = db_query($sql);
996 $this->data_array['enable_pserver']=$booleanparam;
1005 * usesSCM - whether or not this group has opted to use SCM.
1007 * @return boolean uses_scm.
1009 function usesSCM() {
1010 global $sys_use_scm;
1012 return $this->data_array['use_scm'];
1019 * usesMail - whether or not this group has opted to use mailing lists.
1021 * @return boolean uses_mail.
1023 function usesMail() {
1024 global $sys_use_mail;
1025 if ($sys_use_mail) {
1026 return $this->data_array['use_mail'];
1033 * usesNews - whether or not this group has opted to use news.
1035 * @return boolean uses_news.
1037 function usesNews() {
1038 global $sys_use_news;
1039 if ($sys_use_news) {
1040 return $this->data_array['use_news'];
1047 * usesForum - whether or not this group has opted to use discussion forums.
1049 * @return boolean uses_forum.
1051 function usesForum() {
1052 global $sys_use_forum;
1053 if ($sys_use_forum) {
1054 return $this->data_array['use_forum'];
1061 * usesStats - whether or not this group has opted to use stats.
1063 * @return boolean uses_stats.
1065 function usesStats() {
1066 return $this->data_array['use_stats'];
1070 * usesFRS - whether or not this group has opted to use file release system.
1072 * @return boolean uses_frs.
1074 function usesFRS() {
1075 global $sys_use_frs;
1077 return $this->data_array['use_frs'];
1084 * usesTracker - whether or not this group has opted to use tracker.
1086 * @return boolean uses_tracker.
1088 function usesTracker() {
1089 global $sys_use_tracker;
1090 if ($sys_use_tracker) {
1091 return $this->data_array['use_tracker'];
1098 * usesDocman - whether or not this group has opted to use docman.
1100 * @return boolean uses_docman.
1102 function usesDocman() {
1103 global $sys_use_docman;
1104 if ($sys_use_docman) {
1105 return $this->data_array['use_docman'];
1112 * usesFTP - whether or not this group has opted to use FTP.
1114 * @return boolean uses_ftp.
1116 function usesFTP() {
1117 global $sys_use_ftp;
1119 return $this->data_array['use_ftp'];
1126 * usesSurvey - whether or not this group has opted to use surveys.
1128 * @return boolean uses_survey.
1130 function usesSurvey() {
1131 global $sys_use_survey;
1132 if ($sys_use_survey) {
1133 return $this->data_array['use_survey'];
1140 * usesPM - whether or not this group has opted to Project Manager.
1142 * @return boolean uses_projman.
1147 return $this->data_array['use_pm'];
1154 * getPlugins - get a list of all available group plugins
1156 * @return array array containing plugin_id => plugin_name
1158 function getPlugins() {
1159 if (!isset($this->plugins_data)) {
1160 $this->plugins_data = array () ;
1161 $sql="SELECT group_plugin.plugin_id, plugins.plugin_name
1162 FROM group_plugin, plugins
1163 WHERE group_plugin.group_id=".$this->getID()."
1164 AND group_plugin.plugin_id = plugins.plugin_id" ;
1165 $res=db_query($sql);
1166 $rows = db_numrows($res);
1168 for ($i=0; $i<$rows; $i++) {
1169 $plugin_id = db_result($res,$i,'plugin_id');
1170 $this->plugins_data[$plugin_id] = db_result($res,$i,'plugin_name');
1173 return $this->plugins_data ;
1177 * usesPlugin - returns true if the group uses a particular plugin
1179 * @param string name of the plugin
1180 * @return boolean whether plugin is being used or not
1182 function usesPlugin($pluginname) {
1183 $plugins_data = $this->getPlugins() ;
1184 foreach ($plugins_data as $p_id => $p_name) {
1185 if ($p_name == $pluginname) {
1193 * setPluginUse - enables/disables plugins for the group
1195 * @param string name of the plugin
1196 * @param boolean the new state
1197 * @return string database result
1199 function setPluginUse($pluginname, $val=true) {
1200 if ($val == $this->usesPlugin($pluginname)) {
1201 // State is already good, returning
1204 $sql="SELECT plugin_id
1206 WHERE plugin_name = '" . $pluginname . "'" ;
1207 $res=db_query($sql);
1208 $rows = db_numrows($res);
1210 // Error: no plugin by that name
1213 $plugin_id = db_result($res,0,'plugin_id');
1215 unset ($this->plugins_data) ;
1217 $sql="INSERT INTO group_plugin (group_id, plugin_id)
1218 VALUES (". $this->getID() . ", ". $plugin_id .")" ;
1219 $res=db_query($sql);
1222 $sql="DELETE FROM group_plugin
1223 WHERE group_id = ". $this->getID() . "
1224 AND plugin_id = ". $plugin_id ;
1225 $res=db_query($sql);
1231 * getDocEmailAddress - get email address(es) to send doc notifications to.
1233 * @return string email address.
1235 function getDocEmailAddress() {
1236 return $this->data_array['new_doc_address'];
1240 * DocEmailAll - whether or not this group has opted to use receive notices on all doc updates.
1242 * @return boolean email_on_all_doc_updates.
1244 function docEmailAll() {
1245 return $this->data_array['send_all_docs'];
1250 * getHomePage - The URL for this project's home page.
1252 * @return string homepage URL.
1254 function getHomePage() {
1255 return $this->data_array['homepage'];
1259 * getPermission - Return a Permission for this Group and the specified User.
1261 * @param object The user you wish to get permission for (usually the logged in user).
1262 * @return object The Permission.
1264 function &getPermission(&$_user) {
1265 return permission_get_object($this, $_user);
1270 * userIsAdmin - Return if for this Group the User is admin.
1272 * @return boolean is_admin.
1274 function userIsAdmin() {
1275 $perm =& $this->getPermission( session_get_user() );
1276 if (!$perm || !is_object($perm)) {
1278 } elseif ($perm->isError()) {
1281 return $perm->isAdmin();
1284 function delete($sure,$really_sure,$really_really_sure) {
1287 if (!$sure || !$really_sure || !$really_really_sure) {
1288 $this->setMissingParamsError();
1291 if ($this->getID() == $GLOBALS['sys_news_group'] ||
1292 $this->getID() == 1 ||
1293 $this->getID() == $GLOBALS['sys_stats_group'] ||
1294 $this->getID() == $GLOBALS['sys_peer_rating_group']) {
1295 $this->setError('Cannot Delete System Group');
1298 $perm =& $this->getPermission( session_get_user() );
1299 if (!$perm || !is_object($perm)) {
1300 $this->setPermissionDeniedError();
1302 } elseif ($perm->isError()) {
1303 $this->setPermissionDeniedError();
1305 } elseif (!$perm->isSuperUser()) {
1306 $this->setPermissionDeniedError();
1312 // Remove all the members
1314 $members =& $this->getMembers();
1315 for ($i=0; $i<count($members); $i++) {
1316 $this->removeUser($members[$i]->getID());
1317 //echo 'RemoveMembers'.db_error();
1322 $atf = new ArtifactTypeFactory($this);
1323 $at_arr =& $atf->getArtifactTypes();
1324 for ($i=0; $i<count($at_arr); $i++) {
1325 if (!is_object($at_arr[$i])) {
1326 echo "Not Object: ArtifactType: ".$i;
1329 $at_arr[$i]->delete(1,1);
1330 //echo 'ArtifactTypeFactory'.db_error();
1335 $ff = new ForumFactory($this);
1336 $f_arr =& $ff->getForums();
1337 for ($i=0; $i<count($f_arr); $i++) {
1338 if (!is_object($f_arr[$i])) {
1339 echo "Not Object: Forum: ".$i;
1342 $f_arr[$i]->delete(1,1);
1343 //echo 'ForumFactory'.db_error();
1346 // Delete Subprojects
1348 $pgf = new ProjectGroupFactory($this);
1349 $pg_arr =& $pgf->getProjectGroups();
1350 for ($i=0; $i<count($pg_arr); $i++) {
1351 if (!is_object($pg_arr[$i])) {
1352 echo "Not Object: ProjectGroup: ".$i;
1355 $pg_arr[$i]->delete(1,1);
1356 //echo 'ProjectGroupFactory'.db_error();
1359 // Delete FRS Packages
1361 //$frspf = new FRSPackageFactory($this);
1362 $res=db_query("SELECT * FROM frs_package WHERE group_id='".$this->getID()."'");
1363 //echo 'frs_package'.db_error();
1364 //$frsp_arr =& $frspf->getPackages();
1365 while ($arr = db_fetch_array($res)) {
1366 //if (!is_object($pg_arr[$i])) {
1367 // echo "Not Object: ProjectGroup: ".$i;
1370 $frsp=new FRSPackage($this,$arr['package_id'],$arr);
1376 $news_group=&group_get_object($GLOBALS['sys_news_group']);
1377 $res=db_query("SELECT forum_id FROM news_bytes WHERE group_id='".$this->getID()."'");
1378 for ($i=0; $i<db_numrows($res); $i++) {
1379 $Forum = new Forum($news_group,db_result($res,$i,'forum_id'));
1380 if (!$Forum->delete(1,1)) {
1381 echo "Could Not Delete News Forum: ".$Forum->getID();
1384 $res=db_query("DELETE FROM news_bytes WHERE group_id='".$this->getID()."'");
1389 $res=db_query("DELETE FROM doc_data WHERE group_id='".$this->getID()."'");
1390 //echo 'doc_data'.db_error();
1391 $res=db_query("DELETE FROM doc_groups WHERE group_id='".$this->getID()."'");
1392 //echo 'doc_groups'.db_error();
1394 // Delete group history
1396 $res=db_query("DELETE FROM group_history WHERE group_id='".$this->getID()."'");
1397 //echo 'group_history'.db_error();
1399 // Delete group plugins
1401 $res=db_query("DELETE FROM group_plugin WHERE group_id='".$this->getID()."'");
1402 //echo 'group_plugin'.db_error();
1404 // Delete group cvs stats
1406 $res=db_query("DELETE FROM stats_cvs_group WHERE group_id='".$this->getID()."'");
1407 //echo 'stats_cvs_group'.db_error();
1411 $sf = new SurveyFactory($this);
1412 $s_arr =& $sf->getSurveys();
1413 for ($i=0; $i<count($s_arr); $i++) {
1414 if (!is_object($s_arr[$i])) {
1415 echo "Not Object: Survey: ".$i;
1418 $s_arr[$i]->delete();
1419 //echo 'SurveyFactory'.db_error();
1422 // Delete SurveyQuestions
1424 $sqf = new SurveyQuestionFactory($this);
1425 $sq_arr =& $sqf->getSurveyQuestions();
1426 for ($i=0; $i<count($sq_arr); $i++) {
1427 if (!is_object($sq_arr[$i])) {
1428 echo "Not Object: SurveyQuestion: ".$i;
1431 $sq_arr[$i]->delete();
1432 //echo 'SurveyQuestionFactory'.db_error();
1435 // Delete Mailing List Factory
1437 $mlf = new MailingListFactory($this);
1438 $ml_arr =& $mlf->getMailingLists();
1439 for ($i=0; $i<count($ml_arr); $i++) {
1440 if (!is_object($ml_arr[$i])) {
1441 echo "Not Object: MailingList: ".$i;
1444 if (!$ml_arr[$i]->delete(1,1)) {
1445 $this->setError($Language->getText('mail','error_delete'));
1447 //echo 'MailingListFactory'.db_error();
1452 $res=db_query("DELETE FROM trove_group_link WHERE group_id='".$this->getID()."'");
1453 $res=db_query("DELETE FROM trove_agg WHERE group_id='".$this->getID()."'");
1457 $res=db_query("DELETE FROM project_sums_agg WHERE group_id='".$this->getID()."'");
1458 //echo 'project_sums_agg'.db_error();
1459 $res=db_query("INSERT INTO deleted_groups (
1460 unix_group_name,delete_date,isdeleted) VALUES
1461 ('".$this->getUnixName()."','".time()."','0')");
1462 //echo 'InsertIntoDeleteQueue'.db_error();
1463 $res=db_query("DELETE FROM groups WHERE group_id='".$this->getID()."'");
1464 //echo 'DeleteGroup'.db_error();
1469 if (isset($GLOBALS['sys_upload_dir']) && $this->getUnixName()) {
1470 exec('/bin/rm -rf '.$GLOBALS['sys_upload_dir'].'/'.$this->getUnixName().'/');
1472 if (isset($GLOBALS['sys_ftp_upload_dir']) && $this->getUnixName()) {
1473 exec('/bin/rm -rf '.$GLOBALS['sys_ftp_upload_dir'].'/'.$this->getUnixName().'/');
1478 $res=db_query("DELETE FROM rep_group_act_weekly WHERE group_id='".$this->getID()."'");
1479 //echo 'rep_group_act_weekly'.db_error();
1480 $res=db_query("DELETE FROM rep_group_act_monthly WHERE group_id='".$this->getID()."'");
1481 //echo 'rep_group_act_monthly'.db_error();
1482 $res=db_query("DELETE FROM rep_group_act_daily WHERE group_id='".$this->getID()."'");
1483 //echo 'rep_group_act_daily'.db_error();
1484 unset($this->data_array);
1492 Basic functions to add/remove users to/from a group
1493 and update their permissions
1499 * addUser - controls adding a user to a group.
1501 * @param string Unix name of the user to add OR integer user_id.
1502 * @param int The role_id this user should have.
1503 * @return boolean success.
1506 function addUser($user_unix_name,$role_id) {
1507 global $Language,$SYS;
1509 Admins can add users to groups
1512 $perm =& $this->getPermission( session_get_user() );
1513 if (!$perm || !is_object($perm) || !$perm->isAdmin()) {
1514 $this->setPermissionDeniedError();
1520 get user id for this user's unix_name
1522 if (eregi('[^0-9]',$user_unix_name)) {
1523 $res_newuser = db_query("SELECT * FROM users WHERE user_name='". strtolower($user_unix_name) ."'");
1525 $res_newuser = db_query("SELECT * FROM users WHERE user_id='". intval($user_unix_name) ."'");
1527 if (db_numrows($res_newuser) > 0) {
1529 // make sure user is active
1531 if (db_result($res_newuser,0,'status') != 'A') {
1532 $this->setError('User is not active. Only active users can be added.');
1538 // user was found - set new user_id var
1540 $user_id = db_result($res_newuser,0,'user_id');
1543 // if not already a member, add them
1545 $res_member = db_query("SELECT user_id
1547 WHERE user_id='$user_id' AND group_id='". $this->getID() ."'");
1549 if (db_numrows($res_member) < 1) {
1551 // Create this user's row in the user_group table
1553 $res=db_query("INSERT INTO user_group
1554 (user_id,group_id,admin_flags,forum_flags,project_flags,
1555 doc_flags,cvs_flags,member_role,release_flags,artifact_flags)
1556 VALUES ('$user_id','". $this->getID() ."','','0','0','0','1','100','0','0')");
1558 //verify the insert worked
1559 if (!$res || db_affected_rows($res) < 1) {
1560 $this->setError('ERROR: Could Not Add User To Group: '.db_error());
1565 // Add to all forums
1567 $sql="INSERT INTO forum_perm (group_forum_id,user_id,perm_level)
1568 SELECT group_forum_id,$user_id,1
1569 FROM forum_group_list
1570 WHERE group_id='".$this->getID()."'";
1571 $res=db_query($sql);
1573 $this->setError('Adding to forums: '.db_error());
1578 // Add to all subprojects
1580 $sql="INSERT INTO project_perm (group_project_id,user_id,perm_level)
1581 SELECT group_project_id,$user_id,2
1582 FROM project_group_list
1583 WHERE group_id='".$this->getID()."'";
1584 $res=db_query($sql);
1586 $this->setError('Adding to subprojects: '.db_error());
1591 // Add to all trackers
1593 $sql="INSERT INTO artifact_perm (group_artifact_id,user_id,perm_level)
1594 SELECT group_artifact_id,$user_id,2
1595 FROM artifact_group_list
1596 WHERE group_id='".$this->getID()."'";
1597 $res=db_query($sql);
1599 $this->setError('Adding to subprojects: '.db_error());
1605 // check and create if group doesn't exists
1607 //echo "<h2>Group::addUser SYS->sysCheckCreateGroup(".$this->getID().")</h2>";
1608 if (!$SYS->sysCheckCreateGroup($this->getID())){
1609 $this->setError($SYS->getErrorMessage());
1614 // check and create if user doesn't exists
1616 //echo "<h2>Group::addUser SYS->sysCheckCreateUser($user_id)</h2>";
1617 if (!$SYS->sysCheckCreateUser($user_id)) {
1618 $this->setError($SYS->getErrorMessage());
1625 $role = new Role($this,$role_id);
1626 if (!$role || !is_object($role)) {
1627 $this->setError('Error Getting Role Object');
1630 } elseif ($role->isError()) {
1631 $this->setError('addUser::roleget::'.$role->getErrorMessage());
1635 //echo "<h2>Group::addUser role->setUser($user_id)</h2>";
1636 if (!$role->setUser($user_id)) {
1637 $this->setError('addUser::role::setUser'.$role->getErrorMessage());
1643 // user was already a member
1644 // make sure they are set up
1646 $user=&user_get_object($user_id,$res_newuser);
1647 $user->fetchData($user->getID());
1648 $role = new Role($this,$role_id);
1649 if (!$role || !is_object($role)) {
1650 $this->setError('Error Getting Role Object');
1653 } elseif ($role->isError()) {
1654 $this->setError('addUser::roleget::'.$role->getErrorMessage());
1658 //echo "<h2>Already Member Group::addUser role->setUser($user_id)</h2>";
1659 if (!$role->setUser($user_id)) {
1660 $this->setError('addUser::role::setUser'.$role->getErrorMessage());
1665 // set up their system info
1667 //echo "<h2>Already Member Group::addUser SYS->sysCheckCreateUser($user_id)</h2>";
1668 if (!$SYS->sysCheckCreateUser($user_id)) {
1669 $this->setError($SYS->getErrorMessage());
1678 // user doesn't exist
1680 $this->setError('ERROR: User does not exist');
1687 $this->addHistory('Added User',$user_unix_name);
1693 * removeUser - controls removing a user from a group.
1695 * Users can remove themselves.
1697 * @param int The ID of the user to remove.
1698 * @return boolean success.
1700 function removeUser($user_id) {
1701 global $Language,$SYS;
1703 if ($user_id==user_getid()) {
1704 //users can remove themselves
1705 //everyone else must be a project admin
1707 $perm =& $this->getPermission( session_get_user() );
1709 if (!$perm || !is_object($perm) || !$perm->isAdmin()) {
1710 $this->setPermissionDeniedError();
1716 $res=db_query("DELETE FROM user_group
1717 WHERE group_id='".$this->getID()."'
1718 AND user_id='$user_id'");
1719 if (!$res || db_affected_rows($res) < 1) {
1720 $this->setError('ERROR: DB: User not removed.'.db_error());
1725 // remove them from artifact types
1727 $res=db_query("DELETE FROM artifact_perm
1728 WHERE group_artifact_id
1729 IN (SELECT group_artifact_id
1730 FROM artifact_group_list
1731 WHERE group_id='".$this->getID()."')
1732 AND user_id='$user_id'");
1734 $this->setError('ERROR: DB: artifact_perm.'.db_error());
1739 // remove them from subprojects
1741 $res=db_query("DELETE FROM project_perm
1742 WHERE group_project_id
1743 IN (SELECT group_project_id
1744 FROM project_group_list
1745 WHERE group_id='".$this->getID()."')
1746 AND user_id='$user_id'");
1748 $this->setError('ERROR: DB: project_perm.'.db_error());
1753 // remove them from forums
1755 $res=db_query("DELETE FROM forum_perm
1756 WHERE group_forum_id
1757 IN (SELECT group_forum_id
1758 FROM forum_group_list
1759 WHERE group_id='".$this->getID()."')
1760 AND user_id='$user_id'");
1762 $this->setError('ERROR: DB: forum_perm.'.db_error());
1768 // reassign open artifacts to id=100
1770 $res=db_query("UPDATE artifact SET assigned_to='100'
1771 WHERE group_artifact_id
1772 IN (SELECT group_artifact_id
1773 FROM artifact_group_list
1774 WHERE group_id='".$this->getID()."')
1775 AND status_id='1' AND assigned_to='$user_id'");
1777 $this->setError('ERROR: DB: artifact.'.db_error());
1783 // reassign open tasks to id=100
1784 // first have to purge any assignments that would cause
1785 // conflict with existing assignment to 100
1787 $res=db_query("DELETE FROM project_assigned_to
1788 WHERE project_task_id IN (SELECT pt.project_task_id
1789 FROM project_task pt, project_group_list pgl, project_assigned_to pat
1790 WHERE pt.group_project_id = pgl.group_project_id
1791 AND pat.project_task_id=pt.project_task_id
1792 AND pt.status_id='1' AND pgl.group_id='".$this->getID()."'
1793 AND pat.assigned_to_id='$user_id')
1794 AND assigned_to_id='100'");
1796 $this->setError('ERROR: DB: project_assigned_to 1'.db_error());
1800 $res=db_query("UPDATE project_assigned_to SET assigned_to_id='100'
1801 WHERE project_task_id IN (SELECT pt.project_task_id
1802 FROM project_task pt, project_group_list pgl
1803 WHERE pt.group_project_id = pgl.group_project_id
1804 AND pt.status_id='1' AND pgl.group_id='".$this->getID()."')
1805 AND assigned_to_id='$user_id'");
1807 $this->setError('ERROR: DB: project_assigned_to.'.db_error());
1813 // Remove user from system
1815 //echo "<h2>Group::addUser SYS->sysGroupRemoveUser(".$this->getID().",$user_id)</h2>";
1816 if (!$SYS->sysGroupRemoveUser($this->getID(),$user_id)) {
1817 $this->setError($SYS->getErrorMessage());
1822 $this->addHistory('removed user',$user_id);
1830 * updateUser - controls updating a user's role in this group.
1832 * @param int The ID of the user.
1833 * @param int The role_id to set this user to.
1834 * @return boolean success.
1836 function updateUser($user_id,$role_id) {
1837 global $Language,$SYS;
1839 $perm =& $this->getPermission( session_get_user() );
1840 if (!$perm || !is_object($perm) || !$perm->isAdmin()) {
1841 $this->setPermissionDeniedError();
1845 $role = new Role($this,$role_id);
1846 if (!$role || !is_object($role)) {
1847 $this->setError('Could Not Get Role');
1849 } elseif ($role->isError()) {
1850 $this->setError('Role: '.$role->getErrorMessage());
1853 //echo "<h3>Group::updateUser role->setUser($user_id)</h3>";
1854 if (!$role->setUser($user_id)) {
1855 $this->setError('Role: '.$role->getErrorMessage());
1858 $this->addHistory('updated user',$user_id);
1863 * addHistory - Makes an audit trail entry for this project.
1865 * @param string The name of the field.
1866 * @param string The Old Value for this $field_name.
1867 * @return database result handle.
1870 function addHistory($field_name, $old_value) {
1872 INSERT INTO group_history(group_id,field_name,old_value,mod_by,adddate)
1873 VALUES ('". $this->getID() ."','$field_name','$old_value','". user_getid() ."','".time()."')
1875 return db_query($sql);
1879 * activateUsers - Make sure that group members have unix accounts.
1881 * Setup unix accounts for group members. Can be called even
1882 * if members are already active.
1886 function activateUsers() {
1889 Activate member(s) of the project
1892 $member_res = db_query("SELECT user_id, role_id
1894 WHERE group_id='".$this->getID()."'");
1896 $rows = db_numrows($member_res);
1900 for ($i=0; $i<$rows; $i++) {
1902 $member =& user_get_object(db_result($member_res,$i,'user_id'));
1903 $roleId = db_result($member_res,$i,'role_id');
1905 if (!$member || !is_object($member)) {
1906 $this->setError('Error getting member object');
1908 } else if ($member->isError()) {
1909 $this->setError('Error getting member object: '.$member->getErrorMessage());
1913 if (!$this->addUser($member->getUnixName(),$roleId)) {
1924 * getMembers - returns array of User objects for this project
1926 * @return array of User objects for this group.
1928 function &getMembers() {
1929 if (!isset($this->membersArr)) {
1930 $res=db_query("SELECT users.* FROM users
1931 INNER JOIN user_group ON users.user_id=user_group.user_id
1932 WHERE user_group.group_id='".$this->getID()."'");
1933 while ($arr =& db_fetch_array($res)) {
1934 $this->membersArr[] =& new User($arr['user_id'],$arr);
1937 return $this->membersArr;
1941 * approve - Approve pending project.
1943 * @param object The User object who is doing the updating.
1946 function approve(&$user) {
1948 if ($this->getStatus()=='A') {
1949 $this->setError("Group already active");
1955 // Step 1: Activate group and create LDAP entries
1956 if (!$this->setStatus($user, 'A')) {
1963 // Tracker Integration
1966 $ats = new ArtifactTypes($this);
1967 if (!$ats || !is_object($ats)) {
1968 $this->setError('Error creating ArtifactTypes object');
1971 } else if ($ats->isError()) {
1972 $this->setError('ATS1 '.$ats->getErrorMessage());
1976 if (!$ats->createTrackers()) {
1977 $this->setError('ATS2 '.$ats->getErrorMessage());
1984 // Forum Integration
1987 $f = new Forum($this);
1988 if (!$f->create('Open-Discussion','General Discussion',1,'',1,0)) {
1989 $this->setError('F1 '.$f->getErrorMessage());
1993 $f = new Forum($this);
1994 if (!$f->create('Help','Get Public Help',1,'',1,0)) {
1995 $this->setError('F2 '.$f->getErrorMessage());
1999 $f = new Forum($this);
2000 if (!$f->create('Developers','Project Developer Discussion',0,'',1,0)) {
2001 $this->setError('F3 '.$f->getErrorMessage());
2008 // Doc Mgr Integration
2011 $dg = new DocumentGroup($this);
2012 if (!$dg->create('Uncategorized Submissions')) {
2013 $this->setError('DG1 '.$dg->getErrorMessage());
2023 $frs = new FRSPackage($this);
2024 if (!$frs->create($this->getUnixName())) {
2025 $this->setError('FRSP '.$frs->getErrorMessage());
2035 $pg = new ProjectGroup($this);
2036 if (!$pg->create('To Do','Things We Have To Do',1)) {
2037 $this->setError('PG1 '.$pg->getErrorMessage());
2041 $pg = new ProjectGroup($this);
2042 if (!$pg->create('Next Release','Items For Our Next Release',1)) {
2043 $this->setError('PG2 '.$pg->getErrorMessage());
2050 // Set Default Roles
2053 $role = new Role($this);
2054 $todo = array_keys($role->defaults);
2055 for ($c=0; $c<count($todo); $c++) {
2056 $role = new Role($this);
2057 if (!$role->createDefault($todo[$c])) {
2058 $this->setError('R'.$c.' '.$role->getErrorMessage());
2066 // Create MailingList
2069 $mlist = new MailingList($this);
2070 $admin_group = db_query("SELECT user_id FROM user_group
2071 WHERE group_id=".$this->getID()." AND admin_flags='A'");
2072 if (db_numrows($admin_group) > 0) {
2073 $idadmin_group = db_result($admin_group,0,'user_id');
2075 if (!$mlist->create('commits','cvs commits',1,$idadmin_group)) {
2076 $this->setError('MailingList: '.$mlist->getErrorMessage());
2083 $this->sendApprovalEmail();
2084 $this->addHistory('approved', 'x');
2087 //change assistant for webcal
2089 $params[0] = $idadmin_group ;
2090 $params[1] = $this->getID();
2091 plugin_hook('change_cal_permission_default',$params);
2099 * sendApprovalEmail - Send new project email.
2101 * @return boolean success.
2104 function sendApprovalEmail() {
2105 $res_admins = db_query("
2106 SELECT users.user_name,users.email,users.language
2107 FROM users,user_group
2108 WHERE users.user_id=user_group.user_id
2109 AND user_group.group_id='".$this->getID()."'
2110 AND user_group.admin_flags='A'
2113 if (db_numrows($res_admins) < 1) {
2114 $this->setError("Group does not have any administrators.");
2118 // send one email per admin
2119 while ($row_admins = db_fetch_array($res_admins)) {
2120 $l = new BaseLanguage () ;
2121 $l->loadLanguageID($row_admins['language']);
2123 // $2 $2 $3 $4 $5 $6
2124 $message=stripcslashes($l->getText('classgroup', 'acceptedproject', array($this->getPublicName(), $this->getUnixName(), $GLOBALS['sys_default_domain'], $GLOBALS['sys_shell_host'], $GLOBALS['sys_scm_host'], $this->getID(), $GLOBALS['sys_name'])));
2126 util_send_message($row_admins['email'], $l->getText('classgroup', 'acceptedprojecttitle', array($GLOBALS['sys_name'])), $message);
2134 * sendRejectionEmail - Send project rejection email.
2136 * This function sends out a rejection message to a user who
2137 * registered a project.
2139 * @param int The id of the response to use.
2140 * @param string The rejection message.
2141 * @return completion status.
2144 function sendRejectionEmail($response_id, $message="zxcv") {
2145 $res_admins = db_query("
2146 SELECT u.email, u.language
2147 FROM users u, user_group ug
2148 WHERE ug.group_id='".$this->getID()."'
2149 AND u.user_id=ug.user_id;
2152 if (db_numrows($res_admins) < 1) {
2153 $this->setError("Group does not have any administrators.");
2157 while ($row_admins = db_fetch_array($res_admins)) {
2158 $l = new BaseLanguage () ;
2159 $l->loadLanguageID($row_admins['language']);
2161 $response=stripcslashes($l->getText('classgroup', 'rejectedproject', array($this->getPublicName(), $this->getUnixName(), $GLOBALS['sys_name'])));
2163 // Check to see if they want to send a custom rejection response
2164 if ($response_id == 0) {
2165 $response .= stripcslashes($message);
2167 $response .= db_result(db_query("
2168 SELECT response_text
2169 FROM canned_responses
2170 WHERE response_id='$response_id'
2171 "), 0, "response_text");
2174 util_send_message($row_admins['email'], $l->getText('classgroup', 'rejectedprojecttitle', array($GLOBALS['sys_name'])), $response);
2181 * sendNewProjectNotificationEmail - Send new project notification email.
2183 * This function sends out a notification email to the
2184 * SourceForge admin user when a new project is
2187 * @return boolean success.
2190 function sendNewProjectNotificationEmail() {
2192 $res = db_query("SELECT users.email, users.language
2193 FROM users,user_group
2195 AND user_group.admin_flags='A'
2196 AND users.user_id=user_group.user_id;");
2198 if (db_numrows($res) < 1) {
2199 $this->setError("There is no administrator to send the mail.");
2202 for ($i=0; $i<db_numrows($res) ; $i++) {
2203 $admin_email = db_result($res,$i,'email') ;
2204 $l = new BaseLanguage () ;
2205 $l->loadLanguageID(db_result($res,$i,'language'));
2207 $message=stripcslashes($l->getText('classgroup', 'newprojectnotification', array($GLOBALS['sys_name'], $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), $this->getLicenseName(), $GLOBALS['sys_default_domain'])));
2208 util_send_message($admin_email, $l->getText('classgroup', 'newprojectnotificationtitle', array($GLOBALS['sys_name'])), $message);
2212 // Get the email of the user who wants to register the project
2213 $res = db_query("SELECT u.email, u.language
2214 FROM users u, user_group ug
2215 WHERE ug.group_id='".$this->getID()."' AND u.user_id=ug.user_id;");
2217 if (db_numrows($res) < 1) {
2218 $this->setError("Cound not find user who has submitted the project.");
2221 for ($i=0; $i<db_numrows($res) ; $i++) {
2222 $email = db_result($res, $i, 'email');
2223 $l = new BaseLanguage () ;
2224 $l->loadLanguageID(db_result($res,$i,'language'));
2226 $message=stripcslashes($l->getText('classgroup', 'newprojectnotification_submitter', array($GLOBALS['sys_name'], $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), $this->getLicenseName(), $GLOBALS['sys_default_domain'])));
2228 util_send_message($email, $l->getText('classgroup', 'newprojectnotificationtitle', array($GLOBALS['sys_name'])), $message);
2238 * group_getname() - get the group name
2240 * @param int The group ID
2244 function group_getname ($group_id = 0) {
2245 $grp = &group_get_object($group_id);
2247 return $grp->getPublicName();
2254 * group_getunixname() - get the unixname for a group
2256 * @param int The group ID
2260 function group_getunixname ($group_id) {
2261 $grp = &group_get_object($group_id);
2263 return $grp->getUnixName();
2270 * group_get_result() - Get the group object result ID.
2272 * @param int The group ID
2276 function &group_get_result($group_id=0) {
2277 $grp = &group_get_object($group_id);
2279 return $grp->getData();
2286 * getUnixStatus - Status of activation of unix account.
2288 * @return char (N)one, (A)ctive, (S)uspended or (D)eleted
2290 function getUnixStatus() {
2291 return $this->data_array['unix_status'];
2295 * setUnixStatus - Sets status of activation of unix account.
2297 * @param string The unix status.
2303 * @return boolean success.
2305 function setUnixStatus($status) {
2306 global $Language,$SYS;
2310 SET unix_status='$status'
2311 WHERE group_id='". $this->getID()."'
2315 $this->setError('ERROR - Could Not Update Group Unix Status: '.db_error());
2319 if ($status == 'A') {
2320 if (!$SYS->sysCheckCreateGroup($this->getID())) {
2321 $this->setError($SYS->getErrorMessage());
2326 if ($SYS->sysCheckGroup($this->getID())) {
2327 if (!$SYS->sysRemoveGroup($this->getID())) {
2328 $this->setError($SYS->getErrorMessage());
2335 $this->data_array['unix_status']=$status;
2343 // c-file-style: "bsd"