Completed
Push — console-installer ( 03fc02...67c42e )
by Adam
72:27 queued 53:14
created
include/database/MssqlManager.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
             'relate'   => 'varchar',
141 141
             'multienum'=> 'text',
142 142
             'html'     => 'text',
143
-			'longhtml' => 'text',
144
-    		'datetime' => 'datetime',
143
+            'longhtml' => 'text',
144
+            'datetime' => 'datetime',
145 145
             'datetimecombo' => 'datetime',
146 146
             'time'     => 'datetime',
147 147
             'bool'     => 'bit',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             'url'      => 'varchar',
157 157
             'encrypt'  => 'varchar',
158 158
             'file'     => 'varchar',
159
-	        'decimal_tpl' => 'decimal(%d, %d)',
159
+            'decimal_tpl' => 'decimal(%d, %d)',
160 160
             );
161 161
 
162 162
     protected $connectOptions = null;
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
         //it will throw an Unable to select database message.
237 237
 
238 238
         if(!empty($configOptions['db_name']) && !@mssql_select_db($configOptions['db_name'], $this->database)){
239
-			$connected = false;
240
-			for($i=0;$i<5;$i++){
241
-				usleep(200000);
242
-				if(@mssql_select_db($configOptions['db_name'], $this->database)){
243
-					$connected = true;
244
-					break;
245
-				}
246
-			}
247
-			if(!$connected){
248
-			    $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}");
239
+            $connected = false;
240
+            for($i=0;$i<5;$i++){
241
+                usleep(200000);
242
+                if(@mssql_select_db($configOptions['db_name'], $this->database)){
243
+                    $connected = true;
244
+                    break;
245
+                }
246
+            }
247
+            if(!$connected){
248
+                $GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}");
249 249
                 if($dieOnError) {
250 250
                     if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
251 251
                         sugar_die($GLOBALS['app_strings']['ERR_NO_DB']);
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
                 } else {
256 256
                     return false;
257 257
                 }
258
-			}
259
-         }
258
+            }
259
+            }
260 260
 
261 261
         if(!$this->checkError('Could Not Connect', $dieOnError))
262 262
             $GLOBALS['log']->info("connected to db");
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
         return true;
268 268
     }
269 269
 
270
-	/**
270
+    /**
271 271
      * @see DBManager::version()
272 272
      */
273 273
     public function version()
274 274
     {
275 275
         return $this->getOne("SELECT @@VERSION as version");
276
-	}
276
+    }
277 277
 
278
-	/**
278
+    /**
279 279
      * @see DBManager::query()
280
-	 */
281
-	public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false)
280
+     */
281
+    public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false)
282 282
     {
283 283
         if(is_array($sql)) {
284 284
             return $this->queryArray($sql, $dieOnError, $msg, $suppress);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         if ((substr_count($sql, "'") & 1))
288 288
             $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes.");
289 289
 
290
-		$sql = $this->_appendN($sql);
290
+        $sql = $this->_appendN($sql);
291 291
 
292 292
         $GLOBALS['log']->info('Query:' . $sql);
293 293
         $this->checkConnection();
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         $this->query_time = microtime(true);
296 296
 
297 297
         // Bug 34892 - Clear out previous error message by checking the @@ERROR global variable
298
-		@mssql_query("SELECT @@ERROR", $this->database);
298
+        @mssql_query("SELECT @@ERROR", $this->database);
299 299
 
300 300
         $result = $suppress?@mssql_query($sql, $this->database):mssql_query($sql, $this->database);
301 301
 
@@ -305,18 +305,18 @@  discard block
 block discarded – undo
305 305
             //				  not affect the functionality of the query
306 306
             $sqlmsg = mssql_get_last_message();
307 307
             $sqlpos = strpos($sqlmsg, 'Changed database context to');
308
-			$sqlpos2 = strpos($sqlmsg, 'Warning:');
309
-			$sqlpos3 = strpos($sqlmsg, 'Checking identity information:');
308
+            $sqlpos2 = strpos($sqlmsg, 'Warning:');
309
+            $sqlpos3 = strpos($sqlmsg, 'Checking identity information:');
310 310
 
311
-			if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false)		// if sqlmsg has 'Changed database context to', just log it
312
-				$GLOBALS['log']->debug($sqlmsg . ": " . $sql );
313
-			else {
314
-				$GLOBALS['log']->fatal($sqlmsg . ": " . $sql );
315
-				if($dieOnError)
316
-					sugar_die('SQL Error : ' . $sqlmsg);
317
-				else
318
-					echo 'SQL Error : ' . $sqlmsg;
319
-			}
311
+            if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false)		// if sqlmsg has 'Changed database context to', just log it
312
+                $GLOBALS['log']->debug($sqlmsg . ": " . $sql );
313
+            else {
314
+                $GLOBALS['log']->fatal($sqlmsg . ": " . $sql );
315
+                if($dieOnError)
316
+                    sugar_die('SQL Error : ' . $sqlmsg);
317
+                else
318
+                    echo 'SQL Error : ' . $sqlmsg;
319
+            }
320 320
         }
321 321
 
322 322
         $this->query_time = microtime(true) - $this->query_time;
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
         return $limitUnionSQL;
427 427
     }
428 428
 
429
-	/**
430
-	 * FIXME: verify and thoroughly test this code, these regexps look fishy
429
+    /**
430
+     * FIXME: verify and thoroughly test this code, these regexps look fishy
431 431
      * @see DBManager::limitQuery()
432 432
      */
433 433
     public function limitQuery($sql, $start, $count, $dieOnError = false, $msg = '', $execute = true)
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                     }else{
570 570
                         //if there is a distinct clause, form query with rownumber after distinct
571 571
                         if ($hasDistinct) {
572
-                             $newSQL = "SELECT TOP $count * FROM
572
+                                $newSQL = "SELECT TOP $count * FROM
573 573
                                             (
574 574
                             SELECT ROW_NUMBER() OVER (ORDER BY ".$grpByStr.") AS row_number, count(*) counter, " . $distinctSQLARRAY[0] . "
575 575
                                                         " . $distinctSQLARRAY[1] . "
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
                                             WHERE row_number > $start";
580 580
                         }
581 581
                         else {
582
-                             $newSQL = "SELECT TOP $count * FROM
582
+                                $newSQL = "SELECT TOP $count * FROM
583 583
                                            (
584 584
                                   " . $matches[1] . " ROW_NUMBER() OVER (ORDER BY " . $sqlArray['FROM'][0]['alias'] . ".id) AS row_number, " . $matches[2] . $matches[3]. "
585 585
                                            )
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
         while ($i<$count && $offset<strlen($p_sql)) {
627 627
             if ($offset > strlen($p_sql))
628 628
             {
629
-				break;
629
+                break;
630 630
             }
631 631
 
632 632
             $beg_sin = strpos($p_sql, $strip_beg, $offset);
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
      * @param  array  $pattern_array
666 666
      * @return string
667 667
      */
668
-	private function addPatternToSQL($token, array $pattern_array)
668
+    private function addPatternToSQL($token, array $pattern_array)
669 669
     {
670 670
         //strip all single quotes out
671 671
         $pattern_array = array_reverse($pattern_array);
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
      * @param  string $alias
685 685
      * @return string
686 686
      */
687
-	private function getAliasFromSQL($sql, $alias)
687
+    private function getAliasFromSQL($sql, $alias)
688 688
     {
689 689
         $matches = array();
690 690
         preg_match('/^(.*SELECT)(.*?FROM.*WHERE)(.*)$/isU',$sql, $matches);
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
         // If there is no ordering direction (ASC/DESC), use ASC by default
788 788
         if (strpos($orig_order_match, " ") === false) {
789
-        	$orig_order_match .= " ASC";
789
+            $orig_order_match .= " ASC";
790 790
         }
791 791
 
792 792
         //grab first space in order by
@@ -810,11 +810,11 @@  discard block
 block discarded – undo
810 810
                 $lastSpacePos = strrpos($containsColStr, " ");
811 811
                 //use positions of column name, space before name, and length of column to find the correct column name
812 812
                 $col_name = substr($sql, $lastSpacePos, $colMatchPos-$lastSpacePos+strlen($orderMatch));
813
-				//bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error
814
-				$containsCommaPos = strpos($col_name, ",");
815
-				if($containsCommaPos !== false) {
816
-					$col_name = substr($col_name, $containsCommaPos+1);
817
-				}
813
+                //bug 25485. When sorting by a custom field in Account List and then pressing NEXT >, system gives an error
814
+                $containsCommaPos = strpos($col_name, ",");
815
+                if($containsCommaPos !== false) {
816
+                    $col_name = substr($col_name, $containsCommaPos+1);
817
+                }
818 818
                 //add the "asc/desc" order back
819 819
                 $col_name = $col_name. " ". $asc_desc;
820 820
 
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
     }
968 968
 
969 969
 
970
-	/**
970
+    /**
971 971
      * @see DBManager::getFieldsArray()
972 972
      */
973
-	public function getFieldsArray($result, $make_lower_case = false)
974
-	{
975
-		$field_array = array();
973
+    public function getFieldsArray($result, $make_lower_case = false)
974
+    {
975
+        $field_array = array();
976 976
 
977
-		if(! isset($result) || empty($result))
977
+        if(! isset($result) || empty($result))
978 978
             return 0;
979 979
 
980 980
         $i = 0;
@@ -991,37 +991,37 @@  discard block
 block discarded – undo
991 991
         }
992 992
 
993 993
         return $field_array;
994
-	}
994
+    }
995 995
 
996 996
     /**
997 997
      * @see DBManager::getAffectedRowCount()
998 998
      */
999
-	public function getAffectedRowCount($result)
999
+    public function getAffectedRowCount($result)
1000 1000
     {
1001 1001
         return $this->getOne("SELECT @@ROWCOUNT");
1002 1002
     }
1003 1003
 
1004
-	/**
1005
-	 * @see DBManager::fetchRow()
1006
-	 */
1007
-	public function fetchRow($result)
1008
-	{
1009
-		if (empty($result))	return false;
1004
+    /**
1005
+     * @see DBManager::fetchRow()
1006
+     */
1007
+    public function fetchRow($result)
1008
+    {
1009
+        if (empty($result))	return false;
1010 1010
 
1011 1011
         $row = mssql_fetch_assoc($result);
1012 1012
         //MSSQL returns a space " " when a varchar column is empty ("") and not null.
1013 1013
         //We need to iterate through the returned row array and strip empty spaces
1014 1014
         if(!empty($row)){
1015 1015
             foreach($row as $key => $column) {
1016
-               //notice we only strip if one space is returned.  we do not want to strip
1017
-               //strings with intentional spaces (" foo ")
1018
-               if (!empty($column) && $column ==" ") {
1019
-                   $row[$key] = '';
1020
-               }
1016
+                //notice we only strip if one space is returned.  we do not want to strip
1017
+                //strings with intentional spaces (" foo ")
1018
+                if (!empty($column) && $column ==" ") {
1019
+                    $row[$key] = '';
1020
+                }
1021 1021
             }
1022 1022
         }
1023 1023
         return $row;
1024
-	}
1024
+    }
1025 1025
 
1026 1026
     /**
1027 1027
      * @see DBManager::quote()
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
             if (!empty($r)) {
1070 1070
                 while ($a = $this->fetchByAssoc($r)) {
1071 1071
                     $row = array_values($a);
1072
-					$tables[]=$row[0];
1072
+                    $tables[]=$row[0];
1073 1073
                 }
1074 1074
                 return $tables;
1075 1075
             }
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
                 )
1127 1127
                 ";
1128 1128
                 //create full text index
1129
-                 $FTSqry[] = "CREATE FULLTEXT INDEX ON fts_wakeup
1129
+                    $FTSqry[] = "CREATE FULLTEXT INDEX ON fts_wakeup
1130 1130
                 (
1131 1131
                     body
1132 1132
                     Language 0X0
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
                     $len = $this->date_formats[$additional_parameters[0]];
1196 1196
                     return "LEFT(CONVERT(varchar($len),". $string . ",120),$len)";
1197 1197
                 } else {
1198
-                   return "LEFT(CONVERT(varchar(10),". $string . ",120),10)";
1198
+                    return "LEFT(CONVERT(varchar(10),". $string . ",120),10)";
1199 1199
                 }
1200 1200
             case 'ifnull':
1201 1201
                 if(empty($additional_parameters_string)) {
@@ -1237,14 +1237,14 @@  discard block
 block discarded – undo
1237 1237
             case 'datetime': return substr($string, 0,19);
1238 1238
             case 'date': return substr($string, 0, 10);
1239 1239
             case 'time': return substr($string, 11);
1240
-		}
1241
-		return $string;
1240
+        }
1241
+        return $string;
1242 1242
     }
1243 1243
 
1244 1244
     /**
1245 1245
      * @see DBManager::createTableSQLParams()
1246 1246
      */
1247
-	public function createTableSQLParams($tablename, $fieldDefs, $indices)
1247
+    public function createTableSQLParams($tablename, $fieldDefs, $indices)
1248 1248
     {
1249 1249
         if (empty($tablename) || empty($fieldDefs))
1250 1250
             return '';
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
             break;
1323 1323
         default:
1324 1324
             return '';
1325
-    	}
1325
+        }
1326 1326
     }
1327 1327
 
1328 1328
     /**
@@ -1338,14 +1338,14 @@  discard block
 block discarded – undo
1338 1338
         $columns = array();
1339 1339
         if ($this->isFieldArray($fieldDefs)) {
1340 1340
             foreach ($fieldDefs as $def)
1341
-      		{
1342
-          		//if the column is being modified drop the default value
1343
-          		//constraint if it exists. alterSQLRep will add the constraint back
1344
-          		if (!empty($constraints[$def['name']])) {
1345
-          			$sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']];
1346
-          		}
1347
-          		//check to see if we need to drop related indexes before the alter
1348
-          		$indices = $this->get_indices($tablename);
1341
+                {
1342
+                    //if the column is being modified drop the default value
1343
+                    //constraint if it exists. alterSQLRep will add the constraint back
1344
+                    if (!empty($constraints[$def['name']])) {
1345
+                        $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$def['name']];
1346
+                    }
1347
+                    //check to see if we need to drop related indexes before the alter
1348
+                    $indices = $this->get_indices($tablename);
1349 1349
                 foreach ( $indices as $index ) {
1350 1350
                     if ( in_array($def['name'],$index['fields']) ) {
1351 1351
                         $sql  .= ' ' . $this->add_drop_constraint($tablename,$index,true).' ';
@@ -1353,16 +1353,16 @@  discard block
 block discarded – undo
1353 1353
                     }
1354 1354
                 }
1355 1355
 
1356
-          		$columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename);
1357
-      		}
1356
+                    $columns[] = $this->alterSQLRep($action, $def, $ignoreRequired,$tablename);
1357
+                }
1358 1358
         }
1359 1359
         else {
1360 1360
             //if the column is being modified drop the default value
1361
-      		//constraint if it exists. alterSQLRep will add the constraint back
1362
-      		if (!empty($constraints[$fieldDefs['name']])) {
1363
-      			$sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']];
1364
-      		}
1365
-      		//check to see if we need to drop related indexes before the alter
1361
+                //constraint if it exists. alterSQLRep will add the constraint back
1362
+                if (!empty($constraints[$fieldDefs['name']])) {
1363
+                    $sql.=" ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $constraints[$fieldDefs['name']];
1364
+                }
1365
+                //check to see if we need to drop related indexes before the alter
1366 1366
             $indices = $this->get_indices($tablename);
1367 1367
             foreach ( $indices as $index ) {
1368 1368
                 if ( in_array($fieldDefs['name'],$index['fields']) ) {
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
             }
1373 1373
 
1374 1374
 
1375
-          	$columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename);
1375
+                $columns[] = $this->alterSQLRep($action, $fieldDefs, $ignoreRequired,$tablename);
1376 1376
         }
1377 1377
 
1378 1378
         $columns = implode(", ", $columns);
@@ -1383,8 +1383,8 @@  discard block
 block discarded – undo
1383 1383
 
1384 1384
     protected function setAutoIncrement($table, $field_name)
1385 1385
     {
1386
-		return "identity(1,1)";
1387
-	}
1386
+        return "identity(1,1)";
1387
+    }
1388 1388
 
1389 1389
     /**
1390 1390
      * @see DBManager::setAutoIncrementStart()
@@ -1393,16 +1393,16 @@  discard block
 block discarded – undo
1393 1393
     {
1394 1394
         if($start_value > 1)
1395 1395
             $start_value -= 1;
1396
-		$this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS");
1396
+        $this->query("DBCC CHECKIDENT ('$table', RESEED, $start_value) WITH NO_INFOMSGS");
1397 1397
         return true;
1398 1398
     }
1399 1399
 
1400
-	/**
1400
+    /**
1401 1401
      * @see DBManager::getAutoIncrement()
1402 1402
      */
1403 1403
     public function getAutoIncrement($table, $field_name)
1404 1404
     {
1405
-		$result = $this->getOne("select IDENT_CURRENT('$table') + IDENT_INCR ( '$table' ) as 'Auto_increment'");
1405
+        $result = $this->getOne("select IDENT_CURRENT('$table') + IDENT_INCR ( '$table' ) as 'Auto_increment'");
1406 1406
         return $result;
1407 1407
     }
1408 1408
 
@@ -1457,8 +1457,8 @@  discard block
 block discarded – undo
1457 1457
                 $columns[$column_name]['len']=strtolower($row['PRECISION']);
1458 1458
                 $columns[$column_name]['len'].=','.strtolower($row['SCALE']);
1459 1459
             }
1460
-			elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) )
1461
-				$columns[$column_name]['len']=strtolower($row['PRECISION']);
1460
+            elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) )
1461
+                $columns[$column_name]['len']=strtolower($row['PRECISION']);
1462 1462
             elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) )
1463 1463
                 $columns[$column_name]['len']=strtolower($row['LENGTH']);
1464 1464
             if ( stristr($row['TYPE_NAME'],'identity') ) {
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
     protected function full_text_indexing_enabled($dbname = null)
1586 1586
     {
1587 1587
         // check to see if we already have install setting in session
1588
-    	if(!isset($_SESSION['IsFulltextInstalled']))
1588
+        if(!isset($_SESSION['IsFulltextInstalled']))
1589 1589
             $_SESSION['IsFulltextInstalled'] = $this->full_text_indexing_installed();
1590 1590
 
1591 1591
         // check to see if FTS Indexing service is installed
@@ -1593,27 +1593,27 @@  discard block
 block discarded – undo
1593 1593
             return false;
1594 1594
 
1595 1595
         // grab the dbname if it was not passed through
1596
-		if (empty($dbname)) {
1597
-			global $sugar_config;
1598
-			$dbname = $sugar_config['dbconfig']['db_name'];
1599
-		}
1596
+        if (empty($dbname)) {
1597
+            global $sugar_config;
1598
+            $dbname = $sugar_config['dbconfig']['db_name'];
1599
+        }
1600 1600
         //we already know that Indexing service is installed, now check
1601 1601
         //to see if it is enabled
1602
-		$res = $this->getOne("SELECT DATABASEPROPERTY('$dbname', 'IsFulltextEnabled') ftext");
1602
+        $res = $this->getOne("SELECT DATABASEPROPERTY('$dbname', 'IsFulltextEnabled') ftext");
1603 1603
         return !empty($res);
1604
-	}
1604
+    }
1605 1605
 
1606 1606
     /**
1607 1607
      * Creates default full text catalog
1608 1608
      */
1609
-	protected function create_default_full_text_catalog()
1609
+    protected function create_default_full_text_catalog()
1610 1610
     {
1611
-		if ($this->full_text_indexing_enabled()) {
1612
-		    $catalog = $this->ftsCatalogName();
1611
+        if ($this->full_text_indexing_enabled()) {
1612
+            $catalog = $this->ftsCatalogName();
1613 1613
             $GLOBALS['log']->debug("Creating the default catalog for full-text indexing, $catalog");
1614 1614
 
1615 1615
             //drop catalog if exists.
1616
-			$ret = $this->query("
1616
+            $ret = $this->query("
1617 1617
                 if not exists(
1618 1618
                     select *
1619 1619
                         from sys.fulltext_catalogs
@@ -1621,11 +1621,11 @@  discard block
 block discarded – undo
1621 1621
                         )
1622 1622
                 CREATE FULLTEXT CATALOG $catalog");
1623 1623
 
1624
-			if (empty($ret)) {
1625
-				$GLOBALS['log']->error("Error creating default full-text catalog, $catalog");
1626
-			}
1627
-		}
1628
-	}
1624
+            if (empty($ret)) {
1625
+                $GLOBALS['log']->error("Error creating default full-text catalog, $catalog");
1626
+            }
1627
+        }
1628
+    }
1629 1629
 
1630 1630
     /**
1631 1631
      * Function returns name of the constraint automatically generated by sql-server.
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
      * @param  string $column
1636 1636
      * @return string
1637 1637
      */
1638
-	private function get_field_default_constraint_name($table, $column = null)
1638
+    private function get_field_default_constraint_name($table, $column = null)
1639 1639
     {
1640 1640
         static $results = array();
1641 1641
 
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
         }
1671 1671
 
1672 1672
         return null;
1673
-	}
1673
+    }
1674 1674
 
1675 1675
     /**
1676 1676
      * @see DBManager::massageFieldDef()
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
                 case 'varchar'  :
1693 1693
                 case 'nvarchar' :
1694 1694
                                   $fieldDef['len'] = $this->isTextType($fieldDef['dbType']) ? 'max' : '255';
1695
-                                  break;
1695
+                                    break;
1696 1696
                 case 'image'    : $fieldDef['len'] = '2147483647'; break;
1697 1697
                 case 'ntext'    : $fieldDef['len'] = '2147483646'; break;   // Note: this is from legacy code, don't know if this is correct
1698 1698
             }
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
            && empty($fieldDef['precision'])
1702 1702
            && !strpos($fieldDef['len'], ','))
1703 1703
         {
1704
-             $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified
1704
+                $fieldDef['len'] .= ',0'; // Adding 0 precision if it is not specified
1705 1705
         }
1706 1706
 
1707 1707
         if(empty($fieldDef['default'])
@@ -1709,8 +1709,8 @@  discard block
 block discarded – undo
1709 1709
         {
1710 1710
             $fieldDef['default'] = '0';
1711 1711
         }
1712
-		if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) )
1713
-			$fieldDef['default'] = '';
1712
+        if (isset($fieldDef['required']) && $fieldDef['required'] && !isset($fieldDef['default']) )
1713
+            $fieldDef['default'] = '';
1714 1714
 //        if ($fieldDef['type'] == 'bit' && empty($fieldDef['len']) )
1715 1715
 //            $fieldDef['len'] = '1';
1716 1716
 //		if ($fieldDef['type'] == 'bool' && empty($fieldDef['len']) )
@@ -1739,30 +1739,30 @@  discard block
 block discarded – undo
1739 1739
      */
