Public Member Functions | Protected Member Functions | Protected Attributes

BuildFilterBehavior Class Reference

BuildFilter Class build custom sql statements used in BEAppModel::findObjects() method to filter list of BEdita objects. More...

List of all members.

Public Member Functions

 setup (&$model, $settings=array())
 getSqlItems (&$model, $filter)
 set conditions, from, fields, group and order from $filter

Protected Member Functions

 object_userFilter ($s, $e, $value=null)
 filter to get user_id (as obj_userid) joined to an object through object_users table
 count_annotationFilter ($s, $e, $value)
 add a count of Annotation objects as Comment, EditoreNote, etc...
 mediatypeFilter ($s, $e)
 get a category of an object naming it mediatype (used in Multimedia module)
 queryFilter ($s, $e, $value)
 search text filter using fulltext or sql-like
 categoryFilter ($s, $e, $value)
 filter objects by category
 tagFilter ($s, $e, $value)
 filter objects by tag
 rel_detailFilter ($s, $e, $value)
 get RelatedObject fields
 ref_object_detailsFilter ($s, $e, $value)
 get the object referenced from an Annotation object as Comment, EditorNote
 ref_object_typesFilter ($s, $e, $value)
 Filter Reference object types (used with ref_object_details filter for Annotations).
 mail_groupFilter ($s, $e, $value)
 filter the cards joined at a mail group (used in Newsletter module)
 user_createdFilter ($s, $e)
 get userid (username) and real name of user that has created the object
 count_permissionFilter ($s, $e, $value)
 count objects' permissions as num_of_permission
 custom_propertyFilter ($s, $e, $value)
 custom property filter get object_properties fields as ObjectProperty
 date_itemFilter ($s, $e, $value)
 date item filter get date_items fields as DateItem
 count_relationsFilter ($s, $e, $value)
 count relation filter If 'object_type_id' specified in BuildFilter::filter then get relations for that object type/s
 allowed_to_userFilter ($s, $e, $userid)
 filter objects allowed to user

Protected Attributes

 $filter = array()
 $startQuote = ""
 $endQuote = ""
 $model = ""

Detailed Description

BuildFilter Class build custom sql statements used in BEAppModel::findObjects() method to filter list of BEdita objects.

It can be extended with custom behavior classes to refine query according to your needs

Example:

App::import('Behavior', 'BuildFilter');

ClassNameFilterBehavior extends BuildFilterBehavior {

public function myFilterMethod($data) {

}

}

to call that method you have to build your filter to pass at BEAppModel::findObjects() as

$filter['ClassNameFilter.myFilterMethod'] = $yourData;

$yourData item will be passed to myFilterMethod as first argument

methods of your custom filter class should be return an array that can have the following keys:

"fromEnd" => string of FROM statement to insert at the end of the string (list of tables and aliases)

"group" => string to add at GROUP statement

Version:
$Revision$ $LastChangedBy$ $LastChangedDate$

$Id$

Definition at line 62 of file build_filter.php.


Member Function Documentation

BuildFilterBehavior::allowed_to_userFilter ( s,
e,
userid 
) [protected]

filter objects allowed to user

Parameters:
string $s, start quote sql
string $e, end quote sql
string $userid userid (users.userid field)

Definition at line 781 of file build_filter.php.

BuildFilterBehavior::categoryFilter ( s,
e,
value 
) [protected]

filter objects by category

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, id or category name

Definition at line 527 of file build_filter.php.

BuildFilterBehavior::count_annotationFilter ( s,
e,
value 
) [protected]

add a count of Annotation objects as Comment, EditoreNote, etc...

If 'object_type_id' specified in BuildFilter::filter then get annotations for that object type/s

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, annotation model or an array of annotation models Example:

$value = "Comment" => add count of comment as 'num_of_comment' $value = array("Comment", "EditorNote") => add count of comments as 'num_of_comment' and count of editor notes as 'num_of_editor_note'

Definition at line 398 of file build_filter.php.

BuildFilterBehavior::count_permissionFilter ( s,
e,
value 
) [protected]

count objects' permissions as num_of_permission

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, if it's integer then count $value permission

Definition at line 659 of file build_filter.php.

BuildFilterBehavior::count_relationsFilter ( s,
e,
value 
) [protected]

