Completed
Push — console-installer ( 3d54e5...e2b50d )
by Adam
69:10 queued 48:24
created
modules/Administration/UpgradeFields.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(!defined('sugarEntry') || !sugarEntry)
3
-	die('Not A Valid Entry Point');
3
+    die('Not A Valid Entry Point');
4 4
 /*********************************************************************************
5 5
  * SugarCRM Community Edition is a customer relationship management program developed by
6 6
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 global $db;
45 45
 
46 46
 if (!isset ($db)) {
47
-	$db = DBManagerFactory:: getInstance();
47
+    $db = DBManagerFactory:: getInstance();
48 48
 }
49 49
 
50 50
 $result = $db->query('SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module');
@@ -53,82 +53,82 @@  discard block
 block discarded – undo
53 53
  * get the real field_meta_data
54 54
  */
55 55
 while ($row = $db->fetchByAssoc($result)) {
56
-	$the_modules = $row['custom_module'];
57
-	if (!isset ($modules[$the_modules])) {
58
-		$modules[$the_modules] = array ();
59
-	}
60
-	$modules[$the_modules][$row['name']] = $row['name'];
56
+    $the_modules = $row['custom_module'];
57
+    if (!isset ($modules[$the_modules])) {
58
+        $modules[$the_modules] = array ();
59
+    }
60
+    $modules[$the_modules][$row['name']] = $row['name'];
61 61
 }
62 62
 
63 63
 $simulate = false;
64 64
 if (!isset ($_REQUEST['run'])) {
65
-	$simulate = true;
66
-	echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE";
65
+    $simulate = true;
66
+    echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE";
67 67
 }
68 68
 
69 69
 foreach ($modules as $the_module => $fields) {
70
-	$class_name = $beanList[$the_module];
71
-	echo "<br><br>Scanning $the_module <br>";
70
+    $class_name = $beanList[$the_module];
71
+    echo "<br><br>Scanning $the_module <br>";
72 72
 
73
-	require_once ($beanFiles[$class_name]);
74
-	$mod = new $class_name ();
75
-	if (!$db->tableExists($mod->table_name."_cstm")) {
76
-		$mod->custom_fields = new DynamicField();
77
-		$mod->custom_fields->setup($mod);
78
-		$mod->custom_fields->createCustomTable();
79
-	}
73
+    require_once ($beanFiles[$class_name]);
74
+    $mod = new $class_name ();
75
+    if (!$db->tableExists($mod->table_name."_cstm")) {
76
+        $mod->custom_fields = new DynamicField();
77
+        $mod->custom_fields->setup($mod);
78
+        $mod->custom_fields->createCustomTable();
79
+    }
80 80
 
81
-	$table = $db->getTableDescription($mod->table_name."_cstm");
82
-	foreach($table as $row) {
83
-		$col = strtolower(empty ($row['Field']) ? $row['field'] : $row['Field']);
84
-		$the_field = $mod->custom_fields->getField($col);
85
-		$type = strtolower(empty ($row['Type']) ? $row['type'] : $row['Type']);
86
-		if (!empty($row['data_precision']) && !empty($row['data_scale'])) {
87
-			$type.='(' . $row['data_precision'];
88
-			if (!empty($row['data_scale'])) {
89
-				$type.=',' . $row['data_scale'];
90
-			}
91
-			$type.=')';
92
-		} elseif(!empty($row['data_length']) && (strtolower($row['type'])=='varchar' or strtolower($row['type'])=='varchar2')) {
93
-			$type.='(' . $row['data_length'] . ')';
94
-		}
95
-		if (!isset ($fields[$col]) && $col != 'id_c') {
96
-			if (!$simulate) {
97
-				$db->query("ALTER TABLE $mod->table_name"."_cstm DROP COLUMN $col");
98
-			}
99
-			unset ($fields[$col]);
100
-			echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>";
101
-		} else {
102
-			if ($col != 'id_c') {
103
-				$db_data_type = strtolower(str_replace(' ' , '', $the_field->get_db_type()));
81
+    $table = $db->getTableDescription($mod->table_name."_cstm");
82
+    foreach($table as $row) {
83
+        $col = strtolower(empty ($row['Field']) ? $row['field'] : $row['Field']);
84
+        $the_field = $mod->custom_fields->getField($col);
85
+        $type = strtolower(empty ($row['Type']) ? $row['type'] : $row['Type']);
86
+        if (!empty($row['data_precision']) && !empty($row['data_scale'])) {
87
+            $type.='(' . $row['data_precision'];
88
+            if (!empty($row['data_scale'])) {
89
+                $type.=',' . $row['data_scale'];
90
+            }
91
+            $type.=')';
92
+        } elseif(!empty($row['data_length']) && (strtolower($row['type'])=='varchar' or strtolower($row['type'])=='varchar2')) {
93
+            $type.='(' . $row['data_length'] . ')';
94
+        }
95
+        if (!isset ($fields[$col]) && $col != 'id_c') {
96
+            if (!$simulate) {
97
+                $db->query("ALTER TABLE $mod->table_name"."_cstm DROP COLUMN $col");
98
+            }
99
+            unset ($fields[$col]);
100
+            echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>";
101
+        } else {
102
+            if ($col != 'id_c') {
103
+                $db_data_type = strtolower(str_replace(' ' , '', $the_field->get_db_type()));
104 104
 
105
-				$type = strtolower(str_replace(' ' , '', $type));
106
-				if (strcmp($db_data_type,$type) != 0) {
105
+                $type = strtolower(str_replace(' ' , '', $type));
106
+                if (strcmp($db_data_type,$type) != 0) {
107 107
 
108
-					echo "Fixing Column Type for $col changing $type to ".$db_data_type."<br>";
109
-					if (!$simulate) {
110
-						$db->query($the_field->get_db_modify_alter_table($mod->table_name.'_cstm'));
108
+                    echo "Fixing Column Type for $col changing $type to ".$db_data_type."<br>";
109
+                    if (!$simulate) {
110
+                        $db->query($the_field->get_db_modify_alter_table($mod->table_name.'_cstm'));
111 111
                     }
112
-				}
113
-			}
112
+                }
113
+            }
114 114
 
115
-			unset ($fields[$col]);
116
-		}
115
+            unset ($fields[$col]);
116
+        }
117 117
 
118
-	}
118
+    }
119 119
 
120
-	echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>";
121
-	foreach ($fields as $field) {
122
-		echo "Adding Column $field to $mod->table_name"."_cstm<br>";
123
-		if (!$simulate)
124
-			$mod->custom_fields->add_existing_custom_field($field);
125
-	}
120
+    echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>";
121
+    foreach ($fields as $field) {
122
+        echo "Adding Column $field to $mod->table_name"."_cstm<br>";
123
+        if (!$simulate)
124
+            $mod->custom_fields->add_existing_custom_field($field);
125
+    }
126 126
 
127 127
 }
128 128
 
129 129
 DynamicField :: deleteCache();
130 130
 echo '<br>Done<br>';
131 131
 if ($simulate) {
132
-	echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';
132
+    echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';
133 133
 }
134 134
 ?>
135 135
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Administration/callJSRepair.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
                 ConcatenateFiles("$from");
76 76
     
77 77
             }elseif($_REQUEST['js_admin_repair'] == 'repair'){
78
-             //should compress existing javascript (including changes done) without overwriting original source files
78
+                //should compress existing javascript (including changes done) without overwriting original source files
79 79
                 BackUpAndCompressScriptFiles("$from","",false);
80 80
                 ConcatenateFiles("$from");        
81 81
             }
Please login to merge, or discard this patch.
modules/Administration/RebuildDashlets.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $silent = isset($_REQUEST['silent']) ? true : false;
43 43
 if(is_admin($current_user)){
44 44
     global $mod_strings;
45
-	if (!$silent) { echo $mod_strings['LBL_REBUILD_DASHLETS_DESC']; }
45
+    if (!$silent) { echo $mod_strings['LBL_REBUILD_DASHLETS_DESC']; }
46 46
     if(is_file($cachedfile = sugar_cached('dashlets/dashlets.php'))) {
47 47
         unlink($cachedfile);
48 48
     }
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
     $dc = new DashletCacheBuilder();
52 52
     $dc->buildCache();
53
-   if( !$silent ) echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS'];
53
+    if( !$silent ) echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS'];
54 54
 }