1740 1740
     protected function oneColumnSQLRep($fieldDef, $ignoreRequired = false, $table = '', $return_as_array = false)
1741 1741
     {
1742
-    	//Bug 25814
1743
-		if(isset($fieldDef['name'])){
1744
-		    $colType = $this->getFieldType($fieldDef);
1745
-        	if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){
1746
-				$fieldDef['len'] = min($fieldDef['len'],38);
1747
-			}
1748
-		    //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair
1749
-			if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){
1750
-				unset($fieldDef['len']);
1751
-			}
1752
-		}
1753
-
1754
-		// always return as array for post-processing
1755
-		$ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true);
1756
-
1757
-		// Bug 24307 - Don't add precision for float fields.
1758
-		if ( stristr($ref['colType'],'float') )
1759
-			$ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']);
1742
+        //Bug 25814
1743
+        if(isset($fieldDef['name'])){
1744
+            $colType = $this->getFieldType($fieldDef);
1745
+            if(stristr($this->getFieldType($fieldDef), 'decimal') && isset($fieldDef['len'])){
1746
+                $fieldDef['len'] = min($fieldDef['len'],38);
1747
+            }
1748
+            //bug: 39690 float(8) is interpreted as real and this generates a diff when doing repair
1749
+            if(stristr($colType, 'float') && isset($fieldDef['len']) && $fieldDef['len'] == 8){
1750
+                unset($fieldDef['len']);
1751
+            }
1752
+        }
1753
+
1754
+        // always return as array for post-processing
1755
+        $ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true);
1756
+
1757
+        // Bug 24307 - Don't add precision for float fields.
1758
+        if ( stristr($ref['colType'],'float') )
1759
+            $ref['colType'] = preg_replace('/(,\d+)/','',$ref['colType']);
1760 1760
 
1761 1761
         if ( $return_as_array )
1762 1762
             return $ref;
1763 1763
         else
1764 1764
             return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}";
1765
-	}
1765
+    }
1766 1766
 
1767 1767
     /**
1768 1768
      * Saves changes to module's audit table
@@ -1771,13 +1771,13 @@  discard block
 block discarded – undo
1771 1771
      * @param array  $changes changes
1772 1772
      */
1773 1773
     public function save_audit_records(SugarBean $bean, $changes)
1774
-	{
1775
-		//Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00"
1776
-		if($changes['data_type'] == 'date'){
1777
-			$changes['before'] = str_replace(' 00:00:00','',$changes['before']);
1778
-		}
1779
-		parent::save_audit_records($bean,$changes);
1780
-	}
1774
+    {
1775
+        //Bug 25078 fixed by Martin Hu: sqlserver haven't 'date' type, trim extra "00:00:00"
1776
+        if($changes['data_type'] == 'date'){
1777
+            $changes['before'] = str_replace(' 00:00:00','',$changes['before']);
1778
+        }
1779
+        parent::save_audit_records($bean,$changes);
1780
+    }
1781 1781
 
1782 1782
     /**
1783 1783
      * Disconnects from the database
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
      */
1787 1787
     public function disconnect()
1788 1788
     {
1789
-    	$GLOBALS['log']->debug('Calling Mssql::disconnect()');
1789
+        $GLOBALS['log']->debug('Calling Mssql::disconnect()');
1790 1790
         if(!empty($this->database)){
1791 1791
             $this->freeResult();
1792 1792
             mssql_close($this->database);
@@ -1803,21 +1803,21 @@  discard block
 block discarded – undo
1803 1803
             mssql_free_result($dbResult);
1804 1804
     }
1805 1805
 
1806
-	/**
1807
-	 * (non-PHPdoc)
1808
-	 * @see DBManager::lastDbError()
1809
-	 */
1806
+    /**
1807
+     * (non-PHPdoc)
1808
+     * @see DBManager::lastDbError()
1809
+     */
1810 1810
     public function lastDbError()
1811 1811
     {
1812 1812
         $sqlmsg = mssql_get_last_message();
1813 1813
         if(empty($sqlmsg)) return false;
1814 1814
         global $app_strings;
1815 1815
         if (empty($app_strings)
1816
-		    or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])
1817
-			or !isset($app_strings['ERR_MSSQL_WARNING']) ) {
1816
+            or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])
1817
+            or !isset($app_strings['ERR_MSSQL_WARNING']) ) {
1818 1818
         //ignore the message from sql-server if $app_strings array is empty. This will happen
1819 1819
         //only if connection if made before language is set.
1820
-		    return false;
1820
+            return false;
1821 1821
         }
1822 1822
 
1823 1823
         $sqlpos = strpos($sqlmsg, 'Changed database context to');
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
         if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) {
1827 1827
             return false;
1828 1828
         } else {
1829
-        	global $app_strings;
1829
+            global $app_strings;
1830 1830
             //ERR_MSSQL_DB_CONTEXT: localized version of 'Changed database context to' message
1831 1831
             if (empty($app_strings) or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])) {
1832 1832
                 //ignore the message from sql-server if $app_strings array is empty. This will happen
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
         }
1843 1843
 
1844 1844
         if ( strlen($sqlmsg) > 2 ) {
1845
-        	return "SQL Server error: " . $sqlmsg;
1845
+            return "SQL Server error: " . $sqlmsg;
1846 1846
         }
1847 1847
 
1848 1848
         return false;
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
     public function installConfig()
2066 2066
     {
2067 2067
         return array(
2068
-        	'LBL_DBCONFIG_MSG3' =>  array(
2068
+            'LBL_DBCONFIG_MSG3' =>  array(
2069 2069
                 "setup_db_database_name" => array("label" => 'LBL_DBCONF_DB_NAME', "required" => true),
2070 2070
             ),
2071 2071
             'LBL_DBCONFIG_MSG2' =>  array(
@@ -2097,8 +2097,8 @@  discard block
 block discarded – undo
2097 2097
      * @return string
2098 2098
      */
2099 2099
 
2100
-	public function getGuidSQL()
2100
+    public function getGuidSQL()
2101 2101
     {
2102
-      	return 'NEWID()';
2102
+            return 'NEWID()';
2103 2103
     }
2104 2104
 }
Please login to merge, or discard this patch.
modules/Users/authentication/AuthenticationController.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -42,27 +42,27 @@  discard block
 block discarded – undo
42 42
 
43 43
 class AuthenticationController
44 44
 {
45
-	public $loggedIn = false; //if a user has attempted to login
46
-	public $authenticated = false;
47
-	public $loginSuccess = false;// if a user has successfully logged in
45
+    public $loggedIn = false; //if a user has attempted to login
46
+    public $authenticated = false;
47
+    public $loginSuccess = false;// if a user has successfully logged in
48 48
 
49
-	protected static $authcontrollerinstance = null;
49
+    protected static $authcontrollerinstance = null;
50 50
 
51 51
     /**
52 52
      * @var SugarAuthenticate
53 53
      */
54 54
     public $authController;
55 55
 
56
-	/**
57
-	 * Creates an instance of the authentication controller and loads it
58
-	 *
59
-	 * @param STRING $type - the authentication Controller
60
-	 * @return AuthenticationController -
61
-	 */
62
-	public function __construct($type = null)
63
-	{
56
+    /**
57
+     * Creates an instance of the authentication controller and loads it
58
+     *
59
+     * @param STRING $type - the authentication Controller
60
+     * @return AuthenticationController -
61
+     */
62
+    public function __construct($type = null)
63
+    {
64 64
         $this->authController = $this->getAuthController($type);
65
-	}
65
+    }
66 66
 
67 67
     /**
68 68
      * Get auth controller object
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         }
82 82
 
83 83
         // check in custom dir first, in case someone want's to override an auth controller
84
-		if (file_exists('custom/modules/Users/authentication/'.$type.'/' . $type . '.php')) {
84
+        if (file_exists('custom/modules/Users/authentication/'.$type.'/' . $type . '.php')) {
85 85
             require_once('custom/modules/Users/authentication/'.$type.'/' . $type . '.php');
86 86
         } elseif (file_exists('modules/Users/authentication/'.$type.'/' . $type . '.php')) {
87 87
             require_once('modules/Users/authentication/'.$type.'/' . $type . '.php');
@@ -98,123 +98,123 @@  discard block
 block discarded – undo
98 98
         return new $type();
99 99
     }
100 100
 
101
-	/**
102
-	 * Returns an instance of the authentication controller
103
-	 *
104
-	 * @param string $type this is the type of authetnication you want to use default is SugarAuthenticate
105
-	 * @return an instance of the authetnciation controller
106
-	 */
107
-	public static function getInstance($type = null)
108
-	{
109
-		if (empty(self::$authcontrollerinstance)) {
110
-			self::$authcontrollerinstance = new AuthenticationController($type);
111
-		}
112
-
113
-		return self::$authcontrollerinstance;
114
-	}
115
-
116
-	/**
117
-	 * This function is called when a user initially tries to login.
118
-	 *
119
-	 * @param string $username
120
-	 * @param string $password
121
-	 * @param array $PARAMS
122
-	 * @return boolean true if the user successfully logs in or false otherwise.
123
-	 */
124
-	public function login($username, $password, $PARAMS = array())
125
-	{
126
-		//kbrill bug #13225
127
-		$_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts']))? $_SESSION['loginAttempts'] + 1: 1;
128
-		unset($GLOBALS['login_error']);
129
-
130
-		if($this->loggedIn)return $this->loginSuccess;
131
-		LogicHook::initialize()->call_custom_logic('Users', 'before_login');
132
-
133
-		$this->loginSuccess = $this->authController->loginAuthenticate($username, $password, false, $PARAMS);
134
-		$this->loggedIn = true;
135
-
136
-		if($this->loginSuccess){
137
-			//Ensure the user is authorized
138
-			checkAuthUserStatus();
139
-
140
-			//loginLicense();
141
-			if(!empty($GLOBALS['login_error'])){
142
-				unset($_SESSION['authenticated_user_id']);
143
-				$GLOBALS['log']->fatal('FAILED LOGIN: potential hack attempt:'.$GLOBALS['login_error']);
144
-				$this->loginSuccess = false;
145
-				return false;
146
-			}
147
-
148
-			//call business logic hook
149
-			if(isset($GLOBALS['current_user']))
150
-				$GLOBALS['current_user']->call_custom_logic('after_login');
151
-
152
-			// Check for running Admin Wizard
153
-			$config = new Administration();
154
-			$config->retrieveSettings();
155
-		    if ( is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard' ) {
156
-				$GLOBALS['module'] = 'Configurator';
157
-				$GLOBALS['action'] = 'AdminWizard';
158
-				ob_clean();
159
-				header("Location: index.php?module=Configurator&action=AdminWizard");
160
-				sugar_cleanup(true);
161
-			}
162
-
163
-			$ut = $GLOBALS['current_user']->getPreference('ut');
164
-			$checkTimeZone = true;
165
-			if (is_array($PARAMS) && !empty($PARAMS) && isset($PARAMS['passwordEncrypted'])) {
166
-				$checkTimeZone = false;
167
-			} // if
168
-			if(empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone' ) {
169
-				$GLOBALS['module'] = 'Users';
170
-				$GLOBALS['action'] = 'Wizard';
171
-				ob_clean();
172
-				header("Location: index.php?module=Users&action=Wizard");
173
-				sugar_cleanup(true);
174
-			}
175
-		}else{
176
-			//kbrill bug #13225
177
-			LogicHook::initialize();
178
-			$GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
179
-			$GLOBALS['log']->fatal('FAILED LOGIN:attempts[' .$_SESSION['loginAttempts'] .'] - '. $username);
180
-		}
181
-		// if password has expired, set a session variable
182
-
183
-		return $this->loginSuccess;
184
-	}
185
-
186
-	/**
187
-	 * This is called on every page hit.
188
-	 * It returns true if the current session is authenticated or false otherwise
189
-	 *
190
-	 * @return booelan
191
-	 */
192
-	public function sessionAuthenticate()
193
-	{
194
-		if(!$this->authenticated){
195
-			$this->authenticated = $this->authController->sessionAuthenticate();
196
-		}
197
-		if($this->authenticated){
198
-			if(!isset($_SESSION['userStats']['pages'])){
199
-			    $_SESSION['userStats']['loginTime'] = time();
200
-			    $_SESSION['userStats']['pages'] = 0;
201
-			}
202
-			$_SESSION['userStats']['lastTime'] = time();
203
-			$_SESSION['userStats']['pages']++;
204
-
205
-		}
206
-		return $this->authenticated;
207
-	}
208
-
209
-	/**
210
-	 * Called when a user requests to logout. Should invalidate the session and redirect
211
-	 * to the login page.
212
-	 */
213
-	public function logout()
214
-	{
215
-		$GLOBALS['current_user']->call_custom_logic('before_logout');
216
-		$this->authController->logout();
217
-		LogicHook::initialize();
218
-		$GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout');
219
-	}
101
+    /**
102
+     * Returns an instance of the authentication controller
103
+     *
104
+     * @param string $type this is the type of authetnication you want to use default is SugarAuthenticate
105
+     * @return an instance of the authetnciation controller
106
+     */
107
+    public static function getInstance($type = null)
108
+    {
109
+        if (empty(self::$authcontrollerinstance)) {
110
+            self::$authcontrollerinstance = new AuthenticationController($type);
111
+        }
112
+
113
+        return self::$authcontrollerinstance;
114
+    }
115
+
116
+    /**
117
+     * This function is called when a user initially tries to login.
118
+     *
119
+     * @param string $username
120
+     * @param string $password
121
+     * @param array $PARAMS
122
+     * @return boolean true if the user successfully logs in or false otherwise.
123
+     */
124
+    public function login($username, $password, $PARAMS = array())
125
+    {
126
+        //kbrill bug #13225
127
+        $_SESSION['loginAttempts'] = (isset($_SESSION['loginAttempts']))? $_SESSION['loginAttempts'] + 1: 1;
128
+        unset($GLOBALS['login_error']);
129
+
130
+        if($this->loggedIn)return $this->loginSuccess;
131
+        LogicHook::initialize()->call_custom_logic('Users', 'before_login');
132
+
133
+        $this->loginSuccess = $this->authController->loginAuthenticate($username, $password, false, $PARAMS);
134
+        $this->loggedIn = true;
135
+
136
+        if($this->loginSuccess){
137
+            //Ensure the user is authorized
138
+            checkAuthUserStatus();
139
+
140
+            //loginLicense();
141
+            if(!empty($GLOBALS['login_error'])){
142
+                unset($_SESSION['authenticated_user_id']);
143
+                $GLOBALS['log']->fatal('FAILED LOGIN: potential hack attempt:'.$GLOBALS['login_error']);
144
+                $this->loginSuccess = false;
145
+                return false;
146
+            }
147
+
148
+            //call business logic hook
149
+            if(isset($GLOBALS['current_user']))
150
+                $GLOBALS['current_user']->call_custom_logic('after_login');
151
+
152
+            // Check for running Admin Wizard
153
+            $config = new Administration();
154
+            $config->retrieveSettings();
155
+            if ( is_admin($GLOBALS['current_user']) && empty($config->settings['system_adminwizard']) && $_REQUEST['action'] != 'AdminWizard' ) {
156
+                $GLOBALS['module'] = 'Configurator';
157
+                $GLOBALS['action'] = 'AdminWizard';
158
+                ob_clean();
159
+                header("Location: index.php?module=Configurator&action=AdminWizard");
160
+                sugar_cleanup(true);
161
+            }
162
+
163
+            $ut = $GLOBALS['current_user']->getPreference('ut');
164
+            $checkTimeZone = true;
165
+            if (is_array($PARAMS) && !empty($PARAMS) && isset($PARAMS['passwordEncrypted'])) {
166
+                $checkTimeZone = false;
167
+            } // if
168
+            if(empty($ut) && $checkTimeZone && $_REQUEST['action'] != 'SetTimezone' && $_REQUEST['action'] != 'SaveTimezone' ) {
169
+                $GLOBALS['module'] = 'Users';
170
+                $GLOBALS['action'] = 'Wizard';
171
+                ob_clean();
172
+                header("Location: index.php?module=Users&action=Wizard");
173
+                sugar_cleanup(true);
174
+            }
175
+        }else{
176
+            //kbrill bug #13225
177
+            LogicHook::initialize();
178
+            $GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
179
+            $GLOBALS['log']->fatal('FAILED LOGIN:attempts[' .$_SESSION['loginAttempts'] .'] - '. $username);
180
+        }
181
+        // if password has expired, set a session variable
182
+
183
+        return $this->loginSuccess;
184
+    }
185
+
186
+    /**
187
+     * This is called on every page hit.
188
+     * It returns true if the current session is authenticated or false otherwise
189
+     *
190
+     * @return booelan
191
+     */
192
+    public function sessionAuthenticate()
193
+    {
194
+        if(!$this->authenticated){
195
+            $this->authenticated = $this->authController->sessionAuthenticate();
196
+        }
197
+        if($this->authenticated){
198
+            if(!isset($_SESSION['userStats']['pages'])){
199
+                $_SESSION['userStats']['loginTime'] = time();
200
+                $_SESSION['userStats']['pages'] = 0;
201
+            }
202
+            $_SESSION['userStats']['lastTime'] = time();
203
+            $_SESSION['userStats']['pages']++;
204
+
205
+        }
206
+        return $this->authenticated;
207
+    }
208
+
209
+    /**
210
+     * Called when a user requests to logout. Should invalidate the session and redirect
211
+     * to the login page.
212
+     */
213
+    public function logout()
214
+    {
215
+        $GLOBALS['current_user']->call_custom_logic('before_logout');
216
+        $this->authController->logout();
217
+        LogicHook::initialize();
218
+        $GLOBALS['logic_hook']->call_custom_logic('Users', 'after_logout');
219
+    }
220 220
 }
Please login to merge, or discard this patch.
install/performSetup.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 if(strpos($server_software,'Microsoft-IIS') !== false)
157 157
 {
158 158
     installLog("calling handleWebConfig()");
159
-	handleWebConfig();
159
+    handleWebConfig();
160 160
 } else {
161
-	installLog("calling handleHtaccess()");
161
+    installLog("calling handleHtaccess()");
162 162
     handleHtaccess();
163 163
 }
164 164
 
@@ -228,27 +228,27 @@  discard block
 block discarded – undo
228 228
  * loop through all the Beans and create their tables
229 229
  */
230 230
 installStatus($mod_strings['STAT_CREATE_DB']);
231
- installLog("looping through all the Beans and create their tables");
232
- //start by clearing out the vardefs
233
- VardefManager::clearVardef();
231
+    installLog("looping through all the Beans and create their tables");
232
+    //start by clearing out the vardefs
233
+    VardefManager::clearVardef();
234 234
 installerHook('pre_createAllModuleTables');
235 235
 
236 236
 
237 237
 foreach( $beanFiles as $bean => $file ) {
238
-	$doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers');
238
+    $doNotInit = array('Scheduler', 'SchedulersJob', 'ProjectTask','jjwg_Maps','jjwg_Address_Cache','jjwg_Areas','jjwg_Markers');
239 239
 
240
-	if(in_array($bean, $doNotInit)) {
241
-		$focus = new $bean(false);
242
-	} else {
243
-	    $focus = new $bean();
244
-	}
240
+    if(in_array($bean, $doNotInit)) {
241
+        $focus = new $bean(false);
242
+    } else {
243
+        $focus = new $bean();
244
+    }
245 245
 
246
-	if ( $bean == 'Configurator' )
247
-	    continue;
246
+    if ( $bean == 'Configurator' )
247
+        continue;
248 248
 
249 249
     $table_name = $focus->table_name;
250 250
     //installStatus(sprintf($mod_strings['STAT_CREATE_DB_TABLE'], $focus->table_name ));
251
-     installLog("processing table ".$focus->table_name);
251
+        installLog("processing table ".$focus->table_name);
252 252
     // check to see if we have already setup this table
253 253
     if(!in_array($table_name, $processed_tables)) {
254 254
         if(!file_exists("modules/".$focus->module_dir."/vardefs.php")){
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 continue; // support new vardef definitions
261 261
             }
262 262
         } else {
263
-        	continue; //no further processing needed for ignored beans.
263
+            continue; //no further processing needed for ignored beans.
264 264
         }
265 265
 
266 266
         // table has not been setup...we will do it now and remember that
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
         installerHook('pre_createModuleTable', array('module' => $focus->getObjectName()));
289 289
         SugarBean::createRelationshipMeta($focus->getObjectName(), $db, $table_name, $empty, $focus->module_dir);
290 290
         installerHook('post_createModuleTable', array('module' => $focus->getObjectName()));
291
-		echo ".";
291
+        echo ".";
292 292
 
293 293
     } // end if()
294 294
 }
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 
421 421
     //require_once('modules/Connectors/InstallDefaultConnectors.php');
422 422
 
423
-	///////////////////////////////////////////////////////////////////////////////
424
-	////    INSTALL PASSWORD TEMPLATES
423
+    ///////////////////////////////////////////////////////////////////////////////
424
+    ////    INSTALL PASSWORD TEMPLATES
425 425
     include('install/seed_data/Advanced_Password_SeedData.php');
426 426
 
427 427
 ///////////////////////////////////////////////////////////////////////////////
Please login to merge, or discard this patch.
install/installConfig.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     }
222 222
 
223 223
     private function getFormItems($mod_strings, $app_list_strings, $sugarConfigDefaults, $drivers, $checked, $db, $errors, $supportedLanguages,
224
-                                  $current_language, $customSession, $customLog, $customId, $customSessionHidden, $customLogHidden, $customIdHidden) {
224
+                                    $current_language, $customSession, $customLog, $customId, $customSessionHidden, $customLogHidden, $customIdHidden) {
225 225
 
226 226
 
227 227
 
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
             $_SESSION['email1'] = null;
446 446
         }
447 447
 
448
-		if(!isset($_SESSION['setup_site_admin_user_name'])) {
449
-			$_SESSION['setup_site_admin_user_name'] = null;
450
-		}
448
+        if(!isset($_SESSION['setup_site_admin_user_name'])) {
449
+            $_SESSION['setup_site_admin_user_name'] = null;
450
+        }
451 451
 		
452 452
         $out .=<<<EOQ
453 453
 <div class='install_block'>
Please login to merge, or discard this patch.
tests/tests/modules/Meetings/MeetingTest.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -164,23 +164,23 @@
 block discarded – undo
164 164
         $meeting->parent_name = 'Account';
165 165
 
166 166
         $expected = array(
167
-                      'DELETED' => 0,
168
-                      'PARENT_TYPE' => 'Accounts',
169
-                      'STATUS' => 'Planned',
170
-                      'TYPE' => 'Sugar',
171
-                      'REMINDER_TIME' => '-1',
172
-                      'EMAIL_REMINDER_TIME' => '-1',
173
-                      'EMAIL_REMINDER_SENT' => '0',
174
-                      'SEQUENCE' => '0',
175
-                      'CONTACT_NAME' => 'test',
176
-                      'PARENT_NAME' => '',
177
-                      'CONTACT_ID' => 1,
178
-                      'REPEAT_INTERVAL' => '1',
179
-                      'PARENT_MODULE' => 'Accounts',
180
-                      'SET_COMPLETE' => '<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Meetings","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=fqXdFZ_r6FC1K7P_Fy3mVw"     border=\'0\' alt="Close" /></a>',
181
-                      'DATE_START' => '<font class=\'overdueTask\'></font>',
182
-                      'REMINDER_CHECKED' => false,
183
-                      'EMAIL_REMINDER_CHECKED' => false,
167
+                        'DELETED' => 0,
168
+                        'PARENT_TYPE' => 'Accounts',
169
+                        'STATUS' => 'Planned',
170
+                        'TYPE' => 'Sugar',
171
+                        'REMINDER_TIME' => '-1',
172
+                        'EMAIL_REMINDER_TIME' => '-1',
173
+                        'EMAIL_REMINDER_SENT' => '0',
174
+                        'SEQUENCE' => '0',
175
+                        'CONTACT_NAME' => 'test',
176
+                        'PARENT_NAME' => '',
177
+                        'CONTACT_ID' => 1,
178
+                        'REPEAT_INTERVAL' => '1',
179
+                        'PARENT_MODULE' => 'Accounts',
180
+                        'SET_COMPLETE' => '<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Meetings","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=fqXdFZ_r6FC1K7P_Fy3mVw"     border=\'0\' alt="Close" /></a>',
181
+                        'DATE_START' => '<font class=\'overdueTask\'></font>',
182
+                        'REMINDER_CHECKED' => false,
183
+                        'EMAIL_REMINDER_CHECKED' => false,
184 184
                     );
185 185
 
186 186
         $actual = $meeting->get_list_view_data();
Please login to merge, or discard this patch.
tests/tests/modules/Calls/CallTest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -145,9 +145,9 @@
 block discarded – undo
145 145
                 'EMAIL_REMINDER_SENT' => '0',
146 146
                 'REPEAT_INTERVAL' => '1',
147 147
                 'SET_COMPLETE' => '~'
148
-                                  .preg_quote('<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Calls","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=')
149
-                                  .'[\w-]+'
150
-                                  .preg_quote('"     border=\'0\' alt="Close" /></a>').'~',
148
+                                    .preg_quote('<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Calls","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=')
149
+                                    .'[\w-]+'
150
+                                    .preg_quote('"     border=\'0\' alt="Close" /></a>').'~',
151 151
                 'DATE_START' => '<font class=\'overdueTask\'></font>',
152 152
                 'CONTACT_ID' => null,
153 153
                 'CONTACT_NAME' => null,
Please login to merge, or discard this patch.
modules/Meetings/Meeting.php 1 patch
Indentation   +652 added lines, -652 removed lines patch added patch discarded remove patch
@@ -40,150 +40,150 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 class Meeting extends SugarBean {
43
-	// Stored fields
44
-	var $id;
45
-	var $date_entered;
46
-	var $date_modified;
47
-	var $assigned_user_id;
48
-	var $modified_user_id;
49
-	var $created_by;
50
-	var $created_by_name;
51
-	var $modified_by_name;
52
-	var $description;
53
-	var $name;
54
-	var $location;
55
-	var $status;
56
-	var $type;
57
-	var $date_start;
58
-	var $time_start;
59
-	var $date_end;
60
-	var $duration_hours;
61
-	var $duration_minutes;
62
-	var $time_meridiem;
63
-	var $parent_type;
64
-	var $parent_type_options;
65
-	var $parent_id;
66
-	var $field_name_map;
67
-	var $contact_id;
68
-	var $user_id;
69
-	var $meeting_id;
70
-	var $reminder_time;
71
-	var $reminder_checked;
72
-	var $email_reminder_time;
73
-	var $email_reminder_checked;
74
-	var $email_reminder_sent;
75
-	var $required;
76
-	var $accept_status;
77
-	var $parent_name;
78
-	var $contact_name;
79
-	var $contact_phone;
80
-	var $contact_email;
81
-	var $account_id;
82
-	var $opportunity_id;
83
-	var $case_id;
84
-	var $assigned_user_name;
85
-	var $outlook_id;
86
-	var $sequence;
87
-	var $syncing = false;
88
-	var $recurring_source;
89
-
90
-	var $update_vcal = true;
91
-	var $contacts_arr;
92
-	var $users_arr;
93
-	var $meetings_arr;
94
-	// when assoc w/ a user/contact:
95
-	var $minutes_value_default = 15;
96
-	var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
97
-	var $table_name = "meetings";
98
-	var $rel_users_table = "meetings_users";
99
-	var $rel_contacts_table = "meetings_contacts";
100
-	var $rel_leads_table = "meetings_leads";
101
-	var $module_dir = "Meetings";
102
-	var $object_name = "Meeting";
103
-
104
-	var $importable = true;
105
-	// This is used to retrieve related fields from form posts.
106
-	var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name', 'accept_status');
107
-	var $relationship_fields = array('account_id'=>'accounts','opportunity_id'=>'opportunity','case_id'=>'case',
108
-									 'assigned_user_id'=>'users','contact_id'=>'contacts', 'user_id'=>'users', 'meeting_id'=>'meetings');
109
-	// so you can run get_users() twice and run query only once
110
-	var $cached_get_users = null;
111
-	var $new_schema = true;
43
+    // Stored fields
44
+    var $id;
45
+    var $date_entered;
46
+    var $date_modified;
47
+    var $assigned_user_id;
48
+    var $modified_user_id;
49
+    var $created_by;
50
+    var $created_by_name;
51
+    var $modified_by_name;
52
+    var $description;
53
+    var $name;
54
+    var $location;
55
+    var $status;
56
+    var $type;
57
+    var $date_start;
58
+    var $time_start;
59
+    var $date_end;
60
+    var $duration_hours;
61
+    var $duration_minutes;
62
+    var $time_meridiem;
63
+    var $parent_type;
64
+    var $parent_type_options;
65
+    var $parent_id;
66
+    var $field_name_map;
67
+    var $contact_id;
68
+    var $user_id;
69
+    var $meeting_id;
70
+    var $reminder_time;
71
+    var $reminder_checked;
72
+    var $email_reminder_time;
73
+    var $email_reminder_checked;
74
+    var $email_reminder_sent;
75
+    var $required;
76
+    var $accept_status;
77
+    var $parent_name;
78
+    var $contact_name;
79
+    var $contact_phone;
80
+    var $contact_email;
81
+    var $account_id;
82
+    var $opportunity_id;
83
+    var $case_id;
84
+    var $assigned_user_name;
85
+    var $outlook_id;
86
+    var $sequence;
87
+    var $syncing = false;
88
+    var $recurring_source;
89
+
90
+    var $update_vcal = true;
91
+    var $contacts_arr;
92
+    var $users_arr;
93
+    var $meetings_arr;
94
+    // when assoc w/ a user/contact:
95
+    var $minutes_value_default = 15;
96
+    var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
97
+    var $table_name = "meetings";
98
+    var $rel_users_table = "meetings_users";
99
+    var $rel_contacts_table = "meetings_contacts";
100
+    var $rel_leads_table = "meetings_leads";
101
+    var $module_dir = "Meetings";
102
+    var $object_name = "Meeting";
103
+
104
+    var $importable = true;
105
+    // This is used to retrieve related fields from form posts.
106
+    var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name', 'accept_status');
107
+    var $relationship_fields = array('account_id'=>'accounts','opportunity_id'=>'opportunity','case_id'=>'case',
108
+                                        'assigned_user_id'=>'users','contact_id'=>'contacts', 'user_id'=>'users', 'meeting_id'=>'meetings');
109
+    // so you can run get_users() twice and run query only once
110
+    var $cached_get_users = null;
111
+    var $new_schema = true;
112 112
     var $date_changed = false;
113 113
 
114
-	/**
115
-	 * sole constructor
116
-	 */
117
-	public function __construct() {
118
-		parent::__construct();
119
-		$this->setupCustomFields('Meetings');
120
-		foreach($this->field_defs as $field) {
121
-			$this->field_name_map[$field['name']] = $field;
122
-		}
114
+    /**
115
+     * sole constructor
116
+     */
117
+    public function __construct() {
118
+        parent::__construct();
119
+        $this->setupCustomFields('Meetings');
120
+        foreach($this->field_defs as $field) {
121
+            $this->field_name_map[$field['name']] = $field;
122
+        }
123 123
 //		$this->fill_in_additional_detail_fields();
124 124
         if(!empty($GLOBALS['app_list_strings']['duration_intervals'])) {
125 125
             $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals'];
126 126
         }
127
-	}
128
-
129
-	/**
130
-	 * @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
131
-	 */
132
-	public function Meeting(){
133
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
134
-		if(isset($GLOBALS['log'])) {
135
-			$GLOBALS['log']->deprecated($deprecatedMessage);
136
-		}
137
-		else {
138
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
139
-		}
140
-		self::__construct();
141
-	}
142
-
143
-	/**
144
-	 * Disable edit if meeting is recurring and source is not Sugar. It should be edited only from Outlook.
145
-	 * @param $view string
146
-	 * @param $is_owner bool
147
-	 */
148
-	function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){
149
-		// don't check if meeting is being synced from Outlook
150
-		if($this->syncing == false){
151
-			$view = strtolower($view);
152
-			switch($view){
153
-				case 'edit':
154
-				case 'save':
155
-				case 'editview':
156
-				case 'delete':
157
-					if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){
158
-						return false;
159
-					}
160
-			}
161
-		}
162
-		return parent::ACLAccess($view,$is_owner,$in_group);
163
-	}
164
-
165
-	/**
166
-	 * Stub for integration
167
-	 * @return bool
168
-	 */
169
-	function hasIntegratedMeeting() {
170
-		return false;
171
-	}
172
-
173
-	// save date_end by calculating user input
174
-	// this is for calendar
175
-	function save($check_notify = FALSE) {
176
-		global $timedate;
177
-		global $current_user;
178
-
179
-		global $disable_date_format;
127
+    }
128
+
129
+    /**
130
+     * @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
131
+     */
132
+    public function Meeting(){
133
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
134
+        if(isset($GLOBALS['log'])) {
135
+            $GLOBALS['log']->deprecated($deprecatedMessage);
136
+        }
137
+        else {
138
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
139
+        }
140
+        self::__construct();
141
+    }
142
+
143
+    /**
144
+     * Disable edit if meeting is recurring and source is not Sugar. It should be edited only from Outlook.
145
+     * @param $view string
146
+     * @param $is_owner bool
147
+     */
148
+    function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){
149
+        // don't check if meeting is being synced from Outlook
150
+        if($this->syncing == false){
151
+            $view = strtolower($view);
152
+            switch($view){
153
+                case 'edit':
154
+                case 'save':
155
+                case 'editview':
156
+                case 'delete':
157
+                    if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){
158
+                        return false;
159
+                    }
160
+            }
161
+        }
162
+        return parent::ACLAccess($view,$is_owner,$in_group);
163
+    }
164
+
165
+    /**
166
+     * Stub for integration
167
+     * @return bool
168
+     */
169
+    function hasIntegratedMeeting() {
170
+        return false;
171
+    }
172
+
173
+    // save date_end by calculating user input
174
+    // this is for calendar
175
+    function save($check_notify = FALSE) {
176
+        global $timedate;
177
+        global $current_user;
178
+
179
+        global $disable_date_format;
180 180
 
181 181
         if(isset($this->date_start))
182 182
         {
183 183
             $td = $timedate->fromDb($this->date_start);
184 184
             if(!$td){
185
-            		$this->date_start = $timedate->to_db($this->date_start);
186
-            		$td = $timedate->fromDb($this->date_start);
185
+                    $this->date_start = $timedate->to_db($this->date_start);
186
+                    $td = $timedate->fromDb($this->date_start);
187 187
             }
188 188
             if($td)
189 189
             {
@@ -199,30 +199,30 @@  discard block
 block discarded – undo
199 199
             }
200 200
         }
201 201
 
202
-		$check_notify =(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') ? true : false;
203
-		if(empty($_REQUEST['send_invites'])) {
204
-			if(!empty($this->id)) {
205
-				$old_record = new Meeting();
206
-				$old_record->retrieve($this->id);
207
-				$old_assigned_user_id = $old_record->assigned_user_id;
208
-			}
209
-			if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){
210
-				$this->special_notification = true;
211
-				$check_notify = true;
202
+        $check_notify =(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') ? true : false;
203
+        if(empty($_REQUEST['send_invites'])) {
204
+            if(!empty($this->id)) {
205
+                $old_record = new Meeting();
206
+                $old_record->retrieve($this->id);
207
+                $old_assigned_user_id = $old_record->assigned_user_id;
208
+            }
209
+            if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){
210
+                $this->special_notification = true;
211
+                $check_notify = true;
212 212
                 if(isset($_REQUEST['assigned_user_name'])) {
213 213
                     $this->new_assigned_user_name = $_REQUEST['assigned_user_name'];
214 214
                 }
215
-			}
216
-		}
217
-		/*nsingh 7/3/08  commenting out as bug #20814 is invalid
215
+            }
216
+        }
217
+        /*nsingh 7/3/08  commenting out as bug #20814 is invalid
218 218
 		if($current_user->getPreference('reminder_time')!= -1 &&  isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0  && $_POST['reminder_time']==-1){
219 219
 			$this->reminder_checked = '1';
220 220
 			$this->reminder_time = $current_user->getPreference('reminder_time');
221 221
 		}*/
222 222
 
223
-		// prevent a mass mailing for recurring meetings created in Calendar module
224
-		if(empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id))
225
-			$check_notify = false;
223
+        // prevent a mass mailing for recurring meetings created in Calendar module
224
+        if(empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id))
225
+            $check_notify = false;
226 226
 
227 227
         if (empty($this->status) ) {
228 228
             $this->status = $this->getDefaultStatus();
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
         }
244 244
 
245 245
         if (empty($this->type)) {
246
-			$this->type = 'Sugar';
247
-		}
246
+            $this->type = 'Sugar';
247
+        }
248 248
 
