IssueReport.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Define a issuereport.
  4. * @author Administrateur SYS1
  5. * @category Plugin
  6. * @license copyright
  7. */
  8. class IssueReport extends Entity{
  9. public $id,$browser,$browserVersion,$online,$os,$from,$width,$height,$ip,$history,$state,$assign,$followers;
  10. protected $TABLE_NAME = 'issue_report';
  11. public $fields =
  12. array(
  13. 'id' => 'key',
  14. 'browser' => 'string',
  15. 'browserVersion' => 'string',
  16. 'online' => 'boolean',
  17. 'state' => 'string',
  18. 'assign' => 'string',
  19. 'os' => 'string',
  20. 'from' => 'string',
  21. 'width' => 'int',
  22. 'height' => 'int',
  23. 'history' => 'longstring',
  24. 'followers' => 'longstring',
  25. 'ip' => 'string'
  26. );
  27. public static function states($key=null){
  28. $states = array(
  29. 'open' => array('icon'=>'far fa-clock','label'=>'Ouvert','color'=>'#3c3c3c'),
  30. 'closed' => array('icon'=>'fas fa-check','label'=>'Résolu','color'=>'#2cbe4e'),
  31. 'canceled' => array('icon'=>'fas fa-ban','label'=>'Annulé','color'=>'#cb2431'),
  32. );
  33. if(!isset($key)) return $states;
  34. return isset($states[$key]) ? $states[$key] : array();
  35. }
  36. public function remove($cascading = true){
  37. self::deleteById($this->id);
  38. if($cascading){
  39. require_once(__DIR__.SLASH.'IssueEvent.class.php');
  40. foreach(IssueEvent::loadAll(array('issue'=>$this->id)) as $event){
  41. $event->remove();
  42. }
  43. }
  44. }
  45. public function followers($followersArray = null){
  46. if(!isset($followersArray)) return explode(',', $this->followers);
  47. $this->followers = implode(',',$followersArray);
  48. }
  49. public function addFollower($login){
  50. $followers = $this->followers();
  51. $followers[] = $login;
  52. $followers = array_filter(array_unique($followers));
  53. $this->followers($followers);
  54. }
  55. }
  56. ?>