This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  bd254479d7291a1fe469f5ac98c1ab8b07e67a76 (commit)
       via  e00992c24df886fe378ba096859b3921e6935cd0 (commit)
      from  8a1b4ab973b83396a28b2283f5f48cad8d25e185 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=bd254479d7291a1fe469f5ac98c1ab8b07e67a76

commit bd254479d7291a1fe469f5ac98c1ab8b07e67a76
Author: Franck Villaume <[email protected]>
Date:   Sun Oct 23 14:53:11 2016 +0200

    Implement Association: Artifact -> Artifact, Artifact -> Document

diff --git a/src/common/include/FFObject.class.php 
b/src/common/include/FFObject.class.php
index 8bfd26b..2961128 100644
--- a/src/common/include/FFObject.class.php
+++ b/src/common/include/FFObject.class.php
@@ -30,6 +30,7 @@
  */
 
 require_once $gfcommon.'include/FFError.class.php';
+require_once $gfcommon.'include/utils_crossref.php';
 
 class FFObject extends FFError {
 
@@ -112,13 +113,13 @@ class FFObject extends FFError {
                }
        }
 
-       function getRefObject($objectId, $objectRefId, $objectType) {
+       function getLinkObject($objectId, $objectRefId, $objectType) {
                switch ($objectType) {
                        case 'Document':
-                               return document_get_object($objectId, 
$objectRefId);
+                               return _documentid2url($objectId, $objectRefId);
                                break;
                        case 'Artifact':
-                               return artifact_get_object($objectId);
+                               return _artifactid2url($objectId);
                                break;
                }
        }
@@ -177,12 +178,13 @@ class FFObject extends FFError {
                if (is_object($object)) {
                        $objectType = get_class($object);
                        $objectRefId = $this->getRefID($object);
-                       if 
(!isset($this->associateArray[$objectType][$objectRefId][$object->getID()])) {
+                       if 
((isset($this->associatedToArray[$objectType][$objectRefId]) && 
!in_array($object->getID(), 
$this->associatedToArray[$objectType][$objectRefId]))
+                               || 
!isset($this->associatedToArray[$objectType][$objectRefId])) {
                                $res = db_query_params('INSERT INTO 
fusionforge_object_assiociation (from_id, from_object_type, from_ref_id, 
to_object_type, to_id, to_ref_id)
                                                                VALUES ($1, $2, 
$3, $4, $5, $6)',
                                                        array($this->getID(), 
$this->getRealClass($this), $this->getRefID($this), $objectType, 
$object->getID(), $objectRefId));
                                if ($res) {
-                                       
$this->associateArray[$objectType][$objectRefId][] = $object->getID();
+                                       
$this->associatedToArray[$objectType][$objectRefId][] = $object->getID();
                                        return true;
                                } else {
                                        $this->setError(_('Cannot insert 
association')._(': ').db_error());
@@ -196,59 +198,47 @@ class FFObject extends FFError {
                return false;
        }
 
-       function removeAssociationTo($object) {
-               if (is_object($object)) {
-                       $objectType = get_class($object);
-                       $objectRefId = $this->getRefID($object);
-                       if 
(isset($this->associateArray[$objectType][$objectRefId][$object->getID()])) {
-                               $res = db_query_params('DELETE FROM 
fusionforge_object_assiociation WHERE from_id = $1 AND from_object_type = $2
-                                                               AND 
to_object_type = $3 AND to_id = $4',
-                                                       array($this->getID(), 
$this->getRealClass($this), $objectType, $object->getID()));
-                               if ($res) {
-                                       
unset($this->associateArray[$objectType][$objectRefId][$object->getID()]);
-                                       return true;
-                               } else {
-                                       $this->setError(_('Cannot delete 
association')._(': ').db_error());
-                               }
+       function removeAssociationTo($objectId, $objectRefId, $objectType) {
+               if (isset($this->associatedToArray[$objectType][$objectRefId]) 
&& in_array($objectId, $this->associatedToArray[$objectType][$objectRefId])) {
+                       $res = db_query_params('DELETE FROM 
fusionforge_object_assiociation WHERE from_id = $1 AND from_object_type = $2
+                                                       AND to_object_type = $3 
AND to_id = $4',
+                                               array($this->getID(), 
$this->getRealClass($this), $objectType, $objectId));
+                       if ($res) {
+                               
unset($this->associatedToArray[$objectType][$objectRefId][$objectId]);
+                               return true;
                        } else {
-                               $this->setError(_('Association does not 
existing'));
+                               $this->setError(_('Cannot delete 
association')._(': ').db_error());
                        }
                } else {
-                       $this->setError(_('Cannot remove association to a 
non-object'));
+                       $this->setError(_('Association To does not existing'));
                }
                return false;
        }
 
-       function removeAssociationFrom($object) {
-               if (is_object($object)) {
-                       $objectType = get_class($object);
-                       $objectRefId = $this->getRefID($object);
-                       if 
(isset($this->associateArray[$objectType][$objectRefId][$object->getID()])) {
-                               $res = db_query_params('DELETE FROM 
fusionforge_object_assiociation WHERE from_id = $1 AND from_object_type = $2
-                                                               AND 
to_object_type = $3 AND to_id = $4',
-                                                       array($objectType, 
$object->getID(), $this->getID(), get_class($this)));
-                               if ($res) {
-                                       
unset($this->associateArray[$objectType][$objectRefId][$object->getID()]);
-                                       return true;
-                               } else {
-                                       $this->setError(_('Cannot delete 
association')._(': ').db_error());
-                               }
+       function removeAssociationFrom($objectId, $objectRefId, $objectType) {
+               if 
(isset($this->associatedFromArray[$objectType][$objectRefId]) && 
in_array($objectId, $this->associatedFromArray[$objectType][$objectRefId])) {
+                       $res = db_query_params('DELETE FROM 
fusionforge_object_assiociation WHERE from_id = $1 AND from_object_type = $2
+                                                       AND to_object_type = $3 
AND to_id = $4',
+                                               array($objectType, $objectId, 
$this->getID(), $this->getRealClass($this)));
+                       if ($res) {
+                               
unset($this->associatedFromArray[$objectType][$objectRefId][$objectId]);
+                               return true;
                        } else {
-                               $this->setError(_('Association does not 
existing'));
+                               $this->setError(_('Cannot delete 
association')._(': ').db_error());
                        }
                } else {
-                       $this->setError(_('Cannot remove association to a 
non-object'));
+                       $this->setError(_('Association From does not 
existing'));
                }
                return false;
        }
 
        function removeAllAssociations() {
                $res = db_query_params('DELETE FROM 
fusionforge_object_assiociation WHERE (from_id = $1 AND from_object_type = $2)
-                                                                               
        OR (to_id = $1 AND to_object_type $ 4)',
-                                       array($this->getID(), get_class(), 
$this->getID(), get_class()));
+                                                                               
        OR (to_id = $1 AND to_object_type = $2)',
+                                       array($this->getID(), 
get_class($this)));
                if ($res) {
-                       $this->associateToArray = array();
-                       $this->associateFromArray = array();
+                       $this->associatedToArray = array();
+                       $this->associatedFromArray = array();
                        return true;
                } else {
                        $this->setError(_('Unable to remove all 
associations')._(': ').db_error());
@@ -267,7 +257,7 @@ class FFObject extends FFError {
                                                        $tabletop = array('', 
_('Associated Object'), _('Associated Object ID'));
                                                        $classth = array('', 
'', '');
                                                        if ($url !== false) {
-                                                               echo 
html_e('p', array(), _('Remove all association action'));
+                                                               echo 
html_e('p', array(), _('Remove all associations')._(': 
').util_make_link($url.'&link=any', $HTML->getDeletePic(_('Drop all associated 
from and to objects.'))));
                                                                $tabletop[] = 
_('Actions');
                                                                $classth[] = 
'unsortable';
                                                        }
@@ -275,15 +265,12 @@ class FFObject extends FFError {
                                                        $displayHeader = true;
                                                }
                                                foreach ($objectIds as 
$objectId) {
-                                                       $object = 
$this->getRefObject($objectId, $objectRefId, $objectType);
                                                        $cells = array();
                                                        $cells[][] = _('To');
                                                        $cells[][] = 
$objectType;
-                                                       $cells[][] = 
util_make_link($object->getPermalink(), $objectId);
+                                                       $cells[][] = 
$this->getLinkObject($objectId, $objectRefId, $objectType);
                                                        if ($url !== false) {
-                                                               $cells[][] = 
_('Remove action');
-                                                       } else {
-                                                               $cells[][] = '';
+                                                               $cells[][] = 
util_make_link($url.'&link=to&objecttype='.$objectType.'&objectrefid='.$objectRefId.'&objectid='.$objectId,
 $HTML->getDeletePic(_('Remove this association'), _('Remove this 
association')));
                                                        }
                                                        echo 
$HTML->multiTableRow(array(), $cells);
                                                }
@@ -299,7 +286,7 @@ class FFObject extends FFError {
                                                        $tabletop = array('', 
_('Associated Object'), _('Associated Object ID'));
                                                        $classth = array('', 
'', '');
                                                        if ($url !== false) {
-                                                               echo 
html_e('p', array(), _('Remove all association action'));
+                                                               echo 
html_e('p', array(), util_make_link($url.'&link=any', 
$HTML->getDeletePic(_('Remove all associations'), _('Remove all 
associations'))));
                                                                $tabletop[] = 
_('Actions');
                                                                $classth[] = 
'unsortable';
                                                        }
@@ -307,15 +294,12 @@ class FFObject extends FFError {
                                                        $displayHeader = true;
                                                }
                                                foreach ($objectIds as 
$objectId) {
-                                                       $object = 
$this->getRefObject($objectId, $objectRefId, $objectType);
                                                        $cells = array();
                                                        $cells[][] = _('From');
                                                        $cells[][] = 
$objectType;
-                                                       $cells[][] = 
util_make_link($object->getPermalink(), $objectId);
+                                                       $cells[][] = 
$this->getLinkObject($objectId, $objectRefId, $objectType);
                                                        if ($url !== false) {
-                                                               $cells[][] = 
_('Remove action');
-                                                       } else {
-                                                               $cells[][] = '';
+                                                               $cells[][] = 
util_make_link($url.'&link=from&objecttype='.$objectType.'&objectRefId='.$objectRefId.'&objectId='.$objectId,
 $HTML->getDeletePic(_('Remove this association'), _('Remove this 
association')));
                                                        }
                                                        echo 
$HTML->multiTableRow(array(), $cells);
                                                }
diff --git a/src/common/tracker/Artifact.class.php 
b/src/common/tracker/Artifact.class.php
index 85c50f6..7dab996 100644
--- a/src/common/tracker/Artifact.class.php
+++ b/src/common/tracker/Artifact.class.php
@@ -65,7 +65,7 @@ define('ARTIFACT_MAIL_MARKER', 
'#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+');
  * @param      array|bool      $data           The result array, if it's 
passed in
  * @return     Artifact        Artifact object
  */
-function &artifact_get_object($artifact_id,$data=false) {
+function &artifact_get_object($artifact_id, $data=false) {
        global $ARTIFACT_OBJ;
        if (!isset($ARTIFACT_OBJ["_".$artifact_id."_"])) {
                if ($data) {
@@ -80,7 +80,7 @@ function &artifact_get_object($artifact_id,$data=false) {
                        $data = db_fetch_array($res);
                }
                $ArtifactType =& 
artifactType_get_object($data["group_artifact_id"]);
-               $ARTIFACT_OBJ["_".$artifact_id."_"]= new 
Artifact($ArtifactType,$data);
+               $ARTIFACT_OBJ["_".$artifact_id."_"]= new 
Artifact($ArtifactType, $data);
        }
        return $ARTIFACT_OBJ["_".$artifact_id."_"];
 }
@@ -140,9 +140,11 @@ class Artifact extends FFObject {
         * @param       int|bool        $data           (primary key from 
database OR complete assoc array)
         *                                              ONLY OPTIONAL WHEN YOU 
PLAN TO IMMEDIATELY CALL ->create()
         */
-       function __construct(&$ArtifactType, $data=false) {
-               if (is_int($data)) {
-                       parent::__construct($data, get_class());
+       function __construct(&$ArtifactType, $data = false) {
+               if (is_array($data)) {
+                       parent::__construct($data['artifact_id'], 'Artifact');
+               } elseif (is_int($data)) {
+                       parent::__construct($data, 'Artifact');
                } else {
                        parent::__construct();
                }
diff --git a/src/common/tracker/actions/detail.php 
b/src/common/tracker/actions/detail.php
index 6a833d6..943a283 100644
--- a/src/common/tracker/actions/detail.php
+++ b/src/common/tracker/actions/detail.php
@@ -241,9 +241,12 @@ if ($group->usesPM()) {
        <?php $ah->showRelations(); ?>
        <?php if (forge_get_config('use_object_associations')) { ?>
        <div id="tabber-object-associations" class="tabbertab">
-               <?php $ah->showAssociations(); ?>
-               <?php if (forge_check_perm ('tracker',$ath->getID(),'submit')) {
-                       $ah->showAddAssociations(); } ?>
+       <?php if (forge_check_perm ('tracker',$ath->getID(),'submit')) {
+               
$ah->showAssociations('/tracker/?rtype=ajax&aid='.$ah->getID().'&group_id='.$ath->Group->getID().'&atid='.$ath->getID().'&func=removeassoc');
+               $ah->showAddAssociations();
+               } else {
+               $ah->showAssociations();
+               } ?>
        </div>
        <?php } ?>
 </div>
diff --git a/src/common/tracker/actions/mod-limited.php 
b/src/common/tracker/actions/mod-limited.php
index ac19fa4..daf8583 100644
--- a/src/common/tracker/actions/mod-limited.php
+++ b/src/common/tracker/actions/mod-limited.php
@@ -257,9 +257,12 @@ if ($group->usesPM()) {
 <?php $ah->showRelations(); ?>
 <?php if (forge_get_config('use_object_associations')) { ?>
 <div id="tabber-object-associations" class="tabbertab">
-       <?php $ah->showAssociations(); ?>
        <?php if (forge_check_perm ('tracker',$ath->getID(),'submit')) {
-               $ah->showAddAssociations(); } ?>
+               
$ah->showAssociations('/tracker/?rtype=ajax&aid='.$ah->getID().'&group_id='.$ath->Group->getID().'&atid='.$ath->getID().'&func=removeassoc');
+               $ah->showAddAssociations();
+               } else {
+               $ah->showAssociations();
+               } ?>
 </div>
 <?php } ?>
 </div>
diff --git a/src/common/tracker/actions/mod.php 
b/src/common/tracker/actions/mod.php
index c67009d..3efbd2e 100644
--- a/src/common/tracker/actions/mod.php
+++ b/src/common/tracker/actions/mod.php
@@ -317,9 +317,12 @@ if ($group->usesPM()) {
        <?php $ah->showRelations(); ?>
        <?php if (forge_get_config('use_object_associations')) { ?>
        <div id="tabber-object-associations" class="tabbertab">
-               <?php $ah->showAssociations(); ?>
-               <?php if (forge_check_perm ('tracker',$ath->getID(),'submit')) {
-                       $ah->showAddAssociations(); } ?>
+       <?php if (forge_check_perm ('tracker',$ath->getID(),'submit')) {
+               
$ah->showAssociations('/tracker/?func=removeassoc&aid='.$ah->getID().'&group_id='.$ath->Group->getID().'&atid='.$ath->getID());
+               $ah->showAddAssociations();
+               } else {
+               $ah->showAssociations();
+               } ?>
        </div>
        <?php } ?>
 </div>
diff --git a/src/common/tracker/actions/tracker.php 
b/src/common/tracker/actions/tracker.php
index 4b0c758..97f6f09 100644
--- a/src/common/tracker/actions/tracker.php
+++ b/src/common/tracker/actions/tracker.php
@@ -4,8 +4,8 @@
  *
  * Copyright 1999-2001 (c) VA Linux Systems
  * Copyright 2002-2004 (c) GForge Team
- * Copyright 2012-2014, Franck Villaume - TrivialDev
  * Copyright 2012, Thorsten “mirabilos” Glaser <[email protected]>
+ * Copyright 2012-2014,2016 Franck Villaume - TrivialDev
  * http://fusionforge.org/
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -26,6 +26,8 @@
 
 global $group;
 global $atid;
+global $feedback;
+global $error_msg;
 
 //
 //     Create the ArtifactType object
@@ -42,7 +44,7 @@ if ($ath->isError()) {
                exit_error($ath->getErrorMessage(),'tracker');
        }
 }
-$error_msg = '';
+
 switch (getStringFromRequest('func')) {
 
        case 'add' : {
@@ -606,6 +608,35 @@ switch (getStringFromRequest('func')) {
                include $gfcommon.'tracker/actions/browse.php';
                break;
        }
+       case 'removeassoc':
+               $aid = getIntFromRequest('aid');
+               $artifact = artifact_get_object($aid);
+               $objectRefId = getStringFromRequest('objectrefid');
+               $objectId = getStringFromRequest('objectid');
+               $objectType = getStringFromRequest('objecttype');
+               $link = getStringFromRequest('link');
+               $was_error = false;
+               if ($link == 'to') {
+                       if (!$artifact->removeAssociationTo($objectId, 
$objectRefId, $objectType)) {
+                               $error_msg = $artifact->getErrorMessage();
+                               $was_error = true;
+                       }
+               } elseif ($link == 'from') {
+                       if (!$artifact->removeAssociationFrom($objectId, 
$objectRefId, $objectType)) {
+                               $error_msg = $artifact->getErrorMessage();
+                               $was_error = true;
+                       }
+               } elseif ($link == 'any') {
+                       if (!$artifact->removeAllAssociations()) {
+                               $error_msg = $artifact->getErrorMessage();
+                               $was_error = true;
+                       }
+               }
+               if (!$was_error) {
+                       $feedback = _('Associations removed successfully');
+               }
+               
session_redirect('/tracker/?group_id='.$group_id.'&atid='.$atid.'&aid='.$aid, 
false);
+               break;
        default : {
                include $gfcommon.'tracker/actions/browse.php';
                break;

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=e00992c24df886fe378ba096859b3921e6935cd0

commit e00992c24df886fe378ba096859b3921e6935cd0
Author: Franck Villaume <[email protected]>
Date:   Sun Oct 23 14:52:02 2016 +0200

    remove empty line & commented line

diff --git a/src/common/tracker/actions/ajax.php 
b/src/common/tracker/actions/ajax.php
index af466bb..087f531 100644
--- a/src/common/tracker/actions/ajax.php
+++ b/src/common/tracker/actions/ajax.php
@@ -25,11 +25,9 @@ $function = getStringFromRequest('function');
 
 switch ($function) {
        case 'get_canned_response':
-               //$atid = getIntFromRequest('atid');
                $canned_response_id = getIntFromRequest('canned_response_id');
                echo get_canned_response($canned_response_id);
                break;
-
        default:
                echo '';
                break;

-----------------------------------------------------------------------

Summary of changes:
 src/common/include/FFObject.class.php      | 90 ++++++++++++------------------
 src/common/tracker/Artifact.class.php      | 12 ++--
 src/common/tracker/actions/ajax.php        |  2 -
 src/common/tracker/actions/detail.php      |  9 ++-
 src/common/tracker/actions/mod-limited.php |  7 ++-
 src/common/tracker/actions/mod.php         |  9 ++-
 src/common/tracker/actions/tracker.php     | 35 +++++++++++-
 7 files changed, 94 insertions(+), 70 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to