249 249
         if ( isset($api) && is_a($api,'WebMeeting') && empty($this->in_relationship_update) ) {
250 250
             // Make sure the API initialized and it supports Web Meetings
@@ -272,175 +272,175 @@  discard block
 block discarded – undo
272 272
             $api->logoff();
273 273
         }
274 274
 
275
-		$return_id = parent::save($check_notify);
275
+        $return_id = parent::save($check_notify);
276 276
 
277
-		if($this->update_vcal) {
278
-			vCal::cache_sugar_vcal($current_user);
279
-		}
277
+        if($this->update_vcal) {
278
+            vCal::cache_sugar_vcal($current_user);
279
+        }
280 280
 
281
-		if(isset($_REQUEST['reminders_data'])) {
282
-			Reminder::saveRemindersDataJson('Meetings', $return_id, html_entity_decode($_REQUEST['reminders_data']));
283
-		}
281
+        if(isset($_REQUEST['reminders_data'])) {
282
+            Reminder::saveRemindersDataJson('Meetings', $return_id, html_entity_decode($_REQUEST['reminders_data']));
283
+        }
284 284
 
285 285
 
286
-		return $return_id;
287
-	}
286
+        return $return_id;
287
+    }
288 288
 
289
-	// this is for calendar
290
-	function mark_deleted($id) {
289
+    // this is for calendar
290
+    function mark_deleted($id) {
291 291
 
292
-		require_once("modules/Calendar/CalendarUtils.php");
293
-		CalendarUtils::correctRecurrences($this, $id);
292
+        require_once("modules/Calendar/CalendarUtils.php");
293
+        CalendarUtils::correctRecurrences($this, $id);
294 294
 
295
-		global $current_user;
295
+        global $current_user;
296 296
 
297
-		parent::mark_deleted($id);
297
+        parent::mark_deleted($id);
298 298
 
299
-		if($this->update_vcal) {
300
-			vCal::cache_sugar_vcal($current_user);
301
-		}
302
-	}
299
+        if($this->update_vcal) {
300
+            vCal::cache_sugar_vcal($current_user);
301
+        }
302
+    }
303 303
 
304
-	function get_summary_text() {
305
-		return "$this->name";
306
-	}
304
+    function get_summary_text() {
305
+        return "$this->name";
306
+    }
307 307
 
308 308
     function create_export_query($order_by, $where, $relate_link_join='')
309 309
     {
310 310
         $custom_join = $this->getCustomJoin(true, true, $where);
311 311
         $custom_join['join'] .= $relate_link_join;
312
-		$contact_required = stristr($where, "contacts");
312
+        $contact_required = stristr($where, "contacts");
313 313
 
314
-		if($contact_required) {
315
-			$query = "SELECT meetings.*, contacts.first_name, contacts.last_name, contacts.assigned_user_id contact_name_owner, users.user_name as assigned_user_name   ";
314
+        if($contact_required) {
315
+            $query = "SELECT meetings.*, contacts.first_name, contacts.last_name, contacts.assigned_user_id contact_name_owner, users.user_name as assigned_user_name   ";
316 316
             $query .= $custom_join['select'];
317
-			$query .= " FROM contacts, meetings, meetings_contacts ";
318
-			$where_auto = " meetings_contacts.contact_id = contacts.id AND meetings_contacts.meeting_id = meetings.id AND meetings.deleted=0 AND contacts.deleted=0";
319
-		} else {
320
-			$query = 'SELECT meetings.*, users.user_name as assigned_user_name  ';
317
+            $query .= " FROM contacts, meetings, meetings_contacts ";
318
+            $where_auto = " meetings_contacts.contact_id = contacts.id AND meetings_contacts.meeting_id = meetings.id AND meetings.deleted=0 AND contacts.deleted=0";
319
+        } else {
320
+            $query = 'SELECT meetings.*, users.user_name as assigned_user_name  ';
321 321
             $query .= $custom_join['select'];
322
-			$query .= ' FROM meetings ';
323
-			$where_auto = "meetings.deleted=0";
324
-		}
325
-		$query .= "  LEFT JOIN users ON meetings.assigned_user_id=users.id ";
322
+            $query .= ' FROM meetings ';
323
+            $where_auto = "meetings.deleted=0";
324
+        }
325
+        $query .= "  LEFT JOIN users ON meetings.assigned_user_id=users.id ";
326 326
 
327 327
         $query .= $custom_join['join'];
328 328
 
329
-		if($where != "")
330
-			$query .= " where $where AND ".$where_auto;
331
-		else
332
-			$query .= " where ".$where_auto;
329
+        if($where != "")
330
+            $query .= " where $where AND ".$where_auto;
331
+        else
332
+            $query .= " where ".$where_auto;
333 333
 
334 334
         $order_by = $this->process_order_by($order_by);
335 335
         if (!empty($order_by)) {
336 336
             $query .= ' ORDER BY ' . $order_by;
337 337
         }
338 338
 
339
-		return $query;
340
-	}
341
-
342
-
343
-
344
-	function fill_in_additional_detail_fields() {
345
-		global $locale;
346
-		// Fill in the assigned_user_name
347
-		$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
348
-
349
-		if (!empty($this->contact_id)) {
350
-			$query  = "SELECT first_name, last_name FROM contacts ";
351
-			$query .= "WHERE id='$this->contact_id' AND deleted=0";
352
-			$result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
339
+        return $query;
340
+    }
353 341
 
354
-			// Get the contact name.
355
-			$row = $this->db->fetchByAssoc($result);
356
-			$GLOBALS['log']->info("additional call fields $query");
357
-			if($row != null)
358
-			{
359
-				$this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
360
-				$GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
361
-				$GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
362
-			}
363
-		}
364 342
 
365 343
 
