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.25,1.26


From: ruben
Subject: [Gforge-commits] gforge/common/tracker Artifact.class,1.25,1.26
Date: Mon, 20 Dec 2004 10:53:28 -0600

Update of /cvsroot/gforge/gforge/common/tracker
In directory db.perdue.net:/tmp/cvs-serv15734/common/tracker

Modified Files:
        Artifact.class 
Log Message:
added option to delete a task or artifact

Index: Artifact.class
===================================================================
RCS file: /cvsroot/gforge/gforge/common/tracker/Artifact.class,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- Artifact.class      7 Dec 2004 00:51:21 -0000       1.25
+++ Artifact.class      20 Dec 2004 16:53:25 -0000      1.26
@@ -520,39 +520,68 @@
                        $this->setMissingParamsError();
                        return false;
                }
-               if (!$this->userIsAdmin()) {
+               if (!$this->ArtifactType->userIsAdmin()) {
                        $this->setPermissionDeniedError();
                        return false;
                }
                db_begin();
-               db_query("DELETE FROM artifact_extra_field_data
-                       WHERE artifact_id='".$this->getID()."'");
-//echo '0.1'.db_error();
-               db_query("DELETE FROM artifact_file
-                       WHERE artifact_id='".$this->getID()."'");
-//echo '6'.db_error();
-               db_query("DELETE FROM artifact_message
-                       WHERE artifact_id='".$this->getID()."'");
-//echo '7'.db_error();
-               db_query("DELETE FROM artifact_history
-                       WHERE artifact_id='".$this->getID()."'");
-//echo '8'.db_error();
-               db_query("DELETE FROM artifact_monitor
-                       WHERE rtifact_id='".$this->getID()."'");
-//echo '9'.db_error();
-               db_query("DELETE FROM artifact
-                       WHERE artifact_id='".$this->getID()."'");
+               $res = db_query("DELETE FROM artifact_extra_field_data WHERE 
artifact_id='".$this->getID()."'");
+               if (!$res) {
+                       $this->setError('Error deleting extra field data: 
'.db_error());
+                       db_rollback();
+                       return false;
+               }
+               $res = db_query("DELETE FROM artifact_file WHERE 
artifact_id='".$this->getID()."'");
+               if (!$res) {
+                       $this->setError('Error deleting file from db: 
'.db_error());
+                       db_rollback();
+                       return false;
+               }
+               $res = db_query("DELETE FROM artifact_message WHERE 
artifact_id='".$this->getID()."'");
+               if (!$res) {
+                       $this->setError('Error deleting message: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+               $res = db_query("DELETE FROM artifact_history WHERE 
artifact_id='".$this->getID()."'");
+               if (!$res) {
+                       $this->setError('Error deleting history: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+               $res = db_query("DELETE FROM artifact_monitor WHERE 
artifact_id='".$this->getID()."'");
+               if (!$res) {
+                       $this->setError('Error deleting monitor: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+               $res = db_query("DELETE FROM artifact WHERE 
artifact_id='".$this->getID()."'");
+               if (!$res) {
+                       $this->setError('Error deleting artifact: '.db_error());
+                       db_rollback();
+                       return false;
+               }
+               
                if ($this->getStatusID() == 1) {
-                       db_query("UPDATE artifact_counts_agg
-                               SET count=count-1,open_count=open_count-1
+                       $res = db_query("UPDATE artifact_counts_agg SET 
count=count-1,open_count=open_count-1
                                WHERE group_artifact_id='".$this->getID()."'");
+                       if (!$res) {
+                               $this->setError('Error updating 
artifact_counts_agg (1): '.db_error());
+                               db_rollback();
+                               return false;
+                       }
                } elseif ($this->getStatusID() == 2) {
-                       db_query("UPDATE artifact_counts_agg
-                               SET count=count-1
+                       $res = db_query("UPDATE artifact_counts_agg SET 
count=count-1
                                WHERE group_artifact_id='".$this->getID()."'");
+                       if (!$res) {
+                               $this->setError('Error updating 
artifact_counts_agg (2): '.db_error());
+                               db_rollback();
+                               return false;
+                       }
                }
-//echo '5'.db_error();
+
                db_commit();
+               return true;
        }
 
        /**





reply via email to

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