Documentation

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
Updates the weight fields of other rows according to the new and old weight passed in.

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
bool

delWeight()

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
bool

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
int

getMax()

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
int

getNewWeight()

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
int

query()

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()

Updates the weight fields of other rows according to the new and old weight passed in.

public static updateOtherWeights(string $daoName, int $oldWeight, int $newWeight[, array<string|int, mixed> $fieldValues = NULL ][, string $weightField = 'weight' ]) : int

And returns the new weight be used. If old-weight not present, Creates a gap for a new row to be inserted at the specified new weight

Parameters
$daoName : string

Full name of the DAO.

$oldWeight : int
$newWeight : 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
int

        
On this page

Search results