344
+    function fill_in_additional_detail_fields() {
345
+        global $locale;
346
+        // Fill in the assigned_user_name
347
+        $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
366 348
 
367
-		$this->created_by_name = get_assigned_user_name($this->created_by);
368
-		$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
369
-		$this->fill_in_additional_parent_fields();
349
+        if (!empty($this->contact_id)) {
350
+            $query  = "SELECT first_name, last_name FROM contacts ";
351
+            $query .= "WHERE id='$this->contact_id' AND deleted=0";
352
+            $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
370 353
 
371
-		if (!isset($this->time_hour_start)) {
372
-			$this->time_start_hour = intval(substr($this->time_start, 0, 2));
373
-		} //if-else
354
+            // Get the contact name.
355
+            $row = $this->db->fetchByAssoc($result);
356
+            $GLOBALS['log']->info("additional call fields $query");
357
+            if($row != null)
358
+            {
359
+                $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
360
+                $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
361
+                $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
362
+            }
363
+        }
374 364
 
375
-		if (isset($this->time_minute_start)) {
376
-			$time_start_minutes = $this->time_minute_start;
377
-		} else {
378
-			$time_start_minutes = substr($this->time_start, 3, 5);
379
-			if ($time_start_minutes > 0 && $time_start_minutes < 15) {
380
-				$time_start_minutes = "15";
381
-			} else if ($time_start_minutes > 15 && $time_start_minutes < 30) {
382
-				$time_start_minutes = "30";
383
-			} else if ($time_start_minutes > 30 && $time_start_minutes < 45) {
384
-				$time_start_minutes = "45";
385
-			} else if ($time_start_minutes > 45) {
386
-				$this->time_start_hour += 1;
387
-				$time_start_minutes = "00";
388
-		    } //if-else
389
-		} //if-else
390 365
 
391 366
 
392
-		if (isset($this->time_hour_start)) {
393
-			$time_start_hour = $this->time_hour_start;
394
-		} else {
395
-			$time_start_hour = intval(substr($this->time_start, 0, 2));
396
-		}
367
+        $this->created_by_name = get_assigned_user_name($this->created_by);
368
+        $this->modified_by_name = get_assigned_user_name($this->modified_user_id);
369
+        $this->fill_in_additional_parent_fields();
370
+
371
+        if (!isset($this->time_hour_start)) {
372
+            $this->time_start_hour = intval(substr($this->time_start, 0, 2));
373
+        } //if-else
374
+
375
+        if (isset($this->time_minute_start)) {
376
+            $time_start_minutes = $this->time_minute_start;
377
+        } else {
378
+            $time_start_minutes = substr($this->time_start, 3, 5);
379
+            if ($time_start_minutes > 0 && $time_start_minutes < 15) {
380
+                $time_start_minutes = "15";
381
+            } else if ($time_start_minutes > 15 && $time_start_minutes < 30) {
382
+                $time_start_minutes = "30";
383
+            } else if ($time_start_minutes > 30 && $time_start_minutes < 45) {
384
+                $time_start_minutes = "45";
385
+            } else if ($time_start_minutes > 45) {
386
+                $this->time_start_hour += 1;
387
+                $time_start_minutes = "00";
388
+            } //if-else
389
+        } //if-else
390
+
391
+
392
+        if (isset($this->time_hour_start)) {
393
+            $time_start_hour = $this->time_hour_start;
394
+        } else {
395
+            $time_start_hour = intval(substr($this->time_start, 0, 2));
396
+        }
397 397
 
398
-		global $timedate;
398
+        global $timedate;
399 399
         $this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"');
400
-		$hours_arr = array ();
401
-		$num_of_hours = 13;
402
-		$start_at = 1;
403
-
404
-		if (empty ($time_meridiem)) {
405
-			$num_of_hours = 24;
406
-			$start_at = 0;
407
-		} //if
408
-
409
-		for ($i = $start_at; $i < $num_of_hours; $i ++) {
410
-			$i = $i."";
411
-			if (strlen($i) == 1) {
412
-				$i = "0".$i;
413
-			}
414
-			$hours_arr[$i] = $i;
415
-		} //for
400
+        $hours_arr = array ();
401
+        $num_of_hours = 13;
402
+        $start_at = 1;
403
+
404
+        if (empty ($time_meridiem)) {
405
+            $num_of_hours = 24;
406
+            $start_at = 0;
407
+        } //if
408
+
409
+        for ($i = $start_at; $i < $num_of_hours; $i ++) {
410
+            $i = $i."";
411
+            if (strlen($i) == 1) {
412
+                $i = "0".$i;
413
+            }
414
+            $hours_arr[$i] = $i;
415
+        } //for
416 416
 
417 417
         if (!isset($this->duration_minutes)) {
418
-			$this->duration_minutes = $this->minutes_value_default;
419
-		}
418
+            $this->duration_minutes = $this->minutes_value_default;
419
+        }
420 420
 
421 421
         //setting default date and time
422
-		if (is_null($this->date_start))
423
-			$this->date_start = $timedate->now();
424
-		if (is_null($this->time_start))
425
-			$this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true);
426
-		if (is_null($this->duration_hours)) {
427
-			$this->duration_hours = "0";
428
-		}
429
-		if (is_null($this->duration_minutes))
430
-			$this->duration_minutes = "1";
431
-
432
-		if(empty($this->id) && !empty($_REQUEST['date_start'])){
433
-			$this->date_start = $_REQUEST['date_start'];
434
-		}
422
+        if (is_null($this->date_start))
423
+            $this->date_start = $timedate->now();
424
+        if (is_null($this->time_start))
425
+            $this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true);
426
+        if (is_null($this->duration_hours)) {
427
+            $this->duration_hours = "0";
428
+        }
429
+        if (is_null($this->duration_minutes))
430
+            $this->duration_minutes = "1";
431
+
432
+        if(empty($this->id) && !empty($_REQUEST['date_start'])){
433
+            $this->date_start = $_REQUEST['date_start'];
434
+        }
435 435
         if(!empty($this->date_start))
436 436
         {
437 437
             $td = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(),$this->date_start);
438 438
             if (!empty($td))
439 439
             {
440
-    	        if (!empty($this->duration_hours) && $this->duration_hours != '')
440
+                if (!empty($this->duration_hours) && $this->duration_hours != '')
441 441
                 {
442
-		            $td = $td->modify("+{$this->duration_hours} hours");
443
-		        }
442
+                    $td = $td->modify("+{$this->duration_hours} hours");
443
+                }
444 444
                 if (!empty($this->duration_minutes) && $this->duration_minutes != '')
445 445
                 {
446 446
                     $td = $td->modify("+{$this->duration_minutes} mins");
@@ -451,77 +451,77 @@  discard block
 block discarded – undo
451 451
             {
452 452
                 $GLOBALS['log']->fatal("Meeting::save: Bad date {$this->date_start} for format ".$GLOBALS['timedate']->get_date_time_format());
453 453
             }
454
-		}
455
-
456
-		global $app_list_strings;
457
-		$parent_types = $app_list_strings['record_type_display'];
458
-		$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
459
-		foreach($disabled_parent_types as $disabled_parent_type){
460
-			if($disabled_parent_type != $this->parent_type){
461
-				unset($parent_types[$disabled_parent_type]);
462
-			}
463
-		}
464
-
465
-		$this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
466
-		if (empty($this->reminder_time)) {
467
-			$this->reminder_time = -1;
468
-		}
469
-
470
-		if ( empty($this->id) ) {
471
-		    $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
472
-		    if ( isset($reminder_t) )
473
-		        $this->reminder_time = $reminder_t;
474
-		}
475
-		$this->reminder_checked = $this->reminder_time == -1 ? false : true;
476
-
477
-		if (empty($this->email_reminder_time)) {
478
-			$this->email_reminder_time = -1;
479
-		}
480
-		if(empty($this->id)){
481
-			$reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time');
482
-			if(isset($reminder_t))
483
-		    		$this->email_reminder_time = $reminder_t;
484
-		}
485
-		$this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true;
486
-
487
-		if (isset ($_REQUEST['parent_type']) && empty($this->parent_type)) {
488
-			$this->parent_type = $_REQUEST['parent_type'];
489
-		} elseif (is_null($this->parent_type)) {
490
-			$this->parent_type = $app_list_strings['record_type_default_key'];
491
-		}
492
-
493
-	}
494
-
495
-	function get_list_view_data() {
496
-		$meeting_fields = $this->get_list_view_array();
497
-
498
-		global $app_list_strings, $focus, $action, $currentModule;
499
-		if(isset($this->parent_type))
500
-			$meeting_fields['PARENT_MODULE'] = $this->parent_type;
501
-		if($this->status == "Planned") {
502
-			//cn: added this if() to deal with sequential Closes in Meetings.	this is a hack to a hack(formbase.php->handleRedirect)
503
-			if(empty($action))
504
-			     $action = "index";
454
+        }
455
+
456
+        global $app_list_strings;
457
+        $parent_types = $app_list_strings['record_type_display'];
458
+        $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
459
+        foreach($disabled_parent_types as $disabled_parent_type){
460
+            if($disabled_parent_type != $this->parent_type){
461
+                unset($parent_types[$disabled_parent_type]);
462
+            }
463
+        }
464
+
465
+        $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
466
+        if (empty($this->reminder_time)) {
467
+            $this->reminder_time = -1;
468
+        }
469
+
470
+        if ( empty($this->id) ) {
471
+            $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
472
+            if ( isset($reminder_t) )
473
+                $this->reminder_time = $reminder_t;
474
+        }
475
+        $this->reminder_checked = $this->reminder_time == -1 ? false : true;
476
+
477
+        if (empty($this->email_reminder_time)) {
478
+            $this->email_reminder_time = -1;
479
+        }
480
+        if(empty($this->id)){
481
+            $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time');
482
+            if(isset($reminder_t))
483
+                    $this->email_reminder_time = $reminder_t;
484
+        }
485
+        $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true;
486
+
487
+        if (isset ($_REQUEST['parent_type']) && empty($this->parent_type)) {
488
+            $this->parent_type = $_REQUEST['parent_type'];
489
+        } elseif (is_null($this->parent_type)) {
490
+            $this->parent_type = $app_list_strings['record_type_default_key'];
491
+        }
492
+
493
+    }
494
+
495
+    function get_list_view_data() {
496
+        $meeting_fields = $this->get_list_view_array();
497
+
498
+        global $app_list_strings, $focus, $action, $currentModule;
499
+        if(isset($this->parent_type))
500
+            $meeting_fields['PARENT_MODULE'] = $this->parent_type;
501
+        if($this->status == "Planned") {
502
+            //cn: added this if() to deal with sequential Closes in Meetings.	this is a hack to a hack(formbase.php->handleRedirect)
503
+            if(empty($action))
504
+                    $action = "index";
505 505
             $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>";
506
-			if ($this->ACLAccess('edit')) {
506
+            if ($this->ACLAccess('edit')) {
507 507
                 $meeting_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>";
508 508
             } else {
509 509
                 $meeting_fields['SET_COMPLETE'] = '';
510 510
             }
511
-		}
512
-		global $timedate;
513
-		$today = $timedate->nowDb();
514
-		$nextday = $timedate->asDbDate($timedate->getNow()->get("+1 day"));
515
-		$mergeTime = $meeting_fields['DATE_START']; //$timedate->merge_date_time($meeting_fields['DATE_START'], $meeting_fields['TIME_START']);
516
-		$date_db = $timedate->to_db($mergeTime);
517
-		if($date_db	< $today	) {
518
-			$meeting_fields['DATE_START']= "<font class='overdueTask'>".$meeting_fields['DATE_START']."</font>";
519
-		}else if($date_db	< $nextday) {
520
-			$meeting_fields['DATE_START'] = "<font class='todaysTask'>".$meeting_fields['DATE_START']."</font>";
521
-		} else {
522
-			$meeting_fields['DATE_START'] = "<font class='futureTask'>".$meeting_fields['DATE_START']."</font>";
523
-		}
524
-		$this->fill_in_additional_detail_fields();
511
+        }
512
+        global $timedate;
513
+        $today = $timedate->nowDb();
514
+        $nextday = $timedate->asDbDate($timedate->getNow()->get("+1 day"));
515
+        $mergeTime = $meeting_fields['DATE_START']; //$timedate->merge_date_time($meeting_fields['DATE_START'], $meeting_fields['TIME_START']);
516
+        $date_db = $timedate->to_db($mergeTime);
517
+        if($date_db	< $today	) {
518
+            $meeting_fields['DATE_START']= "<font class='overdueTask'>".$meeting_fields['DATE_START']."</font>";
519
+        }else if($date_db	< $nextday) {
520
+            $meeting_fields['DATE_START'] = "<font class='todaysTask'>".$meeting_fields['DATE_START']."</font>";
521
+        } else {
522
+            $meeting_fields['DATE_START'] = "<font class='futureTask'>".$meeting_fields['DATE_START']."</font>";
523
+        }
524
+        $this->fill_in_additional_detail_fields();
525 525
 
526 526
         // make sure we grab the localized version of the contact name, if a contact is provided
527 527
         if (!empty($this->contact_id))
@@ -537,342 +537,342 @@  discard block
 block discarded – undo
537 537
 
538 538
         $meeting_fields['CONTACT_ID'] = $this->contact_id;
539 539
         $meeting_fields['CONTACT_NAME'] = $this->contact_name;
540
-		$meeting_fields['PARENT_NAME'] = $this->parent_name;
540
+        $meeting_fields['PARENT_NAME'] = $this->parent_name;
541 541
         $meeting_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true;
542 542
         $meeting_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true;
543 543
 
544 544
 
545
-		return $meeting_fields;
546
-	}
547
-
548
-	function set_notification_body($xtpl, &$meeting) {
549
-		global $sugar_config;
550
-		global $app_list_strings;
551
-		global $current_user;
552
-		global $timedate;
553
-
554
-
555
-		// cn: bug 9494 - passing a contact breaks this call
556
-		$notifyUser =($meeting->current_notify_user->object_name == 'User') ? $meeting->current_notify_user : $current_user;
557
-		// cn: bug 8078 - fixed call to $timedate
558
-		if(strtolower(get_class($meeting->current_notify_user)) == 'contact') {
559
-			$xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
560
-							'/index.php?entryPoint=acceptDecline&module=Meetings&contact_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
561
-		} elseif(strtolower(get_class($meeting->current_notify_user)) == 'lead') {
562
-			$xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
563
-							'/index.php?entryPoint=acceptDecline&module=Meetings&lead_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
564
-		} else {
565
-			$xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
566
-							'/index.php?entryPoint=acceptDecline&module=Meetings&user_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
567
-		}
568
-		$xtpl->assign("MEETING_TO", $meeting->current_notify_user->new_assigned_user_name);
569
-		$xtpl->assign("MEETING_SUBJECT", trim($meeting->name));
570
-		$xtpl->assign("MEETING_STATUS",(isset($meeting->status)? $app_list_strings['meeting_status_dom'][$meeting->status]:""));
571
-		$typekey = strtolower($meeting->type);
572
-		if(isset($meeting->type)) {
573
-		    if(!empty($app_list_strings['eapm_list'][$typekey])) {
574
-    		    $typestring = $app_list_strings['eapm_list'][$typekey];
575
-	    	} else {
576
-		        $typestring = $app_list_strings['meeting_type_dom'][$meeting->type];
577
-		    }
578
-		}
579
-		$xtpl->assign("MEETING_TYPE", isset($meeting->type)? $typestring:"");
580
-		$startdate = $timedate->fromDb($meeting->date_start);
581
-		$xtpl->assign("MEETING_STARTDATE", $timedate->asUser($startdate, $notifyUser)." ".TimeDate::userTimezoneSuffix($startdate, $notifyUser));
582
-		$enddate = $timedate->fromDb($meeting->date_end);
583
-		$xtpl->assign("MEETING_ENDDATE", $timedate->asUser($enddate, $notifyUser)." ".TimeDate::userTimezoneSuffix($enddate, $notifyUser));
584
-		$xtpl->assign("MEETING_HOURS", $meeting->duration_hours);
585
-		$xtpl->assign("MEETING_MINUTES", $meeting->duration_minutes);
586
-		$xtpl->assign("MEETING_DESCRIPTION", $meeting->description);
545
+        return $meeting_fields;
546
+    }
547
+
548
+    function set_notification_body($xtpl, &$meeting) {
549
+        global $sugar_config;
550
+        global $app_list_strings;
551
+        global $current_user;
552
+        global $timedate;
553
+
554
+
555
+        // cn: bug 9494 - passing a contact breaks this call
556
+        $notifyUser =($meeting->current_notify_user->object_name == 'User') ? $meeting->current_notify_user : $current_user;
557
+        // cn: bug 8078 - fixed call to $timedate
558
+        if(strtolower(get_class($meeting->current_notify_user)) == 'contact') {
559
+            $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
560
+                            '/index.php?entryPoint=acceptDecline&module=Meetings&contact_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
561
+        } elseif(strtolower(get_class($meeting->current_notify_user)) == 'lead') {
562
+            $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
563
+                            '/index.php?entryPoint=acceptDecline&module=Meetings&lead_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
564
+        } else {
565
+            $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
566
+                            '/index.php?entryPoint=acceptDecline&module=Meetings&user_id='.$meeting->current_notify_user->id.'&record='.$meeting->id);
567
+        }
568
+        $xtpl->assign("MEETING_TO", $meeting->current_notify_user->new_assigned_user_name);
569
+        $xtpl->assign("MEETING_SUBJECT", trim($meeting->name));
570
+        $xtpl->assign("MEETING_STATUS",(isset($meeting->status)? $app_list_strings['meeting_status_dom'][$meeting->status]:""));
571
+        $typekey = strtolower($meeting->type);
572
+        if(isset($meeting->type)) {
573
+            if(!empty($app_list_strings['eapm_list'][$typekey])) {
574
+                $typestring = $app_list_strings['eapm_list'][$typekey];
575
+            } else {
576
+                $typestring = $app_list_strings['meeting_type_dom'][$meeting->type];
577
+            }
578
+        }
579
+        $xtpl->assign("MEETING_TYPE", isset($meeting->type)? $typestring:"");
580
+        $startdate = $timedate->fromDb($meeting->date_start);
581
+        $xtpl->assign("MEETING_STARTDATE", $timedate->asUser($startdate, $notifyUser)." ".TimeDate::userTimezoneSuffix($startdate, $notifyUser));
582
+        $enddate = $timedate->fromDb($meeting->date_end);
583
+        $xtpl->assign("MEETING_ENDDATE", $timedate->asUser($enddate, $notifyUser)." ".TimeDate::userTimezoneSuffix($enddate, $notifyUser));
584
+        $xtpl->assign("MEETING_HOURS", $meeting->duration_hours);
585
+        $xtpl->assign("MEETING_MINUTES", $meeting->duration_minutes);
586
+        $xtpl->assign("MEETING_DESCRIPTION", $meeting->description);
587 587
         if ( !empty($meeting->join_url) ) {
588 588
             $xtpl->assign('MEETING_URL', $meeting->join_url);
589 589
             $xtpl->parse('Meeting.Meeting_External_API');
590 590
         }
591 591
 
592
-		return $xtpl;
593
-	}
592
+        return $xtpl;
593
+    }
594 594
 
595
-	/**
596
-	 * Redefine method to attach ics file to notification email
597
-	 */
598
-	public function create_notification_email($notify_user){
595
+    /**
596
+     * Redefine method to attach ics file to notification email
597
+     */
598
+    public function create_notification_email($notify_user){
599 599
         // reset acceptance status for non organizer if date is changed
600 600
         if (($notify_user->id != $GLOBALS['current_user']->id) && $this->date_changed) {
601 601
             $this->set_accept_status($notify_user, 'none');
602 602
         }
603 603
 
604
-		$notify_mail = parent::create_notification_email($notify_user);
605
-
606
-		$path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id;
607
-
608
-		require_once("modules/vCals/vCal.php");
609
-		$content = vCal::get_ical_event($this, $GLOBALS['current_user']);
610
-
611
-		if(file_put_contents($path,$content)){
612
-			$notify_mail->AddAttachment($path, 'meeting.ics', 'base64', 'text/calendar');
613
-		}
614
-		return $notify_mail;
615
-	}
616
-
617
-	/**
618
-	 * Redefine method to remove ics after email is sent
619
-	 */
620
-	public function send_assignment_notifications($notify_user, $admin){
621
-		parent::send_assignment_notifications($notify_user, $admin);
622
-
623
-		$path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id;
624
-		unlink($path);
625
-	}
626
-
627
-	function get_meeting_users() {
628
-		$template = new User();
629
-		// First, get the list of IDs.
630
-		$query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.user_id from meetings_users where meetings_users.meeting_id='$this->id' AND meetings_users.deleted=0";
631
-		$GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
632
-		$result = $this->db->query($query, true);
633
-		$list = Array();
634
-
635
-		while($row = $this->db->fetchByAssoc($result)) {
636
-			$template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
637
-			$record = $template->retrieve($row['user_id']);
638
-			$template->required = $row['required'];
639
-			$template->accept_status = $row['accept_status'];
640
-
641
-			if($record != null) {
642
-				// this copies the object into the array
643
-				$list[] = $template;
644
-			}
645
-		}
646
-		return $list;
647
-	}
648
-
649
-	function get_invite_meetings(&$user) {
650
-		$template = $this;
651
-		// First, get the list of IDs.
652
-		$GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
653
-		$query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.meeting_id from meetings_users where meetings_users.user_id='$user->id' AND( meetings_users.accept_status IS NULL OR	meetings_users.accept_status='none') AND meetings_users.deleted=0";
654
-		$result = $this->db->query($query, true);
655
-		$list = Array();
656
-
657
-		while($row = $this->db->fetchByAssoc($result)) {
658
-			$record = $template->retrieve($row['meeting_id']);
659
-			$template->required = $row['required'];
660
-			$template->accept_status = $row['accept_status'];
661
-
662
-
663
-			if($record != null)
664
-			{
665
-			// this copies the object into the array
666
-			$list[] = $template;
667
-			}
668
-		}
669
-		return $list;
670
-	}
671
-
672
-
673
-	function set_accept_status(&$user,$status)
674
-	{
675
-		if($user->object_name == 'User')
676
-		{
677
-			$relate_values = array('user_id'=>$user->id,'meeting_id'=>$this->id);
678
-			$data_values = array('accept_status'=>$status);
679
-			$this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
680
-			global $current_user;
681
-
682
-			if($this->update_vcal)
683
-			{
684
-				vCal::cache_sugar_vcal($user);
685
-			}
686
-		}
687
-		else if($user->object_name == 'Contact')
688
-		{
689
-			$relate_values = array('contact_id'=>$user->id,'meeting_id'=>$this->id);
690
-			$data_values = array('accept_status'=>$status);
691
-			$this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
692
-		}
604
+        $notify_mail = parent::create_notification_email($notify_user);
605
+
606
+        $path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id;
607
+
608
+        require_once("modules/vCals/vCal.php");
609
+        $content = vCal::get_ical_event($this, $GLOBALS['current_user']);
610
+
611
+        if(file_put_contents($path,$content)){
612
+            $notify_mail->AddAttachment($path, 'meeting.ics', 'base64', 'text/calendar');
613
+        }
614
+        return $notify_mail;
615
+    }
616
+
617
+    /**
618
+     * Redefine method to remove ics after email is sent
619
+     */
620
+    public function send_assignment_notifications($notify_user, $admin){
621
+        parent::send_assignment_notifications($notify_user, $admin);
622
+
623
+        $path = SugarConfig::getInstance()->get('upload_dir','upload/') . $this->id;
624
+        unlink($path);
625
+    }
626
+
627
+    function get_meeting_users() {
628
+        $template = new User();
629
+        // First, get the list of IDs.
630
+        $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.user_id from meetings_users where meetings_users.meeting_id='$this->id' AND meetings_users.deleted=0";
631
+        $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
632
+        $result = $this->db->query($query, true);
633
+        $list = Array();
634
+
635
+        while($row = $this->db->fetchByAssoc($result)) {
636
+            $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
637
+            $record = $template->retrieve($row['user_id']);
638
+            $template->required = $row['required'];
639
+            $template->accept_status = $row['accept_status'];
640
+
641
+            if($record != null) {
642
+                // this copies the object into the array
643
+                $list[] = $template;
644
+            }
645
+        }
646
+        return $list;
647
+    }
648
+
649
+    function get_invite_meetings(&$user) {
650
+        $template = $this;
651
+        // First, get the list of IDs.
652
+        $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
653
+        $query = "SELECT meetings_users.required, meetings_users.accept_status, meetings_users.meeting_id from meetings_users where meetings_users.user_id='$user->id' AND( meetings_users.accept_status IS NULL OR	meetings_users.accept_status='none') AND meetings_users.deleted=0";
654
+        $result = $this->db->query($query, true);
655
+        $list = Array();
656
+
657
+        while($row = $this->db->fetchByAssoc($result)) {
658
+            $record = $template->retrieve($row['meeting_id']);
659
+            $template->required = $row['required'];
660
+            $template->accept_status = $row['accept_status'];
661
+
662
+
663
+            if($record != null)
664
+            {
665
+            // this copies the object into the array
666
+            $list[] = $template;
667
+            }
668
+        }
669
+        return $list;
670
+    }
671
+
672
+
673
+    function set_accept_status(&$user,$status)
674
+    {
675
+        if($user->object_name == 'User')
676
+        {
677
+            $relate_values = array('user_id'=>$user->id,'meeting_id'=>$this->id);
678
+            $data_values = array('accept_status'=>$status);
679
+            $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
680
+            global $current_user;
681
+
682
+            if($this->update_vcal)
683
+            {
684
+                vCal::cache_sugar_vcal($user);
685
+            }
686
+        }
687
+        else if($user->object_name == 'Contact')
688
+        {
689
+            $relate_values = array('contact_id'=>$user->id,'meeting_id'=>$this->id);
690
+            $data_values = array('accept_status'=>$status);
691
+            $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
692
+        }
693 693
         else if($user->object_name == 'Lead')
694
-		{
695
-			$relate_values = array('lead_id'=>$user->id,'meeting_id'=>$this->id);
696
-			$data_values = array('accept_status'=>$status);
697
-			$this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
698
-		}
699
-	}
694
+        {
695
+            $relate_values = array('lead_id'=>$user->id,'meeting_id'=>$this->id);
696
+            $data_values = array('accept_status'=>$status);
697
+            $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
698
+        }
699
+    }
700 700
 
