Build fullname of the user with firstname and lastname (and a space between)
function buildFullNameOfUser($user)
- $user: must contain firstname and lastname index.
Returns the entire string with first letter of the given variable in uppercase
function setFirstCharToUpperCase($string)
- $string: a string.
Show the content of $_SESSION["flashmsg"]
function flashMessage($withHtml = true)
- $withHtml: false if we want to display the message without html
Show the content of $_SESSION["flashmsg"]
function flashMessage($withHtml = true)
- $withHtml: false if we want to display the message without html
Display a var (with var_dump()) for debug, only if debug mode is enabled
function displaydebug($var, $needPrint_r = false)
- $var: must contain var we want to display
- $needPrint_r: true if we want to print_r the var
Convert[x][y] [x] is the table where the field[y] is located, we want to convert [y] to text
function convertXY($int, $needFirstCharToUpper = false)
- convertUserState()
- convertJoinState()
- convertGroupState()
- convertGroupVisibility()
- convertProjectState()
- convertParticipateState()
- convertWorkState()
- convertWorkNeedhelp()
- convertWorkNeedhelpIcon()
- convertTaskState()
- convertTaskType()
- $int: must contain the int
- $needFirstCharToUpper: true if we want an upper lettre at the start of the word
Create hoverables texts-tooltips for help
function createToolTip($innerText, $tooltipText, $link = false, $type = "top")
- $innerText: must contain the content we want to show when tooltip is hovered
- $tooltipText: must contain the title of tooltip
- $link: can contain a link for redirection
- $type: must contain where we want to place the data
Create hoverables texts-tooltips for help
function createToolTipWithPoint($tooltipText, $pointClasses = "icon-small m-2", $link = false, $type = "top")
- $innerText: must contain the content we want to show when tooltip' point is hovered
- $pointClasses: can contain classes for the tooltip's point
- $link: can contain a link for redirection
- $type: must contain where we want to place the data
Return the given string with an upper char for first letter depends on [needFirstCharToUpper]
function manageIfApplyOnFirstChar($txt, $needFirstCharToUpper)
- $txt: must contain the text that we want to trim
- $needFirstCharToUpper: true if we want an upper letter at the start of the word
Display the firstname and lastname
function mentionUser($basicUser, $css = "text-info")
- $basicUser: must contain the user we want to diplay with the hover
- $css: must contain a css class
print (or return) an icon with a file, a title, alt attribute, and personalized or default css classes
function printAnIcon($iconname, $title, $alt, $defaultClasses = "icon-small ml-2 mr-2", $echo = true, $id = "", $hidden = false)
- $iconname: must contain the name of file we want to use in this icon
- $title: must contain a title
- $alt: must contain an alternative text if image isn't avalible
- $defaultClasses: can contain classes
- $echo: can contain a boolean, true if we want to show that in a echo
- $id: can contain an id
- $hidden: can contain a boolean variable to show or not the icon
Create an element with fixed number of line
function createElementWithFixedLines($text, $nbLines, $cssClassesInAddition = "", $withTitle = false)
- $text: must contain the text we want to show
- $nbLines: must contain a number of line
- $cssClassesInAddition: can contain classes
- $withTitle: can contain boolean
Create a colored circle with custom color
function getHTMLPastille($cssColor)
- $cssColor: must contain a css Color code or name
Write if the current page is "Work In Progress"
function printPageWIPTextInfo()
- none
Check the password of a user for an important action
checkUserPassword($id, $password)
- $id: id of the user
- $password: password sent for the important action
Check the length of string doesn't exceed max of chars authorized (usually max defined by the database)
chkLength($string, $max)
- $string: string to test
- $max: nb max of chars authorized
Convert a checkbox sent value to TINYINT format (0 if null and 1 if not) (checkbox input are not sent if not checked!)
chkToTinyint($value)
- $value: value of the checkbox (like $data['visible'] from the input type checkbox)
Set the flashmessage in the session with its number, that will be displayed in a view or in the gabarit
flshmsg($number)
- $number: number of the flashmessage (number in flashmessages.json)
Convert a timestamp date to datetime format (like 1605472805 in "2020-11-15 20:40:05"). Is useful for the database because all dates are stored in datetime
timeToDT($timestamp)
- $timestamp: the timestamp date
Convert a datetime date to a "human displayable date"
DTToHumanDate($datetime, $mode = "simpleday", $isTimestamp = false)
- $datetime: the datetime date
- $mode: the format for date() chosen (possibilities: simpleday = "d.m.Y", simpletime = "d.m.Y à H:i", completeday = "j F Y", completetime = "j F Y à H:i:S")
- $isTimestamp: if the date is a timestamp instead of a datetime, the parameter can be set to true
Convert all chosen fields in a 2d array to html entities
specialCharsConvertFromAnArray($items, $fields)
- $items: the 2d array (ex: [["name" => "test
", "description" => "truc"], ["name" => "html test <script>", "description" => "truc"]])
- $fields: 1D array of all fields to convert (ex: ["name", "description"])
Substring a text cleverly with conditions
substrText($text, $max, $nospace = false, $points = true)
- $text: the text
- $max: maximum of length
- $nospace: if the string can be stopped on another char than a space char (or if words must not be cut).
- $points: add or not points "..." at the end of the string (max length of text alone will be $max - 4)
Return the given string without space, tab, line break, and null byte, at the start and end of the string.
function trimIt($string)
- $string: must contain the text that we want to trim
Replace accented chars with their equivalent without any accent
function replaceAccentChars($string)
- $string: text with accents ("élève" will be converted in "eleve")
Index a 2D array from a select query on a database
function indexAnArrayById($array)
- $array: the array
Is the user logged an admin
function checkAdmin()
none the state of the user will be updated in the session
Check if user has limited access (if banned, archived or unapproved) or not
function checkLimitedAccess()
none
Check that each key of sub array of an 2D array is not null
function checkThatEachKeyIsNotEmpty($array)
- $array: array 2D --> Useful to check that a set of fields are not null before a creation in the database (create an $array only with these fields)
Is a value at least equal to one element in a list
function isAtLeastEqual($value, $possibilities)
- $value: must contain the value we want to test if is in possibilities
- $possibilities: must contain the possibilities as 1D array (like [1, 5, 6])
Compare 2 dates with day precision
function compare2DatesWithDayPrecision($date1, $date2)
- $date1: first date
- $date2: second date
Return: int value: 0 if dates are on the same day, -1 if date1 is before date2, 1 if date1 is after date2
Unset passwords in the 2 dimensions of a 2D array
function unsetPasswordsInArrayOn2Dimensions($array)
- $array: array 2D (1D not accepted)
Is the email respecting the email format (with a regex)
function isEmailFormat($text)
- $text: the email
Send a email with a feedback sent through the feedback form
function sendFeedback($data)
- $data: array with body of POST. it must contain $data['subject'], $data['content'] and $data['email']. email can be null if response is not asked.
Set the HTTP Header for API response (like Content-Type and other values if needed)
function setHTTPHeaderForAPIResponse()
none
Return if we can change the user state from the current to next wanted (no all changes are authorized)
function canChangeUserState($current, $next)
- $current: current state
- $next: wanted new state
Get error value if not true
function setErrorValueIfNotTrue($newValue, $currentValue)
- $newValue: new value got from the last test of validity
- $currentValue: current value of $error in the long list of validation
Manage the response status, if it's fail success or an error
function manageResponseStatus(response)
- response: must contain all the data we need for an ajax's response
Manage the response status, if it's fail success or an error
function manageResponseStatus(response)
- response: must contain all the data we need for an ajax's response
Return the given string without all numbers
function removeNumbersInString(text)
- text: must contain the text that we want to remove numbers
Check length of text in input (type = text), if the string's is more than 4/5 of the max length, counter appears in red. If the string's length = max lenght, writing will be blocked
function checkTextFieldToCheck()
- none
Give an array constitute by values from the [formname]
function getArrayFromAFormFieldsWithName(formname)
- formname: must contain the name of form we want to extract the array
Send a request with ajax
function sendRequest(verb, url, callback, data)
- verb: must contain a verb like: create, read, update, delete (CRUD)
- url: must contain the url where the request
- callback: must contain the name of function we want to call after request
- data: must contain the data we want to send with ajax request
Return the given string without all numbers
function displayResponseMsg(val, checkmark = true, color = "black")
- val: must contain the text that we want display
- checkmark: must contain a bool that tell to us if the checkmark is a tick or a cross
- color: must contain a css color that decide what is the text's color
Return false if one of the [values] is empty
function checkAllValuesAreNotEmpty(values)
- values: must contain the values we want to tests
Return if [needle] is contain in the things after "action=" in the querystring
function queryActionIncludes(needle)
- needle: must contain the text that we want to check if is contained in querystring
Create a div with a DOM object inside from a string with html code
function createElementFromHTML(htmlString)
- htmlString: must contain the text that we want to put in the div
Write in console the given text
function logIt(text)
- text: must contain the text that we want to write in console
Return a bool if the string tested with regex return true
function testRegex(regex, string)
- regex: must contain a regex
- string: must contain a string