55 55
 else{
56
-	sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
56
+    sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
57 57
 }
58 58
 ?>
59 59
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Administration/updateclass.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 require_once("include/utils/sugar_file_utils.php");
44 44
 
45 45
 foreach ($beanFiles as $classname => $filename){ 
46
-	if (file_exists($filename)){
47
-		// Rename the class and its constructor adding SugarCore at the beginning  (Ex: class SugarCoreCall)
48
-		$handle = file_get_contents($filename);
46
+    if (file_exists($filename)){
47
+        // Rename the class and its constructor adding SugarCore at the beginning  (Ex: class SugarCoreCall)
48
+        $handle = file_get_contents($filename);
49 49
         $patterns = array ('/class '.$classname.'/','/function '.$classname.'/');
50 50
         $replace = array ('class SugarCore'.$classname,'function SugarCore'.$classname);
51
-		$data = preg_replace($patterns,$replace, $handle);
52
-		sugar_file_put_contents($filename,$data);
51
+        $data = preg_replace($patterns,$replace, $handle);
52
+        sugar_file_put_contents($filename,$data);
53 53
 		
54
-		// Rename the SugarBean file into SugarCore.SugarBean (Ex: SugarCore.Call.php)
55
-		$pos=strrpos($filename,"/");
56
-		$newfilename=substr_replace($filename, 'SugarCore.', $pos+1, 0);
57
-		sugar_rename($filename,$newfilename);
54
+        // Rename the SugarBean file into SugarCore.SugarBean (Ex: SugarCore.Call.php)
55
+        $pos=strrpos($filename,"/");
56
+        $newfilename=substr_replace($filename, 'SugarCore.', $pos+1, 0);
57
+        sugar_rename($filename,$newfilename);
58 58
 		
59
-		//Create a new SugarBean that extends CoreBean
60
-		$fileHandle = sugar_fopen($filename, 'w') ;
59
+        //Create a new SugarBean that extends CoreBean
60
+        $fileHandle = sugar_fopen($filename, 'w') ;
61 61
 $newclass = <<<FABRICE
62 62
 <?php
63 63
 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 }
111 111
 ?>
112 112
 FABRICE;
113
-		fwrite($fileHandle, $newclass);
114
-		fclose($fileHandle);
115
-	}
113
+        fwrite($fileHandle, $newclass);
114
+        fclose($fileHandle);
115
+    }
116 116
 }
117 117
 ?>
118 118
\ No newline at end of file
Please login to merge, or discard this patch.
modules/Administration/ImportCustomFieldStructure.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 }
44 44
 
45 45
 if (empty($_FILES)) {
46
-	echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_DESC'];
47
-	echo <<<EOQ
46
+    echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_DESC'];
47
+    echo <<<EOQ
48 48
 <br>
49 49
 <br>
50 50
 <form enctype="multipart/form-data" action="index.php" method="POST">
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         if (trim($line) == 'DONE') {
65 65
             $fmd->new_with_id = true;
66 66
             echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_ADDING'] . ':' . $fmd->custom_module . '-' .
67
-                 $fmd->name . '<br>';
67
+                    $fmd->name . '<br>';
68 68
             $fmd->db->query("DELETE FROM $fmd->table_name WHERE id=".$fmd->db->quoted($fmd->id));
69 69
             $fmd->save(false);
70 70
             $fmd = BeanFactory::getBean('EditCustomFields');
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
             }
81 81
         }
82 82
     }
83
-	$_REQUEST['run'] = true;
84
-	$result = $fmd->db->query("SELECT count(*) field_count FROM $fmd->table_name");
85
-	$row = $fmd->db->fetchByAssoc($result);
86
-	echo 'Total Custom Fields :' . $row['field_count'] . '<br>';
87
-	include('modules/Administration/UpgradeFields.php');
83
+    $_REQUEST['run'] = true;
84
+    $result = $fmd->db->query("SELECT count(*) field_count FROM $fmd->table_name");
85
+    $row = $fmd->db->fetchByAssoc($result);
86
+    echo 'Total Custom Fields :' . $row['field_count'] . '<br>';
87
+    include('modules/Administration/UpgradeFields.php');
88 88
 }
Please login to merge, or discard this patch.
modules/Administration/SugarSpriteBuilder.php 1 patch
Indentation   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -43,49 +43,49 @@  discard block
 block discarded – undo
43 43
 
44 44
 class SugarSpriteBuilder
45 45
 {
46
-	var $isAvailable = false;
47
-	var $silentRun = false;
46
+    var $isAvailable = false;
47
+    var $silentRun = false;
48 48
     var $fromSilentUpgrade = false;
49 49
     var $writeToUpgradeLog = false;
50 50
 
51
-	var $debug = false;
52
-	var $fileName = 'sprites';
53
-	var $cssMinify = true;
51
+    var $debug = false;
52
+    var $fileName = 'sprites';
53
+    var $cssMinify = true;
54 54
 
55
-	// class supported image types
56
-	var $supportedTypeMap = array(
57
-		IMG_GIF => IMAGETYPE_GIF,
58
-		IMG_JPG => IMAGETYPE_JPEG,
59
-		IMG_PNG => IMAGETYPE_PNG,
60
-	);
55
+    // class supported image types
56
+    var $supportedTypeMap = array(
57
+        IMG_GIF => IMAGETYPE_GIF,
58
+        IMG_JPG => IMAGETYPE_JPEG,
59
+        IMG_PNG => IMAGETYPE_PNG,
60
+    );
61 61
 
62
-	// sprite settings
63
-	var $pngCompression = 9;
64
-	var $pngFilter = PNG_NO_FILTER;
65
-	var $maxWidth = 75;
66
-	var $maxHeight = 75;
67
-	var $rowCnt = 30;
62
+    // sprite settings
63
+    var $pngCompression = 9;
64
+    var $pngFilter = PNG_NO_FILTER;
65
+    var $maxWidth = 75;
66
+    var $maxHeight = 75;
67
+    var $rowCnt = 30;
68 68
 
69
-	// processed image types
70
-	var $imageTypes = array();
69
+    // processed image types
70
+    var $imageTypes = array();
71 71
 
72
-	// source files
73
-	var $spriteSrc = array();
74
-	var $spriteRepeat = array();
72
+    // source files
73
+    var $spriteSrc = array();
74
+    var $spriteRepeat = array();
75 75
 
76
-	// sprite resource images
77
-	var $spriteImg;
76
+    // sprite resource images
77
+    var $spriteImg;
78 78
 
79
-	// sprite_config collection
80
-	var $sprites_config = array();
79
+    // sprite_config collection
80
+    var $sprites_config = array();
81 81
 
82 82
 
83 83
     public function __construct()
84 84
     {
85
-		// check if we have gd installed
86
-		if(function_exists('imagecreatetruecolor'))
85
+        // check if we have gd installed
86
+        if(function_exists('imagecreatetruecolor'))
87 87
         {
88
-			$this->isAvailable = true;
88
+            $this->isAvailable = true;
89 89
             foreach($this->supportedTypeMap as $gd_bit => $imagetype)
90 90
             {
91 91
                 if(imagetypes() & $gd_bit) {
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
                     $this->imageTypes[$imagetype] = $gd_bit;
94 94
                 }
95 95
             }
96
-		}
96
+        }
97 97
 
98 98
         if(function_exists('logThis') && isset($GLOBALS['path']))
99 99
         {
100 100
             $this->writeToUpgradeLog = true;
101 101
         }
102
-	}
102
+    }
103 103
 
104 104
 
105 105
     /**
@@ -109,80 +109,80 @@  discard block
 block discarded – undo
109 109
      * @param $name String value of the sprite name
110 110
      * @param $dir String value of the directory associated with the sprite entry
111 111
      */
