gforge-commits
[Top][All Lists]
Advanced

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

[Gforge-commits] gforge/common/tracker Artifact.class, 1.18, 1.19 Artifa


From: tperdue
Subject: [Gforge-commits] gforge/common/tracker Artifact.class, 1.18, 1.19 ArtifactBoxOptions.class, NONE, 1.1 ArtifactSelectionBox.class, NONE, 1.1 ArtifactType.class, 1.22, 1.23
Date: Thu, 26 Aug 2004 10:32:10 -0500

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

Modified Files:
        Artifact.class ArtifactType.class 
Added Files:
        ArtifactBoxOptions.class ArtifactSelectionBox.class 
Log Message:
Unlimited Extra Fields for Tracker

Index: Artifact.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/Artifact.class,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Artifact.class      16 Apr 2004 09:38:49 -0000      1.18
+++ Artifact.class      26 Aug 2004 15:32:06 -0000      1.19
@@ -26,11 +26,11 @@
 require_once('common/tracker/ArtifactMessage.class');
 
        /**
-       * Factory method which creates an Artifact from an artifact ID
+       *       Factory method which creates an Artifact from an artifact ID
        *       
-       * @param artifact_id    the artifact ID
-       *       @param data     the DB handle, if it's passed in
-       *       @return an Artifact object
+       *       @param int      The artifact ID
+       *       @param array    The result array, if it's passed in
+       *       @return object  Artifact object
        */
        function &artifact_get_object($artifact_id,$data=false) {
                global $ARTIFACT_OBJ;
@@ -76,6 +76,13 @@
        var $data_array;
 
        /**
+        * Array of artifact data for extra fields defined by Admin.
+        *
+        * @var         array   $data_extra_field_array.
+        */
+       var $data_extra_field_array;
+
+       /**
         * Array of ArtifactFile objects.
         *
         * @var         array   $files
@@ -273,7 +280,30 @@
                        return $artifact_id;
                }
        }
+       /**
+        *
+        *      createExtraFields - extend an artifact with data input in 
selection boxes with choices defined by ADMIN for a project
+        *
+        */
+       function createExtraFields($choice_id){
+               $this->choice_id=$choice_id;
+               $res=db_query("INSERT INTO artifact_extra_field_data
+                       (artifact_id, choice_id)
+                       VALUES
+                       ('".$this->getID()."',$this->choice_id)");
+                                       
+               if (!$res) {
+                       $this->setError('Artifact: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+
+               return $choice_id;
+       
+       }
+       
 
+       
        /**
         *      fetchData - re-fetch the data for this Artifact from the 
database.
         *
@@ -356,6 +386,15 @@
        }
 
        /**
+        *      getExtraFieldID - get choice_id flag.
+        *
+        *      @return int choice_id.
+        */
+       function getExtraFieldID() {
+               return $this->data_extra_field_array['choice_id'];
+       }
+
+       /**
         *      getCategoryName - get category text name.
         *
         *      @return string  The category name.
@@ -910,8 +949,59 @@
                        db_rollback();
                        return false;
                }
+       
+       }
+
+       /**
+        *      updateExtraFields - update an artifact with data input in 
selection 
+        *      boxes with choices defined by ADMIN for a project.
+        *
+        */
+       function updateExtraFields($id,$choice_id){
+                       
+               $res=db_query("UPDATE artifact_extra_field_data
+                       SET
+                       choice_id='$choice_id'
+                       WHERE
+                       id='$id'");
+       
+                       
+               if (!$res) {
+                       $this->setError('Artifact: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+
+               return true;
        }
 
+       /**
+        *
+        *      nullExtraFields - 0 an artifact in selection boxes with choices 
defined 
+        *      by ADMIN for a project to normalize for a transfer to an new 
artifact type
+        *
+        */
+       function  nullExtraFields($artifact_id){
+                       
+               $res=db_query("UPDATE artifact_extra_field_data
+                       SET
+                       artifact_id='0'
+                       WHERE
+                       artifact_id='$artifact_id'");
+       
+                       
+               if (!$res) {
+                       $this->setError('Artifact: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+
+               return true;
+       }
+
+       
+
+
        // function which returns proper marker for changed properties
        function marker($prop_name,$changes) {
                if ($changes[$prop_name]) {

--- NEW FILE: ArtifactBoxOptions.class ---
<?php
/**
 * ArtifactSelectionBox.class - Class to handle user defined artifacts
 *
 * Copyright 2004 (c) Anthony J. Pugliese
 *
 * @version   $Id: ArtifactBoxOptions.class,v 1.1 2004/08/26 15:32:06 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 ArtifactBoxOptions extends Error {

        /** 
         * The artifact type object.
         *
         * @var         object  $ArtifactType.
         */
        var $ArtifactType; //object

        /**
         * Array of artifact data.
         *
         * @var         array   $data_array.
         */
        var $data_array;
        /**
         *      ArtifactSelectionBox - Constructer
         *
         *      @param  object  ArtifactType object.
         *  @param      array   (all fields from artifact_file_user_vw) OR id 
from database.
         *  @return     boolean success.
         */
        function ArtifactBoxOptions(&$ArtifactType,$data=false) {
                $this->Error(); 
                
                //was ArtifactType legit?
                if (!$ArtifactType || !is_object($ArtifactType)) {
                        $this->setError('ArtifactSelectionBox: No Valid 
ArtifactType');
                        return false;
                }
                //did ArtifactType have an error?
                if ($ArtifactType->isError()) {
                        $this->setError('ArtifactSelectionBox: 
'.$Artifact->getErrorMessage());
                        return false;
                }
                $this->ArtifactType =& $ArtifactType;
                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,$id) {
                global $Language;
//settype($id,"integer");       
                //
                //      data validation
                //
                if (!$name) {
                        
$this->setError($Language->getText('tracker_admin_build_boxes','required_choice_name'));
                        return false;
                }
                if (!$this->ArtifactType->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }
                $sql="INSERT INTO artifact_group_selection_box_options 
(artifact_box_id,box_options_name) 
                        VALUES ('$id','".htmlspecialchars($name)."')";

                $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 ArtifactBoxOptions from 
the database.
         *
         *      @param  int             ID of the Box.
         *      @return boolean success.
         */
        function fetchData($id) {
                $res=db_query("SELECT * FROM 
artifact_group_selection_box_options WHERE id='$id'");
                if (!$res || db_numrows($res) < 1) {
                        $this->setError('ArtifactSelectionBox: Invalid Artifact 
ID');
                        return false;
                }
                $this->data_array =& db_fetch_array($res);
                db_free_result($res);
                return true;
        }

        /**
         *      getArtifactType - get the ArtifactType Object this 
ArtifactSelectionBox is associated with.
         *
         *      @return object  ArtifactType.
         */
        function &getArtifactType() {
                return $this->ArtifactType;
        }
        
        /**
         *      getID - get this ArtifactSelectionBox 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['box_options_name'];
        }


        /**
         *              Update an ArtifactSelectionBox
         *
         *  @param      string  Name of the box.
         *  @return     boolean success.
         */
        function update($name,$boxid,$id) {
                if (!$this->ArtifactType->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }
                if (!$name) {
                        $this->setMissingParamsError();
                        return false;
                }   
                $sql="UPDATE artifact_group_selection_box_options 
                        SET box_options_name='".htmlspecialchars($name)."' 
                        WHERE id='$id'"; 
//                      AND artifact_box_id='$boxid'";
                $result=db_query($sql);
                if ($result && db_affected_rows($result) > 0) {
                        return true;
                } else {
                        $this->setError(db_error());
                        return false;
                }
        }
}

?>

--- NEW FILE: ArtifactSelectionBox.class ---
<?php
/**
 * ArtifactSelectionBox.class - Class to handle user defined artifacts
 *
 * Copyright 2004 (c) Anthony J. Pugliese
 *
 * @version   $Id: ArtifactSelectionBox.class,v 1.1 2004/08/26 15:32:06 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 ArtifactSelectionBox extends Error {

        /** 
         * The artifact type object.
         *
         * @var         object  $ArtifactType.
         */
        var $ArtifactType; //object

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

        /**
         *      ArtifactSelectionBox - Constructer
         *
         *      @param  object  ArtifactType object.
         *  @param      array   (all fields from artifact_file_user_vw) OR id 
from database.
         *  @return     boolean success.
         */
        function ArtifactSelectionBox(&$ArtifactType, $data=false) {
                $this->Error(); 

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

                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) {
                global $Language;
                
                //
                //      data validation
                //
                if (!$name) {
                        
$this->setError($Language->getText('tracker_admin_build_boxes','required_box_name'));
                        return false;
                }
                if (!$this->ArtifactType->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }
                $sql="INSERT INTO artifact_group_selection_box_list 
(group_artifact_id,selection_box_name) 
                        VALUES 
('".$this->ArtifactType->getID()."','".htmlspecialchars($name)."')";

                $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 ArtifactSelectionBox 
from the database.
         *
         *      @param  int             ID of the Box.
         *      @return boolean success.
         */
        function fetchData($id) {
                $res=db_query("SELECT * FROM artifact_group_selection_box_list 
WHERE id='$id'");
                if (!$res || db_numrows($res) < 1) {
                        $this->setError('ArtifactSelectionBox: Invalid Artifact 
ID');
                        return false;
                }
                $this->data_array =& db_fetch_array($res);
                db_free_result($res);
                return true;
        }

        /**
         *      getArtifactType - get the ArtifactType Object this 
ArtifactSelectionBox is associated with.
         *
         *      @return object  ArtifactType.
         */
        function &getArtifactType() {
                return $this->ArtifactType;
        }
        
        /**
         *      getID - get this ArtifactSelectionBox 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['selection_box_name'];
        }


        /**
         *              Update an ArtifactSelectionBox
         *
         *  @param      string  Name of the box.
         *  @return     boolean success.
         */
        function update($name) {
                if (!$this->ArtifactType->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }   
                $sql="UPDATE artifact_group_selection_box_list 
                        SET selection_box_name='".htmlspecialchars($name)."' 
                        WHERE id='". $this->getID() ."' 
                        AND 
group_artifact_id='".$this->ArtifactType->getID()."'";
                $result=db_query($sql);
                if ($result && db_affected_rows($result) > 0) {
                        return true;
                } else {
                        $this->setError(db_error());
                        return false;
                }
        }
}

?>

Index: ArtifactType.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/ArtifactType.class,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- ArtifactType.class  4 Aug 2004 16:18:34 -0000       1.22
+++ ArtifactType.class  26 Aug 2004 15:32:06 -0000      1.23
@@ -63,6 +63,26 @@
        var $Group; //group object
 
        /**
+        * Selection boxes db resource ID.
+        *
+        * @var         int             $selection_boxes_res.
+        */
+       var $selection_boxes_res;
+
+       /**
+        * Box options  db resource ID.
+        *
+        * @var         int             $box_options_res.
+        */
+       var $box_options_res;
+
+       var $options_res;
+
+       var $box;
+
+       var $choice_name_res;
+
+       /**
         * Categories db resource ID.
         *
         * @var         int             $categories_res.
@@ -425,11 +445,85 @@
        }
 
        /**
-        *        delete - delete this tracker and all its related data.
+        *      getSelectionBoxes - List of possible user built selection boxes 
set up for this artifact type.
+        *
+        *      @return database result set.
+        */
+       function getSelectionBoxes() {
+               if (!isset($this->selection_boxes_res)) {
+                       $sql="select id,selection_box_name
+                               FROM artifact_group_selection_box_list 
+                               WHERE group_artifact_id='".$this->getID() ."'
+                               ORDER BY id";
+                       $this->selection_boxes_res=db_query($sql);
+               }
+               return $this->selection_boxes_res;
+       }
+
+
+       /**
+        *      getSelectionBoxOptions - List of possible admin configured 
selection boxes set up for this artifact type.
+        *
+        *      @return database result set.
+        */
+       function getSelectionBoxOptions($box) {
+               $this->box=$box;
+               $sql="select id,box_options_name
+                       FROM artifact_group_selection_box_options
+                       WHERE artifact_box_id ='".$this->box."'  
+                       ORDER BY box_options_name";
+               $this->box_options_res=db_query($sql);
+               return $this->box_options_res;
+       }       
+
+       /**
+        *      getBoxOptions - List of possible admin configured selection 
boxes set up for this artifact type.
+        *
+        *      @return database result set.
+        */
+       function getBoxOptions() {
+               $sql="select id,artifact_box_id,box_options_name
+                       FROM artifact_group_selection_box_options
+                       ORDER BY box_options_name";
+               $this->box_options_res=db_query($sql);
+               return $this->box_options_res;
+       
+       }
+
+       /**
+        *      getArtifactChoices -List of choices for each admin configured 
boxe.
+        *      @return databse result set.
+        */
+       function getArtifactChoices($artifact_id){
+               $this->choice=$artifact_id;
+               $sql="select id,artifact_id,choice_id
+                       FROM artifact_extra_field_data
+                       WHERE artifact_id='".$this->choice."'
+                       ORDER BY id";
+               $this->choice_res=db_query($sql);
+               return $this->choice_res;
+       }
+
+       /**
+        *      getBoxOptionName - List of possible user built selection boxes 
set up for this artifact type.
+        *
+        *      @return database result set.
+        */
+       function getBoxOptionsName($choice_id) {
+               $this->choice = $choice_id;
+               $sql="select id, box_options_name
+                       FROM artifact_group_selection_box_options 
+                       WHERE id = '".$this->choice."'";
+               $this->options_res=db_query($sql);
+               return $this->options_res;
+       }
+
+       /**
+        *      delete - delete this tracker and all its related data.
         *
         *      @param  bool    I'm Sure.
         *      @param  bool    I'm REALLY sure.
-        *        @return       bool true/false;
+        *      @return bool true/false;
         */
        function delete($sure, $really_sure) {
                if (!$sure || !$really_sure) {





reply via email to

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