PRinting the event mail template, fixing some jquery, adding security, still need more work see #4658
parent
ba2197b858
commit
0bc2807f73
@ -0,0 +1,91 @@ |
||||
<?php |
||||
// name of the language file that needs to be included |
||||
$language_file = array('admin', 'events'); |
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
//The event type is so mess that I'm giving me the freedom to try to do a "symfony controller" style |
||||
class eventController { // extends Controller { |
||||
public function showAction() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public function newAction() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public function addAction() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public function listingAction() |
||||
{ |
||||
$event_email_template = new EventEmailTemplate(); |
||||
return $event_email_template->display(); |
||||
} |
||||
|
||||
public function deleteAction($id) { |
||||
$event_email_template = new EventEmailTemplate(); |
||||
return $event_email_template->delete($id); |
||||
} |
||||
} |
||||
|
||||
$event_controller = new eventController(); |
||||
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||
|
||||
switch ($action) { |
||||
case 'show': |
||||
$event_controller->showAction(); |
||||
break; |
||||
case 'add': |
||||
$event_controller->addAction(); |
||||
break; |
||||
case 'new': |
||||
$event_controller->newAction(); |
||||
break; |
||||
case 'listing': |
||||
$content = $event_controller->listingAction(); |
||||
break; |
||||
case 'delete' : |
||||
$event_controller->deleteAction($_GET['id']); |
||||
$content = $event_controller->listingAction(); |
||||
break; |
||||
} |
||||
|
||||
//jqgrid will use this URL to do the selects |
||||
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_event_email_template'; |
||||
|
||||
|
||||
//The order is important you need to check the the $column variable in the model.ajax.php file |
||||
$columns = array(get_lang('Subject'), get_lang('Message'), get_lang('EventTypeName'), get_lang('Language'), get_lang('Status'), get_lang('Actions')); |
||||
|
||||
//Column config |
||||
$column_model = array( |
||||
array('name'=>'subject', 'index'=>'subject', 'width'=>'80', 'align'=>'left'), |
||||
array('name'=>'message', 'index'=>'message', 'width'=>'500', 'align'=>'left','sortable'=>'false'), |
||||
array('name'=>'event_type_name', 'index'=>'event_type_name', 'width'=>'80', 'align'=>'left'), |
||||
array('name'=>'language_id', 'index'=>'language_id', 'width'=>'80', 'align'=>'left'), |
||||
array('name'=>'activated', 'index'=>'activated', 'width'=>'80', 'align'=>'left'), |
||||
array('name'=>'actions', 'index'=>'actions', 'width'=>'100') |
||||
); |
||||
//Autowidth |
||||
$extra_params['autowidth'] = 'true'; |
||||
//height auto |
||||
$extra_params['height'] = 'auto'; |
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js(); |
||||
$htmlHeadXtra[] = '<script> |
||||
$(function() { |
||||
'.Display::grid_js('event_email_template', $url,$columns,$column_model,$extra_params, array(), $action_links,true).' |
||||
}); |
||||
</script>'; |
||||
|
||||
$tpl = new Template($tool_name); |
||||
$tpl->assign('actions', $actions); |
||||
$tpl->assign('message', $message); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
@ -0,0 +1,121 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* This class provides methods for the notebook management. |
||||
* Include/require it in your code to use its features. |
||||
* @package chamilo.library |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
define ('EVENT_EMAIL_TEMPLATE_ACTIVE', 1); |
||||
define ('EVENT_EMAIL_TEMPLATE_INACTIVE',0); |
||||
|
||||
/** |
||||
* @package chamilo.library |
||||
*/ |
||||
class EventEmailTemplate extends Model { |
||||
|
||||
var $table; |
||||
var $columns = array('id', 'message','subject','event_type_name','activated'); |
||||
|
||||
public function __construct() { |
||||
$this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE); |
||||
} |
||||
|
||||
public function get_all($where_conditions = array()) { |
||||
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC')); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Displays the title + grid |
||||
*/ |
||||
public function display() { |
||||
// action links |
||||
$content = Display::actions(array(array('url' => 'event_type.php' , 'content' => get_lang('Add')))); |
||||
$content .= Display::grid_html('event_email_template'); |
||||
return $content; |
||||
} |
||||
|
||||
public function get_status_list() { |
||||
return array(EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enable'), EVENT_EMAIL_TEMPLATE_INACTIVE=> get_lang('Disable')); |
||||
} |
||||
|
||||
/** |
||||
* Returns a Form validator Obj |
||||
* @todo the form should be auto generated |
||||
* @param string url |
||||
* @param string action add, edit |
||||
* @return obj form validator obj |
||||
*/ |
||||
public function return_form($url, $action) { |
||||
|
||||
$oFCKeditor = new FCKeditor('description') ; |
||||
$oFCKeditor->ToolbarSet = 'careers'; |
||||
$oFCKeditor->Width = '100%'; |
||||
$oFCKeditor->Height = '200'; |
||||
$oFCKeditor->Value = ''; |
||||
$oFCKeditor->CreateHtml(); |
||||
|
||||
$form = new FormValidator('career', 'post', $url); |
||||
// Settting the form elements |
||||
$header = get_lang('Add'); |
||||
if ($action == 'edit') { |
||||
$header = get_lang('Modify'); |
||||
} |
||||
|
||||
$form->addElement('header', $header); |
||||
$id = isset($_GET['id']) ? intval($_GET['id']) : ''; |
||||
$form->addElement('hidden', 'id', $id); |
||||
|
||||
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70')); |
||||
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250')); |
||||
$status_list = $this->get_status_list(); |
||||
$form->addElement('select', 'status', get_lang('Status'), $status_list); |
||||
if ($action == 'edit') { |
||||
$form->addElement('text', 'created_at', get_lang('CreatedAt')); |
||||
$form->freeze('created_at'); |
||||
} |
||||
|
||||
if ($action == 'edit') { |
||||
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"'); |
||||
} else { |
||||
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"'); |
||||
} |
||||
|
||||
// Setting the defaults |
||||
$defaults = $this->get($id); |
||||
|
||||
if (!empty($defaults['created_at'])) { |
||||
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']); |
||||
} |
||||
if (!empty($defaults['updated_at'])) { |
||||
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']); |
||||
} |
||||
$form->setDefaults($defaults); |
||||
|
||||
// Setting the rules |
||||
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
||||
return $form; |
||||
} |
||||
|
||||
public function get_count() { |
||||
$row = Database::select('count(*) as count', $this->table, array(),'first'); |
||||
return $row['count']; |
||||
} |
||||
|
||||
/* |
||||
public function save($params) { |
||||
$id = parent::save($params); |
||||
if (!empty($id)) { |
||||
event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
||||
} |
||||
return $id; |
||||
} |
||||
|
||||
public function delete($id) { |
||||
parent::delete($id); |
||||
event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
||||
} */ |
||||
} |
||||
Loading…
Reference in new issue