Passed
Push — scrutinizer-code-quality ( 09f5a1...c4c5fb )
by Adam
56:05 queued 14:08
created
XTemplate/xtpl.php 2 patches
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -124,45 +124,45 @@  discard block
 block discarded – undo
124 124
 
125 125
 /***[ variables ]***********************************************************/
126 126
 
127
-var $filecontents="";								/* raw contents of template file */
128
-var $blocks=array();								/* unparsed blocks */
129
-var $parsed_blocks=array();					/* parsed blocks */
130
-var $block_parse_order=array();			/* block parsing order for recursive parsing (sometimes reverse:) */
131
-var $sub_blocks=array();						/* store sub-block names for fast resetting */
132
-var $VARS=array();									/* variables array */
127
+var $filecontents = ""; /* raw contents of template file */
128
+var $blocks = array(); /* unparsed blocks */
129
+var $parsed_blocks = array(); /* parsed blocks */
130
+var $block_parse_order = array(); /* block parsing order for recursive parsing (sometimes reverse:) */
131
+var $sub_blocks = array(); /* store sub-block names for fast resetting */
132
+var $VARS = array(); /* variables array */
133 133
 var $alternate_include_directory = "";
134 134
 
135
-var $file_delim="/\{FILE\s*\"([^\"]+)\"\s*\}/m";  /* regexp for file includes */
136
-var $block_start_delim="<!-- ";			/* block start delimiter */
137
-var $block_end_delim="-->";					/* block end delimiter */
138
-var $block_start_word="BEGIN:";			/* block start word */
139
-var $block_end_word="END:";					/* block end word */
135
+var $file_delim = "/\{FILE\s*\"([^\"]+)\"\s*\}/m"; /* regexp for file includes */
136
+var $block_start_delim = "<!-- "; /* block start delimiter */
137
+var $block_end_delim = "-->"; /* block end delimiter */
138
+var $block_start_word = "BEGIN:"; /* block start word */
139
+var $block_end_word = "END:"; /* block end word */
140 140
 
141 141
 /* this makes the delimiters look like: <!-- BEGIN: block_name --> if you use my syntax. */
142 142
 
143
-var $NULL_STRING=array(""=>"");				/* null string for unassigned vars */
144
-var $NULL_BLOCK=array(""=>"");	/* null string for unassigned blocks */
145
-var $mainblock="";
146
-var $ERROR="";
147
-var $AUTORESET=1;										/* auto-reset sub blocks */
143
+var $NULL_STRING = array(""=>""); /* null string for unassigned vars */
144
+var $NULL_BLOCK = array(""=>""); /* null string for unassigned blocks */
145
+var $mainblock = "";
146
+var $ERROR = "";
147
+var $AUTORESET = 1; /* auto-reset sub blocks */
148 148
 
149 149
 /***[ constructor ]*********************************************************/
150 150
 
