CurrentUserCause.class.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. Cause de workflow
  4. Compare l'utilisateur courant à la valeur définie dans la cause
  5. */
  6. class CurrentUserCause{
  7. //Descriptif de la cause
  8. public static function manifest($key = null){
  9. $manifest = array(
  10. 'slug' => 'current-user',
  11. 'label' => 'Utilisateur Connecté',
  12. 'type' => array(Workflow::TYPE_ALL),
  13. 'class' => get_called_class(),
  14. 'path' => __FILE__,
  15. 'icon' => 'far fa-users',
  16. 'attributes' => ' data-filter-type="user" ',
  17. 'color' => '#ff9f43',
  18. );
  19. if(!isset($key)) return $manifest;
  20. return isset($manifest[$key]) ? $manifest[$key] : '' ;
  21. }
  22. //Méthode de vérification de la cause
  23. public static function check($filter,$parameters = array()){
  24. global $myUser;
  25. switch($filter['operator']){
  26. case '=':
  27. if($myUser->login != $filter['value'][0] ) return false;
  28. break;
  29. case '!=':
  30. if($myUser->login == $filter['value'][0] ) return false;
  31. break;
  32. case 'is null':
  33. if(!empty($myUser->id)) return false;
  34. break;
  35. case 'is not null':
  36. if(empty($myUser->id)) return false;
  37. break;
  38. }
  39. return true;
  40. }
  41. }
  42. ?>