event_email_template.class.php 4.0 KB

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