Permission.class.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Define a permission.
  4. * @author Chuck NORRIS
  5. * @category Plugin
  6. * @license copyright
  7. */
  8. class Permission extends Entity{
  9. public $id;
  10. public $read; //read (Booléen)
  11. public $recursive; //recursive (Booléen)
  12. public $uid; //uid (Texte)
  13. public $entity; //entity (Texte)
  14. public $configure; //configure (Booléen)
  15. public $delete; //delete (Booléen)
  16. public $edit; //edit (Booléen)
  17. public $targetEntity; //Entité cible (Texte)
  18. public $targetUid; //uid cible (Texte)
  19. protected $TABLE_NAME = 'permission';
  20. public $fields = array(
  21. 'id' => 'key',
  22. 'read' => 'boolean',
  23. 'recursive' => 'boolean',
  24. 'uid' => 'string',
  25. 'entity' => 'string',
  26. 'configure' => 'boolean',
  27. 'delete' => 'boolean',
  28. 'edit' => 'boolean',
  29. 'targetEntity' => 'string',
  30. 'targetUid' => 'string'
  31. );
  32. public $links = array(
  33. );
  34. //Colonnes indexées
  35. public $indexes = array();
  36. //Remplis une permission a partir de la modale de base un d'un form custom
  37. public static function form($form = null){
  38. if(!isset($form)){
  39. global $_;
  40. $form = $_;
  41. }
  42. $item = new self();
  43. if(isset($form['read']))$item->read = $form['read'];
  44. if(isset($form['recursive']))$item->recursive = $form['recursive'];
  45. if(isset($form['uid']))$item->uid = $form['uid'];
  46. if(isset($form['entity']))$item->entity = $form['entity'];
  47. if(isset($form['configure']))$item->configure = $form['configure'];
  48. if(isset($form['delete']))$item->delete = $form['delete'];
  49. if(isset($form['edit']))$item->edit = $form['edit'];
  50. if(isset($form['targetEntity']))$item->targetEntity = $form['targetEntity'];
  51. if(isset($form['targetUid']))$item->targetUid = $form['targetUid'];
  52. return $item;
  53. }
  54. }
  55. ?>