event_email_template.class.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This class provides methods for the notebook management.
  5. * Include/require it in your code to use its features.
  6. * @package chamilo.library
  7. */
  8. /**
  9. * Code
  10. */
  11. /**
  12. * @package chamilo.library
  13. */
  14. class EventEmailTemplate extends Model {
  15. var $table;
  16. var $columns = array('id', 'message','subject','event_type_name','activated');
  17. public function __construct() {
  18. $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
  19. }
  20. public function get_all($where_conditions = array()) {
  21. return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
  22. }
  23. /**
  24. * Displays the title + grid
  25. */
  26. public function display() {
  27. // action links
  28. $content = Display::actions(array(
  29. array(
  30. 'url' => 'event_type.php' ,
  31. 'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
  32. )
  33. )
  34. );
  35. $content .= Display::grid_html('event_email_template');
  36. return $content;
  37. }
  38. public function get_status_list() {
  39. return array(EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enabled'), EVENT_EMAIL_TEMPLATE_INACTIVE=> get_lang('Disabled'));
  40. }
  41. /**
  42. * Returns a Form validator Obj
  43. * @todo the form should be auto generated
  44. * @param string url
  45. * @param string action add, edit
  46. * @return obj form validator obj
  47. */
  48. public function return_form($url, $action) {
  49. $oFCKeditor = new FCKeditor('description') ;
  50. $oFCKeditor->ToolbarSet = 'careers';
  51. $oFCKeditor->Width = '100%';
  52. $oFCKeditor->Height = '200';
  53. $oFCKeditor->Value = '';
  54. $oFCKeditor->CreateHtml();
  55. $form = new FormValidator('career', 'post', $url);
  56. // Settting the form elements
  57. $header = get_lang('Add');
  58. if ($action == 'edit') {
  59. $header = get_lang('Modify');
  60. }
  61. $form->addElement('header', $header);
  62. $id = isset($_GET['id']) ? intval($_GET['id']) : '';
  63. $form->addElement('hidden', 'id', $id);
  64. $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
  65. $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
  66. $status_list = $this->get_status_list();
  67. $form->addElement('select', 'status', get_lang('Status'), $status_list);
  68. if ($action == 'edit') {
  69. $form->addElement('text', 'created_at', get_lang('CreatedAt'));
  70. $form->freeze('created_at');
  71. }
  72. if ($action == 'edit') {
  73. $form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
  74. } else {
  75. $form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
  76. }
  77. // Setting the defaults
  78. $defaults = $this->get($id);
  79. if (!empty($defaults['created_at'])) {
  80. $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
  81. }
  82. if (!empty($defaults['updated_at'])) {
  83. $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
  84. }
  85. $form->setDefaults($defaults);
  86. // Setting the rules
  87. $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
  88. return $form;
  89. }
  90. public function get_count() {
  91. $row = Database::select('count(*) as count', $this->table, array(),'first');
  92. return $row['count'];
  93. }
  94. /*
  95. public function save($params) {
  96. $id = parent::save($params);
  97. if (!empty($id)) {
  98. event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
  99. }
  100. return $id;
  101. }
  102. public function delete($id) {
  103. parent::delete($id);
  104. event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
  105. } */
  106. }