count relation filter If 'object_type_id' specified in BuildFilter::filter then get relations for that object type/s

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, relation name or array of relations (object_relations.switch field)

Example:

$value = "seealso" => add count of seealso relation as 'num_of_relations_seealso' $value = array("seealso", "download") => add count of seealso relation as 'num_of_relations_seealso' and count of download relation as 'num_of_relations_download'

Definition at line 742 of file build_filter.php.

BuildFilterBehavior::custom_propertyFilter ( s,
e,
value 
) [protected]

custom property filter get object_properties fields as ObjectProperty

filter rules:

  • default join used is INNER JOIN. It can be overriden with 'join' key in $value

if $value is a string or a number set condition respectively to property_value or property_id

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value can be a string/number or an array with keys equal to object_properties table field

Definition at line 680 of file build_filter.php.

BuildFilterBehavior::date_itemFilter ( s,
e,
value 
) [protected]

date item filter get date_items fields as DateItem

filter rules:

  • default join used is INNER JOIN. It can be overriden with 'join' key in $value

if $value is a number set condition start_date

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value can be a number or an array with keys equal to date_items table field

Definition at line 710 of file build_filter.php.

BuildFilterBehavior::getSqlItems ( &$  model,
filter 
)

set conditions, from, fields, group and order from $filter

Parameters:
array $filter
Returns:
array

Definition at line 170 of file build_filter.php.

BuildFilterBehavior::mail_groupFilter ( s,
e,
value 
) [protected]

filter the cards joined at a mail group (used in Newsletter module)

Parameters:
string $s, start quote sql
string $e, end quote sql
integer $value, mail_group_id

Definition at line 631 of file build_filter.php.

BuildFilterBehavior::mediatypeFilter ( s,
e 
) [protected]

get a category of an object naming it mediatype (used in Multimedia module)

Parameters:
string $s, start quote sql
string $e, end quote sql

Definition at line 439 of file build_filter.php.

BuildFilterBehavior::object_userFilter ( s,
e,
value = null 
) [protected]

filter to get user_id (as obj_userid) joined to an object through object_users table

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, if not empty to get user_id joined to an object with $value relation (object_users.swicth)

Definition at line 371 of file build_filter.php.

BuildFilterBehavior::queryFilter ( s,
e,
value 
) [protected]

search text filter using fulltext or sql-like

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, the string to search for (default $defaultConf['searchType'] used) array( 'searchType' => 'like' or 'fulltext' 'searchString' => 'the string to search' )

Definition at line 464 of file build_filter.php.

BuildFilterBehavior::ref_object_detailsFilter ( s,
e,
value 
) [protected]

get the object referenced from an Annotation object as Comment, EditorNote

Example: getting a list of comment you can take also the object commented with

$filter['object_type_id'] = Configure::read('objectTypes.comment.id'); // to filter comments $filter['ref_object_details'] = 'Comment'; // to get also the object commented

Parameters:
string $s, start quote sql
string $e, end quote sql
string $value, the Annotation Model as Comment, EditorNote, ...

Definition at line 588 of file build_filter.php.

BuildFilterBehavior::ref_object_typesFilter ( s,
e,
value 
) [protected]

Filter Reference object types (used with ref_object_details filter for Annotations).

Parameters:
string $s, start quote sql
string $e, end quote sql
string $value, id or array id of of reference object types

Definition at line 605 of file build_filter.php.

BuildFilterBehavior::rel_detailFilter ( s,
e,
value 
) [protected]

get RelatedObject fields

Parameters:
string $s, start quote sql
string $e, end quote sql
type $value [unused?? To verify]

Definition at line 563 of file build_filter.php.

BuildFilterBehavior::tagFilter ( s,
e,
value 
) [protected]

filter objects by tag

Parameters:
string $s, start quote sql
string $e, end quote sql
mixed $value, id or tag name

Definition at line 545 of file build_filter.php.

BuildFilterBehavior::user_createdFilter ( s,
e 
) [protected]

get userid (username) and real name of user that has created the object

Parameters:
string $s, start quote sql
string $e, end quote sql

Definition at line 644 of file build_filter.php.


The documentation for this class was generated from the following file:
Generated on Fri Dec 11 2015 15:29:46 by Doxygen 1.7.1  BEditaBEdita 3.7 Corylus