}
     }
     event_system(LOG_HOMEPAGE_CHANGED, 'edit_news', strip_tags(Text::cut($home_news, 254)), api_get_utc_datetime(), api_get_user_id());
     break;
 case 'insert_tabs':
 case 'edit_tabs':
 case 'insert_link':
 case 'edit_link':
     $link_index = intval($_POST['link_index']);
     $insert_where = intval($_POST['insert_where']);
     $link_name = trim(stripslashes($_POST['link_name']));
     $link_url = trim(stripslashes($_POST['link_url']));
     $add_in_tab = intval($_POST['add_in_tab']);
     // WCAG
     if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
         $link_html = WCAG_Rendering::prepareXHTML();
     } else {
         $link_html = trim(stripslashes($_POST['link_html']));
     }
     $filename = trim(stripslashes($_POST['filename']));
     $target_blank = $_POST['target_blank'] ? true : false;
     if ($link_url == 'http://' || $link_url == 'https://') {
         $link_url = '';
     } elseif (!empty($link_url) && !strstr($link_url, '://')) {
         $link_url = 'http://' . $link_url;
     }
     $menuf = $action == 'insert_tabs' || $action == 'edit_tabs' ? $menutabs : $menuf;
     if (!is_writable($homePath . $menuf . '_' . $lang . $ext)) {
         $errorMsg = get_lang('HomePageFilesNotWritable');
     } elseif (empty($link_name)) {
         $errorMsg = get_lang('PleaseEnterLinkName');
 /**
  * It's used for adding a course description,
  * render to listing or add view
  */
 public function add()
 {
     $course_description = new CourseDescription();
     $session_id = api_get_session_id();
     $course_description->set_session_id($session_id);
     $data = array();
     if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
         if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
             $check = Security::check_token();
             if ($check) {
                 $title = $_POST['title'];
                 if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
                     $content = WCAG_Rendering::prepareXHTML();
                 } else {
                     $content = $_POST['contentDescription'];
                 }
                 $description_type = $_POST['description_type'];
                 if ($description_type >= ADD_BLOCK) {
                     $course_description->set_description_type($description_type);
                     $course_description->set_title($title);
                     $course_description->set_content($content);
                     $affected_rows = $course_description->insert(api_get_course_int_id());
                 }
                 Security::clear_token();
             }
             if ($affected_rows) {
                 $message['add'] = true;
             }
             $this->listing(false, $message);
         } else {
             $data['error'] = 1;
             $data['default_description_titles'] = $course_description->get_default_description_title();
             $data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
             $data['default_description_icon'] = $course_description->get_default_description_icon();
             $data['question'] = $course_description->get_default_question();
             $data['information'] = $course_description->get_default_information();
             $data['description_title'] = $_POST['title'];
             $data['description_content'] = $_POST['contentDescription'];
             $data['description_type'] = $_POST['description_type'];
             $this->view->set_data($data);
             $this->view->set_layout('layout');
             $this->view->set_template('add');
             $this->view->render();
         }
     } else {
         $data['default_description_titles'] = $course_description->get_default_description_title();
         $data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
         $data['default_description_icon'] = $course_description->get_default_description_icon();
         $data['question'] = $course_description->get_default_question();
         $data['information'] = $course_description->get_default_information();
         $data['description_type'] = $course_description->get_max_description_type();
         // render to the view
         $this->view->set_data($data);
         $this->view->set_layout('layout');
         $this->view->set_template('add');
         $this->view->render();
     }
 }
        if (!file_exists($homep . $my_file . '_' . $lang . $ext)) {
            copy($homep . $my_file . $ext, $homep . $my_file . '_' . $lang . $ext);
        }
    }
}
if (!empty($homep_new)) {
    $homep = $homep_new;
}
if (!empty($action)) {
    if (isset($_POST['formSent']) && $_POST['formSent']) {
        switch ($action) {
            case 'edit_top':
                // Filter
                $home_top = '';
                if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
                    $home_top = WCAG_Rendering::prepareXHTML();
                } else {
                    $home_top = trim(stripslashes($_POST['register_top']));
                }
                // Write
                if (file_exists($homep . $topf . '_' . $lang . $ext)) {
                    if (is_writable($homep . $topf . '_' . $lang . $ext)) {
                        $fp = fopen($homep . $topf . '_' . $lang . $ext, 'w');
                        fputs($fp, $home_top);
                        fclose($fp);
                    } else {
                        $errorMsg = get_lang('HomePageFilesNotWritable');
                    }
                } else {
                    //File does not exist
                    $fp = fopen($homep . $topf . '_' . $lang . $ext, 'w');