From: Jagadedes Date: Tue, 14 Oct 2014 06:29:57 +0000 (+0530) Subject: #29762 Custom template integration in widget creation form DB part and bug fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a946a2b654a37b1285f8bad2fc78bbd260e5caae;p=com.zyxware.civiwci.git #29762 Custom template integration in widget creation form DB part and bug fixes --- diff --git a/CRM/Wci/BAO/Widget.php b/CRM/Wci/BAO/Widget.php index 782686a..a098a5c 100644 --- a/CRM/Wci/BAO/Widget.php +++ b/CRM/Wci/BAO/Widget.php @@ -126,4 +126,32 @@ class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget { } return FALSE; } + public static function getWidgetData($widgetId) { + + $query = "SELECT * FROM civicrm_wci_widget where id=".$widgetId; + $params = array(); + + $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget'); + + $data = array(); + while ($dao->fetch()) { + $data["title"] = $dao->title; + $data["logo_image"] = $dao->logo_image; + $data["image"] = $dao->image; + $data["button_title"] = $dao->button_title; + $data["progress_bar_id"] = $dao->button_link_to; + $data["description"] = strip_tags(base64_decode($dao->description)); + $data["size_variant"] = $dao->size_variant; + $data["color_title"] = $dao->color_title; + $data["color_title_bg"] = $dao->color_title_bg; + $data["color_progress_bar"] = $dao->color_progress_bar; + $data["color_widget_bg"] = $dao->color_widget_bg; + $data["color_description"] = $dao->color_description; + $data["color_border"] = $dao->color_border; + $data["color_button"] = $dao->color_button; + $data["color_button_bg"] = $dao->color_button_bg; + } + + return $data; + } } diff --git a/CRM/Wci/Form/CreateWidget.php b/CRM/Wci/Form/CreateWidget.php index a87d940..abe56df 100644 --- a/CRM/Wci/Form/CreateWidget.php +++ b/CRM/Wci/Form/CreateWidget.php @@ -189,10 +189,11 @@ where w.id=" . $this->_id; 'style_rules' => $wid_page[$dao->id]['style_rules'])); $this->setDefaults(array( 'override' => $wid_page[$dao->id]['override'])); - $cust_templ = base64_decode($wid_page[$dao->id]['custom_template']); - - $this->setDefaults(array( + if(true == $wid_page[$dao->id]['override']) { + $cust_templ = base64_decode($wid_page[$dao->id]['custom_template']); + $this->setDefaults(array( 'custom_template' => $cust_templ)); + } } } else { @@ -211,6 +212,8 @@ where w.id=" . $this->_id; $cust_tmpl = ""; $cust_tmpl_col = ""; $sql = ""; + $coma = ""; + $equals = ""; /** If override check is checked state then only save the custom_template to the database. otherwise wci uses default tpl file. */ @@ -218,9 +221,10 @@ where w.id=" . $this->_id; $override = $values['override']; $cust_tmpl = base64_encode(html_entity_decode($values['custom_template'])); $cust_tmpl_col = ", custom_template"; + $coma = "','"; + $equals = "='"; } if (isset($this->_id)) { - $cust_tmpl_col = "'" . $cust_tmpl_col . "='"; $sql = "UPDATE civicrm_wci_widget SET title = '". $values['title'] . "', logo_image = '" . $values['logo_image'] . "', image = '" . $values['image'] . "', button_title = '" . $values['button_title'] @@ -238,7 +242,7 @@ where w.id=" . $this->_id; . "', color_button = '" . $values['color_button'] . "', color_button_bg = '" . $values['color_button_bg'] . "', style_rules = '" . $values['style_rules'] . "', override = '" - . $override . $cust_tmpl_col . $cust_tmpl . "'"; + . $override . $cust_tmpl_col . $cust_tmpl . "' where id =" . $this->_id ; } else { $sql = "INSERT INTO civicrm_wci_widget (title, logo_image, image, @@ -256,9 +260,10 @@ where w.id=" . $this->_id; $values['color_widget_bg'] . "','" . $values['color_description'] . "','" . $values['color_border'] . "','" . $values['color_button'] . "','" . $values['color_button_bg'] . "','" . $values['style_rules'] . "','" . - $override . "','" . $cust_tmpl + $override . $coma . $cust_tmpl . "')"; - } + } + echo $sql; $errorScope = CRM_Core_TemporaryErrorScope::useException(); try { $transaction = new CRM_Core_Transaction();