Where are the Variables defined?

Hi everyone,
i am new in kanboard and as well as in Programming. Can someone help me plz where is the Variable dest_column_id defined? in the Class TaskmoveColumnAssigned.php.

farthermore I wanna duplicate a task in other projekt I will post my code below. The goal is to have a destination Column in which the task in other Projekt duplicated. i have tryed but its not working. I appreciate any help. tnx

public function getActionRequiredParameters()
{
return array(
‘column_id’ => t(‘Column’),
‘project_id’ => t(‘Project’),
‘dst_column_id’ => t(‘Destination Column’),
);
}

/**
 * Get the required parameter for the event
 *
 * @access public
 * @return string[]
 */
public function getEventRequiredParameters()
{
    return array(
        'task_id',
        'task' => array(
            'project_id',
            'column_id',
            'dst_column_id'
            
        )
    );
}

/**
 * Execute the action (duplicate the task to another project)
 *
 * @access public
 * @param  array   $data   Event data dictionary
 * @return bool            True if the action was executed or false when not executed
 */
public function doAction(array $data)
{
    $destination_column_id = $this->columnModel->getAll($this->getParam('project_id'));
    return (bool) $this->taskProjectDuplicationModel->duplicateToProject(
        $data['task_id'],
        $this->getParam('project_id'),
        null,
         $destination_column_id 
    ); 
}

/**
 * Check if the event data meet the action condition
 *
 * @access public
 * @param  array   $data   Event data dictionary
 * @return bool
 */
public function hasRequiredCondition(array $data)
{
    if( $data['task']['column_id'] == $this->getParam('column_id') &&
        $data['task']['project_id'] != $this->getParam('project_id') &&
        $data['task']['dst_column_id'] != $this->getParam('column_id')&&
        $data['task']['project_id'] != $this->getParam('project_id')
)
{

return true;
}
return false;
}
}

The dest_column_id either an array key or a parameter.

Maybe not an easy topic to start programming.

tnx for the reply sir do u have any Idea?
what I am doing wrong in the code that i had posted before. I defined a Destination Column and the target is that I wanna duplicate a Task in a specific project and in a specific Column.

for example duplicating the task
source column: Ready
project : any project of choice
Destination Column: done

Your code snippet is incomplete and not well formatted. Please try to edit your post or publish a link where your code can be reviewed and/or fixed.

  • BTW, what exactly fails? Any errors?
  • Did you register this action properly?

it gives me no error. The problem is on the user interface in the Destination Column it show me the Standard Column not the Columns of the choice Project that i had chosen.
The Action is already registered i wanna only make some changes in it.

1 Like

do u have any solution for me Sir @alfredb that i can solve the problem?

Yes, I took a little more time than I expected. Here is my solution:

diff --git a/TaskDuplicateAnotherProject.php b/TaskDuplicateAnotherProject.php
index f4e7cd0..2274b59 100644
--- a/TaskDuplicateAnotherProject.php
+++ b/TaskDuplicateAnotherProject.php
@@ -66,8 +66,6 @@ class TaskDuplicateAnotherProject extends Base
             'task' => array(
                 'project_id',
                 'column_id',
-               
-                
             )
         );
     }
@@ -81,15 +79,15 @@ class TaskDuplicateAnotherProject extends Base
      */
     public function doAction(array $data)
     {
-
-        $destination_column_id = $this->columnModel->getAll($this->getParam('project_id'));
+        // This will return an array of ids, not a single id!
+        // $destination_column_id = $this->columnModel->getAll($this->getParam('project_id'));
         return (bool) $this->taskProjectDuplicationModel->duplicateToProject(
-            $data['task_id'],
-            $this->getParam('project_id'),
-            $this->getParam('dest_column_id'),
-            null,
-             $destination_column_id 
-        );  
+            $data['task_id'],                       // task
+            $this->getParam('project_id'),          // project
+            // $this->getParam('dest_column_id'),   // WRONG, misplaced
+            null,                                   // swimline
+            $this->getParam('dest_column_id')       // dest column
+        );
     }
 
     /**
@@ -101,13 +99,10 @@ class TaskDuplicateAnotherProject extends Base
      */
     public function hasRequiredCondition(array $data)
     {
-        error_log(print_r($data, TRUE));
-     return false;
-        return   $data['task']['column_id'] == $this->getParam('column_id') &&
-         $data['task']['project_id'] != $this->getParam('project_id')&&
-            $data['task']['column_id'] != $this->getParam('dest_column_id');
-         
-
+        return
+            $data['task']['column_id']  == $this->getParam('column_id')  &&
+            $data['task']['project_id'] != $this->getParam('project_id') &&
+            ;
     }
-    
+
 }

This works as it should.
But the fixing the definition dialog is another, more difficult story. Remaining things to do/solve:

  • The selector for dest_column_id still shows the column list of the actual project, rather than from the selected target project.
  • Whenever the project selection changes, the column list must be updated. This needs JavaScript, I guess.

I’ll have another look, whenever I find some time.

tnx for the solution I had tryed same thing before but unfortunately it did not worked as I wished. For sure to make it dynamic it need javascript. And I think I have to make a column for destination column in the table of Column. I mean i have to insert a query

This I don’t understand. Why? More details, please.

And always keep in mind, that you should NEVER modify any Kanboard code directly. This is considered as a bad practice.

I thought that I have to insert a destination Column in Column but I was wrong. tnx for Advice I won’t modefiy the code directly any more.