CRM_Utils_Weight
in package
Class CRM_Utils_Weight
Table of Contents
Properties
- $SIGNABLE_FIELDS : array<string|int, mixed>
- List of GET fields which must be validated
Methods
- addOrder() : mixed
- correctDuplicateWeights() : bool
- Correct duplicate weight entries by putting them (duplicate weights) in sequence.
- delWeight() : bool
- Remove a row from the specified weight, and shift all rows below it up
- fixOrder() : mixed
- fixOrderOutput() : mixed
- getDefaultWeight() : int
- Returns the default weight ( highest weight + 1 ) to be used.
- getMax() : int
- Returns the highest weight.
- getNewWeight() : int
- Returns the new calculated weight.
- query() : CRM_Core_DAO
- Execute a weight-related query
- updateOtherWeights() : int
- Makes space for a moved or inserted row by updating the weight of other rows as needed.
Properties
$SIGNABLE_FIELDS
List of GET fields which must be validated
public
static array<string|int, mixed>
$SIGNABLE_FIELDS
= ['reset', 'dao', 'idName', 'url', 'filter']
To reduce the size of this patch, we only sign the exploitable fields which make up "$baseURL" in addOrder() (eg 'filter' or 'dao'). Less-exploitable fields (eg 'dir') are left unsigned. 'id','src','dst','dir'
Methods
addOrder()
public
static addOrder(array<string|int, mixed> &$rows, string $daoName, string $idName, string $returnURL[, string|null $filter = null ]) : mixed
Parameters
- $rows : array<string|int, mixed>
- $daoName : string
- $idName : string
- $returnURL : string
- $filter : string|null = null
correctDuplicateWeights()
Correct duplicate weight entries by putting them (duplicate weights) in sequence.
public
static correctDuplicateWeights(string $daoName[, array<string|int, mixed> $fieldValues = null ][, string $weightField = 'weight' ]) : bool
Parameters
- $daoName : string
-
Full name of the DAO.
- $fieldValues : array<string|int, mixed> = null
-
Field => value to be used in the WHERE.
- $weightField : string = 'weight'
-
Field which contains the weight value. defaults to 'weight'
Return values
booldelWeight()
Remove a row from the specified weight, and shift all rows below it up
public
static delWeight(string $daoName, int $fieldID[, array<string|int, mixed> $fieldValues = null ][, string $weightField = 'weight' ]) : bool
Parameters
- $daoName : string
-
Full name of the DAO. $param integer $weight the weight to be removed
- $fieldID : int
- $fieldValues : array<string|int, mixed> = null
-
Field => value to be used in the WHERE.
- $weightField : string = 'weight'
-
Field which contains the weight value. defaults to 'weight'
Return values
boolfixOrder()
public
static fixOrder() : mixed
Tags
fixOrderOutput()
public
static fixOrderOutput(string $url) : mixed
Parameters
- $url : string
getDefaultWeight()
Returns the default weight ( highest weight + 1 ) to be used.
public
static getDefaultWeight(string $daoName[, array<string|int, mixed> $fieldValues = null ][, string $weightField = 'weight' ]) : int
Parameters
- $daoName : string
-
Full name of the DAO.
- $fieldValues : array<string|int, mixed> = null
-
Field => value to be used in the WHERE.
- $weightField : string = 'weight'
-
Field which contains the weight value. defaults to 'weight'
Return values
intgetMax()
Returns the highest weight.
public
static getMax(string $daoName[, array<string|int, mixed> $fieldValues = null ][, string $weightField = 'weight' ]) : int
Parameters
- $daoName : string
-
Full name of the DAO.
- $fieldValues : array<string|int, mixed> = null
-
Field => value to be used in the WHERE.
- $weightField : string = 'weight'
-
Field which contains the weight value. defaults to 'weight'
Return values
intgetNewWeight()
Returns the new calculated weight.
public
static getNewWeight(string $daoName[, array<string|int, mixed> $fieldValues = null ][, string $weightField = 'weight' ]) : int
Parameters
- $daoName : string
-
Full name of the DAO.
- $fieldValues : array<string|int, mixed> = null
-
Field => value to be used in the WHERE.
- $weightField : string = 'weight'
-
Field which used to get the wt, default to 'weight'.
Return values
intquery()
Execute a weight-related query
public
static & query(string $queryType, CRM_Core_DAO|string $daoName, array<string|int, mixed> $fieldValues, string $queryData[, string|null $additionalWhere = null ][, string|null $orderBy = null ][, string|null $groupBy = null ]) : CRM_Core_DAO
Parameters
- $queryType : string
-
SELECT, UPDATE, DELETE.
- $daoName : CRM_Core_DAO|string
-
Full name of the DAO.
- $fieldValues : array<string|int, mixed>
-
Field => value to be used in the WHERE.
- $queryData : string
-
Data to be used, dependent on the query type.
- $additionalWhere : string|null = null
-
Optional WHERE field.
- $orderBy : string|null = null
-
Optional ORDER BY field.
- $groupBy : string|null = null
-
Optional GROU} BY field.
Return values
CRM_Core_DAO —objet that holds the results of the query
updateOtherWeights()
Makes space for a moved or inserted row by updating the weight of other rows as needed.
public
static updateOtherWeights(string $daoName, int|null $oldWeight, int $newWeight[, array<string|int, mixed> $fieldValues = null ][, string $weightField = 'weight' ]) : int
Parameters
- $daoName : string
-
Full name of the DAO class.
- $oldWeight : int|null
-
Previous weight if the row was moved within the same parent-grouping Null if the item is new or being moved from a different grouping.
- $newWeight : int
-
The desired weight of the moved/inserted row
- $fieldValues : array<string|int, mixed> = null
-
Defines the group, e.g. [parent_id => 8, domain_id => 1]
- $weightField : string = 'weight'
-
Field which contains the weight value, defaults to 'weight'
Return values
int —Adjusted new weight