/**
* Get existing object names.
*
+ * @param array $criteria SQL criteria in nested array format (@see Databaes::getWhere)
* @param integer $limit_val maximum number of elements to return
* @return array object names
*/
- public function getObjectNames($limit_val = null) {
+ public function getObjectNames($criteria = [], $limit_val = null) {
$limit = '';
if(is_int($limit_val) && $limit_val > 0) {
$limit = sprintf(
$limit_val
);
}
+ $where = Database::getWhere($criteria);
$sql = 'SELECT DISTINCT ObjectName as objectname
FROM Object
+ ' . $where['where'] . '
ORDER BY ObjectName ' . $limit;
- $statement = Database::runQuery($sql);
+ $statement = Database::runQuery($sql, $where['params']);
$result = $statement->fetchAll(\PDO::FETCH_GROUP);
$values = array_keys($result);
return $values;
class ObjectNames extends BaculumAPIServer {
public function get() {
+ $misc = $this->getModule('misc');
$limit = $this->Request->contains('limit') ? (int)$this->Request['limit'] : null;
+ $objecttype = $this->Request->contains('objecttype') && $misc->isValidName($this->Request['objecttype']) ? $this->Request['objecttype'] : null;
- $this->output = $this->getModule('object')->getObjectNames($limit);
+ $params = [];
+ if (!empty($objecttype)) {
+ $params['Object.ObjectType'] = [];
+ $params['Object.ObjectType'][] = [
+ 'vals' => $objecttype
+ ];
+ }
+
+ $this->output = $this->getModule('object')->getObjectNames(
+ $params,
+ $limit
+ );
$this->error = ObjectError::ERROR_NO_ERRORS;
}
}