Remove timeline code

pull/3996/head
Julio 4 years ago
parent cff4a2ba56
commit d7796fe283
  1. 50
      public/main/inc/ajax/model.ajax.php
  2. 15
      public/main/inc/ajax/timeline.ajax.php
  3. 157
      public/main/timeline/index.php
  4. 18
      public/main/timeline/insert.sql
  5. 33
      public/main/timeline/view.php

@ -55,7 +55,6 @@ if (!in_array(
'get_work_user_list_others',
'get_work_user_list_all',
'get_work_pending_list',
'get_timelines',
'get_user_skill_ranking',
'get_usergroups',
'get_usergroups_teacher',
@ -923,10 +922,6 @@ switch ($action) {
$obj = new ExtraFieldOption($type);
$count = $obj->get_count_by_field_id($field_id);
break;
case 'get_timelines':
$obj = new Timeline();
$count = $obj->get_count();
break;
case 'get_gradebooks':
$obj = new Gradebook();
$count = $obj->get_count();
@ -2203,51 +2198,6 @@ switch ($action) {
]
);
break;
case 'get_timelines':
$columns = ['headline', 'actions'];
if (!in_array($sidx, $columns)) {
$sidx = 'headline';
}
$sidx = in_array($sidx, $columns) ? $sidx : 'headline';
$course_id = api_get_course_int_id();
$result = Database::select(
'*',
$obj->table,
[
'where' => [
'parent_id = ? AND c_id = ?' => ['0', $course_id],
],
'order' => "$sidx $sord",
'LIMIT' => "$start , $limit",
]
);
$new_result = [];
foreach ($result as $item) {
if (!$item['status']) {
$item['name'] = '<font style="color:#AAA">'.$item['name'].'</font>';
}
$item['headline'] = Display::url(
$item['headline'],
api_get_path(WEB_CODE_PATH).'timeline/view.php?id='.$item['id']
);
$item['actions'] = Display::url(
Display::return_icon('add.png', get_lang('Add items')),
api_get_path(WEB_CODE_PATH).'timeline/?action=add_item&parent_id='.$item['id']
);
$item['actions'] .= Display::url(
Display::return_icon('edit.png', get_lang('Edit')),
api_get_path(WEB_CODE_PATH).'timeline/?action=edit&id='.$item['id']
);
$item['actions'] .= Display::url(
Display::return_icon('delete.png', get_lang('Delete')),
api_get_path(WEB_CODE_PATH).'timeline/?action=delete&id='.$item['id']
);
$new_result[] = $item;
}
$result = $new_result;
break;
case 'get_gradebooks':
$columns = ['name', 'certificates', 'skills', 'actions', 'has_certificates'];
if (!in_array($sidx, $columns)) {

@ -1,15 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../global.inc.php';
$timeline = new Timeline();
$action = $_GET['a'];
switch ($action) {
case 'get_timeline_content':
$items = $timeline->get_timeline_content($_GET['id']);
echo json_encode($items);
break;
}

@ -1,157 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2011
*/
require_once __DIR__.'/../inc/global.inc.php';
$htmlHeadXtra[] = api_get_jqgrid_js();
//$htmlHeadXtra[] = api_get_js('timeline/timeline-min.js');
//$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/timeline/timeline.css');
// setting breadcrumbs
//$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('Administration'));
//$interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('Careers and promotions'));
$action = isset($_GET['action']) ? $_GET['action'] : null;
$check = Security::check_token('request');
$token = Security::get_token();
$actions = '';
$message = '';
switch ($action) {
case 'add':
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')];
break;
case 'edit':
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
break;
case 'add_item':
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Item')];
break;
default:
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Timeline')];
}
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_timelines';
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = [get_lang('Name'), get_lang('Detail')];
//Column config
$column_model = [
['name' => 'name', 'index' => 'name', 'width' => '120', 'align' => 'left'],
['name' => 'actions', 'index' => 'actions', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
];
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//With this function we can add actions to the jgrid (edit, delete, etc)
$htmlHeadXtra[] = '
<script>
$(function() {
// grid definition see the $timeline->display() function
'.Display::grid_js('timelines', $url, $columns, $column_model, $extra_params, [], null, true).'
});
</script>';
$toolbarAction = '';
$timeline = new Timeline();
// Action handling: Add
switch ($action) {
case 'add':
if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']);
$form = $timeline->return_form($url, 'add');
// The validation or display
if ($form->validate()) {
if ($check) {
$values = $form->exportValues();
$res = $timeline->save($values);
if ($res) {
$message = Display::return_message(get_lang('Item added'), 'success');
}
}
$content = $timeline->listing();
} else {
$actions .= '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]);
$content = $form->return_form();
}
break;
case 'edit':
// Action handling: Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$form = $timeline->return_form($url, 'edit');
// The validation or display
if ($form->validate()) {
if ($check) {
$values = $form->exportValues();
//$timeline->update_all_promotion_status_by_career_id($values['id'],$values['status']);
$res = $timeline->update($values);
$message = Display::return_message(sprintf(get_lang('Item updated'), $values['name']), 'confirmation');
}
$timeline->display();
} else {
$actions = '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]);
$content = $form->return_form();
}
break;
case 'add_item':
// Action handling: Editing
$url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&parent_id='.intval($_GET['parent_id']);
$form = $timeline->return_item_form($url, 'edit');
// The validation or display
if ($form->validate()) {
if ($check) {
$values = $form->exportValues();
$values['type'] = '';
//$timeline->update_all_promotion_status_by_career_id($values['id'],$values['status']);
$res = $timeline->save_item($values);
$message = Display::return_message(sprintf(get_lang('Item updated'), $values['name']), 'confirmation');
}
$timeline->display();
} else {
$actions = '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]);
$content = $form->return_form();
}
break;
case 'delete':
// Action handling: delete
if ($check) {
$res = $timeline->delete($_GET['id']);
if ($res) {
$message = Display::return_message(get_lang('Item deleted'), 'success');
}
}
$content = $timeline->listing();
break;
default:
$content = $timeline->listing();
break;
}
$tpl = new Template();
$tpl->assign('actions', $actions);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -1,18 +0,0 @@
-- Insert this in your Chamilo 1.9 Database
CREATE TABLE c_timeline (
id INTEGER NOT NULL AUTO_INCREMENT,
c_id INTEGER NOT NULL,
headline VARCHAR(255) NOT NULL,
type VARCHAR(255) NOT NULL,
start_date VARCHAR(255) NOT NULL,
end_date VARCHAR(255) NOT NULL,
text VARCHAR(255) NOT NULL,
media VARCHAR(255) NOT NULL,
media_credit VARCHAR(255) NOT NULL,
media_caption VARCHAR(255) NOT NULL,
title_slide VARCHAR(255) NOT NULL,
parent_id INTEGER DEFAULT 0 NOT NULL,
status INTEGER NOT NULL,
PRIMARY KEY (id, c_id)
);

@ -1,33 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
@author Julio Montoya <gugli100@gmail.com> BeezNest 2011
*/
require_once __DIR__.'/../inc/global.inc.php';
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')];
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Listing')];
$timeline = new Timeline();
if (empty($_GET['id'])) {
api_not_allowed();
}
$url = $timeline->get_url($_GET['id']);
$item = $timeline->get($_GET['id']);
$interbreadcrumb[] = ['url' => '#', 'name' => $item['headline']];
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/timeline/timeline.css');
$htmlHeadXtra[] = api_get_js('timeline/timeline-min.js');
$htmlHeadXtra[] = '
<script>
$(function() {
var timeline = new VMM.Timeline();
timeline.init("'.$url.'");
});
</script>';
$content = '<div class="timeline-example"><div id="timeline"></div></div>';
$tpl = new Template($tool_name);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
Loading…
Cancel
Save