Beispiel #1
0
/**
 * Alter the term DB query.
 *
 * @param SelectQuery $query
 *   The query object ot alter.
 */
function hook_query_rules_autotag_terms_alter($query)
{
    // Join the original term query from rules_autotag with our field table to
    // exclude terms that should not be tagged.
    $query->leftJoin('field_data_field_dont_autotag', 'fd', "t.tid = fd.entity_id AND fd.entity_type = 'taxonomy_term'");
    $query->condition(db_or()->condition('fd.field_dont_autotag_value', NULL)->condition('fd.field_dont_autotag_value', '1', '<>'));
}
Beispiel #2
0
 public static function getTags($table, $table_id = null)
 {
     if (is_null($table_id)) {
         if (!$table instanceof DBObject) {
             return false;
         }
         $table_id = $table->getMeta('id');
         $table = $table->getMeta('table');
     }
     $query = new SelectQuery('Tag');
     $query->leftJoin('TagLink', array('`tags`.`id` = `tag_links`.`tag_id`'))->filter('`tags`.`foreign_table` = :table')->filter('`tag_links`.`foreign_id` = :id');
     return $query->fetchAll(array(':table' => $table, ':id' => $table_id));
 }
Beispiel #3
0
 public static function get($hook, $type = 'pre')
 {
     if (!BACKEND_WITH_DATABASE) {
         return false;
     }
     $params = array(':type' => $type, ':hook' => $hook);
     $query = new SelectQuery('Hook');
     $query->leftJoin('Component', array('`hooks`.`class` = `components`.`name`'))->filter('`hooks`.`hook` = :hook')->filter('`hooks`.`type` = :type')->filter('`hooks`.`active` = 1')->filter('`components`.`active` = 1');
     if (Controller::$area) {
         $query->filter('`global` = 1 OR `class` = :area');
         $params[':area'] = Controller::$area;
     }
     if (Controller::$view && Controller::$view->mode) {
         $query->filter('`mode` IN (:mode, \'*\')');
         $params[':mode'] = Controller::$view->mode;
     }
     $query->order('`sequence`');
     return $query->fetchAll($params);
 }
Beispiel #4
0
 public function action_roles($id = false)
 {
     $toret = new stdClass();
     if ($id) {
         $toret->role = Role::retrieve($id, 'dbobject');
         if ($toret->role) {
             $query = new SelectQuery('Permission');
             $query->filter('`role` = :role');
             $toret->permissions = $query->fetchAll(array(':role' => $toret->role->array['name']));
             $query = new SelectQuery('Assignment');
             $query->leftJoin('BackendUser', array('`backend_users`.`id` = `assignments`.`access_id`'))->filter("`assignments`.`access_type` = 'users'")->filter('`role_id` = :role OR `role_id` = 0');
             $toret->assignments = $query->fetchAll(array(':role' => $toret->role->array['id']));
         } else {
             $toret->permissions = null;
         }
     } else {
         $toret->roles = Role::retrieve();
     }
     return $toret;
 }
 private function joinProperties(SelectQuery $query, ProtoDAO $parentDao, $parentTable, $parentRequired, $prefix = null)
 {
     $proto = call_user_func(array($parentDao->getObjectName(), 'proto'));
     foreach ($proto->getPropertyList() as $property) {
         if ($property instanceof LightMetaProperty && $property->getRelationId() == MetaRelation::ONE_TO_ONE && !$property->isGenericType() && (!$property->getFetchStrategyId() && $this->getFetchStrategy()->getId() == FetchStrategy::JOIN || $property->getFetchStrategyId() == FetchStrategy::JOIN)) {
             if (is_subclass_of($property->getClassName(), 'Enumeration')) {
                 // field already added by makeSelectHead
                 continue;
             } elseif ($property->isInner()) {
                 $proto = call_user_func(array($property->getClassName(), 'proto'));
                 foreach ($proto->getPropertyList() as $innerProperty) {
                     $query->get(new DBField($innerProperty->getColumnName(), $parentTable));
                 }
                 continue;
             }
             $propertyDao = call_user_func(array($property->getClassName(), 'dao'));
             // add's custom dao's injection possibility
             if (!$propertyDao instanceof ProtoDAO) {
                 continue;
             }
             $tableAlias = $propertyDao->getJoinName($property->getColumnName(), $prefix);
             $fields = $propertyDao->getFields();
             if (!$query->hasJoinedTable($tableAlias)) {
                 $logic = Expression::eq(DBField::create($property->getColumnName(), $parentTable), DBField::create($propertyDao->getIdName(), $tableAlias));
                 if ($property->isRequired() && $parentRequired) {
                     $query->join($propertyDao->getTable(), $logic, $tableAlias);
                 } else {
                     $query->leftJoin($propertyDao->getTable(), $logic, $tableAlias);
                 }
             }
             foreach ($fields as $field) {
                 $query->get(new DBField($field, $tableAlias), $propertyDao->getJoinPrefix($property->getColumnName(), $prefix) . $field);
             }
             $this->joinProperties($query, $propertyDao, $tableAlias, $property->isRequired() && $parentRequired, $propertyDao->getJoinPrefix($property->getColumnName(), $prefix));
         }
     }
 }