Beispiel #1
0
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_BLOGS;
/* 	ACCESS RIGHTS */
// notice for unauthorized people.
api_protect_course_script(true);
//session
if (isset($_GET['id_session'])) {
    $_SESSION['id_session'] = intval($_GET['id_session']);
}
$lib_path = api_get_path(LIBRARY_PATH);
require_once $lib_path . 'blog.lib.php';
require_once $lib_path . 'fckeditor/fckeditor.php';
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang('Blogs');
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
$current_page = $_GET['action'];
/*
	PROCESSING
*/
$safe_post_title = Security::remove_XSS($_POST['post_title']);
$safe_post_file_comment = Security::remove_XSS($_POST['post_file_comment']);
$safe_post_full_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['post_full_text'])), COURSEMANAGERLOWSECURITY);
$safe_comment_text = Security::remove_XSS(stripslashes(api_html_entity_decode($_POST['comment_text'])), COURSEMANAGERLOWSECURITY);
$safe_comment_title = Security::remove_XSS($_POST['comment_title']);
$safe_task_name = Security::remove_XSS($_POST['task_name']);
$safe_task_description = Security::remove_XSS($_POST['task_description']);
if (!empty($_POST['new_post_submit']) and !empty($_POST['post_title'])) {
    Blog::create_post($safe_post_title, $safe_post_full_text, $safe_post_file_comment, $blog_id);
    $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded'));
 /**
  * Show some stats about the number of logins
  * @param string $type month, hour or day
  */
 static function print_login_stats($type)
 {
     $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $current_url_id = api_get_current_access_url_id();
     if (api_is_multiple_url_enabled()) {
         $table_url = ", {$access_url_rel_user_table}";
         $where_url = " WHERE login_user_id=user_id AND access_url_id='" . $current_url_id . "'";
         $where_url_last = ' AND login_date > DATE_SUB(NOW(),INTERVAL 1 %s)';
     } else {
         $table_url = '';
         $where_url = '';
         $where_url_last = ' WHERE login_date > DATE_SUB(NOW(),INTERVAL 1 %s)';
     }
     switch ($type) {
         case 'month':
             $months = api_get_months_long();
             $period = get_lang('PeriodMonth');
             $sql = "SELECT DATE_FORMAT( login_date, '%Y-%m' ) AS stat_date , count( login_id ) AS number_of_logins FROM " . $table . $table_url . $where_url . " GROUP BY stat_date ORDER BY login_date ";
             $sql_last_x = "SELECT DATE_FORMAT( login_date, '%Y-%m' ) AS stat_date , count( login_id ) AS number_of_logins FROM " . $table . $table_url . $where_url . sprintf($where_url_last, 'YEAR') . " GROUP BY stat_date ORDER BY login_date ";
             break;
         case 'hour':
             $period = get_lang('PeriodHour');
             $sql = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM " . $table . $table_url . $where_url . " GROUP BY stat_date ORDER BY stat_date ";
             $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM " . $table . $table_url . $where_url . sprintf($where_url_last, 'DAY') . " GROUP BY stat_date ORDER BY stat_date ";
             break;
         case 'day':
             $week_days = api_get_week_days_long();
             $period = get_lang('PeriodDay');
             $sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM " . $table . $table_url . $where_url . " GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) ";
             $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM " . $table . $table_url . $where_url . sprintf($where_url_last, 'WEEK') . " GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) ";
             break;
     }
     $res_last_x = Database::query($sql_last_x);
     $result_last_x = array();
     while ($obj = Database::fetch_object($res_last_x)) {
         $stat_date = $obj->stat_date;
         switch ($type) {
             case 'month':
                 $stat_date = explode('-', $stat_date);
                 $stat_date[1] = $months[$stat_date[1] - 1];
                 $stat_date = implode(' ', $stat_date);
                 break;
             case 'day':
                 $stat_date = $week_days[$stat_date];
                 break;
         }
         $result_last_x[$stat_date] = $obj->number_of_logins;
     }
     Statistics::print_stats(get_lang('LastLogins') . ' (' . $period . ')', $result_last_x, true);
     flush();
     //flush web request at this point to see something already while the full data set is loading
     echo '<br />';
     $res = Database::query($sql);
     $result = array();
     while ($obj = Database::fetch_object($res)) {
         $stat_date = $obj->stat_date;
         switch ($type) {
             case 'month':
                 $stat_date = explode('-', $stat_date);
                 $stat_date[1] = $months[$stat_date[1] - 1];
                 $stat_date = implode(' ', $stat_date);
                 break;
             case 'day':
                 $stat_date = $week_days[$stat_date];
                 break;
         }
         $result[$stat_date] = $obj->number_of_logins;
     }
     Statistics::print_stats(get_lang('AllLogins') . ' (' . $period . ')', $result, true);
 }
Beispiel #3
0
            api_not_allowed(true);
        }
        $extra_field_data = UserManager::get_extra_user_data_by_field(api_get_user_id(), 'google_calendar_url');
        if (!empty($extra_field_data) && isset($extra_field_data['google_calendar_url']) && !empty($extra_field_data['google_calendar_url'])) {
            $tpl->addGlobal('use_google_calendar', 1);
            $tpl->addGlobal('google_calendar_url', $extra_field_data['google_calendar_url']);
        }
        $this_section = SECTION_MYAGENDA;
        if (!api_is_anonymous()) {
            $can_add_events = 1;
        }
        break;
}
//Setting translations
$day_short = api_get_week_days_short();
$days = api_get_week_days_long();
$months = api_get_months_long();
$months_short = api_get_months_short();
//Setting calendar translations
$tpl->addGlobal('month_names', json_encode($months));
$tpl->addGlobal('month_names_short', json_encode($months_short));
$tpl->addGlobal('day_names', json_encode($days));
$tpl->addGlobal('day_names_short', json_encode($day_short));
$tpl->addGlobal('button_text', json_encode(array('today' => get_lang('Today'), 'month' => get_lang('Month'), 'week' => get_lang('Week'), 'day' => get_lang('Day'))));
//see http://docs.jquery.com/UI/Datepicker/$.datepicker.formatDate
$tpl->addGlobal('js_format_date', 'D d M yy');
$region_value = api_get_language_isocode();
if ($region_value == 'en') {
    $region_value = 'en-GB';
}
$tpl->addGlobal('region_value', $region_value);