701 701
 
702
-	function get_notification_recipients() {
703
-		if($this->special_notification) {
704
-			return parent::get_notification_recipients();
705
-		}
702
+    function get_notification_recipients() {
703
+        if($this->special_notification) {
704
+            return parent::get_notification_recipients();
705
+        }
706 706
 
707
-		$list = array();
708
-		if(!is_array($this->contacts_arr)) {
709
-			$this->contacts_arr =	array();
710
-		}
707
+        $list = array();
708
+        if(!is_array($this->contacts_arr)) {
709
+            $this->contacts_arr =	array();
710
+        }
711 711
 
712
-		if(!is_array($this->users_arr)) {
713
-			$this->users_arr =	array();
714
-		}
712
+        if(!is_array($this->users_arr)) {
713
+            $this->users_arr =	array();
714
+        }
715 715
 
716 716
         if(!is_array($this->leads_arr)) {
717
-			$this->leads_arr =	array();
718
-		}
719
-
720
-		foreach($this->users_arr as $user_id) {
721
-			$notify_user = new User();
722
-			$notify_user->retrieve($user_id);
723
-			$notify_user->new_assigned_user_name = $notify_user->full_name;
724
-			$GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
725
-			$list[$notify_user->id] = $notify_user;
726
-		}
727
-
728
-		foreach($this->contacts_arr as $contact_id) {
729
-			$notify_user = new Contact();
730
-			$notify_user->retrieve($contact_id);
731
-			$notify_user->new_assigned_user_name = $notify_user->full_name;
732
-			$GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
733
-			$list[$notify_user->id] = $notify_user;
734
-		}
717
+            $this->leads_arr =	array();
718
+        }
719
+
720
+        foreach($this->users_arr as $user_id) {
721
+            $notify_user = new User();
722
+            $notify_user->retrieve($user_id);
723
+            $notify_user->new_assigned_user_name = $notify_user->full_name;
724
+            $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
725
+            $list[$notify_user->id] = $notify_user;
726
+        }
727
+
728
+        foreach($this->contacts_arr as $contact_id) {
729
+            $notify_user = new Contact();
730
+            $notify_user->retrieve($contact_id);
731
+            $notify_user->new_assigned_user_name = $notify_user->full_name;
732
+            $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
733
+            $list[$notify_user->id] = $notify_user;
734
+        }
735 735
 
736 736
         foreach($this->leads_arr as $lead_id) {
737
-			$notify_user = new Lead();
738
-			$notify_user->retrieve($lead_id);
739
-			$notify_user->new_assigned_user_name = $notify_user->full_name;
740
-			$GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
741
-			$list[$notify_user->id] = $notify_user;
742
-		}
743
-
744
-		global $sugar_config;
745
-		if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) {
746
-			global $current_user;
747
-			if(isset($list[$current_user->id]))
748
-				unset($list[$current_user->id]);
749
-		}
750
-		return $list;
751
-	}
752
-
753
-
754
-	function bean_implements($interface) {
755
-		switch($interface) {
756
-			case 'ACL':return true;
757
-		}
758
-		return false;
759
-	}
760
-
761
-	function listviewACLHelper() {
762
-		$array_assign = parent::listviewACLHelper();
763
-		$is_owner = false;
764
-		$in_group = false; //SECURITY GROUPS
765
-		if(!empty($this->parent_name)) {
766
-
767
-			if(!empty($this->parent_name_owner)) {
768
-				global $current_user;
769
-				$is_owner = $current_user->id == $this->parent_name_owner;
770
-			}
771
-			/* BEGIN - SECURITY GROUPS */
772
-			//parent_name_owner not being set for whatever reason so we need to figure this out
773
-			else if(!empty($this->parent_type) && !empty($this->parent_id)) {
774
-				global $current_user;
737
+            $notify_user = new Lead();
738
+            $notify_user->retrieve($lead_id);
739
+            $notify_user->new_assigned_user_name = $notify_user->full_name;
740
+            $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
741
+            $list[$notify_user->id] = $notify_user;
742
+        }
743
+
744
+        global $sugar_config;
745
+        if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) {
746
+            global $current_user;
747
+            if(isset($list[$current_user->id]))
748
+                unset($list[$current_user->id]);
749
+        }
750
+        return $list;
751
+    }
752
+
753
+
754
+    function bean_implements($interface) {
755
+        switch($interface) {
756
+            case 'ACL':return true;
757
+        }
758
+        return false;
759
+    }
760
+
761
+    function listviewACLHelper() {
762
+        $array_assign = parent::listviewACLHelper();
763
+        $is_owner = false;
764
+        $in_group = false; //SECURITY GROUPS
765
+        if(!empty($this->parent_name)) {
766
+
767
+            if(!empty($this->parent_name_owner)) {
768
+                global $current_user;
769
+                $is_owner = $current_user->id == $this->parent_name_owner;
770
+            }
771
+            /* BEGIN - SECURITY GROUPS */
772
+            //parent_name_owner not being set for whatever reason so we need to figure this out
773
+            else if(!empty($this->parent_type) && !empty($this->parent_id)) {
774
+                global $current_user;
775 775
                 $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id);
776 776
                 if($parent_bean !== false) {
777
-                	$is_owner = $current_user->id == $parent_bean->assigned_user_id;
777
+                    $is_owner = $current_user->id == $parent_bean->assigned_user_id;
778 778
                 }
779
-			}
780
-			require_once("modules/SecurityGroups/SecurityGroup.php");
781
-			$in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view');
782
-        	/* END - SECURITY GROUPS */
783
-		}
784
-
785
-		/* BEGIN - SECURITY GROUPS */
786
-		/**
779
+            }
780
+            require_once("modules/SecurityGroups/SecurityGroup.php");
781
+            $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view');
782
+            /* END - SECURITY GROUPS */
783
+        }
784
+
785
+        /* BEGIN - SECURITY GROUPS */
786
+        /**
787 787
 		if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)) {
788
-		*/
789
-		if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){
788
+         */
789
+        if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){
790 790
         /* END - SECURITY GROUPS */
791
-			$array_assign['PARENT'] = 'a';
792
-		} else {
793
-			$array_assign['PARENT'] = 'span';
794
-		}
795
-
796
-		$is_owner = false;
797
-		$in_group = false; //SECURITY GROUPS
798
-
799
-		if(!empty($this->contact_name)) {
800
-			if(!empty($this->contact_name_owner)) {
801
-				global $current_user;
802
-				$is_owner = $current_user->id == $this->contact_name_owner;
803
-			}
804
-			/* BEGIN - SECURITY GROUPS */
805
-			//contact_name_owner not being set for whatever reason so we need to figure this out
806
-			else {
807
-				global $current_user;
791
+            $array_assign['PARENT'] = 'a';
792
+        } else {
793
+            $array_assign['PARENT'] = 'span';
794
+        }
795
+
796
+        $is_owner = false;
797
+        $in_group = false; //SECURITY GROUPS
798
+
799
+        if(!empty($this->contact_name)) {
800
+            if(!empty($this->contact_name_owner)) {
801
+                global $current_user;
802
+                $is_owner = $current_user->id == $this->contact_name_owner;
803
+            }
804
+            /* BEGIN - SECURITY GROUPS */
805
+            //contact_name_owner not being set for whatever reason so we need to figure this out
806
+            else {
807
+                global $current_user;
808 808
                 $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id);
809 809
                 if($parent_bean !== false) {
810
-                	$is_owner = $current_user->id == $parent_bean->assigned_user_id;
810
+                    $is_owner = $current_user->id == $parent_bean->assigned_user_id;
811 811
                 }
812
-			}
813
-			require_once("modules/SecurityGroups/SecurityGroup.php");
814
-			$in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view');
815
-        	/* END - SECURITY GROUPS */
816
-		}
817
-
818
-		/* BEGIN - SECURITY GROUPS */
819
-		/**
812
+            }
813
+            require_once("modules/SecurityGroups/SecurityGroup.php");
814
+            $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view');
815
+            /* END - SECURITY GROUPS */
816
+        }
817
+
818
+        /* BEGIN - SECURITY GROUPS */
819
+        /**
820 820
 		if(ACLController::checkAccess('Contacts', 'view', $is_owner)) {
821
-		*/
822
-		if(ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) {
821
+         */
822
+        if(ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)) {
823 823
         /* END - SECURITY GROUPS */
824
-			$array_assign['CONTACT'] = 'a';
825
-		} else {
826
-			$array_assign['CONTACT'] = 'span';
827
-		}
828
-		return $array_assign;
829
-	}
830
-
831
-
832
-	function save_relationship_changes($is_update, $exclude = array()) {
833
-	    if(empty($this->in_workflow)) {
834
-           if(empty($this->in_import)){//if a meeting is being imported then contact_id  should not be excluded
835
-           //if the global soap_server_object variable is not empty (as in from a soap/OPI call), then process the assigned_user_id relationship, otherwise
836
-           //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
837
-           	if(!empty($GLOBALS['soap_server_object'])){
838
-           		$exclude = array('contact_id', 'user_id');
839
-           	}else{
840
-	    		$exclude = array('contact_id', 'user_id','assigned_user_id');
841
-           	}
842
-           }
843
-           else{
844
-           	$exclude = array('user_id');
845
-           }
846
-        }
847
-       parent::save_relationship_changes($is_update, $exclude);
848
-	}
849
-
850
-
851
-	/**
852
-	 * @see SugarBean::afterImportSave()
853
-	 */
854
-	public function afterImportSave()
855
-	{
856
-	    if ( $this->parent_type == 'Contacts' ) {
857
-	        $this->load_relationship('contacts');
858
-	        if ( !$this->contacts->relationship_exists('contacts',array('id'=>$this->parent_id)) )
859
-	            $this->contacts->add($this->parent_id);
860
-	    }
861
-	    elseif ( $this->parent_type == 'Leads' ) {
862
-	        $this->load_relationship('leads');
863
-	        if ( !$this->leads->relationship_exists('leads',array('id'=>$this->parent_id)) )
864
-	            $this->leads->add($this->parent_id);
865
-	    }
866
-
867
-	    parent::afterImportSave();
868
-	}
824
+            $array_assign['CONTACT'] = 'a';
825
+        } else {
826
+            $array_assign['CONTACT'] = 'span';
827
+        }
828
+        return $array_assign;
829
+    }
830
+
831
+
832
+    function save_relationship_changes($is_update, $exclude = array()) {
833
+        if(empty($this->in_workflow)) {
834
+            if(empty($this->in_import)){//if a meeting is being imported then contact_id  should not be excluded
835
+            //if the global soap_server_object variable is not empty (as in from a soap/OPI call), then process the assigned_user_id relationship, otherwise
836
+            //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
837
+                if(!empty($GLOBALS['soap_server_object'])){
838
+                    $exclude = array('contact_id', 'user_id');
839
+                }else{
840
+                $exclude = array('contact_id', 'user_id','assigned_user_id');
841
+                }
842
+            }
843
+            else{
844
+                $exclude = array('user_id');
845
+            }
846
+        }
847
+        parent::save_relationship_changes($is_update, $exclude);
848
+    }
849
+
850
+
851
+    /**
852
+     * @see SugarBean::afterImportSave()
853
+     */
854
+    public function afterImportSave()
855
+    {
856
+        if ( $this->parent_type == 'Contacts' ) {
857
+            $this->load_relationship('contacts');
858
+            if ( !$this->contacts->relationship_exists('contacts',array('id'=>$this->parent_id)) )
859
+                $this->contacts->add($this->parent_id);
860
+        }
861
+        elseif ( $this->parent_type == 'Leads' ) {
862
+            $this->load_relationship('leads');
863
+            if ( !$this->leads->relationship_exists('leads',array('id'=>$this->parent_id)) )
864
+                $this->leads->add($this->parent_id);
865
+        }
866
+
867
+        parent::afterImportSave();
868
+    }
869 869
 
870 870
     public function getDefaultStatus()