112
-	public function addDirectory($name, $dir) {
112
+    public function addDirectory($name, $dir) {
113 113
 
114
-		// sprite namespace
115
-		if(!array_key_exists($name, $this->spriteSrc))
114
+        // sprite namespace
115
+        if(!array_key_exists($name, $this->spriteSrc))
116 116
         {
117
-			$this->spriteSrc[$name] = array();
118
-		}
117
+            $this->spriteSrc[$name] = array();
118
+        }
119 119
 
120
-		// add files from directory
121
-		$this->spriteSrc[$name][$dir] = $this->getFileList($dir);
122
-	}
120
+        // add files from directory
121
+        $this->spriteSrc[$name][$dir] = $this->getFileList($dir);
122
+    }
123 123
 
124
-	/**
124
+    /**
125 125
      * getFileList
126 126
      *
127 127
      * This method processes files in a directory and adds them to the sprites array
128 128
      * @param $dir String value of the directory to scan for image files in
129 129
      */
130
-	private function getFileList($dir) {
131
-		$list = array();
132
-		if(is_dir($dir)) {
133
-			if($dh = opendir($dir)) {
130
+    private function getFileList($dir) {
131
+        $list = array();
132
+        if(is_dir($dir)) {
133
+            if($dh = opendir($dir)) {
134 134
 
135
-				// optional sprites_config.php file
136
-				$this->loadSpritesConfig($dir);
135
+                // optional sprites_config.php file
136
+                $this->loadSpritesConfig($dir);
137 137
 
138
-			    while (($file = readdir($dh)) !== false)
138
+                while (($file = readdir($dh)) !== false)
139 139
                 {
140
-					if ($file != "." && $file != ".." && $file != "sprites_config.php")
140
+                    if ($file != "." && $file != ".." && $file != "sprites_config.php")
141 141
                     {
142 142
 
143
-						// file info & check supported image format
144
-						if($info = $this->getFileInfo($dir, $file)) {
143
+                        // file info & check supported image format
144
+                        if($info = $this->getFileInfo($dir, $file)) {
145 145
 
146
-							// skip excluded files
147
-							if(isset($this->sprites_config[$dir]['exclude']) && array_search($file, $this->sprites_config[$dir]['exclude']) !== false)
146
+                            // skip excluded files
147
+                            if(isset($this->sprites_config[$dir]['exclude']) && array_search($file, $this->sprites_config[$dir]['exclude']) !== false)
148 148
                             {
149 149
                                 global $mod_strings;
150 150
                                 $msg = string_format($mod_strings['LBL_SPRITES_EXCLUDING_FILE'], array("{$dir}/{$file}"));
151
-								$GLOBALS['log']->debug($msg);
151
+                                $GLOBALS['log']->debug($msg);
152 152
                                 $this->logMessage($msg);
153
-							} else {
154
-								// repeatable sprite ?
155
-								$isRepeat = false;
153
+                            } else {
154
+                                // repeatable sprite ?
155
+                                $isRepeat = false;
156 156
 
157
-								if(isset($this->sprites_config[$dir]['repeat']))
157
+                                if(isset($this->sprites_config[$dir]['repeat']))
158 158
                                 {
159
-									foreach($this->sprites_config[$dir]['repeat'] as $repeat)
159
+                                    foreach($this->sprites_config[$dir]['repeat'] as $repeat)
160 160
                                     {
161
-										if($info['x'] == $repeat['width'] && $info['y'] == $repeat['height'])
161
+                                        if($info['x'] == $repeat['width'] && $info['y'] == $repeat['height'])
162 162
                                         {
163
-											$id = md5($repeat['width'].$repeat['height'].$repeat['direction']);
164
-											$isRepeat = true;
165
-											$this->spriteRepeat['repeat_'.$repeat['direction'].'_'.$id][$dir][$file] = $info;
166
-										}
167
-									}
168
-								}
169
-
170
-								if(!$isRepeat)
163
+                                            $id = md5($repeat['width'].$repeat['height'].$repeat['direction']);
164
+                                            $isRepeat = true;
165
+                                            $this->spriteRepeat['repeat_'.$repeat['direction'].'_'.$id][$dir][$file] = $info;
166
+                                        }
167
+                                    }
168
+                                }
169
+
170
+                                if(!$isRepeat)
171 171
                                 {
172
-									$list[$file] = $info;
172
+                                    $list[$file] = $info;
173 173
                                 }
174
-							}
175
-						} else if(preg_match('/\.(jpg|jpeg|gif|png|bmp|ico)$/i', $file)) {
174
+                            }
175
+                        } else if(preg_match('/\.(jpg|jpeg|gif|png|bmp|ico)$/i', $file)) {
176 176
                             $GLOBALS['log']->error('Unable to process image file ' . $file);
177 177
                             //$this->logMessage('Unable to process image file ' . $file);
178 178
                         }
179
-	   	     		}
180
-   		 		}
181
-			}
182
-		    closedir($dh);
183
-		}
184
-		return $list;
185
-	}
179
+                        }
180
+                    }
181
+            }
182
+            closedir($dh);
183
+        }
184
+        return $list;
185
+    }
186 186
 
187 187
 
188 188
     /**
@@ -194,19 +194,19 @@  discard block
 block discarded – undo
194 194
      *
195 195
      * @param $dir String value of the directory containing the custom sprites_config.php file
196 196
      */
197
-	private function loadSpritesConfig($dir) {
198
-		$sprites_config = array();
199
-		if(file_exists("$dir/sprites_config.php"))
197
+    private function loadSpritesConfig($dir) {
198
+        $sprites_config = array();
199
+        if(file_exists("$dir/sprites_config.php"))
200 200
         {
201
-			include("$dir/sprites_config.php");
202
-			if(count($sprites_config)) {
203
-				$this->sprites_config = array_merge($this->sprites_config, $sprites_config);
204
-			}
205
-		}
206
-	}
201
+            include("$dir/sprites_config.php");
202
+            if(count($sprites_config)) {
203
+                $this->sprites_config = array_merge($this->sprites_config, $sprites_config);
204
+            }
205
+        }
206
+    }
207 207
 
208 208
 
209
-	/**
209
+    /**
210 210
      * getFileInfo
211 211
      *
212 212
      * This is a private helper function to return attributes about an image.  If the width, height or type of the
@@ -214,44 +214,44 @@  discard block
 block discarded – undo
214 214
      *
215 215
      * @return array of file info entries containing file information (x, y, type) if image type is supported
216 216
      */
217
-	private function getFileInfo($dir, $file) {
218
-		$result = false;
219
-		$info = @getimagesize($dir.'/'.$file);
220
-		if($info) {
217
+    private function getFileInfo($dir, $file) {
218
+        $result = false;
219
+        $info = @getimagesize($dir.'/'.$file);
220
+        if($info) {
221 221
 
222
-			// supported image type ?
223
-			if(isset($this->imageTypes[$info[2]]))
222
+            // supported image type ?
223
+            if(isset($this->imageTypes[$info[2]]))
224 224
             {
225
-				$w = $info[0];
226
-				$h = $info[1];
227
-				$surface = $w * $h;
225
+                $w = $info[0];
226
+                $h = $info[1];
227
+                $surface = $w * $h;
228 228
 
229
-				// be sure we have an image size
230
-				$addSprite = false;
231
-				if($surface)
229
+                // be sure we have an image size
230
+                $addSprite = false;
231
+                if($surface)
232 232
                 {
233
-					// sprite dimensions
234
-					if($w <= $this->maxWidth && $h <= $this->maxHeight)
233
+                    // sprite dimensions
234
+                    if($w <= $this->maxWidth && $h <= $this->maxHeight)
235 235
                     {
236
-						$addSprite = true;
237
-					}
238
-				}
236
+                        $addSprite = true;
237
+                    }
238
+                }
239 239
 
240
-				if($addSprite)
240
+                if($addSprite)
241 241
                 {
242
-					$result = array();
243
-					$result['x'] = $w;
244
-					$result['y'] = $h;
245
-					$result['type'] = $info[2];
246
-				}
247
-			} else {
242
+                    $result = array();
243
+                    $result['x'] = $w;
244
+                    $result['y'] = $h;
245
+                    $result['type'] = $info[2];
246
+                }
247
+            } else {
248 248
                 $msg = "Skipping unsupported image file type ({$info[2]}) for file {$file}";
249 249
                 $GLOBALS['log']->error($msg);
250 250
                 $this->logMessage($msg."\n");
251 251
             }
252
-		}
253
-		return $result;
254
-	}
252
+        }
253
+        return $result;
254
+    }
255 255
 
