Пример #1
0
 /**
  * This method is used for thematic plan control (update, insert or listing)
  * @param 	string	$action
  * render to thematic_plan.php
  */
 public function thematic_plan($action)
 {
     $thematic = new Thematic();
     $data = array();
     if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
         if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
             if (isset($_POST['title'])) {
                 if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
                     if (api_is_allowed_to_edit(null, true)) {
                         $title_list = $_REQUEST['title'];
                         $description_list = $_REQUEST['description'];
                         $description_type = $_REQUEST['description_type'];
                         for ($i = 1; $i < count($title_list) + 1; $i++) {
                             $thematic->set_thematic_plan_attributes($_REQUEST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]);
                             $thematic->thematic_plan_save();
                         }
                         unset($_SESSION['thematic_plan_token']);
                         $data['message'] = 'ok';
                         $saveRedirect = api_get_path(WEB_PATH) . 'main/course_progress/index.php?';
                         $saveRedirect .= api_get_cidreq() . '&';
                         $saveRedirect .= 'thematic_plan_save_message=ok';
                         header("Location: {$saveRedirect}");
                         exit;
                     }
                     $data['action'] = 'thematic_plan_list';
                 }
             } else {
                 $error = true;
                 $action = $_POST['action'];
                 $data['error'] = $error;
                 $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
                 $data['thematic_id'] = $_POST['thematic_id'];
                 $data['description_type'] = $_POST['description_type'];
                 $data['action'] = $action;
                 $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
                 $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
                 $data['default_thematic_plan_question'] = $thematic->get_default_question();
                 $data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']);
                 // render to the view
                 $this->view->set_data($data);
                 $this->view->set_layout('layout');
                 $this->view->set_template('thematic_plan');
                 $this->view->render();
             }
         }
     }
     $thematic_id = intval($_GET['thematic_id']);
     if ($action == 'thematic_plan_list') {
         $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
     }
     $description_type = isset($_GET['description_type']) ? intval($_GET['description_type']) : null;
     if (!empty($thematic_id) && !empty($description_type)) {
         if ($action == 'thematic_plan_delete') {
             if (api_is_allowed_to_edit(null, true)) {
                 $thematic->thematic_plan_destroy($thematic_id, $description_type);
             }
             $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
             $action = 'thematic_plan_list';
         } else {
             $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type);
         }
         $data['thematic_id'] = $thematic_id;
         $data['description_type'] = $description_type;
     } else {
         if (!empty($thematic_id) && $action == 'thematic_plan_list') {
             $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
             $data['thematic_id'] = $thematic_id;
         }
     }
     $data['thematic_id'] = $thematic_id;
     $data['action'] = $action;
     $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
     $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
     $data['next_description_type'] = $thematic->get_next_description_type($thematic_id);
     $data['default_thematic_plan_question'] = $thematic->get_default_question();
     $data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
     //render to the view
     $this->view->set_data($data);
     $this->view->set_layout('layout');
     $this->view->set_template('thematic_plan');
     $this->view->render();
     exit;
 }
Пример #2
0
}
// get thematic plan description type
if (isset($_GET['description_type'])) {
    $description_type = intval($_GET['description_type']);
}
$courseInfo = api_get_course_info();
// instance thematic object for using like library here
$thematic = new Thematic($courseInfo);
// thematic controller object
$thematic_controller = new ThematicController();
if (!empty($thematic_id)) {
    // thematic data by id
    $thematic_data = $thematic->get_thematic_list($thematic_id);
}
// get default thematic plan title
$default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
// Only when I see the 3 columns. Avoids double or triple click binding for onclick event
$htmlHeadXtra[] = '<script type="text/javascript">

$(document).ready(function() {

	//Second col
     /*
    $("#thematic_plan_add").live("submit", function() {

		var serialize_form_content = $(this).serialize();

		//Getting FCK content
		var oEditor = FCKeditorAPI.GetInstance("description[1]");
		content_1=  oEditor.GetXHTML(true) ;
		var oEditor = FCKeditorAPI.GetInstance("description[2]");
 /**
  * This method is used for thematic plan control (update, insert or listing)
  * @param 	string	Action
  * render to thematic_plan.php
  */
 public function thematic_plan($action)
 {
     $courseInfo = api_get_course_info();
     $thematic = new Thematic($courseInfo);
     $data = array();
     $error = false;
     if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
         if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
             if (isset($_POST['title'])) {
                 if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
                     if (api_is_allowed_to_edit(null, true)) {
                         $title_list = $_REQUEST['title'];
                         $description_list = $_REQUEST['description'];
                         $description_type = $_REQUEST['description_type'];
                         $delete_list = $_REQUEST['delete'];
                         foreach ($title_list as $id => $title) {
                             $thematic_plan_id = $id;
                             if (!$thematic->get_thematic_data_by_id($id)) {
                                 $thematic_plan_id = null;
                             }
                             $thematic->set_thematic_plan_attributes($_REQUEST['thematic_id'], $title, $description_list[$id], $description_type[$id], $thematic_plan_id);
                             if (isset($delete_list[$id]) && !empty($delete_list[$id])) {
                                 $thematic->thematic_plan_delete();
                             } else {
                                 $affected_rows = $thematic->thematic_plan_save();
                             }
                         }
                         unset($_SESSION['thematic_plan_token']);
                         $data['message'] = 'ok';
                     }
                     $data['action'] = 'thematic_plan_list';
                 }
             } else {
                 $error = true;
                 $action = $_POST['action'];
                 $data['error'] = $error;
                 $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
                 $data['thematic_id'] = $_POST['thematic_id'];
                 $data['description_type'] = $_POST['description_type'];
                 $data['action'] = $action;
                 $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
                 $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
                 $data['default_thematic_plan_question'] = $thematic->get_default_question();
                 $data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']);
                 // render to the view
                 $this->view->set_data($data);
                 $this->view->set_layout('layout');
                 $this->view->set_template('thematic_plan');
                 $this->view->render();
             }
         }
     }
     $thematic_id = intval($_GET['thematic_id']);
     if ($action == 'thematic_plan_list') {
         $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
     }
     $description_type = intval($_GET['description_type']);
     if (!empty($thematic_id) && !empty($description_type)) {
         if ($action == 'thematic_plan_delete') {
             if (api_is_allowed_to_edit(null, true)) {
                 $affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type);
             }
             $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
             $action = 'thematic_plan_list';
         } else {
             $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type);
         }
         $data['thematic_id'] = $thematic_id;
         $data['description_type'] = $description_type;
     } else {
         if (!empty($thematic_id) && $action == 'thematic_plan_list') {
             $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
             $data['thematic_id'] = $thematic_id;
         }
     }
     $data['thematic_id'] = $thematic_id;
     $data['action'] = $action;
     $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
     $data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
     $data['next_description_type'] = $thematic->get_next_description_type($thematic_id);
     $data['default_thematic_plan_question'] = $thematic->get_default_question();
     $data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
     //render to the view
     $this->view->set_data($data);
     $this->view->set_layout('layout');
     $this->view->set_template('thematic_plan');
     $this->view->render();
     exit;
 }