Version 15.42.1

This commit is contained in:
Antonio Cañas Vargas 2015-11-21 21:00:18 +01:00
parent 0936bb7bc2
commit a875a3fc59
6 changed files with 24 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -619,7 +619,7 @@ function disableDetailedClicks() {
/************************ Draw an academic calendar **************************/
/*****************************************************************************/
function Cal_DrawCalendar (id,Sunday,TimeUTC,CurrentPlcCod,PrintView,
function Cal_DrawCalendar (id,FirstDayOfWeek,TimeUTC,CurrentPlcCod,PrintView,
CGI,FormGoToCalendarParams,FormEventParams) {
var StartingMonth = [ // Calendar starts one row before current month
9, // January --> September
@ -662,7 +662,7 @@ function Cal_DrawCalendar (id,Sunday,TimeUTC,CurrentPlcCod,PrintView,
MonthId = id + '_month_' + MonthIdNum;
Gbl_HTMLContent += '<td class="CENTER_TOP" style="width:150px;">';
DrawMonth (MonthId,Sunday,Year,Month,CurrentMonth,CurrentDay,
DrawMonth (MonthId,FirstDayOfWeek,Year,Month,CurrentMonth,CurrentDay,
CurrentPlcCod,true,PrintView,CGI,
FormGoToCalendarParams,FormEventParams);
Gbl_HTMLContent += '</td>';
@ -682,7 +682,7 @@ function Cal_DrawCalendar (id,Sunday,TimeUTC,CurrentPlcCod,PrintView,
/***************************** Draw current month ****************************/
/*****************************************************************************/
function DrawCurrentMonth (id,Sunday,TimeUTC,CurrentPlcCod,
function DrawCurrentMonth (id,FirstDayOfWeek,TimeUTC,CurrentPlcCod,
CGI,FormGoToCalendarParams,FormEventParams) {
var d = new Date;
d.setTime(TimeUTC * 1000);
@ -690,7 +690,7 @@ function DrawCurrentMonth (id,Sunday,TimeUTC,CurrentPlcCod,
var Month = d.getMonth() + 1;
var CurrentDay = d.getDate();
DrawMonth (id,Sunday,Year,Month,Month,CurrentDay,
DrawMonth (id,FirstDayOfWeek,Year,Month,Month,CurrentDay,
CurrentPlcCod,false,false,
CGI,FormGoToCalendarParams,FormEventParams);
document.getElementById(id).innerHTML = Gbl_HTMLContent;
@ -699,10 +699,10 @@ function DrawCurrentMonth (id,Sunday,TimeUTC,CurrentPlcCod,
/*****************************************************************************/
/******************************* Draw a month ********************************/
/*****************************************************************************/
// Sunday == 0 ==> Sunday is the first day of the week
// Sunday == 6 ==> Sunday is the last day of the week
// FirstDayOfWeek == 0 (monday) <==> Sunday is the last day of the week
// FirstDayOfWeek == 6 (sunday) <==> Sunday is the first day of the week
function DrawMonth (id,Sunday,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,
function DrawMonth (id,FirstDayOfWeek,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,
CurrentPlcCod,DrawingCalendar,PrintView,
CGI,FormGoToCalendarParams,FormEventParams) {
var NumDaysMonth = [
@ -750,7 +750,7 @@ function DrawMonth (id,Sunday,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,
If it's 0 then write 1 box of the previous month.
If it's 1 then write 0 boxes of the previous month. */
if ((DayOfWeek = (GetDayOfWeekMondayFirst (Yea,Mon,1) + Sunday + 1) % 7) == 0)
if ((DayOfWeek = (GetDayOfWeekMondayFirst (Yea,Mon,1) - FirstDayOfWeek) % 7) == 0)
Day = 1;
else {
if (Mon <= 1) {
@ -787,10 +787,10 @@ function DrawMonth (id,Sunday,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,
Gbl_HTMLContent += '<table class="MONTH_TABLE_DAYS">' + '<tr>';
for (DayOfWeek = 0; DayOfWeek < 7; DayOfWeek++)
Gbl_HTMLContent += '<td class="' +
((DayOfWeek == Sunday) ? 'DAY_NO_WRK_HEAD' :
'DAY_WRK_HEAD') +
((DayOfWeek == 6 - FirstDayOfWeek) ? 'DAY_NO_WRK_HEAD' :
'DAY_WRK_HEAD') +
'">' +
DAYS_CAPS[(DayOfWeek + 6 - Sunday) % 7] +
DAYS_CAPS[(DayOfWeek + FirstDayOfWeek) % 7] +
'</td>';
Gbl_HTMLContent += '</tr>';
@ -840,7 +840,7 @@ function DrawMonth (id,Sunday,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,
}
/* Day being drawn is sunday? */
if (DayOfWeek == Sunday) // All the sundays are holidays
if (DayOfWeek == 6 - FirstDayOfWeek) // All the sundays are holidays
ClassForDay = (Mon == MonthToDraw) ? 'DAY_HLD' :
'DAY_HLD_LIGHT';

View File

@ -149,7 +149,6 @@ void Cal_DrawCurrentMonth (void)
{
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
char Params[256+256+Ses_LENGTH_SESSION_ID+256];
unsigned Sunday = 6;
/***** Get list of holidays *****/
if (!Gbl.Hlds.LstIsRead)
@ -170,7 +169,7 @@ void Cal_DrawCurrentMonth (void)
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
" Gbl_HTMLContent = '';"
" DrawCurrentMonth ('CurrentMonth',%u,%ld,%ld,'%s/%s',",
Sunday,
Gbl.Prefs.FirstDayOfWeek,
(long) Gbl.StartExecutionTimeUTC,
Gbl.CurrentCtr.Ctr.PlcCod,
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language]);
@ -207,11 +206,9 @@ void Cal_DrawCurrentMonth (void)
void Cal_DrawCalendar (void)
{
extern const char *Txt_Print;
bool PrintView = (Gbl.CurrentAct == ActPrnCal);
unsigned Sunday = 6;
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
char Params[256+256+Ses_LENGTH_SESSION_ID+256];
bool PrintView = (Gbl.CurrentAct == ActPrnCal);
/***** Get list of holidays *****/
if (!Gbl.Hlds.LstIsRead)
@ -248,7 +245,7 @@ void Cal_DrawCalendar (void)
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
" Gbl_HTMLContent = '';"
" Cal_DrawCalendar('calendar',%u,%ld,%ld,%s,'%s/%s',",
Sunday,
Gbl.Prefs.FirstDayOfWeek,
(long) Gbl.StartExecutionTimeUTC,
Gbl.CurrentCtr.Ctr.PlcCod,
(Gbl.CurrentAct == ActPrnCal) ? "true" :

View File

@ -111,11 +111,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.42 (2015/11/21)"
#define Log_PLATFORM_VERSION "SWAD 15.42.1 (2015/11/21)"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
Version 15.42.1: Nov 21, 2015 Calendar is drawn depending on user's preference about first day of the week. (187523 lines)
Version 15.42: Nov 21, 2015 New option in preferences to select first day of the week. (187520 lines)
3 changes necessary in database:
ALTER TABLE IP_prefs ADD COLUMN FirstDayOfWeek TINYINT NOT NULL DEFAULT 0 AFTER LastChange;

View File

@ -2374,6 +2374,13 @@ static void Usr_SetUsrRoleAndPrefs (void)
// In this point I am logged
/***** Set preferences from my preferences *****/
Gbl.Prefs.FirstDayOfWeek = Gbl.Usrs.Me.UsrDat.Prefs.FirstDayOfWeek;
Gbl.Prefs.Layout = Gbl.Usrs.Me.UsrDat.Prefs.Layout;
// TODO: Should layout depend on session instead of user prefs?
// (for example, one user with two sessions with different layouts)
Gbl.Prefs.Menu = Gbl.Usrs.Me.UsrDat.Prefs.Menu;
Gbl.Prefs.SideCols = Gbl.Usrs.Me.UsrDat.Prefs.SideCols;
Gbl.Prefs.Theme = Gbl.Usrs.Me.UsrDat.Prefs.Theme;
sprintf (Gbl.Prefs.PathTheme,"%s/%s/%s",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_THEMES,
@ -2384,9 +2391,6 @@ static void Usr_SetUsrRoleAndPrefs (void)
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_ICON_SETS,
Ico_IconSetId[Gbl.Prefs.IconSet]);
Gbl.Prefs.Menu = Gbl.Usrs.Me.UsrDat.Prefs.Menu;
Gbl.Prefs.SideCols = Gbl.Usrs.Me.UsrDat.Prefs.SideCols;
/***** Get my last data *****/
Usr_GetMyLastData ();
if (Gbl.CurrentAct == ActAutUsrInt ||