$VALIDATE_BOOLEAN
$VALIDATE_BOOLEAN :
Check for a boolean value
Action-class to manage a login system.
User should derive this class to implement an own action for the login page.
validate() : boolean
Validate the data from user.
It call the proper validate function, depending on the request method (GET or POST), to allow different checks. WARNING: this function should not be overrided! Please create proper validatePost() or validateGet() functions!
true if data are valid, false otherwise
perform() : \myMVC_HttpResponse
Perform the Action
Response code for the next Action or View
manageInvalidData() : \myMVC_HttpResponse
Called if user data are not valid (check with validate)
Response code for the next Action or View (typically the same view, with error messages)
setCheckFunction(string $type, string $func)
Set the functions to be used to validate the user's input.
string | $type | The type of the request (ALL, POST, GET, AJAX) |
string | $func | The method of the current class, to validate the input. It must return a boolean value (true: all valid, false: at least one field not validated) |
validateInput(array $definitions, array $names, array $errorMsgs) : boolean
Check if the given data (from Request) are valid.
The function save in the session (namespace: validate) an associative array with the invalid fields.
array | $definitions | The definition of the fields to validate as associative array ('field' => VALIDATE_TYPE) |
array | $names | The names of the fields to be used for displaying errors as associative array ('field' => 'name') |
array | $errorMsgs | The error messages for the fields as associative array ('field' => array('error' => 'message')) |
On problems
true if ALL fields are valid, false otherwise
getLoggedUser() : \myMVC_BaseLogin
Returns the current logged user, if any.
This function has to be static, then it will normally called from static functions (eg hasUserRightForAction).
The currently logged user, or NULL if no user is logged in, or the user's class is not a subclass of myMVC_BaseLogin
saveParameterForNextPage(string $key, string $value)
Save a variable in the session, to be used by the next page (Action or view).
This variable can be read with the method getParameterFromPreviousPage of the classes BaseAction or BaseView
string | $key | The name of the variable |
string | $value | The value |
isParameterFromPreviousSubmitValid(string $field) : boolean
Returns whether the given parameter of the previous submitted form passed the validation or not.
string | $field | The name of the parameter |
true if the parameter passed the validation, false otherwise
setLoggedIn(\myMVC_BaseLogin $user)
Save the user in the session.
User is now logged in.
\myMVC_BaseLogin | $user | The user (it must be a derived class of myMVC_BaseLogin) |
On problems
setNextAction(\myMVC_HttpResponse $response)
Sets the next action after a successfully login.
If the user tried to call another action, after a successfull login it must be redirected to this action. Otherwise to the default action.
\myMVC_HttpResponse | $response | The used response |
createErrorString(array $definitions, array $names, array $errorMsgs, string $field, string $check, string $externError = NULL) : string
Create the error string for the given field.
array | $definitions | The definition of the fields to validate as associative array ('field' => VALIDATE_TYPE) |
array | $names | The names of the fields to be used for displaying errors as associative array ('field' => 'name') |
array | $errorMsgs | The error messages for the fields as associative array ('field' => array('error' => 'message')) |
string | $field | The checked field |
string | $check | The check that field does not passed |
string | $externError | Optional extra error (given from extern parsed check function). Default: NULL |
The formatted error string
checkExtraParameters(array $checks, mixed $userInput, array $parameters) : string
Check if the given value from user's form comply with the given restrictions (min, max, range, and so on).
It does NOT check for empty value (this must be done before the first check).
array | $checks | The required checks as numeric array |
mixed | $userInput | User's input |
array | $parameters | The parameters to check the field |
The errors for this field (see myMVC_BaseAction::$ERROR_xxx) or false if no errors occoured