gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/common/tracker ArtifactHistory.class, NONE, 1.1


From: tperdue
Subject: [Gforge-commits] gforge/common/tracker ArtifactHistory.class, NONE, 1.1 ArtifactMessage.class, NONE, 1.1 Artifact.class, 1.14, 1.15 ArtifactFactory.class, 1.4, 1.5 ArtifactType.class, 1.20, 1.21 ArtifactTypeFactory.class, 1.5, 1.6
Date: Sat, 28 Feb 2004 08:11:56 -0600

Update of /cvsroot/gforge/gforge/common/tracker
In directory db.perdue.net:/home/tperdue/share/dev.gforge.org/common/tracker

Modified Files:
        Artifact.class ArtifactFactory.class ArtifactType.class 
        ArtifactTypeFactory.class 
Added Files:
        ArtifactHistory.class ArtifactMessage.class 
Log Message:
Laying some groundwork for SOAP

--- NEW FILE: ArtifactHistory.class ---
<?php
/**
 * ArtifactHistory.class - Class to handle artifact categories
 *
 * Copyright 2004 (c) GForge, LLC
 *
 * @version   $Id: ArtifactHistory.class,v 1.1 2004/02/28 14:11:52 tperdue Exp $
 *
 * 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.
 *
 * 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  US
 */
require_once('common/include/Error.class');

class ArtifactHistory extends Error {

        /** 
         * The artifact object.
         *
         * @var         object  $Artifact.
         */
        var $Artifact; //object

        /**
         * Array of artifact data.
         *
         * @var         array   $data_array.
         */
        var $data_array;

        /**
         *  ArtifactHistory - constructor.
         *
         *      @param  object  Artifact object.
         *  @param      array   (all fields from artifact_history_user_vw) OR 
id from database.
         *  @return     boolean success.
         */
        function ArtifactHistory(&$Artifact, $data=false) {
                $this->Error(); 

                //was Artifact legit?
                if (!$Artifact || !is_object($Artifact)) {
                        $this->setError('ArtifactHistory: No Valid Artifact');
                        return false;
                }
                //did Artifact have an error?
                if ($Artifact->isError()) {
                        $this->setError('ArtifactHistory: 
'.$Artifact->getErrorMessage());
                        return false;
                }
                $this->Artifact =& $Artifact;

                if ($data) {
                        if (is_array($data)) {
                                $this->data_array =& $data;
                                return true;
                        } else {
                                if (!$this->fetchData($data)) {
                                        return false;
                                } else {
                                        return true;
                                }
                        }
                }
        }

        /**
         *      create - create a new item in the database.
         *
         *      @param  string  Item name.
         *      @param  int             User_id of assignee.
         *  @return id on success / false on failure.
         * /
        function create($name, $auto_assign_to) {
                global $Language;
                
                //
                //      data validation
                //
                if (!$name || !$auto_assign_to) {
                        
$this->setError($Language->getText('artifact_category','required_fields'));
                        return false;
                }
                if (!$this->Artifact->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }
                $sql="INSERT INTO artifact_category 
(group_artifact_id,category_name,auto_assign_to) 
                        VALUES 
('".$this->Artifact->getID()."','".htmlspecialchars($name)."','$auto_assign_to')";

                $result=db_query($sql);

                if ($result && db_affected_rows($result) > 0) {
                        $this->clearError();
                        return true;
                } else {
                        $this->setError(db_error());
                        return false;
                }

/*
                        //
                        //      Now set up our internal data structures
                        //
                        if (!$this->fetchData($id)) {
                                return false;
                        }
*/
        }