256 256
 
257 257
     /**
@@ -261,220 +261,220 @@  discard block
 block discarded – undo
261 261
      *
262 262
      * @return $result boolean value indicating whether or not sprites were created
263 263
      */
264
-	public function createSprites() {
264
+    public function createSprites() {
265 265
 
266 266
         global $mod_strings;
267 267
 
268
-		if(!$this->isAvailable)
268
+        if(!$this->isAvailable)
269 269
         {
270
-			if(!$this->silentRun)
270
+            if(!$this->silentRun)
271 271
             {
272 272
                 $msg = $mod_strings['LBL_SPRITES_NOT_SUPPORTED'];
273 273
                 $GLOBALS['log']->warn($msg);
274 274
                 $this->logMessage($msg);
275 275
             }
276
-			return false;
277
-		}
276
+            return false;
277
+        }
278 278
 
279
-		// add repeatable sprites
280
-		if(count($this->spriteRepeat))
279
+        // add repeatable sprites
280
+        if(count($this->spriteRepeat))
281 281
         {
282
-			$this->spriteSrc = array_merge($this->spriteSrc, $this->spriteRepeat);
282
+            $this->spriteSrc = array_merge($this->spriteSrc, $this->spriteRepeat);
283 283
         }
284 284
 
285
-		foreach($this->spriteSrc as $name => $dirs)
285
+        foreach($this->spriteSrc as $name => $dirs)
286 286
         {
287
-			if(!$this->silentRun)
287
+            if(!$this->silentRun)
288 288
             {
289 289
                 $msg = string_format($mod_strings['LBL_SPRITES_CREATING_NAMESPACE'], array($name));
290 290
                 $GLOBALS['log']->debug($msg);
291
-				$this->logMessage($msg);
291
+                $this->logMessage($msg);
292 292
             }
293 293
 
294
-			// setup config for sprite placement algorithm
295
-			if(substr($name, 0, 6) == 'repeat')
294
+            // setup config for sprite placement algorithm
295
+            if(substr($name, 0, 6) == 'repeat')
296 296
             {
297
-				$isRepeat = true;
297
+                $isRepeat = true;
298 298
                 $type = substr($name, 7, 10) == 'horizontal' ? 'horizontal' : 'vertical';
299
-				$config = array(
300
-					'type' => $type,
301
-				);
302
-			} else {
303
-				$isRepeat = false;
304
-				$config = array(
305
-					'type' => 'boxed',
306
-					'width' => $this->maxWidth,
307
-					'height' => $this->maxHeight,
308
-					'rowcnt' => $this->rowCnt,
309
-				);
310
-			}
311
-
312
-			// use separate class to arrange the images
313
-			$sp = new SpritePlacement($dirs, $config);
314
-			$sp->processSprites();
315
-
316
-			//if(! $this->silentRun)
317
-			//	echo " (size {$sp->width()}x{$sp->height()})<br />";
318
-
319
-			// we need a target image size
320
-			if($sp->width() && $sp->height())
299
+                $config = array(
300
+                    'type' => $type,
301
+                );
302
+            } else {
303
+                $isRepeat = false;
304
+                $config = array(
305
+                    'type' => 'boxed',
306
+                    'width' => $this->maxWidth,
307
+                    'height' => $this->maxHeight,
308
+                    'rowcnt' => $this->rowCnt,
309
+                );
310
+            }
311
+
312
+            // use separate class to arrange the images
313
+            $sp = new SpritePlacement($dirs, $config);
314
+            $sp->processSprites();
315
+
316
+            //if(! $this->silentRun)
317
+            //	echo " (size {$sp->width()}x{$sp->height()})<br />";
318
+
319
+            // we need a target image size
320
+            if($sp->width() && $sp->height())
321 321
             {
322
-				// init sprite image
323
-				$this->initSpriteImg($sp->width(), $sp->height());
322
+                // init sprite image
323
+                $this->initSpriteImg($sp->width(), $sp->height());
324 324
 
325
-				// add sprites based upon determined coordinates
326
-				foreach($dirs as $dir => $files)
325
+                // add sprites based upon determined coordinates
326
+                foreach($dirs as $dir => $files)
327 327
                 {
328
-					if(!$this->silentRun)
328
+                    if(!$this->silentRun)
329 329
                     {
330 330
                         $msg = string_format($mod_strings['LBL_SPRITES_PROCESSING_DIR'], array($dir));
331 331
                         $GLOBALS['log']->debug($msg);
332 332
                         $this->logMessage($msg);
333 333
                     }
334 334
 
335
-					foreach($files as $file => $info)
335
+                    foreach($files as $file => $info)
336 336
                     {
337
-						if($im = $this->loadImage($dir, $file, $info['type']))
337
+                        if($im = $this->loadImage($dir, $file, $info['type']))
338 338
                         {
339
-							// coordinates
340
-							$dst_x = $sp->spriteMatrix[$dir.'/'.$file]['x'];
341
-							$dst_y = $sp->spriteMatrix[$dir.'/'.$file]['y'];
339
+                            // coordinates
340
+                            $dst_x = $sp->spriteMatrix[$dir.'/'.$file]['x'];
341
+                            $dst_y = $sp->spriteMatrix[$dir.'/'.$file]['y'];
342 342
 
343
-							imagecopy($this->spriteImg, $im, $dst_x, $dst_y, 0, 0, $info['x'], $info['y']);
344
-							imagedestroy($im);
343
+                            imagecopy($this->spriteImg, $im, $dst_x, $dst_y, 0, 0, $info['x'], $info['y']);
344
+                            imagedestroy($im);
345 345
 
346
-							if(!$this->silentRun)
346
+                            if(!$this->silentRun)
347 347
                             {
348 348
                                 $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array("{$dir}/{$file}"));
349 349
                                 $GLOBALS['log']->debug($msg);
350 350
                                 $this->logMessage($msg);
351 351
                             }
352
-						}
353
-					}
354
-				}
352
+                        }
353
+                    }
354
+                }
355 355
 
356
-				// dir & filenames
357
-				if($isRepeat)
356
+                // dir & filenames
357
+                if($isRepeat)
358 358
                 {
359
-					$outputDir = sugar_cached("sprites/Repeatable");
360
-					$spriteFileName = "{$name}.png";
361
-					$cssFileName = "{$this->fileName}.css";
362
-					$metaFileName = "{$this->fileName}.meta.php";
363
-					$nameSpace = "Repeatable";
364
-				} else {
365
-					$outputDir = sugar_cached("sprites/$name");
366
-					$spriteFileName = "{$this->fileName}.png";
367
-					$cssFileName = "{$this->fileName}.css";
368
-					$metaFileName = "{$this->fileName}.meta.php";
369
-					$nameSpace = "{$name}";
370
-				}
371
-
372
-				// directory structure
373
-				if(!is_dir(sugar_cached("sprites/$nameSpace")))
359
+                    $outputDir = sugar_cached("sprites/Repeatable");
360
+                    $spriteFileName = "{$name}.png";
361
+                    $cssFileName = "{$this->fileName}.css";
362
+                    $metaFileName = "{$this->fileName}.meta.php";
363
+                    $nameSpace = "Repeatable";
364
+                } else {
365
+                    $outputDir = sugar_cached("sprites/$name");
366
+                    $spriteFileName = "{$this->fileName}.png";
367
+                    $cssFileName = "{$this->fileName}.css";
368
+                    $metaFileName = "{$this->fileName}.meta.php";
369
+                    $nameSpace = "{$name}";
370
+                }
371
+
372
+                // directory structure
373
+                if(!is_dir(sugar_cached("sprites/$nameSpace")))
374 374
                 {
375
-					sugar_mkdir(sugar_cached("sprites/$nameSpace"), 0775, true);
375
+                    sugar_mkdir(sugar_cached("sprites/$nameSpace"), 0775, true);
376 376
                 }
