Maarch Framework 2.1/Technical Handbook/PHP classes details

De Maarch Wiki.

Sommaire

Class functions

This class contains various functions for the use of MAARCH.

getmicrotime()

Function to obtain the hour in microseconds. No parameter.

start_page_stat()

To put in top of a page. Allows to obtain the beginning hour of the page loading in microseconds. No parameter.

start_page_stat()

Returns the generation time of the page. No parameter.

show_error()

Shows the errors if there are. No parameter.

add_error()

Adds an error in the error manager.

Parameters:

  • $msg : Error message

wash()

Allows to clean a variable and to return an error message if the variable is not in conformity with the rules fixed in parameters.

Parameters:

  • $what : Variable to clean
  • $mask : Regular expression. Possibility of choosing between several masks:
  • No : No mask
  • num : No numbers
  • letter : Only letters
  • alphanum : Only letters or figures
  • nick : Only letters, figures and “.- _”
  • mail : a valid mail address
  • url : a URL beginning with www
  • file : Only characters, figures and “.-?/&é _”
  • name : Only characters, figures and “.-?/&é et _ \'èà”
  • $msg_error : Error message to be turned over (must be formed

like : "the name").

  • $empty : Indicates if the variable is obligatory or not (obligatory by default)
  • $min_limit : Allows to prohibit the variable with contents of size lower than a given number
  • $max_limit : Allows to prohibit the variable with contents of size higher than a given number


show()

Shows a variable by removing the “\”.

No parameter.

where_am_i()

Shows the name of the heading where the user is, compared to the name of the page. No parameter.

insert_page()

Inserts a page in a template. Made safe version, accepts only the pages locally having a valid name. (see function wash())

Parameters:

  • Takes the name of the page passed in the aggregate variable $_GET[‘page’]

show_array()

Shows in a structured way a table.

Parameters :

  • $arr : array to show

format_date()

Transforms a MySQL date of the form yyyy-mm-dd hh:mm:ss in a date of the form dd/mm/yyyy

Parameters:

  • $date : date to transform

dateformat()

Transforms a mysql date of the form yyyy-mm-dd hh:mm:ss in a date of the form dd/mm/yyyy hh:mm:ss

Parameters :

  • $date : date to transform

echo_error()

Show a personalized error.

Parameters :

  • $title : Title to show
  • $message : Error message to show

writeifnotempty()

Shows information in parameters if they are not empty.

Parameters :

  • $what : Variable to show
  • $title : Title of the line to show

whatsecuritylevel ()

Shows the security level label of a level

Parameters :

  • $level: Level to show

infouser ()

Extracts the user info from database and put the result in an array

Parameters :

  • $id : user id

Class Users

__construct()

Treats aggregate variables and fixed the order of sorting of the list of the users (Launched automatically at the beginning of the call of the class). No parameters.

load_groups()

Loads data related to the user groups (group name, role, primary group or not) in session variables. No parameters.

load_security()

Loads in session variables, the security parameters corresponding to the user groups. No parameters.

login()

Identification of a user with name and password.

Parameters :

  • $s_login : name of user
  • $pass : password of the user

reopen()

Identification of a user by cookie with a key and User Id.

Parameters :

  • $s_UserId : Id of user
  • $s_key : Key of reopening of the session

build_config()

Treats the xml file of configuration and puts it in variables of session for a later use. No parameters.

userslistletters()

Lists the letters of the alphabet to list the users. No parameters.

userslist()

Shows the list of the users according to the selected letter.

Parameters:

  • $where : sorting of the list (by default: no)
  • $what : 1st letter of the name

adminuser()

Allows the administrators to manage the users (modification, suspension, authorization, deletes)

Parameters :

  • $id : Id of user
  • $mode : administrator mode (modification, suspension, authorization, delete)

formuser()

Form for the management of the users.

Parameters :

  • $mode : administrator mode (modification, suspension, authorization, delete)
  • $id : Id of user (empty by default)

usersinfo()

Treats the information returned by the form of formuser()

Parameters :

  • $mode : administrator mode (modification, suspension, authorization, delete)

addupusers()

Allows the administrators to modify and add users.

Parameters :

  • $mode : mode (modification, suspension, authorization, delete)

clearuserinfos()

Empty information administrator of the user put in session. No parameters.

lang()

Builds the site language Parameters :

  • $lang : language

User_modif()

Treats the information returned by the form of change_info_user(). No parameters.

Change_info_user()

Form for the management of the current user. No parameters.

Class Types

__construct()

Treats aggregate variables and fixed the sorting order of the list of the documents types (Launched automatically at the beginning of the call of the class) No parameters.

typelistletters()

Lists the letters of the alphabet to list the types of documents

Parameters :

  • $page : Name of the page for the links (by default standards)

typeslist()

Shows the list of the documents types according to the selected letter.

Parameters :

  • $where : sorting of the list (by default: no)
  • $what : 1st letter of the name

typessearch()

Shows the list of the documents types according to a search criterion.

Parameters :

  • $where : sorting of the list (by default: no)
  • $what : 1st letter of the name

formtype()

Form for the administration of the types of documents (Validation, Modification, and Proposal)

