@@ -1,140 +1,140 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // created: 2014-01-29 09:59:23 |
| 3 | 3 | $unified_search_modules_display = array ( |
| 4 | - 'AOP_Case_Events' => |
|
| 5 | - array ( |
|
| 4 | + 'AOP_Case_Events' => |
|
| 5 | + array ( |
|
| 6 | 6 | 'visible' => false, |
| 7 | - ), |
|
| 8 | - 'AOP_Case_Updates' => |
|
| 9 | - array ( |
|
| 7 | + ), |
|
| 8 | + 'AOP_Case_Updates' => |
|
| 9 | + array ( |
|
| 10 | 10 | 'visible' => false, |
| 11 | - ), |
|
| 12 | - 'AOR_Reports' => |
|
| 13 | - array ( |
|
| 11 | + ), |
|
| 12 | + 'AOR_Reports' => |
|
| 13 | + array ( |
|
| 14 | 14 | 'visible' => false, |
| 15 | - ), |
|
| 16 | - 'AOS_Contracts' => |
|
| 17 | - array ( |
|
| 15 | + ), |
|
| 16 | + 'AOS_Contracts' => |
|
| 17 | + array ( |
|
| 18 | 18 | 'visible' => false, |
| 19 | - ), |
|
| 20 | - 'AOS_Invoices' => |
|
| 21 | - array ( |
|
| 19 | + ), |
|
| 20 | + 'AOS_Invoices' => |
|
| 21 | + array ( |
|
| 22 | 22 | 'visible' => false, |
| 23 | - ), |
|
| 24 | - 'AOS_PDF_Templates' => |
|
| 25 | - array ( |
|
| 23 | + ), |
|
| 24 | + 'AOS_PDF_Templates' => |
|
| 25 | + array ( |
|
| 26 | 26 | 'visible' => false, |
| 27 | - ), |
|
| 28 | - 'AOS_Product_Categories' => |
|
| 29 | - array ( |
|
| 27 | + ), |
|
| 28 | + 'AOS_Product_Categories' => |
|
| 29 | + array ( |
|
| 30 | 30 | 'visible' => false, |
| 31 | - ), |
|
| 32 | - 'AOS_Products' => |
|
| 33 | - array ( |
|
| 31 | + ), |
|
| 32 | + 'AOS_Products' => |
|
| 33 | + array ( |
|
| 34 | 34 | 'visible' => false, |
| 35 | - ), |
|
| 36 | - 'AOS_Quotes' => |
|
| 37 | - array ( |
|
| 35 | + ), |
|
| 36 | + 'AOS_Quotes' => |
|
| 37 | + array ( |
|
| 38 | 38 | 'visible' => false, |
| 39 | - ), |
|
| 40 | - 'AOW_Processed' => |
|
| 41 | - array ( |
|
| 39 | + ), |
|
| 40 | + 'AOW_Processed' => |
|
| 41 | + array ( |
|
| 42 | 42 | 'visible' => false, |
| 43 | - ), |
|
| 44 | - 'AOW_WorkFlow' => |
|
| 45 | - array ( |
|
| 43 | + ), |
|
| 44 | + 'AOW_WorkFlow' => |
|
| 45 | + array ( |
|
| 46 | 46 | 'visible' => false, |
| 47 | - ), |
|
| 48 | - 'Accounts' => |
|
| 49 | - array ( |
|
| 47 | + ), |
|
| 48 | + 'Accounts' => |
|
| 49 | + array ( |
|
| 50 | 50 | 'visible' => true, |
| 51 | - ), |
|
| 52 | - 'Bugs' => |
|
| 53 | - array ( |
|
| 51 | + ), |
|
| 52 | + 'Bugs' => |
|
| 53 | + array ( |
|
| 54 | 54 | 'visible' => false, |
| 55 | - ), |
|
| 56 | - 'Calls' => |
|
| 57 | - array ( |
|
| 55 | + ), |
|
| 56 | + 'Calls' => |
|
| 57 | + array ( |
|
| 58 | 58 | 'visible' => true, |
| 59 | - ), |
|
| 60 | - 'Calls_Reschedule' => |
|
| 61 | - array ( |
|
| 59 | + ), |
|
| 60 | + 'Calls_Reschedule' => |
|
| 61 | + array ( |
|
| 62 | 62 | 'visible' => false, |
| 63 | - ), |
|
| 64 | - 'Campaigns' => |
|
| 65 | - array ( |
|
| 63 | + ), |
|
| 64 | + 'Campaigns' => |
|
| 65 | + array ( |
|
| 66 | 66 | 'visible' => false, |
| 67 | - ), |
|
| 68 | - 'Cases' => |
|
| 69 | - array ( |
|
| 67 | + ), |
|
| 68 | + 'Cases' => |
|
| 69 | + array ( |
|
| 70 | 70 | 'visible' => true, |
| 71 | - ), |
|
| 72 | - 'Contacts' => |
|
| 73 | - array ( |
|
| 71 | + ), |
|
| 72 | + 'Contacts' => |
|
| 73 | + array ( |
|
| 74 | 74 | 'visible' => true, |
| 75 | - ), |
|
| 76 | - 'Documents' => |
|
| 77 | - array ( |
|
| 75 | + ), |
|
| 76 | + 'Documents' => |
|
| 77 | + array ( |
|
| 78 | 78 | 'visible' => true, |
| 79 | - ), |
|
| 80 | - 'FP_Event_Locations' => |
|
| 81 | - array ( |
|
| 79 | + ), |
|
| 80 | + 'FP_Event_Locations' => |
|
| 81 | + array ( |
|
| 82 | 82 | 'visible' => false, |
| 83 | - ), |
|
| 84 | - 'FP_events' => |
|
| 85 | - array ( |
|
| 83 | + ), |
|
| 84 | + 'FP_events' => |
|
| 85 | + array ( |
|
| 86 | 86 | 'visible' => false, |
| 87 | - ), |
|
| 88 | - 'Leads' => |
|
| 89 | - array ( |
|
| 87 | + ), |
|
| 88 | + 'Leads' => |
|
| 89 | + array ( |
|
| 90 | 90 | 'visible' => true, |
| 91 | - ), |
|
| 92 | - 'Meetings' => |
|
| 93 | - array ( |
|
| 91 | + ), |
|
| 92 | + 'Meetings' => |
|
| 93 | + array ( |
|
| 94 | 94 | 'visible' => true, |
| 95 | - ), |
|
| 96 | - 'Notes' => |
|
| 97 | - array ( |
|
| 95 | + ), |
|
| 96 | + 'Notes' => |
|
| 97 | + array ( |
|
| 98 | 98 | 'visible' => true, |
| 99 | - ), |
|
| 100 | - 'Opportunities' => |
|
| 101 | - array ( |
|
| 99 | + ), |
|
| 100 | + 'Opportunities' => |
|
| 101 | + array ( |
|
| 102 | 102 | 'visible' => true, |
| 103 | - ), |
|
| 104 | - 'Project' => |
|
| 105 | - array ( |
|
| 103 | + ), |
|
| 104 | + 'Project' => |
|
| 105 | + array ( |
|
| 106 | 106 | 'visible' => false, |
| 107 | - ), |
|
| 108 | - 'ProjectTask' => |
|
| 109 | - array ( |
|
| 107 | + ), |
|
| 108 | + 'ProjectTask' => |
|
| 109 | + array ( |
|
| 110 | 110 | 'visible' => false, |
| 111 | - ), |
|
| 112 | - 'ProspectLists' => |
|
| 113 | - array ( |
|
| 111 | + ), |
|
| 112 | + 'ProspectLists' => |
|
| 113 | + array ( |
|
| 114 | 114 | 'visible' => false, |
| 115 | - ), |
|
| 116 | - 'Prospects' => |
|
| 117 | - array ( |
|
| 115 | + ), |
|
| 116 | + 'Prospects' => |
|
| 117 | + array ( |
|
| 118 | 118 | 'visible' => false, |
| 119 | - ), |
|
| 120 | - 'Tasks' => |
|
| 121 | - array ( |
|
| 119 | + ), |
|
| 120 | + 'Tasks' => |
|
| 121 | + array ( |
|
| 122 | 122 | 'visible' => false, |
| 123 | - ), |
|
| 124 | - 'jjwg_Address_Cache' => |
|
| 125 | - array ( |
|
| 123 | + ), |
|
| 124 | + 'jjwg_Address_Cache' => |
|
| 125 | + array ( |
|
| 126 | 126 | 'visible' => false, |
| 127 | - ), |
|
| 128 | - 'jjwg_Areas' => |
|
| 129 | - array ( |
|
| 127 | + ), |
|
| 128 | + 'jjwg_Areas' => |
|
| 129 | + array ( |
|
| 130 | 130 | 'visible' => false, |
| 131 | - ), |
|
| 132 | - 'jjwg_Maps' => |
|
| 133 | - array ( |
|
| 131 | + ), |
|
| 132 | + 'jjwg_Maps' => |
|
| 133 | + array ( |
|
| 134 | 134 | 'visible' => false, |
| 135 | - ), |
|
| 136 | - 'jjwg_Markers' => |
|
| 137 | - array ( |
|
| 135 | + ), |
|
| 136 | + 'jjwg_Markers' => |
|
| 137 | + array ( |
|
| 138 | 138 | 'visible' => false, |
| 139 | - ), |
|
| 139 | + ), |
|
| 140 | 140 | ); |
| 141 | 141 | \ No newline at end of file |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function parse() { |
| 61 | - return "NOT AVAILABLE"; |
|
| 61 | + return "NOT AVAILABLE"; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | * Parses for contents enclosed within <form>...</form> tags |
| 67 | 67 | */ |
| 68 | 68 | function getFormContents($contents, $all = true) { |
| 69 | - if($all) { |
|
| 70 | - preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
| 71 | - return $matches; |
|
| 72 | - } |
|
| 69 | + if($all) { |
|
| 70 | + preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
| 71 | + return $matches; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - preg_match("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
| 75 | - return $this->convertToTagElement($matches); |
|
| 76 | - //return $matches; |
|
| 74 | + preg_match("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
| 75 | + return $this->convertToTagElement($matches); |
|
| 76 | + //return $matches; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | * @return $matches Array of matches of PREG_SET_ORDER |
| 85 | 85 | */ |
| 86 | 86 | function getFormElements($contents) { |
| 87 | - preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
| 88 | - $elems = array(); |
|
| 89 | - foreach($matches[3] as $match) { |
|
| 90 | - $elems[] = $match; |
|
| 91 | - } |
|
| 92 | - return $elems; |
|
| 87 | + preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
| 88 | + $elems = array(); |
|
| 89 | + foreach($matches[3] as $match) { |
|
| 90 | + $elems[] = $match; |
|
| 91 | + } |
|
| 92 | + return $elems; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | * @return $matches Array of name/value pairs |
| 101 | 101 | */ |
| 102 | 102 | function getFormElementsNames($contents) { |
| 103 | - preg_match_all("'(<[ ]*?)(textarea|input|select)[^>]*?name=[\'\"]([^\'\"]*?)(\[\])?(_basic)?[\'\"]([^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
| 104 | - return !empty($matches[3]) ? $matches[3] : null; |
|
| 103 | + preg_match_all("'(<[ ]*?)(textarea|input|select)[^>]*?name=[\'\"]([^\'\"]*?)(\[\])?(_basic)?[\'\"]([^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
| 104 | + return !empty($matches[3]) ? $matches[3] : null; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -114,21 +114,21 @@ discard block |
||
| 114 | 114 | * @return Array of name/value for matching attribute |
| 115 | 115 | */ |
| 116 | 116 | function getTagAttribute($name, $contents, $filter = '') { |
| 117 | - //$exp = "'".$name."[ ]*?=[ ]*?[\'\"]([a-zA-Z0-9\_\[\]]*)[\'\"]'si"; |
|
| 117 | + //$exp = "'".$name."[ ]*?=[ ]*?[\'\"]([a-zA-Z0-9\_\[\]]*)[\'\"]'si"; |
|
| 118 | 118 | |
| 119 | - $exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si"; |
|
| 120 | - preg_match_all($exp, $contents, $matches, PREG_SET_ORDER); |
|
| 121 | - if(empty($filter)) { |
|
| 122 | - return !empty($matches[0][1]) ? $matches[0][1] : ''; |
|
| 123 | - } |
|
| 119 | + $exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si"; |
|
| 120 | + preg_match_all($exp, $contents, $matches, PREG_SET_ORDER); |
|
| 121 | + if(empty($filter)) { |
|
| 122 | + return !empty($matches[0][1]) ? $matches[0][1] : ''; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $filtered = array(); |
|
| 126 | - foreach($matches as $tag) { |
|
| 127 | - if(preg_match($filter, $tag[1])) { |
|
| 128 | - $filtered[] = $tag; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - return $filtered; |
|
| 125 | + $filtered = array(); |
|
| 126 | + foreach($matches as $tag) { |
|
| 127 | + if(preg_match($filter, $tag[1])) { |
|
| 128 | + $filtered[] = $tag; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + return $filtered; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | * @return Array of table elements found |
| 141 | 141 | */ |
| 142 | 142 | function getTables($tableClass = null, $contents) { |
| 143 | - preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
| 144 | - if($tableClass == null) { |
|
| 145 | - return $matches; |
|
| 146 | - } |
|
| 143 | + preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
| 144 | + if($tableClass == null) { |
|
| 145 | + return $matches; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $tables = array(); |
|
| 149 | - foreach($matches as $key => $table) { |
|
| 150 | - if(strpos($table[1], $tableClass) > 0) { |
|
| 151 | - $tables[] = $table; |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - return $this->convertToTagElement($tables); |
|
| 148 | + $tables = array(); |
|
| 149 | + foreach($matches as $key => $table) { |
|
| 150 | + if(strpos($table[1], $tableClass) > 0) { |
|
| 151 | + $tables[] = $table; |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + return $this->convertToTagElement($tables); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -167,40 +167,40 @@ discard block |
||
| 167 | 167 | * @return a tag element format Array |
| 168 | 168 | */ |
| 169 | 169 | function getElementsByType($type, $contents) { |
| 170 | - $x = strlen($contents); |
|
| 171 | - $mark = 0; |
|
| 172 | - $count = 0; |
|
| 173 | - $stag1 = "<" . trim($type, " <>") . '>'; |
|
| 174 | - $stag2 = "<" . trim($type, " <>") . ' '; |
|
| 175 | - $etag = "</".$type.">"; |
|
| 176 | - $sincrement = strlen($stag1); |
|
| 177 | - $eincrement = strlen($etag); |
|
| 178 | - $sarr = array(); |
|
| 179 | - $values = array(); |
|
| 180 | - |
|
| 181 | - while($count < $x) { |
|
| 182 | - $stok = substr($contents, $count, $sincrement); |
|
| 183 | - $etok = substr($contents, $count, $eincrement); |
|
| 184 | - if($stok == $stag1 || $stok == $stag2) { |
|
| 185 | - //Reset mark; |
|
| 186 | - if(count($sarr) == 0) { |
|
| 187 | - $mark = $count; |
|
| 188 | - } |
|
| 170 | + $x = strlen($contents); |
|
| 171 | + $mark = 0; |
|
| 172 | + $count = 0; |
|
| 173 | + $stag1 = "<" . trim($type, " <>") . '>'; |
|
| 174 | + $stag2 = "<" . trim($type, " <>") . ' '; |
|
| 175 | + $etag = "</".$type.">"; |
|
| 176 | + $sincrement = strlen($stag1); |
|
| 177 | + $eincrement = strlen($etag); |
|
| 178 | + $sarr = array(); |
|
| 179 | + $values = array(); |
|
| 180 | + |
|
| 181 | + while($count < $x) { |
|
| 182 | + $stok = substr($contents, $count, $sincrement); |
|
| 183 | + $etok = substr($contents, $count, $eincrement); |
|
| 184 | + if($stok == $stag1 || $stok == $stag2) { |
|
| 185 | + //Reset mark; |
|
| 186 | + if(count($sarr) == 0) { |
|
| 187 | + $mark = $count; |
|
| 188 | + } |
|
| 189 | 189 | $sarr[] = $count; |
| 190 | 190 | |
| 191 | - } else if($etok == $etag) { |
|
| 192 | - array_shift($sarr); |
|
| 193 | - if(count($sarr) == 0) { |
|
| 194 | - $val = substr($contents, $mark, ($count - $mark) + $eincrement); |
|
| 195 | - $values[] = $val; |
|
| 196 | - $mark = $count; |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - $count++; |
|
| 200 | - } |
|
| 191 | + } else if($etok == $etag) { |
|
| 192 | + array_shift($sarr); |
|
| 193 | + if(count($sarr) == 0) { |
|
| 194 | + $val = substr($contents, $mark, ($count - $mark) + $eincrement); |
|
| 195 | + $values[] = $val; |
|
| 196 | + $mark = $count; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + $count++; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - $count = 0; |
|
| 203 | - return $values; |
|
| 202 | + $count = 0; |
|
| 203 | + return $values; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | |
@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | * |
| 211 | 211 | */ |
| 212 | 212 | function getElementValue($type, $contents, $filter = "(.*?)") { |
| 213 | - $exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si"; |
|
| 214 | - preg_match($exp, $contents, $matches); |
|
| 215 | - return isset($matches[1]) ? $matches[1] : ''; |
|
| 213 | + $exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si"; |
|
| 214 | + preg_match($exp, $contents, $matches); |
|
| 215 | + return isset($matches[1]) ? $matches[1] : ''; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | function stripComments($contents) { |
| 220 | - return preg_replace("'(<!--.*?-->)'si", "", $contents); |
|
| 220 | + return preg_replace("'(<!--.*?-->)'si", "", $contents); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | * @param $result The file contents with non-matching flavor tags and their nested comments removed |
| 230 | 230 | */ |
| 231 | 231 | function stripFlavorTags($contents) { |
| 232 | - $flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO'; |
|
| 233 | - $isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false; |
|
| 234 | - if($isPro) { |
|
| 235 | - $contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents); |
|
| 236 | - } else { |
|
| 237 | - $contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents); |
|
| 238 | - } |
|
| 239 | - return $contents; |
|
| 232 | + $flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO'; |
|
| 233 | + $isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false; |
|
| 234 | + if($isPro) { |
|
| 235 | + $contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents); |
|
| 236 | + } else { |
|
| 237 | + $contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents); |
|
| 238 | + } |
|
| 239 | + return $contents; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -247,34 +247,34 @@ discard block |
||
| 247 | 247 | * @return The maximum column count |
| 248 | 248 | */ |
| 249 | 249 | function getMaxColumns($contents, $filter) { |
| 250 | - preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
| 251 | - $max = 0; |
|
| 252 | - foreach($matches as $tableRows) { |
|
| 253 | - $count = substr_count($tableRows[2], $filter); |
|
| 254 | - if($count > $max) { |
|
| 255 | - $max = $count; |
|
| 256 | - } |
|
| 257 | - } |
|
| 250 | + preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
| 251 | + $max = 0; |
|
| 252 | + foreach($matches as $tableRows) { |
|
| 253 | + $count = substr_count($tableRows[2], $filter); |
|
| 254 | + if($count > $max) { |
|
| 255 | + $max = $count; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - return $max; |
|
| 259 | + return $max; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | function convertToTagElement($matches) { |
| 263 | 263 | |
| 264 | - $elements = array(); |
|
| 264 | + $elements = array(); |
|
| 265 | 265 | |
| 266 | - foreach($matches as $data) { |
|
| 267 | - // We need 4 because the 1,2,3 indexes make up start,body,end |
|
| 268 | - if(count($data) == 4) { |
|
| 269 | - $element = array(); |
|
| 270 | - $element['start'] = $data[1]; |
|
| 271 | - $element['body'] = $data[2]; |
|
| 272 | - $element['end'] = $data[3]; |
|
| 273 | - $elements[] = $element; |
|
| 274 | - } |
|
| 275 | - } |
|
| 266 | + foreach($matches as $data) { |
|
| 267 | + // We need 4 because the 1,2,3 indexes make up start,body,end |
|
| 268 | + if(count($data) == 4) { |
|
| 269 | + $element = array(); |
|
| 270 | + $element['start'] = $data[1]; |
|
| 271 | + $element['body'] = $data[2]; |
|
| 272 | + $element['end'] = $data[3]; |
|
| 273 | + $elements[] = $element; |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - return empty($elements) ? $matches : $elements; |
|
| 277 | + return empty($elements) ? $matches : $elements; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /* |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | * This function removes the \r (return), \n (newline) and \t (tab) markup from string |
| 283 | 283 | */ |
| 284 | 284 | function trimHTML($contents) { |
| 285 | - $contents = str_replace(array("\r"), array(""), $contents); |
|
| 286 | - $contents = str_replace(array("\n"), array(""), $contents); |
|
| 287 | - $contents = str_replace(array("\t"), array(""), $contents); |
|
| 288 | - return $contents; |
|
| 285 | + $contents = str_replace(array("\r"), array(""), $contents); |
|
| 286 | + $contents = str_replace(array("\n"), array(""), $contents); |
|
| 287 | + $contents = str_replace(array("\t"), array(""), $contents); |
|
| 288 | + return $contents; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -307,11 +307,11 @@ discard block |
||
| 307 | 307 | //Check if there are Javascript blocks of code to process |
| 308 | 308 | preg_match_all("'(<script[^>]*?>)(.*?)(</script[^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
| 309 | 309 | if(empty($matches)) { |
| 310 | - return $javascript; |
|
| 310 | + return $javascript; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | foreach($matches[0] as $scriptBlock) { |
| 314 | - $javascript .= "\n" . $scriptBlock; |
|
| 314 | + $javascript .= "\n" . $scriptBlock; |
|
| 315 | 315 | } //foreach |
| 316 | 316 | |
| 317 | 317 | $javascript = substr($javascript, 1); |
@@ -323,19 +323,19 @@ discard block |
||
| 323 | 323 | //Find all blocks that may need to be replaced with Smarty syntax |
| 324 | 324 | preg_match_all("'([\{])([a-zA-Z0-9_]*?)([\}])'si", $javascript, $matches, PREG_PATTERN_ORDER); |
| 325 | 325 | if(!empty($matches)) { |
| 326 | - $replace = array(); |
|
| 326 | + $replace = array(); |
|
| 327 | 327 | |
| 328 | - foreach($matches[0] as $xTemplateCode) { |
|
| 329 | - if(!isset($replace[$xTemplateCode])) { |
|
| 330 | - $replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode); |
|
| 331 | - } //if |
|
| 332 | - } //foreach |
|
| 328 | + foreach($matches[0] as $xTemplateCode) { |
|
| 329 | + if(!isset($replace[$xTemplateCode])) { |
|
| 330 | + $replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode); |
|
| 331 | + } //if |
|
| 332 | + } //foreach |
|
| 333 | 333 | |
| 334 | - $javascript = str_replace(array_keys($replace), array_values($replace), $javascript); |
|
| 334 | + $javascript = str_replace(array_keys($replace), array_values($replace), $javascript); |
|
| 335 | 335 | } //if |
| 336 | 336 | |
| 337 | 337 | if(!$addLiterals) { |
| 338 | - return $javascript; |
|
| 338 | + return $javascript; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | return $this->parseDelimiters($javascript); |
@@ -343,44 +343,44 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | static function parseDelimiters($javascript) { |
| 346 | - $newJavascript = ''; |
|
| 347 | - $scriptLength = strlen($javascript); |
|
| 348 | - $count = 0; |
|
| 349 | - $inSmartyVariable = false; |
|
| 350 | - |
|
| 351 | - while($count < $scriptLength) { |
|
| 352 | - |
|
| 353 | - if($inSmartyVariable) { |
|
| 354 | - $start = $count; |
|
| 355 | - $numOfChars = 1; |
|
| 356 | - while(isset($javascript[$count]) && $javascript[$count] != '}') { |
|
| 357 | - $count++; |
|
| 358 | - $numOfChars++; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - $newJavascript .= substr($javascript, $start, $numOfChars); |
|
| 362 | - $inSmartyVariable = false; |
|
| 363 | - |
|
| 364 | - } else { |
|
| 365 | - |
|
| 366 | - $char = $javascript[$count]; |
|
| 367 | - $nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1]; |
|
| 368 | - |
|
| 369 | - if($char == "{" && $nextChar == "$") { |
|
| 370 | - $inSmartyVariable = true; |
|
| 371 | - $newJavascript .= $javascript[$count]; |
|
| 372 | - } else if($char == "{") { |
|
| 373 | - $newJavascript .= " {ldelim} "; |
|
| 374 | - } else if($char == "}") { |
|
| 375 | - $newJavascript .= " {rdelim} "; |
|
| 376 | - } else { |
|
| 377 | - $newJavascript .= $javascript[$count]; |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - $count++; |
|
| 381 | - } //while |
|
| 382 | - |
|
| 383 | - return $newJavascript; |
|
| 346 | + $newJavascript = ''; |
|
| 347 | + $scriptLength = strlen($javascript); |
|
| 348 | + $count = 0; |
|
| 349 | + $inSmartyVariable = false; |
|
| 350 | + |
|
| 351 | + while($count < $scriptLength) { |
|
| 352 | + |
|
| 353 | + if($inSmartyVariable) { |
|
| 354 | + $start = $count; |
|
| 355 | + $numOfChars = 1; |
|
| 356 | + while(isset($javascript[$count]) && $javascript[$count] != '}') { |
|
| 357 | + $count++; |
|
| 358 | + $numOfChars++; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + $newJavascript .= substr($javascript, $start, $numOfChars); |
|
| 362 | + $inSmartyVariable = false; |
|
| 363 | + |
|
| 364 | + } else { |
|
| 365 | + |
|
| 366 | + $char = $javascript[$count]; |
|
| 367 | + $nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1]; |
|
| 368 | + |
|
| 369 | + if($char == "{" && $nextChar == "$") { |
|
| 370 | + $inSmartyVariable = true; |
|
| 371 | + $newJavascript .= $javascript[$count]; |
|
| 372 | + } else if($char == "{") { |
|
| 373 | + $newJavascript .= " {ldelim} "; |
|
| 374 | + } else if($char == "}") { |
|
| 375 | + $newJavascript .= " {rdelim} "; |
|
| 376 | + } else { |
|
| 377 | + $newJavascript .= $javascript[$count]; |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + $count++; |
|
| 381 | + } //while |
|
| 382 | + |
|
| 383 | + return $newJavascript; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -397,43 +397,43 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | function findAssignedVariableName($name, $filePath) { |
| 399 | 399 | |
| 400 | - if($this->mPHPFile == "INVALID") { |
|
| 401 | - return $name; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - if(!isset($this->mPHPFile)) { |
|
| 405 | - if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
| 406 | - $dir = $matches[1]; |
|
| 407 | - } else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
| 408 | - $dir = $matches[1]; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - if(!isset($dir) || !is_dir($dir)) { |
|
| 412 | - $this->mPHPFile = "INVALID"; |
|
| 413 | - return $name; |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - $filesInDir = $this->dirList($dir); |
|
| 417 | - $phpFile = $matches[2].'.*?[\.]php'; |
|
| 418 | - foreach($filesInDir as $file) { |
|
| 419 | - if(preg_match("/$phpFile/", $file)) { |
|
| 420 | - $this->mPHPFile = $matches[1] . $file; |
|
| 421 | - break; |
|
| 422 | - } |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
| 426 | - $this->mPHPFile = "INVALID"; |
|
| 427 | - return $name; |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - $phpContents = file_get_contents($this->mPHPFile); |
|
| 432 | - $uname = strtoupper($name); |
|
| 433 | - if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
| 434 | - return $matches[1]; |
|
| 435 | - } |
|
| 436 | - return $name; |
|
| 400 | + if($this->mPHPFile == "INVALID") { |
|
| 401 | + return $name; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + if(!isset($this->mPHPFile)) { |
|
| 405 | + if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
| 406 | + $dir = $matches[1]; |
|
| 407 | + } else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
| 408 | + $dir = $matches[1]; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + if(!isset($dir) || !is_dir($dir)) { |
|
| 412 | + $this->mPHPFile = "INVALID"; |
|
| 413 | + return $name; |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + $filesInDir = $this->dirList($dir); |
|
| 417 | + $phpFile = $matches[2].'.*?[\.]php'; |
|
| 418 | + foreach($filesInDir as $file) { |
|
| 419 | + if(preg_match("/$phpFile/", $file)) { |
|
| 420 | + $this->mPHPFile = $matches[1] . $file; |
|
| 421 | + break; |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
| 426 | + $this->mPHPFile = "INVALID"; |
|
| 427 | + return $name; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + $phpContents = file_get_contents($this->mPHPFile); |
|
| 432 | + $uname = strtoupper($name); |
|
| 433 | + if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
| 434 | + return $matches[1]; |
|
| 435 | + } |
|
| 436 | + return $name; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | |
@@ -476,65 +476,65 @@ discard block |
||
| 476 | 476 | */ |
| 477 | 477 | function getCustomField($elementNames) { |
| 478 | 478 | |
| 479 | - if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
| 480 | - return null; |
|
| 481 | - } |
|
| 479 | + if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
| 480 | + return null; |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - if(is_string($elementNames)) { |
|
| 484 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
| 485 | - return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
| 486 | - } |
|
| 487 | - return null; |
|
| 488 | - } |
|
| 483 | + if(is_string($elementNames)) { |
|
| 484 | + if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
| 485 | + return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
| 486 | + } |
|
| 487 | + return null; |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - foreach($elementNames as $name) { |
|
| 491 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
| 492 | - return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
| 493 | - } |
|
| 494 | - } |
|
| 490 | + foreach($elementNames as $name) { |
|
| 491 | + if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
| 492 | + return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - return null; |
|
| 496 | + return null; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | function applyPreRules($moduleDir, $panels) { |
| 500 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 501 | - require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
| 502 | - $class = $moduleDir."ParseRule"; |
|
| 503 | - $parseRule = new $class(); |
|
| 504 | - $panels = $parseRule->preParse($panels, $this->mView); |
|
| 505 | - } |
|
| 506 | - return $panels; |
|
| 500 | + if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 501 | + require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
| 502 | + $class = $moduleDir."ParseRule"; |
|
| 503 | + $parseRule = new $class(); |
|
| 504 | + $panels = $parseRule->preParse($panels, $this->mView); |
|
| 505 | + } |
|
| 506 | + return $panels; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | function applyRules($moduleDir, $panels) { |
| 510 | - return $this->applyPostRules($moduleDir, $panels); |
|
| 510 | + return $this->applyPostRules($moduleDir, $panels); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | function applyPostRules($moduleDir, $panels) { |
| 514 | - //Run module specific rules |
|
| 515 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 516 | - require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
| 517 | - $class = $moduleDir."ParseRule"; |
|
| 518 | - $parseRule = new $class(); |
|
| 519 | - $panels = $parseRule->parsePanels($panels, $this->mView); |
|
| 520 | - } |
|
| 514 | + //Run module specific rules |
|
| 515 | + if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
| 516 | + require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
| 517 | + $class = $moduleDir."ParseRule"; |
|
| 518 | + $parseRule = new $class(); |
|
| 519 | + $panels = $parseRule->parsePanels($panels, $this->mView); |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | - //Now run defined rules |
|
| 523 | - require_once("include/SugarFields/Parsers/Rules/ParseRules.php"); |
|
| 524 | - $rules = ParseRules::getRules(); |
|
| 522 | + //Now run defined rules |
|
| 523 | + require_once("include/SugarFields/Parsers/Rules/ParseRules.php"); |
|
| 524 | + $rules = ParseRules::getRules(); |
|
| 525 | 525 | |
| 526 | - foreach($rules as $rule) { |
|
| 527 | - if(!file_exists($rule['file'])) { |
|
| 528 | - $GLOBALS['log']->error("Cannot run rule for " . $rule['file']); |
|
| 529 | - continue; |
|
| 530 | - } //if |
|
| 531 | - require_once($rule['file']); |
|
| 532 | - $runRule = new $rule['class']; |
|
| 533 | - $panels = $runRule->parsePanels($panels, $this->mView); |
|
| 526 | + foreach($rules as $rule) { |
|
| 527 | + if(!file_exists($rule['file'])) { |
|
| 528 | + $GLOBALS['log']->error("Cannot run rule for " . $rule['file']); |
|
| 529 | + continue; |
|
| 530 | + } //if |
|
| 531 | + require_once($rule['file']); |
|
| 532 | + $runRule = new $rule['class']; |
|
| 533 | + $panels = $runRule->parsePanels($panels, $this->mView); |
|
| 534 | 534 | |
| 535 | - } //foreach |
|
| 535 | + } //foreach |
|
| 536 | 536 | |
| 537 | - return $panels; |
|
| 537 | + return $panels; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) { |
@@ -574,11 +574,11 @@ discard block |
||
| 574 | 574 | ); |
| 575 | 575 | ?>"; |
| 576 | 576 | |
| 577 | - $metadata = ''; |
|
| 578 | - $body = var_export($panels, true); |
|
| 579 | - $metadata = $header . $body . $footer; |
|
| 580 | - $metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata); |
|
| 581 | - return $metadata; |
|
| 577 | + $metadata = ''; |
|
| 578 | + $body = var_export($panels, true); |
|
| 579 | + $metadata = $header . $body . $footer; |
|
| 580 | + $metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata); |
|
| 581 | + return $metadata; |
|
| 582 | 582 | |
| 583 | 583 | } |
| 584 | 584 | |
@@ -592,88 +592,88 @@ discard block |
||
| 592 | 592 | * @return Array of merged $panel definition |
| 593 | 593 | */ |
| 594 | 594 | function mergePanels($panels, $vardefs, $moduleDir, $masterCopy) { |
| 595 | - require($masterCopy); |
|
| 596 | - $masterpanels = $viewdefs[$moduleDir][$this->mView]['panels']; |
|
| 597 | - $hasMultiplePanels = $this->hasMultiplePanels($masterpanels); |
|
| 595 | + require($masterCopy); |
|
| 596 | + $masterpanels = $viewdefs[$moduleDir][$this->mView]['panels']; |
|
| 597 | + $hasMultiplePanels = $this->hasMultiplePanels($masterpanels); |
|
| 598 | 598 | |
| 599 | - if(!$hasMultiplePanels) { |
|
| 600 | - $keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']); |
|
| 599 | + if(!$hasMultiplePanels) { |
|
| 600 | + $keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']); |
|
| 601 | 601 | if(!empty($keys) && count($keys) == 1) { |
| 602 | - if(strtolower($keys[0]) == 'default') { |
|
| 603 | - $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]); |
|
| 604 | - } else { |
|
| 605 | - $firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']); |
|
| 606 | - $masterpanels = array('default'=> $firstPanel[0]); |
|
| 607 | - } |
|
| 602 | + if(strtolower($keys[0]) == 'default') { |
|
| 603 | + $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]); |
|
| 604 | + } else { |
|
| 605 | + $firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']); |
|
| 606 | + $masterpanels = array('default'=> $firstPanel[0]); |
|
| 607 | + } |
|
| 608 | 608 | } else { |
| 609 | - $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']); |
|
| 609 | + $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']); |
|
| 610 | 610 | } |
| 611 | - } |
|
| 612 | - foreach($masterpanels as $name=>$masterpanel) { |
|
| 613 | - if(isset($panels[$name])) { |
|
| 614 | - // Get all the names in the panel |
|
| 615 | - $existingElements = array(); |
|
| 616 | - $existingLocation = array(); |
|
| 617 | - |
|
| 618 | - foreach($panels[$name] as $rowKey=>$row) { |
|
| 619 | - foreach($row as $colKey=>$column) { |
|
| 620 | - if(is_array($column) && !empty($column['name'])) { |
|
| 621 | - $existingElements[$column['name']] = $column['name']; |
|
| 622 | - $existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
| 623 | - } else if(!is_array($column) && !empty($column)) { |
|
| 624 | - $existingElements[$column] = $column; |
|
| 625 | - $existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
| 626 | - } |
|
| 627 | - } //foreach |
|
| 628 | - } //foreach |
|
| 629 | - |
|
| 630 | - // Now check against the $masterCopy |
|
| 631 | - foreach($masterpanel as $rowKey=>$row) { |
|
| 632 | - |
|
| 633 | - $addRow = array(); |
|
| 634 | - |
|
| 635 | - foreach($row as $colKey=>$column) { |
|
| 636 | - if(is_array($column) && isset($column['name'])) { |
|
| 637 | - $id = $column['name']; |
|
| 638 | - } else if(!is_array($column) && !empty($column)) { |
|
| 639 | - $id = $column; |
|
| 640 | - } else { |
|
| 641 | - continue; |
|
| 642 | - } |
|
| 643 | - if(empty($existingElements[$id])) { |
|
| 644 | - //Only add if |
|
| 645 | - // 1) if it is a required field (as defined in metadata) |
|
| 646 | - // 2) or if it has a customLabel and customCode (a very deep customization) |
|
| 647 | - if((is_array($column) && !empty($column['displayParams']['required'])) || |
|
| 648 | - (is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) { |
|
| 649 | - $addRow[] = $column; |
|
| 650 | - } |
|
| 651 | - } else { |
|
| 652 | - //Use definition from master copy instead |
|
| 653 | - $panels[$existingLocation[$id]['panel']][$existingLocation[$id]['row']][$existingLocation[$id]['col']] = $column; |
|
| 654 | - } |
|
| 655 | - } //foreach |
|
| 656 | - |
|
| 657 | - // Add it to the $panels |
|
| 658 | - if(!empty($addRow)) { |
|
| 659 | - $panels[$name][] = $addRow; |
|
| 660 | - } |
|
| 661 | - } //foreach |
|
| 662 | - |
|
| 663 | - } else { |
|
| 664 | - $panels[$name] = $masterpanel; |
|
| 665 | - } |
|
| 666 | - } //foreach |
|
| 667 | - |
|
| 668 | - // We're not done yet... go through the $panels Array now and try to remove duplicate |
|
| 669 | - // or empty panels |
|
| 670 | - foreach($panels as $name=>$panel) { |
|
| 671 | - if(count($panel) == 0 || !isset($masterpanels[$name])) { |
|
| 672 | - unset($panels[$name]); |
|
| 673 | - } |
|
| 674 | - } //foreach |
|
| 675 | - |
|
| 676 | - return $panels; |
|
| 611 | + } |
|
| 612 | + foreach($masterpanels as $name=>$masterpanel) { |
|
| 613 | + if(isset($panels[$name])) { |
|
| 614 | + // Get all the names in the panel |
|
| 615 | + $existingElements = array(); |
|
| 616 | + $existingLocation = array(); |
|
| 617 | + |
|
| 618 | + foreach($panels[$name] as $rowKey=>$row) { |
|
| 619 | + foreach($row as $colKey=>$column) { |
|
| 620 | + if(is_array($column) && !empty($column['name'])) { |
|
| 621 | + $existingElements[$column['name']] = $column['name']; |
|
| 622 | + $existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
| 623 | + } else if(!is_array($column) && !empty($column)) { |
|
| 624 | + $existingElements[$column] = $column; |
|
| 625 | + $existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
| 626 | + } |
|
| 627 | + } //foreach |
|
| 628 | + } //foreach |
|
| 629 | + |
|
| 630 | + // Now check against the $masterCopy |
|
| 631 | + foreach($masterpanel as $rowKey=>$row) { |
|
| 632 | + |
|
| 633 | + $addRow = array(); |
|
| 634 | + |
|
| 635 | + foreach($row as $colKey=>$column) { |
|
| 636 | + if(is_array($column) && isset($column['name'])) { |
|
| 637 | + $id = $column['name']; |
|
| 638 | + } else if(!is_array($column) && !empty($column)) { |
|
| 639 | + $id = $column; |
|
| 640 | + } else { |
|
| 641 | + continue; |
|
| 642 | + } |
|
| 643 | + if(empty($existingElements[$id])) { |
|
| 644 | + //Only add if |
|
| 645 | + // 1) if it is a required field (as defined in metadata) |
|
| 646 | + // 2) or if it has a customLabel and customCode (a very deep customization) |
|
| 647 | + if((is_array($column) && !empty($column['displayParams']['required'])) || |
|
| 648 | + (is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) { |
|
| 649 | + $addRow[] = $column; |
|
| 650 | + } |
|
| 651 | + } else { |
|
| 652 | + //Use definition from master copy instead |
|
| 653 | + $panels[$existingLocation[$id]['panel']][$existingLocation[$id]['row']][$existingLocation[$id]['col']] = $column; |
|
| 654 | + } |
|
| 655 | + } //foreach |
|
| 656 | + |
|
| 657 | + // Add it to the $panels |
|
| 658 | + if(!empty($addRow)) { |
|
| 659 | + $panels[$name][] = $addRow; |
|
| 660 | + } |
|
| 661 | + } //foreach |
|
| 662 | + |
|
| 663 | + } else { |
|
| 664 | + $panels[$name] = $masterpanel; |
|
| 665 | + } |
|
| 666 | + } //foreach |
|
| 667 | + |
|
| 668 | + // We're not done yet... go through the $panels Array now and try to remove duplicate |
|
| 669 | + // or empty panels |
|
| 670 | + foreach($panels as $name=>$panel) { |
|
| 671 | + if(count($panel) == 0 || !isset($masterpanels[$name])) { |
|
| 672 | + unset($panels[$name]); |
|
| 673 | + } |
|
| 674 | + } //foreach |
|
| 675 | + |
|
| 676 | + return $panels; |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | /** |
@@ -685,70 +685,70 @@ discard block |
||
| 685 | 685 | * @return Array of merged $templateMeta definition |
| 686 | 686 | */ |
| 687 | 687 | function mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy) { |
| 688 | - require($masterCopy); |
|
| 689 | - $masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta']; |
|
| 688 | + require($masterCopy); |
|
| 689 | + $masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta']; |
|
| 690 | 690 | |
| 691 | - if(isset($masterTemplateMeta['javascript'])) { |
|
| 692 | - //Insert the getJSPath code back into src value |
|
| 693 | - $masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']); |
|
| 694 | - } |
|
| 691 | + if(isset($masterTemplateMeta['javascript'])) { |
|
| 692 | + //Insert the getJSPath code back into src value |
|
| 693 | + $masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']); |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | - return $masterTemplateMeta; |
|
| 696 | + return $masterTemplateMeta; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | function hasRequiredSpanLabel($html) { |
| 700 | - if(empty($html)) { |
|
| 701 | - return false; |
|
| 702 | - } |
|
| 700 | + if(empty($html)) { |
|
| 701 | + return false; |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - return preg_match('/\<(div|span) class=(\")?required(\")?\s?>\*<\/(div|span)>/si', $html); |
|
| 704 | + return preg_match('/\<(div|span) class=(\")?required(\")?\s?>\*<\/(div|span)>/si', $html); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | function hasMultiplePanels($panels) { |
| 708 | 708 | |
| 709 | - if(!isset($panels) || empty($panels) || !is_array($panels)) { |
|
| 710 | - return false; |
|
| 711 | - } |
|
| 709 | + if(!isset($panels) || empty($panels) || !is_array($panels)) { |
|
| 710 | + return false; |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
| 714 | - return false; |
|
| 715 | - } |
|
| 713 | + if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
| 714 | + return false; |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - foreach($panels as $panel) { |
|
| 718 | - if(!empty($panel) && !is_array($panel)) { |
|
| 719 | - return false; |
|
| 720 | - } else { |
|
| 721 | - foreach($panel as $row) { |
|
| 722 | - if(!empty($row) && !is_array($row)) { |
|
| 723 | - return false; |
|
| 724 | - } //if |
|
| 725 | - } //foreach |
|
| 726 | - } //if-else |
|
| 727 | - } //foreach |
|
| 717 | + foreach($panels as $panel) { |
|
| 718 | + if(!empty($panel) && !is_array($panel)) { |
|
| 719 | + return false; |
|
| 720 | + } else { |
|
| 721 | + foreach($panel as $row) { |
|
| 722 | + if(!empty($row) && !is_array($row)) { |
|
| 723 | + return false; |
|
| 724 | + } //if |
|
| 725 | + } //foreach |
|
| 726 | + } //if-else |
|
| 727 | + } //foreach |
|
| 728 | 728 | |
| 729 | - return true; |
|
| 729 | + return true; |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | function getRelateFieldName($mixed='') { |
| 733 | - if(!is_array($mixed)) { |
|
| 734 | - return ''; |
|
| 735 | - } else if(count($mixed) == 2){ |
|
| 736 | - $id = ''; |
|
| 737 | - $name = ''; |
|
| 738 | - foreach($mixed as $el) { |
|
| 739 | - if(preg_match('/_id$/', $el)) { |
|
| 740 | - $id = $el; |
|
| 741 | - } else if(preg_match('/_name$/', $el)) { |
|
| 742 | - $name = $el; |
|
| 743 | - } |
|
| 744 | - } |
|
| 745 | - return (!empty($id) && !empty($name)) ? $name : ''; |
|
| 746 | - } |
|
| 747 | - return ''; |
|
| 733 | + if(!is_array($mixed)) { |
|
| 734 | + return ''; |
|
| 735 | + } else if(count($mixed) == 2){ |
|
| 736 | + $id = ''; |
|
| 737 | + $name = ''; |
|
| 738 | + foreach($mixed as $el) { |
|
| 739 | + if(preg_match('/_id$/', $el)) { |
|
| 740 | + $id = $el; |
|
| 741 | + } else if(preg_match('/_name$/', $el)) { |
|
| 742 | + $name = $el; |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | + return (!empty($id) && !empty($name)) ? $name : ''; |
|
| 746 | + } |
|
| 747 | + return ''; |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | function getCustomPanels() { |
| 751 | - return $this->mCustomPanels; |
|
| 751 | + return $this->mCustomPanels; |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
@@ -759,10 +759,10 @@ discard block |
||
| 759 | 759 | * |
| 760 | 760 | */ |
| 761 | 761 | function fixTablesWithMissingTr($tableContents) { |
| 762 | - if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 763 | - return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents); |
|
| 764 | - } |
|
| 765 | - return $tableContents; |
|
| 762 | + if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 763 | + return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents); |
|
| 764 | + } |
|
| 765 | + return $tableContents; |
|
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | /** |
@@ -770,10 +770,10 @@ discard block |
||
| 770 | 770 | * This is a very crude function to fix instances where files have an </tr> tag immediately followed by a <td> tag |
| 771 | 771 | */ |
| 772 | 772 | function fixRowsWithMissingTr($tableContents) { |
| 773 | - if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 774 | - return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents); |
|
| 775 | - } |
|
| 776 | - return $tableContents; |
|
| 773 | + if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
| 774 | + return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents); |
|
| 775 | + } |
|
| 776 | + return $tableContents; |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
@@ -781,10 +781,10 @@ discard block |
||
| 781 | 781 | * This is a very crude function to fix instances where files have two consecutive <tr> tags |
| 782 | 782 | */ |
| 783 | 783 | function fixDuplicateTrTags($tableContents) { |
| 784 | - if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
| 785 | - return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents); |
|
| 786 | - } |
|
| 787 | - return $tableContents; |
|
| 784 | + if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
| 785 | + return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents); |
|
| 786 | + } |
|
| 787 | + return $tableContents; |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -793,18 +793,18 @@ discard block |
||
| 793 | 793 | * return that vardef name |
| 794 | 794 | */ |
| 795 | 795 | function findSingleVardefElement($formElements=array(), $vardefs=array()) { |
| 796 | - if(empty($formElements) || !is_array($formElements)) { |
|
| 797 | - return ''; |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - $found = array(); |
|
| 801 | - foreach($formElements as $el) { |
|
| 802 | - if(isset($vardefs[$el])) { |
|
| 803 | - $found[] = $el; |
|
| 804 | - } |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - return count($found) == 1 ? $found[0] : ''; |
|
| 796 | + if(empty($formElements) || !is_array($formElements)) { |
|
| 797 | + return ''; |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + $found = array(); |
|
| 801 | + foreach($formElements as $el) { |
|
| 802 | + if(isset($vardefs[$el])) { |
|
| 803 | + $found[] = $el; |
|
| 804 | + } |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + return count($found) == 1 ? $found[0] : ''; |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * getFormElementsNames |
| 98 | 98 | * Parses for the name values of input, select, textarea types from string content |
| 99 | - * @param $contents The String contents to parse |
|
| 99 | + * @param string $contents The String contents to parse |
|
| 100 | 100 | * @return $matches Array of name/value pairs |
| 101 | 101 | */ |
| 102 | 102 | function getFormElementsNames($contents) { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * getTagAttribute |
| 110 | 110 | * Returns the name/value of a tag attribute where name is set to $name |
| 111 | - * @param $name The name of the attribute |
|
| 111 | + * @param string $name The name of the attribute |
|
| 112 | 112 | * @param $contents The contents to parse |
| 113 | 113 | * @param $filter Option regular expression to filter value |
| 114 | 114 | * @return Array of name/value for matching attribute |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * and method call getElementsByType("<td>", $contents) returns |
| 164 | 164 | * "<td>Text <table><tr><td>a</td></tr></table></td>" |
| 165 | 165 | * |
| 166 | - * @param $type The type of element to parse out and return |
|
| 166 | + * @param string $type The type of element to parse out and return |
|
| 167 | 167 | * @return a tag element format Array |
| 168 | 168 | */ |
| 169 | 169 | function getElementsByType($type, $contents) { |
@@ -208,6 +208,7 @@ discard block |
||
| 208 | 208 | /** |
| 209 | 209 | * getElementValue |
| 210 | 210 | * |
| 211 | + * @param string $type |
|
| 211 | 212 | */ |
| 212 | 213 | function getElementValue($type, $contents, $filter = "(.*?)") { |
| 213 | 214 | $exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si"; |
@@ -244,7 +245,7 @@ discard block |
||
| 244 | 245 | * Returns the highest number of <td>...</td> blocks within a <tr>...</tr> block. |
| 245 | 246 | * @param $contents The table contents to parse |
| 246 | 247 | * @param $filter Optional filter to parse for an attribute within the td block. |
| 247 | - * @return The maximum column count |
|
| 248 | + * @return integer maximum column count |
|
| 248 | 249 | */ |
| 249 | 250 | function getMaxColumns($contents, $filter) { |
| 250 | 251 | preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
@@ -281,6 +282,9 @@ discard block |
||
| 281 | 282 | * trimHTML |
| 282 | 283 | * This function removes the \r (return), \n (newline) and \t (tab) markup from string |
| 283 | 284 | */ |
| 285 | +/** |
|
| 286 | + * @param string $contents |
|
| 287 | + */ |
|
| 284 | 288 | function trimHTML($contents) { |
| 285 | 289 | $contents = str_replace(array("\r"), array(""), $contents); |
| 286 | 290 | $contents = str_replace(array("\n"), array(""), $contents); |
@@ -342,6 +346,9 @@ discard block |
||
| 342 | 346 | |
| 343 | 347 | } |
| 344 | 348 | |
| 349 | +/** |
|
| 350 | + * @param string $javascript |
|
| 351 | + */ |
|
| 345 | 352 | static function parseDelimiters($javascript) { |
| 346 | 353 | $newJavascript = ''; |
| 347 | 354 | $scriptLength = strlen($javascript); |
@@ -441,7 +448,7 @@ discard block |
||
| 441 | 448 | * dirList |
| 442 | 449 | * Utility method to list all the files in a given directory. |
| 443 | 450 | * |
| 444 | - * @param $directory The directory to scan |
|
| 451 | + * @param string $directory The directory to scan |
|
| 445 | 452 | * @return $results The files in the directory that were found |
| 446 | 453 | */ |
| 447 | 454 | function dirList ($directory) { |
@@ -496,6 +503,9 @@ discard block |
||
| 496 | 503 | return null; |
| 497 | 504 | } |
| 498 | 505 | |
| 506 | +/** |
|
| 507 | + * @param string $moduleDir |
|
| 508 | + */ |
|
| 499 | 509 | function applyPreRules($moduleDir, $panels) { |
| 500 | 510 | if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
| 501 | 511 | require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
@@ -506,6 +516,9 @@ discard block |
||
| 506 | 516 | return $panels; |
| 507 | 517 | } |
| 508 | 518 | |
| 519 | +/** |
|
| 520 | + * @param string $moduleDir |
|
| 521 | + */ |
|
| 509 | 522 | function applyRules($moduleDir, $panels) { |
| 510 | 523 | return $this->applyPostRules($moduleDir, $panels); |
| 511 | 524 | } |
@@ -537,6 +550,9 @@ discard block |
||
| 537 | 550 | return $panels; |
| 538 | 551 | } |
| 539 | 552 | |
| 553 | +/** |
|
| 554 | + * @param string $moduleDir |
|
| 555 | + */ |
|
| 540 | 556 | function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) { |
| 541 | 557 | |
| 542 | 558 | $header = "<?php\n\n"; |
@@ -587,7 +603,7 @@ discard block |
||
| 587 | 603 | * mergePanels |
| 588 | 604 | * This function merges the $panels Array against the $masterCopy's meta data definition |
| 589 | 605 | * @param $panels meta data Array to merge |
| 590 | - * @param $moduleDir Directory name of the module |
|
| 606 | + * @param string $moduleDir Directory name of the module |
|
| 591 | 607 | * @param $masterCopy file path to the meta data master copy |
| 592 | 608 | * @return Array of merged $panel definition |
| 593 | 609 | */ |
@@ -680,7 +696,7 @@ discard block |
||
| 680 | 696 | * mergeTemplateMeta |
| 681 | 697 | * This function merges the $templateMeta Array against the $masterCopy's meta data definition |
| 682 | 698 | * @param $templateMeta meta data Array to merge |
| 683 | - * @param $moduleDir Directory name of the module |
|
| 699 | + * @param string $moduleDir Directory name of the module |
|
| 684 | 700 | * @param $masterCopy file path to the meta data master copy |
| 685 | 701 | * @return Array of merged $templateMeta definition |
| 686 | 702 | */ |
@@ -49,24 +49,24 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | static function fixupFieldType($field) { |
| 51 | 51 | switch($field) { |
| 52 | - case 'double': |
|
| 52 | + case 'double': |
|
| 53 | 53 | case 'decimal': |
| 54 | 54 | $field = 'float'; |
| 55 | 55 | break; |
| 56 | - case 'uint': |
|
| 56 | + case 'uint': |
|
| 57 | 57 | case 'ulong': |
| 58 | 58 | case 'long': |
| 59 | 59 | case 'short': |
| 60 | 60 | case 'tinyint': |
| 61 | 61 | $field = 'int'; |
| 62 | 62 | break; |
| 63 | - case 'date': |
|
| 63 | + case 'date': |
|
| 64 | 64 | $field = 'datetime'; |
| 65 | 65 | break; |
| 66 | - case 'url': |
|
| 67 | - $field = 'link'; |
|
| 68 | - break; |
|
| 69 | - case 'varchar': |
|
| 66 | + case 'url': |
|
| 67 | + $field = 'link'; |
|
| 68 | + break; |
|
| 69 | + case 'varchar': |
|
| 70 | 70 | $field = 'base'; |
| 71 | 71 | break; |
| 72 | 72 | } |
@@ -86,34 +86,34 @@ discard block |
||
| 86 | 86 | $field = ucfirst($field); |
| 87 | 87 | |
| 88 | 88 | if(!isset($sugarFieldObjects[$field])) { |
| 89 | - //check custom directory |
|
| 90 | - if(file_exists('custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
| 91 | - $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
| 89 | + //check custom directory |
|
| 90 | + if(file_exists('custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
| 91 | + $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
| 92 | 92 | $type = $field; |
| 93 | - //else check the fields directory |
|
| 94 | - }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
| 95 | - $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
| 93 | + //else check the fields directory |
|
| 94 | + }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
| 95 | + $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
| 96 | 96 | $type = $field; |
| 97 | - }else{ |
|
| 97 | + }else{ |
|
| 98 | 98 | // No direct class, check the directories to see if they are defined |
| 99 | - if( $returnNullIfBase && |
|
| 99 | + if( $returnNullIfBase && |
|
| 100 | 100 | !is_dir('custom/include/SugarFields/Fields/'.$field) && |
| 101 | 101 | !is_dir('include/SugarFields/Fields/'.$field) ) { |
| 102 | 102 | return null; |
| 103 | 103 | } |
| 104 | - $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php'; |
|
| 104 | + $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php'; |
|
| 105 | 105 | $type = 'Base'; |
| 106 | - } |
|
| 107 | - require_once($file); |
|
| 106 | + } |
|
| 107 | + require_once($file); |
|
| 108 | 108 | |
| 109 | - $class = 'SugarField' . $type; |
|
| 110 | - //could be a custom class check it |
|
| 111 | - $customClass = 'Custom' . $class; |
|
| 112 | - if(class_exists($customClass)){ |
|
| 113 | - $sugarFieldObjects[$field] = new $customClass($field); |
|
| 114 | - }else{ |
|
| 115 | - $sugarFieldObjects[$field] = new $class($field); |
|
| 116 | - } |
|
| 109 | + $class = 'SugarField' . $type; |
|
| 110 | + //could be a custom class check it |
|
| 111 | + $customClass = 'Custom' . $class; |
|
| 112 | + if(class_exists($customClass)){ |
|
| 113 | + $sugarFieldObjects[$field] = new $customClass($field); |
|
| 114 | + }else{ |
|
| 115 | + $sugarFieldObjects[$field] = new $class($field); |
|
| 116 | + } |
|
| 117 | 117 | } |
| 118 | 118 | return $sugarFieldObjects[$field]; |
| 119 | 119 | } |
@@ -134,22 +134,22 @@ discard block |
||
| 134 | 134 | $string = ''; |
| 135 | 135 | $displayTypeFunc = 'get' . $displayType . 'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc... |
| 136 | 136 | |
| 137 | - // This will handle custom type fields. |
|
| 138 | - // The incoming $vardef Array may have custom_type set. |
|
| 139 | - // If so, set $vardef['type'] to the $vardef['custom_type'] value |
|
| 140 | - if(isset($vardef['custom_type'])) { |
|
| 141 | - $vardef['type'] = $vardef['custom_type']; |
|
| 142 | - } |
|
| 143 | - if(empty($vardef['type'])) { |
|
| 144 | - $vardef['type'] = 'varchar'; |
|
| 145 | - } |
|
| 137 | + // This will handle custom type fields. |
|
| 138 | + // The incoming $vardef Array may have custom_type set. |
|
| 139 | + // If so, set $vardef['type'] to the $vardef['custom_type'] value |
|
| 140 | + if(isset($vardef['custom_type'])) { |
|
| 141 | + $vardef['type'] = $vardef['custom_type']; |
|
| 142 | + } |
|
| 143 | + if(empty($vardef['type'])) { |
|
| 144 | + $vardef['type'] = 'varchar'; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - $field = self::getSugarField($vardef['type']); |
|
| 148 | - if ( !empty($vardef['function']) ) { |
|
| 149 | - $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 150 | - } else { |
|
| 151 | - $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 152 | - } |
|
| 147 | + $field = self::getSugarField($vardef['type']); |
|
| 148 | + if ( !empty($vardef['function']) ) { |
|
| 149 | + $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 150 | + } else { |
|
| 151 | + $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | 154 | return $string; |
| 155 | 155 | } |
@@ -47,6 +47,9 @@ |
||
| 47 | 47 | function SugarFieldHandler() { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $field |
|
| 52 | + */ |
|
| 50 | 53 | static function fixupFieldType($field) { |
| 51 | 54 | switch($field) { |
| 52 | 55 | case 'double': |
@@ -44,19 +44,19 @@ discard block |
||
| 44 | 44 | function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
| 45 | 45 | // Create Smarty variables for the Calendar picker widget |
| 46 | 46 | if(!isset($displayParams['showMinutesDropdown'])) { |
| 47 | - $displayParams['showMinutesDropdown'] = false; |
|
| 47 | + $displayParams['showMinutesDropdown'] = false; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if(!isset($displayParams['showHoursDropdown'])) { |
| 51 | - $displayParams['showHoursDropdown'] = false; |
|
| 51 | + $displayParams['showHoursDropdown'] = false; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if(!isset($displayParams['showNoneCheckbox'])) { |
| 55 | - $displayParams['showNoneCheckbox'] = false; |
|
| 55 | + $displayParams['showNoneCheckbox'] = false; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if(!isset($displayParams['showFormats'])) { |
| 59 | - $displayParams['showFormats'] = false; |
|
| 59 | + $displayParams['showFormats'] = false; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | global $timedate; |
@@ -75,44 +75,44 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
| 77 | 77 | |
| 78 | - if($this->isRangeSearchView($vardef)) { |
|
| 79 | - $displayParams['showMinutesDropdown'] = false; |
|
| 80 | - $displayParams['showHoursDropdown'] = false; |
|
| 81 | - $displayParams['showNoneCheckbox'] = false; |
|
| 82 | - $displayParams['showFormats'] = false; |
|
| 83 | - global $timedate, $current_language; |
|
| 84 | - $displayParams['dateFormat'] = $timedate->get_cal_date_format(); |
|
| 85 | - $displayParams['timeFormat'] = $timedate->get_user_time_format(); |
|
| 86 | - |
|
| 87 | - $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 88 | - $id = isset($displayParams['idName']) ? $displayParams['idName'] : $vardef['name']; |
|
| 89 | - $this->ss->assign('original_id', "{$id}"); |
|
| 90 | - $this->ss->assign('id_range', "range_{$id}"); |
|
| 91 | - $this->ss->assign('id_range_start', "start_range_{$id}"); |
|
| 92 | - $this->ss->assign('id_range_end', "end_range_{$id}"); |
|
| 93 | - $this->ss->assign('id_range_choice', "{$id}_range_choice"); |
|
| 94 | - if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
| 95 | - { |
|
| 96 | - return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
| 97 | - } |
|
| 98 | - return $this->fetch('include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
| 78 | + if($this->isRangeSearchView($vardef)) { |
|
| 79 | + $displayParams['showMinutesDropdown'] = false; |
|
| 80 | + $displayParams['showHoursDropdown'] = false; |
|
| 81 | + $displayParams['showNoneCheckbox'] = false; |
|
| 82 | + $displayParams['showFormats'] = false; |
|
| 83 | + global $timedate, $current_language; |
|
| 84 | + $displayParams['dateFormat'] = $timedate->get_cal_date_format(); |
|
| 85 | + $displayParams['timeFormat'] = $timedate->get_user_time_format(); |
|
| 86 | + |
|
| 87 | + $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 88 | + $id = isset($displayParams['idName']) ? $displayParams['idName'] : $vardef['name']; |
|
| 89 | + $this->ss->assign('original_id', "{$id}"); |
|
| 90 | + $this->ss->assign('id_range', "range_{$id}"); |
|
| 91 | + $this->ss->assign('id_range_start', "start_range_{$id}"); |
|
| 92 | + $this->ss->assign('id_range_end', "end_range_{$id}"); |
|
| 93 | + $this->ss->assign('id_range_choice', "{$id}_range_choice"); |
|
| 94 | + if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
| 95 | + { |
|
| 96 | + return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
| 97 | + } |
|
| 98 | + return $this->fetch('include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - // Create Smarty variables for the Calendar picker widget |
|
| 101 | + // Create Smarty variables for the Calendar picker widget |
|
| 102 | 102 | if(!isset($displayParams['showMinutesDropdown'])) { |
| 103 | - $displayParams['showMinutesDropdown'] = false; |
|
| 103 | + $displayParams['showMinutesDropdown'] = false; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | if(!isset($displayParams['showHoursDropdown'])) { |
| 107 | - $displayParams['showHoursDropdown'] = false; |
|
| 107 | + $displayParams['showHoursDropdown'] = false; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | if(!isset($displayParams['showNoneCheckbox'])) { |
| 111 | - $displayParams['showNoneCheckbox'] = false; |
|
| 111 | + $displayParams['showNoneCheckbox'] = false; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if(!isset($displayParams['showFormats'])) { |
| 115 | - $displayParams['showFormats'] = false; |
|
| 115 | + $displayParams['showFormats'] = false; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | global $timedate; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
| 127 | - public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0){ |
|
| 127 | + public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0){ |
|
| 128 | 128 | // This does not return a smarty section, instead it returns a direct value |
| 129 | 129 | if(isset($context['notify_user'])) { |
| 130 | 130 | $user = $context['notify_user']; |
@@ -143,14 +143,14 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | if(strpos($params[$prefix.$field], ' ') > 0) { |
| 145 | 145 | if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATETIME_FORMAT)) { |
| 146 | - $bean->$field = $params[$prefix.$field]; |
|
| 146 | + $bean->$field = $params[$prefix.$field]; |
|
| 147 | 147 | } else { |
| 148 | 148 | $bean->$field = $timedate->to_db($params[$prefix.$field]); |
| 149 | 149 | } |
| 150 | 150 | } else { |
| 151 | - $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]); |
|
| 152 | - //Default to assume date format value |
|
| 153 | - if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) { |
|
| 151 | + $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]); |
|
| 152 | + //Default to assume date format value |
|
| 153 | + if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) { |
|
| 154 | 154 | $bean->$field = $params[$prefix.$field]; |
| 155 | 155 | } else { |
| 156 | 156 | $bean->$field = $timedate->to_db_date($params[$prefix.$field]); |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | if ( !$timedate->check_matching_format($value, $format) ) { |
| 176 | 176 | $parts = $timedate->split_date_time($value); |
| 177 | 177 | if(empty($parts[0])) { |
| 178 | - $datepart = $timedate->getNow()->format($settings->dateformat); |
|
| 178 | + $datepart = $timedate->getNow()->format($settings->dateformat); |
|
| 179 | 179 | } |
| 180 | 180 | else { |
| 181 | - $datepart = $parts[0]; |
|
| 181 | + $datepart = $parts[0]; |
|
| 182 | 182 | } |
| 183 | 183 | if(empty($parts[1])) { |
| 184 | 184 | $timepart = $timedate->fromTimestamp(0)->format($settings->timeformat); |
@@ -41,14 +41,14 @@ |
||
| 41 | 41 | |
| 42 | 42 | class SugarFieldAssigned_user_name extends SugarFieldBase { |
| 43 | 43 | |
| 44 | - function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
|
| 45 | - $vardef['options'] = get_user_array(false); |
|
| 46 | - if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){ |
|
| 47 | - $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 48 | - return $this->fetch($this->findTemplate('EditViewFunction')); |
|
| 49 | - }else{ |
|
| 50 | - $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 51 | - return $this->fetch($this->findTemplate('SearchView')); |
|
| 52 | - } |
|
| 44 | + function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
|
| 45 | + $vardef['options'] = get_user_array(false); |
|
| 46 | + if(!empty($vardef['function']['returns']) && $vardef['function']['returns']== 'html'){ |
|
| 47 | + $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 48 | + return $this->fetch($this->findTemplate('EditViewFunction')); |
|
| 49 | + }else{ |
|
| 50 | + $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 51 | + return $this->fetch($this->findTemplate('SearchView')); |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | require_once 'include/clean.php'; |
| 42 | 42 | class SugarFieldText extends SugarFieldBase { |
| 43 | 43 | |
| 44 | - function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
|
| 44 | + function getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
|
| 45 | 45 | if(!isset($displayParams['nl2br'])){ |
| 46 | 46 | $displayParams['nl2br'] = true; |
| 47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | if(!isset($displayParams['url2html'])) { |
| 52 | 52 | $displayParams['url2html'] = true; |
| 53 | 53 | } |
| 54 | - return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 54 | + return parent::getDetailViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
| 55 | 55 | } |
| 56 | 56 | function getClassicEditView($field_id='description', $value='', $prefix='', $rich_text=false, $maxlength='', $tabindex=1, $cols=80, $rows=4) { |
| 57 | 57 | |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | $this->ss->assign('displayParams', $displayParams); |
| 71 | - if(isset($GLOBALS['current_user'])) { |
|
| 72 | - $height = $GLOBALS['current_user']->getPreference('text_editor_height'); |
|
| 73 | - $width = $GLOBALS['current_user']->getPreference('text_editor_width'); |
|
| 74 | - $height = isset($height) ? $height : '300px'; |
|
| 75 | - $width = isset($width) ? $width : '95%'; |
|
| 76 | - $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height); |
|
| 77 | - $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width); |
|
| 78 | - } else { |
|
| 79 | - $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px'); |
|
| 80 | - $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%'); |
|
| 81 | - } |
|
| 71 | + if(isset($GLOBALS['current_user'])) { |
|
| 72 | + $height = $GLOBALS['current_user']->getPreference('text_editor_height'); |
|
| 73 | + $width = $GLOBALS['current_user']->getPreference('text_editor_width'); |
|
| 74 | + $height = isset($height) ? $height : '300px'; |
|
| 75 | + $width = isset($width) ? $width : '95%'; |
|
| 76 | + $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height); |
|
| 77 | + $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width); |
|
| 78 | + } else { |
|
| 79 | + $this->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px'); |
|
| 80 | + $this->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%'); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - return $this->ss->fetch($this->findTemplate('ClassicEditView')); |
|
| 83 | + return $this->ss->fetch($this->findTemplate('ClassicEditView')); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | ?> |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | var $object_name = 'EmailAddress'; |
| 57 | 57 | |
| 58 | 58 | //bug 40068, According to rules in page 6 of http://www.apps.ietf.org/rfc/rfc3696.html#sec-3, |
| 59 | - //allowed special characters ! # $ % & ' * + - / = ? ^ _ ` . { | } ~ in local part |
|
| 59 | + //allowed special characters ! # $ % & ' * + - / = ? ^ _ ` . { | } ~ in local part |
|
| 60 | 60 | var $regex = "/^(?:['\.\-\+&#!\$\*=\?\^_`\{\}~\/\w]+)@(?:(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\w+(?:[\.-]*\w+)*(?:\.[\w-]{2,})+)\$/"; |
| 61 | 61 | var $disable_custom_fields = true; |
| 62 | 62 | var $db; |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | // determine which array to process |
| 392 | 392 | foreach($_REQUEST as $k => $v) { |
| 393 | 393 | if(strpos($k, 'emailAddress') !== false) { |
| 394 | - $fromRequest = true; |
|
| 395 | - break; |
|
| 394 | + $fromRequest = true; |
|
| 395 | + break; |
|
| 396 | 396 | } |
| 397 | 397 | $widget_id = $_REQUEST[$module .'_email_widget_id']; |
| 398 | 398 | } |
@@ -409,30 +409,30 @@ discard block |
||
| 409 | 409 | |
| 410 | 410 | $eId = $module . $widget_id; |
| 411 | 411 | if(isset($_REQUEST[$eId . 'emailAddressPrimaryFlag'])) { |
| 412 | - $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag']; |
|
| 412 | + $primaryValue = $_REQUEST[$eId . 'emailAddressPrimaryFlag']; |
|
| 413 | 413 | } else if(isset($_REQUEST[$module . 'emailAddressPrimaryFlag'])) { |
| 414 | - $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag']; |
|
| 414 | + $primaryValue = $_REQUEST[$module . 'emailAddressPrimaryFlag']; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $optOutValues = array(); |
| 418 | 418 | if(isset($_REQUEST[$eId .'emailAddressOptOutFlag'])) { |
| 419 | - $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag']; |
|
| 419 | + $optOutValues = $_REQUEST[$eId .'emailAddressOptOutFlag']; |
|
| 420 | 420 | } else if(isset($_REQUEST[$module . 'emailAddressOptOutFlag'])) { |
| 421 | - $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag']; |
|
| 421 | + $optOutValues = $_REQUEST[$module . 'emailAddressOptOutFlag']; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $invalidValues = array(); |
| 425 | 425 | if(isset($_REQUEST[$eId .'emailAddressInvalidFlag'])) { |
| 426 | - $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag']; |
|
| 426 | + $invalidValues = $_REQUEST[$eId .'emailAddressInvalidFlag']; |
|
| 427 | 427 | } else if(isset($_REQUEST[$module . 'emailAddressInvalidFlag'])) { |
| 428 | - $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag']; |
|
| 428 | + $invalidValues = $_REQUEST[$module . 'emailAddressInvalidFlag']; |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $deleteValues = array(); |
| 432 | 432 | if(isset($_REQUEST[$eId .'emailAddressDeleteFlag'])) { |
| 433 | - $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag']; |
|
| 433 | + $deleteValues = $_REQUEST[$eId .'emailAddressDeleteFlag']; |
|
| 434 | 434 | } else if(isset($_REQUEST[$module . 'emailAddressDeleteFlag'])) { |
| 435 | - $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag']; |
|
| 435 | + $deleteValues = $_REQUEST[$module . 'emailAddressDeleteFlag']; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // prep from form save |
@@ -446,9 +446,9 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | if($fromRequest && empty($replyTo)) { |
| 448 | 448 | if(isset($_REQUEST[$eId .'emailAddressReplyToFlag'])) { |
| 449 | - $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag']; |
|
| 449 | + $replyToField = $_REQUEST[$eId .'emailAddressReplyToFlag']; |
|
| 450 | 450 | } else if(isset($_REQUEST[$module . 'emailAddressReplyToFlag'])) { |
| 451 | - $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag']; |
|
| 451 | + $replyToField = $_REQUEST[$module . 'emailAddressReplyToFlag']; |
|
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | if($fromRequest && empty($new_addrs)) { |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | if(preg_match('/'.$eId.'emailAddressVerifiedValue[0-9]+$/i', $k) && !empty($v)) { |
| 473 | 473 | $validateFlag = str_replace("Value", "Flag", $k); |
| 474 | 474 | if (isset($_REQUEST[$validateFlag]) && $_REQUEST[$validateFlag] == "true") |
| 475 | - $new_addrs[$k] = $v; |
|
| 475 | + $new_addrs[$k] = $v; |
|
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | } |
@@ -484,18 +484,18 @@ discard block |
||
| 484 | 484 | $optOutValues = array(); |
| 485 | 485 | $invalidValues = array(); |
| 486 | 486 | foreach($new_addrs as $k=>$email) { |
| 487 | - preg_match('/emailAddress([0-9])+$/', $k, $matches); |
|
| 488 | - $count = $matches[1]; |
|
| 489 | - $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'"); |
|
| 490 | - if(!empty($result)) { |
|
| 491 | - $row=$this->db->fetchByAssoc($result); |
|
| 492 | - if(!empty($row['opt_out'])) { |
|
| 493 | - $optOutValues[$k] = "emailAddress$count"; |
|
| 494 | - } |
|
| 495 | - if(!empty($row['invalid_email'])) { |
|
| 496 | - $invalidValues[$k] = "emailAddress$count"; |
|
| 497 | - } |
|
| 498 | - } |
|
| 487 | + preg_match('/emailAddress([0-9])+$/', $k, $matches); |
|
| 488 | + $count = $matches[1]; |
|
| 489 | + $result = $this->db->query("SELECT opt_out, invalid_email from email_addresses where email_address_caps = '" . $this->db->quote(strtoupper($email)) . "'"); |
|
| 490 | + if(!empty($result)) { |
|
| 491 | + $row=$this->db->fetchByAssoc($result); |
|
| 492 | + if(!empty($row['opt_out'])) { |
|
| 493 | + $optOutValues[$k] = "emailAddress$count"; |
|
| 494 | + } |
|
| 495 | + if(!empty($row['invalid_email'])) { |
|
| 496 | + $invalidValues[$k] = "emailAddress$count"; |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | // Re-populate the addresses class variable if we have new address(es). |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | |
| 523 | 523 | //If no widgets, set addresses array to empty |
| 524 | 524 | if($post_from_email_address_widget && !$hasEmailValue) { |
| 525 | - $this->addresses = array(); |
|
| 525 | + $this->addresses = array(); |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | |
@@ -861,14 +861,14 @@ discard block |
||
| 861 | 861 | $count = 0; |
| 862 | 862 | $key = $module . $widget_id . 'emailAddress'.$count; |
| 863 | 863 | while(isset($_REQUEST[$key])) { |
| 864 | - $email = $_REQUEST[$key]; |
|
| 865 | - $prefillDataArr[] = array('email_address'=>$email, |
|
| 866 | - 'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key, |
|
| 867 | - 'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']), |
|
| 868 | - 'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']), |
|
| 869 | - 'reply_to_address'=>false |
|
| 864 | + $email = $_REQUEST[$key]; |
|
| 865 | + $prefillDataArr[] = array('email_address'=>$email, |
|
| 866 | + 'primary_address'=>isset($_REQUEST['emailAddressPrimaryFlag']) && $_REQUEST['emailAddressPrimaryFlag'] == $key, |
|
| 867 | + 'invalid_email'=>isset($_REQUEST['emailAddressInvalidFlag']) && in_array($key, $_REQUEST['emailAddressInvalidFlag']), |
|
| 868 | + 'opt_out'=>isset($_REQUEST['emailAddressOptOutFlag']) && in_array($key, $_REQUEST['emailAddressOptOutFlag']), |
|
| 869 | + 'reply_to_address'=>false |
|
| 870 | 870 | ); |
| 871 | - $key = $module . $widget_id . 'emailAddress' . ++$count; |
|
| 871 | + $key = $module . $widget_id . 'emailAddress' . ++$count; |
|
| 872 | 872 | } //while |
| 873 | 873 | } |
| 874 | 874 | |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | $this->smarty->assign('emailAddressWidget',$_POST['emailAddressWidget']); |
| 986 | 986 | |
| 987 | 987 | if(isset($_POST[$mod . $widget_id . 'emailAddressPrimaryFlag'])) { |
| 988 | - $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag']; |
|
| 988 | + $primary = $_POST[$mod . $widget_id . 'emailAddressPrimaryFlag']; |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | while(isset($_POST[$mod . $widget_id . "emailAddress" . $count])) { |
@@ -994,31 +994,31 @@ discard block |
||
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | if($count == 0) { |
| 997 | - return ""; |
|
| 997 | + return ""; |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | if(isset($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'])) { |
| 1001 | - foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) { |
|
| 1002 | - $optOut[] = $v; |
|
| 1003 | - } |
|
| 1001 | + foreach($_POST[$mod . $widget_id . 'emailAddressOptOutFlag'] as $v) { |
|
| 1002 | + $optOut[] = $v; |
|
| 1003 | + } |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | if(isset($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'])) { |
| 1007 | - foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) { |
|
| 1008 | - $invalid[] = $v; |
|
| 1009 | - } |
|
| 1007 | + foreach($_POST[$mod . $widget_id . 'emailAddressInvalidFlag'] as $v) { |
|
| 1008 | + $invalid[] = $v; |
|
| 1009 | + } |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | if(isset($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'])) { |
| 1013 | - foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) { |
|
| 1014 | - $replyTo[] = $v; |
|
| 1015 | - } |
|
| 1013 | + foreach($_POST[$mod . $widget_id . 'emailAddressReplyToFlag'] as $v) { |
|
| 1014 | + $replyTo[] = $v; |
|
| 1015 | + } |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | if(isset($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'])) { |
| 1019 | - foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) { |
|
| 1020 | - $delete[] = $v; |
|
| 1021 | - } |
|
| 1019 | + foreach($_POST[$mod . $widget_id . 'emailAddressDeleteFlag'] as $v) { |
|
| 1020 | + $delete[] = $v; |
|
| 1021 | + } |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | while(isset($_POST[$mod . $widget_id . "emailAddressVerifiedValue" . $count])) { |
@@ -1052,13 +1052,13 @@ discard block |
||
| 1052 | 1052 | $get .= '&emailAddressWidget='.$_POST['emailAddressWidget']; |
| 1053 | 1053 | |
| 1054 | 1054 | while(isset($_REQUEST[$mod . $widget_id . 'emailAddress' . $count])) { |
| 1055 | - $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]); |
|
| 1056 | - $count++; |
|
| 1055 | + $get .= "&" . $mod . $widget_id . "emailAddress" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddress' . $count]); |
|
| 1056 | + $count++; |
|
| 1057 | 1057 | } //while |
| 1058 | 1058 | |
| 1059 | 1059 | while(isset($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count])) { |
| 1060 | - $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]); |
|
| 1061 | - $count++; |
|
| 1060 | + $get .= "&" . $mod . $widget_id . "emailAddressVerifiedValue" . $count . "=" . urlencode($_REQUEST[$mod . $widget_id . 'emailAddressVerifiedValue' . $count]); |
|
| 1061 | + $count++; |
|
| 1062 | 1062 | } //while |
| 1063 | 1063 | |
| 1064 | 1064 | $options = array('emailAddressPrimaryFlag', 'emailAddressOptOutFlag', 'emailAddressInvalidFlag', 'emailAddressDeleteFlag', 'emailAddressReplyToFlag'); |
@@ -1067,14 +1067,14 @@ discard block |
||
| 1067 | 1067 | $count = 0; |
| 1068 | 1068 | $optionIdentifier = $mod.$widget_id.$option; |
| 1069 | 1069 | if(isset($_REQUEST[$optionIdentifier])) { |
| 1070 | - if(is_array($_REQUEST[$optionIdentifier])) { |
|
| 1071 | - foreach($_REQUEST[$optionIdentifier] as $optOut) { |
|
| 1072 | - $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut; |
|
| 1073 | - $count++; |
|
| 1074 | - } //foreach |
|
| 1075 | - } else { |
|
| 1076 | - $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier]; |
|
| 1077 | - } |
|
| 1070 | + if(is_array($_REQUEST[$optionIdentifier])) { |
|
| 1071 | + foreach($_REQUEST[$optionIdentifier] as $optOut) { |
|
| 1072 | + $get .= "&" . $optionIdentifier . "[" . $count . "]=" . $optOut; |
|
| 1073 | + $count++; |
|
| 1074 | + } //foreach |
|
| 1075 | + } else { |
|
| 1076 | + $get .= "&" . $optionIdentifier . "=" . $_REQUEST[$optionIdentifier]; |
|
| 1077 | + } |
|
| 1078 | 1078 | } //if |
| 1079 | 1079 | } //foreach |
| 1080 | 1080 | return $get; |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | function setView($view) { |
| 1085 | - $this->view = $view; |
|
| 1085 | + $this->view = $view; |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -80,8 +80,6 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Legacy email address handling. This is to allow support for SOAP or customizations |
| 83 | - * @param string $id |
|
| 84 | - * @param string $module |
|
| 85 | 83 | */ |
| 86 | 84 | function handleLegacySave($bean, $prefix = "") { |
| 87 | 85 | if(!isset($_REQUEST) || !isset($_REQUEST['useEmailWidget'])) { |
@@ -166,12 +164,6 @@ discard block |
||
| 166 | 164 | |
| 167 | 165 | /** |
| 168 | 166 | * Saves email addresses for a parent bean |
| 169 | - * @param string $id Parent bean ID |
|
| 170 | - * @param string $module Parent bean's module |
|
| 171 | - * @param array $addresses Override of $_REQUEST vars, used to handle non-standard bean saves |
|
| 172 | - * @param string $primary GUID of primary address |
|
| 173 | - * @param string $replyTo GUID of reply-to address |
|
| 174 | - * @param string $invalid GUID of invalid address |
|
| 175 | 167 | */ |
| 176 | 168 | public function save($check_notify = FALSE) { |
| 177 | 169 | $args = func_get_args(); |
@@ -369,7 +361,6 @@ discard block |
||
| 369 | 361 | * Saves email addresses for a parent bean |
| 370 | 362 | * @param string $id Parent bean ID |
| 371 | 363 | * @param string $module Parent bean's module |
| 372 | - * @param array $addresses Override of $_REQUEST vars, used to handle non-standard bean saves |
|
| 373 | 364 | * @param string $primary GUID of primary address |
| 374 | 365 | * @param string $replyTo GUID of reply-to address |
| 375 | 366 | * @param string $invalid GUID of invalid address |
@@ -620,7 +611,7 @@ discard block |
||
| 620 | 611 | |
| 621 | 612 | /** |
| 622 | 613 | * preps a passed email address for email address storage |
| 623 | - * @param array $addr Address in focus, must be RFC compliant |
|
| 614 | + * @param string $addr Address in focus, must be RFC compliant |
|
| 624 | 615 | * @return string $id email_addresses ID |
| 625 | 616 | */ |
| 626 | 617 | function getEmailGUID($addr) { |
@@ -733,7 +724,8 @@ discard block |
||
| 733 | 724 | |
| 734 | 725 | /** |
| 735 | 726 | * Returns Primary or newest email address |
| 736 | - * @param object $focus Object in focus |
|
| 727 | + * @param boolean $focus Object in focus |
|
| 728 | + * @param string $parent_type |
|
| 737 | 729 | * @return string email |
| 738 | 730 | */ |
| 739 | 731 | function getPrimaryAddress($focus,$parent_id=null,$parent_type=null) { |
@@ -804,7 +796,7 @@ discard block |
||
| 804 | 796 | * Returns all email addresses by parent's GUID |
| 805 | 797 | * @param string $id Parent's GUID |
| 806 | 798 | * @param string $module Parent's module |
| 807 | - * @return array |
|
| 799 | + * @return string |
|
| 808 | 800 | */ |
| 809 | 801 | function getAddressesByGUID($id, $module) { |
| 810 | 802 | $return = array(); |
@@ -828,7 +820,6 @@ discard block |
||
| 828 | 820 | |
| 829 | 821 | /** |
| 830 | 822 | * Returns the HTML/JS for the EmailAddress widget |
| 831 | - * @param string $parent_id ID of parent bean, generally $focus |
|
| 832 | 823 | * @param string $module $focus' module |
| 833 | 824 | * @param bool asMetadata Default false |
| 834 | 825 | * @return string HTML/JS for widget |
@@ -965,7 +956,7 @@ discard block |
||
| 965 | 956 | |
| 966 | 957 | /** |
| 967 | 958 | * getEmailAddressWidgetDuplicatesView($focus) |
| 968 | - * @param object $focus Bean in focus |
|
| 959 | + * @param Lead $focus Bean in focus |
|
| 969 | 960 | * @return string HTML that contains hidden input values based off of HTML request |
| 970 | 961 | */ |
| 971 | 962 | function getEmailAddressWidgetDuplicatesView($focus) |
@@ -1041,6 +1032,7 @@ discard block |
||
| 1041 | 1032 | /** |
| 1042 | 1033 | * getFormBaseURL |
| 1043 | 1034 | * |
| 1035 | + * @param SugarBean $focus |
|
| 1044 | 1036 | */ |
| 1045 | 1037 | function getFormBaseURL($focus) { |
| 1046 | 1038 | $get = ""; |
@@ -1081,13 +1073,15 @@ discard block |
||
| 1081 | 1073 | |
| 1082 | 1074 | } |
| 1083 | 1075 | |
| 1076 | + /** |
|
| 1077 | + * @param string $view |
|
| 1078 | + */ |
|
| 1084 | 1079 | function setView($view) { |
| 1085 | 1080 | $this->view = $view; |
| 1086 | 1081 | } |
| 1087 | 1082 | |
| 1088 | 1083 | /** |
| 1089 | 1084 | * This function is here so the Employees/Users division can be handled cleanly in one place |
| 1090 | - * @param object $focus SugarBean |
|
| 1091 | 1085 | * @return string The value for the bean_module column in the email_addr_bean_rel table |
| 1092 | 1086 | */ |
| 1093 | 1087 | function getCorrectedModule(&$module) { |
@@ -1119,7 +1113,7 @@ discard block |
||
| 1119 | 1113 | |
| 1120 | 1114 | /** |
| 1121 | 1115 | * Convenience function for MVC (Mystique) |
| 1122 | - * @param object $focus SugarBean |
|
| 1116 | + * @param SugarBean $focus SugarBean |
|
| 1123 | 1117 | * @param string $field unused |
| 1124 | 1118 | * @param string $value unused |
| 1125 | 1119 | * @param string $view DetailView or EditView |
@@ -145,34 +145,34 @@ discard block |
||
| 145 | 145 | * @return array |
| 146 | 146 | */ |
| 147 | 147 | public function getAccessToken($url, |
| 148 | - Zend_Oauth_Token_Request $token = null, |
|
| 149 | - $httpMethod = null, |
|
| 150 | - Zend_Oauth_Http_AccessToken $request = null) |
|
| 148 | + Zend_Oauth_Token_Request $token = null, |
|
| 149 | + $httpMethod = null, |
|
| 150 | + Zend_Oauth_Http_AccessToken $request = null) |
|
| 151 | 151 | { |
| 152 | 152 | $this->setAccessTokenUrl($url); |
| 153 | 153 | $this->_last = $token = parent::getAccessToken($_REQUEST, $this->makeRequestToken()); |
| 154 | 154 | return array('oauth_token' => $token->getToken(), 'oauth_token_secret' => $token->getTokenSecret()); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - /** |
|
| 158 | - * Fetch URL with OAuth |
|
| 159 | - * @param string $url |
|
| 160 | - * @param string $params Query params |
|
| 161 | - * @param string $method HTTP method |
|
| 162 | - * @param array $headers HTTP headers |
|
| 163 | - * @return string |
|
| 164 | - */ |
|
| 157 | + /** |
|
| 158 | + * Fetch URL with OAuth |
|
| 159 | + * @param string $url |
|
| 160 | + * @param string $params Query params |
|
| 161 | + * @param string $method HTTP method |
|
| 162 | + * @param array $headers HTTP headers |
|
| 163 | + * @return string |
|
| 164 | + */ |
|
| 165 | 165 | |
| 166 | 166 | public function fetch($url, $params = null, $method = 'GET', $headers = null) |
| 167 | 167 | { |
| 168 | 168 | $acc = $this->makeAccessToken(); |
| 169 | 169 | if ( strpos($url,'?') ) { |
| 170 | - list($clean_url, $query) = explode('?', $url); |
|
| 171 | - if($query) { |
|
| 172 | - $url = $clean_url; |
|
| 173 | - parse_str($query, $query_params); |
|
| 174 | - $params = array_merge($params?$params:array(), $query_params); |
|
| 175 | - } |
|
| 170 | + list($clean_url, $query) = explode('?', $url); |
|
| 171 | + if($query) { |
|
| 172 | + $url = $clean_url; |
|
| 173 | + parse_str($query, $query_params); |
|
| 174 | + $params = array_merge($params?$params:array(), $query_params); |
|
| 175 | + } |
|
| 176 | 176 | } |
| 177 | 177 | $client = $acc->getHttpClient($this->_oauth_config, $url); |
| 178 | 178 | |
@@ -212,33 +212,33 @@ discard block |
||
| 212 | 212 | $this->_last = $resp = $client->request(); |
| 213 | 213 | $this->_lastReq = $client->getLastRequest(); |
| 214 | 214 | return $resp->getBody(); |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Get HTTP client |
|
| 219 | - * @return Zend_Oauth_Client |
|
| 220 | - */ |
|
| 221 | - public function getClient() |
|
| 222 | - { |
|
| 217 | + /** |
|
| 218 | + * Get HTTP client |
|
| 219 | + * @return Zend_Oauth_Client |
|
| 220 | + */ |
|
| 221 | + public function getClient() |
|
| 222 | + { |
|
| 223 | 223 | $acc = $this->makeAccessToken(); |
| 224 | 224 | return $acc->getHttpClient($this->_oauth_config); |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * Get last response |
|
| 229 | - * @return string |
|
| 230 | - */ |
|
| 231 | - public function getLastResponse() |
|
| 232 | - { |
|
| 227 | + /** |
|
| 228 | + * Get last response |
|
| 229 | + * @return string |
|
| 230 | + */ |
|
| 231 | + public function getLastResponse() |
|
| 232 | + { |
|
| 233 | 233 | return $this->_last; |
| 234 | - } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Get last request |
|
| 238 | - * @return string |
|
| 239 | - */ |
|
| 240 | - public function getLastRequest() |
|
| 241 | - { |
|
| 236 | + /** |
|
| 237 | + * Get last request |
|
| 238 | + * @return string |
|
| 239 | + */ |
|
| 240 | + public function getLastRequest() |
|
| 241 | + { |
|
| 242 | 242 | return $this->_lastReq; |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' برنامج الإرسال غير مدعوم.'; |
| 20 | 20 | $PHPMAILER_LANG['provide_address'] = 'يجب توفير عنوان البريد الإلكتروني لمستلم واحد على الأقل.'; |
| 21 | 21 | $PHPMAILER_LANG['recipients_failed'] = 'خطأ SMTP: الأخطاء التالية ' . |
| 22 | - 'فشل في الارسال لكل من : '; |
|
| 22 | + 'فشل في الارسال لكل من : '; |
|
| 23 | 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; |
| 24 | 24 | $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() غير ممكن.'; |
| 25 | 25 | $PHPMAILER_LANG['smtp_error'] = 'خطأ على مستوى الخادم SMTP: '; |