type_id] = $r->name; } $form['stockprop_type_id'] = array( '#type' => 'radios', '#title' => t('Property Types'), '#options' => $types, '#default_value' => $this->options['stockprop_type_id'], '#required' => TRUE, '#description' => t('Select the type of property represented by this argument.'), ); $operators = array( '=' => t('Is equal to'), '!=' => t('Is not equal to'), '~' => t('Contains'), '!~' => t('Does not contain'), 'IS NOT NULL' => t('Is Present (Not Empty)'), 'IS NULL' => t('Is Absent (Empty)'), ); $form['operator'] = array( '#type' => 'radios', '#title' => 'Operator', '#description' => t('Specify how to compare the argument with the property values.'), '#options' => $operators, '#default_value' => $this->options['operator'], '#required' => TRUE, ); } /** * Build the query based upon the formula */ function query() { $argument = $this->argument; if (!empty($this->options['transform_dash'])) { $argument = strtr($argument, '-', ' '); } if (preg_match('/IS NOT NULL/', $this->options['operator'])) { $new_where_sql = "stock.stock_id IN (SELECT stockprop.stock_id FROM stockprop WHERE stockprop.type_id=" . $this->options['stockprop_type_id'] . ")"; } elseif (preg_match('/IS NULL/', $this->options['operator'])) { $new_where_sql = "stock.stock_id NOT IN (SELECT stockprop.stock_id FROM stockprop WHERE stockprop.type_id=" . $this->options['stockprop_type_id'] . ")"; } else { $new_where_sql = "stock.stock_id IN (SELECT stockprop.stock_id FROM stockprop " . "WHERE stockprop.type_id=" . $this->options['stockprop_type_id'] . " AND stockprop.value" . $this->options['operator'] . "'" . $argument . "')"; } $this->query->add_where($this->options['group'], $new_where_sql); } }