377 377
 
378
-				// save sprite image
379
-				imagepng($this->spriteImg, "$outputDir/$spriteFileName", $this->pngCompression, $this->pngFilter);
380
-				imagedestroy($this->spriteImg);
378
+                // save sprite image
379
+                imagepng($this->spriteImg, "$outputDir/$spriteFileName", $this->pngCompression, $this->pngFilter);
380
+                imagedestroy($this->spriteImg);
381 381
 
382
-				/* generate css & metadata */
382
+                /* generate css & metadata */
383 383
 
384
-				$head = '';
385
-				$body = '';
386
-				$metadata = '';
384
+                $head = '';
385
+                $body = '';
386
+                $metadata = '';
387 387
 
388
-				foreach($sp->spriteSrc as $id => $info)
388
+                foreach($sp->spriteSrc as $id => $info)
389 389
                 {
390
-					// sprite id
391
-					$hash_id = md5($id);
390
+                    // sprite id
391
+                    $hash_id = md5($id);
392 392
 
393
-					// header
394
-					$head .= "span.spr_{$hash_id},\n";
393
+                    // header
394
+                    $head .= "span.spr_{$hash_id},\n";
395 395
 
396
-					// image size
397
-					$w = $info['x'];
398
-					$h = $info['y'];
396
+                    // image size
397
+                    $w = $info['x'];
398
+                    $h = $info['y'];
399 399
 
400
-					// image offset
401
-					$offset_x = $sp->spriteMatrix[$id]['x'];
402
-					$offset_y = $sp->spriteMatrix[$id]['y'];
400
+                    // image offset
401
+                    $offset_x = $sp->spriteMatrix[$id]['x'];
402
+                    $offset_y = $sp->spriteMatrix[$id]['y'];
403 403
 
404
-					// sprite css
405
-					$body .= "/* {$id} */
404
+                    // sprite css
405
+                    $body .= "/* {$id} */
406 406
 span.spr_{$hash_id} {
407 407
 width: {$w}px;
408 408
 height: {$h}px;
409 409
 background-position: -{$offset_x}px -{$offset_y}px;
410 410
 }\n";
411 411
 
412
-					$metadata .= '$sprites["'.$id.'"] = array ("class"=>"'.$hash_id.'","width"=>"'.$w.'","height"=>"'.$h.'");'."\n";
413
-				}
412
+                    $metadata .= '$sprites["'.$id.'"] = array ("class"=>"'.$hash_id.'","width"=>"'.$w.'","height"=>"'.$h.'");'."\n";
413
+                }
414 414
 
415
-				// common css header
415
+                // common css header
416 416
                 require_once('include/utils.php');
417 417
                 $bg_path = getVersionedPath('index.php').'&entryPoint=getImage&imageName='.$spriteFileName.'&spriteNamespace='.$nameSpace;
418
-				$head = rtrim($head, "\n,")." {background: url('../../../{$bg_path}'); no-repeat;display:inline-block;}\n";
418
+                $head = rtrim($head, "\n,")." {background: url('../../../{$bg_path}'); no-repeat;display:inline-block;}\n";
419 419
 
420
-				// append mode for repeatable sprites
420
+                // append mode for repeatable sprites
421 421
                 $fileMode = $isRepeat ? 'a' : 'w';
422 422
 
423
-				// save css
424
-				$css_content = "\n/* autogenerated sprites - $name */\n".$head.$body;
425
-				if($this->cssMinify)
423
+                // save css
424
+                $css_content = "\n/* autogenerated sprites - $name */\n".$head.$body;
425
+                if($this->cssMinify)
426 426
                 {
427
-					$css_content = cssmin::minify($css_content);
427
+                    $css_content = cssmin::minify($css_content);
428 428
                 }
429
-				$fh = fopen("$outputDir/$cssFileName", $fileMode);
430
-				fwrite($fh, $css_content);
431
-				fclose($fh);
432
-
433
-				/* save metadata */
434
-				$add_php_tag = (file_exists("$outputDir/$metaFileName") && $isRepeat) ? false : true;
435
-				$fh = fopen("$outputDir/$metaFileName", $fileMode);
436
-				if($add_php_tag)
429
+                $fh = fopen("$outputDir/$cssFileName", $fileMode);
430
+                fwrite($fh, $css_content);
431
+                fclose($fh);
432
+
433
+                /* save metadata */
434
+                $add_php_tag = (file_exists("$outputDir/$metaFileName") && $isRepeat) ? false : true;
435
+                $fh = fopen("$outputDir/$metaFileName", $fileMode);
436
+                if($add_php_tag)
437 437
                 {
438
-					fwrite($fh, '<?php');
438
+                    fwrite($fh, '<?php');
439 439
                 }
440
-				fwrite($fh, "\n/* sprites metadata - $name */\n");
441
-				fwrite($fh, $metadata."\n");
442
-				fclose($fh);
440
+                fwrite($fh, "\n/* sprites metadata - $name */\n");
441
+                fwrite($fh, $metadata."\n");
442
+                fclose($fh);
443 443
 
444
-			// if width & height
445
-			} else {
444
+            // if width & height
445
+            } else {
446 446
 
447
-				if(!$this->silentRun)
447
+                if(!$this->silentRun)
448 448
                 {
449 449
                     $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array($name));
450 450
                     $GLOBALS['log']->debug($msg);
451 451
                     $this->logMessage($msg);
452 452
                 }
453 453
 
454
-			}
454
+            }
455 455
 
456
-		}
457
-		return true;
458
-	}
456
+        }
457
+        return true;
458
+    }
459 459
 
460 460
 
461
-	/**
461
+    /**
462 462
      * initSpriteImg
463 463
      *
464 464
      * @param w int value representing width of sprite
465 465
      * @param h int value representing height of sprite
466 466
      * Private function to initialize creating the sprite canvas image
467 467
      */
468
-	private function initSpriteImg($w, $h) {
469
-		$this->spriteImg = imagecreatetruecolor($w,$h);
470
-		$transparent = imagecolorallocatealpha($this->spriteImg, 0, 0, 0, 127);
471
-		imagefill($this->spriteImg, 0, 0, $transparent);
472
-		imagealphablending($this->spriteImg, false);
473
-		imagesavealpha($this->spriteImg, true);
474
-	}
468
+    private function initSpriteImg($w, $h) {
469
+        $this->spriteImg = imagecreatetruecolor($w,$h);
470
+        $transparent = imagecolorallocatealpha($this->spriteImg, 0, 0, 0, 127);
471
+        imagefill($this->spriteImg, 0, 0, $transparent);
472
+        imagealphablending($this->spriteImg, false);
473
+        imagesavealpha($this->spriteImg, true);
474
+    }
475 475
 
476 476
 
477
-	/**
477
+    /**
478 478
      * loadImage
479 479
      *
480 480
      * private function to load image resources
@@ -484,19 +484,19 @@  discard block
 block discarded – undo
484 484
      * @param $type String value of the file type (IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)
485 485
      *
486 486
      */
487
-	private function loadImage($dir, $file, $type) {
488
-		$path_file = $dir.'/'.$file;
489
-		switch($type) {
490
-			case IMAGETYPE_GIF:
491
-				return imagecreatefromgif($path_file);
492
-			case IMAGETYPE_JPEG:
493
-				return imagecreatefromjpeg($path_file);
494
-			case IMAGETYPE_PNG:
495
-				return imagecreatefrompng($path_file);
496
-			default:
497
-				return false;
498
-		}
499
-	}
487
+    private function loadImage($dir, $file, $type) {
488
+        $path_file = $dir.'/'.$file;
489
+        switch($type) {
490
+            case IMAGETYPE_GIF:
491
+                return imagecreatefromgif($path_file);
492
+            case IMAGETYPE_JPEG:
493
+                return imagecreatefromjpeg($path_file);
494
+            case IMAGETYPE_PNG:
495
+                return imagecreatefrompng($path_file);
496
+            default:
497
+                return false;
498
+        }
499
+    }
500 500
 
