Merged in feature/PMCORE-2389-B (pull request #7593)
PMCORE-2389 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -101,6 +101,29 @@ class Filter
|
|||||||
return $filter;
|
return $filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a filter of the advanced search for the current user
|
||||||
|
*
|
||||||
|
* @param string $userUid
|
||||||
|
* @param string $filterUid
|
||||||
|
* @param string $name
|
||||||
|
* @param object $filters
|
||||||
|
*/
|
||||||
|
public static function update($userUid, $filterUid, $name, $filters)
|
||||||
|
{
|
||||||
|
// Build object to serialize and save
|
||||||
|
$filter = new stdClass();
|
||||||
|
$filter->id = $filterUid;
|
||||||
|
$filter->name = $name;
|
||||||
|
$filter->filters = $filters;
|
||||||
|
|
||||||
|
// Update filter
|
||||||
|
Configuration::query()->where('CFG_UID', '=', self::ADVANCED_SEARCH_FILTER_KEY)
|
||||||
|
->where('OBJ_UID', '=', $filterUid)
|
||||||
|
->where('USR_UID', '=', $userUid)
|
||||||
|
->update(['CFG_VALUE' => json_encode($filter)]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a specific filter by filter Uid
|
* Delete a specific filter by filter Uid
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ class Configuration extends Model
|
|||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
|
protected $fillable = ['CFG_UID', 'OBJ_UID', 'CFG_VALUE', 'PRO_UID', 'USR_UID', 'APP_UID'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1537,6 +1537,39 @@ class Cases extends Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a filter of the advanced search for the current user
|
||||||
|
*
|
||||||
|
* @url PUT /advanced-search/filter/:filterUid
|
||||||
|
*
|
||||||
|
* @param string $filterUid {@min 32}{@max 32}
|
||||||
|
* @param string $name
|
||||||
|
* @param string $filters
|
||||||
|
*
|
||||||
|
* @throws RestException
|
||||||
|
*/
|
||||||
|
public function doPutAdvancedSearchFilter($filterUid, $name, $filters)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Create JSON object if is a serialized string
|
||||||
|
$filters = is_string($filters) ? json_decode($filters) : $filters;
|
||||||
|
|
||||||
|
// Get requested filter
|
||||||
|
$filter = Filter::getByUid($this->getUserId(), $filterUid);
|
||||||
|
|
||||||
|
// Update the requested filter if exists
|
||||||
|
if (!is_null($filter)) {
|
||||||
|
Filter::update($this->getUserId(), $filterUid, $name, $filters);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
}
|
||||||
|
// If not exists the requested filter throw an 404 error
|
||||||
|
if (is_null($filter)) {
|
||||||
|
throw new RestException(404, "Filter with Uid '{$filterUid}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a specific filter of the advanced search for the current user
|
* Delete a specific filter of the advanced search for the current user
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user