871 871
     {
872
-         $def = $this->field_defs['status'];
873
-         if (isset($def['default'])) {
874
-             return $def['default'];
875
-         } else {
872
+            $def = $this->field_defs['status'];
873
+            if (isset($def['default'])) {
874
+                return $def['default'];
875
+            } else {
876 876
             $app = return_app_list_strings_language($GLOBALS['current_language']);
877 877
             if (isset($def['options']) && isset($app[$def['options']])) {
878 878
                 $keys = array_keys($app[$def['options']]);
@@ -888,9 +888,9 @@  discard block
 block discarded – undo
888 888
 //TODO: do we really need focus, name and view params for this function
889 889
 function getMeetingsExternalApiDropDown($focus = null, $name = null, $value = null, $view = null)
890 890
 {
891
-	global $dictionary, $app_list_strings;
891
+    global $dictionary, $app_list_strings;
892 892
 
893
-	$cacheKeyName = 'meetings_type_drop_down';
893
+    $cacheKeyName = 'meetings_type_drop_down';
894 894
 
895 895
     $apiList = sugar_cache_retrieve($cacheKeyName);
896 896
     if ($apiList === null)
@@ -902,17 +902,17 @@  discard block
 block discarded – undo
902 902
         sugar_cache_put($cacheKeyName, $apiList);
903 903
     }
904 904
 
905
-	if(!empty($value) && empty($apiList[$value]))
906
-	{
907
-		$apiList[$value] = $value;
905
+    if(!empty($value) && empty($apiList[$value]))
906
+    {
907
+        $apiList[$value] = $value;
908 908
     }
909
-	//bug 46294: adding list of options to dropdown list (if it is not the default list)
909
+    //bug 46294: adding list of options to dropdown list (if it is not the default list)
910 910
     if ($dictionary['Meeting']['fields']['type']['options'] != "eapm_list")
911 911
     {
912 912
         $apiList = array_merge(getMeetingTypeOptions($dictionary, $app_list_strings), $apiList);
913 913
     }
914 914
 
915
-	return $apiList;
915
+    return $apiList;
916 916
 }
917 917
 
918 918
 /**
@@ -923,20 +923,20 @@  discard block
 block discarded – undo
923 923
  */
924 924
 function getMeetingTypeOptions($dictionary, $app_list_strings)
925 925
 {
926
-	$result = array();
926
+    $result = array();
927 927
 
928 928
     // getting name of meeting type to fill dropdown list by its values
929 929
     if (isset($dictionary['Meeting']['fields']['type']['options']))
930
-	{
931
-    	$typeName = $dictionary['Meeting']['fields']['type']['options'];
930
+    {
931
+        $typeName = $dictionary['Meeting']['fields']['type']['options'];
932 932
 
933 933
         if (!empty($app_list_strings[$typeName]))
934
-		{
935
-        	$typeList = $app_list_strings[$typeName];
934
+        {
935
+            $typeList = $app_list_strings[$typeName];
936 936
 
937 937
             foreach ($typeList as $key => $value)
938
-			{
939
-				$result[$value] = $value;
938
+            {
939
+                $result[$value] = $value;
940 940
             }
941 941
         }
942 942
     }
Please login to merge, or discard this patch.
modules/Calls/Call.php 1 patch
Indentation   +526 added lines, -526 removed lines patch added patch discarded remove patch
@@ -47,176 +47,176 @@  discard block
 block discarded – undo
47 47
  ********************************************************************************/
48 48
 
49 49
 class Call extends SugarBean {
50
-	var $field_name_map;
51
-	// Stored fields
52
-	var $id;
53
-	var $json_id;
54
-	var $date_entered;
55
-	var $date_modified;
56
-	var $assigned_user_id;
57
-	var $modified_user_id;
58
-	var $description;
59
-	var $name;
60
-	var $status;
61
-	var $date_start;
62
-	var $time_start;
63
-	var $duration_hours;
64
-	var $duration_minutes;
65
-	var $date_end;
66
-	var $parent_type;
67
-	var $parent_type_options;
68
-	var $parent_id;
69
-	var $contact_id;
70
-	var $user_id;
71
-	var $lead_id;
72
-	var $direction;
73
-	var $reminder_time;
74
-	var $reminder_time_options;
75
-	var $reminder_checked;
76
-	var $email_reminder_time;
77
-	var $email_reminder_checked;
78
-	var $email_reminder_sent;
79
-	var $required;
80
-	var $accept_status;
81
-	var $created_by;
82
-	var $created_by_name;
83
-	var $modified_by_name;
84
-	var $parent_name;
85
-	var $contact_name;
86
-	var $contact_phone;
87
-	var $contact_email;
88
-	var $account_id;
89
-	var $opportunity_id;
90
-	var $case_id;
91
-	var $assigned_user_name;
92
-	var $note_id;
50
+    var $field_name_map;
51
+    // Stored fields
52
+    var $id;
53
+    var $json_id;
54
+    var $date_entered;
55
+    var $date_modified;
56
+    var $assigned_user_id;
57
+    var $modified_user_id;
58
+    var $description;
59
+    var $name;
60
+    var $status;
61
+    var $date_start;
62
+    var $time_start;
63
+    var $duration_hours;
64
+    var $duration_minutes;
65
+    var $date_end;
66
+    var $parent_type;
67
+    var $parent_type_options;
68
+    var $parent_id;
69
+    var $contact_id;
70
+    var $user_id;
71
+    var $lead_id;
72
+    var $direction;
73
+    var $reminder_time;
74
+    var $reminder_time_options;
75
+    var $reminder_checked;
76
+    var $email_reminder_time;
77
+    var $email_reminder_checked;
78
+    var $email_reminder_sent;
79
+    var $required;
80
+    var $accept_status;
81
+    var $created_by;
82
+    var $created_by_name;
83
+    var $modified_by_name;
84
+    var $parent_name;
85
+    var $contact_name;
86
+    var $contact_phone;
87
+    var $contact_email;
88
+    var $account_id;
89
+    var $opportunity_id;
90
+    var $case_id;
91
+    var $assigned_user_name;
92
+    var $note_id;
93 93
     var $outlook_id;
94
-	var $update_vcal = true;
95
-	var $contacts_arr;
96
-	var $users_arr;
97
-	var $leads_arr;
98
-	var $default_call_name_values = array('Assemble catalogs', 'Make travel arrangements', 'Send a letter', 'Send contract', 'Send fax', 'Send a follow-up letter', 'Send literature', 'Send proposal', 'Send quote');
99
-	var $minutes_value_default = 15;
100
-	var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
101
-	var $table_name = "calls";
102
-	var $rel_users_table = "calls_users";
103
-	var $rel_contacts_table = "calls_contacts";
94
+    var $update_vcal = true;
95
+    var $contacts_arr;
96
+    var $users_arr;
97
+    var $leads_arr;
98
+    var $default_call_name_values = array('Assemble catalogs', 'Make travel arrangements', 'Send a letter', 'Send contract', 'Send fax', 'Send a follow-up letter', 'Send literature', 'Send proposal', 'Send quote');
99
+    var $minutes_value_default = 15;
100
+    var $minutes_values = array('0'=>'00','15'=>'15','30'=>'30','45'=>'45');
101
+    var $table_name = "calls";
102
+    var $rel_users_table = "calls_users";
103
+    var $rel_contacts_table = "calls_contacts";
104 104
     var $rel_leads_table = "calls_leads";
105
-	var $module_dir = 'Calls';
106
-	var $object_name = "Call";
107
-	var $new_schema = true;
108
-	var $importable = true;
109
-	var $syncing = false;
110
-	var $recurring_source;
111
-
112
-	// This is used to retrieve related fields from form posts.
113
-	var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name');
114
-	var $relationship_fields = array(	'account_id'		=> 'accounts',
115
-										'opportunity_id'	=> 'opportunities',
116
-										'contact_id'		=> 'contacts',
117
-										'case_id'			=> 'cases',
118
-										'user_id'			=> 'users',
119
-										'assigned_user_id'	=> 'users',
120
-										'note_id'			=> 'notes',
105
+    var $module_dir = 'Calls';
106
+    var $object_name = "Call";
107
+    var $new_schema = true;
108
+    var $importable = true;
109
+    var $syncing = false;
110
+    var $recurring_source;
111
+
112
+    // This is used to retrieve related fields from form posts.
113
+    var $additional_column_fields = array('assigned_user_name', 'assigned_user_id', 'contact_id', 'user_id', 'contact_name');
114
+    var $relationship_fields = array(	'account_id'		=> 'accounts',
115
+                                        'opportunity_id'	=> 'opportunities',
116
+                                        'contact_id'		=> 'contacts',
117
+                                        'case_id'			=> 'cases',
118
+                                        'user_id'			=> 'users',
119
+                                        'assigned_user_id'	=> 'users',
120
+                                        'note_id'			=> 'notes',
121 121
                                         'lead_id'			=> 'leads',
122
-								);
123
-
124
-	public function __construct() {
125
-		parent::__construct();
126
-		global $app_list_strings;
127
-
128
-       	$this->setupCustomFields('Calls');
129
-
130
-		foreach ($this->field_defs as $field) {
131
-			$this->field_name_map[$field['name']] = $field;
132
-		}
133
-
134
-
135
-
136
-
137
-         if(!empty($GLOBALS['app_list_strings']['duration_intervals']))
138
-        	$this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals'];
139
-	}
140
-
141
-	/**
142
-	 * @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
143
-	 */
144
-	public function Call(){
145
-		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
146
-		if(isset($GLOBALS['log'])) {
147
-			$GLOBALS['log']->deprecated($deprecatedMessage);
148
-		}
149
-		else {
150
-			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
151
-		}
152
-		self::__construct();
153
-	}
154
-
155
-	/**
156
-	 * Disable edit if call is recurring and source is not Sugar. It should be edited only from Outlook.
157
-	 * @param $view string
158
-	 * @param $is_owner bool
159
-	 */
160
-	function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){
161
-		// don't check if call is being synced from Outlook
162
-		if($this->syncing == false){
163
-			$view = strtolower($view);
164
-			switch($view){
165
-				case 'edit':
166
-				case 'save':
167
-				case 'editview':
168
-				case 'delete':
169
-					if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){
170
-						return false;
171
-					}
172
-			}
173
-		}
174
-		return parent::ACLAccess($view,$is_owner,$in_group);
175
-	}
122
+                                );
123
+
124
+    public function __construct() {
125
+        parent::__construct();
126
+        global $app_list_strings;
127
+
128
+            $this->setupCustomFields('Calls');
129
+
130
+        foreach ($this->field_defs as $field) {
131
+            $this->field_name_map[$field['name']] = $field;
132
+        }
133
+
134
+
135
+
136
+
137
+            if(!empty($GLOBALS['app_list_strings']['duration_intervals']))
138
+            $this->minutes_values = $GLOBALS['app_list_strings']['duration_intervals'];
139
+    }
140
+
141
+    /**
142
+     * @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
143
+     */
144
+    public function Call(){
145
+        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
146
+        if(isset($GLOBALS['log'])) {
147
+            $GLOBALS['log']->deprecated($deprecatedMessage);
148
+        }
149
+        else {
150
+            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
151
+        }
152
+        self::__construct();
153
+    }
154
+
155
+    /**
156
+     * Disable edit if call is recurring and source is not Sugar. It should be edited only from Outlook.
157
+     * @param $view string
158
+     * @param $is_owner bool
159
+     */
160
+    function ACLAccess($view,$is_owner='not_set',$in_group='not_set'){
161
+        // don't check if call is being synced from Outlook
162
+        if($this->syncing == false){
163
+            $view = strtolower($view);
164
+            switch($view){
165
+                case 'edit':
166
+                case 'save':
167
+                case 'editview':
168
+                case 'delete':
169
+                    if(!empty($this->recurring_source) && $this->recurring_source != "Sugar"){
170
+                        return false;
171
+                    }
172
+            }
173
+        }
174
+        return parent::ACLAccess($view,$is_owner,$in_group);
175
+    }
176 176
     // save date_end by calculating user input
177 177
     // this is for calendar
178
-	function save($check_notify = FALSE) {
179
-		global $timedate,$current_user;
178
+    function save($check_notify = FALSE) {
179
+        global $timedate,$current_user;
180 180
 
181
-	    if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes))
181
+        if(isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes))
182 182
         {
183
-    	    $td = $timedate->fromDb($this->date_start);
184
-    	    if($td)
185
-    	    {
186
-	        	$this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb();
187
-    	    }
183
+            $td = $timedate->fromDb($this->date_start);
184
+            if($td)
185
+            {
186
+                $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb();
187
+            }
188 188
         }
189 189
 
190
-		if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') {
191
-			$check_notify = true;
190
+        if(!empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1') {
191
+            $check_notify = true;
192 192
         } else {
193
-			$check_notify = false;
194
-		}
195
-		if(empty($_REQUEST['send_invites'])) {
196
-			if(!empty($this->id)) {
197
-				$old_record = new Call();
198
-				$old_record->retrieve($this->id);
199
-				$old_assigned_user_id = $old_record->assigned_user_id;
200
-			}
201
-			if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){
202
-				$this->special_notification = true;
203
-				if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) {
204
-					$check_notify = true;
205
-				}
193
+            $check_notify = false;
194
+        }
195
+        if(empty($_REQUEST['send_invites'])) {
196
+            if(!empty($this->id)) {
197
+                $old_record = new Call();
198
+                $old_record->retrieve($this->id);
199
+                $old_assigned_user_id = $old_record->assigned_user_id;
200
+            }
201
+            if((empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id']) || (isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) ){
202
+                $this->special_notification = true;
203
+                if(!isset($GLOBALS['resavingRelatedBeans']) || $GLOBALS['resavingRelatedBeans'] == false) {
204
+                    $check_notify = true;
205
+                }
206 206
                 if(isset($_REQUEST['assigned_user_name'])) {
207 207
                     $this->new_assigned_user_name = $_REQUEST['assigned_user_name'];
208 208
                 }
209
-			}
210
-		}
209
+            }
210
+        }
211 211
         if (empty($this->status) ) {
212 212
             $this->status = $this->getDefaultStatus();
213 213
         }
214 214
 
215
-		// prevent a mass mailing for recurring meetings created in Calendar module
216
-		if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) {
217
-			$check_notify = false;
218
-		}
219
-		/*nsingh 7/3/08  commenting out as bug #20814 is invalid
215
+        // prevent a mass mailing for recurring meetings created in Calendar module
216
+        if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) {
217
+            $check_notify = false;
218
+        }
219
+        /*nsingh 7/3/08  commenting out as bug #20814 is invalid
220 220
 		if($current_user->getPreference('reminder_time')!= -1 &&  isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0  && $_POST['reminder_time']==-1){
221 221
 			$this->reminder_checked = '1';
222 222
 			$this->reminder_time = $current_user->getPreference('reminder_time');
@@ -227,87 +227,87 @@  discard block
 block discarded – undo
227 227
 
228 228
 
229 229
         if($this->update_vcal) {
230
-			vCal::cache_sugar_vcal($current_user);
230
+            vCal::cache_sugar_vcal($current_user);
231 231
         }
232 232
 
233
-		if(isset($_REQUEST['reminders_data'])) {
234
-			Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data']));
235
-		}
233
+        if(isset($_REQUEST['reminders_data'])) {
234
+            Reminder::saveRemindersDataJson('Calls', $return_id, html_entity_decode($_REQUEST['reminders_data']));
235
+        }
236 236
 
237 237
         return $return_id;
238
-	}
238
+    }
239 239
 
240
-	/** Returns a list of the associated contacts
241
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
242
-	 * All Rights Reserved..
243
-	 * Contributor(s): ______________________________________..
244
-	*/
245
-	function get_contacts()
246
-	{
247
-		// First, get the list of IDs.
248
-		$query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0";
240
+    /** Returns a list of the associated contacts
241
+     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
242
+     * All Rights Reserved..
243
+     * Contributor(s): ______________________________________..
244
+     */
245
+    function get_contacts()
246
+    {
247
+        // First, get the list of IDs.
248
+        $query = "SELECT contact_id as id from calls_contacts where call_id='$this->id' AND deleted=0";
249 249
 
250
-		return $this->build_related_list($query, new Contact());
251
-	}
250
+        return $this->build_related_list($query, new Contact());
251
+    }
252 252
 
253 253
 
254
-	function get_summary_text()
255
-	{
256
-		return "$this->name";
257
-	}
254
+    function get_summary_text()
255
+    {
256
+        return "$this->name";
257
+    }
258 258
 
259
-	function create_list_query($order_by, $where, $show_deleted=0)
260
-	{
259
+    function create_list_query($order_by, $where, $show_deleted=0)
260
+    {
261 261
         $custom_join = $this->getCustomJoin();
262 262
                 $query = "SELECT ";
263
-		$query .= "
263
+        $query .= "
264 264
 			calls.*,";
265
-			if ( preg_match("/calls_users\.user_id/",$where))
266
-			{
267
-				$query .= "calls_users.required,
265
+            if ( preg_match("/calls_users\.user_id/",$where))
266
+            {
267
+                $query .= "calls_users.required,
268 268
 				calls_users.accept_status,";
269
-			}
269
+            }
270 270
 
271
-			$query .= "
271
+            $query .= "
272 272
 			users.user_name as assigned_user_name";
273 273
         $query .= $custom_join['select'];
274 274
 
275
-			// this line will help generate a GMT-metric to compare to a locale's timezone
275
+            // this line will help generate a GMT-metric to compare to a locale's timezone
276 276
 
277
-			if ( preg_match("/contacts/",$where)){
278
-				$query .= ", contacts.first_name, contacts.last_name";
279
-				$query .= ", contacts.assigned_user_id contact_name_owner";
280
-			}
281
-			$query .= " FROM calls ";
277
+            if ( preg_match("/contacts/",$where)){
278
+                $query .= ", contacts.first_name, contacts.last_name";
279
+                $query .= ", contacts.assigned_user_id contact_name_owner";
280
+            }
281
+            $query .= " FROM calls ";
282 282
 
283
-			if ( preg_match("/contacts/",$where)){
284
-				$query .=	"LEFT JOIN calls_contacts
283
+            if ( preg_match("/contacts/",$where)){
284
+                $query .=	"LEFT JOIN calls_contacts
285 285
 	                    ON calls.id=calls_contacts.call_id
286 286
 	                    LEFT JOIN contacts
287 287
 	                    ON calls_contacts.contact_id=contacts.id ";
288
-			}
289
-			if ( preg_match('/calls_users\.user_id/',$where))
290
-			{
291
-		$query .= "LEFT JOIN calls_users
288
+            }
289
+            if ( preg_match('/calls_users\.user_id/',$where))
290
+            {
291
+        $query .= "LEFT JOIN calls_users
292 292
 			ON calls.id=calls_users.call_id and calls_users.deleted=0 ";
293
-			}
294
-			$query .= "
293
+            }
294
+            $query .= "
295 295
 			LEFT JOIN users
296 296
 			ON calls.assigned_user_id=users.id ";
297 297
         $query .= $custom_join['join'];
298
-			$where_auto = '1=1';
299
-       		 if($show_deleted == 0){
300
-            	$where_auto = " $this->table_name.deleted=0  ";
301
-			}else if($show_deleted == 1){
302
-				$where_auto = " $this->table_name.deleted=1 ";
303
-			}
298
+            $where_auto = '1=1';
299
+                if($show_deleted == 0){
300
+                $where_auto = " $this->table_name.deleted=0  ";
301
+            }else if($show_deleted == 1){
302
+                $where_auto = " $this->table_name.deleted=1 ";
303
+            }
304 304
 
305
-			//$where_auto .= " GROUP BY calls.id";
305
+            //$where_auto .= " GROUP BY calls.id";
306 306
 
307
-		if($where != "")
308
-			$query .= "where $where AND ".$where_auto;
309
-		else
310
-			$query .= "where ".$where_auto;
307
+        if($where != "")
308
+            $query .= "where $where AND ".$where_auto;
309
+        else
310
+            $query .= "where ".$where_auto;
311 311
 
312 312
         $order_by = $this->process_order_by($order_by);
313 313
         if (empty($order_by)) {
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
         }
316 316
         $query .= ' ORDER BY ' . $order_by;
317 317
 
318
-		return $query;
319
-	}
318
+        return $query;
319
+    }
320 320
 
321 321
         function create_export_query($order_by, $where, $relate_link_join='')
322 322
         {
323 323
             $custom_join = $this->getCustomJoin(true, true, $where);
324 324
             $custom_join['join'] .= $relate_link_join;
325
-			$contact_required = stristr($where, "contacts");
325
+            $contact_required = stristr($where, "contacts");
326 326
             if($contact_required)
327 327
             {
328 328
                     $query = "SELECT calls.*, contacts.first_name, contacts.last_name, users.user_name as assigned_user_name ";
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
             }
340 340
 
341 341
 
342
-			$query .= "  LEFT JOIN users ON calls.assigned_user_id=users.id ";
342
+            $query .= "  LEFT JOIN users ON calls.assigned_user_id=users.id ";
343 343
 
344 344
             $query .= $custom_join['join'];
345 345
 
346
-			if($where != "")
346
+            if($where != "")
347 347
                     $query .= "where $where AND ".$where_auto;
348 348
             else
349 349
                     $query .= "where ".$where_auto;
@@ -361,199 +361,199 @@  discard block
 block discarded – undo
361 361
 
362 362
 
363 363
 
364
-	function fill_in_additional_detail_fields()
365
-	{
366
-		global $locale;
367
-		parent::fill_in_additional_detail_fields();
368
-		if (!empty($this->contact_id)) {
369
-			$query  = "SELECT first_name, last_name FROM contacts ";
370
-			$query .= "WHERE id='$this->contact_id' AND deleted=0";
371
-			$result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
372
-
373
-			// Get the contact name.
374
-			$row = $this->db->fetchByAssoc($result);
375
-			$GLOBALS['log']->info("additional call fields $query");
376
-			if($row != null)
377
-			{
378
-				$this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
379
-				$GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
380
-				$GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
381
-			}
382
-		}
383
-		if (!isset($this->duration_minutes)) {
384
-			$this->duration_minutes = $this->minutes_value_default;
385
-		}
364
+    function fill_in_additional_detail_fields()
365
+    {
366
+        global $locale;
367
+        parent::fill_in_additional_detail_fields();
368
+        if (!empty($this->contact_id)) {
369
+            $query  = "SELECT first_name, last_name FROM contacts ";
370
+            $query .= "WHERE id='$this->contact_id' AND deleted=0";
371
+            $result = $this->db->limitQuery($query,0,1,true," Error filling in additional detail fields: ");
372
+
373
+            // Get the contact name.
374
+            $row = $this->db->fetchByAssoc($result);
375
+            $GLOBALS['log']->info("additional call fields $query");
376
+            if($row != null)
377
+            {
378
+                $this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
379
+                $GLOBALS['log']->debug("Call($this->id): contact_name = $this->contact_name");
380
+                $GLOBALS['log']->debug("Call($this->id): contact_id = $this->contact_id");
381
+            }
382
+        }
383
+        if (!isset($this->duration_minutes)) {
384
+            $this->duration_minutes = $this->minutes_value_default;
385
+        }
386 386
 
387 387
         global $timedate;
388 388
         //setting default date and time
389
-		if (is_null($this->date_start)) {
390
-			$this->date_start = $timedate->now();
391
-		}
392
-
393
-		if (is_null($this->duration_hours))
394
-			$this->duration_hours = "0";
395
-		if (is_null($this->duration_minutes))
396
-			$this->duration_minutes = "1";
397
-
398
-		$this->fill_in_additional_parent_fields();
399
-
400
-		global $app_list_strings;
401
-		$parent_types = $app_list_strings['record_type_display'];
402
-		$disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
403
-		foreach($disabled_parent_types as $disabled_parent_type){
404
-			if($disabled_parent_type != $this->parent_type){
405
-				unset($parent_types[$disabled_parent_type]);
406
-			}
407
-		}
408
-
409
-		$this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
410
-
411
-		if (empty($this->reminder_time)) {
412
-			$this->reminder_time = -1;
413
-		}
414
-
415
-		if ( empty($this->id) ) {
416
-		    $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
417
-		    if ( isset($reminder_t) )
418
-		        $this->reminder_time = $reminder_t;
419
-		}
420
-		$this->reminder_checked = $this->reminder_time == -1 ? false : true;
421
-
422
-		if (empty($this->email_reminder_time)) {
423
-			$this->email_reminder_time = -1;
424
-		}
425
-		if(empty($this->id)){
426
-			$reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time');
427
-			if(isset($reminder_t))
428
-		    		$this->email_reminder_time = $reminder_t;
429
-		}
430
-		$this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true;
431
-
432
-		if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) {
433
-			$this->parent_type = $_REQUEST['parent_type'];
434
-		} elseif (is_null($this->parent_type)) {
435
-			$this->parent_type = $app_list_strings['record_type_default_key'];
436
-		}
437
-	}
438
-
439
-
440
-	function get_list_view_data(){
441
-		$call_fields = $this->get_list_view_array();
442
-		global $app_list_strings, $focus, $action, $currentModule;
443
-		if (isset($focus->id)) $id = $focus->id;
444
-		else $id = '';
445
-		if (isset($this->parent_type) && $this->parent_type != null)
446
-		{
447
-			$call_fields['PARENT_MODULE'] = $this->parent_type;
448
-		}
449
-		if ($this->status == "Planned") {
450
-			//cn: added this if() to deal with sequential Closes in Meetings.  this is a hack to a hack (formbase.php->handleRedirect)
451
-			if(empty($action))
452
-			    $action = "index";
389
+        if (is_null($this->date_start)) {
390
+            $this->date_start = $timedate->now();
391
+        }
392
+
393
+        if (is_null($this->duration_hours))
394
+            $this->duration_hours = "0";
395
+        if (is_null($this->duration_minutes))
396
+            $this->duration_minutes = "1";
397
+
398
+        $this->fill_in_additional_parent_fields();
399
+
400
+        global $app_list_strings;
401
+        $parent_types = $app_list_strings['record_type_display'];
402
+        $disabled_parent_types = ACLController::disabledModuleList($parent_types,false, 'list');
403
+        foreach($disabled_parent_types as $disabled_parent_type){
404
+            if($disabled_parent_type != $this->parent_type){
405
+                unset($parent_types[$disabled_parent_type]);
406
+            }
407
+        }
408
+
409
+        $this->parent_type_options = get_select_options_with_id($parent_types, $this->parent_type);
410
+
411
+        if (empty($this->reminder_time)) {
412
+            $this->reminder_time = -1;
413
+        }
414
+
415
+        if ( empty($this->id) ) {
416
+            $reminder_t = $GLOBALS['current_user']->getPreference('reminder_time');
417
+            if ( isset($reminder_t) )
418
+                $this->reminder_time = $reminder_t;
419
+        }
420
+        $this->reminder_checked = $this->reminder_time == -1 ? false : true;
421
+
422
+        if (empty($this->email_reminder_time)) {
423
+            $this->email_reminder_time = -1;
424
+        }
425
+        if(empty($this->id)){
426
+            $reminder_t = $GLOBALS['current_user']->getPreference('email_reminder_time');
427
+            if(isset($reminder_t))
428
+                    $this->email_reminder_time = $reminder_t;
429
+        }
430
+        $this->email_reminder_checked = $this->email_reminder_time == -1 ? false : true;
431
+
432
+        if (isset ($_REQUEST['parent_type']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'SubpanelEdits')) {
433
+            $this->parent_type = $_REQUEST['parent_type'];
434
+        } elseif (is_null($this->parent_type)) {
435
+            $this->parent_type = $app_list_strings['record_type_default_key'];
436
+        }
437
+    }
438
+
439
+
440
+    function get_list_view_data(){
441
+        $call_fields = $this->get_list_view_array();
442
+        global $app_list_strings, $focus, $action, $currentModule;
443
+        if (isset($focus->id)) $id = $focus->id;
444
+        else $id = '';
445
+        if (isset($this->parent_type) && $this->parent_type != null)
446
+        {
447
+            $call_fields['PARENT_MODULE'] = $this->parent_type;
448
+        }
449
+        if ($this->status == "Planned") {
450
+            //cn: added this if() to deal with sequential Closes in Meetings.  this is a hack to a hack (formbase.php->handleRedirect)
451
+            if(empty($action))
452
+                $action = "index";
453 453
 
454 454
             $setCompleteUrl = "<a id='{$this->id}' onclick='SUGAR.util.closeActivityPanel.show(\"{$this->module_dir}\",\"{$this->id}\",\"Held\",\"listview\",\"1\");'>";
455
-			if ($this->ACLAccess('edit')) {
455
+            if ($this->ACLAccess('edit')) {
456 456
                 $call_fields['SET_COMPLETE'] = $setCompleteUrl . SugarThemeRegistry::current()->getImage("close_inline"," border='0'",null,null,'.gif',translate('LBL_CLOSEINLINE'))."</a>";
457 457
             } else {
458 458
                 $call_fields['SET_COMPLETE'] = '';
459 459
             }
460
-		}
461
-		global $timedate;
462
-		$today = $timedate->nowDb();
463
-		$nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day"));
464
-		$mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']);
465
-		$date_db = $timedate->to_db($mergeTime);
466
-		if( $date_db	< $today){
467
-			$call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>";
468
-		}else if($date_db < $nextday){
469
-			$call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>";
470
-		}else{
471
-			$call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>";
472
-		}
473
-		$this->fill_in_additional_detail_fields();
474
-
475
-		//make sure we grab the localized version of the contact name, if a contact is provided
476
-		if (!empty($this->contact_id)) {
477
-           // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs
460
+        }
461
+        global $timedate;
462
+        $today = $timedate->nowDb();
463
+        $nextday = $timedate->asDbDate($timedate->getNow()->modify("+1 day"));
464
+        $mergeTime = $call_fields['DATE_START']; //$timedate->merge_date_time($call_fields['DATE_START'], $call_fields['TIME_START']);
465
+        $date_db = $timedate->to_db($mergeTime);
466
+        if( $date_db	< $today){
467
+            $call_fields['DATE_START']= "<font class='overdueTask'>".$call_fields['DATE_START']."</font>";
468
+        }else if($date_db < $nextday){
469
+            $call_fields['DATE_START'] = "<font class='todaysTask'>".$call_fields['DATE_START']."</font>";
470
+        }else{
471
+            $call_fields['DATE_START'] = "<font class='futureTask'>".$call_fields['DATE_START']."</font>";
472
+        }
473
+        $this->fill_in_additional_detail_fields();
474
+
475
+        //make sure we grab the localized version of the contact name, if a contact is provided
476
+        if (!empty($this->contact_id)) {
477
+            // Bug# 46125 - make first name, last name, salutation and title of Contacts respect field level ACLs
478 478
             $contact_temp = BeanFactory::getBean("Contacts", $this->contact_id);
479 479
             if(!empty($contact_temp)) {
480 480
                 $contact_temp->_create_proper_name_field();
481 481
                 $this->contact_name = $contact_temp->full_name;
482 482
             }
483
-		}
483
+        }
484 484
 
485 485
         $call_fields['CONTACT_ID'] = $this->contact_id;
486 486
         $call_fields['CONTACT_NAME'] = $this->contact_name;
487
-		$call_fields['PARENT_NAME'] = $this->parent_name;
487
+        $call_fields['PARENT_NAME'] = $this->parent_name;
488 488
         $call_fields['REMINDER_CHECKED'] = $this->reminder_time==-1 ? false : true;
489
-	    $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true;
489
+        $call_fields['EMAIL_REMINDER_CHECKED'] = $this->email_reminder_time==-1 ? false : true;
490 490
 
491
-		return $call_fields;
492
-	}
491
+        return $call_fields;
492
+    }
493 493
 
494
-	function set_notification_body($xtpl, $call) {
495
-		global $sugar_config;
496
-		global $app_list_strings;
497
-		global $current_user;
498
-		global $app_list_strings;
499
-		global $timedate;
494
+    function set_notification_body($xtpl, $call) {
495
+        global $sugar_config;
496
+        global $app_list_strings;
497
+        global $current_user;
498
+        global $app_list_strings;
499
+        global $timedate;
500 500
 
501 501
         // rrs: bug 42684 - passing a contact breaks this call
502
-		$notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user;
503
-
504
-
505
-		// Assumes $call dates are in user format
506
-		$calldate = $timedate->fromDb($call->date_start);
507
-		$xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser);
508
-
509
-		if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) {
510
-			$xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
511
-				  '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id);
512
-		} elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) {
513
-			$xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
514
-				  '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id);
515
-		} else {
516
-			$xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
517
-				  '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id);
518
-		}
519
-
520
-		$xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name);
521
-		$xtpl->assign("CALL_SUBJECT", $call->name);
522
-		$xtpl->assign("CALL_STARTDATE", $xOffset);
523
-		$xtpl->assign("CALL_HOURS", $call->duration_hours);
524
-		$xtpl->assign("CALL_MINUTES", $call->duration_minutes);
525
-		$xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : ""));
526
-		$xtpl->assign("CALL_DESCRIPTION", $call->description);
527
-
528
-		return $xtpl;
529
-	}
530
-
531
-
532
-	function get_call_users() {
533
-		$template = new User();
534
-		// First, get the list of IDs.
535
-		$query = "SELECT calls_users.required, calls_users.accept_status, calls_users.user_id from calls_users where calls_users.call_id='$this->id' AND calls_users.deleted=0";
536
-		$GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
537
-		$result = $this->db->query($query, true);
538
-		$list = Array();
539
-
540
-		while($row = $this->db->fetchByAssoc($result)) {
541
-			$template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
542
-			$record = $template->retrieve($row['user_id']);
543
-			$template->required = $row['required'];
544
-			$template->accept_status = $row['accept_status'];
545
-
546
-			if($record != null) {
547
-			    // this copies the object into the array
548
-				$list[] = $template;
549
-			}
550
-		}
551
-		return $list;
552
-	}
553
-
554
-
555
-  function get_invite_calls(&$user)
556
-  {
502
+        $notifyUser =($call->current_notify_user->object_name == 'User') ? $call->current_notify_user : $current_user;
503
+
504
+
505
+        // Assumes $call dates are in user format
506
+        $calldate = $timedate->fromDb($call->date_start);
507
+        $xOffset = $timedate->asUser($calldate, $notifyUser).' '.$timedate->userTimezoneSuffix($calldate, $notifyUser);
508
+
509
+        if ( strtolower(get_class($call->current_notify_user)) == 'contact' ) {
510
+            $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
511
+                    '/index.php?entryPoint=acceptDecline&module=Calls&contact_id='.$call->current_notify_user->id.'&record='.$call->id);
512
+        } elseif ( strtolower(get_class($call->current_notify_user)) == 'lead' ) {
513
+            $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
514
+                    '/index.php?entryPoint=acceptDecline&module=Calls&lead_id='.$call->current_notify_user->id.'&record='.$call->id);
515
+        } else {
516
+            $xtpl->assign("ACCEPT_URL", $sugar_config['site_url'].
517
+                    '/index.php?entryPoint=acceptDecline&module=Calls&user_id='.$call->current_notify_user->id.'&record='.$call->id);
518
+        }
519
+
520
+        $xtpl->assign("CALL_TO", $call->current_notify_user->new_assigned_user_name);
521
+        $xtpl->assign("CALL_SUBJECT", $call->name);
522
+        $xtpl->assign("CALL_STARTDATE", $xOffset);
523
+        $xtpl->assign("CALL_HOURS", $call->duration_hours);
524
+        $xtpl->assign("CALL_MINUTES", $call->duration_minutes);
525
+        $xtpl->assign("CALL_STATUS", ((isset($call->status))?$app_list_strings['call_status_dom'][$call->status] : ""));
526
+        $xtpl->assign("CALL_DESCRIPTION", $call->description);
527
+
528
+        return $xtpl;
529
+    }
530
+
531
+
532
+    function get_call_users() {
533
+        $template = new User();
534
+        // First, get the list of IDs.
535
+        $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.user_id from calls_users where calls_users.call_id='$this->id' AND calls_users.deleted=0";
536
+        $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query);
537
+        $result = $this->db->query($query, true);
538
+        $list = Array();
539
+
540
+        while($row = $this->db->fetchByAssoc($result)) {
541
+            $template = new User(); // PHP 5 will retrieve by reference, always over-writing the "old" one
542
+            $record = $template->retrieve($row['user_id']);
543
+            $template->required = $row['required'];
544
+            $template->accept_status = $row['accept_status'];
545
+
546
+            if($record != null) {
547
+                // this copies the object into the array
548
+                $list[] = $template;
549
+            }
550
+        }
551
+        return $list;
552
+    }
553
+
554
+
555
+    function get_invite_calls(&$user)
556
+    {
557 557
     $template = $this;
558 558
     // First, get the list of IDs.
559 559
     $query = "SELECT calls_users.required, calls_users.accept_status, calls_users.call_id from calls_users where calls_users.user_id='$user->id' AND ( calls_users.accept_status IS NULL OR  calls_users.accept_status='none') AND calls_users.deleted=0";
@@ -568,182 +568,182 @@  discard block
 block discarded – undo
568 568
 
569 569
     while($row = $this->db->fetchByAssoc($result))
570 570
     {
571
-      $record = $template->retrieve($row['call_id']);
572
-      $template->required = $row['required'];
573
-      $template->accept_status = $row['accept_status'];
571
+        $record = $template->retrieve($row['call_id']);
572
+        $template->required = $row['required'];
573
+        $template->accept_status = $row['accept_status'];
574 574
 
575 575
 
576
-      if($record != null)
577
-      {
576
+        if($record != null)
577
+        {
578 578
         // this copies the object into the array
579 579
         $list[] = $template;
580
-      }
580
+        }
581 581
     }
582 582
     return $list;
583 583
 
584
-  }
584
+    }
585 585
 
