Merge pull request #17568 from agileware/CIVICRM-1496
[civicrm-core.git] / CRM / Event / Form / Task / SaveSearch / Update.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This class provides the functionality to update a saved search
20 *
21 */
22 class CRM_Event_Form_Task_SaveSearch_Update extends CRM_Event_Form_Task_SaveSearch {
23
24 /**
25 * Build all the data structures needed to build the form.
26 *
27 * @return void
28 */
29 public function preProcess() {
30 parent::preProcess();
31
32 $this->_id = $this->get('ssID');
33 if (!$this->_id) {
34 // fetch the value from the group id gid
35 $gid = $this->get('gid');
36 $this->_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gid, 'saved_search_id');
37 }
38 }
39
40 /**
41 * Set default values for the form.
42 * the default values are retrieved from the database
43 *
44 *
45 * @return void
46 */
47 public function setDefaultValues() {
48
49 $defaults = [];
50 $params = [];
51
52 $params = ['saved_search_id' => $this->_id];
53 CRM_Contact_BAO_Group::retrieve($params, $defaults);
54
55 return $defaults;
56 }
57
58 }