本文整理汇总了PHP中SavedSearch::save方法的典型用法代码示例。如果您正苦于以下问题:PHP SavedSearch::save方法的具体用法?PHP SavedSearch::save怎么用?PHP SavedSearch::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SavedSearch
的用法示例。
在下文中一共展示了SavedSearch::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMain
public function testMain()
{
$savedSearch = new SavedSearch();
$savedSearch->name = 'test';
$savedSearch->search_module = 'Leads';
$savedSearch->save();
//test for record ID to verify that record is saved
$this->assertTrue(isset($savedSearch->id));
$this->assertEquals(36, strlen($savedSearch->id));
//test handleSave method
$this->handleSaveAndRetrieveSavedSearch($savedSearch->id);
//test returnSavedSearch method
$this->returnSavedSearch($savedSearch->id);
//test returnSavedSearchContents method
$this->returnSavedSearchContents($savedSearch->id);
//test handleDelete method
$this->handleDelete($savedSearch->id);
}
示例2: testGetByOwnerAndViewClassName
public function testGetByOwnerAndViewClassName()
{
$user = User::getByUsername('super');
$steven = User::getByUsername('steven');
$savedSearches = SavedSearch::getByOwnerAndViewClassName($user, 'someView');
$this->assertEquals(0, count($savedSearches));
$savedSearches = SavedSearch::getByOwnerAndViewClassName($steven, 'someView');
$this->assertEquals(0, count($savedSearches));
//create saved search for steven
$savedSearch = new SavedSearch();
$savedSearch->owner = $steven;
$savedSearch->name = 'Test Saved Search';
$savedSearch->serializedData = serialize(array('x', 'y'));
$savedSearch->viewClassName = 'someView';
$this->assertTrue($savedSearch->save());
$savedSearches = SavedSearch::getByOwnerAndViewClassName($user, 'someView');
$this->assertEquals(0, count($savedSearches));
$savedSearches = SavedSearch::getByOwnerAndViewClassName($steven, 'someView');
$this->assertEquals(1, count($savedSearches));
$savedSearches = SavedSearch::getByOwnerAndViewClassName($steven, 'someView2');
$this->assertEquals(0, count($savedSearches));
}
示例3: handleSave
function handleSave($prefix, $redirect = true, $useRequired = false, $id = null, $searchModuleBean)
{
global $current_user, $timedate;
$focus = new SavedSearch();
if ($id) {
$focus->retrieve($id);
}
if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
return null;
}
$ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced', 'Calls_divs', 'ACLRoles_divs');
$contents = $_REQUEST;
if ($id == null) {
$focus->name = $contents['saved_search_name'];
}
$focus->search_module = $contents['search_module'];
foreach ($contents as $input => $value) {
if (in_array($input, $ignored_inputs)) {
unset($contents[$input]);
continue;
}
//Filter date fields to ensure it is saved to DB format, but also avoid empty values
if (!empty($value) && preg_match('/^(start_range_|end_range_|range_)?(.*?)(_advanced|_basic)$/', $input, $match)) {
$field = $match[2];
if (isset($searchModuleBean->field_defs[$field]['type'])) {
$type = $searchModuleBean->field_defs[$field]['type'];
//Avoid macro values for the date types
if (($type == 'date' || $type == 'datetime' || $type == 'datetimecombo') && !preg_match('/^\\[.*?\\]$/', $value)) {
$db_format = $timedate->to_db_date($value, false);
$contents[$input] = $db_format;
} else {
if ($type == 'int' || $type == 'currency' || $type == 'decimal' || $type == 'float') {
if (preg_match('/[^\\d]/', $value)) {
require_once 'modules/Currencies/Currency.php';
$contents[$input] = unformat_number($value);
//Flag this value as having been unformatted
$contents[$input . '_unformatted_number'] = true;
//If the type is of currency and there was a currency symbol (non-digit), save the symbol
if ($type == 'currency' && preg_match('/^([^\\d])/', $value, $match)) {
$contents[$input . '_currency_symbol'] = $match[1];
}
} else {
//unset any flags
if (isset($contents[$input . '_unformatted_number'])) {
unset($contents[$input . '_unformatted_number']);
}
if (isset($contents[$input . '_currency_symbol'])) {
unset($contents[$input . '_currency_symbol']);
}
}
}
}
}
}
}
$contents['advanced'] = true;
$focus->contents = base64_encode(serialize($contents));
$focus->assigned_user_id = $current_user->id;
$focus->new_schema = true;
$saved_search_id = $focus->save();
$GLOBALS['log']->debug("Saved record with id of " . $focus->id);
$orderBy = empty($contents['orderBy']) ? 'name' : $contents['orderBy'];
$search_query = "&orderBy=" . $orderBy . "&sortOrder=" . $contents['sortOrder'] . "&query=" . $_REQUEST['query'] . "&searchFormTab=" . $_REQUEST['searchFormTab'] . '&showSSDIV=' . $contents['showSSDIV'];
if ($redirect) {
$this->handleRedirect($focus->search_module, $search_query, $saved_search_id, 'true');
}
}
示例4: getSearchDataForSort
private function getSearchDataForSort()
{
$savedSearch = new SavedSearch();
$savedSearch->name = 'something';
$savedSearch->viewClassName = 'view';
$savedSearch->serializedData = 'someString';
$saved = $savedSearch->save();
$searchModel = new AAASavedDynamicSearchFormTestModel(new AAA(false));
$listAttributesSelector = new ListAttributesSelector('AListView', 'TestModule');
$searchModel->setListAttributesSelector($listAttributesSelector);
$searchModel->dynamicStructure = '1 and 5';
$searchModel->dynamicClauses = array('a', 'b');
$searchModel->anyMixedAttributes = 'abcdef';
$searchModel->savedSearchId = $savedSearch->id;
$searchModel->setAnyMixedAttributesScope('xyz');
$searchModel->getListAttributesSelector()->setSelected(array('aaaMember', 'aaaMember2'));
$dataCollection = new SavedSearchAttributesDataCollection($searchModel);
return array('dataCollection' => $dataCollection, 'savedSearch' => $savedSearch);
}
示例5: handleSave
function handleSave($prefix, $redirect = true, $useRequired = false, $id = null)
{
global $current_user;
$focus = new SavedSearch();
if ($id) {
$focus->retrieve($id);
}
if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
return null;
}
$ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced', 'Calls_divs', 'ACLRoles_divs');
$contents = $_REQUEST;
if ($id == null) {
$focus->name = $contents['saved_search_name'];
}
$focus->search_module = $contents['search_module'];
foreach ($contents as $input => $value) {
if (in_array($input, $ignored_inputs)) {
unset($contents[$input]);
}
}
$contents['advanced'] = true;
$focus->contents = base64_encode(serialize($contents));
$focus->assigned_user_id = $current_user->id;
$focus->new_schema = true;
$saved_search_id = $focus->save();
$GLOBALS['log']->debug("Saved record with id of " . $focus->id);
$orderBy = empty($contents['orderBy']) ? 'name' : $contents['orderBy'];
$search_query = "&orderBy=" . $orderBy . "&sortOrder=" . $contents['sortOrder'] . "&query=" . $_REQUEST['query'] . "&searchFormTab=" . $_REQUEST['searchFormTab'] . '&showSSDIV=' . $contents['showSSDIV'];
$this->handleRedirect($focus->search_module, $search_query, $saved_search_id, 'true');
}
示例6: saveSearch
public function saveSearch()
{
$this->layout->body_class = 'user';
$title = Input::get('title', '');
$filter = Input::get('filter', '');
$location = Input::get('location', '');
$query = Input::get('query', '');
if (Auth::check()) {
$search = new SavedSearch();
$search->title = $title;
$search->filter = $filter;
$search->location = $location;
$search->query = $query;
$search->user = Auth::user()->id;
$search->datetime = date("Y-m-d H:i:s");
$search->save();
}
}
示例7: handleSave
function handleSave($prefix, $redirect = true, $useRequired = false, $id = null)
{
require_once 'log4php/LoggerManager.php';
global $current_user;
$focus = new SavedSearch();
if ($id) {
$focus->retrieve($id);
}
if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
return null;
}
$ignored_inputs = array('PHPSESSID', 'module', 'action', 'saved_search_name', 'saved_search_select', 'advanced');
$contents = array_merge($_POST, $_GET);
if ($id == null) {
$focus->name = $contents['saved_search_name'];
}
$focus->search_module = $contents['search_module'];
foreach ($contents as $input => $value) {
if (in_array($input, $ignored_inputs)) {
unset($contents[$input]);
}
}
$contents['advanced'] = true;
$focus->contents = base64_encode(serialize($contents));
$focus->assigned_user_id = $current_user->id;
$focus->new_schema = true;
$focus->search_module = $focus->search_module;
$saved_search_id = $focus->save();
$GLOBALS['log']->debug("Saved record with id of " . $focus->id);
$search_query = '';
foreach ($contents as $input => $value) {
if (is_array($value)) {
// handle multiselects
foreach ($value as $v) {
$search_query .= $input . '[]=' . $v . '&';
}
} else {
$search_query .= $input . '=' . $value . '&';
}
}
$this->handleRedirect($focus->search_module, $search_query, $saved_search_id, 'true');
}