Index: common/include/Group.class =================================================================== RCS file: /cvsroot/gforge/gforge/common/include/Group.class,v retrieving revision 1.22 diff -u -b -r1.22 Group.class --- common/include/Group.class 12 Feb 2003 17:23:47 -0000 1.22 +++ common/include/Group.class 16 Feb 2003 06:35:09 -0000 @@ -125,6 +125,13 @@ var $types_res; /** + * List of members. + * + * @var array $members_array. + */ + var $members_array; + + /** * Associative array of data for plugins. * * @var array $plugins_array. @@ -789,6 +796,18 @@ return $this->data_array['register_purpose']; } + function getMembers() { + if (!$this->members_array) { + $query = "SELECT users.user_id, users.realname, users.* + FROM users,user_group + WHERE users.user_id=user_group.user_id + AND user_group.group_id='".$this->getID()."'"; + $this->members_array = db_query($query); + } + return $this->members_array; + } + + /* Index: common/tracker/Artifact.class =================================================================== RCS file: /cvsroot/gforge/gforge/common/tracker/Artifact.class,v retrieving revision 1.7 diff -u -b -r1.7 Artifact.class --- common/tracker/Artifact.class 12 Feb 2003 17:23:47 -0000 1.7 +++ common/tracker/Artifact.class 16 Feb 2003 06:35:10 -0000 @@ -48,6 +48,13 @@ var $data_array; /** + * Array of user IDs to CC: on changes. + * + * @var array $cc. + */ + var $cc; + + /** * Array of ArtifactFile objects. * * @var array $files @@ -118,11 +125,11 @@ * @param int The ID of the user to which this artifact is to be assigned. * @param int The artifacts priority. * @param string An email address to add to the monitoring queue. + * @param array An array ofuser_id's that should be CC:ed * @return id on success / false on failure. */ - function create($category_id, $artifact_group_id, $summary, $details, $assigned_to=100, $priority=5, $monitor_email=false) { + function create($category_id, $artifact_group_id, $summary, $details, $assigned_to=100, $priority=5, $monitor_email=false, &$cc_arr) { global $Language; - // // make sure this person has permission to add artifacts // @@ -221,6 +228,7 @@ $artifact_id=db_insertid($res,'artifact','artifact_id'); + if (!$res || !$artifact_id) { $this->setError('Artifact: '.db_error()); db_rollback(); @@ -234,6 +242,11 @@ return false; } + if (!$this->setCC($cc_arr)) { + db_rollback(); + return false; + } + // // now send an email if appropriate // @@ -433,6 +446,63 @@ return $this->data_array['assigned_unixname']; } + function &getCC() { + if (!$this->getID()) { + return array(); + } + if (!$this->cc) { + $this->cc =& util_result_column_to_array(db_query("SELECT cc_id FROM tracker_cc WHERE artifact_id='".$this->getID()."'")); + } + return $this->cc; + } + + function getCCString() { + $cc_arr = $this->getCC(); + if (!$cc_arr) { + return 'Nobody (none)'; + } + while (list($key, $value) = each($cc_arr)) { + $user = user_get_object($value); + if ($return) { + $return .= ", "; + } + $return .= $user->getRealName() . " (" . $user->getUnixName() . ")"; + } + return $return; + } + + function setCC(&$arr) { + $arr2 =& $this->getCC(); + $this->cc =& $arr2; + if (count($arr) < 1 || ((count($arr)==1) && ($arr[0]==''))) { + $arr=array('100'); + } + if (count($arr) || count($arr2)) { + $add_arr = array_diff($arr, $arr2); + $del_arr = array_diff($arr2, $arr); + while(list($key, $value) = each($del_arr)) { + db_query("DELETE FROM tracker_cc + WHERE artifact_id='".$this->getID()."' + AND cc_id='".$value."'"); + if (db_error()) { + $this->setError('setCC 1:: ' . db_error()); + return false; + } + } + while(list($key, $value) = each($add_arr)) { + db_query("INSERT INTO tracker_cc (artifact_id, cc_id) + VALUES ('".$this->getID()."', '". $value . "')"); + if (db_error()) { + $this->setError('setCC 2:: ' . db_error()); + return false; + } + } + return true; + } else { + return true; + } + } + /** * getOpenDate - get unix time of creation. * @@ -670,10 +740,11 @@ * @param int The canned response. * @param string Attaching another comment. * @param int Allows you to move an artifact to another type. + * @param array List of user_id's to CC. * @return boolean success. */ function update($priority,$status_id,$category_id,$artifact_group_id,$resolution_id, - $assigned_to,$summary,$canned_response,$details,$new_artifact_type_id) { + $assigned_to,$summary,$canned_response,$details,$new_artifact_type_id, &$cc_arr) { global $Language; if (!$this->getID() @@ -806,6 +877,19 @@ $update = true; } + $cc_add = array_diff($cc_arr, $this->getCC()); + $cc_del = array_diff($this->getCC(), $cc_arr); + if ($cc_add || $cc_del) { + $old_cc = $this->getCCString(); + if (!$this->setCC($cc_arr)) { + db_rollback(); + return false; + } else { + $this->addHistory('cc',$old_cc); + $changes['cc'] = 1; + $send_message = true; + } + } /* Finally, update the artifact itself */ @@ -924,6 +1008,8 @@ $this->marker('assigned_to',$changes). "Assigned to: ". $this->getAssignedRealName() . " (". $this->getAssignedUnixName(). ")"."\n". + $this->marker('cc',$changes). + "CC: " . $this->getCCString() . "\n". $this->marker('summary',$changes). "Summary: ". util_unconvert_htmlspecialchars( $this->getSummary() ); @@ -961,6 +1047,17 @@ } } + // Add CC: people to emails. + $cc_arr = $this->getCC(); + reset($cc_arr); + while(list($key, $value) = each($cc_arr)) { + if ($value != 100) { + $user = user_get_object($value); + $emails[] = $user->getEmail(); + $jabbers[] = $user->getJabberAddress(); + } + } + $body .= "\n\nInitial Comment:". "\n".util_unconvert_htmlspecialchars( $this->getDetails() ) . "\n\n----------------------------------------------------------------------"; @@ -1016,6 +1113,9 @@ if (count($emails) > 0) { $BCC=implode(',',array_unique($emails)); } + if (count($jabbers) > 0) { + $jab=implode(',',array_unique($jabbers)); + } if (count($monitor_ids) < 1) { $monitor_ids=array(); @@ -1025,7 +1125,7 @@ /* Send the email */ - util_handle_message($monitor_ids,$subject,$body,$BCC); + util_handle_message($monitor_ids,$subject,$body,$BCC,$jab); return true; } Index: www/tracker/add.php =================================================================== RCS file: /cvsroot/gforge/gforge/www/tracker/add.php,v retrieving revision 1.7 diff -u -b -r1.7 add.php --- www/tracker/add.php 13 Feb 2003 13:58:22 -0000 1.7 +++ www/tracker/add.php 16 Feb 2003 06:35:10 -0000 @@ -46,6 +46,9 @@ echo '