/**
  * Function called when a Dolibarrr business event is done.
  * All functions "run_trigger" are triggered if file
  * is inside directory core/triggers
  *
  * 	@param		string		$action		Event action code
  * 	@param		Object		$object		Object
  * 	@param		User		$user		Object user
  * 	@param		Translate	$langs		Object langs
  * 	@param		conf		$conf		Object conf
  * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
  */
 public function run_trigger($action, $object, $user, $langs, $conf)
 {
     // Put here code you want to execute when a Dolibarr business events occurs.
     // Data and type of action are stored into $object and $action
     // Users
     if ($action === 'PROJECT_CREATE') {
         if (empty($object->array_options['options_color'])) {
             dol_include_once('/scrumboard/lib/scrumboard.lib.php');
             $object->array_options['options_color'] = '#' . scrumboard_random_color();
             $object->update($user, 1);
         }
         dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id);
     } else {
         if ($action === 'TASK_CREATE') {
             if (!empty($conf->global->SCRUM_ADD_TASKS_TO_GRID)) {
                 $object->array_options['options_grid_use'] = 1;
                 $object->update($user, 1);
             }
             dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id);
         }
     }
     return 0;
 }
 /**
  * Function called when a Dolibarrr business event is done.
  * All functions "run_trigger" are triggered if file
  * is inside directory core/triggers
  *
  * 	@param		string		$action		Event action code
  * 	@param		Object		$object		Object
  * 	@param		User		$user		Object user
  * 	@param		Translate	$langs		Object langs
  * 	@param		conf		$conf		Object conf
  * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
  */
 public function run_trigger($action, $object, $user, $langs, $conf)
 {
     // Put here code you want to execute when a Dolibarr business events occurs.
     // Data and type of action are stored into $object and $action
     // Users
     if ($action === 'PROJECT_CREATE') {
         if (empty($object->array_options['options_color'])) {
             dol_include_once('/scrumboard/lib/scrumboard.lib.php');
             $object->array_options['options_color'] = '#' . scrumboard_random_color();
             $object->update($user, 1);
         }
         dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id);
     } else {
         if ($action === 'TASK_CREATE') {
             if (!empty($conf->global->SCRUM_ADD_TASKS_TO_GRID)) {
                 $object->array_options['options_grid_use'] = 1;
                 $object->update($user, 1);
                 $object->insertExtraFields();
             }
             dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id);
         } else {
             if ($action === 'ACTION_CREATE' || $action == 'ACTION_MODIFY') {
                 $fk_task = 0;
                 $object->fetchObjectLinked();
                 if (!empty($object->linkedObjectsIds['task'])) {
                     $row = each($object->linkedObjectsIds['task']);
                     $fk_task = $row[1];
                 }
                 $fk_project_task = GETPOST('fk_project_task');
                 if (!empty($fk_project_task)) {
                     list($fk_project, $fk_task) = explode('_', $fk_project_task);
                     if (!empty($fk_task)) {
                         if (!empty($object->linkedObjectsIds['task'])) {
                             $object->updateObjectLinked($fk_task, 'task');
                         } else {
                             $object->add_object_linked('task', $fk_task);
                         }
                     }
                 }
                 /*var_dump($object);
                 			exit('!');
                 	*/
             }
         }
     }
     return 0;
 }