501 501
     /**
502 502
      * private logMessage
@@ -527,17 +527,17 @@  discard block
 block discarded – undo
527 527
 class SpritePlacement
528 528
 {
529 529
 
530
-	// occupied space
531
-	var $spriteMatrix = array();
530
+    // occupied space
531
+    var $spriteMatrix = array();
532 532
 
533
-	// minimum surface
534
-	var $minSurface = 0;
533
+    // minimum surface
534
+    var $minSurface = 0;
535 535
 
536
-	// sprite src (flattened array)
537
-	var $spriteSrc = array();
536
+    // sprite src (flattened array)
537
+    var $spriteSrc = array();
538 538
 
539
-	// placement config array
540
-	/*
539
+    // placement config array
540
+    /*
541 541
 		type = 	boxed
542 542
 				horizontal
543 543
 				vertical
@@ -548,99 +548,99 @@  discard block
 block discarded – undo
548 548
 				-> rowcnt
549 549
 
550 550
 	*/
551
-	var $config = array();
552
-
553
-	function __construct($spriteSrc, $config) {
554
-
555
-		// convert spriteSrc to flat array
556
-		foreach($spriteSrc as $dir => $files) {
557
-			foreach($files as $file => $info) {
558
-				// use full path as identifier
559
-				$full_path = $dir.'/'.$file;
560
-				$this->spriteSrc[$full_path] = $info;
561
-			}
562
-		}
563
-
564
-		$this->config = $config;
565
-	}
566
-
567
-	function processSprites() {
568
-
569
-		foreach($this->spriteSrc as $id => $info) {
570
-
571
-			// dimensions
572
-			$x = $info['x'];
573
-			$y = $info['y'];
574
-
575
-			// update min surface
576
-			$this->minSurface += $x * $y;
577
-
578
-			// get coordinates where to add this sprite
579
-			if($coor = $this->addSprite($x, $y)) {
580
-				$this->spriteMatrix[$id] = $coor;
581
-			}
582
-		}
583
-	}
584
-
585
-	// returns x/y coordinates to fit the sprite
586
-	function addSprite($w, $h) {
587
-		$result = false;
588
-
589
-		switch($this->config['type']) {
590
-
591
-			// boxed
592
-			case 'boxed':
593
-
594
-				$spriteX = $this->config['width'];
595
-				$spriteY = $this->config['height'];
596
-				$spriteCnt = count($this->spriteMatrix) + 1;
597
-				$y = ceil($spriteCnt / $this->config['rowcnt']);
598
-				$x = $spriteCnt - (($y - 1) * $this->config['rowcnt']);
599
-				$result = array(
600
-					'x' => ($x * $spriteX) + 1 - $spriteX,
601
-					'y' => ($y * $spriteY) + 1 - $spriteY);
602
-
603
-				break;
604
-
605
-			// horizontal -> align vertically
606
-			case 'horizontal':
607
-				$result = array('x' => 1, 'y' => $this->height() + 1);
608
-				break;
609
-
610
-			// vertical -> align horizontally
611
-			case 'vertical':
612
-				$result = array('x' => $this->width() + 1, 'y' => 1);
613
-				break;
614
-
615
-			default:
616
-				$GLOBALS['log']->warn(__CLASS__.": Unknown sprite placement algorithm -> {$this->config['type']}");
617
-				break;
618
-		}
619
-
620
-		return $result;
621
-	}
622
-
623
-	// calculate total width
624
-	function width() {
625
-		return $this->getMaxAxis('x');
626
-	}
627
-
628
-	// calculate total height
629
-	function height() {
630
-		return $this->getMaxAxis('y');
631
-	}
632
-
633
-	// helper function to get highest axis value
634
-	function getMaxAxis($axis) {
635
-		$val = 0;
636
-		foreach($this->spriteMatrix as $id => $coor) {
637
-			$new_val = $coor[$axis] + $this->spriteSrc[$id][$axis] - 1;
638
-			if($new_val > $val) {
639
-				$val = $new_val;
640
-			}
641
-		}
642
-		return $val;
643
-	}
551
+    var $config = array();
552
+
553
+    function __construct($spriteSrc, $config) {
554
+
555
+        // convert spriteSrc to flat array
556
+        foreach($spriteSrc as $dir => $files) {
557
+            foreach($files as $file => $info) {
558
+                // use full path as identifier
559
+                $full_path = $dir.'/'.$file;
560
+                $this->spriteSrc[$full_path] = $info;
561
+            }
562
+        }
563
+
564
+        $this->config = $config;
565
+    }
566
+
567
+    function processSprites() {
568
+
569
+        foreach($this->spriteSrc as $id => $info) {
570
+
571
+            // dimensions
572
+            $x = $info['x'];
573
+            $y = $info['y'];
574
+
575
+            // update min surface
576
+            $this->minSurface += $x * $y;
577
+
578
+            // get coordinates where to add this sprite
579
+            if($coor = $this->addSprite($x, $y)) {
580
+                $this->spriteMatrix[$id] = $coor;
581
+            }
582
+        }
583
+    }
584
+
585
+    // returns x/y coordinates to fit the sprite
586
+    function addSprite($w, $h) {
587
+        $result = false;
588
+
589
+        switch($this->config['type']) {
590
+
591
+            // boxed
592
+            case 'boxed':
593
+
594
+                $spriteX = $this->config['width'];
595
+                $spriteY = $this->config['height'];
596
+                $spriteCnt = count($this->spriteMatrix) + 1;
597
+                $y = ceil($spriteCnt / $this->config['rowcnt']);
598
+                $x = $spriteCnt - (($y - 1) * $this->config['rowcnt']);
599
+                $result = array(
600
+                    'x' => ($x * $spriteX) + 1 - $spriteX,
601
+                    'y' => ($y * $spriteY) + 1 - $spriteY);
602
+
603
+                break;
604
+
605
+            // horizontal -> align vertically
606
+            case 'horizontal':
607
+                $result = array('x' => 1, 'y' => $this->height() + 1);
608
+                break;
609
+
610
+            // vertical -> align horizontally
611
+            case 'vertical':
612
+                $result = array('x' => $this->width() + 1, 'y' => 1);
613
+                break;
614
+
615
+            default:
616
+                $GLOBALS['log']->warn(__CLASS__.": Unknown sprite placement algorithm -> {$this->config['type']}");
617
+                break;
618
+        }
619
+
620
+        return $result;
621
+    }
622
+
623
+    // calculate total width
624
+    function width() {
625
+        return $this->getMaxAxis('x');
626
+    }
627
+
628
+    // calculate total height
629
+    function height() {
630
+        return $this->getMaxAxis('y');
631
+    }
632
+
633
+    // helper function to get highest axis value
634
+    function getMaxAxis($axis) {
635
+        $val = 0;
636
+        foreach($this->spriteMatrix as $id => $coor) {
637
+            $new_val = $coor[$axis] + $this->spriteSrc[$id][$axis] - 1;
638
+            if($new_val > $val) {
639
+                $val = $new_val;
640
+            }
641
+        }
642
+        return $val;
643
+    }
644 644
 }
645 645
 
646 646
 ?>
Please login to merge, or discard this patch.
modules/Administration/UpgradeWizardCommon.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -69,24 +69,24 @@  discard block
 block discarded – undo
69 69
 
70 70
 if(!defined('SUGARCRM_PRE_INSTALL_FILE'))
71 71
 {
72
-	define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
73
-	define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
74
-	define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
75
-	define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
72
+    define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
73
+    define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
74
+    define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
75
+    define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
76 76
 }
