swad-core/swad_action.h

115 lines
4.2 KiB
C
Raw Permalink Normal View History

2014-12-01 23:55:08 +01:00
// swad_action.h: actions
#ifndef _SWAD_ACT
#define _SWAD_ACT
/*
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 **********************************/
/*****************************************************************************/
2015-10-16 02:24:29 +02:00
#include <stdbool.h> // For boolean type
#include "swad_action_list.h"
#include "swad_hierarchy_type.h"
2016-10-12 14:02:56 +02:00
#include "swad_tab.h"
#include "swad_user_type.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
2017-03-08 20:31:49 +01:00
#define Act_MAX_CHARS_ACTION_TXT (256 - 1) // 255
#define Act_MAX_BYTES_ACTION_TXT Act_MAX_CHARS_ACTION_TXT // 255
2014-12-01 23:55:08 +01:00
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
/*****************************************************************************/
/******************************** Public types *******************************/
/*****************************************************************************/
#define Act_NUM_CONTENTS 2
2014-12-01 23:55:08 +01:00
typedef enum
{
Act_NORM,
Act_DATA,
2014-12-01 23:55:08 +01:00
} Act_Content_t;
typedef enum
{
Act_UNK, // Unknown tab
Act_1ST, // The main (original, first) tab in the browser
Act_NEW, // A new (second) blank tab in the browser
Act_2ND, // The second tab in the browser
Act_AJA, // Update a zone of the page using AJAX
Act_REF, // Update a zone of the page using AJAX, with auto-refresh
Act_UPL, // Upload a file. Do not write HTML content. Write Status code instead for Dropzone.js
Act_DWN, // Download a file in a new tab. Do not write HTML content.
Act_204, // Do not write HTML content. HTTP will return Status 204 No Content
Act_SVC, // Web service. Send output to client using SOAP.
2017-09-14 01:10:20 +02:00
} Act_BrowserTab_t;
2014-12-01 23:55:08 +01:00
struct Act_Actions
{
long ActCod; // Unique, time-persistent numerical code for the action
signed int IndexInMenu;
2016-10-12 14:02:56 +02:00
Tab_Tab_t Tab;
2014-12-01 23:55:08 +01:00
Act_Action_t SuperAction;
void (*FunctionPriori) (void);
void (*FunctionPosteriori) (void);
unsigned Permission[Hie_NUM_LEVELS][Usr_NUM_BELONG];
2014-12-01 23:55:08 +01:00
Act_Content_t ContentType;
2017-10-04 12:20:58 +02:00
Act_BrowserTab_t BrowserTab;
2014-12-01 23:55:08 +01:00
};
struct Act_ActionFunc
{
Act_Action_t NextAction;
void (*FuncPars) (void *Args);
void *Args;
};
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
2017-05-09 20:56:02 +02:00
Act_Action_t Act_GetActionFromActCod (long ActCod);
2018-04-24 13:21:53 +02:00
long Act_GetActCod (Act_Action_t Action);
signed int Act_GetIndexInMenu (Act_Action_t Action);
Tab_Tab_t Act_GetTab (Act_Action_t Action);
Act_Action_t Act_GetSuperAction (Act_Action_t Action);
Usr_Can_t Act_CheckIfICanExecuteAction (Act_Action_t Action);
2018-04-24 13:21:53 +02:00
Act_Content_t Act_GetContentType (Act_Action_t Action);
Act_BrowserTab_t Act_GetBrowserTab (Act_Action_t Action);
void (*Act_GetFunctionPriori (Act_Action_t Action)) (void);
void (*Act_GetFunctionPosteriori (Act_Action_t Action)) (void);
const char *Act_GetIconFromAction (Act_Action_t Action);
2018-04-24 13:21:53 +02:00
2014-12-01 23:55:08 +01:00
const char *Act_GetTitleAction (Act_Action_t Action);
2020-01-02 13:58:13 +01:00
const char *Act_GetActionText (Act_Action_t Action);
2014-12-01 23:55:08 +01:00
void Act_AdjustActionWhenNoUsrLogged (void);
void Act_AdjustCurrentAction (void);
#endif