Persist workflow entry fields to order
This commit is contained in:
@@ -24,74 +24,6 @@ class Wiaas_Delivery_Process_Addon extends Gravity_Flow_Extension {
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
||||
parent::init();
|
||||
|
||||
add_filter('gravityflow_get_users_args', array ($this, 'allow_only_administrator_to_be_assigned_to_step'));
|
||||
|
||||
add_filter('gravityflow_assignee_choices', array ($this, 'add_orders_assignee_choices'));
|
||||
|
||||
add_filter('gravityflow_step_assignees', array ($this, 'maybe_assign_organization_to_step'), 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle organization assignee for step (Map users from organization as assignees to step)
|
||||
*
|
||||
* @param $assignees
|
||||
* @param Gravity_Flow_Step $step
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function maybe_assign_organization_to_step($assignees, Gravity_Flow_Step $step) {
|
||||
|
||||
$mapped_assignees = array();
|
||||
|
||||
foreach ($assignees as $assignee) {
|
||||
|
||||
if (strpos($assignee->get_type(), 'wiaas_organization_order_') !== false) {
|
||||
|
||||
$organization_id = $assignee->get_id();
|
||||
|
||||
$user_ids = wiaas_get_organization_user_ids($organization_id);
|
||||
|
||||
if (empty($user_ids)) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$user_id = $user_ids[0];
|
||||
|
||||
$mapped_assignees[] = $step->get_assignee( array(
|
||||
'id' => $user_id,
|
||||
'type' => 'user_id',
|
||||
'editable_fields' => $assignee->get_editable_fields()
|
||||
) );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$mapped_assignees[] = $assignee;
|
||||
}
|
||||
|
||||
return $mapped_assignees;
|
||||
}
|
||||
|
||||
|
||||
public function allow_only_administrator_to_be_assigned_to_step($args) {
|
||||
|
||||
$args['role'] = 'administrator';
|
||||
|
||||
//$args['exclude'] = array( 1 ); // exclude super admin user
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
public static function add_orders_assignee_choices($choices) {
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends Gravity Form entry metadata with 'wiaas_delivery_process_id'
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user