586 586
 
587
-  function set_accept_status(&$user,$status)
588
-  {
587
+    function set_accept_status(&$user,$status)
588
+    {
589 589
     if ( $user->object_name == 'User')
590 590
     {
591
-      $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id);
592
-      $data_values = array('accept_status'=>$status);
593
-      $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
594
-      global $current_user;
591
+        $relate_values = array('user_id'=>$user->id,'call_id'=>$this->id);
592
+        $data_values = array('accept_status'=>$status);
593
+        $this->set_relationship($this->rel_users_table, $relate_values, true, true,$data_values);
594
+        global $current_user;
595 595
 
596
-      if ( $this->update_vcal )
597
-      {
596
+        if ( $this->update_vcal )
597
+        {
598 598
         vCal::cache_sugar_vcal($user);
599
-      }
599
+        }
600 600
     }
601 601
     else if ( $user->object_name == 'Contact')
602 602
     {
603
-      $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id);
604
-      $data_values = array('accept_status'=>$status);
605
-      $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
603
+        $relate_values = array('contact_id'=>$user->id,'call_id'=>$this->id);
604
+        $data_values = array('accept_status'=>$status);
605
+        $this->set_relationship($this->rel_contacts_table, $relate_values, true, true,$data_values);
606 606
     }
607 607
     else if ( $user->object_name == 'Lead')
608 608
     {
609
-      $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id);
610
-      $data_values = array('accept_status'=>$status);
611
-      $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
609
+        $relate_values = array('lead_id'=>$user->id,'call_id'=>$this->id);
610
+        $data_values = array('accept_status'=>$status);
611
+        $this->set_relationship($this->rel_leads_table, $relate_values, true, true,$data_values);
612
+    }
612 613
     }
613
-  }
614 614
 
615 615
 
616 616
 
617
-	function get_notification_recipients() {
618
-		if($this->special_notification) {
619
-			return parent::get_notification_recipients();
620
-		}
617
+    function get_notification_recipients() {
618
+        if($this->special_notification) {
619
+            return parent::get_notification_recipients();
620
+        }
621 621
 
622 622
 //		$GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($this,true));
623
-		$list = array();
623
+        $list = array();
624 624
         if(!is_array($this->contacts_arr)) {
625
-			$this->contacts_arr =	array();
626
-		}
625
+            $this->contacts_arr =	array();
626
+        }
627 627
 
628
-		if(!is_array($this->users_arr)) {
629
-			$this->users_arr =	array();
630
-		}
628
+        if(!is_array($this->users_arr)) {
629
+            $this->users_arr =	array();
630
+        }
631 631
 
632 632
         if(!is_array($this->leads_arr)) {
633
-			$this->leads_arr =	array();
634
-		}
635
-
636
-		foreach($this->users_arr as $user_id) {
637
-			$notify_user = new User();
638
-			$notify_user->retrieve($user_id);
639
-			$notify_user->new_assigned_user_name = $notify_user->full_name;
640
-			$GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
641
-			$list[$notify_user->id] = $notify_user;
642
-		}
643
-
644
-		foreach($this->contacts_arr as $contact_id) {
645
-			$notify_user = new Contact();
646
-			$notify_user->retrieve($contact_id);
647
-			$notify_user->new_assigned_user_name = $notify_user->full_name;
648
-			$GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
649
-			$list[$notify_user->id] = $notify_user;
650
-		}
633
+            $this->leads_arr =	array();
634
+        }
635
+
636
+        foreach($this->users_arr as $user_id) {
637
+            $notify_user = new User();
638
+            $notify_user->retrieve($user_id);
639
+            $notify_user->new_assigned_user_name = $notify_user->full_name;
640
+            $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
641
+            $list[$notify_user->id] = $notify_user;
642
+        }
643
+
644
+        foreach($this->contacts_arr as $contact_id) {
645
+            $notify_user = new Contact();
646
+            $notify_user->retrieve($contact_id);
647
+            $notify_user->new_assigned_user_name = $notify_user->full_name;
648
+            $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
649
+            $list[$notify_user->id] = $notify_user;
650
+        }
651 651
 
652 652
         foreach($this->leads_arr as $lead_id) {
653
-			$notify_user = new Lead();
654
-			$notify_user->retrieve($lead_id);
655
-			$notify_user->new_assigned_user_name = $notify_user->full_name;
656
-			$GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
657
-			$list[$notify_user->id] = $notify_user;
658
-		}
659
-		global $sugar_config;
660
-		if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) {
661
-			global $current_user;
662
-			if(isset($list[$current_user->id]))
663
-				unset($list[$current_user->id]);
664
-		}
653
+            $notify_user = new Lead();
654
+            $notify_user->retrieve($lead_id);
655
+            $notify_user->new_assigned_user_name = $notify_user->full_name;
656
+            $GLOBALS['log']->info("Notifications: recipient is $notify_user->new_assigned_user_name");
657
+            $list[$notify_user->id] = $notify_user;
658
+        }
659
+        global $sugar_config;
660
+        if(isset($sugar_config['disable_notify_current_user']) && $sugar_config['disable_notify_current_user']) {
661
+            global $current_user;
662
+            if(isset($list[$current_user->id]))
663
+                unset($list[$current_user->id]);
664
+        }
665 665
 //		$GLOBALS['log']->debug('Call.php->get_notification_recipients():'.print_r($list,true));
666
-		return $list;
667
-	}
666
+        return $list;
667
+    }
668 668
 
669 669
     function bean_implements($interface){
670
-		switch($interface){
671
-			case 'ACL':return true;
672
-		}
673
-		return false;
674
-	}
675
-
676
-	function listviewACLHelper(){
677
-		$array_assign = parent::listviewACLHelper();
678
-		$is_owner = false;
679
-		$in_group = false; //SECURITY GROUPS
680
-		if(!empty($this->parent_name)){
681
-
682
-			if(!empty($this->parent_name_owner)){
683
-				global $current_user;
684
-				$is_owner = $current_user->id == $this->parent_name_owner;
685
-			}
686
-			/* BEGIN - SECURITY GROUPS */
687
-			//parent_name_owner not being set for whatever reason so we need to figure this out
688
-			else if(!empty($this->parent_type) && !empty($this->parent_id)) {
689
-				global $current_user;
670
+        switch($interface){
671
+            case 'ACL':return true;
672
+        }
673
+        return false;
674
+    }
675
+
676
+    function listviewACLHelper(){
677
+        $array_assign = parent::listviewACLHelper();
678
+        $is_owner = false;
679
+        $in_group = false; //SECURITY GROUPS
680
+        if(!empty($this->parent_name)){
681
+
682
+            if(!empty($this->parent_name_owner)){
683
+                global $current_user;
684
+                $is_owner = $current_user->id == $this->parent_name_owner;
685
+            }
686
+            /* BEGIN - SECURITY GROUPS */
687
+            //parent_name_owner not being set for whatever reason so we need to figure this out
688
+            else if(!empty($this->parent_type) && !empty($this->parent_id)) {
689
+                global $current_user;
690 690
                 $parent_bean = BeanFactory::getBean($this->parent_type,$this->parent_id);
691 691
                 if($parent_bean !== false) {
692
-                	$is_owner = $current_user->id == $parent_bean->assigned_user_id;
692
+                    $is_owner = $current_user->id == $parent_bean->assigned_user_id;
693 693
                 }
694
-			}
695
-			require_once("modules/SecurityGroups/SecurityGroup.php");
696
-			$in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view');
697
-        	/* END - SECURITY GROUPS */
698
-		}
699
-
700
-			/* BEGIN - SECURITY GROUPS */
701
-			/**
694
+            }
695
+            require_once("modules/SecurityGroups/SecurityGroup.php");
696
+            $in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view');
697
+            /* END - SECURITY GROUPS */
698
+        }
699
+
700
+            /* BEGIN - SECURITY GROUPS */
701
+            /**
702 702
 			if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner)){
703
-			*/
704
-			if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){
705
-        	/* END - SECURITY GROUPS */
706
-				$array_assign['PARENT'] = 'a';
707
-			}else{
708
-				$array_assign['PARENT'] = 'span';
709
-			}
710
-		$is_owner = false;
711
-		$in_group = false; //SECURITY GROUPS
712
-		if(!empty($this->contact_name)){
713
-
714
-			if(!empty($this->contact_name_owner)){
715
-				global $current_user;
716
-				$is_owner = $current_user->id == $this->contact_name_owner;
717
-			}
718
-			/* BEGIN - SECURITY GROUPS */
719
-			//contact_name_owner not being set for whatever reason so we need to figure this out
720
-			else {
721
-				global $current_user;
703
+             */
704
+            if(!ACLController::moduleSupportsACL($this->parent_type) || ACLController::checkAccess($this->parent_type, 'view', $is_owner, 'module', $in_group)){
705
+            /* END - SECURITY GROUPS */
706
+                $array_assign['PARENT'] = 'a';
707
+            }else{
708
+                $array_assign['PARENT'] = 'span';
709
+            }
710
+        $is_owner = false;
711
+        $in_group = false; //SECURITY GROUPS
712
+        if(!empty($this->contact_name)){
713
+
714
+            if(!empty($this->contact_name_owner)){
715
+                global $current_user;
716
+                $is_owner = $current_user->id == $this->contact_name_owner;
717
+            }
718
+            /* BEGIN - SECURITY GROUPS */
719
+            //contact_name_owner not being set for whatever reason so we need to figure this out
720
+            else {
721
+                global $current_user;
722 722
                 $parent_bean = BeanFactory::getBean('Contacts',$this->contact_id);
723 723
                 if($parent_bean !== false) {
724
-                	$is_owner = $current_user->id == $parent_bean->assigned_user_id;
724
+                    $is_owner = $current_user->id == $parent_bean->assigned_user_id;
725 725
                 }
726
-			}
727
-			require_once("modules/SecurityGroups/SecurityGroup.php");
728
-			$in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view');
729
-        	/* END - SECURITY GROUPS */
730
-		}
731
-			/* BEGIN - SECURITY GROUPS */
732
-			/**
726
+            }
727
+            require_once("modules/SecurityGroups/SecurityGroup.php");
728
+            $in_group = SecurityGroup::groupHasAccess('Contacts', $this->contact_id, 'view');
729
+            /* END - SECURITY GROUPS */
730
+        }
731
+            /* BEGIN - SECURITY GROUPS */
732
+            /**
733 733
 			if( ACLController::checkAccess('Contacts', 'view', $is_owner)){
734
-			*/
735
-			if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){
736
-        	/* END - SECURITY GROUPS */
737
-				$array_assign['CONTACT'] = 'a';
738
-			}else{
739
-				$array_assign['CONTACT'] = 'span';
740
-			}
741
-
742
-		return $array_assign;
743
-	}
744
-
745
-	function save_relationship_changes($is_update, $exclude = array()) {
746
-		if(empty($this->in_workflow))
734
+             */
735
+            if( ACLController::checkAccess('Contacts', 'view', $is_owner, 'module', $in_group)){
736
+            /* END - SECURITY GROUPS */
737
+                $array_assign['CONTACT'] = 'a';
738
+            }else{
739
+                $array_assign['CONTACT'] = 'span';
740
+            }
741
+
742
+        return $array_assign;
743
+    }
744
+
745
+    function save_relationship_changes($is_update, $exclude = array()) {
746
+        if(empty($this->in_workflow))
747 747
         {
748 748
             if(empty($this->in_import))
749 749
             {
@@ -751,12 +751,12 @@  discard block
 block discarded – undo
751 751
                 //add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
752 752
                 if(!empty($GLOBALS['soap_server_object']))
753 753
                 {
754
-           		    $exclude = array('lead_id', 'contact_id', 'user_id');
755
-           	    }
754
+                        $exclude = array('lead_id', 'contact_id', 'user_id');
755
+                    }
756 756
                 else
757 757
                 {
758
-	                $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id');
759
-           	    }
758
+                    $exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id');
759
+                    }
760 760
             }
761 761
             else
762 762
             {
@@ -765,15 +765,15 @@  discard block
 block discarded – undo
765 765
 
766 766
 
767 767
         }
768
-		parent::save_relationship_changes($is_update, $exclude);
769
-	}
768
+        parent::save_relationship_changes($is_update, $exclude);
769
+    }
770 770
 
771 771
     public function getDefaultStatus()