        /**
         *      fetchData - re-fetch the data for this ArtifactHistory from the 
database.
         *
         *      @param  int             ID of the category.
         *      @return boolean success.
         */
        function fetchData($id) {
                $res=db_query("SELECT * FROM artifact_category WHERE id='$id'");
                if (!$res || db_numrows($res) < 1) {
                        $this->setError('ArtifactHistory: Invalid 
ArtifactHistory ID');
                        return false;
                }
                $this->data_array =& db_fetch_array($res);
                db_free_result($res);
                return true;
        }

        /**
         *      getArtifact - get the Artifact Object this ArtifactHistory is 
associated with.
         *
         *      @return object  Artifact.
         */
        function &getArtifact() {
                return $this->Artifact;
        }
        
        /**
         *      getID - get this ArtifactHistory's ID.
         *
         *      @return int     The id #.
         */
        function getID() {
                return $this->data_array['id'];
        }

        /**
         *      getName - get the name.
         *
         *      @return string  The name.
         * /
        function getName() {
                return $this->data_array['category_name'];
        }

        /**
         *      getAssignee - get the user_id of the person to assign this 
category to.
         *
         *      @return int user_id.
         * /
        function getAssignee() {
                return $this->data_array['auto_assign_to'];
        }

}

?>

--- NEW FILE: ArtifactMessage.class ---
<?php
/**
 * ArtifactMessage.class - Class to handle artifact messages.
 *
 * Copyright 2004 (c) GForge, LLC
 *
 * @version   $Id: ArtifactMessage.class,v 1.1 2004/02/28 14:11:52 tperdue Exp $
 *
 * 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.
 *
 * 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  US
 */
require_once('common/include/Error.class');

class ArtifactMessage extends Error {

        /** 
         * The artifact object.
         *
         * @var         object  $Artifact.
         */
        var $Artifact; //object

        /**
         * Array of artifact data.
         *
         * @var         array   $data_array.
         */
        var $data_array;

        /**
         *  ArtifactMessage - constructor.
         *
         *      @param  object  Artifact object.
         *  @param      array   (all fields from artifact_history_user_vw) OR 
id from database.
         *  @return     boolean success.
         */
        function ArtifactMessage(&$Artifact, $data=false) {
                $this->Error(); 

                //was Artifact legit?
                if (!$Artifact || !is_object($Artifact)) {
                        $this->setError('ArtifactMessage: No Valid Artifact');
                        return false;
                }
                //did Artifact have an error?
                if ($Artifact->isError()) {
                        $this->setError('ArtifactMessage: 
'.$Artifact->getErrorMessage());
                        return false;
                }
                $this->Artifact =& $Artifact;

                if ($data) {
                        if (is_array($data)) {
                                $this->data_array =& $data;
                                return true;
                        } else {
                                if (!$this->fetchData($data)) {
                                        return false;
                                } else {
                                        return true;
                                }
                        }
                }
        }

        /**
         *      create - create a new item in the database.
         *
         *      @param  string  Item name.
         *      @param  int             User_id of assignee.
         *  @return id on success / false on failure.
         * /
        function create($name, $auto_assign_to) {
                global $Language;
                
                //
                //      data validation
                //
                if (!$name || !$auto_assign_to) {
                        
$this->setError($Language->getText('artifact_category','required_fields'));
                        return false;
                }
                if (!$this->Artifact->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }
                $sql="INSERT INTO artifact_category 
(group_artifact_id,category_name,auto_assign_to) 
                        VALUES 
('".$this->Artifact->getID()."','".htmlspecialchars($name)."','$auto_assign_to')";

                $result=db_query($sql);

                if ($result && db_affected_rows($result) > 0) {
                        $this->clearError();
                        return true;
                } else {
                        $this->setError(db_error());
                        return false;
                }

/*
                        //
                        //      Now set up our internal data structures
                        //
                        if (!$this->fetchData($id)) {
                                return false;
                        }
*/
        }

        /**
         *      fetchData - re-fetch the data for this ArtifactMessage from the 
database.
         *
         *      @param  int             ID of the category.
         *      @return boolean success.
         */
        function fetchData($id) {
                $res=db_query("SELECT * FROM artifact_message_user_vw WHERE 
id='$id'");
                if (!$res || db_numrows($res) < 1) {
                        $this->setError('ArtifactMessage: Invalid 
ArtifactMessage ID');
                        return false;
                }
                $this->data_array =& db_fetch_array($res);
                db_free_result($res);
                return true;
        }

        /**
         *      getArtifact - get the Artifact Object this ArtifactMessage is 
associated with.
         *
         *      @return object  Artifact.
         */
        function &getArtifact() {
                return $this->Artifact;
        }
        
        /**
         *      getID - get this ArtifactMessage's ID.
         *
         *      @return int     The id #.
         */
        function getID() {
                return $this->data_array['id'];
        }

        /**
         *      getBody - get the message body.
         *
         *      @return string  The message body.
         */
        function getBody() {
                return $this->data_array['body'];
        }

        /**
         *      getAddDate - get the date this message was added.
         *
         *      @return int adddate.
         */
        function getAddDate() {
                return $this->data_array['addate'];
        }

        /**
         *      getUserID - get the ID of the person who posted this.
         *
         *      @return int user_id.
         */
        function getUserID() {
                return $this->data_array['user_id'];
        }

//TODO email
//user_name
//realname

}

?>

Index: Artifact.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/Artifact.class,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Artifact.class      18 Feb 2004 09:18:23 -0000      1.14
+++ Artifact.class      28 Feb 2004 14:11:52 -0000      1.15
@@ -23,6 +23,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
  */
 require_once('common/include/Error.class');
+require_once('common/tracker/ArtifactMessage.class');
 
        /**
        * Factory method which creates an Artifact from an artifact ID
@@ -599,6 +600,18 @@
        }
 
        /**
+        *      getMessageObjects - get an array of message objects.
+        *
+        *      @return array Of ArtifactMessage objects.
+        */
+       function &getMessageObjects() {
+               $res=$this->getMessages();
+               while ($arr =& db_fetch_array($res)) {
+                       $return[]=new ArtifactMessage($arr['artifact_id'],$arr);
+               }
+       }
+
+       /**
         *      getFiles - get array of ArtifactFile's.
         *
         *      @return array of ArtifactFile's.

Index: ArtifactFactory.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/ArtifactFactory.class,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ArtifactFactory.class       16 Dec 2003 20:05:01 -0000      1.4
+++ ArtifactFactory.class       28 Feb 2004 14:11:52 -0000      1.5
@@ -71,7 +71,7 @@
                        return false;
                }
                $this->ArtifactType =& $ArtifactType;
-                $this->changed_from = 0x7ffffff; // Any
+               $this->changed_from = 0x7ffffff; // Any
 
                return true;
        }

Index: ArtifactType.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/ArtifactType.class,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ArtifactType.class  26 Feb 2004 22:00:18 -0000      1.20
+++ ArtifactType.class  28 Feb 2004 14:11:52 -0000      1.21
@@ -426,7 +426,7 @@
         */
        function getCategories() {
                if (!isset($this->categories_res)) {
-                       $sql="select id,category_name 
+                       $sql="select id,category_name,auto_assign_to
                                FROM artifact_category 
                                WHERE group_artifact_id='". $this->getID() ."'
                                ORDER BY category_name";
@@ -436,6 +436,19 @@
        }
 
        /**
+        *      getCategoryObjects - Array of ArtifactCategory objects set up 
for this artifact type.
+        *
+        *      @return array   Of ArtifactCategory objects.
+        */
+       function &getCategoryObjects() {
+               $res = $this->getCategories();
+               while ($arr =& db_fetch_array($res)) {
+                       $cats[] =& new ArtifactCategory(&$this,$arr);
+               }
+               return $cats[];
+       }
+
+       /**
         *      getGroups - List of possible groups set up for this artifact 
type.
         *
         *      @return database result set.
@@ -451,6 +464,19 @@
        }
 
        /**
+        *      getGroupObjects - Array of ArtifactGroup objects set up for 
this artifact type.
+        *
+        *      @return array   Of ArtifactGroup objects.
+        */
+       function &getGroupObjects() {
+               $res = $this->getGroups();
+               while ($arr =& db_fetch_array($res)) {
+                       $grps[] =& new ArtifactGroup(&$this,$arr);
+               }
+               return $grps[];
+       }
+
+       /**
         *      getResolutions - List of possible resolutions.
         *
         *      @return database result set.
@@ -465,6 +491,19 @@
        }
 
        /**
+        *      getResolutionObjects - Array of ArtifactResolution objects set 
up for this artifact type.
+        *
+        *      @return array   Of ArtifactResolution objects.
+        */
+       function &getResolutionObjects() {
+               $res = $this->getResolutions();
+               while ($arr =& db_fetch_array($res)) {
+                       $grps[] =& new ArtifactResolutions(&$this,$arr);
+               }
+               return $grps[];
+       }
+
+       /**
         *      getTechnicians - returns a result set of technicians.
         *
         *      @return database result set.
@@ -482,6 +521,16 @@
        }
 
        /**
+        *      getTechnicianObjects - Array of User objects set up for this 
artifact type.
+        *
+        *      @return array   Of User objects.
+        */
+       function &getTechnicianObjects() {
+               $res = $this->getTechnicians();
+               $arr =& util_result_column_to_array($res,0);
+               return user_get_objects($arr);
+       }
+       /**
         *      getCannedResponses - returns a result set of canned responses.
         *
         *      @return database result set.

Index: ArtifactTypeFactory.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/ArtifactTypeFactory.class,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ArtifactTypeFactory.class   12 Feb 2003 17:23:47 -0000      1.5
+++ ArtifactTypeFactory.class   28 Feb 2004 14:11:52 -0000      1.6
@@ -59,11 +59,11 @@
        function ArtifactTypeFactory(&$Group) {
                $this->Error();
                if (!$Group || !is_object($Group)) {
-                       $this->setError('Forum:: No Valid Group Object');
+                       $this->setError('ArtifactTypeFactory:: No Valid Group 
Object');
                        return false;
                }
                if ($Group->isError()) {
-                       $this->setError('Forum:: '.$Group->getErrorMessage());
+                       $this->setError('ArtifactTypeFactory:: 
'.$Group->getErrorMessage());
                        return false;
                }
                $this->Group =& $Group;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]