151
-function __construct ($file, $alt_include = "", $mainblock="main") {
151
+function __construct($file, $alt_include = "", $mainblock = "main") {
152 152
 	$this->alternate_include_directory = $alt_include;
153
-	$this->mainblock=$mainblock;
154
-	$this->filecontents=$this->r_getfile($file);	/* read in template file */
153
+	$this->mainblock = $mainblock;
154
+	$this->filecontents = $this->r_getfile($file); /* read in template file */
155 155
 	//if(substr_count($file, 'backup') == 1)_ppd($this->filecontents);
156
-	$this->blocks=$this->maketree($this->filecontents,$mainblock);	/* preprocess some stuff */
156
+	$this->blocks = $this->maketree($this->filecontents, $mainblock); /* preprocess some stuff */
157 157
 	//$this->scan_globals();
158 158
 }
159 159
 
160 160
     /**
161 161
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
162 162
      */
163
-    function XTemplate($file, $alt_include = "", $mainblock="main"){
163
+    function XTemplate($file, $alt_include = "", $mainblock = "main") {
164 164
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
165
-        if(isset($GLOBALS['log'])) {
165
+        if (isset($GLOBALS['log'])) {
166 166
             $GLOBALS['log']->deprecated($deprecatedMessage);
167 167
         }
168 168
         else {
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 	assign a variable
184 184
 */
185 185
 
186
-function assign ($name,$val="") {
186
+function assign($name, $val = "") {
187 187
 	if (is_array($name)) {
188 188
 		foreach ($name as $k => $v) {
189 189
 			$this->VARS[$k] = $v;
190 190
 		}
191 191
 	} else {
192
-		$this->VARS[$name]=$val;
192
+		$this->VARS[$name] = $val;
193 193
 	}
194 194
 }
195 195
 
196
-function append ($varname, $name,$val="") {
197
-	if(!isset($this->VARS[$varname])){
196
+function append($varname, $name, $val = "") {
197
+	if (!isset($this->VARS[$varname])) {
198 198
 		$this->VARS[$varname] = array();
199 199
 	}
200
-   if(is_array($this->VARS[$varname])){
200
+   if (is_array($this->VARS[$varname])) {
201 201
        $this->VARS[$varname][$name] = $val;
202 202
     }
203 203
 }
@@ -207,50 +207,50 @@  discard block
 block discarded – undo
207 207
 	parse a block
208 208
 */
209 209
 
210
-function parse ($bname) {
210
+function parse($bname) {
211 211
 	global $sugar_version, $sugar_config;
212 212
 
213 213
 	$this->assign('SUGAR_VERSION', $GLOBALS['js_version_key']);
214 214
 	$this->assign('JS_CUSTOM_VERSION', $sugar_config['js_custom_version']);
215 215
     $this->assign('VERSION_MARK', getVersionedPath(''));
216 216
 
217
-	if(empty($this->blocks[$bname]))
217
+	if (empty($this->blocks[$bname]))
218 218
 		return;
219 219
 
220
-	$copy=$this->blocks[$bname];
220
+	$copy = $this->blocks[$bname];
221 221
 	if (!isset($this->blocks[$bname]))
222
-		$this->set_error ("parse: blockname [$bname] does not exist");
223
-	preg_match_all("/\{([A-Za-z0-9\._]+?)}/",$this->blocks[$bname],$var_array);
224
-	$var_array=$var_array[1];
222
+		$this->set_error("parse: blockname [$bname] does not exist");
223
+	preg_match_all("/\{([A-Za-z0-9\._]+?)}/", $this->blocks[$bname], $var_array);
224
+	$var_array = $var_array[1];
225 225
 	foreach ($var_array as $k => $v) {
226
-		$sub=explode(".",$v);
227
-		if ($sub[0]=="_BLOCK_") {
226
+		$sub = explode(".", $v);
227
+		if ($sub[0] == "_BLOCK_") {
228 228
 			unset($sub[0]);
229
-			$bname2=implode(".",$sub);
229
+			$bname2 = implode(".", $sub);
230 230
 
231
-			if(isset($this->parsed_blocks[$bname2]))
231
+			if (isset($this->parsed_blocks[$bname2]))
232 232
 			{
233
-				$var=$this->parsed_blocks[$bname2];
233
+				$var = $this->parsed_blocks[$bname2];
234 234
 			}
235 235
 			else
236 236
 			{
237 237
 				$var = null;
238 238
 			}
239 239
 
240
-			$nul=(!isset($this->NULL_BLOCK[$bname2])) ? $this->NULL_BLOCK[""] : $this->NULL_BLOCK[$bname2];
241
-			$var=(empty($var))?$nul:trim($var);
240
+			$nul = (!isset($this->NULL_BLOCK[$bname2])) ? $this->NULL_BLOCK[""] : $this->NULL_BLOCK[$bname2];
241
+			$var = (empty($var)) ? $nul : trim($var);
242 242
 			// Commented out due to regular expression issue with '$' in replacement string.
243 243
 			//$copy=preg_replace("/\{".$v."\}/","$var",$copy);
244 244
 			// This should be faster and work better for '$'
245
-			$copy=str_replace("{".$v."}",$var,$copy);
245
+			$copy = str_replace("{".$v."}", $var, $copy);
246 246
 		} else {
247
-			$var=$this->VARS;
247
+			$var = $this->VARS;
248 248
 
249 249
 			foreach ($sub as $k1 => $v1)
250 250
 			{
251
-				if(is_array($var) && isset($var[$v1]))
251
+				if (is_array($var) && isset($var[$v1]))
252 252
 				{
253
-					$var=$var[$v1];
253
+					$var = $var[$v1];
254 254
 				}
255 255
 				else
256 256
 				{
@@ -258,27 +258,27 @@  discard block
 block discarded – undo
258 258
 				}
259 259
 			}
260 260
 
261
-			$nul=(!isset($this->NULL_STRING[$v])) ? ($this->NULL_STRING[""]) : ($this->NULL_STRING[$v]);
262
-			$var=(!isset($var))?$nul:$var;
261
+			$nul = (!isset($this->NULL_STRING[$v])) ? ($this->NULL_STRING[""]) : ($this->NULL_STRING[$v]);
262
+			$var = (!isset($var)) ? $nul : $var;
263 263
 			// Commented out due to regular expression issue with '$' in replacement string.
264 264
 			//$copy=preg_replace("/\{$v\}/","$var",$copy);
265 265
 			// This should be faster and work better for '$'
266 266
 
267 267
 			// this was periodically returning an array to string conversion error....
268
-			if(!is_array($var))
268
+			if (!is_array($var))
269 269
 			{
270
-				$copy=str_replace("{".$v."}",$var,$copy);
270
+				$copy = str_replace("{".$v."}", $var, $copy);
271 271
 			}
272 272
 		}
273 273
 	}
274 274
 
275
-	if(isset($this->parsed_blocks[$bname]))
275
+	if (isset($this->parsed_blocks[$bname]))
276 276
 	{
277
-		$this->parsed_blocks[$bname].=$copy;
277
+		$this->parsed_blocks[$bname] .= $copy;
278 278
 	}
279 279
 	else
280 280
 	{
281
-		$this->parsed_blocks[$bname]=$copy;
281
+		$this->parsed_blocks[$bname] = $copy;
282 282
 	}
283 283
 
284 284
 	// reset sub-blocks
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 /*
294 294
 	returns true if a block exists otherwise returns false.
295 295
 */
296
-function exists($bname){
296
+function exists($bname) {
297 297
 	return (!empty($this->parsed_blocks[$bname])) || (!empty($this->blocks[$bname]));
298 298
 }
299 299
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 /*
303 303
 	returns true if a block exists otherwise returns false.
304 304
 */
305
-function var_exists($bname,$vname){
306
-	if(!empty($this->blocks[$bname])){
307
-		return substr_count($this->blocks[$bname], '{'. $vname . '}') >0;
305
+function var_exists($bname, $vname) {
306
+	if (!empty($this->blocks[$bname])) {
307
+		return substr_count($this->blocks[$bname], '{'.$vname.'}') > 0;
308 308
 	}
309 309
 	return false;
310 310
 }
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 function rparse($bname) {
319 319
 	if (!empty($this->sub_blocks[$bname])) {
320 320
 		reset($this->sub_blocks[$bname]);
321
-		while (list($k,$v)=each($this->sub_blocks[$bname]))
321
+		while (list($k, $v) = each($this->sub_blocks[$bname]))
322 322
 			if (!empty($v))
323
-				$this->rparse($v,$indent."\t");
323
+				$this->rparse($v, $indent."\t");
324 324
 	}
325 325
 	$this->parse($bname);
326 326
 }
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 	inserts a loop ( call assign & parse )
331 331
 */
332 332
 
333
-function insert_loop($bname,$var,$value="") {
334
-	$this->assign($var,$value);
333
+function insert_loop($bname, $var, $value = "") {
334
+	$this->assign($var, $value);
335 335
 	$this->parse($bname);
336 336
 }
337 337
 
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 
343 343
 function text($bname) {
344 344
 
345
-    if(!empty($this->parsed_blocks)){
346
-	   return $this->parsed_blocks[isset($bname) ? $bname :$this->mainblock];
347
-    }else{
345
+    if (!empty($this->parsed_blocks)) {
346
+	   return $this->parsed_blocks[isset($bname) ? $bname : $this->mainblock];
347
+    } else {
348 348
         return '';
349 349
     }
350 350
 }
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 	prints the parsed text
355 355
 */
356 356
 
357
-function out ($bname) {
357
+function out($bname) {
358 358
 	global $focus;
359 359
 
360
-	if(isset($focus)){
360
+	if (isset($focus)) {
361 361
 		global $action;
362 362
 
363
-		if($focus && is_subclass_of($focus, 'SugarBean') && !$focus->ACLAccess($action)){
363
+		if ($focus && is_subclass_of($focus, 'SugarBean') && !$focus->ACLAccess($action)) {
364 364
 
365 365
 			ACLController::displayNoAccess(true);
366 366
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	resets the parsed text
377 377
 */
378 378
 
379
-function reset ($bname) {
380
-	$this->parsed_blocks[$bname]="";
379
+function reset($bname) {
380
+	$this->parsed_blocks[$bname] = "";
381 381
 }
382 382
 
383 383
 /***[ parsed ]**************************************************************/
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	returns true if block was parsed, false if not
386 386
 */
387 387
 
388
-function parsed ($bname) {
388
+function parsed($bname) {
389 389
 	return (!empty($this->parsed_blocks[$bname]));
390 390
 }
391 391
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	sets the string to replace in case the var was not assigned
395 395
 */
396 396
 
397
-function SetNullString($str,$varname="") {
398
-	$this->NULL_STRING[$varname]=$str;
397
+function SetNullString($str, $varname = "") {
398
+	$this->NULL_STRING[$varname] = $str;
399 399
 }
400 400
 
401 401
 /***[ SetNullBlock ]********************************************************/
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	sets the string to replace in case the block was not parsed
404 404
 */
405 405
 
406
-function SetNullBlock($str,$bname="") {
407
-	$this->NULL_BLOCK[$bname]=$str;
406
+function SetNullBlock($str, $bname = "") {
407
+	$this->NULL_BLOCK[$bname] = $str;
408 408
 }
409 409
 
410 410
 /***[ set_autoreset ]*******************************************************/
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 */
416 416
 
417 417
 function set_autoreset() {
418
-	$this->AUTORESET=1;
418
+	$this->AUTORESET = 1;
419 419
 }
420 420
 
421 421
 /***[ clear_autoreset ]*****************************************************/
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 */
427 427
 
428 428
 function clear_autoreset() {
429
-	$this->AUTORESET=0;
429
+	$this->AUTORESET = 0;
430 430
 }
431 431
 
432 432
 /***[ scan_globals ]********************************************************/
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 
437 437
 function scan_globals() {
438 438
 	reset($GLOBALS);
439
-	while (list($k,$v)=each($GLOBALS))
440
-		$GLOB[$k]=$v;
441
-	$this->assign("PHP",$GLOB);	/* access global variables as {PHP.HTTP_HOST} in your template! */
439
+	while (list($k, $v) = each($GLOBALS))
440
+		$GLOB[$k] = $v;
441
+	$this->assign("PHP", $GLOB); /* access global variables as {PHP.HTTP_HOST} in your template! */
442 442
 }
443 443
 
444 444
 /******
@@ -461,59 +461,59 @@  discard block
 block discarded – undo
461 461
 */
462 462
 
463 463
 
464
-function maketree($con,$block) {
465
-	$con2=explode($this->block_start_delim,$con);
466
-	$level=0;
467
-	$block_names=array();
468
-	$blocks=array();
464
+function maketree($con, $block) {
465
+	$con2 = explode($this->block_start_delim, $con);
466
+	$level = 0;
467
+	$block_names = array();
468
+	$blocks = array();
469 469
 	reset($con2);
470
-	while(list($k,$v)=each($con2)) {
471
-		$patt="($this->block_start_word|$this->block_end_word)\s*(\w+)\s*$this->block_end_delim(.*)";
472
-		if (preg_match_all("/$patt/ims",$v,$res, PREG_SET_ORDER)) {
470
+	while (list($k, $v) = each($con2)) {
471
+		$patt = "($this->block_start_word|$this->block_end_word)\s*(\w+)\s*$this->block_end_delim(.*)";
472
+		if (preg_match_all("/$patt/ims", $v, $res, PREG_SET_ORDER)) {
473 473
 			// $res[0][1] = BEGIN or END
474 474
 			// $res[0][2] = block name
475 475
 			// $res[0][3] = kinda content
476
-			if ($res[0][1]==$this->block_start_word) {
477
-				$parent_name=implode(".",$block_names);
478
-				$block_names[++$level]=$res[0][2];							/* add one level - array("main","table","row")*/
479
-				$cur_block_name=implode(".",$block_names);	/* make block name (main.table.row) */
480
-				$this->block_parse_order[]=$cur_block_name;	/* build block parsing order (reverse) */
476
+			if ($res[0][1] == $this->block_start_word) {
477
+				$parent_name = implode(".", $block_names);
478
+				$block_names[++$level] = $res[0][2]; /* add one level - array("main","table","row")*/
479
+				$cur_block_name = implode(".", $block_names); /* make block name (main.table.row) */
480
+				$this->block_parse_order[] = $cur_block_name; /* build block parsing order (reverse) */
481 481
 
482
-				if(array_key_exists($cur_block_name, $blocks))
482
+				if (array_key_exists($cur_block_name, $blocks))
483 483
 				{
484
-					$blocks[$cur_block_name].=$res[0][3];				/* add contents */
484
+					$blocks[$cur_block_name] .= $res[0][3]; /* add contents */
485 485
 				}
486 486
 				else
487 487
 				{
488
-					$blocks[$cur_block_name]=$res[0][3];				/* add contents */
488
+					$blocks[$cur_block_name] = $res[0][3]; /* add contents */
489 489
 				}
490 490
 
491 491
 				/* add {_BLOCK_.blockname} string to parent block */
492
-				if(array_key_exists($parent_name, $blocks))
492
+				if (array_key_exists($parent_name, $blocks))
493 493
 				{
494
-					$blocks[$parent_name].="{_BLOCK_.$cur_block_name}";
494
+					$blocks[$parent_name] .= "{_BLOCK_.$cur_block_name}";
495 495
 				}
496 496
 				else
497 497
 				{
498
-					$blocks[$parent_name]="{_BLOCK_.$cur_block_name}";
498
+					$blocks[$parent_name] = "{_BLOCK_.$cur_block_name}";
499 499
 				}
500 500
 
501
-				$this->sub_blocks[$parent_name][]=$cur_block_name;		/* store sub block names for autoresetting and recursive parsing */
502
-				$this->sub_blocks[$cur_block_name][]="";		/* store sub block names for autoresetting */
503
-			} else if ($res[0][1]==$this->block_end_word) {
501
+				$this->sub_blocks[$parent_name][] = $cur_block_name; /* store sub block names for autoresetting and recursive parsing */
502
+				$this->sub_blocks[$cur_block_name][] = ""; /* store sub block names for autoresetting */
503
+			} else if ($res[0][1] == $this->block_end_word) {
504 504
 				unset($block_names[$level--]);
505
-				$parent_name=implode(".",$block_names);
506
-				$blocks[$parent_name].=$res[0][3];	/* add rest of block to parent block */
505
+				$parent_name = implode(".", $block_names);
506
+				$blocks[$parent_name] .= $res[0][3]; /* add rest of block to parent block */
507 507
   			}
508 508
 		} else { /* no block delimiters found */
509
-			$index = implode(".",$block_names);
510
-			if(array_key_exists($index, $blocks))
509
+			$index = implode(".", $block_names);
510
+			if (array_key_exists($index, $blocks))
511 511
 			{
512
-				$blocks[].=$this->block_start_delim.$v;
512
+				$blocks[] .= $this->block_start_delim.$v;
513 513
 			}
514 514
 			else
515 515
 			{
516
-				$blocks[]=$this->block_start_delim.$v;
516
+				$blocks[] = $this->block_start_delim.$v;
517 517
 			}
518 518
 		}
519 519
 	}
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 	sets and gets error
528 528
 */
529 529
 
530
-function get_error()	{
531
-	return ($this->ERROR=="")?0:$this->ERROR;
530
+function get_error() {
531
+	return ($this->ERROR == "") ? 0 : $this->ERROR;
532 532
 }
533 533
 
534 534
 
535
-function set_error($str)	{
536
-	$this->ERROR=$str;
535
+function set_error($str) {
536
+	$this->ERROR = $str;
537 537
 }
538 538
 
539 539
 /***[ getfile ]*************************************************************/
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
 	if (!is_file($file))
553 553
 		$file = $this->alternate_include_directory.$file;
554 554
 
555
-	if(is_file($file))
555
+	if (is_file($file))
556 556
 	{
557
-		$file_text=file_get_contents($file);
557
+		$file_text = file_get_contents($file);
558 558
 
559 559
 	} else {
560 560
 		$this->set_error("[$file] does not exist");
561
-		$file_text="<b>__XTemplate fatal error: file [$file] does not exist__</b>";
561
+		$file_text = "<b>__XTemplate fatal error: file [$file] does not exist__</b>";
562 562
 	}
563 563
 
564 564
 	return $file_text;
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
 
572 572
 
573 573
 function r_getfile($file) {
574
-	$text=$this->getfile($file);
575
-	while (preg_match($this->file_delim,$text,$res)) {
576
-		$text2=$this->getfile($res[1]);
577
-		$text=str_replace($res[0], $text2, $text);
574
+	$text = $this->getfile($file);
575
+	while (preg_match($this->file_delim, $text, $res)) {
576
+		$text2 = $this->getfile($res[1]);
577
+		$text = str_replace($res[0], $text2, $text);
578 578
 	}
579 579
 	return $text;
580 580
 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -27 removed lines patch added patch discarded remove patch
@@ -164,8 +164,7 @@  discard block
 block discarded – undo
164 164
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
165 165
         if(isset($GLOBALS['log'])) {
166 166
             $GLOBALS['log']->deprecated($deprecatedMessage);
167
-        }
168
-        else {
167
+        } else {
169 168
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
170 169
         }
171 170
         self::__construct($file, $alt_include, $mainblock);
@@ -214,12 +213,14 @@  discard block
 block discarded – undo
214 213
 	$this->assign('JS_CUSTOM_VERSION', $sugar_config['js_custom_version']);
215 214
     $this->assign('VERSION_MARK', getVersionedPath(''));
216 215
 
217
-	if(empty($this->blocks[$bname]))
218
-		return;
216
+	if(empty($this->blocks[$bname])) {
217
+			return;
218
+	}
219 219
 
220 220
 	$copy=$this->blocks[$bname];
221
-	if (!isset($this->blocks[$bname]))
222
-		$this->set_error ("parse: blockname [$bname] does not exist");
221
+	if (!isset($this->blocks[$bname])) {
222
+			$this->set_error ("parse: blockname [$bname] does not exist");
223
+	}
223 224
 	preg_match_all("/\{([A-Za-z0-9\._]+?)}/",$this->blocks[$bname],$var_array);
224 225
 	$var_array=$var_array[1];
225 226
 	foreach ($var_array as $k => $v) {
@@ -231,8 +232,7 @@  discard block
 block discarded – undo
231 232
 			if(isset($this->parsed_blocks[$bname2]))
232 233
 			{
233 234
 				$var=$this->parsed_blocks[$bname2];
234
-			}
235
-			else
235
+			} else
236 236
 			{
237 237
 				$var = null;
238 238
 			}
@@ -251,8 +251,7 @@  discard block
 block discarded – undo
251 251
 				if(is_array($var) && isset($var[$v1]))
252 252
 				{
253 253
 					$var=$var[$v1];
254
-				}
255
-				else
254
+				} else
256 255
 				{
257 256
 					$var = null;
258 257
 				}
@@ -275,8 +274,7 @@  discard block
 block discarded – undo
275 274
 	if(isset($this->parsed_blocks[$bname]))
276 275
 	{
277 276
 		$this->parsed_blocks[$bname].=$copy;
278
-	}
279
-	else
277
+	} else
280 278
 	{
281 279
 		$this->parsed_blocks[$bname]=$copy;
282 280
 	}
@@ -284,8 +282,9 @@  discard block
 block discarded – undo
284 282
 	// reset sub-blocks
285 283
 	if ($this->AUTORESET && (!empty($this->sub_blocks[$bname]))) {
286 284
 		reset($this->sub_blocks[$bname]);
287
-		foreach ($this->sub_blocks[$bname] as $v)
288
-			$this->reset($v);
285
+		foreach ($this->sub_blocks[$bname] as $v) {
286
+					$this->reset($v);
287
+		}
289 288
 	}
290 289
 }
291 290
 
@@ -318,9 +317,10 @@  discard block
 block discarded – undo
318 317
 function rparse($bname) {
319 318
 	if (!empty($this->sub_blocks[$bname])) {
320 319
 		reset($this->sub_blocks[$bname]);
321
-		while (list($k,$v)=each($this->sub_blocks[$bname]))
322
-			if (!empty($v))
320
+		while (list($k,$v)=each($this->sub_blocks[$bname])) {
321
+					if (!empty($v))
323 322
 				$this->rparse($v,$indent."\t");
323
+		}
324 324
 	}
325 325
 	$this->parse($bname);
326 326
 }
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 
345 345
     if(!empty($this->parsed_blocks)){
346 346
 	   return $this->parsed_blocks[isset($bname) ? $bname :$this->mainblock];
347
-    }else{
347
+    } else{
348 348
         return '';
349 349
     }
350 350
 }
@@ -436,8 +436,9 @@  discard block
 block discarded – undo
436 436
 
437 437
 function scan_globals() {
438 438
 	reset($GLOBALS);
439
-	while (list($k,$v)=each($GLOBALS))
440
-		$GLOB[$k]=$v;
439
+	while (list($k,$v)=each($GLOBALS)) {
440
+			$GLOB[$k]=$v;
441
+	}
441 442
 	$this->assign("PHP",$GLOB);	/* access global variables as {PHP.HTTP_HOST} in your template! */
442 443
 }
443 444
 
@@ -482,8 +483,7 @@  discard block
 block discarded – undo
482 483
 				if(array_key_exists($cur_block_name, $blocks))
483 484
 				{
484 485
 					$blocks[$cur_block_name].=$res[0][3];				/* add contents */
485
-				}
486
-				else
486
+				} else
487 487
 				{
488 488
 					$blocks[$cur_block_name]=$res[0][3];				/* add contents */
489 489
 				}
@@ -492,8 +492,7 @@  discard block
 block discarded – undo
492 492
 				if(array_key_exists($parent_name, $blocks))
493 493
 				{
494 494
 					$blocks[$parent_name].="{_BLOCK_.$cur_block_name}";
495
-				}
496
-				else
495
+				} else
497 496
 				{
498 497
 					$blocks[$parent_name]="{_BLOCK_.$cur_block_name}";
499 498
 				}
@@ -510,8 +509,7 @@  discard block
 block discarded – undo
510 509
 			if(array_key_exists($index, $blocks))
511 510
 			{
512 511
 				$blocks[].=$this->block_start_delim.$v;
513
-			}
514
-			else
512
+			} else
515 513
 			{
516 514
 				$blocks[]=$this->block_start_delim.$v;
517 515
 			}
@@ -549,8 +547,9 @@  discard block
 block discarded – undo
549 547
 
550 548
 	// Pick which folder we should include from
551 549
 	// Prefer the local directory, then try the theme directory.
552
-	if (!is_file($file))
553
-		$file = $this->alternate_include_directory.$file;
550
+	if (!is_file($file)) {
551
+			$file = $this->alternate_include_directory.$file;
552
+	}
554 553
 
555 554
 	if(is_file($file))
556 555
 	{
Please login to merge, or discard this patch.
modules/jjwg_Address_Cache/jjwg_Address_Cache_sugar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@
 block discarded – undo
33 33
     /**
34 34
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
35 35
      */
36
-    function jjwg_Address_Cache_sugar(){
36
+    function jjwg_Address_Cache_sugar() {
37 37
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
38
-        if(isset($GLOBALS['log'])) {
38
+        if (isset($GLOBALS['log'])) {
39 39
             $GLOBALS['log']->deprecated($deprecatedMessage);
40 40
         }
41 41
         else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/jjwg_Address_Cache/jjwg_Address_Cache.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * Constructor
19 19
      */
20
-    function __construct($init=true) {
20
+    function __construct($init = true) {
21 21
 
22 22
         parent::__construct();
23 23
         // Admin Config Setting
24
-        if($init) $this->configuration();
24
+        if ($init) $this->configuration();
25 25
     }
26 26
 
27 27
     /**
28 28
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
29 29
      */
30
-    function jjwg_Address_Cache($init=true){
30
+    function jjwg_Address_Cache($init = true) {
31 31
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
32
-        if(isset($GLOBALS['log'])) {
32
+        if (isset($GLOBALS['log'])) {
33 33
             $GLOBALS['log']->deprecated($deprecatedMessage);
34 34
         }
35 35
         else {
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 
66 66
         if (!empty($this->settings['address_cache_get_enabled']) && !empty($address)) {
67 67
 
68
-            $query = "SELECT " . $this->table_name . ".* FROM " . $this->table_name . " WHERE " .
69
-                    $this->table_name . ".deleted = 0 AND " .
70
-                    $this->table_name . ".name='" . $this->db->quote($address) . "'";
68
+            $query = "SELECT ".$this->table_name.".* FROM ".$this->table_name." WHERE ".
69
+                    $this->table_name.".deleted = 0 AND ".
70
+                    $this->table_name.".name='".$this->db->quote($address)."'";
71 71
             //var_dump($query);
72 72
             $cache_result = $this->db->limitQuery($query, 0, 1);
73 73
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('sugarEntry') || !sugarEntry)
3
+if (!defined('sugarEntry') || !sugarEntry) {
4 4
     die('Not A Valid Entry Point');
5
+}
5 6
 
6 7
 require_once('modules/jjwg_Maps/jjwg_Maps.php');
7 8
 require_once('modules/jjwg_Address_Cache/jjwg_Address_Cache_sugar.php');
@@ -21,7 +22,9 @@  discard block
 block discarded – undo
21 22
 
22 23
         parent::__construct();
23 24
         // Admin Config Setting
24
-        if($init) $this->configuration();
25
+        if($init) {
26
+            $this->configuration();
27
+        }
25 28
     }
26 29
 
27 30
     /**
@@ -31,8 +34,7 @@  discard block
 block discarded – undo
31 34
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
32 35
         if(isset($GLOBALS['log'])) {
33 36
             $GLOBALS['log']->deprecated($deprecatedMessage);
34
-        }
35
-        else {
37
+        } else {
36 38
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
37 39
         }
38 40
         self::__construct($init);
Please login to merge, or discard this patch.
Dashlets/jjwg_Address_CacheDashlet/jjwg_Address_CacheDashlet.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 require_once('include/Dashlets/DashletGeneric.php');
5 5
 require_once('modules/jjwg_Address_Cache/jjwg_Address_Cache.php');
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
26 26
      */
27
-    function jjwg_Address_CacheDashlet($id, $def = null){
27
+    function jjwg_Address_CacheDashlet($id, $def = null) {
28 28
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
29
-        if(isset($GLOBALS['log'])) {
29
+        if (isset($GLOBALS['log'])) {
30 30
             $GLOBALS['log']->deprecated($deprecatedMessage);
31 31
         }
32 32
         else {
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 
4 6
 require_once('include/Dashlets/DashletGeneric.php');
5 7
 require_once('modules/jjwg_Address_Cache/jjwg_Address_Cache.php');
@@ -12,8 +14,9 @@  discard block
 block discarded – undo
12 14
 
13 15
         parent::__construct($id, $def);
14 16
 
15
-        if (empty($def['title']))
16
-            $this->title = translate('LBL_HOMEPAGE_TITLE', 'jjwg_Address_Cache');
17
+        if (empty($def['title'])) {
18
+                    $this->title = translate('LBL_HOMEPAGE_TITLE', 'jjwg_Address_Cache');
19
+        }
17 20
 
18 21
         $this->searchFields = $dashletData['jjwg_Address_CacheDashlet']['searchFields'];
19 22
         $this->columns = $dashletData['jjwg_Address_CacheDashlet']['columns'];
@@ -28,8 +31,7 @@  discard block
 block discarded – undo
28 31
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
29 32
         if(isset($GLOBALS['log'])) {
30 33
             $GLOBALS['log']->deprecated($deprecatedMessage);
31
-        }
32
-        else {
34
+        } else {
33 35
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
34 36
         }
35 37
         self::__construct($id, $def);
Please login to merge, or discard this patch.
modules/EmailMan/EmailMan.php 2 patches
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 
43
-class EmailMan extends SugarBean{
43
+class EmailMan extends SugarBean {
44 44
 	var $id;
45 45
 	var $deleted;
46 46
 	var $date_created;
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	var $send_attempts;
65 65
 	var $related_id;
66 66
 	var $related_type;
67
-	var $test=false;
67
+	var $test = false;
68 68
 	var $notes_array = array();
69
-    var $verified_email_marketing_ids =  array();
70
-	function toString(){
69
+    var $verified_email_marketing_ids = array();
70
+	function toString() {
71 71
 		return "EmailMan:\nid = $this->id ,user_id= $this->user_id module = $this->module , related_id = $this->related_id , related_type = $this->related_type ,list_id = $this->list_id, send_date_time= $this->send_date_time\n";
72 72
 	}
73 73
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
84 84
      */
85
-    public function EmailMan(){
85
+    public function EmailMan() {
86 86
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
87
-        if(isset($GLOBALS['log'])) {
87
+        if (isset($GLOBALS['log'])) {
88 88
             $GLOBALS['log']->deprecated($deprecatedMessage);
89 89
         }
90 90
         else {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 	var $new_schema = true;
98 98
 
99
-    function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) {
99
+    function create_new_list_query($order_by, $where, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $parentbean = null, $singleSelect = false, $ifListForExport = false) {
100 100
 		$query = array('select' => '', 'from' => '', 'where' => '', 'order_by' => '');
101 101
 
102 102
 
@@ -124,32 +124,32 @@  discard block
 block discarded – undo
124 124
 
125 125
                 $where_auto = " $this->table_name.deleted=0";
126 126
 
127
-        if($where != "")
127
+        if ($where != "")
128 128
 			$query['where'] = "WHERE $where AND ".$where_auto;
129 129
 		else
130 130
 			$query['where'] = "WHERE ".$where_auto;
131 131
 
132
-    	if(isset($params['group_by'])) {
132
+    	if (isset($params['group_by'])) {
133 133
             $query['group_by'] .= " GROUP BY {$params['group_by']}";
134 134
 		}
135 135
 
136 136
         $order_by = $this->process_order_by($order_by);
137 137
         if (!empty($order_by)) {
138
-            $query['order_by'] = ' ORDER BY ' . $order_by;
138
+            $query['order_by'] = ' ORDER BY '.$order_by;
139 139
         }
140 140
 
141 141
 		if ($return_array) {
142 142
 			return $query;
143 143
 		}
144 144
 
145
-		return  $query['select'] . $query['from'] . $query['where']. $query['order_by'];
145
+		return  $query['select'].$query['from'].$query['where'].$query['order_by'];
146 146
 
147 147
     } // if
148 148
 
149
-    function create_queue_items_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false) {
149
+    function create_queue_items_query($order_by, $where, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $parentbean = null, $singleSelect = false) {
150 150
 
151 151
 		if ($return_array) {
152
-			return parent::create_new_list_query($order_by, $where,$filter,$params, $show_deleted,$join_type, $return_array,$parentbean, $singleSelect);
152
+			return parent::create_new_list_query($order_by, $where, $filter, $params, $show_deleted, $join_type, $return_array, $parentbean, $singleSelect);
153 153
 		}
154 154
 
155 155
 		$query = "SELECT $this->table_name.* ,
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 					LEFT JOIN email_marketing ON email_marketing.id = $this->table_name.marketing_id ";
176 176
 
177 177
 		 //B.F. #37943
178
-		if( isset($params['group_by']) )
178
+		if (isset($params['group_by']))
179 179
 		{
180 180
 			$group_by = str_replace("emailman", "em", $params['group_by']);
181 181
 		    $query .= "INNER JOIN (select min(id) as id from emailman  em GROUP BY $group_by  ) secondary
@@ -184,21 +184,21 @@  discard block
 block discarded – undo
184 184
 
185 185
                 $where_auto = " $this->table_name.deleted=0";
186 186
 
187
-        if($where != "")
187
+        if ($where != "")
188 188
 			$query .= "WHERE $where AND ".$where_auto;
189 189
 		else
190 190
 			$query .= "WHERE ".$where_auto;
191 191
 
192 192
         $order_by = $this->process_order_by($order_by);
193 193
         if (!empty($order_by)) {
194
-            $query .= ' ORDER BY ' . $order_by;
194
+            $query .= ' ORDER BY '.$order_by;
195 195
         }
196 196
 
197 197
 		return $query;
198 198
 
199 199
     }
200 200
 
201
-	function create_list_query($order_by, $where, $show_deleted = 0){
201
+	function create_list_query($order_by, $where, $show_deleted = 0) {
202 202
 
203 203
 		$query = "SELECT $this->table_name.* ,
204 204
 					campaigns.name as campaign_name,
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 
224 224
                 $where_auto = " $this->table_name.deleted=0";
225 225
 
226
-        if($where != "")
226
+        if ($where != "")
227 227
 			$query .= "where $where AND ".$where_auto;
228 228
 		else
229 229
 			$query .= "where ".$where_auto;
230 230
 
231 231
         $order_by = $this->process_order_by($order_by);
232 232
         if (!empty($order_by)) {
233
-            $query .= ' ORDER BY ' . $order_by;
233
+            $query .= ' ORDER BY '.$order_by;
234 234
         }
235 235
 
236 236
 		return $query;
@@ -245,29 +245,29 @@  discard block
 block discarded – undo
245 245
         $related_id = $temp_array['RELATED_ID'];
246 246
         $is_person = SugarModule::get($related_type)->moduleImplements('Person');
247 247
 
248
-        if($is_person)
248
+        if ($is_person)
249 249
         {
250
-            $query = "SELECT first_name, last_name FROM ". strtolower($related_type) ." WHERE id ='". $related_id ."'";
250
+            $query = "SELECT first_name, last_name FROM ".strtolower($related_type)." WHERE id ='".$related_id."'";
251 251
         } else {
252
-            $query = "SELECT name FROM ". strtolower($related_type) ." WHERE id ='". $related_id ."'";
252
+            $query = "SELECT name FROM ".strtolower($related_type)." WHERE id ='".$related_id."'";
253 253
         }
254 254
 
255
-        $result=$this->db->query($query);
256
-        $row=$this->db->fetchByAssoc($result);
255
+        $result = $this->db->query($query);
256
+        $row = $this->db->fetchByAssoc($result);
257 257
 
258
-        if($row)
258
+        if ($row)
259 259
         {
260 260
         	$temp_array['RECIPIENT_NAME'] = $is_person ? $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '') : $row['name'];
261 261
         }
262 262
 
263 263
         //also store the recipient_email address
264
-        $query = "SELECT addr.email_address FROM email_addresses addr,email_addr_bean_rel eb WHERE eb.deleted=0 AND addr.id=eb.email_address_id AND bean_id ='". $related_id ."' AND primary_address = '1'";
264
+        $query = "SELECT addr.email_address FROM email_addresses addr,email_addr_bean_rel eb WHERE eb.deleted=0 AND addr.id=eb.email_address_id AND bean_id ='".$related_id."' AND primary_address = '1'";
265 265
 
266
-        $result=$this->db->query($query);
267
-        $row=$this->db->fetchByAssoc($result);
266
+        $result = $this->db->query($query);
267
+        $row = $this->db->fetchByAssoc($result);
268 268
         if ($row)
269 269
         {
270
-            $temp_array['RECIPIENT_EMAIL']=$row['email_address'];
270
+            $temp_array['RECIPIENT_EMAIL'] = $row['email_address'];
271 271
         }
272 272
 
273 273
         $this->email1 = $temp_array['RECIPIENT_EMAIL'];
@@ -277,38 +277,38 @@  discard block
 block discarded – undo
277 277
     }
278 278
 
279 279
 
280
-	function set_as_sent($email_address, $delete= true,$email_id=null, $email_type=null,$activity_type=null){
280
+	function set_as_sent($email_address, $delete = true, $email_id = null, $email_type = null, $activity_type = null) {
281 281
 
282 282
 		global $timedate;
283 283
 
284 284
 		$this->send_attempts++;
285 285
 		$this->id = (int)$this->id;
286
-		if($delete || $this->send_attempts > 5){
286
+		if ($delete || $this->send_attempts > 5) {
287 287
 
288 288
 			//create new campaign log record.
289 289
 
290 290
 			$campaign_log = new CampaignLog();
291
-			$campaign_log->campaign_id=$this->campaign_id;
292
-			$campaign_log->target_tracker_key=$this->target_tracker_key;
293
-			$campaign_log->target_id= $this->related_id;
294
-			$campaign_log->target_type=$this->related_type;
295
-            $campaign_log->marketing_id=$this->marketing_id;
291
+			$campaign_log->campaign_id = $this->campaign_id;
292
+			$campaign_log->target_tracker_key = $this->target_tracker_key;
293
+			$campaign_log->target_id = $this->related_id;
294
+			$campaign_log->target_type = $this->related_type;
295
+            $campaign_log->marketing_id = $this->marketing_id;
296 296
 			//if test suppress duplicate email address checking.
297 297
 			if (!$this->test) {
298
-				$campaign_log->more_information=$email_address;
298
+				$campaign_log->more_information = $email_address;
299 299
 			}
300
-			$campaign_log->activity_type=$activity_type;
301
-			$campaign_log->activity_date=$timedate->now();
302
-			$campaign_log->list_id=$this->list_id;
303
-			$campaign_log->related_id= $email_id;
304
-			$campaign_log->related_type=$email_type;
300
+			$campaign_log->activity_type = $activity_type;
301
+			$campaign_log->activity_date = $timedate->now();
302
+			$campaign_log->list_id = $this->list_id;
303
+			$campaign_log->related_id = $email_id;
304
+			$campaign_log->related_type = $email_type;
305 305
             $campaign_log->save();
306 306
 
307 307
 			$query = "DELETE FROM emailman WHERE id = $this->id";
308 308
 			$this->db->query($query);
309
-		}else{
309
+		} else {
310 310
 			//try to send the email again a day later.
311
-			$query = 'UPDATE ' . $this->table_name . " SET in_queue='1', send_attempts='$this->send_attempts', in_queue_date=". $this->db->now() ." WHERE id = $this->id";
311
+			$query = 'UPDATE '.$this->table_name." SET in_queue='1', send_attempts='$this->send_attempts', in_queue_date=".$this->db->now()." WHERE id = $this->id";
312 312
 			$this->db->query($query);
313 313
 		}
314 314
 	}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
      * @param string from_address_name The from address eg markeing <[email protected]>
331 331
      * @return
332 332
      */
333
-    function create_ref_email($marketing_id,$subject,$body_text,$body_html,$campagin_name,$from_address,$sender_id,$notes,$macro_nv,$newmessage,$from_address_name) {
333
+    function create_ref_email($marketing_id, $subject, $body_text, $body_html, $campagin_name, $from_address, $sender_id, $notes, $macro_nv, $newmessage, $from_address_name) {
334 334
 
335 335
        global $mod_Strings, $timedate;
336
-       $upd_ref_email=false;
336
+       $upd_ref_email = false;
337 337
        if ($newmessage or empty($this->ref_email->id)) {
338 338
            $this->ref_email = new Email();
339 339
            $this->ref_email->retrieve($marketing_id, true, false);
@@ -341,25 +341,25 @@  discard block
 block discarded – undo
341 341
            //the reference email should be updated when user swithces from test mode to regular mode,and, for every run in test mode, and is user
342 342
            //switches back to test mode.
343 343
            //this is to account for changes to email template.
344
-           $upd_ref_email=(!empty($this->ref_email->id) and $this->ref_email->parent_type=='test' and $this->ref_email->parent_id=='test');
344
+           $upd_ref_email = (!empty($this->ref_email->id) and $this->ref_email->parent_type == 'test' and $this->ref_email->parent_id == 'test');
345 345
           //following condition is for switching back to test mode.
346
-           if (!$upd_ref_email) $upd_ref_email=($this->test and !empty($this->ref_email->id) and empty($this->ref_email->parent_type) and empty($this->ref_email->parent_id));
346
+           if (!$upd_ref_email) $upd_ref_email = ($this->test and !empty($this->ref_email->id) and empty($this->ref_email->parent_type) and empty($this->ref_email->parent_id));
347 347
            if (empty($this->ref_email->id) or $upd_ref_email) {
348 348
                 //create email record.
349
-                $this->ref_email->id=$marketing_id;
349
+                $this->ref_email->id = $marketing_id;
350 350
                 $this->ref_email->date_sent = '';
351 351
 
352
-                if ($upd_ref_email==false) {
353
-                    $this->ref_email->new_with_id=true;
352
+                if ($upd_ref_email == false) {
353
+                    $this->ref_email->new_with_id = true;
354 354
                 }
355 355
 
356
-                $this->ref_email->to_addrs= '';
356
+                $this->ref_email->to_addrs = '';
357 357
                 $this->ref_email->to_addrs_ids = '';
358 358
                 $this->ref_email->to_addrs_names = '';
359
-                $this->ref_email->to_addrs_emails ='';
360
-                $this->ref_email->type= 'campaign';
359
+                $this->ref_email->to_addrs_emails = '';
360
+                $this->ref_email->type = 'campaign';
361 361
                 $this->ref_email->deleted = '0';
362
-                $this->ref_email->name = $campagin_name.': '.$subject ;
362
+                $this->ref_email->name = $campagin_name.': '.$subject;
363 363
                 $this->ref_email->description_html = $body_html;
364 364
                 $this->ref_email->description = $body_text;
365 365
                 $this->ref_email->from_addr = $from_address;
@@ -367,20 +367,20 @@  discard block
 block discarded – undo
367 367
                 $this->ref_email->assigned_user_id = $sender_id;
368 368
                 if ($this->test) {
369 369
                     $this->ref_email->parent_type = 'test';
370
-                    $this->ref_email->parent_id =  'test';
370
+                    $this->ref_email->parent_id = 'test';
371 371
                 } else {
372 372
                     $this->ref_email->parent_type = '';
373
-                    $this->ref_email->parent_id =  '';
373
+                    $this->ref_email->parent_id = '';
374 374
                 }
375 375
                 $this->ref_email->date_start = $timedate->nowDate();
376 376
                 $this->ref_email->time_start = $timedate->asUserTime($timedate->getNow(true));
377 377
 
378
-                $this->ref_email->status='sent';
378
+                $this->ref_email->status = 'sent';
379 379
                 $retId = $this->ref_email->save();
380 380
 
381
-                foreach($notes as $note) {
382
-                    if($note->object_name == 'Note') {
383
-                        if (! empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
381
+                foreach ($notes as $note) {
382
+                    if ($note->object_name == 'Note') {
383
+                        if (!empty($note->file->temp_file_location) && is_file($note->file->temp_file_location)) {
384 384
                             $file_location = $note->file->temp_file_location;
385 385
                             $filename = $note->file->original_file_name;
386 386
                             $mime_type = $note->file->mime_type;
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
                             $filename = $note->id.$note->filename;
390 390
                             $mime_type = $note->file_mime_type;
391 391
                         }
392
-                    } elseif($note->object_name == 'DocumentRevision') { // from Documents
392
+                    } elseif ($note->object_name == 'DocumentRevision') { // from Documents
393 393
                         $filename = $note->id.$note->filename;
394 394
                         $file_location = "upload://$filename";
395 395
                         $mime_type = $note->file_mime_type;
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
                     $noteAudit->parent_id = $retId;
400 400
                     $noteAudit->parent_type = $this->ref_email->module_dir;
401 401
                     $noteAudit->description = "[".$note->filename."] ".$mod_strings['LBL_ATTACHMENT_AUDIT'];
402
-                    $noteAudit->filename=$filename;
403
-                    $noteAudit->file_mime_type=$mime_type;
404
-                    $noteAudit_id=$noteAudit->save();
402
+                    $noteAudit->filename = $filename;
403
+                    $noteAudit->file_mime_type = $mime_type;
404
+                    $noteAudit_id = $noteAudit->save();
405 405
 
406 406
                     UploadFile::duplicate_file($note->id, $noteAudit_id, $filename);
407 407
                 }
@@ -415,28 +415,28 @@  discard block
 block discarded – undo
415 415
             $this->ref_email->load_relationship('accounts');
416 416
        }
417 417
 
418
-       if (!empty($this->related_id ) && !empty($this->related_type)) {
418
+       if (!empty($this->related_id) && !empty($this->related_type)) {
419 419
 
420 420
             //save relationships.
421
-            switch ($this->related_type)  {
421
+            switch ($this->related_type) {
422 422
                 case 'Users':
423
-                    $rel_name="users";
423
+                    $rel_name = "users";
424 424
                     break;
425 425
 
426 426
                 case 'Prospects':
427
-                    $rel_name="prospects";
427
+                    $rel_name = "prospects";
428 428
                     break;
429 429
 
430 430
                 case 'Contacts':
431
-                    $rel_name="contacts";
431
+                    $rel_name = "contacts";
432 432
                     break;
433 433
 
434 434
                 case 'Leads':
435
-                    $rel_name="leads";
435
+                    $rel_name = "leads";
436 436
                     break;
437 437
 
438 438
                 case 'Accounts':
439
-                    $rel_name="accounts";
439
+                    $rel_name = "accounts";
440 440
                     break;
441 441
             }
442 442
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
             $campaignData = serialize($macro_nv);
445 445
 
446 446
             //required for one email per campaign per marketing message.
447
-            $this->ref_email->$rel_name->add($this->related_id,array('campaign_data'=>$this->db->quote($campaignData)));
447
+            $this->ref_email->$rel_name->add($this->related_id, array('campaign_data'=>$this->db->quote($campaignData)));
448 448
        }
449 449
        return $this->ref_email->id;
450 450
     }
@@ -452,20 +452,20 @@  discard block
 block discarded – undo
452 452
    /**
453 453
     * The function creates a copy of email send to each target.
454 454
     */
455
-    function create_indiv_email($module,$mail) {
455
+    function create_indiv_email($module, $mail) {
456 456
 
457 457
         global $locale, $timedate;
458 458
         $email = new Email();
459
-        $email->to_addrs= $module->name . '&lt;'.$module->email1.'&gt;';
460
-        $email->to_addrs_ids = $module->id .';';
461
-        $email->to_addrs_names = $module->name . ';';
462
-        $email->to_addrs_emails = $module->email1 . ';';
463
-        $email->type= 'archived';
459
+        $email->to_addrs = $module->name.'&lt;'.$module->email1.'&gt;';
460
+        $email->to_addrs_ids = $module->id.';';
461
+        $email->to_addrs_names = $module->name.';';
462
+        $email->to_addrs_emails = $module->email1.';';
463
+        $email->type = 'archived';
464 464
         $email->deleted = '0';
465
-        $email->name = $this->current_campaign->name.': '.$mail->Subject ;
465
+        $email->name = $this->current_campaign->name.': '.$mail->Subject;
466 466
         if ($mail->ContentType == "text/plain") {
467 467
             $email->description = $mail->Body;
468
-            $email->description_html =null;
468
+            $email->description_html = null;
469 469
         } else {
470 470
             $email->description_html = $mail->Body;
471 471
             $email->description = $mail->AltBody;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
         $email->from_addr = $mail->From;
474 474
         $email->assigned_user_id = $this->user_id;
475 475
         $email->parent_type = $this->related_type;
476
-        $email->parent_id = $this->related_id ;
476
+        $email->parent_id = $this->related_id;
477 477
 
478 478
         $email->date_start = $timedate->nowDbDate();
479 479
         $email->time_start = $timedate->asDbTime($timedate->getNow());
480
-        $email->status='sent';
480
+        $email->status = 'sent';
481 481
         $retId = $email->save();
482 482
 
483
-        foreach($this->notes_array as $note) {
484
-            if(!class_exists('Note')) {
483
+        foreach ($this->notes_array as $note) {
484
+            if (!class_exists('Note')) {
485 485
 
486 486
             }
487 487
             // create "audit" email without duping off the file to save on disk space
@@ -492,28 +492,28 @@  discard block
 block discarded – undo
492 492
             $noteAudit->save();
493 493
         }
494 494
 
495
-        if (!empty($this->related_id ) && !empty($this->related_type)) {
495
+        if (!empty($this->related_id) && !empty($this->related_type)) {
496 496
 
497 497
                 //save relationships.
498
-                switch ($this->related_type)  {
498
+                switch ($this->related_type) {
499 499
                     case 'Users':
500
-                        $rel_name="users";
500
+                        $rel_name = "users";
501 501
                         break;
502 502
 
503 503
                     case 'Prospects':
504
-                        $rel_name="prospects";
504
+                        $rel_name = "prospects";
505 505
                         break;
506 506
 
507 507
                     case 'Contacts':
508
-                        $rel_name="contacts";
508
+                        $rel_name = "contacts";
509 509
                         break;
510 510
 
511 511
                     case 'Leads':
512
-                        $rel_name="leads";
512
+                        $rel_name = "leads";
513 513
                         break;
514 514
 
515 515
                     case 'Accounts':
516
-                        $rel_name="accounts";
516
+                        $rel_name = "accounts";
517 517
                         break;
518 518
                 }
519 519
 
@@ -536,69 +536,69 @@  discard block
 block discarded – undo
536 536
 
537 537
             }
538 538
             $email_marketing = new EmailMarketing();
539
-            $ret=$email_marketing->retrieve($marketing_id);
539
+            $ret = $email_marketing->retrieve($marketing_id);
540 540
             if (empty($ret)) {
541
-                $GLOBALS['log']->fatal('Error retrieving marketing message for the email campaign. marketing_id = ' .$marketing_id);
541
+                $GLOBALS['log']->fatal('Error retrieving marketing message for the email campaign. marketing_id = '.$marketing_id);
542 542
                 return false;
543 543
             }
544 544
 
545 545
             //verify the email template.
546 546
             if (empty($email_marketing->template_id)) {
547
-                $GLOBALS['log']->fatal('Error retrieving template for the email campaign. marketing_id = ' .$marketing_id);
547
+                $GLOBALS['log']->fatal('Error retrieving template for the email campaign. marketing_id = '.$marketing_id);
548 548
                 return false;
549 549
             }
550 550
 
551 551
             if (!class_exists('EmailTemplate')) {
552 552
 
553 553
             }
554
-            $emailtemplate= new EmailTemplate();
554
+            $emailtemplate = new EmailTemplate();
555 555
 
556
-            $ret=$emailtemplate->retrieve($email_marketing->template_id);
556
+            $ret = $emailtemplate->retrieve($email_marketing->template_id);
557 557
             if (empty($ret)) {
558
-                $GLOBALS['log']->fatal('Error retrieving template for the email campaign. template_id = ' .$email_marketing->template_id);
558
+                $GLOBALS['log']->fatal('Error retrieving template for the email campaign. template_id = '.$email_marketing->template_id);
559 559
                 return false;
560 560
             }
561 561
 
562 562
             if (empty($emailtemplate->subject) and empty($emailtemplate->body) and empty($emailtemplate->body_html)) {
563
-                $GLOBALS['log']->fatal('Email template is empty. email_template_id=' .$email_marketing->template_id);
563
+                $GLOBALS['log']->fatal('Email template is empty. email_template_id='.$email_marketing->template_id);
564 564
 				return false;
565 565
             }
566 566
 
567 567
         }
568
-        $this->verified_email_marketing_ids[$marketing_id]=1;
568
+        $this->verified_email_marketing_ids[$marketing_id] = 1;
569 569
 
570 570
         return true;
571 571
     }
572
-	function sendEmail($mail,$save_emails=1,$testmode=false){
573
-	    $this->test=$testmode;
572
+	function sendEmail($mail, $save_emails = 1, $testmode = false) {
573
+	    $this->test = $testmode;
574 574
 
575 575
 		global $beanList, $beanFiles, $sugar_config;
576 576
 		global $mod_strings;
577 577
         global $locale;
578 578
         $OBCharset = $locale->getPrecedentPreference('default_email_charset');
579
-		$mod_strings = return_module_language( $sugar_config['default_language'], 'EmailMan');
579
+		$mod_strings = return_module_language($sugar_config['default_language'], 'EmailMan');
580 580
 
581 581
 		//get tracking entities locations.
582 582
 		if (!isset($this->tracking_url)) {
583 583
 			if (!class_exists('Administration')) {
584 584
 
585 585
 			}
586
-			$admin=new Administration();
586
+			$admin = new Administration();
587 587
 			$admin->retrieveSettings('massemailer'); //retrieve all admin settings.
588
-		    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']) ) {
589
-				$this->tracking_url=$admin->settings['massemailer_tracking_entities_location'];
588
+		    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'])) {
589
+				$this->tracking_url = $admin->settings['massemailer_tracking_entities_location'];
590 590
 		    } else {
591
-				$this->tracking_url=$sugar_config['site_url'];
591
+				$this->tracking_url = $sugar_config['site_url'];
592 592
 		    }
593 593
 		}
594 594
 
595 595
         //make sure tracking url ends with '/' character
596 596
         $strLen = strlen($this->tracking_url);
597
-        if($this->tracking_url{$strLen-1} !='/'){
598
-            $this->tracking_url .='/';
597
+        if ($this->tracking_url{$strLen - 1} != '/') {
598
+            $this->tracking_url .= '/';
599 599
         }
600 600
 
601
-		if(!isset($beanList[$this->related_type])){
601
+		if (!isset($beanList[$this->related_type])) {
602 602
 			return false;
603 603
 		}
604 604
 		$class = $beanList[$this->related_type];
@@ -621,15 +621,15 @@  discard block
 block discarded – undo
621 621
         if (!$this->is_primary_email_address($module)) {
622 622
             //no primary email address designated, do not send out email, create campaign log
623 623
             //of type send error to denote that this user was not emailed
624
-            $this->set_as_sent($module->email1, true,null,null,'send error');
624
+            $this->set_as_sent($module->email1, true, null, null, 'send error');
625 625
             //create fatal logging for easy review of cause.
626
-            $GLOBALS['log']->fatal('Email Address provided is not Primary Address for email with id ' . $module->email1 . "' Emailman id=$this->id");
626
+            $GLOBALS['log']->fatal('Email Address provided is not Primary Address for email with id '.$module->email1."' Emailman id=$this->id");
627 627
             return true;
628 628
         }
629 629
 
630 630
 		if (!$this->valid_email_address($module->email1)) {
631
-			$this->set_as_sent($module->email1, true,null,null,'invalid email');
632
-			$GLOBALS['log']->fatal('Encountered invalid email address' . $module->email1 . " Emailman id=$this->id");
631
+			$this->set_as_sent($module->email1, true, null, null, 'invalid email');
632
+			$GLOBALS['log']->fatal('Encountered invalid email address'.$module->email1." Emailman id=$this->id");
633 633
 			return true;
634 634
 		}
635 635
 
@@ -640,33 +640,33 @@  discard block
 block discarded – undo
640 640
             && (!isset($module->invalid_email)
641 641
                     || ($module->invalid_email !== 'on'
642 642
                         && $module->invalid_email !== 1
643
-                        && $module->invalid_email !== '1'))){
644
-            $lower_email_address=strtolower($module->email1);
643
+                        && $module->invalid_email !== '1'))) {
644
+            $lower_email_address = strtolower($module->email1);
645 645
 			//test against indivdual address.
646 646
 			if (isset($this->restricted_addresses) and isset($this->restricted_addresses[$lower_email_address])) {
647
-				$this->set_as_sent($lower_email_address, true,null,null,'blocked');
647
+				$this->set_as_sent($lower_email_address, true, null, null, 'blocked');
648 648
 				return true;
649 649
 			}
650 650
 			//test against restricted domains
651
-			$at_pos=strrpos($lower_email_address,'@');
651
+			$at_pos = strrpos($lower_email_address, '@');
652 652
 			if ($at_pos !== false) {
653 653
 				foreach ($this->restricted_domains as $domain=>$value) {
654
-					$pos=strrpos($lower_email_address,$domain);
654
+					$pos = strrpos($lower_email_address, $domain);
655 655
 					if ($pos !== false && $pos > $at_pos) {
656 656
 						//found
657
-						$this->set_as_sent($lower_email_address, true,null,null,'blocked');
657
+						$this->set_as_sent($lower_email_address, true, null, null, 'blocked');
658 658
 						return true;
659 659
 					}
660 660
 				}
661 661
 			}
662 662
 
663 663
 			//test for duplicate email address by marketing id.
664
-            $dup_query="select id from campaign_log where more_information='".$this->db->quote($module->email1)."' and marketing_id='".$this->marketing_id."'";
665
-			$dup=$this->db->query($dup_query);
666
-			$dup_row=$this->db->fetchByAssoc($dup);
664
+            $dup_query = "select id from campaign_log where more_information='".$this->db->quote($module->email1)."' and marketing_id='".$this->marketing_id."'";
665
+			$dup = $this->db->query($dup_query);
666
+			$dup_row = $this->db->fetchByAssoc($dup);
667 667
 			if (!empty($dup_row)) {
668 668
 				//we have seen this email address before
669
-				$this->set_as_sent($module->email1,true,null,null,'blocked');
669
+				$this->set_as_sent($module->email1, true, null, null, 'blocked');
670 670
 				return true;
671 671
 			}
672 672
 
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 
678 678
 				}
679 679
 
680
-				$this->current_emailmarketing=new EmailMarketing();
680
+				$this->current_emailmarketing = new EmailMarketing();
681 681
 
682 682
 			}
683 683
 			if (empty($this->current_emailmarketing->id) or $this->current_emailmarketing->id !== $this->marketing_id) {
@@ -690,24 +690,24 @@  discard block
 block discarded – undo
690 690
 				if (!class_exists('EmailTemplate')) {
691 691
 
692 692
 				}
693
-				$this->current_emailtemplate= new EmailTemplate();
693
+				$this->current_emailtemplate = new EmailTemplate();
694 694
 
695 695
 				$this->current_emailtemplate->retrieve($this->current_emailmarketing->template_id);
696 696
 
697 697
 				//escape email template contents.
698
-				$this->current_emailtemplate->subject=from_html($this->current_emailtemplate->subject);
699
-				$this->current_emailtemplate->body_html=from_html($this->current_emailtemplate->body_html);
700
-				$this->current_emailtemplate->body=from_html($this->current_emailtemplate->body);
698
+				$this->current_emailtemplate->subject = from_html($this->current_emailtemplate->subject);
699
+				$this->current_emailtemplate->body_html = from_html($this->current_emailtemplate->body_html);
700
+				$this->current_emailtemplate->body = from_html($this->current_emailtemplate->body);
701 701
 
702 702
 				$q = "SELECT * FROM notes WHERE parent_id = '".$this->current_emailtemplate->id."' AND deleted = 0";
703 703
 				$r = $this->db->query($q);
704 704
 
705 705
 				// cn: bug 4684 - initialize the notes array, else old data is still around for the next round
706 706
 				$this->notes_array = array();
707
-                if (!class_exists('Note')){
707
+                if (!class_exists('Note')) {
708 708
                 	require_once('modules/Notes/Note.php');
709 709
 				}
710
-				while($a = $this->db->fetchByAssoc($r)) {
710
+				while ($a = $this->db->fetchByAssoc($r)) {
711 711
 					$noteTemplate = new Note();
712 712
 					$noteTemplate->retrieve($a['id']);
713 713
 					$this->notes_array[] = $noteTemplate;
@@ -715,16 +715,16 @@  discard block
 block discarded – undo
715 715
 			}
716 716
 
717 717
 			// fetch mailbox details..
718
-			if(empty($this->current_mailbox)) {
718
+			if (empty($this->current_mailbox)) {
719 719
 				if (!class_exists('InboundEmail')) {
720 720
 
721 721
 				}
722
-				$this->current_mailbox= new InboundEmail();
722
+				$this->current_mailbox = new InboundEmail();
723 723
 			}
724 724
 			if (empty($this->current_mailbox->id) or $this->current_mailbox->id !== $this->current_emailmarketing->inbound_email_id) {
725 725
 				$this->current_mailbox->retrieve($this->current_emailmarketing->inbound_email_id);
726 726
 				//extract the email address.
727
-				$this->mailbox_from_addr=$this->current_mailbox->get_stored_options('from_addr','[email protected]',null);
727
+				$this->mailbox_from_addr = $this->current_mailbox->get_stored_options('from_addr', '[email protected]', null);
728 728
 			}
729 729
 
730 730
 			// fetch campaign details..
@@ -732,53 +732,53 @@  discard block
 block discarded – undo
732 732
 				if (!class_exists('Campaign')) {
733 733
 
734 734
 				}
735
-				$this->current_campaign= new Campaign();
735
+				$this->current_campaign = new Campaign();
736 736
 			}
737 737
 			if (empty($this->current_campaign->id) or $this->current_campaign->id !== $this->current_emailmarketing->campaign_id) {
738 738
 				$this->current_campaign->retrieve($this->current_emailmarketing->campaign_id);
739 739
 
740 740
 				//load defined tracked_urls
741 741
 				$this->current_campaign->load_relationship('tracked_urls');
742
-				$query_array=$this->current_campaign->tracked_urls->getQuery(true);
743
-				$query_array['select']="SELECT tracker_name, tracker_key, id, is_optout ";
744
-				$result=$this->current_campaign->db->query(implode(' ',$query_array));
745
-
746
-				$this->has_optout_links=false;
747
-				$this->tracker_urls=array();
748
-				while (($row=$this->current_campaign->db->fetchByAssoc($result)) != null) {
749
-					$this->tracker_urls['{'.$row['tracker_name'].'}']=$row;
742
+				$query_array = $this->current_campaign->tracked_urls->getQuery(true);
743
+				$query_array['select'] = "SELECT tracker_name, tracker_key, id, is_optout ";
744
+				$result = $this->current_campaign->db->query(implode(' ', $query_array));
745
+
746
+				$this->has_optout_links = false;
747
+				$this->tracker_urls = array();
748
+				while (($row = $this->current_campaign->db->fetchByAssoc($result)) != null) {
749
+					$this->tracker_urls['{'.$row['tracker_name'].'}'] = $row;
750 750
 					//has the user defined opt-out links for the campaign.
751
-					if ($row['is_optout']==1) {
752
-						$this->has_optout_links=true;
751
+					if ($row['is_optout'] == 1) {
752
+						$this->has_optout_links = true;
753 753
 					}
754 754
 				}
755 755
 			}
756 756
 
757 757
 			$mail->ClearAllRecipients();
758 758
 			$mail->ClearReplyTos();
759
-			$mail->Sender	= $this->mailbox_from_addr;
759
+			$mail->Sender = $this->mailbox_from_addr;
760 760
 			$mail->From     = $this->mailbox_from_addr;
761 761
 			$mail->FromName = $locale->translateCharsetMIME(trim($this->current_emailmarketing->from_name), 'UTF-8', $OBCharset);
762 762
 			$mail->ClearCustomHeaders();
763 763
             $mail->AddCustomHeader('X-CampTrackID:'.$this->target_tracker_key);
764 764
             //CL - Bug 25256 Check if we have a reply_to_name/reply_to_addr value from the email marketing table.  If so use email marketing entry; otherwise current mailbox (inbound email) entry
765
-			$replyToName = empty($this->current_emailmarketing->reply_to_name) ? $this->current_mailbox->get_stored_options('reply_to_name',$mail->FromName,null) : $this->current_emailmarketing->reply_to_name;
766
-			$replyToAddr = empty($this->current_emailmarketing->reply_to_addr) ? $this->current_mailbox->get_stored_options('reply_to_addr',$mail->From,null) : $this->current_emailmarketing->reply_to_addr;
765
+			$replyToName = empty($this->current_emailmarketing->reply_to_name) ? $this->current_mailbox->get_stored_options('reply_to_name', $mail->FromName, null) : $this->current_emailmarketing->reply_to_name;
766
+			$replyToAddr = empty($this->current_emailmarketing->reply_to_addr) ? $this->current_mailbox->get_stored_options('reply_to_addr', $mail->From, null) : $this->current_emailmarketing->reply_to_addr;
767 767
 
768 768
             if (!empty($replyToAddr)) {
769
-                $mail->AddReplyTo($replyToAddr,$locale->translateCharsetMIME(trim($replyToName), 'UTF-8', $OBCharset));
769
+                $mail->AddReplyTo($replyToAddr, $locale->translateCharsetMIME(trim($replyToName), 'UTF-8', $OBCharset));
770 770
             }
771 771
 
772 772
 			//parse and replace bean variables.
773
-            $macro_nv=array();
773
+            $macro_nv = array();
774 774
             $focus_name = 'Contacts';
775
-            if($module->module_dir == 'Accounts')
775
+            if ($module->module_dir == 'Accounts')
776 776
             {
777 777
                 $focus_name = 'Accounts';
778 778
             }
779 779
 
780 780
 
781
-			$template_data=  $this->current_emailtemplate->parse_email_template(array('subject'=>$this->current_emailtemplate->subject,
781
+			$template_data = $this->current_emailtemplate->parse_email_template(array('subject'=>$this->current_emailtemplate->subject,
782 782
 																					  'body_html'=>$this->current_emailtemplate->body_html,
783 783
 																					  'body'=>$this->current_emailtemplate->body,
784 784
 																					  )
@@ -786,65 +786,65 @@  discard block
 block discarded – undo
786 786
                                                                                       ,$macro_nv);
787 787
 
788 788
             //add email address to this list.
789
-            $macro_nv['sugar_to_email_address']=$module->email1;
790
-            $macro_nv['email_template_id']=$this->current_emailmarketing->template_id;
789
+            $macro_nv['sugar_to_email_address'] = $module->email1;
790
+            $macro_nv['email_template_id'] = $this->current_emailmarketing->template_id;
791 791
 
792 792
             //parse and replace urls.
793 793
 			//this is new style of adding tracked urls to a campaign.
794
-			$tracker_url_template= $this->tracking_url . 'index.php?entryPoint=campaign_trackerv2&track=%s'.'&identifier='.$this->target_tracker_key;
795
-			$removeme_url_template=$this->tracking_url . 'index.php?entryPoint=removeme&identifier='.$this->target_tracker_key;
796
-			$template_data=  $this->current_emailtemplate->parse_tracker_urls($template_data,$tracker_url_template,$this->tracker_urls,$removeme_url_template);
797
-			$mail->AddAddress($module->email1,$locale->translateCharsetMIME(trim($module->name), 'UTF-8', $OBCharset) );
794
+			$tracker_url_template = $this->tracking_url.'index.php?entryPoint=campaign_trackerv2&track=%s'.'&identifier='.$this->target_tracker_key;
795
+			$removeme_url_template = $this->tracking_url.'index.php?entryPoint=removeme&identifier='.$this->target_tracker_key;
796
+			$template_data = $this->current_emailtemplate->parse_tracker_urls($template_data, $tracker_url_template, $this->tracker_urls, $removeme_url_template);
797
+			$mail->AddAddress($module->email1, $locale->translateCharsetMIME(trim($module->name), 'UTF-8', $OBCharset));
798 798
 
799 799
             //refetch strings in case they have been changed by creation of email templates or other beans.
800
-            $mod_strings = return_module_language( $sugar_config['default_language'], 'EmailMan');
800
+            $mod_strings = return_module_language($sugar_config['default_language'], 'EmailMan');
801 801
 
802
-            if($this->test){
803
-                $mail->Subject =  $mod_strings['LBL_PREPEND_TEST'] . $template_data['subject'];
804
-            }else{
805
-                $mail->Subject =  $template_data['subject'];
802
+            if ($this->test) {
803
+                $mail->Subject = $mod_strings['LBL_PREPEND_TEST'].$template_data['subject'];
804
+            } else {
805
+                $mail->Subject = $template_data['subject'];
806 806
             }
807 807
 
808 808
             //check if this template is meant to be used as "text only"
809 809
             $text_only = false;
810
-            if(isset($this->current_emailtemplate->text_only) && $this->current_emailtemplate->text_only){$text_only =true;}
810
+            if (isset($this->current_emailtemplate->text_only) && $this->current_emailtemplate->text_only) {$text_only = true; }
811 811
             //if this template is textonly, then just send text body.  Do not add tracker, opt out,
812 812
             //or perform other processing as it will not show up in text only email
813
-            if($text_only){
813
+            if ($text_only) {
814 814
                 $this->description_html = '';
815 815
                 $mail->IsHTML(false);
816 816
                 $mail->Body = $template_data['body'];
817 817
 
818
-            }else{
818
+            } else {
819 819
                 $mail->Body = wordwrap($template_data['body_html'], 900);
820 820
                 //BEGIN:this code will trigger for only campaigns pending before upgrade to 4.2.0.
821 821
                 //will be removed for the next release.
822
-                if(!isset($btracker)) $btracker=false;
822
+                if (!isset($btracker)) $btracker = false;
823 823
                 if ($btracker) {
824
-                    $mail->Body .= "<br /><br /><a href='". $tracker_url ."'>" . $tracker_text . "</a><br /><br />";
824
+                    $mail->Body .= "<br /><br /><a href='".$tracker_url."'>".$tracker_text."</a><br /><br />";
825 825
                 } else {
826 826
                     if (!empty($tracker_url)) {
827
-                        $mail->Body = str_replace('TRACKER_URL_START', "<a href='" . $tracker_url ."'>", $mail->Body);
827
+                        $mail->Body = str_replace('TRACKER_URL_START', "<a href='".$tracker_url."'>", $mail->Body);
828 828
                         $mail->Body = str_replace('TRACKER_URL_END', "</a>", $mail->Body);
829
-                        $mail->AltBody = str_replace('TRACKER_URL_START', "<a href='" . $tracker_url ."'>", $mail->AltBody);
829
+                        $mail->AltBody = str_replace('TRACKER_URL_START', "<a href='".$tracker_url."'>", $mail->AltBody);
830 830
                         $mail->AltBody = str_replace('TRACKER_URL_END', "</a>", $mail->AltBody);
831 831
                     }
832 832
                 }
833 833
                 //END
834 834
 
835 835
                 //do not add the default remove me link if the campaign has a trackerurl of the opotout link
836
-                if ($this->has_optout_links==false) {
837
-                    $mail->Body .= "<br /><span style='font-size:0.8em'>{$mod_strings['TXT_REMOVE_ME']} <a href='". $this->tracking_url . "index.php?entryPoint=removeme&identifier={$this->target_tracker_key}'>{$mod_strings['TXT_REMOVE_ME_CLICK']}</a></span>";
836
+                if ($this->has_optout_links == false) {
837
+                    $mail->Body .= "<br /><span style='font-size:0.8em'>{$mod_strings['TXT_REMOVE_ME']} <a href='".$this->tracking_url."index.php?entryPoint=removeme&identifier={$this->target_tracker_key}'>{$mod_strings['TXT_REMOVE_ME_CLICK']}</a></span>";
838 838
                 }
839 839
                 // cn: bug 11979 - adding single quote to comform with HTML email RFC
840 840
                 $mail->Body .= "<br /><img alt='' height='1' width='1' src='{$this->tracking_url}index.php?entryPoint=image&identifier={$this->target_tracker_key}' />";
841 841
 
842 842
                 $mail->AltBody = $template_data['body'];
843 843
                 if ($btracker) {
844
-                    $mail->AltBody .="\n". $tracker_url;
844
+                    $mail->AltBody .= "\n".$tracker_url;
845 845
                 }
846
-                if ($this->has_optout_links==false) {
847
-                    $mail->AltBody .="\n\n\n{$mod_strings['TXT_REMOVE_ME_ALT']} ". $this->tracking_url . "index.php?entryPoint=removeme&identifier=$this->target_tracker_key";
846
+                if ($this->has_optout_links == false) {
847
+                    $mail->AltBody .= "\n\n\n{$mod_strings['TXT_REMOVE_ME_ALT']} ".$this->tracking_url."index.php?entryPoint=removeme&identifier=$this->target_tracker_key";
848 848
                 }
849 849
 
850 850
             }
@@ -857,16 +857,16 @@  discard block
 block discarded – undo
857 857
 	    	$success = $mail->Send();
858 858
 	    	//Do not save the encoded subject.
859 859
             $mail->Subject = $tmp_Subject;
860
-			if($success ){
861
-                $email_id=null;
862
-                if ($save_emails==1) {
863
-                    $email_id=$this->create_indiv_email($module,$mail);
860
+			if ($success) {
861
+                $email_id = null;
862
+                if ($save_emails == 1) {
863
+                    $email_id = $this->create_indiv_email($module, $mail);
864 864
                 } else {
865 865
                     //find/create reference email record. all campaign targets reveiving this message will be linked with this message.
866 866
                     $decodedFromName = mb_decode_mimeheader($this->current_emailmarketing->from_name);
867
-                    $fromAddressName= "{$decodedFromName} <{$this->mailbox_from_addr}>";
867
+                    $fromAddressName = "{$decodedFromName} <{$this->mailbox_from_addr}>";
868 868
 
869
-                    $email_id=$this->create_ref_email($this->marketing_id,
869
+                    $email_id = $this->create_ref_email($this->marketing_id,
870 870
                                             $this->current_emailtemplate->subject,
871 871
                                             $this->current_emailtemplate->body,
872 872
                                             $this->current_emailtemplate->body_html,
@@ -886,30 +886,30 @@  discard block
 block discarded – undo
886 886
 				$this->set_as_sent($module->email1, true, $email_id, 'Emails', 'targeted');
887 887
 			} else {
888 888
 
889
-				if(!empty($layout_def['parent_id'])) {
889
+				if (!empty($layout_def['parent_id'])) {
890 890
 	                if (isset($layout_def['fields'][strtoupper($layout_def['parent_id'])])) {
891
-	                    $parent.="&parent_id=".$layout_def['fields'][strtoupper($layout_def['parent_id'])];
891
+	                    $parent .= "&parent_id=".$layout_def['fields'][strtoupper($layout_def['parent_id'])];
892 892
 	                }
893 893
 	            }
894
-	            if(!empty($layout_def['parent_module'])) {
894
+	            if (!empty($layout_def['parent_module'])) {
895 895
 	                if (isset($layout_def['fields'][strtoupper($layout_def['parent_module'])])) {
896
-	                    $parent.="&parent_module=".$layout_def['fields'][strtoupper($layout_def['parent_module'])];
896
+	                    $parent .= "&parent_module=".$layout_def['fields'][strtoupper($layout_def['parent_module'])];
897 897
 	                }
898 898
 	            }
899 899
 				//log send error. save for next attempt after 24hrs. no campaign log entry will be created.
900
-				$this->set_as_sent($module->email1,false,null,null,'send error');
900
+				$this->set_as_sent($module->email1, false, null, null, 'send error');
901 901
 			}
902
-		}else{
902
+		} else {
903 903
             $success = false;
904
-            $this->target_tracker_key=create_guid();
904
+            $this->target_tracker_key = create_guid();
905 905
 
906 906
 			if (isset($module->email_opt_out) && ($module->email_opt_out === 'on' || $module->email_opt_out == '1' || $module->email_opt_out == 1)) {
907
-				$this->set_as_sent($module->email1,true,null,null,'removed');
907
+				$this->set_as_sent($module->email1, true, null, null, 'removed');
908 908
 			} else {
909 909
 				if (isset($module->invalid_email) && ($module->invalid_email == 1 || $module->invalid_email == '1')) {
910
-					$this->set_as_sent($module->email1,true,null,null,'invalid email');
910
+					$this->set_as_sent($module->email1, true, null, null, 'invalid email');
911 911
 				} else {
912
-					$this->set_as_sent($module->email1,true, null,null,'send error');
912
+					$this->set_as_sent($module->email1, true, null, null, 'send error');
913 913
 				}
914 914
 			}
915 915
 		}
@@ -924,15 +924,15 @@  discard block
 block discarded – undo
924 924
 	 */
925 925
 	function valid_email_address($email_address) {
926 926
 
927
-		$email_address=trim($email_address);
927
+		$email_address = trim($email_address);
928 928
 		if (empty($email_address)) {
929 929
 			return false;
930 930
 		}
931 931
 
932
-		$pattern='/[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Za-z]{2,}$/i';
933
-		$ret=preg_match($pattern, $email_address);
932
+		$pattern = '/[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Za-z]{2,}$/i';
933
+		$ret = preg_match($pattern, $email_address);
934 934
 		echo $ret;
935
-		if ($ret===false or $ret==0) {
935
+		if ($ret === false or $ret == 0) {
936 936
 			return false;
937 937
 		}
938 938
 		return true;
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
      * If no primary email address is found, then false is returned
945 945
      *
946 946
      */
947
-    function is_primary_email_address($bean){
948
-        $email_address=trim($bean->email1);
947
+    function is_primary_email_address($bean) {
948
+        $email_address = trim($bean->email1);
949 949
 
950 950
         if (empty($email_address)) {
951 951
             return false;
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
         //query for this email address rel and see if this is primary address
954 954
         $primary_qry = "select email_address_id from email_addr_bean_rel where bean_id = '".$bean->id."' and email_addr_bean_rel.primary_address=1 and deleted=0";
955 955
         $res = $bean->db->query($primary_qry);
956
-        $prim_row=$this->db->fetchByAssoc($res);
956
+        $prim_row = $this->db->fetchByAssoc($res);
957 957
         //return true if this is primary
958 958
         if (!empty($prim_row)) {
959 959
             return true;
@@ -974,14 +974,14 @@  discard block
 block discarded – undo
974 974
 
975 975
         $where_auto = "( emailman.deleted IS NULL OR emailman.deleted=0 )";
976 976
 
977
-        if($where != "")
977
+        if ($where != "")
978 978
             $query .= "where ($where) AND ".$where_auto;
979 979
         else
980 980
             $query .= "where ".$where_auto;
981 981
 
982 982
         $order_by = $this->process_order_by($order_by);
983 983
         if (!empty($order_by)) {
984
-            $query .= ' ORDER BY ' . $order_by;
984
+            $query .= ' ORDER BY '.$order_by;
985 985
         }
986 986
 
987 987
         return $query;
Please login to merge, or discard this patch.
Braces   +34 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -86,8 +88,7 @@  discard block
 block discarded – undo
86 88
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
87 89
         if(isset($GLOBALS['log'])) {
88 90
             $GLOBALS['log']->deprecated($deprecatedMessage);
89
-        }
90
-        else {
91
+        } else {
91 92
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
92 93
         }
93 94
         self::__construct();
@@ -124,10 +125,11 @@  discard block
 block discarded – undo
124 125
 
125 126
                 $where_auto = " $this->table_name.deleted=0";
126 127
 
127
-        if($where != "")
128
-			$query['where'] = "WHERE $where AND ".$where_auto;
129
-		else
130
-			$query['where'] = "WHERE ".$where_auto;
128
+        if($where != "") {
129
+        			$query['where'] = "WHERE $where AND ".$where_auto;
130
+        } else {
131
+					$query['where'] = "WHERE ".$where_auto;
132
+		}
131 133
 
132 134
     	if(isset($params['group_by'])) {
133 135
             $query['group_by'] .= " GROUP BY {$params['group_by']}";
@@ -184,10 +186,11 @@  discard block
 block discarded – undo
184 186
 
185 187
                 $where_auto = " $this->table_name.deleted=0";
186 188
 
187
-        if($where != "")
188
-			$query .= "WHERE $where AND ".$where_auto;
189
-		else
190
-			$query .= "WHERE ".$where_auto;
189
+        if($where != "") {
190
+        			$query .= "WHERE $where AND ".$where_auto;
191
+        } else {
192
+					$query .= "WHERE ".$where_auto;
193
+		}
191 194
 
192 195
         $order_by = $this->process_order_by($order_by);
193 196
         if (!empty($order_by)) {
@@ -223,10 +226,11 @@  discard block
 block discarded – undo
223 226
 
224 227
                 $where_auto = " $this->table_name.deleted=0";
225 228
 
226
-        if($where != "")
227
-			$query .= "where $where AND ".$where_auto;
228
-		else
229
-			$query .= "where ".$where_auto;
229
+        if($where != "") {
230
+        			$query .= "where $where AND ".$where_auto;
231
+        } else {
232
+					$query .= "where ".$where_auto;
233
+		}
230 234
 
231 235
         $order_by = $this->process_order_by($order_by);
232 236
         if (!empty($order_by)) {
@@ -306,7 +310,7 @@  discard block
 block discarded – undo
306 310
 
307 311
 			$query = "DELETE FROM emailman WHERE id = $this->id";
308 312
 			$this->db->query($query);
309
-		}else{
313
+		} else{
310 314
 			//try to send the email again a day later.
311 315
 			$query = 'UPDATE ' . $this->table_name . " SET in_queue='1', send_attempts='$this->send_attempts', in_queue_date=". $this->db->now() ." WHERE id = $this->id";
312 316
 			$this->db->query($query);
@@ -343,7 +347,9 @@  discard block
 block discarded – undo
343 347
            //this is to account for changes to email template.
344 348
            $upd_ref_email=(!empty($this->ref_email->id) and $this->ref_email->parent_type=='test' and $this->ref_email->parent_id=='test');
345 349
           //following condition is for switching back to test mode.
346
-           if (!$upd_ref_email) $upd_ref_email=($this->test and !empty($this->ref_email->id) and empty($this->ref_email->parent_type) and empty($this->ref_email->parent_id));
350
+           if (!$upd_ref_email) {
351
+               $upd_ref_email=($this->test and !empty($this->ref_email->id) and empty($this->ref_email->parent_type) and empty($this->ref_email->parent_id));
352
+           }
347 353
            if (empty($this->ref_email->id) or $upd_ref_email) {
348 354
                 //create email record.
349 355
                 $this->ref_email->id=$marketing_id;
@@ -801,7 +807,7 @@  discard block
 block discarded – undo
801 807
 
802 808
             if($this->test){
803 809
                 $mail->Subject =  $mod_strings['LBL_PREPEND_TEST'] . $template_data['subject'];
804
-            }else{
810
+            } else{
805 811
                 $mail->Subject =  $template_data['subject'];
806 812
             }
807 813
 
@@ -815,11 +821,13 @@  discard block
 block discarded – undo
815 821
                 $mail->IsHTML(false);
816 822
                 $mail->Body = $template_data['body'];
817 823
 
818
-            }else{
824
+            } else{
819 825
                 $mail->Body = wordwrap($template_data['body_html'], 900);
820 826
                 //BEGIN:this code will trigger for only campaigns pending before upgrade to 4.2.0.
821 827
                 //will be removed for the next release.
822
-                if(!isset($btracker)) $btracker=false;
828
+                if(!isset($btracker)) {
829
+                    $btracker=false;
830
+                }
823 831
                 if ($btracker) {
824 832
                     $mail->Body .= "<br /><br /><a href='". $tracker_url ."'>" . $tracker_text . "</a><br /><br />";
825 833
                 } else {
@@ -899,7 +907,7 @@  discard block
 block discarded – undo
899 907
 				//log send error. save for next attempt after 24hrs. no campaign log entry will be created.
900 908
 				$this->set_as_sent($module->email1,false,null,null,'send error');
901 909
 			}
902
-		}else{
910
+		} else{
903 911
             $success = false;
904 912
             $this->target_tracker_key=create_guid();
905 913
 
@@ -974,10 +982,11 @@  discard block
 block discarded – undo
974 982
 
975 983
         $where_auto = "( emailman.deleted IS NULL OR emailman.deleted=0 )";
976 984
 
977
-        if($where != "")
978
-            $query .= "where ($where) AND ".$where_auto;
979
-        else
980
-            $query .= "where ".$where_auto;
985
+        if($where != "") {
986
+                    $query .= "where ($where) AND ".$where_auto;
987
+        } else {
988
+                    $query .= "where ".$where_auto;
989
+        }
981 990
 
982 991
         $order_by = $this->process_order_by($order_by);
983 992
         if (!empty($order_by)) {
Please login to merge, or discard this patch.
modules/FP_events/FP_events.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 require_once('modules/FP_events/FP_events_sugar.php');
44 44
 class FP_events extends FP_events_sugar {
45 45
 
46
-	function __construct(){
46
+	function __construct() {
47 47
 		parent::__construct();
48 48
 	}
49 49
 
50 50
     /**
51 51
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
52 52
      */
53
-    function FP_events(){
53
+    function FP_events() {
54 54
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
55
-        if(isset($GLOBALS['log'])) {
55
+        if (isset($GLOBALS['log'])) {
56 56
             $GLOBALS['log']->deprecated($deprecatedMessage);
57 57
         }
58 58
         else {
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 	//assign email templates to drop_down in module
66
-	function email_templates(){
66
+	function email_templates() {
67 67
 
68 68
 		global $app_list_strings;
69 69
 
70
-		$app_list_strings['email_templet_list'] = get_bean_select_array(true, 'EmailTemplate','name');
70
+		$app_list_strings['email_templet_list'] = get_bean_select_array(true, 'EmailTemplate', 'name');
71 71
 
72 72
 
73 73
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/FP_events/FP_events_sugar.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	var $object_name = 'FP_events';
51 51
 	var $table_name = 'fp_events';
52 52
 	var $importable = true;
53
-	var $disable_row_level_security = true ; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
53
+	var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
54 54
 		var $id;
55 55
 		var $name;
56 56
 		var $date_entered;
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 		var $currency_id;
74 74
 		var $invite_templates;
75 75
 
76
-    function __construct(){
76
+    function __construct() {
77 77
 		parent::__construct();
78 78
 	}
79 79
 
80 80
     /**
81 81
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
82 82
      */
83
-    function FP_events_sugar(){
83
+    function FP_events_sugar() {
84 84
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
85
-        if(isset($GLOBALS['log'])) {
85
+        if (isset($GLOBALS['log'])) {
86 86
             $GLOBALS['log']->deprecated($deprecatedMessage);
87 87
         }
88 88
         else {
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
 
95
-	function bean_implements($interface){
96
-		switch($interface){
95
+	function bean_implements($interface) {
96
+		switch ($interface) {
97 97
 			case 'ACL': return true;
98 98
 		}
99 99
 		return false;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
24 24
         if(isset($GLOBALS['log'])) {
25 25
             $GLOBALS['log']->deprecated($deprecatedMessage);
26
-        }
27
-        else {
26
+        } else {
28 27
             trigger_error($deprecatedMessage, E_USER_DEPRECATED);
29 28
         }
30 29
         self::__construct($seed, $module, $subPanel, $options);
Please login to merge, or discard this patch.
modules/FP_events/views/view.detail.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 require_once('include/MVC/View/views/view.detail.php');
5 5
 
6 6
 class FP_eventsViewDetail extends ViewDetail {
7 7
 	var $currSymbol;
8
-	function __construct(){
8
+	function __construct() {
9 9
  		parent::__construct();
10 10
  	}
11 11
 
12 12
     /**
13 13
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
14 14
      */
15
-    function FP_eventsViewDetail(){
15
+    function FP_eventsViewDetail() {
16 16
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
17
-        if(isset($GLOBALS['log'])) {
17
+        if (isset($GLOBALS['log'])) {
18 18
             $GLOBALS['log']->deprecated($deprecatedMessage);
19 19
         }
20 20
         else {
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
 
27
-	function display(){
27
+	function display() {
28 28
 		$this->bean->email_templates();
29 29
 		parent::display();
30 30
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.
modules/FP_events/views/view.edit.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 require_once('include/MVC/View/views/view.edit.php');
5 5
 
6 6
 class FP_eventsViewEdit extends ViewEdit {
7
-	function __construct(){
7
+	function __construct() {
8 8
  		parent::__construct();
9 9
  	}
10 10
 
11 11
     /**
12 12
      * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
13 13
      */
14
-    function FP_eventsViewEdit(){
14
+    function FP_eventsViewEdit() {
15 15
         $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
16
-        if(isset($GLOBALS['log'])) {
16
+        if (isset($GLOBALS['log'])) {
17 17
             $GLOBALS['log']->deprecated($deprecatedMessage);
18 18
         }
19 19
         else {
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
 
26
-	function display(){
26
+	function display() {
27 27
 		$this->bean->email_templates();
28 28
 		parent::display();
29 29
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
  * Date: 06/03/15
44 44
  * Comments
45 45
  */
46
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
46
+if(!defined('sugarEntry') || !sugarEntry) {
47
+    die('Not A Valid Entry Point');
48
+}
47 49
 
48 50
 class CasesController extends SugarController {
49 51
 
@@ -90,8 +92,7 @@  discard block
 block discarded – undo
90 92
                 $count++;
91 93
             }
92 94
             echo '</table>';
93
-        }
94
-        else {
95
+        } else {
95 96
             echo $mod_strings['LBL_NO_SUGGESTIONS'];
96 97
         }
97 98
         die();
Please login to merge, or discard this patch.