Parameters :

  • $mode : mode of administration (Validation, Modification, Proposal)
  • $id : Id of the type (empty by default)

typesinfo()

Treats the information returned by the form of formtype(). No parameters.

uptypes()

Updates a document type. No parameters.

cleartypeinfos()

Empty the documents types information put in session. No parameter.

deltypes()

Deletes a document type.

Parameters :

  • $id : Id of the type of document

Class Search

thisword()

Puts in intensified brightness the searched words in the search results.

Parameters :

  • $words : Expression returned by the search
  • $need : searched word

define_order()

Defines the sorting order of the search results. No parameters.

list_doc()

Shows the list of the documents of search.

Parameters :

  • $listarr : List results of required in the form of an array
  • $nb_total : Total number of search results.
  • $title : Title to show for the array
  • $what : Required chain
  • $name : Page name where to establish a link

Class History

__construct()

Treats aggregate variables and fixes the sorting order of the event list in the history (Launched automatically at the beginning of the call of the class). No parameters.

add()

Adds an entry in the history

Parameters :

  • $id : Id of the reason of the entry in the history (UserId, TypeId or other)
  • $how : Reason of the entry in history (ADD, UP, LED)
  • $what : The event label.

listhistory()

Posts the events list of the history. No parameters.

Class Docserver

filename()

Generates a file name for the uploaded file and a destination folder.

Parameters:

  • $ path_template : Path to the DocServer

Class Db

show_step()

DEBUG – Posts a preset sentence if the debug mode is active.

Parameters :

  • $phrase : Sentence to show.

connect()

Connection to the database server. No parameters.

select_db()

Selects the database. No parameters.

query()

Carries out the sql request parameter.

Parameters :

  • $sq_sql : SQL Request.

fetch_object()

Puts in an object the results of the last request. No parameters.

fetch_array()

Puts in an array the results of the last request. No parameters.

nb_result()

Returns the number of results of the request. No parameters.

deco()

Disconnects the connection with the database. No parameters.

error()

DEBUG – Management of the errors. Posts a message and the request in the event of error. No parameters.

show()

Shows the last request. No parameters.

Class Admin

adminlink()

Posts the hypertext link for the desired category.

Parameters :

  • $what : Type for the showing of the link

menu()

Shows the fast menu for the administration. No parameters.

bigmenu()

Shows the detailed menu of the administration. No parameters.

Class Security

Load_security_group()

Loads the security parameters for a group in session variables.

Parameters :

  • $group_id : group identifier

Init_session()

Inits the session variables related to the group administration. No parameters.

Init_rights_session()

Inits to ‘N’ (no) the rights in the session variables related to the group administration. No parameters.

Set_rights_session()

Set the rights (insert or update, depending on the parameter) for the tables passed on parameters through an array.

Parameters :

  • $tab : array of table names
  • $what : insert or update

Remove_security()

Removes the security rights on the tables passed in parameters.

Parameters :

  • $tab : array of table names

Add_grouptmp_session()

Adds security parameters of a group in the session variables related to the group administration.

Parameters :

  • $table : table name
  • $where : where clause
  • $comment : comment on the table
  • $insert : insert right (Y/N)
  • $update : update right (Y/N)

Load_db()

Updates the database with the groups security of the session variables. No parameters.

Where_test()

Test the syntax of the where clauses of all tables for a group. No parameters.

Class Usergroup_content

Init_session()

Inits the session variables related to the user administration. No parameters.

Remove_session()

Removes the group on the tables passed in parameters for the user.

Parameters :

  • $tab : array of group names

Set_primary_group_session()

Set the primary group for a user in the session variables.

Parameters :

  • $group_id : group identifier

Erase_primary_group_session()

No group is the primary group for the user. No parameters.

Add_usertmp_to_group_session()

Adds a group in the session variables related to the user administration.

Parameters :

  • $group_id : group identifier
  • $role : role in the group

load_group_session()

Loads in the session variables the groups of the user passed in parameter.

Parameters :

  • $user_id : user identifier

Load_db()

Updates the database (usergroup_content table) with the session variables. No parameters.

Class Usergroups

__construct()

Treats aggregate variables and fixed the order of sorting of the list of the usergroups (Launched automatically at the beginning of the call of the class). No parameters.

groupslistletters()

Lists the letters of the alphabet to list the groups. No parameters.

groupslist()

Shows the list of the groups according to the selected letter.

Parameters:

  • $where : sorting of the list (by default: none)
  • $what : 1st letter of the name

formgroups()

Form for the management of the groups.

Parameters :

  • $mode : administrator mode (modification, suspension, authorization, delete)
  • $id : group identifier (empty by default)

groupsinfo()

Treats the information returned by the form of formgroups()

Parameters :

  • $mode : administrator mode (modification, suspension, authorization, delete)

addupgroups()

Allows the administrators to modify and add groups.

Parameters :

  • $mode : mode (modification, suspension, authorization, delete)

admingroup()

Allows the administrators to manage the groups (modification, suspension, authorization, deletes)

Parameters :

  • $id : group identifier
  • $mode : administrator mode (modification, suspension, authorization, delete)
Language