event_email_template.class.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @deprecated
  5. * Class EventEmailTemplate
  6. */
  7. class EventEmailTemplate extends Model
  8. {
  9. public $table;
  10. public $columns = [
  11. 'id',
  12. 'message',
  13. 'subject',
  14. 'event_type_name',
  15. 'activated',
  16. ];
  17. /**
  18. * Constructor
  19. */
  20. public function __construct()
  21. {
  22. $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
  23. }
  24. /**
  25. * @param array $where_conditions
  26. * @return array
  27. */
  28. public function get_all($where_conditions = [])
  29. {
  30. return Database::select(
  31. '*',
  32. $this->table,
  33. ['where' => $where_conditions, 'order' => 'name ASC']
  34. );
  35. }
  36. /**
  37. * Displays the title + grid
  38. */
  39. public function display()
  40. {
  41. // action links
  42. $content = Display::actions(
  43. [
  44. [
  45. 'url' => 'event_type.php',
  46. 'content' => Display::return_icon(
  47. 'new_document.png',
  48. get_lang('Add'),
  49. [],
  50. ICON_SIZE_MEDIUM
  51. )
  52. ]
  53. ]
  54. );
  55. $content .= Display::grid_html('event_email_template');
  56. return $content;
  57. }
  58. /**
  59. * @return array
  60. */
  61. public function get_status_list()
  62. {
  63. return [
  64. EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enabled'),
  65. EVENT_EMAIL_TEMPLATE_INACTIVE => get_lang('Disabled')
  66. ];
  67. }
  68. /**
  69. * Returns a Form validator Obj
  70. * @param string $url
  71. * @param string $action add, edit
  72. *
  73. * @return FormValidator
  74. */
  75. public function return_form($url, $action)
  76. {
  77. $form = new FormValidator('career', 'post', $url);
  78. // Setting the form elements
  79. $header = get_lang('Add');
  80. if ($action == 'edit') {
  81. $header = get_lang('Modify');
  82. }
  83. $form->addElement('header', $header);
  84. $id = isset($_GET['id']) ? intval($_GET['id']) : '';
  85. $form->addElement('hidden', 'id', $id);
  86. $form->addElement('text', 'name', get_lang('Name'), ['size' => '70']);
  87. $form->addHtmlEditor(
  88. 'description',
  89. get_lang('Description'),
  90. false,
  91. false,
  92. [
  93. 'ToolbarSet' => 'careers',
  94. 'Width' => '100%',
  95. 'Height' => '250',
  96. ]
  97. );
  98. $status_list = $this->get_status_list();
  99. $form->addElement('select', 'status', get_lang('Status'), $status_list);
  100. if ($action == 'edit') {
  101. $form->addElement('text', 'created_at', get_lang('CreatedAt'));
  102. $form->freeze('created_at');
  103. }
  104. if ($action == 'edit') {
  105. $form->addButtonSave(get_lang('Modify'), 'submit');
  106. } else {
  107. $form->addButtonCreate(get_lang('Add'), 'submit');
  108. }
  109. // Setting the defaults
  110. $defaults = $this->get($id);
  111. if (!empty($defaults['created_at'])) {
  112. $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
  113. }
  114. if (!empty($defaults['updated_at'])) {
  115. $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
  116. }
  117. $form->setDefaults($defaults);
  118. // Setting the rules
  119. $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
  120. return $form;
  121. }
  122. public function get_count()
  123. {
  124. $row = Database::select('count(*) as count', $this->table, [], 'first');
  125. return $row['count'];
  126. }
  127. }