77 77
 $script_files = array(
78
-	"pre-install" => constant('SUGARCRM_PRE_INSTALL_FILE'),
79
-	"post-install" => constant('SUGARCRM_POST_INSTALL_FILE'),
80
-	"pre-uninstall" => constant('SUGARCRM_PRE_UNINSTALL_FILE'),
81
-	"post-uninstall" => constant('SUGARCRM_POST_UNINSTALL_FILE'),
78
+    "pre-install" => constant('SUGARCRM_PRE_INSTALL_FILE'),
79
+    "post-install" => constant('SUGARCRM_POST_INSTALL_FILE'),
80
+    "pre-uninstall" => constant('SUGARCRM_PRE_UNINSTALL_FILE'),
81
+    "post-uninstall" => constant('SUGARCRM_POST_UNINSTALL_FILE'),
82 82
 );
83 83
 
84 84
 
85 85
 
86 86
 function extractFile( $zip_file, $file_in_zip ){
87 87
     global $base_tmp_upgrade_dir;
88
-	if(empty($base_tmp_upgrade_dir)){
89
-    	$base_tmp_upgrade_dir   = sugar_cached("upgrades/temp");
88
+    if(empty($base_tmp_upgrade_dir)){
89
+        $base_tmp_upgrade_dir   = sugar_cached("upgrades/temp");
90 90
     }
91 91
     $my_zip_dir = mk_temp_dir( $base_tmp_upgrade_dir );
92 92
     register_shutdown_function('rmdir_recursive', $my_zip_dir);
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 }
147 147
 
148 148
 function getUITextForType( $type ){
149
-	$type = 'LBL_UW_TYPE_'.strtoupper($type);
150
-	global $mod_strings;
151
-	return $mod_strings[$type];
149
+    $type = 'LBL_UW_TYPE_'.strtoupper($type);
150
+    global $mod_strings;
151
+    return $mod_strings[$type];
152 152
 }
153 153
 
154 154
 function getUITextForMode( $mode ){
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     global $subdirs;
163 163
     global $sugar_version;
164 164
     global $sugar_flavor;
165
-	global $mod_strings;
165
+    global $mod_strings;
166 166
 
167 167
     if( !isset($manifest['type']) ){
168 168
         die($mod_strings['ERROR_MANIFEST_TYPE']);
@@ -211,41 +211,41 @@  discard block
 block discarded – undo
211 211
 }
212 212
 
213 213
 function getDiffFiles($unzip_dir, $install_file, $is_install = true, $previous_version = ''){
214
-	//require_once($unzip_dir . '/manifest.php');
215
-	global $installdefs;
216
-	if(!empty($previous_version)){
217
-		//check if the upgrade path exists
218
-		if(!empty($upgrade_manifest)){
219
-			if(!empty($upgrade_manifest['upgrade_paths'])){
220
-				if(!empty($upgrade_manifest['upgrade_paths'][$previous_version])){
221
-					$installdefs = 	$upgrade_manifest['upgrade_paths'][$previous_version];
222
-				}
223
-			}//fi
224
-		}//fi
225
-	}//fi
226
-	$modified_files = array();
227
-	if(!empty($installdefs['copy'])){
228
-		foreach($installdefs['copy'] as $cp){
229
-			$cp['to'] = clean_path(str_replace('<basepath>', $unzip_dir, $cp['to']));
230
-			$restore_path = remove_file_extension(urldecode($install_file))."-restore/";
231
-			$backup_path = clean_path($restore_path.$cp['to'] );
232
-			//check if this file exists in the -restore directory
233
-			if(file_exists($backup_path)){
234
-				//since the file exists, then we want do an md5 of the install version and the file system version
235
-				$from = $backup_path;
236
-				$needle = $restore_path;
237
-				if(!$is_install){
238
-					$from = str_replace('<basepath>', $unzip_dir, $cp['from']);
239
-					$needle = $unzip_dir;
240
-				}
241
-				$files_found = md5DirCompare($from.'/', $cp['to'].'/', array('.svn'), false);
242
-				if(count($files_found > 0)){
243
-					foreach($files_found as $key=>$value){
244
-						$modified_files[] = str_replace($needle, '', $key);
245
-					}
246
-				}
247
-			}//fi
248
-		}//rof
249
-	}//fi
250
-	return $modified_files;
214
+    //require_once($unzip_dir . '/manifest.php');
215
+    global $installdefs;
216
+    if(!empty($previous_version)){
217
+        //check if the upgrade path exists
218
+        if(!empty($upgrade_manifest)){
219
+            if(!empty($upgrade_manifest['upgrade_paths'])){
220
+                if(!empty($upgrade_manifest['upgrade_paths'][$previous_version])){
221
+                    $installdefs = 	$upgrade_manifest['upgrade_paths'][$previous_version];
222
+                }
223
+            }//fi
224
+        }//fi
225
+    }//fi
226
+    $modified_files = array();
227
+    if(!empty($installdefs['copy'])){
228
+        foreach($installdefs['copy'] as $cp){
229
+            $cp['to'] = clean_path(str_replace('<basepath>', $unzip_dir, $cp['to']));
230
+            $restore_path = remove_file_extension(urldecode($install_file))."-restore/";
231
+            $backup_path = clean_path($restore_path.$cp['to'] );
232
+            //check if this file exists in the -restore directory
233
+            if(file_exists($backup_path)){
234
+                //since the file exists, then we want do an md5 of the install version and the file system version
235
+                $from = $backup_path;
236
+                $needle = $restore_path;
237
+                if(!$is_install){
238
+                    $from = str_replace('<basepath>', $unzip_dir, $cp['from']);
239
+                    $needle = $unzip_dir;
240
+                }
241
+                $files_found = md5DirCompare($from.'/', $cp['to'].'/', array('.svn'), false);
242
+                if(count($files_found > 0)){
243
+                    foreach($files_found as $key=>$value){
244
+                        $modified_files[] = str_replace($needle, '', $key);
245
+                    }
246
+                }
247
+            }//fi
248
+        }//rof
249
+    }//fi
250
+    return $modified_files;
251 251
 }
Please login to merge, or discard this patch.
modules/Administration/updateTimezonePrefs.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
48 48
 $prompt_users = 'checked';
49 49
 if(isset($_POST['preview']) && !isset($_POST['prompt_users'])){
50
-	$prompt_users = '';
50
+    $prompt_users = '';
51 51
 }
52 52
 
53 53
 
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 $execute = false;
56 56
 // loop through user preferences and check for "bad" elements; rebuild preferences array and update database
57 57
 if(isset($_POST['execute'])){
58
-	$execute = true;
58
+    $execute = true;
59 59
 }
60 60
 $serverTimeZone = lookupTimezone(0);
61 61
 while ($row = $db->fetchByAssoc($result)) {
62
-	$adjustment = 'none';
62
+    $adjustment = 'none';
63 63
 
64
-	if(isset($_POST[$row['id'].'adjust'])){
65
-		$adjustment = $_POST[$row['id'].'adjust'];
66
-	}
64
+    if(isset($_POST[$row['id'].'adjust'])){
65
+        $adjustment = $_POST[$row['id'].'adjust'];
66
+    }
67 67
 	
68
-		$string = "Preview";
69
-		if($execute)$string = "Updating";
68
+        $string = "Preview";
69
+        if($execute)$string = "Updating";
70 70
         echo "<tr><td> $string timezone preferences for user <b>{$row['user_name']}</b>...</td><td>";
71 71
 		
72 72
         
@@ -76,84 +76,84 @@  discard block
 block discarded – undo
76 76
         $prefs = unserialize(base64_decode($row['user_preferences']));
77 77
         $setTo = '';
78 78
         $alreadySet = '';
79
-		if(!empty($prefs)){
79
+        if(!empty($prefs)){
80 80
 			
81
-	        foreach ($prefs as $key => $val) {
82
-	               if ($key == 'timez') {
83
-	                	if(empty($prefs['timezone']) && $val != ''){
84
-		                	$hourAdjust = $adjustment;
85
-		                	if($hourAdjust == 'none'){
86
-								$hourAdjust = 0;
87
-							}
88
-	                		$selectedZone = lookupTimezone($prefs['timez'] + $hourAdjust);
81
+            foreach ($prefs as $key => $val) {
82
+                    if ($key == 'timez') {
83
+                        if(empty($prefs['timezone']) && $val != ''){
84
+                            $hourAdjust = $adjustment;
85
+                            if($hourAdjust == 'none'){
86
+                                $hourAdjust = 0;
87
+                            }
88
+                            $selectedZone = lookupTimezone($prefs['timez'] + $hourAdjust);
89 89
 	                	
90
-	                	if(!empty($selectedZone)){
91
-	                   	 	$newprefs['timezone'] = $selectedZone;   
92
-	                   	 	$newprefs['timez']  = $val;
93
-	                   	 	$setTo = $selectedZone;
94
-	                   	 	if(empty($prompt_users)){
95
-	                   			$newprefs['ut']=1;
96
-	                   	 	}else{
97
-	                   	 		$newprefs['ut']=0;
98
-	                   	 	}
99
-	                	}else{
100
-	                		$newprefs['timezone'] = $serverTimeZone;   
101
-	                   	 	$newprefs['timez']  = $val;
102
-	                   	 	$setTo = $serverTimeZone;
103
-	                   	 	if(empty($prompt_users)){
104
-	                   			$newprefs['ut']=1;
105
-	                   	 	}else{
106
-	                   	 		$newprefs['ut']=0;
107
-	                   	 	}
108
-	                	}
109
-	                }else{
110
-	                	$newprefs[$key] = $val;
111
-	                	if(!empty($prefs['timezone'])){
112
-	                		$alreadySet = 'Previously Set - '. $prefs['timezone'];	
113
-	                	}
114
-	                }
90
+                        if(!empty($selectedZone)){
91
+                                $newprefs['timezone'] = $selectedZone;   
92
+                                $newprefs['timez']  = $val;
93
+                                $setTo = $selectedZone;
94
+                                if(empty($prompt_users)){
95
+                                    $newprefs['ut']=1;
96
+                                }else{
97
+                                    $newprefs['ut']=0;
98
+                                }
99
+                        }else{
100
+                            $newprefs['timezone'] = $serverTimeZone;   
101
+                                $newprefs['timez']  = $val;
102
+                                $setTo = $serverTimeZone;
103
+                                if(empty($prompt_users)){
104
+                                    $newprefs['ut']=1;
105
+                                }else{
106
+                                    $newprefs['ut']=0;
107
+                                }
108
+                        }
109
+                    }else{
110
+                        $newprefs[$key] = $val;
111
+                        if(!empty($prefs['timezone'])){
112
+                            $alreadySet = 'Previously Set - '. $prefs['timezone'];	
113
+                        }
114
+                    }
115 115
 	                
116 116
 	         
117
-	                }else{
118
-	                	$newprefs[$key] = $val;
119
-	                }
120
-	        }
121
-	        	if($execute){
122
-        			$newstr = mysql_real_escape_string(base64_encode(serialize($newprefs)));
123
-       				$db->query("UPDATE users SET user_preferences = '{$newstr}' WHERE id = '{$row['id']}'");
124
-	        	}
125
-	        }
126
-		if(!empty($setTo)){
127
-			echo $setTo;
128
-		}else{
129
-			if(!empty($alreadySet)){
130
-				echo $alreadySet;
131
-			}else{
132
-				echo $serverTimeZone;
133
-				$prefs['timezone'] = $serverTimeZone;
134
-			}
135
-		}
117
+                    }else{
118
+                        $newprefs[$key] = $val;
119
+                    }
120
+            }
121
+                if($execute){
122
+                    $newstr = mysql_real_escape_string(base64_encode(serialize($newprefs)));
123
+                        $db->query("UPDATE users SET user_preferences = '{$newstr}' WHERE id = '{$row['id']}'");
124
+                }
125
+            }
126
+        if(!empty($setTo)){
127
+            echo $setTo;
128
+        }else{
129
+            if(!empty($alreadySet)){
130
+                echo $alreadySet;
131
+            }else{
132
+                echo $serverTimeZone;
133
+                $prefs['timezone'] = $serverTimeZone;
134
+            }
135
+        }
136 136
         echo "</td><td>";
137 137
         if(!empty($setTo)){
138
-        	echo "Adjust: ";
138
+            echo "Adjust: ";
139 139
         if($execute){
140
-			if(isset($_POST[$row['id'].'adjust'])){
141
-				echo  $adjustment;
142
-			}
143
-		}else{
144
-			echo "<select name='{$row['id']}adjust'>";
140
+            if(isset($_POST[$row['id'].'adjust'])){
141
+                echo  $adjustment;
142
+            }
143
+        }else{
144
+            echo "<select name='{$row['id']}adjust'>";
145 145
 			
146
-			echo get_select_options_with_id(array('-1'=>'-1', 'none'=>'0', '1'=>'+1'), $adjustment.'');
147
-			echo '</select>';
146
+            echo get_select_options_with_id(array('-1'=>'-1', 'none'=>'0', '1'=>'+1'), $adjustment.'');
147
+            echo '</select>';
148 148
 
149
-		}
150
-		echo ' hour';
151 149
         }
152
-		echo ' </td><td>';
150
+        echo ' hour';
151
+        }
152
+        echo ' </td><td>';
153 153
         echo "</tr>";
154 154
 
155
-		$the_old_prefs[] = $prefs;
156
-		$the_new_prefs[] = $newprefs;
155
+        $the_old_prefs[] = $prefs;
156
+        $the_new_prefs[] = $newprefs;
157 157
 
158 158
         unset($prefs);
159 159
         unset($newprefs);
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 echo "</table>";
164 164
 
165 165
 if($execute){
166
-	echo "<br>All timezone preferences updated!<br><br>";
166
+    echo "<br>All timezone preferences updated!<br><br>";
167 167
 	
168 168
 }else{
169
-	echo "Prompt users on login to confirm:<input type='checkbox' name='prompt_users' value='1' $prompt_users><br>";
170
-	echo "<input class='button' type='submit' name='execute' value='Execute'>&nbsp; <input class='button' type='submit' name='preview' value='Preview'>";
169
+    echo "Prompt users on login to confirm:<input type='checkbox' name='prompt_users' value='1' $prompt_users><br>";
170
+    echo "<input class='button' type='submit' name='execute' value='Execute'>&nbsp; <input class='button' type='submit' name='preview' value='Preview'>";
171 171
 	
172 172
 }
173 173
 echo "&nbsp;<input class='button' type='button' name='Done' value='Done' onclick='document.location.href=\"index.php?action=DstFix&module=Administration\"'>";
Please login to merge, or discard this patch.
modules/InboundEmail/AOPInboundEmail.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2
- /**
3
- * 
4
- * 
5
- * @package 
6
- * @copyright SalesAgility Ltd http://www.salesagility.com
7
- * 
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
10
- * the Free Software Foundation; either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
19
- * along with this program; if not, see http://www.gnu.org/licenses
20
- * or write to the Free Software Foundation,Inc., 51 Franklin Street,
21
- * Fifth Floor, Boston, MA 02110-1301  USA
22
- *
23
- * @author Salesagility Ltd <[email protected]>
24
- */
2
+    /**
3
+     * 
4
+     * 
5
+     * @package 
6
+     * @copyright SalesAgility Ltd http://www.salesagility.com
7
+     * 
8
+     * This program is free software; you can redistribute it and/or modify
9
+     * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
10
+     * the Free Software Foundation; either version 3 of the License, or
11
+     * (at your option) any later version.
12
+     *
13
+     * This program is distributed in the hope that it will be useful,
14
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+     * GNU General Public License for more details.
17
+     *
18
+     * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
19
+     * along with this program; if not, see http://www.gnu.org/licenses
20
+     * or write to the Free Software Foundation,Inc., 51 Franklin Street,
21
+     * Fifth Floor, Boston, MA 02110-1301  USA
22
+     *
23
+     * @author Salesagility Ltd <[email protected]>
24
+     */
25 25
 require_once 'modules/InboundEmail/InboundEmail.php';
26 26
 require_once 'include/clean.php';
27 27
 class AOPInboundEmail extends InboundEmail {
Please login to merge, or discard this patch.