Elgg  Version 3.0
RiverWhereClause.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database\Clauses;
4 
5 use DateTime;
8 use ElggEntity;
9 
14 
18  public $ids;
19 
24 
28  public $action_types;
29 
33  public $views;
34 
39 
43  public $object_guids;
44 
48  public $target_guids;
49 
54 
58  public $enabled;
59 
64 
69 
74 
78  public function prepare(QueryBuilder $qb, $table_alias = null) {
79  $alias = function ($column) use ($table_alias) {
80  return $table_alias ? "{$table_alias}.{$column}" : $column;
81  };
82 
83  $wheres = [];
84  $wheres[] = parent::prepare($qb, $table_alias);
85 
86  if (!isset($this->use_enabled_clause)) {
87  $this->use_enabled_clause = !_elgg_services()->session->getDisabledEntityVisibility();
88  }
89 
90  if (!isset($this->enabled) && $this->use_enabled_clause) {
91  $this->enabled = 'yes';
92  }
93 
94  $types = new TypeSubtypeWhereClause();
95  $types->type_subtype_pairs = $this->type_subtype_pairs;
96  $wheres[] = $types->prepare($qb, $table_alias);
97 
98  $wheres[] = $qb->compare($alias('id'), '=', $this->ids, ELGG_VALUE_ID);
99  $wheres[] = $qb->compare($alias('annotation_id'), '=', $this->annotation_ids, ELGG_VALUE_ID);
100  $wheres[] = $qb->compare($alias('view'), '=', $this->views, ELGG_VALUE_STRING);
101  $wheres[] = $qb->compare($alias('action_type'), '=', $this->action_types, ELGG_VALUE_STRING);
102  $wheres[] = $qb->compare($alias('subject_guid'), '=', $this->subject_guids, ELGG_VALUE_GUID);
103  $wheres[] = $qb->compare($alias('object_guid'), '=', $this->object_guids, ELGG_VALUE_GUID);
104  $wheres[] = $qb->compare($alias('target_guid'), '=', $this->target_guids, ELGG_VALUE_GUID);
105  $wheres[] = $qb->compare($alias('enabled'), '=', $this->enabled, ELGG_VALUE_STRING);
106  $wheres[] = $qb->between($alias('posted'), $this->created_after, $this->created_before, ELGG_VALUE_TIMESTAMP);
107 
108  return $qb->merge($wheres);
109  }
110 
111 }
$column
Definition: add.php:10
const ELGG_VALUE_GUID
Definition: constants.php:140
Database abstraction query builder.
const ELGG_VALUE_ID
Definition: constants.php:141
Builds queries for matching river items against their properties.
between($x, $lower=null, $upper=null, $type=null)
Build a between clause.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
const ELGG_VALUE_TIMESTAMP
Definition: constants.php:142
Builds clauses for filtering entities by their type and subtype.
Builds a clause from closure or composite expression.
Definition: WhereClause.php:12
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
const ELGG_VALUE_STRING
Definition: constants.php:139
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
prepare(QueryBuilder $qb, $table_alias=null)
{Build an expression and/or apply it to an instance of query builder.Query builder Table aliasComposi...
elgg ElggEntity
Definition: ElggEntity.js:15