0a028ba4e75511b1ea907c8d0d6549563c48fb0e
3 require_once 'CRM/Core/Form.php';
6 * Form controller class
8 * @see http://wiki.civicrm.org/confluence/display/CRMDOC43/QuickForm+Reference
10 class CRM_Wci_Form_WCISettings
extends CRM_Core_Form
{
11 function buildQuickForm() {
12 $this->add('text', 'default_profile', ts('Default profile'),true)->setSize(45);
13 $this->add('text', 'widget_cache_timeout', ts('Widget cache timeout'),true)->setSize(45);
14 $this->addButtons(array(
22 $cacheTime = civicrm_api3('setting', 'getValue', array('group' => 'Wci Preference', 'name' => 'widget_cache_timeout'));
23 $defProf = civicrm_api3('setting', 'getValue', array('group' => 'Wci Preference', 'name' => 'default_wci_profile'));
24 /*$this->setDefaults(array(
25 'default_widget' => $widgetId));*/
26 $this->setDefaults(array(
27 'default_profile' => $defProf));
28 $this->setDefaults(array(
29 'widget_cache_timeout' => $cacheTime));
31 // export form elements
32 $this->assign('elementNames', $this->getRenderableElementNames());
34 CRM_Utils_System
::setTitle(ts('Widget Settings'));
36 parent
::buildQuickForm();
39 function postProcess() {
40 $values = $this->exportValues();
41 /*civicrm_api3('setting', 'create', array('domain_id' => 1, 'default_wci_widget' => $values['default_widget'],));*/
42 civicrm_api3('setting', 'create', array('sequential' => 1, 'default_wci_profile' => $values['default_profile']));
43 civicrm_api3('setting', 'create', array('sequential' => 1, 'widget_cache_timeout' => $values['widget_cache_timeout']));
44 CRM_Core_Session
::setStatus(ts('Widget settings are saved to database'), '', 'success');
45 parent
::postProcess();
48 function getProfiles() {
50 $result = civicrm_api3('Profile', 'get', $params);
51 $result = civicrm_api('Profile', 'getcount', $params);
54 function getWidgets() {
55 $query = "SELECT * FROM civicrm_wci_widget";
59 '' => ts('- select -'),
62 $dao = CRM_Core_DAO
::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
64 while ($dao->fetch()) {
65 $widgetlist[$dao->id
] = $dao->title
;
72 * Get the fields/elements defined in this form.
74 * @return array (string)
76 function getRenderableElementNames() {
77 // The _elements list includes some items which should not be
78 // auto-rendered in the loop -- such as "qfKey" and "buttons". These
79 // items don't have labels. We'll identify renderable by filtering on
81 $elementNames = array();
82 foreach ($this->_elements
as $element) {
83 $label = $element->getLabel();
85 $elementNames[] = $element->getName();