Skip to content

Commit

Permalink
doc(Utils) function headers
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed Oct 31, 2021
1 parent dcf503a commit 86fcabc
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 93 deletions.
9 changes: 4 additions & 5 deletions include/utils/CommonUtils.php
Expand Up @@ -257,8 +257,8 @@ function popup_from_html($string, $encode = true) {
}

/** To get the Currency of the specified user
* @param $id -- The user Id:: Type integer
* @returns currencyid :: Type integer
* @param integer user ID
* @return integer currency ID
*/
function fetchCurrency($id) {
global $log;
Expand All @@ -284,9 +284,8 @@ function fetchCurrency($id) {
}

/** Function to get the Currency name from the vtiger_currency_info
* @param $currencyid -- currencyid:: Type integer
* @returns $currencyname -- Currency Name:: Type varchar
*
* @param integer currency ID
* @return string Currency Name
*/
function getCurrencyName($currencyid, $show_symbol = true) {
global $log;
Expand Down
110 changes: 54 additions & 56 deletions include/utils/ListViewUtils.php
Expand Up @@ -216,13 +216,13 @@ function getListViewHeader($focus, $module, $sort_qry = '', $sorder = '', $order
return $list_header;
}

/* * This function is used to get the list view header in popup
* Param $focus - module object
* Param $module - module name
* Param $sort_qry - sort by value
* Param $sorder - sorting order (asc/desc)
* Param $order_by - order by
* Returns the listview header values in an array
/** This function is used to get the list view header in popup
* @param object module object
* @param string module name
* @param string sort by value
* @param string sorting order (asc/desc)
* @param string order by
* @return array listview header values
*/
function getSearchListViewHeader($focus, $module, $sort_qry = '', $sorder = '', $order_by = '') {
global $log, $adb, $theme, $current_user;
Expand Down Expand Up @@ -347,14 +347,12 @@ function getSearchListViewHeader($focus, $module, $sort_qry = '', $sorder = '',
return $list_header;
}

/* * This function generates the navigation array in a listview
* Param $display - start value of the navigation
* Param $noofrows - no of records
* Param $limit - no of entries per page
* Returns an array type
/** This function generates the navigation array in a listview
* @param integer start value of the navigation
* @param integer no of records
* @param integer no of entries per page
* @return array of navigation values
*/

//code contributed by raju for improved pagination
function getNavigationValues($display, $noofrows, $limit) {
global $log;
$log->debug('> getNavigationValues ' . $display . ',' . $noofrows . ',' . $limit);
Expand Down Expand Up @@ -1156,19 +1154,19 @@ function getSearchListViewEntries($focus, $module, $list_result, $navigation_arr
return $list;
}

/* * This function generates the value for a given field name
* Param $field_result - vtiger_field result in array
* Param $list_result - resultset of a listview query
* Param $fieldname - field name
* Param $focus - module object
* Param $module - module name
* Param $entity_id - entity id
* Param $list_result_count - row of the field to use
* Param $mode - mode type
* Param $popuptype - popup type
* Param $returnset - list query parameters in url string
* Param $viewid - custom view id
* Returns an string value
/** This function generates the value for a given field name
* @param $field_result - vtiger_field result in array
* @param $list_result - resultset of a listview query
* @param $fieldname - field name
* @param $focus - module object
* @param $module - module name
* @param $entity_id - entity id
* @param $list_result_count - row of the field to use
* @param $mode - mode type
* @param $popuptype - popup type
* @param $returnset - list query parameters in url string
* @param integer custom view id
* @return string value
*/
function getValue($field_result, $list_result, $fieldname, $focus, $module, $entity_id, $list_result_count, $mode, $popuptype) {
global $log, $app_strings, $current_language, $currentModule, $adb, $current_user, $default_charset;
Expand Down Expand Up @@ -2315,9 +2313,9 @@ function getListQuery($module, $where = '') {
return $query;
}

/* * Function returns the list of records which an user is entiled to view
* Param $module - module name
* Returns a database query - type string
/** Function returns the list of records which an user is entiled to view
* @param string module name
* @return string a database query
*/
function getReadEntityIds($module) {
global $log, $current_user;
Expand Down Expand Up @@ -2411,18 +2409,18 @@ function getReadEntityIds($module) {
}

/** Function to get alphabetical search links
* Param $module - module name
* Param $action - action
* Param $fieldname - vtiger_field name
* Param $query - query
* Param $type - search type
* Param $popuptype - popup type
* Param $recordid - record id
* Param $return_module - return module
* Param $append_url - url string to be appended
* Param $viewid - custom view id
* Param $groupid - group id
* Returns an string value
* @param string module name
* @param string action
* @param string field name
* @param string query
* @param string search type
* @param string popup type
* @param integer record id
* @param string return module
* @param string url string to be appended
* @param integer custom view id
* @param integer group id
* @return string value
*/
function AlphabeticalSearch($module, $action, $fieldname, $query, $type, $popuptype = '', $recordid = '', $return_module = '', $append_url = '', $viewid = '', $groupid = '') {
global $log;
Expand Down Expand Up @@ -2544,13 +2542,13 @@ function getRelatedTo($module, $list_result, $rset) {
return $parent_value;
}

/* * Function to get the table headers for a listview
* Param $navigation_arrray - navigation values in array
* Param $url_qry - url string
* Param $module - module name
* Param $action- action file name
* Param $viewid - view id
* Returns an string value
/** Function to get the table headers for a listview
* @param $navigation_arrray - navigation values in array
* @param $url_qry - url string
* @param $module - module name
* @param $action- action file name
* @param $viewid - view id
* @return string value
*/
function getTableHeaderNavigation($navigation_array, $url_qry, $module = '', $action_val = 'index', $viewid = '') {
global $log, $app_strings, $theme, $current_user;
Expand Down Expand Up @@ -3422,13 +3420,13 @@ function VT_getSimpleNavigationValues($start, $size, $total) {
'prev' => $prev, 'next' => $next, 'verylast' => $lastPage);
}

/* * Function to get the simplified table headers for a listview
* Param $navigation_arrray - navigation values in array
* Param $url_qry - url string
* Param $module - module name
* Param $action- action file name
* Param $viewid - view id
* Returns an string value
/** Function to get the simplified table headers for a listview
* @param array navigation values
* @param string url
* @param string module name
* @param string action file name
* @param integer view id
* @return string HTML for header
*/
function getTableHeaderSimpleNavigation($navigation_array, $url_qry, $module = '', $action_val = 'index', $viewid = '') {
global $app_strings, $theme, $current_user;
Expand Down
14 changes: 7 additions & 7 deletions include/utils/VtlibUtils.php
Expand Up @@ -427,9 +427,9 @@ function vtlib_isDirWriteable($dirpath) {
/**
* Purify (Cleanup) malicious snippets of code from the input
*
* @param string value to clean
* @param mixed value(s) to clean
* @param boolean ignore skip cleaning of the input
* @return string sanitized
* @return mixed sanitized
*/
function vtlib_purify($input, $ignore = false) {
global $__htmlpurifier_instance, $root_directory, $default_charset;
Expand Down Expand Up @@ -488,7 +488,7 @@ function vtlib_purify($input, $ignore = false) {
/**
* Process the UI Widget requested
* @param Vtiger_Link $widgetLinkInfo
* @param Current Smarty Context $context
* @param Smarty Context
* @return
*/
function vtlib_process_widget($widgetLinkInfo, $context = false) {
Expand Down Expand Up @@ -526,10 +526,10 @@ function vtlib_module_icon($modulename) {
}

/**
* Function to return the valid SQl input.
* @param <String> $string
* @param <Boolean> $skipEmpty Skip the check if string is empty.
* @return <String> $string/false
* Function to return the valid SQL input
* @param string SQL
* @param boolean Skip the check if string is empty
* @return string sanitized SQL or false
*/
function vtlib_purifyForSql($string, $skipEmpty = true) {
$pattern = '/^[_a-zA-Z0-9.]+$/';
Expand Down
48 changes: 23 additions & 25 deletions vtlib/Vtiger/Utils.php
Expand Up @@ -26,9 +26,9 @@ public static function isNumber($value) {

/**
* Implode the prefix and suffix as string for given number of times
* @param String prefix to use
* @param Integer Number of times
* @param String suffix to use (optional)
* @param string prefix to use
* @param integer Number of times
* @param string suffix to use (optional)
*/
public static function implodestr($prefix, $count, $suffix = false) {
$strvalue = '';
Expand All @@ -43,8 +43,8 @@ public static function implodestr($prefix, $count, $suffix = false) {

/**
* Function to check the file access is made within web root directory as well as is safe for php inclusion
* @param String File path to check
* @param Boolean False to avoid die() if check fails
* @param string File path to check
* @param boolean False to avoid die() if check fails
*/
public static function checkFileAccessForInclusion($filepath, $dieOnFail = true) {
global $root_directory;
Expand Down Expand Up @@ -85,8 +85,8 @@ public static function checkFileAccessForInclusion($filepath, $dieOnFail = true)

/**
* Function to check the file access is made within web root directory.
* @param String File path to check
* @param Boolean False to avoid die() if check fails
* @param string File path to check
* @param boolean False to avoid die() if check fails
*/
public static function checkFileAccess($filepath, $dieOnFail = true) {
global $root_directory;
Expand Down Expand Up @@ -123,8 +123,8 @@ public static function checkFileAccess($filepath, $dieOnFail = true) {

/**
* Log the debug message
* @param String Log message
* @param Boolean true to append end-of-line, false otherwise
* @param string Log message
* @param boolean true to append end-of-line, false otherwise
*/
public static function Log($message, $delimit = true) {
global $Vtiger_Utils_Log, $log;
Expand All @@ -146,7 +146,7 @@ public static function Log($message, $delimit = true) {

/**
* Escape the string to avoid SQL Injection attacks.
* @param String Sql statement string
* @param string Sql statement string
*/
public static function SQLEscape($value) {
if ($value == null) {
Expand All @@ -158,7 +158,7 @@ public static function SQLEscape($value) {

/**
* Check if table is present in database
* @param String tablename to check
* @param string tablename to check
*/
public static function CheckTable($tablename) {
global $adb;
Expand All @@ -179,10 +179,9 @@ public static function CheckTable($tablename) {

/**
* Create table (supressing failure)
* @param String tablename to create
* @param String table creation criteria like '(columnname columntype, ....)'
* @param String Optional suffix to add during table creation
* will be appended to CREATE TABLE $tablename SQL
* @param string tablename to create
* @param string table creation criteria like '(columnname columntype, ....)'
* @param string Optional suffix to add during table creation will be appended to CREATE TABLE $tablename SQL
*/
public static function CreateTable($tablename, $criteria, $suffixTableMeta = false) {
global $adb;
Expand All @@ -206,9 +205,8 @@ public static function CreateTable($tablename, $criteria, $suffixTableMeta = fal

/**
* Alter existing table
* @param String tablename to alter
* @param String alter criteria like ' ADD columnname columntype' <br>
* will be appended to ALTER TABLE $tablename SQL
* @param string tablename to alter
* @param string alter criteria like ' ADD columnname columntype' <br> will be appended to ALTER TABLE $tablename SQL
*/
public static function AlterTable($tablename, $criteria) {
global $adb;
Expand All @@ -217,9 +215,9 @@ public static function AlterTable($tablename, $criteria) {

/**
* Add column to existing table
* @param String tablename to alter
* @param String columnname to add
* @param String columntype (criteria like 'VARCHAR(100)')
* @param string tablename to alter
* @param string columnname to add
* @param string columntype (criteria like 'VARCHAR(100)')
*/
public static function AddColumn($tablename, $columnname, $criteria) {
global $adb;
Expand All @@ -230,7 +228,7 @@ public static function AddColumn($tablename, $columnname, $criteria) {

/**
* Get SQL query
* @param String SQL query statement
* @param string SQL query statement
*/
public static function ExecuteQuery($sqlquery, $supressdie = false) {
global $adb;
Expand All @@ -248,7 +246,7 @@ public static function ExecuteQuery($sqlquery, $supressdie = false) {

/**
* Get CREATE SQL for given table
* @param String tablename for which CREATE SQL is requried
* @param string tablename for which CREATE SQL is requried
*/
public static function CreateTableSql($tablename) {
global $adb;
Expand All @@ -262,7 +260,7 @@ public static function CreateTableSql($tablename) {

/**
* Check if the given SQL is a CREATE statement
* @param String SQL String
* @param string SQL String
*/
public static function IsCreateSql($sql) {
if (preg_match('/(CREATE TABLE)/', strtoupper($sql))) {
Expand All @@ -273,7 +271,7 @@ public static function IsCreateSql($sql) {

/**
* Check if the given SQL is destructive (DELETE's DATA)
* @param String SQL String
* @param string SQL String
*/
public static function IsDestructiveSql($sql) {
if (preg_match(
Expand Down

0 comments on commit 86fcabc

Please sign in to comment.