Esempio n. 1
0
 /**
  * Create the where part for the query that selects the list options
  *
  * @param   array           $data            Current row data to use in placeholder replacements
  * @param   bool            $incWhere        Should the additional user defined WHERE statement be included
  * @param   string          $thisTableAlias  Db table alias
  * @param   array           $opts            Options
  * @param   JDatabaseQuery  $query           Append where to JDatabaseQuery object or return string (false)
  *
  * @return string|JDatabaseQuery
  */
 protected function buildQueryWhere($data = array(), $incWhere = true, $thisTableAlias = null, $opts = array(), $query = false)
 {
     $rowId = $this->getFormModel()->getRowId();
     $db = $this->getDb();
     $join = $this->getJoin();
     $fk = $db->qn($join->table_join_alias . '.' . $join->table_join_key);
     $params = $this->getParams();
     $formModel = $this->getFormModel();
     // Always filter on the current records tags (return no records if new row)
     $params->set('database_join_where_access', 1);
     if ($formModel->failedValidation()) {
         $pk = $db->qn($join->table_join_alias . '.' . $join->table_key);
         $name = $this->getFullName(true, false) . '_raw';
         $tagIds = FArrayHelper::getValue($data, $name, array());
         $tagIds = ArrayHelper::toInteger($tagIds);
         $where = FArrayHelper::emptyIsh($tagIds) ? '6 = -6' : $pk . ' IN (' . implode(', ', $tagIds) . ')';
     } else {
         // $$$ hugh - erm ... surely we don't want to select ALL tags on a new form?
         /*
         if (!empty($rowId))
         {
         	$where = $fk . ' = ' . $db->quote($rowId);
         }
         else
         {
         	$where = '';
         }
         */
         if (FArrayHelper::getValue($opts, 'mode', '') !== 'filter') {
             $where = $fk . ' = ' . $db->quote($rowId);
         } else {
             $where = '';
         }
     }
     $params->set('database_join_where_sql', $where);
     $where = parent::buildQueryWhere($data, $incWhere, $thisTableAlias, $opts, $query);
     return $where;
 }