772 772
     {
773
-         $def = $this->field_defs['status'];
774
-         if (isset($def['default'])) {
775
-             return $def['default'];
776
-         } else {
773
+            $def = $this->field_defs['status'];
774
+            if (isset($def['default'])) {
775
+                return $def['default'];
776
+            } else {
777 777
             $app = return_app_list_strings_language($GLOBALS['current_language']);
778 778
             if (isset($def['options']) && isset($app[$def['options']])) {
779 779
                 $keys = array_keys($app[$def['options']]);
Please login to merge, or discard this patch.
modules/ProspectLists/ProspectList.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -50,51 +50,51 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
 class ProspectList extends SugarBean {
53
-	var $field_name_map;
54
-
55
-	// Stored fields
56
-	var $id;
57
-	var $date_entered;
58
-	var $date_modified;
59
-	var $modified_user_id;
60
-	var $assigned_user_id;
61
-	var $created_by;
62
-	var $created_by_name;
63
-	var $modified_by_name;
64
-	var $list_type;
65
-	var $domain_name;
66
-
67
-	var $name;
68
-	var $description;
69
-
70
-	// These are related
71
-	var $assigned_user_name;
72
-	var $prospect_id;
73
-	var $contact_id;
74
-	var $lead_id;
75
-
76
-	// module name definitions and table relations
77
-	var $table_name = "prospect_lists";
78
-	var $module_dir = 'ProspectLists';
79
-	var $rel_prospects_table = "prospect_lists_prospects";
80
-	var $object_name = "ProspectList";
81
-
82
-	// This is used to retrieve related fields from form posts.
83
-	var $additional_column_fields = array(
84
-		'assigned_user_name', 'assigned_user_id', 'campaign_id',
85
-	);
86
-	var $relationship_fields = array(
87
-		'campaign_id'=>'campaigns',
88
-		'prospect_list_prospects' => 'prospects',
89
-	);
53
+    var $field_name_map;
54
+
55
+    // Stored fields
56
+    var $id;
57
+    var $date_entered;
58
+    var $date_modified;
59
+    var $modified_user_id;
60
+    var $assigned_user_id;
61
+    var $created_by;
62
+    var $created_by_name;
63
+    var $modified_by_name;
64
+    var $list_type;
65
+    var $domain_name;
66
+
67
+    var $name;
68
+    var $description;
69
+
70
+    // These are related
71
+    var $assigned_user_name;
72
+    var $prospect_id;
73
+    var $contact_id;
74
+    var $lead_id;
75
+
76
+    // module name definitions and table relations
77
+    var $table_name = "prospect_lists";
78
+    var $module_dir = 'ProspectLists';
79
+    var $rel_prospects_table = "prospect_lists_prospects";
80
+    var $object_name = "ProspectList";
81
+
82
+    // This is used to retrieve related fields from form posts.
83
+    var $additional_column_fields = array(
84
+        'assigned_user_name', 'assigned_user_id', 'campaign_id',
85
+    );
86
+    var $relationship_fields = array(
87
+        'campaign_id'=>'campaigns',
88
+        'prospect_list_prospects' => 'prospects',
89
+    );
90 90
 
91 91
     var $entry_count;
92 92
 
93 93
     public function __construct() {
94
-		global $sugar_config;
95
-		parent::__construct();
94
+        global $sugar_config;
95
+        parent::__construct();
96 96
 
97
-	}
97
+    }
98 98
 
99 99
     /**
100 100
      * @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
@@ -111,61 +111,61 @@  discard block
 block discarded – undo
111 111
     }
112 112
 
113 113
 
114
-	var $new_schema = true;
114
+    var $new_schema = true;
115 115
 
116
-	function get_summary_text()
117
-	{
118
-		return "$this->name";
119
-	}
116
+    function get_summary_text()
117
+    {
118
+        return "$this->name";
119
+    }
120 120
 
121
-	function create_list_query($order_by, $where, $show_deleted = 0)
122
-	{
121
+    function create_list_query($order_by, $where, $show_deleted = 0)
122
+    {
123 123
         $custom_join = $this->getCustomJoin();
124 124
 
125
-		$query = "SELECT ";
126
-		$query .= "users.user_name as assigned_user_name, ";
127
-		$query .= "prospect_lists.*";
125
+        $query = "SELECT ";
126
+        $query .= "users.user_name as assigned_user_name, ";
127
+        $query .= "prospect_lists.*";
128 128
 
129 129
         $query .= $custom_join['select'];
130
-		$query .= " FROM prospect_lists ";
130
+        $query .= " FROM prospect_lists ";
131 131
 
132
-		$query .= "LEFT JOIN users
132
+        $query .= "LEFT JOIN users
133 133
 					ON prospect_lists.assigned_user_id=users.id ";
134 134
 
135 135
         $query .= $custom_join['join'];
136 136
 
137
-			$where_auto = '1=1';
138
-				if($show_deleted == 0){
139
-                	$where_auto = "$this->table_name.deleted=0";
140
-				}else if($show_deleted == 1){
141
-                	$where_auto = "$this->table_name.deleted=1";
142
-				}
137
+            $where_auto = '1=1';
138
+                if($show_deleted == 0){
139
+                    $where_auto = "$this->table_name.deleted=0";
140
+                }else if($show_deleted == 1){
141
+                    $where_auto = "$this->table_name.deleted=1";
142
+                }
143 143
 
144
-		if($where != "")
145
-			$query .= "where $where AND ".$where_auto;
146
-		else
147
-			$query .= "where ".$where_auto;
144
+        if($where != "")
145
+            $query .= "where $where AND ".$where_auto;
146
+        else
147
+            $query .= "where ".$where_auto;
148 148
 
149
-		if($order_by != "")
150
-			$query .= " ORDER BY $order_by";
151
-		else
152
-			$query .= " ORDER BY prospect_lists.name";
149
+        if($order_by != "")
150
+            $query .= " ORDER BY $order_by";
151
+        else
152
+            $query .= " ORDER BY prospect_lists.name";
153 153
 
154
-		return $query;
155
-	}
154
+        return $query;
155
+    }
156 156
 
157 157
 
158
-	function create_export_query($order_by, $where)
159
-	{
158
+    function create_export_query($order_by, $where)
159
+    {
160 160
 
161 161
                                 $query = "SELECT
162 162
                                 prospect_lists.*,
163 163
                                 users.user_name as assigned_user_name ";
164
-	                            $query .= "FROM prospect_lists ";
165
-		$query .= 				"LEFT JOIN users
164
+                                $query .= "FROM prospect_lists ";
165
+        $query .= 				"LEFT JOIN users
166 166
                                 ON prospect_lists.assigned_user_id=users.id ";
167 167
 
168
-		$where_auto = " prospect_lists.deleted=0";
168
+        $where_auto = " prospect_lists.deleted=0";
169 169
 
170 170
         if($where != "")
171 171
                 $query .= " WHERE $where AND ".$where_auto;
@@ -179,47 +179,47 @@  discard block
 block discarded – undo
179 179
         return $query;
180 180
     }
181 181
 
182
-	function create_export_members_query($record_id)
183
-	{
184
-		$members = array(	'Accounts' 	=> array('has_custom_fields' => false, 'fields' => array()),
185
-					'Contacts' 	=> array('has_custom_fields' => false, 'fields' => array()),
186
-					'Users' 	=> array('has_custom_fields' => false, 'fields' => array()),
187
-					'Prospects' 	=> array('has_custom_fields' => false, 'fields' => array()),
188
-					'Leads' 	=> array('has_custom_fields' => false, 'fields' => array())
189
-				);
190
-
191
-		// query all custom fields in the fields_meta_data table for the modules which are being exported
192
-		$db = DBManagerFactory::getInstance();
193
-		$result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('" .
194
-					implode("', '", array_keys($members)) . "')",
195
-					true,
196
-					"ProspectList::create_export_members_query() : error querying custom fields");
197
-
198
-		// cycle through the custom fields and put them in the members array according to
199
-		// what module the field belongs
200
-		// take into account that the same custom field may exist in more modules
201
-		while($val = $db->fetchByAssoc($result, false))
202
-		{
203
-			$fieldname = $val['name'];
204
-
205
-			foreach($members as $membername => &$memberarr)
206
-			{
207
-				// if the field belongs to this module, then query it in the cstm table
208
-				if ($membername == $val['custom_module'])
209
-				{
210
-					$memberarr['has_custom_fields'] = true;
211
-					$memberarr['fields'][$fieldname] =
212
-						strtolower($membername) . '_cstm.'.$fieldname . ' AS ' . $fieldname;
213
-				}
214
-				// else, only if for this module no entry exists for this field, query an empty string
215
-				else if (!isset($memberarr['fields'][$val['name']]))
216
-				{
217
-					$memberarr['fields'][$fieldname] = "'' AS " . $fieldname;
218
-				}
219
-			}
220
-		}
221
-
222
-		$leads_query = "SELECT l.id AS id, 'Leads' AS related_type, '' AS \"name\", l.first_name AS first_name, l.last_name AS last_name, l.title AS title, l.salutation AS salutation,
182
+    function create_export_members_query($record_id)
183
+    {
184
+        $members = array(	'Accounts' 	=> array('has_custom_fields' => false, 'fields' => array()),
185
+                    'Contacts' 	=> array('has_custom_fields' => false, 'fields' => array()),
186
+                    'Users' 	=> array('has_custom_fields' => false, 'fields' => array()),
187
+                    'Prospects' 	=> array('has_custom_fields' => false, 'fields' => array()),
188
+                    'Leads' 	=> array('has_custom_fields' => false, 'fields' => array())
189
+                );
190
+
191
+        // query all custom fields in the fields_meta_data table for the modules which are being exported
192
+        $db = DBManagerFactory::getInstance();
193
+        $result = $db->query("select name, custom_module from fields_meta_data where custom_module in ('" .
194
+                    implode("', '", array_keys($members)) . "')",
195
+                    true,
196
+                    "ProspectList::create_export_members_query() : error querying custom fields");
197
+
198
+        // cycle through the custom fields and put them in the members array according to
199
+        // what module the field belongs
200
+        // take into account that the same custom field may exist in more modules
201
+        while($val = $db->fetchByAssoc($result, false))
202
+        {
203
+            $fieldname = $val['name'];
204
+
205
+            foreach($members as $membername => &$memberarr)
206
+            {
207
+                // if the field belongs to this module, then query it in the cstm table
208
+                if ($membername == $val['custom_module'])
209
+                {
210
+                    $memberarr['has_custom_fields'] = true;
211
+                    $memberarr['fields'][$fieldname] =
212
+                        strtolower($membername) . '_cstm.'.$fieldname . ' AS ' . $fieldname;
213
+                }
214
+                // else, only if for this module no entry exists for this field, query an empty string
215
+                else if (!isset($memberarr['fields'][$val['name']]))
216
+                {
217
+                    $memberarr['fields'][$fieldname] = "'' AS " . $fieldname;
218
+                }
219
+            }
220
+        }
221
+
222
+        $leads_query = "SELECT l.id AS id, 'Leads' AS related_type, '' AS \"name\", l.first_name AS first_name, l.last_name AS last_name, l.title AS title, l.salutation AS salutation,
223 223
 				l.primary_address_street AS primary_address_street,l.primary_address_city AS primary_address_city, l.primary_address_state AS primary_address_state, l.primary_address_postalcode AS primary_address_postalcode, l.primary_address_country AS primary_address_country,
224 224
 				l.account_name AS account_name,
225 225
 				ea.email_address AS primary_email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				AND l.deleted=0
235 235
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
236 236
 
237
-		$users_query = "SELECT u.id AS id, 'Users' AS related_type, '' AS \"name\", u.first_name AS first_name, u.last_name AS last_name,u.title AS title, '' AS salutation,
237
+        $users_query = "SELECT u.id AS id, 'Users' AS related_type, '' AS \"name\", u.first_name AS first_name, u.last_name AS last_name,u.title AS title, '' AS salutation,
238 238
 				u.address_street AS primary_address_street,u.address_city AS primary_address_city, u.address_state AS primary_address_state,  u.address_postalcode AS primary_address_postalcode, u.address_country AS primary_address_country,
239 239
 				'' AS account_name,
240 240
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 				AND u.deleted=0
250 250
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
251 251
 
252
-		$contacts_query = "SELECT c.id AS id, 'Contacts' AS related_type, '' AS \"name\", c.first_name AS first_name, c.last_name AS last_name,c.title AS title, c.salutation AS salutation,
252
+        $contacts_query = "SELECT c.id AS id, 'Contacts' AS related_type, '' AS \"name\", c.first_name AS first_name, c.last_name AS last_name,c.title AS title, c.salutation AS salutation,
253 253
 				c.primary_address_street AS primary_address_street,c.primary_address_city AS primary_address_city, c.primary_address_state AS primary_address_state,  c.primary_address_postalcode AS primary_address_postalcode, c.primary_address_country AS primary_address_country,
254 254
 				a.name AS account_name,
255 255
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 				AND c.deleted=0
266 266
                 AND (ear.deleted=0 OR ear.deleted IS NULL)";
267 267
 
268
-		$prospects_query = "SELECT p.id AS id, 'Prospects' AS related_type, '' AS \"name\", p.first_name AS first_name, p.last_name AS last_name,p.title AS title, p.salutation AS salutation,
268
+        $prospects_query = "SELECT p.id AS id, 'Prospects' AS related_type, '' AS \"name\", p.first_name AS first_name, p.last_name AS last_name,p.title AS title, p.salutation AS salutation,
269 269
 				p.primary_address_street AS primary_address_street,p.primary_address_city AS primary_address_city, p.primary_address_state AS primary_address_state,  p.primary_address_postalcode AS primary_address_postalcode, p.primary_address_country AS primary_address_country,
270 270
 				p.account_name AS account_name,
271 271
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 				AND p.deleted=0
281 281
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
282 282
 
283
-		$accounts_query = "SELECT a.id AS id, 'Accounts' AS related_type, a.name AS \"name\", '' AS first_name, '' AS last_name,'' AS title, '' AS salutation,
283
+        $accounts_query = "SELECT a.id AS id, 'Accounts' AS related_type, a.name AS \"name\", '' AS first_name, '' AS last_name,'' AS title, '' AS salutation,
284 284
 				a.billing_address_street AS primary_address_street,a.billing_address_city AS primary_address_city, a.billing_address_state AS primary_address_state, a.billing_address_postalcode AS primary_address_postalcode, a.billing_address_country AS primary_address_country,
285 285
 				'' AS account_name,
286 286
 				ea.email_address AS email_address, ea.invalid_email AS invalid_email, ea.opt_out AS opt_out, ea.deleted AS ea_deleted, ear.deleted AS ear_deleted, ear.primary_address AS primary_address,
@@ -294,115 +294,115 @@  discard block
 block discarded – undo
294 294
 				WHERE plp.prospect_list_id = $record_id  AND plp.deleted=0
295 295
 				AND a.deleted=0
296 296
 				AND (ear.deleted=0 OR ear.deleted IS NULL)";
297
-		$order_by = "ORDER BY related_type, id, primary_address DESC";
298
-		$query = "$leads_query UNION ALL $users_query UNION ALL $contacts_query UNION ALL $prospects_query UNION ALL $accounts_query $order_by";
299
-		return $query;
300
-	}
297
+        $order_by = "ORDER BY related_type, id, primary_address DESC";
298
+        $query = "$leads_query UNION ALL $users_query UNION ALL $contacts_query UNION ALL $prospects_query UNION ALL $accounts_query $order_by";
299
+        return $query;
300
+    }
301 301
 
302
-	function save_relationship_changes($is_update, $exclude = array())
302
+    function save_relationship_changes($is_update, $exclude = array())
303 303
     {
304
-    	parent::save_relationship_changes($is_update, $exclude);
305
-		if($this->lead_id != "")
306
-	   		$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
-    	if($this->contact_id != "")
308
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
-    	if($this->prospect_id != "")
310
-    		$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
304
+        parent::save_relationship_changes($is_update, $exclude);
305
+        if($this->lead_id != "")
306
+                $this->set_prospect_relationship($this->id, $this->lead_id, "lead");
307
+        if($this->contact_id != "")
308
+            $this->set_prospect_relationship($this->id, $this->contact_id, "contact");
309
+        if($this->prospect_id != "")
310
+            $this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
311 311
     }
312 312
 
313
-	function set_prospect_relationship($prospect_list_id, &$link_ids, $link_name)
314
-	{
315
-		$link_field = sprintf("%s_id", $link_name);
313
+    function set_prospect_relationship($prospect_list_id, &$link_ids, $link_name)
314
+    {
315
+        $link_field = sprintf("%s_id", $link_name);
316 316
 
317
-		foreach($link_ids as $link_id)
318
-		{
319
-			$this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
320
-		}
321
-	}
317
+        foreach($link_ids as $link_id)
318
+        {
319
+            $this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
320
+        }
321
+    }
322 322
 
323
-	function set_prospect_relationship_single($prospect_list_id, $link_id, $link_name)
324
-	{
325
-		$link_field = sprintf("%s_id", $link_name);
323
+    function set_prospect_relationship_single($prospect_list_id, $link_id, $link_name)
324
+    {
325
+        $link_field = sprintf("%s_id", $link_name);
326 326
 
327
-		$this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
328
-	}
327
+        $this->set_relationship('prospect_lists_prospects', array( $link_field=>$link_id, 'prospect_list_id'=>$prospect_list_id ));
328
+    }
329 329
 
330 330
 
331
-	function clear_prospect_relationship($prospect_list_id, $link_id, $link_name)
332
-	{
333
-		$link_field = sprintf("%s_id", $link_name);
334
-		$where_clause = " AND $link_field = '$link_id' ";
331
+    function clear_prospect_relationship($prospect_list_id, $link_id, $link_name)
332
+    {
333
+        $link_field = sprintf("%s_id", $link_name);
334
+        $where_clause = " AND $link_field = '$link_id' ";
335 335
 
336
-		$query = sprintf("DELETE FROM prospect_lists_prospects WHERE prospect_list_id='%s' AND deleted = '0' %s", $prospect_list_id, $where_clause);
336
+        $query = sprintf("DELETE FROM prospect_lists_prospects WHERE prospect_list_id='%s' AND deleted = '0' %s", $prospect_list_id, $where_clause);
337 337
 
338
-		$this->db->query($query, true, "Error clearing prospect/prospect_list relationship: ");
339
-	}
338
+        $this->db->query($query, true, "Error clearing prospect/prospect_list relationship: ");
339
+    }
340 340
 
341 341
 
342
-	function mark_relationships_deleted($id)
343
-	{
344
-	}
342
+    function mark_relationships_deleted($id)
343
+    {
344
+    }
345 345
 
346
-	function fill_in_additional_list_fields()
347
-	{
348
-	}
346
+    function fill_in_additional_list_fields()
347
+    {
348
+    }
349 349
 
350
-	function fill_in_additional_detail_fields()
351
-	{
352
-		parent::fill_in_additional_detail_fields();
350
+    function fill_in_additional_detail_fields()
351
+    {
352
+        parent::fill_in_additional_detail_fields();
353 353
         $this->entry_count = $this->get_entry_count();
354
-	}
354
+    }
355 355
 
356 356
 
357
-	function update_currency_id($fromid, $toid){
358
-	}
357
+    function update_currency_id($fromid, $toid){
358
+    }
359 359
 
360 360
 
361
-	function get_entry_count()
362
-	{
363
-		$query = "SELECT count(*) AS num FROM prospect_lists_prospects WHERE prospect_list_id='$this->id' AND deleted = '0'";
364
-		$result = $this->db->query($query, true, "Grabbing prospect_list entry count");
361
+    function get_entry_count()
362
+    {
363
+        $query = "SELECT count(*) AS num FROM prospect_lists_prospects WHERE prospect_list_id='$this->id' AND deleted = '0'";
364
+        $result = $this->db->query($query, true, "Grabbing prospect_list entry count");
365 365
 
366
-		$row = $this->db->fetchByAssoc($result);
366
+        $row = $this->db->fetchByAssoc($result);
367 367
 
368
-		if($row)
369
-			return $row['num'];
370
-		else
371
-			return 0;
372
-	}
368
+        if($row)
369
+            return $row['num'];
370
+        else
371
+            return 0;
372
+    }
373 373
 
374 374
 
375
-	function get_list_view_data(){
376
-		$temp_array = $this->get_list_view_array();
377
-		$temp_array["ENTRY_COUNT"] = $this->get_entry_count();
378
-		return $temp_array;
379
-	}
380
-	/**
375
+    function get_list_view_data(){
376
+        $temp_array = $this->get_list_view_array();
377
+        $temp_array["ENTRY_COUNT"] = $this->get_entry_count();
378
+        return $temp_array;
379
+    }
380
+    /**
381 381
 		builds a generic search based on the query string using or
382 382
 		do not include any $this-> because this is called on without having the class instantiated
383
-	*/
384
-	function build_generic_where_clause ($the_query_string)
385
-	{
386
-		$where_clauses = Array();
387
-		$the_query_string = $GLOBALS['db']->quote($the_query_string);
388
-		array_push($where_clauses, "prospect_lists.name like '$the_query_string%'");
389
-
390
-		$the_where = "";
391
-		foreach($where_clauses as $clause)
392
-		{
393
-			if($the_where != "") $the_where .= " or ";
394
-			$the_where .= $clause;
395
-		}
383
+     */
384
+    function build_generic_where_clause ($the_query_string)
385
+    {
386
+        $where_clauses = Array();
387
+        $the_query_string = $GLOBALS['db']->quote($the_query_string);
388
+        array_push($where_clauses, "prospect_lists.name like '$the_query_string%'");
389
+
390
+        $the_where = "";
391
+        foreach($where_clauses as $clause)
392
+        {
393
+            if($the_where != "") $the_where .= " or ";
394
+            $the_where .= $clause;
395
+        }
396 396
 
397 397
 
398
-		return $the_where;
399
-	}
398
+        return $the_where;
399
+    }
400 400
 
401
-	function save($check_notify = FALSE) {
401
+    function save($check_notify = FALSE) {
402 402
 
403
-		return parent::save($check_notify);
403
+        return parent::save($check_notify);
404 404
 
405
-	}
405
+    }
406 406
 
407 407
     function mark_deleted($id){
408 408
         $query = "UPDATE prospect_lists_prospects SET deleted = 1 WHERE prospect_list_id = '{$id}' ";
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
         return parent::mark_deleted($id);
411 411
     }
412 412
 
413
-	 function bean_implements($interface){
414
-		switch($interface){
415
-			case 'ACL':return true;
416
-		}
417
-		return false;
418
-	}
413
+        function bean_implements($interface){
414
+        switch($interface){
415
+            case 'ACL':return true;
416
+        }
417
+        return false;
418
+    }
419 419
 
420 420
 }
421 421
 
Please login to merge, or discard this patch.