event_email_template.class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 = array(
  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 = array())
  29. {
  30. return Database::select(
  31. '*',
  32. $this->table,
  33. array('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(array(
  43. array(
  44. 'url' => 'event_type.php',
  45. 'content' => Display::return_icon(
  46. 'new_document.png',
  47. get_lang('Add'),
  48. array(),
  49. ICON_SIZE_MEDIUM
  50. )
  51. )
  52. )
  53. );
  54. $content .= Display::grid_html('event_email_template');
  55. return $content;
  56. }
  57. /**
  58. * @return array
  59. */
  60. public function get_status_list()
  61. {
  62. return array(
  63. EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enabled'),
  64. EVENT_EMAIL_TEMPLATE_INACTIVE => get_lang('Disabled')
  65. );
  66. }
  67. /**
  68. * Returns a Form validator Obj
  69. * @param string $url
  70. * @param string $action add, edit
  71. *
  72. * @return FormValidator
  73. */
  74. public function return_form($url, $action)
  75. {
  76. $form = new FormValidator('career', 'post', $url);
  77. // Setting the form elements
  78. $header = get_lang('Add');
  79. if ($action == 'edit') {
  80. $header = get_lang('Modify');
  81. }
  82. $form->addElement('header', $header);
  83. $id = isset($_GET['id']) ? intval($_GET['id']) : '';
  84. $form->addElement('hidden', 'id', $id);
  85. $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
  86. $form->addHtmlEditor(
  87. 'description',
  88. get_lang('Description'),
  89. false,
  90. false,
  91. array(
  92. 'ToolbarSet' => 'careers',
  93. 'Width' => '100%',
  94. 'Height' => '250',
  95. )
  96. );
  97. $status_list = $this->get_status_list();
  98. $form->addElement('select', 'status', get_lang('Status'), $status_list);
  99. if ($action == 'edit') {
  100. $form->addElement('text', 'created_at', get_lang('CreatedAt'));
  101. $form->freeze('created_at');
  102. }
  103. if ($action == 'edit') {
  104. $form->addButtonSave(get_lang('Modify'), 'submit');
  105. } else {
  106. $form->addButtonCreate(get_lang('Add'), 'submit');
  107. }
  108. // Setting the defaults
  109. $defaults = $this->get($id);
  110. if (!empty($defaults['created_at'])) {
  111. $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
  112. }
  113. if (!empty($defaults['updated_at'])) {
  114. $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
  115. }
  116. $form->setDefaults($defaults);
  117. // Setting the rules
  118. $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
  119. return $form;
  120. }
  121. public function get_count()
  122. {
  123. $row = Database::select('count(*) as count', $this->table, array(), 'first');
  124. return $row['count'];
  125. }
  126. }