newMessageForm.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. class newMessageForm extends Staple_Form
  3. {
  4. public function _start()
  5. {
  6. $this->setLayout('newMessageFormLayout');
  7. $this->setName('newMessageForm')
  8. ->setAction($this->link(array('messages','index')));
  9. $message = new Staple_Form_FoundationTextareaElement('message','Message');
  10. $message->setRequired()
  11. ->addAttrib("placeholder","1000 character limit")
  12. ->addValidator(new Staple_Form_Validate_Length(1,1000))
  13. ->addAttrib("style","height:200px;");
  14. $account = new Staple_Form_FoundationSelectElement('account','Send To');
  15. $account->setRequired()
  16. ->addOption('','Select an account')
  17. ->addOptionsArray($this->accounts())
  18. ->addValidator(new Staple_Form_Validate_InArray($this->accounts(1)));
  19. $expireDate = new Staple_Form_FoundationTextElement('expireDate','Expiration Date');
  20. $expireDate->setRequired()
  21. ->addValidator(new Staple_Form_Validate_Date())
  22. ->addAttrib('placeholder','mm/dd/yyyy');
  23. $submit = new Staple_Form_FoundationSubmitElement('submit','Submit');
  24. $submit->addClass('button expand radius');
  25. $this->addField($account, $expireDate, $message, $submit);
  26. }
  27. public function accounts($ids = null)
  28. {
  29. $user = new userModel();
  30. $id = $user->getId();
  31. $authLevel = $user->getAuthLevel();
  32. $accounts = new userModel();
  33. $users = $accounts->listAll();
  34. $data = array();
  35. if($ids == null)
  36. {
  37. if($user->getAuthLevel() >= 900)
  38. {
  39. $data['all'] = "All Accounts";
  40. }
  41. foreach($users as $user)
  42. {
  43. if($user['supervisorId'] == $id)
  44. {
  45. $data[$user['id']] = $user['lastName'].", ".$user['firstName']." (". $user['type'] .")";
  46. }
  47. elseif($authLevel >= 900)
  48. {
  49. $data[$user['id']] = $user['lastName'].", ".$user['firstName']." (". $user['type'] .")";
  50. }
  51. }
  52. }
  53. else
  54. {
  55. $data[] = "all";
  56. foreach($users as $user)
  57. {
  58. $data[] = $user['id'];
  59. }
  60. }
  61. return $data;
  62. }
  63. }
  64. ?>