2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
37 /*********************************************************************************
39 * Description: The primary Function of this file is to manage all the data
40 * used by other files in this nodule. It should extend the SugarBean which implements
41 * all the basic database operations. Any custom behaviors can be implemented here by
42 * implementing functions available in the SugarBean.
43 ********************************************************************************/
50 class CampaignTracker extends SugarBean {
51 /* Foreach instance of the bean you will need to access the fields in the table.
52 * So define a variable for each one of them, the variable name should be same as the field name
53 * Use this module's vardef file as a reference to create these variables.
69 /* End field definitions*/
71 /* variable $table_name is used by SugarBean and methods in this file to constructs queries
72 * set this variables value to the table associated with this bean.
74 var $table_name = 'campaign_trkrs';
76 /*This variable overrides the object_name variable in SugarBean, wher it has a value of null.*/
77 var $object_name = 'CampaignTracker';
80 var $module_dir = 'CampaignTrackers';
82 /* This is a legacy variable, set its value to true for new modules*/
83 var $new_schema = true;
85 /* $column_fields holds a list of columns that exist in this bean's table. This list is referenced
86 * when fetching or saving data for the bean. As you modify a table you need to keep this up to date.
88 var $column_fields = Array(
96 // This is used to retrieve related fields from form posts.
97 var $additional_column_fields = Array('campaign_id');
98 var $relationship_fields = Array('campaing_id'=>'campaign');
100 var $required_fields = array('tracker_name'=>1,'tracker_url'=>1);
101 /*This bean's constructor*/
102 function CampaignTracker() {
107 //make sure that the url has a scheme, if not then add http:// scheme
108 if ($this->is_optout!=1 ){
109 $url = strtolower(trim($this->tracker_url));
110 if(!preg_match('/^(http|https|ftp):\/\//i', $url)){
111 $this->tracker_url = 'http://'.$url;
118 /* This method should return the summary text which is used to build the bread crumb navigation*/
119 /* Generally from this method you would return value of a field that is required and is of type string*/
120 function get_summary_text()
122 return "$this->tracker_name";
126 /* This method is used to generate query for the list form. The base implementation of this method
127 * uses the table_name and list_field variable to generate the basic query and then adds the custom field
128 * join and team filter. If you are implementing this function do not forget to consider the additional conditions.
131 function fill_in_additional_detail_fields() {
132 global $sugar_config;
134 //setup campaign name.
135 $query = "SELECT name from campaigns where id = '$this->campaign_id'";
136 $result =$this->db->query($query,true," Error filling in additional detail fields: ");
138 // Get the id and the name.
139 $row = $this->db->fetchByAssoc($result);
141 $this->campaign_name=$row['name'];
144 if (!class_exists('Administration')) {
147 $admin=new Administration();
148 $admin->retrieveSettings('massemailer'); //retrieve all admin settings.
149 if (isset($admin->settings['massemailer_tracking_entities_location_type']) and $admin->settings['massemailer_tracking_entities_location_type']=='2' and isset($admin->settings['massemailer_tracking_entities_location']) ) {
150 $this->message_url=$admin->settings['massemailer_tracking_entities_location'];
152 $this->message_url=$sugar_config['site_url'];
154 if ($this->is_optout == 1) {
155 $this->message_url .= '/index.php?entryPoint=removeme&identifier={MESSAGE_ID}';
157 $this->message_url .= '/index.php?entryPoint=campaign_trackerv2&track=' . $this->id;