Fix ticket plugin

remotes/angel/1.11.x
jmontoyaa 9 years ago
parent c711048026
commit 02497755d1
  1. 28
      main/admin/configure_plugin.php
  2. 14
      main/inc/lib/api.lib.php
  3. 10
      main/inc/lib/plugin.class.php
  4. 3
      main/inc/lib/plugin.lib.php
  5. 5
      plugin/ticket/src/categories.php
  6. 5
      plugin/ticket/src/myticket.php
  7. 63
      plugin/ticket/src/ticket.class.php
  8. 6
      plugin/ticket/src/ticket_details.php
  9. 11
      plugin/vchamilo/index.php
  10. 2
      plugin/vchamilo/plugin.php

@ -25,17 +25,23 @@ if (!in_array($pluginName, $installedPlugins) || empty($pluginInfo)) {
global $_configuration;
$message = null;
$content = null;
$message = '';
$content = '';
$currentUrl = api_get_self() . "?name=$pluginName";
if (isset($pluginInfo['settings_form'])) {
/** @var FormValidator $form */
$form = $pluginInfo['settings_form'];
if (isset($form)) {
// We override the form attributes
$attributes = array('action' => $currentUrl, 'method' => 'POST');
$form->updateAttributes($attributes);
if (isset($pluginInfo['settings'])) {
$form->setDefaults($pluginInfo['settings']);
}
$content = Display::page_header($pluginInfo['title']);
$content .= $form->toHtml();
}
@ -46,8 +52,6 @@ if (isset($pluginInfo['settings_form'])) {
if (isset($form)) {
if ($form->validate()) {
$values = $form->exportValues();
//api_delete_category_settings_by_subkey($pluginName);
$accessUrlId = api_get_current_access_url_id();
api_delete_settings_params(
@ -64,7 +68,8 @@ if (isset($form)) {
foreach ($values as $key => $value) {
api_add_setting(
$value, Database::escape_string($pluginName . '_' . $key),
$value,
Database::escape_string($pluginName . '_' . $key),
$pluginName,
'setting',
'Plugins',
@ -76,28 +81,23 @@ if (isset($form)) {
1
);
}
if (isset($values['show_main_menu_tab'])) {
$objPlugin = $pluginInfo['plugin_class']::create();
$objPlugin->manageTab($values['show_main_menu_tab']);
}
$message = Display::return_message(get_lang('Updated'), 'success');
Session::write('message', $message);
Display::addFlash(Display::return_message(get_lang('Updated'), 'success'));
header("Location: $currentUrl");
exit;
} else {
foreach ($form->_errors as $error) {
$message .= Display::return_message($error, 'error');
Display::addFlash(Display::return_message($error, 'error'));
}
}
}
if (Session::has('message')) {
$message = Session::read('message');
}
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH) . 'admin/index.php',
'name' => get_lang('PlatformAdmin')
@ -108,7 +108,7 @@ $interbreadcrumb[] = array(
);
$tpl = new Template($pluginName, true, true, false, true, false);
$tpl->assign('message', $message);
$tpl->assign('message', '');
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -5274,7 +5274,19 @@ function api_delete_category_settings_by_subkey($subkey, $access_url_id = 1) {
* @param string $c
* @return boolean true on success, false on failure
*/
function api_add_setting($val, $var, $sk = null, $type = 'textfield', $c = null, $title = '', $com = '', $sc = null, $skt = null, $a = 1, $v = 0) {
function api_add_setting(
$val,
$var,
$sk = null,
$type = 'textfield',
$c = null,
$title = '',
$com = '',
$sc = null,
$skt = null,
$a = 1,
$v = 0
) {
if (empty($var) || !isset($val)) { return false; }
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$var = Database::escape_string($var);

@ -81,8 +81,10 @@ class Plugin
if ($form = $this->get_settings_form()) {
$result['settings_form'] = $form;
foreach ($this->fields as $name => $type) {
$value = $this->get($name);
if (is_array($type)) {
$value = $type['options'];
}
@ -183,13 +185,12 @@ class Plugin
foreach ($this->fields as $name => $type) {
$options = null;
if (is_array($type) && isset($type['type']) && $type['type'] === "select") {
if (is_array($type) && isset($type['type']) && $type['type'] === 'select') {
$options = $type['options'];
$type = $type['type'];
}
$value = $this->get($name);
$defaults[$name] = $value;
$type = isset($type) ? $type : 'text';
@ -267,7 +268,8 @@ class Plugin
{
$settings = $this->get_settings();
foreach ($settings as $setting) {
if ($setting['variable'] == ($this->get_name() . '_' . $name)) {
if ($setting['variable'] == $this->get_name() . '_' . $name) {
return $setting['selected_value'];
}
}
@ -281,7 +283,7 @@ class Plugin
*/
public function get_settings()
{
if (is_null($this->settings)) {
if (empty($this->settings)) {
$settings = api_get_settings_params(
array(
"subkey = ? AND category = ? AND type = ? " => array($this->get_name(), 'Plugins', 'setting')

@ -421,12 +421,13 @@ class AppPlugin
require $plugin_file;
}
//extra options
// Extra options
$plugin_settings = api_get_settings_params(
array(
"subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting')
)
);
$settings_filtered = array();
foreach ($plugin_settings as $item) {
$settings_filtered[$item['variable']] = $item['selected_value'];

@ -63,7 +63,10 @@ if (isset($_GET['action'])) {
'description' => $values['description'],
'total_tickets' => 0,
'sys_insert_user_id' => api_get_user_id(),
'sys_insert_datetime' => api_get_utc_datetime()
'sys_insert_datetime' => api_get_utc_datetime(),
'category_id' => 0,
'project_id' => 0,
'course_required' => ''
];
TicketManager::addCategory($params);

@ -227,6 +227,11 @@ if ($isAdmin) {
);
}
echo Display::url(
Display::return_icon('settings.png'),
api_get_path(WEB_CODE_PATH) . 'admin/configure_plugin.php?name=ticket'
);
echo '</span>';
}

@ -127,7 +127,6 @@ class TicketManager
}
/**
* @param int $id
* @param array $params
*/
public static function addCategory($params)
@ -185,7 +184,8 @@ class TicketManager
$table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
$userId = intval($userId);
$categoryId = intval($categoryId);
$sql = "SELECT * FROM $table WHERE category_id = $categoryId AND user_id = $userId";
$sql = "SELECT * FROM $table
WHERE category_id = $categoryId AND user_id = $userId";
$result = Database::query($sql);
return Database::num_rows($result) > 0;
@ -516,6 +516,7 @@ class TicketManager
$ticket_id, get_lang('MessageResent'), $studentMessage, null, 1
);
}
return true;
} else {
@ -525,6 +526,7 @@ class TicketManager
/**
* Assign ticket to admin
*
* @param int $ticket_id
* @param int $user_id
*/
@ -635,21 +637,18 @@ class TicketManager
) {
global $data_files, $plugin;
$ticket_id = intval($ticket_id);
$subject = Database::escape_string($subject);
$content = Database::escape_string($content);
$user_id = intval($user_id);
$status = Database::escape_string($status);
$table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
if ($sendConfirmation) {
$form = '<form action="ticket_details.php?ticket_id=' . $ticket_id . '" id="confirmticket" method="POST" >
<p>' . $plugin->get_lang('TicketWasThisAnswerSatisfying') . '</p>
<button name="response" id="responseyes" value="1">' . get_lang('Yes') . '</button>
<button name="response" id="responseno" value="0">' . get_lang('No') . '</button>
<button class="btn btn-primary responseyes" name="response" id="responseyes" value="1">' . get_lang('Yes') . '</button>
<button class="btn btn-danger responseno" name="response" id="responseno" value="0">' . get_lang('No') . '</button>
</form>';
$content .= $form;
Database::query(
"UPDATE $table_support_tickets
SET status_id = '".self::STATUS_UNCONFIRMED."'
@ -658,52 +657,42 @@ class TicketManager
}
$sql = "SELECT COUNT(*) as total_messages
FROM $table_support_messages
WHERE ticket_id ='$ticket_id'";
WHERE ticket_id = $ticket_id";
$result = Database::query($sql);
$obj = Database::fetch_object($result);
$message_id = $obj->total_messages + 1;
$now = api_get_utc_datetime();
// insert msg
$sql = "INSERT INTO $table_support_messages (
ticket_id,
message_id,
subject,
message,
ip_address,
sys_insert_user_id,
sys_insert_datetime,
sys_lastedit_user_id,
sys_lastedit_datetime,
status
) VALUES (
'$ticket_id',
'$message_id',
'$subject',
'$content',
'" . Database::escape_string($_SERVER['REMOTE_ADDR']) . "',
'$user_id',
'" . $now . "',
'$user_id',
'" . $now . "',
'$status'
)";
Database::query($sql);
$params = [
'ticket_id' => $ticket_id,
'message_id' => $message_id,
'subject' => $subject,
'message' => $content,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'sys_insert_user_id' => $user_id,
'sys_insert_datetime' => $now,
'sys_lastedit_user_id' => $user_id,
'sys_lastedit_datetime' => $now,
'status' => $status
];
Database::insert($table_support_messages, $params);
// update_total_message
$sql = "UPDATE $table_support_tickets
SET sys_lastedit_user_id ='$user_id',
SET
sys_lastedit_user_id ='$user_id',
sys_lastedit_datetime ='$now',
total_messages = (
SELECT COUNT(*) as total_messages
FROM $table_support_messages
WHERE ticket_id ='$ticket_id'
)
WHERE ticket_id ='$ticket_id' ";
WHERE ticket_id = $ticket_id ";
Database::query($sql);
$sql = "SELECT COUNT(*) as total_attach
FROM $table_support_message_attachments
WHERE ticket_id ='$ticket_id' AND message_id = '$message_id'";
WHERE ticket_id = $ticket_id AND message_id = $message_id";
$result = Database::query($sql);
$obj = Database::fetch_object($result);

@ -17,10 +17,10 @@ $interbreadcrumb[] = array('url' => 'myticket.php', 'name' => $plugin->get_lang(
$interbreadcrumb[] = array('url' => '#', 'name' => $plugin->get_lang('TicketDetail'));
$disableReponseButtons = '';
if ($isAdmin) {
/*if ($isAdmin) {
$disableReponseButtons = "$('#responseyes').attr('disabled', 'disabled');
$('#responseno').attr('disabled', 'disabled');";
}
}*/
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
@ -43,7 +43,7 @@ $(document).ready(function() {
$( "#dialog-form" ).dialog( "open" );
});
$("input#responseyes").click(function () {
$(".responseyes").click(function () {
if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. ' . $plugin->get_lang('IfYouAreSureTheTicketWillBeClosed') . '")){
return false;
}

@ -18,15 +18,7 @@ $_template['show_message'] = true;
$_template['title'] = $plugininstance->get_lang('hostlist');
$tablename = Database::get_main_table('vchamilo');
$sql = "
SELECT
sitename,
root_web
FROM
$tablename
WHERE
visible = 1
";
$sql = "SELECT sitename, root_web FROM $tablename WHERE visible = 1";
if ($virtualChamilo == '%'){
$result = Database::query($sql);
@ -36,5 +28,4 @@ if ($virtualChamilo == '%'){
$_template['hosts'][] = $vchamilo;
}
}
} else {
}

@ -59,7 +59,7 @@ $wwwroot = $_configuration['root_web'];
//A simple select
$options = array(0 => $plugininstance->get_lang('no'), 1 => $plugininstance->get_lang('yes'));
$form->addlabel('', '<a class="btn btn-primary" href="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php">'.
$form->addLabel('', '<a class="btn btn-primary" href="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php">'.
$plugininstance->get_lang('manage_instances').'</a>');
$form->addElement('header', $plugininstance->get_lang('enabling'));
$form->addElement('select', 'enable_virtualisation', $plugininstance->get_lang('enable_virtualisation'), $options);

Loading…
Cancel
Save