swad-core/swad_pagination.c

980 lines
41 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_pagination.c: pagination of assignments, forums and messages
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************** Headers **********************************/
/*****************************************************************************/
2019-11-18 18:19:41 +01:00
#define _GNU_SOURCE // For asprintf
2019-12-29 12:39:00 +01:00
#include <stddef.h> // For NULL
2019-11-18 18:19:41 +01:00
#include <stdio.h> // For asprintf
2019-11-19 00:17:23 +01:00
#include <stdlib.h> // For free
2014-12-01 23:55:08 +01:00
#include "swad_action.h"
#include "swad_action_list.h"
2020-04-14 17:15:17 +02:00
#include "swad_agenda.h"
2020-04-10 19:14:08 +02:00
#include "swad_attendance.h"
2014-12-01 23:55:08 +01:00
#include "swad_database.h"
#include "swad_error.h"
2020-04-22 03:15:04 +02:00
#include "swad_exam.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2014-12-01 23:55:08 +01:00
#include "swad_forum.h"
2020-04-14 17:15:17 +02:00
#include "swad_game.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
2019-10-23 20:07:56 +02:00
#include "swad_HTML.h"
2020-04-14 17:15:17 +02:00
#include "swad_message.h"
2020-04-07 03:01:41 +02:00
#include "swad_pagination.h"
2014-12-01 23:55:08 +01:00
#include "swad_parameter.h"
2020-02-20 23:48:48 +01:00
#include "swad_program.h"
2017-09-17 16:58:09 +02:00
#include "swad_project.h"
#include "swad_session_database.h"
2020-04-14 17:15:17 +02:00
#include "swad_survey.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/*************** External global variables from others modules ***************/
/*****************************************************************************/
extern struct Globals Gbl;
extern Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM];
extern Act_Action_t For_ActionsSeePstFor[For_NUM_TYPES_FORUM];
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2017-04-13 20:09:22 +02:00
/***************************** Private constants *****************************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static const char *Pag_ParNumPag[Pag_NUM_WHAT_PAGINATE] =
2017-04-13 20:09:22 +02:00
{
2020-09-26 17:20:01 +02:00
[Pag_NONE ] = NULL,
2019-11-21 01:27:17 +01:00
[Pag_ASSIGNMENTS ] = "NumPagAsg",
[Pag_PROJECTS ] = "NumPagPrj",
2020-04-22 03:15:04 +02:00
[Pag_EXAMS ] = "NumPagExa",
2019-11-21 01:27:17 +01:00
[Pag_GAMES ] = "NumPagGam",
[Pag_RUBRICS ] = "NumPagRub",
[Pag_ATT_EVENTS ] = "NumPagAtt",
2019-11-21 01:27:17 +01:00
[Pag_THREADS_FORUM ] = "NumPagThr",
[Pag_POSTS_FORUM ] = "NumPagPst",
[Pag_MESSAGES_RECEIVED] = "NumPagRcv",
[Pag_MESSAGES_SENT ] = "NumPagSnt",
[Pag_SURVEYS ] = "NumPagSvy",
2019-11-21 01:27:17 +01:00
[Pag_MY_AGENDA ] = "NumPagMyAgd",
[Pag_ANOTHER_AGENDA ] = "NumPagOthAgd",
2017-04-13 20:09:22 +02:00
};
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******* Calculate variables related to the pagination of the messages *******/
/*****************************************************************************/
// Return the number of subsets of N elements in a set of NumElements elements
#define Pag_NumPags(NumItems) ((Pagination->NumItems+(Pag_ITEMS_PER_PAGE-1)) / Pag_ITEMS_PER_PAGE)
#define Pag_NUM_PAGES_BEFORE_CURRENT 1
#define Pag_NUM_PAGES_AFTER_CURRENT 1
2014-12-01 23:55:08 +01:00
void Pag_CalculatePagination (struct Pag_Pagination *Pagination)
2014-12-01 23:55:08 +01:00
{
2017-04-18 16:44:44 +02:00
Pagination->StartPage =
Pagination->LeftPage =
Pagination->RightPage =
Pagination->EndPage = 1;
2014-12-01 23:55:08 +01:00
Pagination->MoreThanOnePage = false;
Pagination->NumPags = ((Pagination->NumItems + (Pag_ITEMS_PER_PAGE-1)) / Pag_ITEMS_PER_PAGE);
if (Pagination->NumPags > 1)
2014-12-01 23:55:08 +01:00
{
Pagination->MoreThanOnePage = true;
/* If page to show is 0 (special code), then last page must be shown.
If page to show is greater than number of pages, then show last page also */
if (Pagination->CurrentPage == 0 ||
Pagination->CurrentPage > Pagination->NumPags)
Pagination->CurrentPage = Pagination->NumPags;
/* Compute first page with link around the current */
if (Pagination->CurrentPage <= Pag_NUM_PAGES_BEFORE_CURRENT)
2014-12-01 23:55:08 +01:00
Pagination->StartPage = 1;
2017-04-18 16:44:44 +02:00
else
Pagination->StartPage = Pagination->CurrentPage - Pag_NUM_PAGES_BEFORE_CURRENT;
2014-12-01 23:55:08 +01:00
/* Compute last page with link around the current */
if ((Pagination->EndPage = Pagination->CurrentPage + Pag_NUM_PAGES_AFTER_CURRENT) > Pagination->NumPags)
2014-12-01 23:55:08 +01:00
Pagination->EndPage = Pagination->NumPags;
/* Compute left page with link in the middle of first page and current page */
Pagination->LeftPage = (1 + Pagination->StartPage) / 2;
/* Compute right page with link in the middle of current page and last page */
Pagination->RightPage = (Pagination->EndPage + Pagination->NumPags) / 2;
}
else // Only one page
Pagination->CurrentPage = 1; // If there is only a page, the number of page to show is 1
Pagination->LastItemVisible = Pagination->CurrentPage * Pag_ITEMS_PER_PAGE;
2016-10-26 01:23:02 +02:00
Pagination->FirstItemVisible = Pagination->LastItemVisible - (Pag_ITEMS_PER_PAGE - 1);
2014-12-01 23:55:08 +01:00
if (Pagination->LastItemVisible > Pagination->NumItems)
Pagination->LastItemVisible = Pagination->NumItems;
2017-04-11 15:17:27 +02:00
/* Default anchor */
Pagination->Anchor = NULL;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Show enlaces a distintas p<>ginas of messages *****************/
/*****************************************************************************/
2017-04-17 11:57:55 +02:00
void Pag_WriteLinksToPagesCentered (Pag_WhatPaginate_t WhatPaginate,
struct Pag_Pagination *Pagination,
2020-04-10 19:14:08 +02:00
const void *Context,long Cod)
2014-12-01 23:55:08 +01:00
{
2019-12-11 00:13:09 +01:00
if (Pagination->MoreThanOnePage)
{
HTM_DIV_Begin ("class=\"CM\"");
Pag_WriteLinksToPages (WhatPaginate,Pagination,Context,Cod,
Cns_ENABLED,NULL,"PAG_TXT",false); // !!!!!!!!!!!!!!!!!!!!!!!!!!
2019-12-11 00:13:09 +01:00
HTM_DIV_End ();
}
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********************** Show links to pages of messages **********************/
/*****************************************************************************/
2017-04-17 11:57:55 +02:00
void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
struct Pag_Pagination *Pagination,
2020-04-10 19:14:08 +02:00
const void *Context,long Cod,
Cns_DisabledOrEnabled_t FirstMsgDisabledOrEnabled,
2019-11-18 18:19:41 +01:00
const char *Subject,const char *ClassTxt,
2014-12-01 23:55:08 +01:00
bool LinkToPagCurrent)
{
2017-04-18 22:46:43 +02:00
extern const char *Txt_Page_X_of_Y;
2019-03-06 10:13:39 +01:00
extern const char *Txt_FORUM_Post_banned;
2020-03-27 14:56:54 +01:00
Grp_WhichGroups_t WhichGroups;
2017-04-18 16:44:44 +02:00
unsigned NumPage;
2019-12-30 22:32:06 +01:00
char *Title;
2019-11-18 18:19:41 +01:00
2014-12-01 23:55:08 +01:00
/***** Link to page 1, including a text *****/
if (Subject)
{
2019-10-24 23:03:19 +02:00
HTM_DIV_Begin (NULL);
if (LinkToPagCurrent)
{
switch (WhatPaginate)
{
case Pag_ASSIGNMENTS:
Frm_BeginFormAnchor (ActSeeAllAsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
case Pag_PROJECTS:
Frm_BeginFormAnchor (ActSeeAllPrj,Pagination->Anchor);
Prj_PutPars (&((struct Prj_Projects *) Context)->Filter,
((struct Prj_Projects *) Context)->SelectedOrder,
1,
Cod);
break;
case Pag_EXAMS:
Frm_BeginFormAnchor (ActSeeAllExa,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Exa_Exams *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
case Pag_GAMES:
Frm_BeginFormAnchor (ActSeeAllGam,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Gam_Games *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
case Pag_RUBRICS:
Frm_BeginFormAnchor (ActSeeAllRub,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
break;
case Pag_ATT_EVENTS:
Frm_BeginFormAnchor (ActSeeAllAtt,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Att_Events *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
case Pag_THREADS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeeFor[((struct For_Forums *) Context)->Forum.Type],
Pagination->Anchor);
For_PutAllParsForum (1, // Page of threads = first
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
-1L,
-1L);
break;
case Pag_POSTS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeePstFor[((struct For_Forums *) Context)->Forum.Type],
Pagination->Anchor);
For_PutAllParsForum (((struct For_Forums *) Context)->CurrentPageThrs, // Page of threads = current
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
Cod,
-1L);
break;
case Pag_MESSAGES_RECEIVED:
Frm_BeginFormAnchor (ActSeeRcvMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
break;
case Pag_MESSAGES_SENT:
Frm_BeginFormAnchor (ActSeeSntMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
break;
case Pag_SURVEYS:
Frm_BeginFormAnchor (ActSeeAllSvy,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Svy_Surveys *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
case Pag_MY_AGENDA:
Frm_BeginFormAnchor (ActSeeMyAgd,Pagination->Anchor);
Agd_PutParsMyAgenda (((struct Agd_Agenda *) Context)->Past__FutureEvents,
((struct Agd_Agenda *) Context)->PrivatPublicEvents,
((struct Agd_Agenda *) Context)->HiddenVisiblEvents,
((struct Agd_Agenda *) Context)->SelectedOrder,
1,
Cod);
break;
case Pag_ANOTHER_AGENDA:
Frm_BeginFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutParEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutParPagNum (WhatPaginate,1);
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
default:
break;
}
if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_Submit_Begin (Title,
"class=\"LT BT_LINK %s_%s\"",
ClassTxt,The_GetSuffix ());
free (Title);
}
else
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
switch (FirstMsgDisabledOrEnabled)
{
case Cns_DISABLED:
HTM_TxtF ("[%s]",Txt_FORUM_Post_banned);
break;
case Cns_ENABLED:
HTM_Txt (Subject);
break;
}
if (LinkToPagCurrent)
{
HTM_BUTTON_End ();
Frm_EndForm ();
}
else
HTM_SPAN_End ();
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2014-12-01 23:55:08 +01:00
}
2017-04-18 22:46:43 +02:00
/***** Links to several pages start here *****/
2014-12-01 23:55:08 +01:00
if (Pagination->MoreThanOnePage)
{
/***** Possible link to page 1 *****/
if (Pagination->StartPage > 1)
{
switch (WhatPaginate)
{
case Pag_ASSIGNMENTS:
Frm_BeginFormAnchor (ActSeeAllAsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
2017-09-17 16:58:09 +02:00
case Pag_PROJECTS:
Frm_BeginFormAnchor (ActSeeAllPrj,Pagination->Anchor);
Prj_PutPars (&((struct Prj_Projects *) Context)->Filter,
((struct Prj_Projects *) Context)->SelectedOrder,
1,
Cod);
2017-09-17 16:58:09 +02:00
break;
2020-04-22 03:15:04 +02:00
case Pag_EXAMS:
Frm_BeginFormAnchor (ActSeeAllExa,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Exa_Exams *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2020-04-22 03:15:04 +02:00
break;
2017-09-13 16:24:29 +02:00
case Pag_GAMES:
Frm_BeginFormAnchor (ActSeeAllGam,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Gam_Games *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2017-09-13 16:24:29 +02:00
break;
case Pag_RUBRICS:
Frm_BeginFormAnchor (ActSeeAllRub,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
break;
case Pag_ATT_EVENTS:
Frm_BeginFormAnchor (ActSeeAllAtt,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Att_Events *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
case Pag_THREADS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeeFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (1, // Page of threads = first
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
-1L,
-1L);
2017-04-18 01:25:44 +02:00
break;
2014-12-01 23:55:08 +01:00
case Pag_POSTS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeePstFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (((struct For_Forums *) Context)->CurrentPageThrs, // Page of threads = current
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
Cod,
-1L);
2014-12-01 23:55:08 +01:00
break;
2017-04-13 20:09:22 +02:00
case Pag_MESSAGES_RECEIVED:
Frm_BeginFormAnchor (ActSeeRcvMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_MESSAGES_SENT:
Frm_BeginFormAnchor (ActSeeSntMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_SURVEYS:
Frm_BeginFormAnchor (ActSeeAllSvy,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,1);
Par_PutParOrder ((unsigned) ((struct Svy_Surveys *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
2017-03-21 14:52:07 +01:00
case Pag_MY_AGENDA:
Frm_BeginFormAnchor (ActSeeMyAgd,Pagination->Anchor);
Agd_PutParsMyAgenda (((struct Agd_Agenda *) Context)->Past__FutureEvents,
((struct Agd_Agenda *) Context)->PrivatPublicEvents,
((struct Agd_Agenda *) Context)->HiddenVisiblEvents,
((struct Agd_Agenda *) Context)->SelectedOrder,
1,
Cod);
2016-12-06 21:08:28 +01:00
break;
2017-03-21 14:52:07 +01:00
case Pag_ANOTHER_AGENDA:
Frm_BeginFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutParEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutParPagNum (WhatPaginate,1);
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
2016-12-06 21:26:02 +01:00
break;
2020-09-26 17:20:01 +02:00
default:
break;
2014-12-01 23:55:08 +01:00
}
if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_Submit_Begin (Title,
"class=\"BT_LINK PAG PAG_%s %s_%s\"",
The_GetSuffix (),
ClassTxt,The_GetSuffix ());
HTM_Unsigned (1);
HTM_BUTTON_End ();
free (Title);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
if (Pagination->LeftPage > 2)
2019-11-07 10:24:00 +01:00
{
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
HTM_Txt ("&hellip;");
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
}
2014-12-01 23:55:08 +01:00
}
/***** Posible link to page left *****/
2017-04-18 16:44:44 +02:00
if (Pagination->LeftPage > 1 &&
Pagination->LeftPage < Pagination->StartPage)
2014-12-01 23:55:08 +01:00
{
switch (WhatPaginate)
{
case Pag_ASSIGNMENTS:
Frm_BeginFormAnchor (ActSeeAllAsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
2017-09-17 16:58:09 +02:00
case Pag_PROJECTS:
Frm_BeginFormAnchor (ActSeeAllPrj,Pagination->Anchor);
Prj_PutPars (&((struct Prj_Projects *) Context)->Filter,
((struct Prj_Projects *) Context)->SelectedOrder,
Pagination->LeftPage,
Cod);
2017-09-17 16:58:09 +02:00
break;
2020-04-22 03:15:04 +02:00
case Pag_EXAMS:
Frm_BeginFormAnchor (ActSeeAllExa,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Par_PutParOrder ((unsigned) ((struct Exa_Exams *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2020-04-22 03:15:04 +02:00
break;
2017-09-13 16:24:29 +02:00
case Pag_GAMES:
Frm_BeginFormAnchor (ActSeeAllGam,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Par_PutParOrder ((unsigned) ((struct Gam_Games *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2017-09-13 16:24:29 +02:00
break;
case Pag_RUBRICS:
Frm_BeginFormAnchor (ActSeeAllRub,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
break;
case Pag_ATT_EVENTS:
Frm_BeginFormAnchor (ActSeeAllAtt,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Par_PutParOrder ((unsigned) ((struct Att_Events *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
case Pag_THREADS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeeFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (Pagination->LeftPage, // Page of threads = left
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
-1L,
-1L);
2014-12-01 23:55:08 +01:00
break;
case Pag_POSTS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeePstFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (((struct For_Forums *) Context)->CurrentPageThrs, // Page of threads = current
Pagination->LeftPage, // Page of posts = left
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
Cod,
-1L);
2014-12-01 23:55:08 +01:00
break;
2017-04-13 20:09:22 +02:00
case Pag_MESSAGES_RECEIVED:
Frm_BeginFormAnchor (ActSeeRcvMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_MESSAGES_SENT:
Frm_BeginFormAnchor (ActSeeSntMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_SURVEYS:
Frm_BeginFormAnchor (ActSeeAllSvy,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Par_PutParOrder ((unsigned) ((struct Svy_Surveys *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
2017-03-21 14:52:07 +01:00
case Pag_MY_AGENDA:
Frm_BeginFormAnchor (ActSeeMyAgd,Pagination->Anchor);
Agd_PutParsMyAgenda (((struct Agd_Agenda *) Context)->Past__FutureEvents,
((struct Agd_Agenda *) Context)->PrivatPublicEvents,
((struct Agd_Agenda *) Context)->HiddenVisiblEvents,
((struct Agd_Agenda *) Context)->SelectedOrder,
Pagination->LeftPage,
Cod);
2016-12-06 21:08:28 +01:00
break;
2017-03-21 14:52:07 +01:00
case Pag_ANOTHER_AGENDA:
Frm_BeginFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutParEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutParPagNum (WhatPaginate,Pagination->LeftPage);
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
2016-12-06 21:26:02 +01:00
break;
2020-09-26 17:20:01 +02:00
default:
break;
2014-12-01 23:55:08 +01:00
}
if (asprintf (&Title,Txt_Page_X_of_Y,
Pagination->LeftPage,Pagination->NumPags) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_Submit_Begin (Title,
"class=\"BT_LINK PAG PAG_%s %s_%s\"",
The_GetSuffix (),
ClassTxt,The_GetSuffix ());
HTM_Unsigned (Pagination->LeftPage);
HTM_BUTTON_End ();
free (Title);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2017-04-18 16:44:44 +02:00
if (Pagination->LeftPage < Pagination->StartPage - 1)
2019-11-07 10:24:00 +01:00
{
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
HTM_Txt ("&hellip;");
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
}
2014-12-01 23:55:08 +01:00
}
/***** Loop to put links to the pages around the current one *****/
for (NumPage = Pagination->StartPage;
NumPage <= Pagination->EndPage;
NumPage++)
{
2019-12-30 22:32:06 +01:00
if (asprintf (&Title,Txt_Page_X_of_Y,NumPage,Pagination->NumPags) < 0)
Err_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage)
2019-11-07 10:24:00 +01:00
{
HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR PAG_CUR_%s %s_%s\"",
Title,The_GetSuffix (),ClassTxt,The_GetSuffix ());
HTM_Unsigned (NumPage);
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
}
2014-12-01 23:55:08 +01:00
else
{
switch (WhatPaginate)
{
case Pag_ASSIGNMENTS:
Frm_BeginFormAnchor (ActSeeAllAsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
2017-09-17 16:58:09 +02:00
case Pag_PROJECTS:
Frm_BeginFormAnchor (ActSeeAllPrj,Pagination->Anchor);
Prj_PutPars (&((struct Prj_Projects *) Context)->Filter,
((struct Prj_Projects *) Context)->SelectedOrder,
NumPage,
Cod);
2017-09-17 16:58:09 +02:00
break;
2020-04-22 03:15:04 +02:00
case Pag_EXAMS:
Frm_BeginFormAnchor (ActSeeAllExa,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Par_PutParOrder ((unsigned) ((struct Exa_Exams *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2020-04-22 03:15:04 +02:00
break;
2017-09-13 16:24:29 +02:00
case Pag_GAMES:
Frm_BeginFormAnchor (ActSeeAllGam,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Par_PutParOrder ((unsigned) ((struct Gam_Games *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2017-09-13 16:24:29 +02:00
break;
case Pag_RUBRICS:
Frm_BeginFormAnchor (ActSeeAllRub,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
break;
case Pag_ATT_EVENTS:
Frm_BeginFormAnchor (ActSeeAllAtt,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Par_PutParOrder ((unsigned) ((struct Att_Events *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
case Pag_THREADS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeeFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (NumPage, // Page of threads = number of page
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
-1L,
-1L);
2014-12-01 23:55:08 +01:00
break;
case Pag_POSTS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeePstFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (((struct For_Forums *) Context)->CurrentPageThrs, // Page of threads = current
NumPage, // Page of posts = number of page
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
Cod,
-1L);
2014-12-01 23:55:08 +01:00
break;
2017-04-13 20:09:22 +02:00
case Pag_MESSAGES_RECEIVED:
Frm_BeginFormAnchor (ActSeeRcvMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_MESSAGES_SENT:
Frm_BeginFormAnchor (ActSeeSntMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_SURVEYS:
Frm_BeginFormAnchor (ActSeeAllSvy,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,NumPage);
Par_PutParOrder ((unsigned) ((struct Svy_Surveys *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
2017-04-13 20:09:22 +02:00
case Pag_MY_AGENDA:
Frm_BeginFormAnchor (ActSeeMyAgd,Pagination->Anchor);
Agd_PutParsMyAgenda (((struct Agd_Agenda *) Context)->Past__FutureEvents,
((struct Agd_Agenda *) Context)->PrivatPublicEvents,
((struct Agd_Agenda *) Context)->HiddenVisiblEvents,
((struct Agd_Agenda *) Context)->SelectedOrder,
NumPage,
Cod);
2017-04-13 20:09:22 +02:00
break;
case Pag_ANOTHER_AGENDA:
Frm_BeginFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutParEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutParPagNum (WhatPaginate,NumPage);
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
2017-04-13 20:09:22 +02:00
break;
2020-09-26 17:20:01 +02:00
default:
break;
2014-12-01 23:55:08 +01:00
}
HTM_BUTTON_Submit_Begin (Title,
"class=\"BT_LINK PAG PAG_%s %s_%s\"",
The_GetSuffix (),
ClassTxt,The_GetSuffix ());
HTM_Unsigned (NumPage);
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
2019-12-30 22:32:06 +01:00
free (Title);
2014-12-01 23:55:08 +01:00
}
/***** Posible link to page right *****/
2015-08-24 11:25:20 +02:00
if (Pagination->RightPage > Pagination->EndPage &&
Pagination->RightPage < Pagination->NumPags)
2014-12-01 23:55:08 +01:00
{
2017-01-28 15:58:46 +01:00
if (Pagination->RightPage > Pagination->EndPage + 1)
2019-11-07 10:24:00 +01:00
{
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
HTM_Txt ("&hellip;");
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
}
2014-12-01 23:55:08 +01:00
switch (WhatPaginate)
{
case Pag_ASSIGNMENTS:
Frm_BeginFormAnchor (ActSeeAllAsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
2017-09-17 16:58:09 +02:00
case Pag_PROJECTS:
Frm_BeginFormAnchor (ActSeeAllPrj,Pagination->Anchor);
Prj_PutPars (&((struct Prj_Projects *) Context)->Filter,
((struct Prj_Projects *) Context)->SelectedOrder,
Pagination->RightPage,
Cod);
2017-09-17 16:58:09 +02:00
break;
2020-04-22 03:15:04 +02:00
case Pag_EXAMS:
Frm_BeginFormAnchor (ActSeeAllExa,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Par_PutParOrder ((unsigned) ((struct Exa_Exams *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2020-04-22 03:15:04 +02:00
break;
2017-09-13 16:24:29 +02:00
case Pag_GAMES:
Frm_BeginFormAnchor (ActSeeAllGam,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Par_PutParOrder ((unsigned) ((struct Gam_Games *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2017-09-13 16:24:29 +02:00
break;
case Pag_RUBRICS:
Frm_BeginFormAnchor (ActSeeAllRub,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
break;
case Pag_ATT_EVENTS:
Frm_BeginFormAnchor (ActSeeAllAtt,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Par_PutParOrder ((unsigned) ((struct Att_Events *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
case Pag_THREADS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeeFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (Pagination->RightPage, // Page of threads = right
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
-1L,
-1L);
2017-04-18 01:25:44 +02:00
break;
2014-12-01 23:55:08 +01:00
case Pag_POSTS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeePstFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (((struct For_Forums *) Context)->CurrentPageThrs, // Page of threads = current
Pagination->RightPage, // Page of posts = right
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
Cod,
-1L);
2014-12-01 23:55:08 +01:00
break;
2017-04-13 20:09:22 +02:00
case Pag_MESSAGES_RECEIVED:
Frm_BeginFormAnchor (ActSeeRcvMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_MESSAGES_SENT:
Frm_BeginFormAnchor (ActSeeSntMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_SURVEYS:
Frm_BeginFormAnchor (ActSeeAllSvy,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Par_PutParOrder ((unsigned) ((struct Svy_Surveys *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
2017-03-21 14:52:07 +01:00
case Pag_MY_AGENDA:
Frm_BeginFormAnchor (ActSeeMyAgd,Pagination->Anchor);
Agd_PutParsMyAgenda (((struct Agd_Agenda *) Context)->Past__FutureEvents,
((struct Agd_Agenda *) Context)->PrivatPublicEvents,
((struct Agd_Agenda *) Context)->HiddenVisiblEvents,
((struct Agd_Agenda *) Context)->SelectedOrder,
Pagination->RightPage,
Cod);
2016-12-06 21:08:28 +01:00
break;
2017-03-21 14:52:07 +01:00
case Pag_ANOTHER_AGENDA:
Frm_BeginFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutParEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutParPagNum (WhatPaginate,Pagination->RightPage);
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
2016-12-06 21:26:02 +01:00
break;
2020-09-26 17:20:01 +02:00
default:
break;
2014-12-01 23:55:08 +01:00
}
if (asprintf (&Title,Txt_Page_X_of_Y,
Pagination->RightPage,Pagination->NumPags) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_Submit_Begin (Title,
"class=\"BT_LINK PAG PAG_%s %s_%s\"",
The_GetSuffix (),
ClassTxt,The_GetSuffix ());
HTM_Unsigned (Pagination->RightPage);
HTM_BUTTON_End ();
free (Title);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
/***** Possible link to last page *****/
if (Pagination->EndPage < Pagination->NumPags)
{
2017-01-28 15:58:46 +01:00
if (Pagination->NumPags > Pagination->RightPage + 1)
2019-11-07 10:24:00 +01:00
{
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
HTM_Txt ("&hellip;");
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
}
2014-12-01 23:55:08 +01:00
switch (WhatPaginate)
{
case Pag_ASSIGNMENTS:
Frm_BeginFormAnchor (ActSeeAllAsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Par_PutParOrder ((unsigned) ((struct Asg_Assignments *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
2017-09-17 16:58:09 +02:00
case Pag_PROJECTS:
Frm_BeginFormAnchor (ActSeeAllPrj,Pagination->Anchor);
Prj_PutPars (&((struct Prj_Projects *) Context)->Filter,
((struct Prj_Projects *) Context)->SelectedOrder,
Pagination->NumPags,
Cod);
2017-09-17 16:58:09 +02:00
break;
2020-04-22 03:15:04 +02:00
case Pag_EXAMS:
Frm_BeginFormAnchor (ActSeeAllExa,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Par_PutParOrder ((unsigned) ((struct Exa_Exams *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2020-04-22 03:15:04 +02:00
break;
2017-09-13 16:24:29 +02:00
case Pag_GAMES:
Frm_BeginFormAnchor (ActSeeAllGam,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Par_PutParOrder ((unsigned) ((struct Gam_Games *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2017-09-13 16:24:29 +02:00
break;
case Pag_RUBRICS:
Frm_BeginFormAnchor (ActSeeAllRub,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
break;
case Pag_ATT_EVENTS:
Frm_BeginFormAnchor (ActSeeAllAtt,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Par_PutParOrder ((unsigned) ((struct Att_Events *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
2014-12-01 23:55:08 +01:00
break;
case Pag_THREADS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeeFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (Pagination->NumPags, // Page of threads = last
1, // Page of posts = first
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
-1L,
-1L);
2014-12-01 23:55:08 +01:00
break;
case Pag_POSTS_FORUM:
Frm_BeginFormAnchor (For_ActionsSeePstFor[((struct For_Forums *) Context)->Forum.Type],
2017-04-11 15:17:27 +02:00
Pagination->Anchor);
For_PutAllParsForum (((struct For_Forums *) Context)->CurrentPageThrs, // Page of threads = current
Pagination->NumPags, // Page of posts = last
((struct For_Forums *) Context)->ForumSet,
((struct For_Forums *) Context)->ThreadsOrder,
((struct For_Forums *) Context)->Forum.HieCod,
Cod,
-1L);
2014-12-01 23:55:08 +01:00
break;
2017-04-13 20:09:22 +02:00
case Pag_MESSAGES_RECEIVED:
Frm_BeginFormAnchor (ActSeeRcvMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_MESSAGES_SENT:
Frm_BeginFormAnchor (ActSeeSntMsg,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Msg_PutParsMsgsFilters ((struct Msg_Messages *) Context);
2017-04-13 20:09:22 +02:00
break;
case Pag_SURVEYS:
Frm_BeginFormAnchor (ActSeeAllSvy,Pagination->Anchor);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Par_PutParOrder ((unsigned) ((struct Svy_Surveys *) Context)->SelectedOrder);
WhichGroups = Grp_GetParWhichGroups ();
Grp_PutParWhichGroups (&WhichGroups);
break;
2017-03-21 14:52:07 +01:00
case Pag_MY_AGENDA:
Frm_BeginFormAnchor (ActSeeMyAgd,Pagination->Anchor);
Agd_PutParsMyAgenda (((struct Agd_Agenda *) Context)->Past__FutureEvents,
((struct Agd_Agenda *) Context)->PrivatPublicEvents,
((struct Agd_Agenda *) Context)->HiddenVisiblEvents,
((struct Agd_Agenda *) Context)->SelectedOrder,
Pagination->NumPags,
Cod);
2016-12-06 21:08:28 +01:00
break;
2017-03-21 14:52:07 +01:00
case Pag_ANOTHER_AGENDA:
Frm_BeginFormAnchor (ActSeeUsrAgd,Pagination->Anchor);
Agd_PutParEventsOrder (((struct Agd_Agenda *) Context)->SelectedOrder);
Pag_PutParPagNum (WhatPaginate,Pagination->NumPags);
Usr_PutParOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
2016-12-06 21:26:02 +01:00
break;
2020-09-26 17:20:01 +02:00
default:
break;
2014-12-01 23:55:08 +01:00
}
if (asprintf (&Title,Txt_Page_X_of_Y,
Pagination->NumPags,Pagination->NumPags) < 0)
Err_NotEnoughMemoryExit ();
HTM_BUTTON_Submit_Begin (Title,
"class=\"BT_LINK PAG PAG_%s %s_%s\"",
The_GetSuffix (),
ClassTxt,The_GetSuffix ());
HTM_Unsigned (Pagination->NumPags);
HTM_BUTTON_End ();
free (Title);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
2019-11-18 20:12:10 +01:00
}
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Put hidden parameter number of page *********************/
/*****************************************************************************/
void Pag_PutParPagNum (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage)
2014-12-01 23:55:08 +01:00
{
Par_PutParUnsigned (NULL,Pag_ParNumPag[WhatPaginate],NumPage);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************ Get parameter number of page ***********************/
/*****************************************************************************/
unsigned Pag_GetParPagNum (Pag_WhatPaginate_t WhatPaginate)
2014-12-01 23:55:08 +01:00
{
2017-04-13 20:09:22 +02:00
unsigned CurrentPage;
/***** Try to get parameter with the number of page *****/
CurrentPage = (unsigned) Par_GetParUnsignedLong (Pag_ParNumPag[WhatPaginate],
1,
UINT_MAX,
0);
2017-04-13 20:09:22 +02:00
if (CurrentPage == 0)
/***** If there's no parameter page, return a default value *****/
switch (WhatPaginate)
{
case Pag_MESSAGES_RECEIVED:
if (Gbl.Action.Act == ActExpRcvMsg)
/* Expanding a message, perhaps it is the result of following a link
from a notification of received message */
/* Show the page corresponding to the expanded message */
return 1; // Now set the current page to the first,
2017-04-13 20:09:22 +02:00
// but later the correct page will be calculated
/* Show the last visited page */
return Pag_GetLastPageMsgFromSession (Pag_MESSAGES_RECEIVED);
2017-04-13 20:09:22 +02:00
case Pag_MESSAGES_SENT:
/* Show the last visited page */
return Pag_GetLastPageMsgFromSession (Pag_MESSAGES_SENT);
2017-04-13 20:09:22 +02:00
default:
return 1;
2017-04-13 20:09:22 +02:00
}
2014-12-01 23:55:08 +01:00
2017-04-13 20:09:22 +02:00
return CurrentPage;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********* Get last page of received/sent messages stored in session *********/
/*****************************************************************************/
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
{
unsigned NumPage;
switch (WhatPaginate)
{
case Pag_MESSAGES_RECEIVED:
case Pag_MESSAGES_SENT:
/***** Get last page of received/sent messages from database *****/
if ((NumPage = Ses_DB_GetLastPageMsgFromSession (WhatPaginate)) == 0)
return 1;
return NumPage;
default:
return 1;
}
2014-12-01 23:55:08 +01:00
}