5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2002-2004, GForge, LLC
7 * Copyright 2009, Roland Mas
9 * This file is part of FusionForge.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published
13 * by the Free Software Foundation; either version 2 of the License,
14 * or (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with FusionForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 require_once $gfcommon.'include/Error.class.php';
28 require_once $gfcommon.'tracker/ArtifactExtraFieldElement.class.php';
31 * Gets an ArtifactType object from the artifact type id
33 * @param artType_id the ArtifactType id
34 * @param res the DB handle if passed in (optional)
35 * @return the ArtifactType object
37 function &artifactType_get_object($artType_id,$res=false) {
38 global $ARTIFACTTYPE_OBJ;
39 if (!isset($ARTIFACTTYPE_OBJ["_".$artType_id."_"])) {
41 //the db result handle was passed in
43 $res = db_query_params ('SELECT * FROM artifact_group_list_vw WHERE group_artifact_id=$1',
44 array ($artType_id)) ;
46 if (!$res || db_numrows($res) < 1 ){
47 $ARTIFACTTYPE_OBJ["_".$artType_id."_"]=false;
49 $data =& db_fetch_array($res);
50 $Group =& group_get_object($data["group_id"]);
51 $ARTIFACTTYPE_OBJ["_".$artType_id."_"]= new ArtifactType($Group,$data["group_artifact_id"],$data);
54 return $ARTIFACTTYPE_OBJ["_".$artType_id."_"];
57 function artifacttype_get_groupid ($artifact_type_id) {
58 global $ARTIFACTTYPE_OBJ;
59 if (isset($ARTIFACTTYPE_OBJ["_".$artifact_type_id."_"])) {
60 return $ARTIFACTTYPE_OBJ["_".$artifact_type_id."_"]->Group->getID() ;
63 $res = db_query_params ('SELECT group_id FROM artifact_group_list WHERE group_artifact_id=$1',
64 array ($artifact_type_id)) ;
65 if (!$res || db_numrows($res) < 1) {
68 $arr =& db_fetch_array ($res);
69 return $arr['group_id'] ;
72 class ArtifactType extends Error {
79 var $Group; //group object
82 * extra_fields 3d array - the IDs and Names of the extra fields
84 * @var array extra_fields;
86 var $extra_fields = array();
89 * extra_field[extra_field_id] array - the IDs and Names of elements on the extra fields
91 * @var array extra_field
96 * Technicians db resource ID.
98 * @var int $technicians_res.
100 var $technicians_res;
103 * Status db resource ID.
105 * @var int $status_res.
110 * Canned responses resource ID.
112 * @var int $cannecresponses_res.
114 var $cannedresponses_res;
117 * Array of artifact data.
119 * @var array $data_array.
124 * Array of element names so they only have to be fetched once from db.
126 * @var array $data_array.
131 * Array of element status so they only have to be fetched once from db.
133 * @var array $data_array.
138 * ArtifactType - constructor.
140 * @param object The Group object.
141 * @param int The id # assigned to this artifact type in the db.
142 * @param array The associative array of data.
143 * @return boolean success.
145 function ArtifactType(&$Group,$artifact_type_id=false, $arr=false) {
147 if (!$Group || !is_object($Group)) {
148 $this->setError('No Valid Group Object');
151 if ($Group->isError()) {
152 $this->setError('ArtifactType: '.$Group->getErrorMessage());
155 $this->Group =& $Group;
156 if ($artifact_type_id) {
157 if (!$arr || !is_array($arr)) {
158 if (!$this->fetchData($artifact_type_id)) {
162 $this->data_array =& $arr;
163 if ($this->data_array['group_id'] != $this->Group->getID()) {
164 $this->setError('Group_id in db result does not match Group Object');
165 $this->data_array = null;
170 // Make sure they can even access this object
172 if (!forge_check_perm ('tracker', $this->getID(), 'read')) {
173 $this->setPermissionDeniedError();
174 $this->data_array = null;
181 * create - use this to create a new ArtifactType in the database.
183 * @param string The type name.
184 * @param string The type description.
185 * @param bool (1) true (0) false - viewable by general public.
186 * @param bool (1) true (0) false - whether non-logged-in users can submit.
187 * @param bool (1) true (0) false - whether to email on all updates.
188 * @param string The address to send new entries and updates to.
189 * @param int Days before this item is considered overdue.
190 * @param bool (1) trye (0) false - whether the resolution box should be shown.
191 * @param string Free-form string that project admins can place on the submit page.
192 * @param string Free-form string that project admins can place on the browse page.
193 * @param int (1) bug tracker, (2) Support Tracker, (3) Patch Tracker, (4) features (0) other.
194 * @return id on success, false on failure.
196 function create($name,$description,$is_public,$allow_anon,$email_all,$email_address,
197 $due_period,$use_resolution,$submit_instructions,$browse_instructions,$datatype=0) {
199 if (!forge_check_perm('tracker_admin', $this->Group->getID())) {
200 $this->setPermissionDeniedError();
204 if (!$name || !$description || !$due_period) {
205 $this->setError(_('ArtifactType: Name, Description, Due Period, and Status Timeout are required'));
209 if ($email_address) {
210 $invalid_emails = validate_emails($email_address);
211 if (count($invalid_emails) > 0) {
212 $this->SetError(_('E-mail address(es) appeared invalid').': '.implode(',',$invalid_emails));
217 $use_resolution = ((!$use_resolution) ? 0 : $use_resolution);
218 $is_public = ((!$is_public) ? 0 : $is_public);
219 $allow_anon = ((!$allow_anon) ? 0 : $allow_anon);
220 $email_all = ((!$email_all) ? 0 : $email_all);
224 $res = db_query_params ('INSERT INTO
239 ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12)',
240 array ($this->Group->getID(),
241 htmlspecialchars($name),
242 htmlspecialchars($description),
247 $due_period*(60*60*24),
249 htmlspecialchars($submit_instructions),
250 htmlspecialchars($browse_instructions),
253 $id = db_insertid($res,'artifact_group_list','group_artifact_id');
256 $this->setError('ArtifactType: '.db_error());
260 if (!$this->fetchData($id)) {
265 $this->Group->normalizeAllRoles () ;
272 * fetchData - re-fetch the data for this ArtifactType from the database.
274 * @param int The artifact type ID.
275 * @return boolean success.
277 function fetchData($artifact_type_id) {
278 $res = db_query_params ('SELECT * FROM artifact_group_list_vw
279 WHERE group_artifact_id=$1
281 array ($artifact_type_id,
282 $this->Group->getID())) ;
283 if (!$res || db_numrows($res) < 1) {
284 $this->setError('ArtifactType: Invalid ArtifactTypeID');
287 $this->data_array =& db_fetch_array($res);
288 db_free_result($res);
293 * getGroup - get the Group object this ArtifactType is associated with.
295 * @return Object The Group object.
297 function &getGroup() {
302 * getID - get this ArtifactTypeID.
304 * @return int The group_artifact_id #.
307 return $this->data_array['group_artifact_id'];
311 * getOpenCount - get the count of open tracker items in this tracker type.
313 * @return int The count.
315 function getOpenCount() {
316 return $this->data_array['open_count'];
320 * getTotalCount - get the total number of tracker items in this tracker type.
322 * @return int The total count.
324 function getTotalCount() {
325 return $this->data_array['count'];
329 * allowsAnon - determine if non-logged-in users can post.
331 * @return boolean allow_anonymous_submissions.
333 function allowsAnon() {
334 return $this->data_array['allow_anon'];
338 * getSubmitInstructions - get the free-form string strings.
340 * @return string instructions.
342 function getSubmitInstructions() {
343 return $this->data_array['submit_instructions'];
347 * getBrowseInstructions - get the free-form string strings.
349 * @return string instructions.
351 function getBrowseInstructions() {
352 return $this->data_array['browse_instructions'];
356 * emailAll - determine if we're supposed to email on every event.
358 * @return boolean email_all.
360 function emailAll() {
361 return $this->data_array['email_all_updates'];
365 * emailAddress - defined email address to send events to.
367 * @return string email.
369 function getEmailAddress() {
370 return $this->data_array['email_address'];
374 * isPublic - whether non-group-members can view.
376 * @return boolean is_public.
378 function isPublic() {
379 return $this->data_array['is_public'];
383 * getName - the name of this ArtifactType.
385 * @return string name.
388 return $this->data_array['name'];
392 * getFormattedName - formatted name of this ArtifactType
394 * @return string formatted name
396 function getFormattedName() {
397 $name = preg_replace('/[^[:alnum:]]/','',$this->getName());
398 $name = strtolower($name);
403 * getUnixName - returns the name used by email gateway
405 * @return string unix name
407 function getUnixName() {
408 return strtolower($this->Group->getUnixName()).'-'.$this->getFormattedName();
412 * getReturnEmailAddress() - return the return email address for notification emails
414 * @return string return email address
416 function getReturnEmailAddress() {
419 if(forge_get_config('use_gateways')) {
420 $address .= strtolower($this->getUnixName());
422 $address .= 'noreply';
424 $address .= '@'.forge_get_config('web_host');
429 * getDescription - the description of this ArtifactType.
431 * @return string description.
433 function getDescription() {
434 return $this->data_array['description'];
438 * getDuePeriod - how many seconds until it's considered overdue.
440 * @return int seconds.
442 function getDuePeriod() {
443 return $this->data_array['due_period'];
447 * getStatusTimeout - how many seconds until an item is stale.
449 * @return int seconds.
451 function getStatusTimeout() {
452 return $this->data_array['status_timeout'];
456 * getCustomStatusField - return the extra_field_id of the field containing the custom status.
458 * @return int extra_field_id.
460 function getCustomStatusField() {
461 return $this->data_array['custom_status_field'];
465 * setCustomStatusField - set the extra_field_id of the field containing the custom status.
466 * @param int The extra field id.
467 * @return boolean success.
469 function setCustomStatusField($extra_field_id) {
470 $res = db_query_params ('UPDATE artifact_group_list SET custom_status_field=$1
471 WHERE group_artifact_id=$2',
472 array ($extra_field_id,
478 * usesCustomStatuses - boolean
480 * @return boolean use_custom_statues.
482 function usesCustomStatuses() {
483 return $this->getCustomStatusField();
487 * remap status - pass the extra_fields array and return the status_id, either open/closed
488 * @param int The status_id
489 * @param array Complex array of extra_field_data
490 * @return int status_id.
492 function remapStatus($status_id,$extra_fields) {
493 if ($this->usesCustomStatuses()) {
494 //get the selected element for the extra_field_status element
495 $csfield = $this->getCustomStatusField();
496 if (array_key_exists($csfield, $extra_fields)) {
497 $element_id=$extra_fields[$csfield];
499 //convert that element_id into the status_id
500 $res = db_query_params ('SELECT status_id FROM artifact_extra_field_elements WHERE element_id=$1',
501 array ($element_id)) ;
503 $this->setError('Error Remapping Status: '.db_error());
506 $status_id=db_result($res,0,'status_id');
508 // custom status was not passed... use the first status from the database
509 $res = db_query_params ('SELECT status_id FROM artifact_extra_field_elements WHERE extra_field_id=$1 ORDER BY element_id ASC LIMIT 1 OFFSET 0',
511 if (db_numrows($res) == 0) { // No values available
512 $this->setError('Error Remapping Status');
515 $status_id=db_result($res,0,'status_id');
518 if ($status_id < 1 || $status_id > 4) {
519 echo "INVALID STATUS REMAP: $status_id FROM SELECTED ELEMENT: $element_id";
529 * getDataType - flag that is generally unused but can mark the difference between bugs, patches, etc.
531 * @return int The type (1) bug (2) support (3) patch (4) feature (0) other.
533 function getDataType() {
534 return $this->data_array['datatype'];
538 * setMonitor - user can monitor this artifact.
540 * @return false - always false - always use the getErrorMessage() for feedback
542 function setMonitor ($user_id = -1) {
543 if ($user_id == -1) {
544 if (!session_loggedin()) {
545 $this->setError(_('You can only monitor if you are logged in'));
548 $user_id = user_getid() ;
551 $res = db_query_params ('SELECT * FROM artifact_type_monitor WHERE group_artifact_id=$1 AND user_id=$2',
552 array ($this->getID(),
554 if (!$res || db_numrows($res) < 1) {
556 $res = db_query_params ('INSERT INTO artifact_type_monitor (group_artifact_id,user_id) VALUES ($1,$2)',
557 array ($this->getID(),
560 $this->setError(db_error());
563 $this->setError(_('Now Monitoring Tracker'));
567 //already monitoring - remove their monitor
568 db_query_params ('DELETE FROM artifact_type_monitor
569 WHERE group_artifact_id=$1
571 array ($this->getID(),
573 $this->setError(_('Tracker Monitoring Deactivated'));
578 function isMonitoring() {
579 if (!session_loggedin()) {
582 $result = db_query_params ('SELECT count(*) AS count FROM artifact_type_monitor
583 WHERE user_id=$1 AND group_artifact_id=$2',
586 $row_count = db_fetch_array($result);
587 return $result && $row_count['count'] > 0;
591 * getMonitorIds - array of email addresses monitoring this Artifact.
593 * @return array of email addresses monitoring this Artifact.
595 function &getMonitorIds() {
596 $res = db_query_params ('SELECT user_id FROM artifact_type_monitor WHERE group_artifact_id=$1',
597 array ($this->getID())) ;
598 return util_result_column_to_array($res);
602 * getExtraFields - List of possible user built extra fields
603 * set up for this artifact type.
605 * @return arrays of data;
607 function getExtraFields($filter='') {
608 if (!isset($this->extra_fields["$filter"])) {
609 $this->extra_fields["$filter"] = array();
611 $res = db_query_params ('SELECT *
612 FROM artifact_extra_field_list
613 WHERE group_artifact_id=$1
614 AND field_type = ANY ($2)
615 ORDER BY field_type ASC',
616 array ($this->getID(),
617 db_int_array_to_any_clause (explode (',', $filter)))) ;
619 $res = db_query_params ('SELECT *
620 FROM artifact_extra_field_list
621 WHERE group_artifact_id=$1
622 ORDER BY field_type ASC',
623 array ($this->getID())) ;
625 while($arr = db_fetch_array($res)) {
626 $this->extra_fields["$filter"][$arr['extra_field_id']] = $arr;
630 return $this->extra_fields["$filter"];
634 * cloneFieldsFrom - clone all the fields and elements from another tracker
636 * @return boolean true/false on success
638 function cloneFieldsFrom($clone_tracker_id) {
640 $g =& group_get_object(forge_get_config('template_group'));
641 if (!$g || !is_object($g)) {
642 $this->setError('Could Not Get Template Group');
644 } elseif ($g->isError()) {
645 $this->setError('Template Group Error '.$g->getErrorMessage());
648 $at =& new ArtifactType($g,$clone_tracker_id);
649 if (!$at || !is_object($at)) {
650 $this->setError('Could Not Get Tracker To Clone');
652 } elseif ($at->isError()) {
653 $this->setError('Clone Tracker Error '.$at->getErrorMessage());
656 $efs =& $at->getExtraFields();
660 // Iterate list of extra fields
663 foreach ($efs as $ef) {
664 //new field in this tracker
665 $nef = new ArtifactExtraField($this);
666 if (!$nef->create( addslashes(util_unconvert_htmlspecialchars($ef['field_name'])), $ef['field_type'], $ef['attribute1'], $ef['attribute2'], $ef['is_required'], $ef['alias'])) {
668 $this->setError('Error Creating New Extra Field: '.$nef->getErrorMessage());
672 // Iterate the elements
674 $resel = db_query_params ('SELECT * FROM artifact_extra_field_elements WHERE extra_field_id=$1',
675 array ($ef['extra_field_id'])) ;
676 while ($el =& db_fetch_array($resel)) {
678 $nel = new ArtifactExtraFieldElement($nef);
679 if (!$nel->create( addslashes(util_unconvert_htmlspecialchars($el['element_name'])), $el['status_id'] )) {
681 $this->setError('Error Creating New Extra Field Element: '.$nel->getErrorMessage());
692 * getExtraFieldName - Get a box name using the box ID
694 * @param int id of an extra field.
695 * @return string name of extra field.
697 function getExtraFieldName($extra_field_id) {
698 $arr = $this->getExtraFields();
699 return $arr[$extra_field_id]['field_name'];
703 * getExtraFieldElements - List of possible admin configured
704 * extra field elements. This function is used to
705 * present the boxes and choices on the main Add/Update page.
707 * @param int id of the extra field
708 * @return array of elements for this extra field.
710 function getExtraFieldElements($id) {
715 if (!isset($this->extra_field[$id])) {
716 $this->extra_field[$id] = array();
717 $res = db_query_params ('SELECT element_id,element_name,status_id
718 FROM artifact_extra_field_elements
719 WHERE extra_field_id = $1
720 ORDER BY element_pos ASC, element_id ASC',
723 while($arr =& db_fetch_array($res)) {
724 $this->extra_field[$id][$i++] = $arr;
726 // if (count($this->extra_field[$id]) == 0) {
731 return $this->extra_field[$id];
735 * getElementName - get the name of a particular element.
737 * @return string The name.
739 function getElementName($choiceid) {
743 if (is_array($choiceid)) {
744 $choiceid=implode(',', array_map('intval', $choiceid));
746 $choiceid=intval($choiceid);
748 if ($choiceid == 100) {
751 if (!isset($this->element_name["$choiceid"])) {
752 $res = db_query_params ('SELECT element_id,extra_field_id,element_name
753 FROM artifact_extra_field_elements
754 WHERE element_id = ANY ($1)',
755 array (db_int_array_to_any_clause (explode (',', $choiceid)))) ;
756 if (db_numrows($res) > 1) {
757 $arr=util_result_column_to_array($res,2);
758 $this->element_name["$choiceid"]=implode(',',$arr);
760 $this->element_name["$choiceid"]=db_result($res,0,'element_name');
763 return $this->element_name["$choiceid"];
767 * getElementStatusID - get the status of a particular element.
769 * @return int The status
771 function getElementStatusID($choiceid) {
775 if (is_array($choiceid)) {
776 $choiceid=implode(',',$choiceid);
778 if ($choiceid == 100) {
781 if (!$this->element_status["$choiceid"]) {
782 $res = db_query_params ('SELECT element_id,extra_field_id,status_id
783 FROM artifact_extra_field_elements
784 WHERE element_id = ANY ($1)',
785 array (db_int_array_to_any_clause (explode (',', $choiceid)))) ;
786 if (db_numrows($res) > 1) {
787 $arr=util_result_column_to_array($res,2);
788 $this->element_status["$choiceid"]=implode(',',$arr);
790 $this->element_status["$choiceid"]=db_result($res,0,'status_id');
793 return $this->element_status["$choiceid"];
798 * delete - delete this tracker and all its related data.
800 * @param bool I'm Sure.
801 * @param bool I'm REALLY sure.
802 * @return bool true/false;
804 function delete($sure, $really_sure) {
805 if (!$sure || !$really_sure) {
806 $this->setMissingParamsError();
809 if (!forge_check_perm ('tracker_admin', $this->Group->getID())) {
810 $this->setPermissionDeniedError();
814 db_query_params ('DELETE FROM artifact_extra_field_data
815 WHERE EXISTS (SELECT artifact_id FROM artifact
816 WHERE group_artifact_id=$1
817 AND artifact.artifact_id=artifact_extra_field_data.artifact_id)',
818 array ($this->getID())) ;
819 //echo '0.1'.db_error();
820 db_query_params ('DELETE FROM artifact_extra_field_elements
821 WHERE EXISTS (SELECT extra_field_id FROM artifact_extra_field_list
822 WHERE group_artifact_id=$1
823 AND artifact_extra_field_list.extra_field_id = artifact_extra_field_elements.extra_field_id)',
824 array ($this->getID())) ;
825 //echo '0.2'.db_error();
826 db_query_params ('DELETE FROM artifact_extra_field_list
827 WHERE group_artifact_id=$1',
828 array ($this->getID())) ;
829 //echo '0.3'.db_error();
830 db_query_params ('DELETE FROM artifact_canned_responses
831 WHERE group_artifact_id=$1',
832 array ($this->getID())) ;
833 //echo '1'.db_error();
834 db_query_params ('DELETE FROM artifact_counts_agg
835 WHERE group_artifact_id=$1',
836 array ($this->getID())) ;
837 //echo '5'.db_error();
838 db_query_params ('DELETE FROM artifact_file
839 WHERE EXISTS (SELECT artifact_id FROM artifact
840 WHERE group_artifact_id=$1
841 AND artifact.artifact_id=artifact_file.artifact_id)',
842 array ($this->getID())) ;
843 //echo '6'.db_error();
844 db_query_params ('DELETE FROM artifact_message
845 WHERE EXISTS (SELECT artifact_id FROM artifact
846 WHERE group_artifact_id=$1
847 AND artifact.artifact_id=artifact_message.artifact_id)',
848 array ($this->getID())) ;
849 //echo '7'.db_error();
850 db_query_params ('DELETE FROM artifact_history
851 WHERE EXISTS (SELECT artifact_id FROM artifact
852 WHERE group_artifact_id=$1
853 AND artifact.artifact_id=artifact_history.artifact_id)',
854 array ($this->getID())) ;
855 //echo '8'.db_error();
856 db_query_params ('DELETE FROM artifact_monitor
857 WHERE EXISTS (SELECT artifact_id FROM artifact
858 WHERE group_artifact_id=$1
859 AND artifact.artifact_id=artifact_monitor.artifact_id)',
860 array ($this->getID())) ;
861 //echo '9'.db_error();
862 db_query_params ('DELETE FROM artifact
863 WHERE group_artifact_id=$1',
864 array ($this->getID())) ;
865 //echo '4'.db_error();
866 db_query_params ('DELETE FROM artifact_group_list
867 WHERE group_artifact_id=$1',
868 array ($this->getID())) ;
869 //echo '11'.db_error();
873 $this->Group->normalizeAllRoles () ;
879 * getCannedResponses - returns a result set of canned responses.
881 * @return database result set.
883 function getCannedResponses() {
884 if (!isset($this->cannedresponses_res)) {
885 $this->cannedresponses_res = db_query_params ('SELECT id,title
886 FROM artifact_canned_responses
887 WHERE group_artifact_id=$1',
888 array ($this->getID()));
890 return $this->cannedresponses_res;
894 * getStatuses - returns a result set of statuses.
896 * These statuses are either the default open/closed or any number of
897 * custom statuses that are stored in the extra fields. On insert/update
898 * to an artifact the status_id is remapped from the extra_field_element_id to
899 * the standard open/closed id.
901 * @param boolean Whether to show the real statuses or not.
902 * @return database result set.
904 function getStatuses() {
905 if (!isset($this->status_res)) {
906 $this->status_res = db_query_params ('SELECT * FROM artifact_status',array());
908 return $this->status_res;
912 * getStatusName - returns the name of this status.
914 * @param int The status ID.
915 * @return string name.
917 function getStatusName($id) {
918 $result = db_query_params ('select status_name from artifact_status WHERE id=$1',
920 if ($result && db_numrows($result) > 0) {
921 return db_result($result,0,'status_name');
923 return 'Error - Not Found';
928 * update - use this to update this ArtifactType in the database.
930 * @param string The item name.
931 * @param string The item description.
932 * @param bool (1) true (0) false - whether to email on all updates.
933 * @param string The address to send new entries and updates to.
934 * @param int Days before this item is considered overdue.
935 * @param int Days before stale items time out.
936 * @param bool (1) true (0) false - whether the resolution box should be shown.
937 * @param string Free-form string that project admins can place on the submit page.
938 * @param string Free-form string that project admins can place on the browse page.
939 * @return true on success, false on failure.
941 function update($name,$description,$email_all,$email_address,
942 $due_period, $status_timeout,$use_resolution,$submit_instructions,$browse_instructions) {
944 if (!forge_check_perm ('tracker_admin', $this->Group->getID())) {
945 $this->setPermissionDeniedError();
949 if ($this->getDataType()) {
950 $name=$this->getName();
951 $description=$this->getDescription();
954 if (!$name || !$description || !$due_period || !$status_timeout) {
955 $this->setError(_('ArtifactType: Name, Description, Due Period, and Status Timeout are required'));
959 if ($email_address) {
960 $invalid_emails = validate_emails($email_address);
961 if (count($invalid_emails) > 0) {
962 $this->SetError(_('E-mail address(es) appeared invalid').': '.implode(',',$invalid_emails));
967 $email_all = ((!$email_all) ? 0 : $email_all);
968 $use_resolution = ((!$use_resolution) ? 0 : $use_resolution);
970 $res = db_query_params ('UPDATE artifact_group_list SET
973 email_all_updates=$3,
977 submit_instructions=$7,
978 browse_instructions=$8
979 WHERE group_artifact_id=$9 AND group_id=$10',
981 htmlspecialchars($name),
982 htmlspecialchars($description),
985 $due_period * (60*60*24),
986 $status_timeout * (60*60*24),
987 htmlspecialchars($submit_instructions),
988 htmlspecialchars($browse_instructions),
990 $this->Group->getID())) ;
992 if (!$res || db_affected_rows($res) < 1) {
993 $this->setError('ArtifactType::Update(): '.db_error());
996 $this->fetchData($this->getID());
1002 * getBrowseList - get the free-form string strings.
1004 * @return string instructions.
1006 function getBrowseList() {
1007 $list = $this->data_array['browse_list'];
1009 // remove status_id in the browse list if a custom status exists
1010 if (count($this->getExtraFields(ARTIFACT_EXTRAFIELDTYPE_STATUS)) > 0) {
1011 $arr = explode(',', $list);
1012 $idx = array_search('status_id', $arr);
1013 if($idx !== False) {
1014 array_splice($arr, $idx, 1);
1016 return join(',', $arr);
1023 * setCustomStatusField - set the extra_field_id of the field containing the custom status.
1024 * @param int The extra field id.
1025 * @return boolean success.
1027 function setBrowseList($list) {
1028 $res=db_query_params ('UPDATE artifact_group_list
1030 WHERE group_artifact_id=$2',
1033 $this->fetchData($this->getID());
1041 // c-file-style: "bsd"