@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | class AOR_Chart extends Basic { |
| 26 | 26 | |
| 27 | 27 | var $colours = "['#1f78b4','#a6cee3','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99','#b15928']"; |
| 28 | - var $new_schema = true; |
|
| 29 | - var $module_dir = 'AOR_Charts'; |
|
| 30 | - var $object_name = 'AOR_Chart'; |
|
| 31 | - var $table_name = 'aor_charts'; |
|
| 32 | - var $importable = true; |
|
| 33 | - var $disable_row_level_security = true ; |
|
| 28 | + var $new_schema = true; |
|
| 29 | + var $module_dir = 'AOR_Charts'; |
|
| 30 | + var $object_name = 'AOR_Chart'; |
|
| 31 | + var $table_name = 'aor_charts'; |
|
| 32 | + var $importable = true; |
|
| 33 | + var $disable_row_level_security = true ; |
|
| 34 | 34 | |
| 35 | - var $id; |
|
| 36 | - var $name; |
|
| 37 | - var $date_entered; |
|
| 38 | - var $date_modified; |
|
| 39 | - var $modified_user_id; |
|
| 40 | - var $modified_by_name; |
|
| 41 | - var $created_by; |
|
| 42 | - var $created_by_name; |
|
| 43 | - var $description; |
|
| 44 | - var $deleted; |
|
| 45 | - var $created_by_link; |
|
| 46 | - var $modified_user_link; |
|
| 35 | + var $id; |
|
| 36 | + var $name; |
|
| 37 | + var $date_entered; |
|
| 38 | + var $date_modified; |
|
| 39 | + var $modified_user_id; |
|
| 40 | + var $modified_by_name; |
|
| 41 | + var $created_by; |
|
| 42 | + var $created_by_name; |
|
| 43 | + var $description; |
|
| 44 | + var $deleted; |
|
| 45 | + var $created_by_link; |
|
| 46 | + var $modified_user_link; |
|
| 47 | 47 | |
| 48 | 48 | var $type; |
| 49 | 49 | var $x_field; |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - function AOR_Chart(){ |
|
| 56 | - parent::Basic(); |
|
| 57 | - } |
|
| 55 | + function AOR_Chart(){ |
|
| 56 | + parent::Basic(); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | function save_lines(array $post,AOR_Report $bean,$postKey){ |
| 60 | 60 | $seenIds = array(); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | var $object_name = 'AOR_Chart'; |
| 31 | 31 | var $table_name = 'aor_charts'; |
| 32 | 32 | var $importable = true; |
| 33 | - var $disable_row_level_security = true ; |
|
| 33 | + var $disable_row_level_security = true; |
|
| 34 | 34 | |
| 35 | 35 | var $id; |
| 36 | 36 | var $name; |
@@ -52,148 +52,148 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - function AOR_Chart(){ |
|
| 55 | + function AOR_Chart() { |
|
| 56 | 56 | parent::Basic(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - function save_lines(array $post,AOR_Report $bean,$postKey){ |
|
| 59 | + function save_lines(array $post, AOR_Report $bean, $postKey) { |
|
| 60 | 60 | $seenIds = array(); |
| 61 | - if(isset($post[$postKey.'id'])) { |
|
| 62 | - foreach ($post[$postKey . 'id'] as $key => $id) { |
|
| 61 | + if (isset($post[$postKey.'id'])) { |
|
| 62 | + foreach ($post[$postKey.'id'] as $key => $id) { |
|
| 63 | 63 | if ($id) { |
| 64 | 64 | $aorChart = BeanFactory::getBean('AOR_Charts', $id); |
| 65 | 65 | } else { |
| 66 | 66 | $aorChart = BeanFactory::newBean('AOR_Charts'); |
| 67 | 67 | } |
| 68 | - $aorChart->name = $post[$postKey . 'title'][$key]; |
|
| 69 | - $aorChart->type = $post[$postKey . 'type'][$key]; |
|
| 70 | - $aorChart->x_field = $post[$postKey . 'x_field'][$key]; |
|
| 71 | - $aorChart->y_field = $post[$postKey . 'y_field'][$key]; |
|
| 68 | + $aorChart->name = $post[$postKey.'title'][$key]; |
|
| 69 | + $aorChart->type = $post[$postKey.'type'][$key]; |
|
| 70 | + $aorChart->x_field = $post[$postKey.'x_field'][$key]; |
|
| 71 | + $aorChart->y_field = $post[$postKey.'y_field'][$key]; |
|
| 72 | 72 | $aorChart->aor_report_id = $bean->id; |
| 73 | 73 | $aorChart->save(); |
| 74 | 74 | $seenIds[] = $aorChart->id; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | //Any beans that exist but aren't in $seenIds must have been removed. |
| 78 | - foreach($bean->get_linked_beans('aor_charts','AOR_Charts') as $chart){ |
|
| 79 | - if(!in_array($chart->id,$seenIds)){ |
|
| 78 | + foreach ($bean->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) { |
|
| 79 | + if (!in_array($chart->id, $seenIds)) { |
|
| 80 | 80 | $chart->mark_deleted($chart->id); |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - private function getValidChartTypes(){ |
|
| 86 | - return array('bar','line','pie','radar','rose', 'grouped_bar', 'stacked_bar'); |
|
| 85 | + private function getValidChartTypes() { |
|
| 86 | + return array('bar', 'line', 'pie', 'radar', 'rose', 'grouped_bar', 'stacked_bar'); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
| 90 | - private function getColour($seed,$rgbArray = false){ |
|
| 90 | + private function getColour($seed, $rgbArray = false) { |
|
| 91 | 91 | $hash = md5($seed); |
| 92 | 92 | $r = hexdec(substr($hash, 0, 2)); |
| 93 | 93 | $g = hexdec(substr($hash, 2, 2)); |
| 94 | 94 | $b = hexdec(substr($hash, 4, 2)); |
| 95 | - if($rgbArray){ |
|
| 96 | - return array('R'=>$r,'G'=>$g,'B'=>$b); |
|
| 95 | + if ($rgbArray) { |
|
| 96 | + return array('R'=>$r, 'G'=>$g, 'B'=>$b); |
|
| 97 | 97 | } |
| 98 | 98 | $highR = $r + 10; |
| 99 | 99 | $highG = $g + 10; |
| 100 | 100 | $highB = $b + 10; |
| 101 | - $main = '#'.str_pad(dechex($r),2,'0',STR_PAD_LEFT) |
|
| 102 | - .str_pad(dechex($g),2,'0',STR_PAD_LEFT) |
|
| 103 | - .str_pad(dechex($b),2,'0',STR_PAD_LEFT); |
|
| 101 | + $main = '#'.str_pad(dechex($r), 2, '0', STR_PAD_LEFT) |
|
| 102 | + .str_pad(dechex($g), 2, '0', STR_PAD_LEFT) |
|
| 103 | + .str_pad(dechex($b), 2, '0', STR_PAD_LEFT); |
|
| 104 | 104 | $highlight = '#'.dechex($highR).dechex($highG).dechex($highB); |
| 105 | - return array('main'=>$main,'highlight'=>$highlight); |
|
| 105 | + return array('main'=>$main, 'highlight'=>$highlight); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - function buildChartImageBar($chartPicture,$recordImageMap = false){ |
|
| 108 | + function buildChartImageBar($chartPicture, $recordImageMap = false) { |
|
| 109 | 109 | $scaleSettings = array("DrawSubTicks" => false, "LabelRotation" => 30, 'MinDivHeight' => 50); |
| 110 | 110 | $chartPicture->drawScale($scaleSettings); |
| 111 | 111 | $chartPicture->drawBarChart(array("RecordImageMap"=>$recordImageMap)); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - function buildChartImagePie($chartPicture,$chartData, $reportData,$imageHeight, $imageWidth, $xName,$recordImageMap){ |
|
| 115 | - $PieChart = new pPie($chartPicture,$chartData); |
|
| 114 | + function buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, $recordImageMap) { |
|
| 115 | + $PieChart = new pPie($chartPicture, $chartData); |
|
| 116 | 116 | $x = 0; |
| 117 | - foreach($reportData as $row){ |
|
| 118 | - $PieChart->setSliceColor($x,$this->getColour($row[$xName],true)); |
|
| 117 | + foreach ($reportData as $row) { |
|
| 118 | + $PieChart->setSliceColor($x, $this->getColour($row[$xName], true)); |
|
| 119 | 119 | $x++; |
| 120 | 120 | } |
| 121 | - $PieChart->draw2DPie($imageWidth/3,$imageHeight/2,array("Border"=>TRUE,'Radius'=>200,''=>true,"RecordImageMap"=>$recordImageMap)); |
|
| 122 | - $PieChart->drawPieLegend($imageWidth*0.7,$imageHeight/3, array('FontSize'=>10,"FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf",'BoxSize'=>14)); |
|
| 121 | + $PieChart->draw2DPie($imageWidth / 3, $imageHeight / 2, array("Border"=>TRUE, 'Radius'=>200, ''=>true, "RecordImageMap"=>$recordImageMap)); |
|
| 122 | + $PieChart->drawPieLegend($imageWidth * 0.7, $imageHeight / 3, array('FontSize'=>10, "FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", 'BoxSize'=>14)); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - function buildChartImageLine($chartPicture, $recordImageMap = false){ |
|
| 126 | - $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"GridR"=>200,"GridG"=>200,"GridB"=>200,'MinDivHeight' => 50,"LabelRotation" => 30); |
|
| 125 | + function buildChartImageLine($chartPicture, $recordImageMap = false) { |
|
| 126 | + $scaleSettings = array("XMargin"=>10, "YMargin"=>10, "GridR"=>200, "GridG"=>200, "GridB"=>200, 'MinDivHeight' => 50, "LabelRotation" => 30); |
|
| 127 | 127 | $chartPicture->drawScale($scaleSettings); |
| 128 | 128 | $chartPicture->drawLineChart(array("RecordImageMap"=>$recordImageMap)); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - function buildChartImageRadar($chartPicture, $chartData,$recordImageMap){ |
|
| 131 | + function buildChartImageRadar($chartPicture, $chartData, $recordImageMap) { |
|
| 132 | 132 | $SplitChart = new pRadar(); |
| 133 | - $Options = array("LabelPos"=>RADAR_LABELS_HORIZONTAL,"RecordImageMap"=>$recordImageMap); |
|
| 134 | - $SplitChart->drawRadar($chartPicture,$chartData,$Options); |
|
| 133 | + $Options = array("LabelPos"=>RADAR_LABELS_HORIZONTAL, "RecordImageMap"=>$recordImageMap); |
|
| 134 | + $SplitChart->drawRadar($chartPicture, $chartData, $Options); |
|
| 135 | 135 | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function buildChartImage(array $reportData, array $fields,$asDataURI = true, $generateImageMapId = false){ |
|
| 138 | + public function buildChartImage(array $reportData, array $fields, $asDataURI = true, $generateImageMapId = false) { |
|
| 139 | 139 | global $current_user; |
| 140 | 140 | require_once 'modules/AOR_Charts/lib/pChart/pChart.php'; |
| 141 | 141 | |
| 142 | - if($generateImageMapId !== false){ |
|
| 142 | + if ($generateImageMapId !== false) { |
|
| 143 | 143 | $generateImageMapId = $current_user->id."-".$generateImageMapId; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $html = ''; |
| 147 | - if(!in_array($this->type, $this->getValidChartTypes())){ |
|
| 147 | + if (!in_array($this->type, $this->getValidChartTypes())) { |
|
| 148 | 148 | return $html; |
| 149 | 149 | } |
| 150 | 150 | $x = $fields[$this->x_field]; |
| 151 | 151 | $y = $fields[$this->y_field]; |
| 152 | - if(!$x || !$y){ |
|
| 152 | + if (!$x || !$y) { |
|
| 153 | 153 | //Malformed chart object - missing an axis field |
| 154 | 154 | return ''; |
| 155 | 155 | } |
| 156 | - $xName = str_replace(' ','_',$x->label) . $this->x_field; |
|
| 157 | - $yName = str_replace(' ','_',$y->label) . $this->y_field; |
|
| 156 | + $xName = str_replace(' ', '_', $x->label).$this->x_field; |
|
| 157 | + $yName = str_replace(' ', '_', $y->label).$this->y_field; |
|
| 158 | 158 | |
| 159 | 159 | $chartData = new pData(); |
| 160 | 160 | $chartData->loadPalette("modules/AOR_Charts/lib/pChart/palettes/navy.color", TRUE); |
| 161 | 161 | $labels = array(); |
| 162 | - foreach($reportData as $row){ |
|
| 163 | - $chartData->addPoints($row[$yName],'data'); |
|
| 164 | - $chartData->addPoints($row[$xName],'Labels'); |
|
| 162 | + foreach ($reportData as $row) { |
|
| 163 | + $chartData->addPoints($row[$yName], 'data'); |
|
| 164 | + $chartData->addPoints($row[$xName], 'Labels'); |
|
| 165 | 165 | $labels[] = $row[$xName]; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $chartData->setSerieDescription("Months","Month"); |
|
| 168 | + $chartData->setSerieDescription("Months", "Month"); |
|
| 169 | 169 | $chartData->setAbscissa("Labels"); |
| 170 | 170 | |
| 171 | 171 | $imageHeight = 700; |
| 172 | 172 | $imageWidth = 700; |
| 173 | 173 | |
| 174 | - $chartPicture = new pImage($imageWidth,$imageHeight,$chartData); |
|
| 175 | - if($generateImageMapId){ |
|
| 174 | + $chartPicture = new pImage($imageWidth, $imageHeight, $chartData); |
|
| 175 | + if ($generateImageMapId) { |
|
| 176 | 176 | $imageMapDir = create_cache_directory('modules/AOR_Charts/ImageMap/'.$current_user->id.'/'); |
| 177 | - $chartPicture->initialiseImageMap($generateImageMapId,IMAGE_MAP_STORAGE_FILE,$generateImageMapId,$imageMapDir); |
|
| 177 | + $chartPicture->initialiseImageMap($generateImageMapId, IMAGE_MAP_STORAGE_FILE, $generateImageMapId, $imageMapDir); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $chartPicture->Antialias = True; |
| 181 | 181 | |
| 182 | - $chartPicture->drawFilledRectangle(0,0,$imageWidth-1,$imageHeight-1,array("R"=>240,"G"=>240,"B"=>240,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0,)); |
|
| 182 | + $chartPicture->drawFilledRectangle(0, 0, $imageWidth - 1, $imageHeight - 1, array("R"=>240, "G"=>240, "B"=>240, "BorderR"=>0, "BorderG"=>0, "BorderB"=>0,)); |
|
| 183 | 183 | |
| 184 | - $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf","FontSize"=>14)); |
|
| 184 | + $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize"=>14)); |
|
| 185 | 185 | |
| 186 | - $chartPicture->drawText($imageWidth/2,20,$this->name,array("R"=>0,"G"=>0,"B"=>0,'Align'=>TEXT_ALIGN_TOPMIDDLE)); |
|
| 187 | - $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf","FontSize"=>6)); |
|
| 186 | + $chartPicture->drawText($imageWidth / 2, 20, $this->name, array("R"=>0, "G"=>0, "B"=>0, 'Align'=>TEXT_ALIGN_TOPMIDDLE)); |
|
| 187 | + $chartPicture->setFontProperties(array("FontName"=>"modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize"=>6)); |
|
| 188 | 188 | |
| 189 | - $chartPicture->setGraphArea(60,60,$imageWidth-60,$imageHeight-100); |
|
| 189 | + $chartPicture->setGraphArea(60, 60, $imageWidth - 60, $imageHeight - 100); |
|
| 190 | 190 | |
| 191 | - switch($this->type){ |
|
| 191 | + switch ($this->type) { |
|
| 192 | 192 | case 'radar': |
| 193 | 193 | $this->buildChartImageRadar($chartPicture, $chartData, !empty($generateImageMapId)); |
| 194 | 194 | break; |
| 195 | 195 | case 'pie': |
| 196 | - $this->buildChartImagePie($chartPicture,$chartData, $reportData,$imageHeight, $imageWidth, $xName, !empty($generateImageMapId)); |
|
| 196 | + $this->buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, !empty($generateImageMapId)); |
|
| 197 | 197 | break; |
| 198 | 198 | case 'line': |
| 199 | 199 | $this->buildChartImageLine($chartPicture, !empty($generateImageMapId)); |
@@ -203,50 +203,50 @@ discard block |
||
| 203 | 203 | $this->buildChartImageBar($chartPicture, !empty($generateImageMapId)); |
| 204 | 204 | break; |
| 205 | 205 | } |
| 206 | - if($generateImageMapId) { |
|
| 206 | + if ($generateImageMapId) { |
|
| 207 | 207 | $chartPicture->replaceImageMapTitle("data", $labels); |
| 208 | 208 | } |
| 209 | 209 | ob_start(); |
| 210 | 210 | $chartPicture->render(''); |
| 211 | 211 | $img = ob_get_clean(); |
| 212 | - if($asDataURI){ |
|
| 212 | + if ($asDataURI) { |
|
| 213 | 213 | return 'data:image/png;base64,'.base64_encode($img); |
| 214 | - }else{ |
|
| 214 | + } else { |
|
| 215 | 215 | return $img; |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public function buildChartHTML(array $reportData, array $fields,$index = 0, $chartType = AOR_Report::CHART_TYPE_PCHART, AOR_Field $mainGroupField = null){ |
|
| 220 | - switch($chartType){ |
|
| 219 | + public function buildChartHTML(array $reportData, array $fields, $index = 0, $chartType = AOR_Report::CHART_TYPE_PCHART, AOR_Field $mainGroupField = null) { |
|
| 220 | + switch ($chartType) { |
|
| 221 | 221 | case AOR_Report::CHART_TYPE_PCHART: |
| 222 | - return $this->buildChartHTMLPChart($reportData,$fields,$index); |
|
| 222 | + return $this->buildChartHTMLPChart($reportData, $fields, $index); |
|
| 223 | 223 | case AOR_Report::CHART_TYPE_CHARTJS: |
| 224 | - return $this->buildChartHTMLChartJS($reportData,$fields); |
|
| 224 | + return $this->buildChartHTMLChartJS($reportData, $fields); |
|
| 225 | 225 | case AOR_Report::CHART_TYPE_RGRAPH: |
| 226 | - return $this->buildChartHTMLRGraph($reportData,$fields, $mainGroupField); |
|
| 226 | + return $this->buildChartHTMLRGraph($reportData, $fields, $mainGroupField); |
|
| 227 | 227 | } |
| 228 | 228 | return ''; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
| 232 | - private function buildChartHTMLRGraph(array $reportData, array $fields, AOR_Field $mainGroupField = null){ |
|
| 232 | + private function buildChartHTMLRGraph(array $reportData, array $fields, AOR_Field $mainGroupField = null) { |
|
| 233 | 233 | $html = ''; |
| 234 | - if(!in_array($this->type, $this->getValidChartTypes())){ |
|
| 234 | + if (!in_array($this->type, $this->getValidChartTypes())) { |
|
| 235 | 235 | return $html; |
| 236 | 236 | } |
| 237 | 237 | $x = $fields[$this->x_field]; |
| 238 | 238 | $y = $fields[$this->y_field]; |
| 239 | - if(!$x || !$y){ |
|
| 239 | + if (!$x || !$y) { |
|
| 240 | 240 | //Malformed chart object - missing an axis field |
| 241 | 241 | return ''; |
| 242 | 242 | } |
| 243 | - $xName = str_replace(' ','_',$x->label) . $this->x_field; |
|
| 244 | - $yName = str_replace(' ','_',$y->label) . $this->y_field; |
|
| 243 | + $xName = str_replace(' ', '_', $x->label).$this->x_field; |
|
| 244 | + $yName = str_replace(' ', '_', $y->label).$this->y_field; |
|
| 245 | 245 | |
| 246 | 246 | $defaultHeight = 500; |
| 247 | 247 | $defaultWidth = 900; |
| 248 | 248 | |
| 249 | - switch($this->type){ |
|
| 249 | + switch ($this->type) { |
|
| 250 | 250 | /* |
| 251 | 251 | //Polar was not implemented for the previous library (it is not in the getValidChartTypes method) |
| 252 | 252 | case 'polar': |
@@ -257,56 +257,56 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | case 'radar': |
| 259 | 259 | $chartFunction = 'Radar'; |
| 260 | - $data = $this->getRGraphBarChartData($reportData, $xName,$yName); |
|
| 260 | + $data = $this->getRGraphBarChartData($reportData, $xName, $yName); |
|
| 261 | 261 | $config = $this->getRadarChartConfig(); |
| 262 | - $chart = $this->getRGraphRadarChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth); |
|
| 262 | + $chart = $this->getRGraphRadarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth); |
|
| 263 | 263 | break; |
| 264 | 264 | case 'pie': |
| 265 | 265 | $chartFunction = 'Pie'; |
| 266 | - $data = $this->getRGraphBarChartData($reportData, $xName,$yName); |
|
| 266 | + $data = $this->getRGraphBarChartData($reportData, $xName, $yName); |
|
| 267 | 267 | $config = $this->getPieChartConfig(); |
| 268 | - $chart = $this->getRGraphPieChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth); |
|
| 268 | + $chart = $this->getRGraphPieChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth); |
|
| 269 | 269 | break; |
| 270 | 270 | case 'line': |
| 271 | 271 | $chartFunction = 'Line'; |
| 272 | - $data = $this->getRGraphBarChartData($reportData, $xName,$yName); |
|
| 272 | + $data = $this->getRGraphBarChartData($reportData, $xName, $yName); |
|
| 273 | 273 | $config = $this->getLineChartConfig(); |
| 274 | - $chart = $this->getRGraphLineChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth); |
|
| 274 | + $chart = $this->getRGraphLineChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth); |
|
| 275 | 275 | break; |
| 276 | 276 | case 'rose': |
| 277 | 277 | $chartFunction = 'Rose'; |
| 278 | - $data = $this->getRGraphBarChartData($reportData, $xName,$yName); |
|
| 278 | + $data = $this->getRGraphBarChartData($reportData, $xName, $yName); |
|
| 279 | 279 | $config = $this->getRoseChartConfig(); |
| 280 | - $chart = $this->getRGraphRoseChart(json_encode($data['data']), json_encode($data['labels']),json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth); |
|
| 280 | + $chart = $this->getRGraphRoseChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth); |
|
| 281 | 281 | break; |
| 282 | 282 | case 'grouped_bar': |
| 283 | 283 | $chartFunction = 'Grouped bar'; |
| 284 | - $data = $this->getRGraphGroupedBarChartData($reportData, $xName,$yName, $mainGroupField); |
|
| 284 | + $data = $this->getRGraphGroupedBarChartData($reportData, $xName, $yName, $mainGroupField); |
|
| 285 | 285 | $config = $this->getGroupedBarChartConfig(); |
| 286 | - $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth, true); |
|
| 286 | + $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth, true); |
|
| 287 | 287 | break; |
| 288 | 288 | case 'stacked_bar': |
| 289 | 289 | $chartFunction = 'Stacked bar'; |
| 290 | - $data = $this->getRGraphGroupedBarChartData($reportData, $xName,$yName, $mainGroupField); |
|
| 290 | + $data = $this->getRGraphGroupedBarChartData($reportData, $xName, $yName, $mainGroupField); |
|
| 291 | 291 | $config = $this->getStackedBarChartConfig(); |
| 292 | - $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth, false); |
|
| 292 | + $chart = $this->getRGraphGroupedBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth, false); |
|
| 293 | 293 | break; |
| 294 | 294 | case 'bar': |
| 295 | 295 | default: |
| 296 | 296 | $chartFunction = 'Bar'; |
| 297 | - $data = $this->getRGraphBarChartData($reportData, $xName,$yName); |
|
| 297 | + $data = $this->getRGraphBarChartData($reportData, $xName, $yName); |
|
| 298 | 298 | $config = $this->getBarChartConfig(); |
| 299 | - $chart = $this->getRGraphBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight,$defaultWidth); |
|
| 299 | + $chart = $this->getRGraphBarChart(json_encode($data['data']), json_encode($data['labels']), json_encode($data['tooltips']), $this->name, $this->id, $defaultHeight, $defaultWidth); |
|
| 300 | 300 | break; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | return $chart; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - private function getRGraphRoseChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 306 | + private function getRGraphRoseChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 307 | 307 | { |
| 308 | 308 | $dataArray = json_decode($chartDataValues); |
| 309 | - if(!is_array($dataArray)||count($dataArray) < 1) |
|
| 309 | + if (!is_array($dataArray) || count($dataArray) < 1) |
|
| 310 | 310 | { |
| 311 | 311 | return "<h3>$this->noDataMessage</h3>"; |
| 312 | 312 | } |
@@ -340,14 +340,14 @@ discard block |
||
| 340 | 340 | //I have not used a parameter for getRGraphBarChart to say whether to group etc, as the future development could be quite different |
| 341 | 341 | //for both, hence the separate methods. However, the $grouped parameter allows us to specify whether the chart is grouped (true) |
| 342 | 342 | //or stacked (false) |
| 343 | - private function getRGraphGroupedBarChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400, $grouped = false) |
|
| 343 | + private function getRGraphGroupedBarChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400, $grouped = false) |
|
| 344 | 344 | { |
| 345 | 345 | //$keys = array_keys($chartTooltips); |
| 346 | 346 | |
| 347 | 347 | |
| 348 | - $i=0; |
|
| 349 | - foreach($chartDataValues as $rowKey => $row) { |
|
| 350 | - foreach($row as $key => $value) { |
|
| 348 | + $i = 0; |
|
| 349 | + foreach ($chartDataValues as $rowKey => $row) { |
|
| 350 | + foreach ($row as $key => $value) { |
|
| 351 | 351 | $_tooltips[$rowKey][$key] = $chartTooltips[$i]; |
| 352 | 352 | $i++; |
| 353 | 353 | } |
@@ -356,9 +356,9 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | $dataArray = json_decode($chartDataValues); |
| 358 | 358 | $grouping = 'grouped'; //$mainGroupField->label; //'grouped'; |
| 359 | - if(!$grouped) |
|
| 360 | - $grouping='stacked'; |
|
| 361 | - if(!is_array($dataArray)||count($dataArray) < 1) |
|
| 359 | + if (!$grouped) |
|
| 360 | + $grouping = 'stacked'; |
|
| 361 | + if (!is_array($dataArray) || count($dataArray) < 1) |
|
| 362 | 362 | { |
| 363 | 363 | return "<h3>$this->noDataMessage</h3>"; |
| 364 | 364 | } |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | |
| 401 | 401 | |
| 402 | - private function getRGraphBarChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 402 | + private function getRGraphBarChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 403 | 403 | { |
| 404 | 404 | $dataArray = json_decode($chartDataValues); |
| 405 | - if(!is_array($dataArray)||count($dataArray) < 1) |
|
| 405 | + if (!is_array($dataArray) || count($dataArray) < 1) |
|
| 406 | 406 | { |
| 407 | 407 | return "<h3>$this->noDataMessage</h3>"; |
| 408 | 408 | } |
@@ -439,10 +439,10 @@ discard block |
||
| 439 | 439 | return $html; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - private function getRGraphRadarChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 442 | + private function getRGraphRadarChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 443 | 443 | { |
| 444 | 444 | $dataArray = json_decode($chartDataValues); |
| 445 | - if(!is_array($dataArray)||count($dataArray) < 1) |
|
| 445 | + if (!is_array($dataArray) || count($dataArray) < 1) |
|
| 446 | 446 | { |
| 447 | 447 | return "<h3>$this->noDataMessage</h3>"; |
| 448 | 448 | } |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | return $html; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - private function getRGraphPieChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 475 | + private function getRGraphPieChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 476 | 476 | { |
| 477 | 477 | $dataArray = json_decode($chartDataValues); |
| 478 | - if(!is_array($dataArray)||count($dataArray) < 1) |
|
| 478 | + if (!is_array($dataArray) || count($dataArray) < 1) |
|
| 479 | 479 | { |
| 480 | 480 | return "<h3>$this->noDataMessage</h3>"; |
| 481 | 481 | } |
@@ -508,10 +508,10 @@ discard block |
||
| 508 | 508 | return $html; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - private function getRGraphLineChart($chartDataValues, $chartLabelValues,$chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 511 | + private function getRGraphLineChart($chartDataValues, $chartLabelValues, $chartTooltips, $chartName, $chartId, $chartHeight = 400, $chartWidth = 400) |
|
| 512 | 512 | { |
| 513 | 513 | $dataArray = json_decode($chartDataValues); |
| 514 | - if(!is_array($dataArray)||count($dataArray) < 1) |
|
| 514 | + if (!is_array($dataArray) || count($dataArray) < 1) |
|
| 515 | 515 | { |
| 516 | 516 | return "<h3>$this->noDataMessage</h3>"; |
| 517 | 517 | } |
@@ -551,45 +551,45 @@ discard block |
||
| 551 | 551 | return $html; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - private function buildChartHTMLChartJS(array $reportData, array $fields){ |
|
| 554 | + private function buildChartHTMLChartJS(array $reportData, array $fields) { |
|
| 555 | 555 | $html = ''; |
| 556 | - if(!in_array($this->type, $this->getValidChartTypes())){ |
|
| 556 | + if (!in_array($this->type, $this->getValidChartTypes())) { |
|
| 557 | 557 | return $html; |
| 558 | 558 | } |
| 559 | 559 | $x = $fields[$this->x_field]; |
| 560 | 560 | $y = $fields[$this->y_field]; |
| 561 | - if(!$x || !$y){ |
|
| 561 | + if (!$x || !$y) { |
|
| 562 | 562 | //Malformed chart object - missing an axis field |
| 563 | 563 | return ''; |
| 564 | 564 | } |
| 565 | - $xName = str_replace(' ','_',$x->label) . $this->x_field; |
|
| 566 | - $yName = str_replace(' ','_',$y->label) . $this->y_field; |
|
| 565 | + $xName = str_replace(' ', '_', $x->label).$this->x_field; |
|
| 566 | + $yName = str_replace(' ', '_', $y->label).$this->y_field; |
|
| 567 | 567 | |
| 568 | - switch($this->type){ |
|
| 568 | + switch ($this->type) { |
|
| 569 | 569 | case 'polar': |
| 570 | 570 | $chartFunction = 'PolarArea'; |
| 571 | - $data = $this->getPolarChartData($reportData, $xName,$yName); |
|
| 571 | + $data = $this->getPolarChartData($reportData, $xName, $yName); |
|
| 572 | 572 | $config = $this->getPolarChartConfig(); |
| 573 | 573 | break; |
| 574 | 574 | case 'radar': |
| 575 | 575 | $chartFunction = 'Radar'; |
| 576 | - $data = $this->getRadarChartData($reportData, $xName,$yName); |
|
| 576 | + $data = $this->getRadarChartData($reportData, $xName, $yName); |
|
| 577 | 577 | $config = $this->getRadarChartConfig(); |
| 578 | 578 | break; |
| 579 | 579 | case 'pie': |
| 580 | 580 | $chartFunction = 'Pie'; |
| 581 | - $data = $this->getPieChartData($reportData, $xName,$yName); |
|
| 581 | + $data = $this->getPieChartData($reportData, $xName, $yName); |
|
| 582 | 582 | $config = $this->getPieChartConfig(); |
| 583 | 583 | break; |
| 584 | 584 | case 'line': |
| 585 | 585 | $chartFunction = 'Line'; |
| 586 | - $data = $this->getLineChartData($reportData, $xName,$yName); |
|
| 586 | + $data = $this->getLineChartData($reportData, $xName, $yName); |
|
| 587 | 587 | $config = $this->getLineChartConfig(); |
| 588 | 588 | break; |
| 589 | 589 | case 'bar': |
| 590 | 590 | default: |
| 591 | 591 | $chartFunction = 'Bar'; |
| 592 | - $data = $this->getBarChartData($reportData, $xName,$yName); |
|
| 592 | + $data = $this->getBarChartData($reportData, $xName, $yName); |
|
| 593 | 593 | $config = $this->getBarChartConfig(); |
| 594 | 594 | break; |
| 595 | 595 | } |
@@ -616,9 +616,9 @@ discard block |
||
| 616 | 616 | return $html; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - private function buildChartHTMLPChart(array $reportData, array $fields,$index = 0){ |
|
| 619 | + private function buildChartHTMLPChart(array $reportData, array $fields, $index = 0) { |
|
| 620 | 620 | $html = ''; |
| 621 | - $imgUri = $this->buildChartImage($reportData,$fields,true,$index); |
|
| 621 | + $imgUri = $this->buildChartImage($reportData, $fields, true, $index); |
|
| 622 | 622 | $img = "<img id='{$this->id}_img' src='{$imgUri}'>"; |
| 623 | 623 | $html .= $img; |
| 624 | 624 | $html .= <<<EOF |
@@ -633,24 +633,24 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | private function getShortenedLabel($label, $maxLabelSize = 20) |
| 635 | 635 | { |
| 636 | - if(strlen($label) > $maxLabelSize) |
|
| 636 | + if (strlen($label) > $maxLabelSize) |
|
| 637 | 637 | { |
| 638 | - return substr($label,0,$maxLabelSize).'...'; |
|
| 638 | + return substr($label, 0, $maxLabelSize).'...'; |
|
| 639 | 639 | } |
| 640 | 640 | else |
| 641 | 641 | return $label; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | |
| 645 | - private function getRGraphGroupedBarChartData($reportData, $xName,$yName, AOR_Field $mainGroupField = null){ |
|
| 645 | + private function getRGraphGroupedBarChartData($reportData, $xName, $yName, AOR_Field $mainGroupField = null) { |
|
| 646 | 646 | |
| 647 | 647 | |
| 648 | 648 | // get z-axis name |
| 649 | 649 | |
| 650 | 650 | $zName = null; |
| 651 | - foreach($reportData[0] as $key => $value) { |
|
| 651 | + foreach ($reportData[0] as $key => $value) { |
|
| 652 | 652 | $field = str_replace(' ', '_', is_null($mainGroupField) ? 'no data' : $mainGroupField->label); |
| 653 | - if (preg_match('/^' . $field . '[0-9]+/', $key)) { |
|
| 653 | + if (preg_match('/^'.$field.'[0-9]+/', $key)) { |
|
| 654 | 654 | $zName = $key; |
| 655 | 655 | break; |
| 656 | 656 | } |
@@ -664,20 +664,20 @@ discard block |
||
| 664 | 664 | $tooltips = array(); |
| 665 | 665 | |
| 666 | 666 | $usedKeys = array(); |
| 667 | - foreach($reportData as $key => $row) { |
|
| 667 | + foreach ($reportData as $key => $row) { |
|
| 668 | 668 | $filter = $row[$xName]; |
| 669 | - foreach($reportData as $key2 => $row2) { |
|
| 670 | - if($row2[$xName] == $filter && !in_array($key, $usedKeys)) { |
|
| 671 | - $data [ $row[$xName] ] [] = (float) $row[$yName]; |
|
| 672 | - $tooltips [ $row[$xName] ] [] = $row[$zName]; |
|
| 669 | + foreach ($reportData as $key2 => $row2) { |
|
| 670 | + if ($row2[$xName] == $filter && !in_array($key, $usedKeys)) { |
|
| 671 | + $data [$row[$xName]] [] = (float)$row[$yName]; |
|
| 672 | + $tooltips [$row[$xName]] [] = $row[$zName]; |
|
| 673 | 673 | $usedKeys[] = $key; |
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | $_data = array(); |
| 679 | - foreach($data as $label => $values) { |
|
| 680 | - foreach($values as $key => $value) { |
|
| 679 | + foreach ($data as $label => $values) { |
|
| 680 | + foreach ($values as $key => $value) { |
|
| 681 | 681 | $_data[$label][$tooltips[$label][$key]] = $value; |
| 682 | 682 | } |
| 683 | 683 | } |
@@ -689,11 +689,11 @@ discard block |
||
| 689 | 689 | $_data = array(); |
| 690 | 690 | $_labels = array(); |
| 691 | 691 | $_tooltips = array(); |
| 692 | - foreach($data as $label => $values) { |
|
| 692 | + foreach ($data as $label => $values) { |
|
| 693 | 693 | $_labels[] = $this->getShortenedLabel($label); |
| 694 | 694 | $_values = array(); |
| 695 | - foreach($values as $tooltip => $value) { |
|
| 696 | - $_tooltips[] = $tooltip . " ($value)"; |
|
| 695 | + foreach ($values as $tooltip => $value) { |
|
| 696 | + $_tooltips[] = $tooltip." ($value)"; |
|
| 697 | 697 | $_values[] = $value; |
| 698 | 698 | } |
| 699 | 699 | $_data[] = $_values; |
@@ -711,11 +711,11 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - private function getRGraphBarChartData($reportData, $xName,$yName){ |
|
| 715 | - $chart['labels']=array(); |
|
| 716 | - $chart['data']=array(); |
|
| 717 | - $chart['tooltips']=array(); |
|
| 718 | - foreach($reportData as $row){ |
|
| 714 | + private function getRGraphBarChartData($reportData, $xName, $yName) { |
|
| 715 | + $chart['labels'] = array(); |
|
| 716 | + $chart['data'] = array(); |
|
| 717 | + $chart['tooltips'] = array(); |
|
| 718 | + foreach ($reportData as $row) { |
|
| 719 | 719 | $chart['labels'][] = $this->getShortenedLabel($row[$xName]); |
| 720 | 720 | $chart['tooltips'][] = $row[$xName]; |
| 721 | 721 | $chart['data'][] = (float)$row[$yName]; |
@@ -725,11 +725,11 @@ discard block |
||
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | |
| 728 | - private function getBarChartData($reportData, $xName,$yName){ |
|
| 728 | + private function getBarChartData($reportData, $xName, $yName) { |
|
| 729 | 729 | $data = array(); |
| 730 | 730 | $data['labels'] = array(); |
| 731 | 731 | $datasetData = array(); |
| 732 | - foreach($reportData as $row){ |
|
| 732 | + foreach ($reportData as $row) { |
|
| 733 | 733 | $data['labels'][] = $row[$xName]; |
| 734 | 734 | $datasetData[] = $row[$yName]; |
| 735 | 735 | } |
@@ -746,14 +746,14 @@ discard block |
||
| 746 | 746 | return $data; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - private function getLineChartData($reportData, $xName,$yName){ |
|
| 750 | - return $this->getBarChartData($reportData, $xName,$yName); |
|
| 749 | + private function getLineChartData($reportData, $xName, $yName) { |
|
| 750 | + return $this->getBarChartData($reportData, $xName, $yName); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | - private function getBarChartConfig(){ |
|
| 753 | + private function getBarChartConfig() { |
|
| 754 | 754 | return array(); |
| 755 | 755 | } |
| 756 | - private function getLineChartConfig(){ |
|
| 756 | + private function getLineChartConfig() { |
|
| 757 | 757 | return $this->getBarChartConfig(); |
| 758 | 758 | } |
| 759 | 759 | |
@@ -767,36 +767,36 @@ discard block |
||
| 767 | 767 | return $this->getBarChartConfig(); |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - private function getRoseChartConfig(){ |
|
| 770 | + private function getRoseChartConfig() { |
|
| 771 | 771 | return $this->getBarChartConfig(); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - private function getRadarChartData($reportData, $xName,$yName){ |
|
| 775 | - return $this->getBarChartData($reportData, $xName,$yName); |
|
| 774 | + private function getRadarChartData($reportData, $xName, $yName) { |
|
| 775 | + return $this->getBarChartData($reportData, $xName, $yName); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | - private function getPolarChartData($reportData, $xName,$yName){ |
|
| 779 | - return $this->getPieChartData($reportData, $xName,$yName); |
|
| 778 | + private function getPolarChartData($reportData, $xName, $yName) { |
|
| 779 | + return $this->getPieChartData($reportData, $xName, $yName); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - private function getRadarChartConfig(){ |
|
| 782 | + private function getRadarChartConfig() { |
|
| 783 | 783 | return array(); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - private function getPolarChartConfig(){ |
|
| 786 | + private function getPolarChartConfig() { |
|
| 787 | 787 | return $this->getPieChartConfig(); |
| 788 | 788 | } |
| 789 | - private function getPieChartConfig(){ |
|
| 789 | + private function getPieChartConfig() { |
|
| 790 | 790 | $config = array(); |
| 791 | 791 | $config['legendTemplate'] = "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"> </span> <%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"; |
| 792 | 792 | return $config; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - private function getPieChartData($reportData, $xName,$yName){ |
|
| 795 | + private function getPieChartData($reportData, $xName, $yName) { |
|
| 796 | 796 | $data = array(); |
| 797 | 797 | |
| 798 | - foreach($reportData as $row){ |
|
| 799 | - if(!$row[$yName]){ |
|
| 798 | + foreach ($reportData as $row) { |
|
| 799 | + if (!$row[$yName]) { |
|
| 800 | 800 | continue; |
| 801 | 801 | } |
| 802 | 802 | $colour = $this->getColour($row[$xName]); |
@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Advanced OpenReports, SugarCRM Reporting. |
|
| 4 | - * @package Advanced OpenReports for SugarCRM |
|
| 5 | - * @copyright SalesAgility Ltd http://www.salesagility.com |
|
| 6 | - * |
|
| 7 | - * This program is free software; you can redistribute it and/or modify |
|
| 8 | - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
| 9 | - * the Free Software Foundation; either version 3 of the License, or |
|
| 10 | - * (at your option) any later version. |
|
| 11 | - * |
|
| 12 | - * This program is distributed in the hope that it will be useful, |
|
| 13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 | - * GNU General Public License for more details. |
|
| 16 | - * |
|
| 17 | - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 18 | - * along with this program; if not, see http://www.gnu.org/licenses |
|
| 19 | - * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
| 20 | - * Fifth Floor, Boston, MA 02110-1301 USA |
|
| 21 | - * |
|
| 22 | - * @author SalesAgility <[email protected]> |
|
| 23 | - */ |
|
| 3 | + * Advanced OpenReports, SugarCRM Reporting. |
|
| 4 | + * @package Advanced OpenReports for SugarCRM |
|
| 5 | + * @copyright SalesAgility Ltd http://www.salesagility.com |
|
| 6 | + * |
|
| 7 | + * This program is free software; you can redistribute it and/or modify |
|
| 8 | + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by |
|
| 9 | + * the Free Software Foundation; either version 3 of the License, or |
|
| 10 | + * (at your option) any later version. |
|
| 11 | + * |
|
| 12 | + * This program is distributed in the hope that it will be useful, |
|
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 | + * GNU General Public License for more details. |
|
| 16 | + * |
|
| 17 | + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 18 | + * along with this program; if not, see http://www.gnu.org/licenses |
|
| 19 | + * or write to the Free Software Foundation,Inc., 51 Franklin Street, |
|
| 20 | + * Fifth Floor, Boston, MA 02110-1301 USA |
|
| 21 | + * |
|
| 22 | + * @author SalesAgility <[email protected]> |
|
| 23 | + */ |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * This file adds support for studio |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | protected function action_getModuleFields() |
| 32 | 32 | { |
| 33 | 33 | if (!empty($_REQUEST['aor_module']) && $_REQUEST['aor_module'] != '') { |
| 34 | - if(isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != ''){ |
|
| 35 | - $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']); |
|
| 34 | + if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') { |
|
| 35 | + $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']); |
|
| 36 | 36 | } else { |
| 37 | 37 | $module = $_REQUEST['aor_module']; |
| 38 | 38 | } |
| 39 | 39 | $val = !empty($_REQUEST['aor_value']) ? $_REQUEST['aor_value'] : ''; |
| 40 | - echo getModuleFields($module,$_REQUEST['view'],$val); |
|
| 40 | + echo getModuleFields($module, $_REQUEST['view'], $val); |
|
| 41 | 41 | } |
| 42 | 42 | die; |
| 43 | 43 | |
| 44 | 44 | } |
| 45 | - function action_getVarDefs(){ |
|
| 46 | - if($_REQUEST['aor_module']){ |
|
| 45 | + function action_getVarDefs() { |
|
| 46 | + if ($_REQUEST['aor_module']) { |
|
| 47 | 47 | $bean = BeanFactory::getBean($_REQUEST['aor_module']); |
| 48 | 48 | echo json_encode((array)$bean->field_defs[$_REQUEST['aor_request']]); |
| 49 | 49 | die(); |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | die; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - protected function action_changeReportPage(){ |
|
| 72 | + protected function action_changeReportPage() { |
|
| 73 | 73 | $tableId = !empty($_REQUEST['table_id']) ? $_REQUEST['table_id'] : ''; |
| 74 | 74 | $group = !empty($_REQUEST['group']) ? $_REQUEST['group'] : ''; |
| 75 | 75 | $offset = !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0; |
| 76 | - if(!empty($this->bean->id)){ |
|
| 76 | + if (!empty($this->bean->id)) { |
|
| 77 | 77 | $this->bean->user_parameters = requestToUserParameters(); |
| 78 | 78 | //echo $this->bean->build_report_html($offset, true,$group,$tableId); |
| 79 | 79 | echo $this->bean->build_group_report($offset, true); |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | die(); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - protected function action_getParametersForReport(){ |
|
| 86 | - if(empty($_REQUEST['record'])){ |
|
| 85 | + protected function action_getParametersForReport() { |
|
| 86 | + if (empty($_REQUEST['record'])) { |
|
| 87 | 87 | echo json_encode(array()); |
| 88 | 88 | return; |
| 89 | 89 | } |
| 90 | - $report = BeanFactory::getBean('AOR_Reports',$_REQUEST['record']); |
|
| 91 | - if(!$report){ |
|
| 90 | + $report = BeanFactory::getBean('AOR_Reports', $_REQUEST['record']); |
|
| 91 | + if (!$report) { |
|
| 92 | 92 | echo json_encode(array()); |
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | - if(empty($report->id)) { |
|
| 95 | + if (empty($report->id)) { |
|
| 96 | 96 | echo json_encode(array()); |
| 97 | 97 | return; |
| 98 | 98 | } |
@@ -100,24 +100,24 @@ discard block |
||
| 100 | 100 | echo json_encode($conditions); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - protected function action_getChartsForReport(){ |
|
| 104 | - if(empty($_REQUEST['record'])){ |
|
| 103 | + protected function action_getChartsForReport() { |
|
| 104 | + if (empty($_REQUEST['record'])) { |
|
| 105 | 105 | echo json_encode(array()); |
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | - $report = BeanFactory::getBean('AOR_Reports',$_REQUEST['record']); |
|
| 109 | - if(!$report){ |
|
| 108 | + $report = BeanFactory::getBean('AOR_Reports', $_REQUEST['record']); |
|
| 109 | + if (!$report) { |
|
| 110 | 110 | echo json_encode(array()); |
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | $charts = array(); |
| 114 | - foreach($report->get_linked_beans('aor_charts','AOR_Charts') as $chart){ |
|
| 114 | + foreach ($report->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) { |
|
| 115 | 115 | $charts[$chart->id] = $chart->name; |
| 116 | 116 | } |
| 117 | 117 | echo json_encode($charts); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - protected function action_addToProspectList(){ |
|
| 120 | + protected function action_addToProspectList() { |
|
| 121 | 121 | global $beanList; |
| 122 | 122 | |
| 123 | 123 | require_once('modules/Relationships/Relationship.php'); |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | $result = $this->bean->db->query($sql); |
| 136 | 136 | $beans = array(); |
| 137 | 137 | while ($row = $this->bean->db->fetchByAssoc($result)) { |
| 138 | - if (isset($row[$module->table_name.'_id'])){ |
|
| 138 | + if (isset($row[$module->table_name.'_id'])) { |
|
| 139 | 139 | $beans[] = $row[$module->table_name.'_id']; |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | - if(!empty($beans)){ |
|
| 143 | - foreach($prospectList->field_defs as $field=>$def){ |
|
| 144 | - if($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key){ |
|
| 142 | + if (!empty($beans)) { |
|
| 143 | + foreach ($prospectList->field_defs as $field=>$def) { |
|
| 144 | + if ($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key) { |
|
| 145 | 145 | $prospectList->load_relationship($field); |
| 146 | 146 | $prospectList->$field->add($beans); |
| 147 | 147 | } |
@@ -170,41 +170,41 @@ discard block |
||
| 170 | 170 | error_reporting(0); |
| 171 | 171 | require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php'); |
| 172 | 172 | |
| 173 | - $d_image = explode('?',SugarThemeRegistry::current()->getImageURL('company_logo.png')); |
|
| 173 | + $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png')); |
|
| 174 | 174 | $graphs = $_POST["graphsForPDF"]; |
| 175 | 175 | $graphHtml = "<div class='reportGraphs' style='width:100%; text-align:center;'>"; |
| 176 | 176 | |
| 177 | 177 | $chartsPerRow = $this->bean->graphs_per_row; |
| 178 | 178 | $countOfCharts = count($graphs); |
| 179 | - if($countOfCharts > 0) |
|
| 179 | + if ($countOfCharts > 0) |
|
| 180 | 180 | { |
| 181 | - $width = ((int)100/$chartsPerRow); |
|
| 181 | + $width = ((int)100 / $chartsPerRow); |
|
| 182 | 182 | |
| 183 | 183 | $modulusRemainder = $countOfCharts % $chartsPerRow; |
| 184 | 184 | |
| 185 | - if($modulusRemainder > 0) |
|
| 185 | + if ($modulusRemainder > 0) |
|
| 186 | 186 | { |
| 187 | - $modulusWidth = ((int)100/$modulusRemainder); |
|
| 187 | + $modulusWidth = ((int)100 / $modulusRemainder); |
|
| 188 | 188 | $itemsWithModulus = $countOfCharts - $modulusRemainder; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
| 192 | - for($x =0; $x < $countOfCharts; $x++) |
|
| 192 | + for ($x = 0; $x < $countOfCharts; $x++) |
|
| 193 | 193 | { |
| 194 | - if(is_null($itemsWithModulus) || $x < $itemsWithModulus) |
|
| 195 | - $graphHtml.="<img src='.$graphs[$x].' style='width:$width%;' />"; |
|
| 194 | + if (is_null($itemsWithModulus) || $x < $itemsWithModulus) |
|
| 195 | + $graphHtml .= "<img src='.$graphs[$x].' style='width:$width%;' />"; |
|
| 196 | 196 | else |
| 197 | - $graphHtml.="<img src='.$graphs[$x].' style='width:$modulusWidth%;' />"; |
|
| 197 | + $graphHtml .= "<img src='.$graphs[$x].' style='width:$modulusWidth%;' />"; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /* foreach($graphs as $g) |
| 201 | 201 | { |
| 202 | 202 | $graphHtml.="<img src='.$g.' style='width:$width%;' />"; |
| 203 | 203 | }*/ |
| 204 | - $graphHtml.="</div>"; |
|
| 204 | + $graphHtml .= "</div>"; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2"> |
|
| 207 | + $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2"> |
|
| 208 | 208 | <tbody style="text-align: left;"> |
| 209 | 209 | <tr style="text-align: left;"> |
| 210 | 210 | <td style="text-align: left;"> |
@@ -229,25 +229,25 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | $this->bean->user_parameters = requestToUserParameters(); |
| 231 | 231 | |
| 232 | - $printable = $this->bean->build_group_report(-1,false); |
|
| 233 | - $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL('style.css',false)); |
|
| 232 | + $printable = $this->bean->build_group_report(-1, false); |
|
| 233 | + $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL('style.css', false)); |
|
| 234 | 234 | ob_clean(); |
| 235 | - try{ |
|
| 236 | - $pdf=new mPDF('en','A4','','DejaVuSansCondensed'); |
|
| 235 | + try { |
|
| 236 | + $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed'); |
|
| 237 | 237 | $pdf->setAutoFont(); |
| 238 | - $pdf->WriteHTML($stylesheet,1); |
|
| 239 | - $pdf->WriteHTML($head,2); |
|
| 240 | - $pdf->WriteHTML($printable,3); |
|
| 238 | + $pdf->WriteHTML($stylesheet, 1); |
|
| 239 | + $pdf->WriteHTML($head, 2); |
|
| 240 | + $pdf->WriteHTML($printable, 3); |
|
| 241 | 241 | $pdf->Output($this->bean->name.'.pdf', "D"); |
| 242 | 242 | |
| 243 | - }catch(mPDF_exception $e){ |
|
| 243 | + }catch (mPDF_exception $e) { |
|
| 244 | 244 | echo $e; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | die; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - protected function action_getModuleFunctionField(){ |
|
| 250 | + protected function action_getModuleFunctionField() { |
|
| 251 | 251 | global $app_list_strings; |
| 252 | 252 | |
| 253 | 253 | $view = $_REQUEST['view']; |
@@ -256,31 +256,31 @@ discard block |
||
| 256 | 256 | $fieldname = $_REQUEST['aor_fieldname']; |
| 257 | 257 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 258 | 258 | |
| 259 | - if($view == 'EditView'){ |
|
| 260 | - echo "<select type='text' style='width:100px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_function_list'], $value) ."</select>"; |
|
| 261 | - }else{ |
|
| 259 | + if ($view == 'EditView') { |
|
| 260 | + echo "<select type='text' style='width:100px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_function_list'], $value)."</select>"; |
|
| 261 | + } else { |
|
| 262 | 262 | echo $app_list_strings['aor_function_list'][$value]; |
| 263 | 263 | } |
| 264 | 264 | die; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
| 268 | - protected function action_getModuleOperatorField(){ |
|
| 268 | + protected function action_getModuleOperatorField() { |
|
| 269 | 269 | |
| 270 | 270 | global $app_list_strings, $beanFiles, $beanList; |
| 271 | 271 | |
| 272 | - if(isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != ''){ |
|
| 273 | - $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']); |
|
| 272 | + if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') { |
|
| 273 | + $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']); |
|
| 274 | 274 | } else { |
| 275 | 275 | $module = $_REQUEST['aor_module']; |
| 276 | 276 | } |
| 277 | 277 | $fieldname = $_REQUEST['aor_fieldname']; |
| 278 | 278 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 279 | 279 | |
| 280 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 281 | - else $view= 'EditView'; |
|
| 280 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 281 | + else $view = 'EditView'; |
|
| 282 | 282 | |
| 283 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 283 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 284 | 284 | else $value = ''; |
| 285 | 285 | |
| 286 | 286 | |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | $focus = new $beanList[$module]; |
| 289 | 289 | $vardef = $focus->getFieldDefinition($fieldname); |
| 290 | 290 | |
| 291 | - switch($vardef['type']) { |
|
| 291 | + switch ($vardef['type']) { |
|
| 292 | 292 | case 'double': |
| 293 | 293 | case 'decimal': |
| 294 | 294 | case 'float': |
| 295 | 295 | case 'currency': |
| 296 | - $valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To'); |
|
| 296 | + $valid_opp = array('Equal_To', 'Not_Equal_To', 'Greater_Than', 'Less_Than', 'Greater_Than_or_Equal_To', 'Less_Than_or_Equal_To'); |
|
| 297 | 297 | break; |
| 298 | 298 | case 'uint': |
| 299 | 299 | case 'ulong': |
@@ -301,24 +301,24 @@ discard block |
||
| 301 | 301 | case 'short': |
| 302 | 302 | case 'tinyint': |
| 303 | 303 | case 'int': |
| 304 | - $valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To'); |
|
| 304 | + $valid_opp = array('Equal_To', 'Not_Equal_To', 'Greater_Than', 'Less_Than', 'Greater_Than_or_Equal_To', 'Less_Than_or_Equal_To'); |
|
| 305 | 305 | break; |
| 306 | 306 | case 'date': |
| 307 | 307 | case 'datetime': |
| 308 | 308 | case 'datetimecombo': |
| 309 | - $valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To'); |
|
| 309 | + $valid_opp = array('Equal_To', 'Not_Equal_To', 'Greater_Than', 'Less_Than', 'Greater_Than_or_Equal_To', 'Less_Than_or_Equal_To'); |
|
| 310 | 310 | break; |
| 311 | 311 | case 'enum': |
| 312 | 312 | case 'multienum': |
| 313 | - $valid_opp = array('Equal_To','Not_Equal_To'); |
|
| 313 | + $valid_opp = array('Equal_To', 'Not_Equal_To'); |
|
| 314 | 314 | break; |
| 315 | 315 | default: |
| 316 | - $valid_opp = array('Equal_To','Not_Equal_To','Contains', 'Starts_With', 'Ends_With',); |
|
| 316 | + $valid_opp = array('Equal_To', 'Not_Equal_To', 'Contains', 'Starts_With', 'Ends_With',); |
|
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - foreach($app_list_strings['aor_operator_list'] as $key => $keyValue){ |
|
| 321 | - if(!in_array($key, $valid_opp)){ |
|
| 320 | + foreach ($app_list_strings['aor_operator_list'] as $key => $keyValue) { |
|
| 321 | + if (!in_array($key, $valid_opp)) { |
|
| 322 | 322 | unset($app_list_strings['aor_operator_list'][$key]); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -326,31 +326,31 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | $app_list_strings['aor_operator_list']; |
| 329 | - if($view == 'EditView'){ |
|
| 330 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_operator_list'], $value) ."</select>"; |
|
| 331 | - }else{ |
|
| 329 | + if ($view == 'EditView') { |
|
| 330 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_operator_list'], $value)."</select>"; |
|
| 331 | + } else { |
|
| 332 | 332 | echo $app_list_strings['aor_operator_list'][$value]; |
| 333 | 333 | } |
| 334 | 334 | die; |
| 335 | 335 | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - protected function action_getFieldTypeOptions(){ |
|
| 338 | + protected function action_getFieldTypeOptions() { |
|
| 339 | 339 | |
| 340 | 340 | global $app_list_strings, $beanFiles, $beanList; |
| 341 | 341 | |
| 342 | - if(isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != ''){ |
|
| 343 | - $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']); |
|
| 342 | + if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') { |
|
| 343 | + $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']); |
|
| 344 | 344 | } else { |
| 345 | 345 | $module = $_REQUEST['aor_module']; |
| 346 | 346 | } |
| 347 | 347 | $fieldname = $_REQUEST['aor_fieldname']; |
| 348 | 348 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 349 | 349 | |
| 350 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 351 | - else $view= 'EditView'; |
|
| 350 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 351 | + else $view = 'EditView'; |
|
| 352 | 352 | |
| 353 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 353 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 354 | 354 | else $value = ''; |
| 355 | 355 | |
| 356 | 356 | |
@@ -358,12 +358,12 @@ discard block |
||
| 358 | 358 | $focus = new $beanList[$module]; |
| 359 | 359 | $vardef = $focus->getFieldDefinition($fieldname); |
| 360 | 360 | |
| 361 | - switch($vardef['type']) { |
|
| 361 | + switch ($vardef['type']) { |
|
| 362 | 362 | case 'double': |
| 363 | 363 | case 'decimal': |
| 364 | 364 | case 'float': |
| 365 | 365 | case 'currency': |
| 366 | - $valid_opp = array('Value','Field'); |
|
| 366 | + $valid_opp = array('Value', 'Field'); |
|
| 367 | 367 | break; |
| 368 | 368 | case 'uint': |
| 369 | 369 | case 'ulong': |
@@ -371,50 +371,50 @@ discard block |
||
| 371 | 371 | case 'short': |
| 372 | 372 | case 'tinyint': |
| 373 | 373 | case 'int': |
| 374 | - $valid_opp = array('Value','Field'); |
|
| 374 | + $valid_opp = array('Value', 'Field'); |
|
| 375 | 375 | break; |
| 376 | 376 | case 'date': |
| 377 | 377 | case 'datetime': |
| 378 | 378 | case 'datetimecombo': |
| 379 | - $valid_opp = array('Value','Field', 'Date', 'Period'); |
|
| 379 | + $valid_opp = array('Value', 'Field', 'Date', 'Period'); |
|
| 380 | 380 | break; |
| 381 | 381 | case 'enum': |
| 382 | 382 | case 'dynamicenum': |
| 383 | 383 | case 'multienum': |
| 384 | - $valid_opp = array('Value','Field', 'Multi'); |
|
| 384 | + $valid_opp = array('Value', 'Field', 'Multi'); |
|
| 385 | 385 | break; |
| 386 | 386 | default: |
| 387 | 387 | // Added to compare fields like assinged to with the current user |
| 388 | - if( (isset($vardef['module']) && $vardef['module'] == "Users") || $vardef['name'] = 'id') { |
|
| 389 | - $valid_opp = array('Value','Field', 'CurrentUserID'); |
|
| 388 | + if ((isset($vardef['module']) && $vardef['module'] == "Users") || $vardef['name'] = 'id') { |
|
| 389 | + $valid_opp = array('Value', 'Field', 'CurrentUserID'); |
|
| 390 | 390 | } else { |
| 391 | - $valid_opp = array('Value','Field'); |
|
| 391 | + $valid_opp = array('Value', 'Field'); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | break; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - foreach($app_list_strings['aor_condition_type_list'] as $key => $keyValue){ |
|
| 398 | - if(!in_array($key, $valid_opp)){ |
|
| 397 | + foreach ($app_list_strings['aor_condition_type_list'] as $key => $keyValue) { |
|
| 398 | + if (!in_array($key, $valid_opp)) { |
|
| 399 | 399 | unset($app_list_strings['aor_condition_type_list'][$key]); |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - if($view == 'EditView'){ |
|
| 404 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_condition_type_list'], $value) ."</select>"; |
|
| 405 | - }else{ |
|
| 403 | + if ($view == 'EditView') { |
|
| 404 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_condition_type_list'], $value)."</select>"; |
|
| 405 | + } else { |
|
| 406 | 406 | echo $app_list_strings['aor_condition_type_list'][$value]; |
| 407 | 407 | } |
| 408 | 408 | die; |
| 409 | 409 | |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - protected function action_getActionFieldTypeOptions(){ |
|
| 412 | + protected function action_getActionFieldTypeOptions() { |
|
| 413 | 413 | |
| 414 | 414 | global $app_list_strings, $beanFiles, $beanList; |
| 415 | 415 | |
| 416 | - if(isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != ''){ |
|
| 417 | - $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']); |
|
| 416 | + if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') { |
|
| 417 | + $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']); |
|
| 418 | 418 | } else { |
| 419 | 419 | $module = $_REQUEST['aor_module']; |
| 420 | 420 | } |
@@ -422,10 +422,10 @@ discard block |
||
| 422 | 422 | $fieldname = $_REQUEST['aor_fieldname']; |
| 423 | 423 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 424 | 424 | |
| 425 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 426 | - else $view= 'EditView'; |
|
| 425 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 426 | + else $view = 'EditView'; |
|
| 427 | 427 | |
| 428 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 428 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 429 | 429 | else $value = ''; |
| 430 | 430 | |
| 431 | 431 | |
@@ -433,12 +433,12 @@ discard block |
||
| 433 | 433 | $focus = new $beanList[$module]; |
| 434 | 434 | $vardef = $focus->getFieldDefinition($fieldname); |
| 435 | 435 | |
| 436 | - switch($vardef['type']) { |
|
| 436 | + switch ($vardef['type']) { |
|
| 437 | 437 | case 'double': |
| 438 | 438 | case 'decimal': |
| 439 | 439 | case 'float': |
| 440 | 440 | case 'currency': |
| 441 | - $valid_opp = array('Value','Field'); |
|
| 441 | + $valid_opp = array('Value', 'Field'); |
|
| 442 | 442 | break; |
| 443 | 443 | case 'uint': |
| 444 | 444 | case 'ulong': |
@@ -446,35 +446,35 @@ discard block |
||
| 446 | 446 | case 'short': |
| 447 | 447 | case 'tinyint': |
| 448 | 448 | case 'int': |
| 449 | - $valid_opp = array('Value','Field'); |
|
| 449 | + $valid_opp = array('Value', 'Field'); |
|
| 450 | 450 | break; |
| 451 | 451 | case 'date': |
| 452 | 452 | case 'datetime': |
| 453 | 453 | case 'datetimecombo': |
| 454 | - $valid_opp = array('Value','Field', 'Date'); |
|
| 454 | + $valid_opp = array('Value', 'Field', 'Date'); |
|
| 455 | 455 | break; |
| 456 | 456 | case 'enum': |
| 457 | 457 | case 'multienum': |
| 458 | - $valid_opp = array('Value','Field'); |
|
| 458 | + $valid_opp = array('Value', 'Field'); |
|
| 459 | 459 | break; |
| 460 | 460 | case 'relate': |
| 461 | - $valid_opp = array('Value','Field'); |
|
| 462 | - if($vardef['module'] == 'Users') $valid_opp = array('Value','Field','Round_Robin','Least_Busy','Random'); |
|
| 461 | + $valid_opp = array('Value', 'Field'); |
|
| 462 | + if ($vardef['module'] == 'Users') $valid_opp = array('Value', 'Field', 'Round_Robin', 'Least_Busy', 'Random'); |
|
| 463 | 463 | break; |
| 464 | 464 | default: |
| 465 | - $valid_opp = array('Value','Field'); |
|
| 465 | + $valid_opp = array('Value', 'Field'); |
|
| 466 | 466 | break; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - foreach($app_list_strings['aor_action_type_list'] as $key => $keyValue){ |
|
| 470 | - if(!in_array($key, $valid_opp)){ |
|
| 469 | + foreach ($app_list_strings['aor_action_type_list'] as $key => $keyValue) { |
|
| 470 | + if (!in_array($key, $valid_opp)) { |
|
| 471 | 471 | unset($app_list_strings['aor_action_type_list'][$key]); |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if($view == 'EditView'){ |
|
| 476 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_action_type_list'], $value) ."</select>"; |
|
| 477 | - }else{ |
|
| 475 | + if ($view == 'EditView') { |
|
| 476 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_action_type_list'], $value)."</select>"; |
|
| 477 | + } else { |
|
| 478 | 478 | echo $app_list_strings['aor_action_type_list'][$value]; |
| 479 | 479 | } |
| 480 | 480 | die; |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | protected function action_getModuleFieldType() |
| 485 | 485 | { |
| 486 | - if(isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != ''){ |
|
| 487 | - $rel_module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']); |
|
| 486 | + if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') { |
|
| 487 | + $rel_module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']); |
|
| 488 | 488 | } else { |
| 489 | 489 | $rel_module = $_REQUEST['aor_module']; |
| 490 | 490 | } |
@@ -493,18 +493,18 @@ discard block |
||
| 493 | 493 | $fieldname = $_REQUEST['aor_fieldname']; |
| 494 | 494 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 495 | 495 | |
| 496 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 497 | - else $view= 'EditView'; |
|
| 496 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 497 | + else $view = 'EditView'; |
|
| 498 | 498 | |
| 499 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 499 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 500 | 500 | else $value = ''; |
| 501 | 501 | |
| 502 | - switch($_REQUEST['aor_type']) { |
|
| 502 | + switch ($_REQUEST['aor_type']) { |
|
| 503 | 503 | case 'Field': |
| 504 | - if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 505 | - if($view == 'EditView'){ |
|
| 506 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>"; |
|
| 507 | - }else{ |
|
| 504 | + if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 505 | + if ($view == 'EditView') { |
|
| 506 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getModuleFields($module, $view, $value)."</select>"; |
|
| 507 | + } else { |
|
| 508 | 508 | echo getModuleFields($module, $view, $value); |
| 509 | 509 | } |
| 510 | 510 | break; |
@@ -512,13 +512,13 @@ discard block |
||
| 512 | 512 | echo getDateField($module, $aor_field, $view, $value, false); |
| 513 | 513 | break; |
| 514 | 514 | case 'Multi': |
| 515 | - echo getModuleField($rel_module,$fieldname, $aor_field, $view, $value,'multienum'); |
|
| 515 | + echo getModuleField($rel_module, $fieldname, $aor_field, $view, $value, 'multienum'); |
|
| 516 | 516 | break; |
| 517 | 517 | case 'Period': |
| 518 | - if($view == 'EditView'){ |
|
| 519 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getDropdownList('date_time_period_list',$_REQUEST['aor_value']) ."</select>"; |
|
| 520 | - }else{ |
|
| 521 | - echo getDropdownList('date_time_period_list',$_REQUEST['aor_value']); |
|
| 518 | + if ($view == 'EditView') { |
|
| 519 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getDropdownList('date_time_period_list', $_REQUEST['aor_value'])."</select>"; |
|
| 520 | + } else { |
|
| 521 | + echo getDropdownList('date_time_period_list', $_REQUEST['aor_value']); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | break; |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | break; |
| 527 | 527 | case 'Value': |
| 528 | 528 | default: |
| 529 | - echo getModuleField($rel_module,$fieldname, $aor_field, $view, $value ); |
|
| 529 | + echo getModuleField($rel_module, $fieldname, $aor_field, $view, $value); |
|
| 530 | 530 | break; |
| 531 | 531 | } |
| 532 | 532 | die; |
@@ -539,23 +539,23 @@ discard block |
||
| 539 | 539 | $fieldname = $_REQUEST['aor_fieldname']; |
| 540 | 540 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 541 | 541 | |
| 542 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 543 | - else $view= 'EditView'; |
|
| 542 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 543 | + else $view = 'EditView'; |
|
| 544 | 544 | |
| 545 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 545 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 546 | 546 | else $value = ''; |
| 547 | 547 | |
| 548 | - switch($_REQUEST['aor_type']) { |
|
| 548 | + switch ($_REQUEST['aor_type']) { |
|
| 549 | 549 | case 'Field': |
| 550 | - if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 551 | - if($view == 'EditView'){ |
|
| 552 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>"; |
|
| 553 | - }else{ |
|
| 550 | + if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 551 | + if ($view == 'EditView') { |
|
| 552 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getModuleFields($module, $view, $value)."</select>"; |
|
| 553 | + } else { |
|
| 554 | 554 | echo getModuleFields($module, $view, $value); |
| 555 | 555 | } |
| 556 | 556 | break; |
| 557 | 557 | case 'Date': |
| 558 | - if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 558 | + if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 559 | 559 | echo getDateField($module, $aor_field, $view, $value); |
| 560 | 560 | break; |
| 561 | 561 | Case 'Round_Robin'; |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | break; |
| 566 | 566 | case 'Value': |
| 567 | 567 | default: |
| 568 | - echo getModuleField($module,$fieldname, $aor_field, $view, $value ); |
|
| 568 | + echo getModuleField($module, $fieldname, $aor_field, $view, $value); |
|
| 569 | 569 | break; |
| 570 | 570 | } |
| 571 | 571 | die; |
@@ -574,13 +574,13 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | protected function action_getModuleField() |
| 576 | 576 | { |
| 577 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 578 | - else $view= 'EditView'; |
|
| 577 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 578 | + else $view = 'EditView'; |
|
| 579 | 579 | |
| 580 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 580 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 581 | 581 | else $value = ''; |
| 582 | 582 | |
| 583 | - echo getModuleField($_REQUEST['aor_module'],$_REQUEST['aor_fieldname'], $_REQUEST['aor_newfieldname'], $view, $value ); |
|
| 583 | + echo getModuleField($_REQUEST['aor_module'], $_REQUEST['aor_fieldname'], $_REQUEST['aor_newfieldname'], $view, $value); |
|
| 584 | 584 | die; |
| 585 | 585 | } |
| 586 | 586 | |
@@ -590,31 +590,31 @@ discard block |
||
| 590 | 590 | $fieldname = $_REQUEST['aor_fieldname']; |
| 591 | 591 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 592 | 592 | |
| 593 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 594 | - else $view= 'EditView'; |
|
| 593 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 594 | + else $view = 'EditView'; |
|
| 595 | 595 | |
| 596 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 596 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 597 | 597 | else $value = ''; |
| 598 | 598 | |
| 599 | - switch($_REQUEST['aor_type']) { |
|
| 599 | + switch ($_REQUEST['aor_type']) { |
|
| 600 | 600 | case 'Field': |
| 601 | - if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 602 | - if($view == 'EditView'){ |
|
| 603 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>"; |
|
| 604 | - }else{ |
|
| 601 | + if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module']; |
|
| 602 | + if ($view == 'EditView') { |
|
| 603 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getModuleFields($module, $view, $value)."</select>"; |
|
| 604 | + } else { |
|
| 605 | 605 | echo getModuleFields($module, $view, $value); |
| 606 | 606 | } |
| 607 | 607 | break; |
| 608 | 608 | case 'Value': |
| 609 | 609 | default: |
| 610 | - echo getModuleField($module,$fieldname, $aor_field, $view, $value ); |
|
| 610 | + echo getModuleField($module, $fieldname, $aor_field, $view, $value); |
|
| 611 | 611 | break; |
| 612 | 612 | } |
| 613 | 613 | die; |
| 614 | 614 | |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - protected function action_getRelActionFieldTypeOptions(){ |
|
| 617 | + protected function action_getRelActionFieldTypeOptions() { |
|
| 618 | 618 | |
| 619 | 619 | global $app_list_strings, $beanFiles, $beanList; |
| 620 | 620 | |
@@ -623,10 +623,10 @@ discard block |
||
| 623 | 623 | $fieldname = $_REQUEST['aor_fieldname']; |
| 624 | 624 | $aor_field = $_REQUEST['aor_newfieldname']; |
| 625 | 625 | |
| 626 | - if(isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 627 | - else $view= 'EditView'; |
|
| 626 | + if (isset($_REQUEST['view'])) $view = $_REQUEST['view']; |
|
| 627 | + else $view = 'EditView'; |
|
| 628 | 628 | |
| 629 | - if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 629 | + if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value']; |
|
| 630 | 630 | else $value = ''; |
| 631 | 631 | |
| 632 | 632 | |
@@ -643,15 +643,15 @@ discard block |
||
| 643 | 643 | }*/ |
| 644 | 644 | $valid_opp = array('Value'); |
| 645 | 645 | |
| 646 | - foreach($app_list_strings['aor_rel_action_type_list'] as $key => $keyValue){ |
|
| 647 | - if(!in_array($key, $valid_opp)){ |
|
| 646 | + foreach ($app_list_strings['aor_rel_action_type_list'] as $key => $keyValue) { |
|
| 647 | + if (!in_array($key, $valid_opp)) { |
|
| 648 | 648 | unset($app_list_strings['aor_rel_action_type_list'][$key]); |
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if($view == 'EditView'){ |
|
| 653 | - echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_rel_action_type_list'], $value) ."</select>"; |
|
| 654 | - }else{ |
|
| 652 | + if ($view == 'EditView') { |
|
| 653 | + echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_rel_action_type_list'], $value)."</select>"; |
|
| 654 | + } else { |
|
| 655 | 655 | echo $app_list_strings['aor_rel_action_type_list'][$value]; |
| 656 | 656 | } |
| 657 | 657 | die; |
@@ -23,66 +23,66 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | $mod_strings = array ( |
| 26 | - 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
|
| 27 | - 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
|
| 28 | - 'LBL_ID' => 'ID', |
|
| 29 | - 'LBL_DATE_ENTERED' => 'Date Created', |
|
| 30 | - 'LBL_DATE_MODIFIED' => 'Date Modified', |
|
| 31 | - 'LBL_MODIFIED' => 'Modified By', |
|
| 32 | - 'LBL_MODIFIED_ID' => 'Modified By Id', |
|
| 33 | - 'LBL_MODIFIED_NAME' => 'Modified By Name', |
|
| 34 | - 'LBL_CREATED' => 'Created By', |
|
| 35 | - 'LBL_CREATED_ID' => 'Created By Id', |
|
| 36 | - 'LBL_DESCRIPTION' => 'Description', |
|
| 37 | - 'LBL_DELETED' => 'Deleted', |
|
| 38 | - 'LBL_NAME' => 'Name', |
|
| 39 | - 'LBL_CREATED_USER' => 'Created by User', |
|
| 40 | - 'LBL_MODIFIED_USER' => 'Modified by User', |
|
| 41 | - 'LBL_LIST_NAME' => 'Name', |
|
| 42 | - 'LBL_EDIT_BUTTON' => 'Edit', |
|
| 43 | - 'LBL_REMOVE' => 'Remove', |
|
| 44 | - 'LBL_LIST_FORM_TITLE' => 'Reports List', |
|
| 45 | - 'LBL_MODULE_NAME' => 'Reports', |
|
| 46 | - 'LBL_MODULE_TITLE' => 'Reports', |
|
| 47 | - 'LBL_HOMEPAGE_TITLE' => 'My Reports', |
|
| 48 | - 'LNK_NEW_RECORD' => 'Create Report', |
|
| 49 | - 'LNK_LIST' => 'View Reports', |
|
| 50 | - 'LNK_IMPORT_AOR_REPORTS' => 'Import Reports', |
|
| 51 | - 'LBL_SEARCH_FORM_TITLE' => 'Search Reports', |
|
| 52 | - 'LBL_HISTORY_SUBPANEL_TITLE' => 'View History', |
|
| 53 | - 'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities', |
|
| 54 | - 'LBL_AOR_REPORTS_SUBPANEL_TITLE' => 'Reports', |
|
| 55 | - 'LBL_NEW_FORM_TITLE' => 'New Reports', |
|
| 56 | - 'LBL_REPORT_MODULE' => 'Report Module', |
|
| 26 | + 'LBL_ASSIGNED_TO_ID' => 'Assigned User Id', |
|
| 27 | + 'LBL_ASSIGNED_TO_NAME' => 'Assigned to', |
|
| 28 | + 'LBL_ID' => 'ID', |
|
| 29 | + 'LBL_DATE_ENTERED' => 'Date Created', |
|
| 30 | + 'LBL_DATE_MODIFIED' => 'Date Modified', |
|
| 31 | + 'LBL_MODIFIED' => 'Modified By', |
|
| 32 | + 'LBL_MODIFIED_ID' => 'Modified By Id', |
|
| 33 | + 'LBL_MODIFIED_NAME' => 'Modified By Name', |
|
| 34 | + 'LBL_CREATED' => 'Created By', |
|
| 35 | + 'LBL_CREATED_ID' => 'Created By Id', |
|
| 36 | + 'LBL_DESCRIPTION' => 'Description', |
|
| 37 | + 'LBL_DELETED' => 'Deleted', |
|
| 38 | + 'LBL_NAME' => 'Name', |
|
| 39 | + 'LBL_CREATED_USER' => 'Created by User', |
|
| 40 | + 'LBL_MODIFIED_USER' => 'Modified by User', |
|
| 41 | + 'LBL_LIST_NAME' => 'Name', |
|
| 42 | + 'LBL_EDIT_BUTTON' => 'Edit', |
|
| 43 | + 'LBL_REMOVE' => 'Remove', |
|
| 44 | + 'LBL_LIST_FORM_TITLE' => 'Reports List', |
|
| 45 | + 'LBL_MODULE_NAME' => 'Reports', |
|
| 46 | + 'LBL_MODULE_TITLE' => 'Reports', |
|
| 47 | + 'LBL_HOMEPAGE_TITLE' => 'My Reports', |
|
| 48 | + 'LNK_NEW_RECORD' => 'Create Report', |
|
| 49 | + 'LNK_LIST' => 'View Reports', |
|
| 50 | + 'LNK_IMPORT_AOR_REPORTS' => 'Import Reports', |
|
| 51 | + 'LBL_SEARCH_FORM_TITLE' => 'Search Reports', |
|
| 52 | + 'LBL_HISTORY_SUBPANEL_TITLE' => 'View History', |
|
| 53 | + 'LBL_ACTIVITIES_SUBPANEL_TITLE' => 'Activities', |
|
| 54 | + 'LBL_AOR_REPORTS_SUBPANEL_TITLE' => 'Reports', |
|
| 55 | + 'LBL_NEW_FORM_TITLE' => 'New Reports', |
|
| 56 | + 'LBL_REPORT_MODULE' => 'Report Module', |
|
| 57 | 57 | 'LBL_GRAPHS_PER_ROW' => 'Charts per row', |
| 58 | - 'LBL_FIELD_LINES' => 'Display Fields', |
|
| 59 | - 'LBL_ADD_FIELD' => 'Add Field', |
|
| 60 | - 'LBL_CONDITION_LINES' => 'Conditions', |
|
| 61 | - 'LBL_ADD_CONDITION' => 'Add Condition', |
|
| 62 | - 'LBL_EXPORT' => 'Export', |
|
| 63 | - 'LBL_DOWNLOAD_PDF' => 'Download PDF', |
|
| 64 | - 'LBL_ADD_TO_PROSPECT_LIST' => 'Add To Target List', |
|
| 65 | - 'LBL_AOR_MODULETREE_SUBPANEL_TITLE' => 'Module tree', |
|
| 66 | - 'LBL_AOR_FIELDS_SUBPANEL_TITLE' => 'Fields', |
|
| 67 | - 'LBL_AOR_CONDITIONS_SUBPANEL_TITLE' => 'Conditions', |
|
| 68 | - 'LBL_TOTAL' => 'Total', |
|
| 69 | - 'LBL_AOR_CHARTS_SUBPANEL_TITLE' => 'Charts', |
|
| 70 | - 'LBL_ADD_CHART' => 'Add chart', |
|
| 58 | + 'LBL_FIELD_LINES' => 'Display Fields', |
|
| 59 | + 'LBL_ADD_FIELD' => 'Add Field', |
|
| 60 | + 'LBL_CONDITION_LINES' => 'Conditions', |
|
| 61 | + 'LBL_ADD_CONDITION' => 'Add Condition', |
|
| 62 | + 'LBL_EXPORT' => 'Export', |
|
| 63 | + 'LBL_DOWNLOAD_PDF' => 'Download PDF', |
|
| 64 | + 'LBL_ADD_TO_PROSPECT_LIST' => 'Add To Target List', |
|
| 65 | + 'LBL_AOR_MODULETREE_SUBPANEL_TITLE' => 'Module tree', |
|
| 66 | + 'LBL_AOR_FIELDS_SUBPANEL_TITLE' => 'Fields', |
|
| 67 | + 'LBL_AOR_CONDITIONS_SUBPANEL_TITLE' => 'Conditions', |
|
| 68 | + 'LBL_TOTAL' => 'Total', |
|
| 69 | + 'LBL_AOR_CHARTS_SUBPANEL_TITLE' => 'Charts', |
|
| 70 | + 'LBL_ADD_CHART' => 'Add chart', |
|
| 71 | 71 | 'LBL_ADD_PARENTHESIS' => 'Drop parenthesis', |
| 72 | - 'LBL_CHART_TITLE' => 'Title', |
|
| 73 | - 'LBL_CHART_TYPE' => 'Type', |
|
| 74 | - 'LBL_CHART_X_FIELD' => 'X Axis', |
|
| 75 | - 'LBL_CHART_Y_FIELD' => 'Y Axis', |
|
| 76 | - 'LBL_AOR_REPORTS_DASHLET' => 'Reports', |
|
| 77 | - 'LBL_DASHLET_TITLE' => 'Title', |
|
| 78 | - 'LBL_DASHLET_REPORT' => 'Report', |
|
| 79 | - 'LBL_DASHLET_CHOOSE_REPORT' => 'Please choose a report', |
|
| 80 | - 'LBL_DASHLET_SAVE' => 'Save', |
|
| 81 | - 'LBL_DASHLET_CHARTS' => 'Charts', |
|
| 82 | - 'LBL_DASHLET_ONLY_CHARTS' => 'Only show charts', |
|
| 83 | - 'LBL_AOR_SCHEDULED_REPORTS_AOR_REPORTS_FROM_AOR_SCHEDULED_REPORTS_TITLE' => 'Scheduled Reports', |
|
| 84 | - 'LBL_UPDATE_PARAMETERS' => 'Update', |
|
| 85 | - 'LBL_PARAMETERS' => 'Parameters', |
|
| 72 | + 'LBL_CHART_TITLE' => 'Title', |
|
| 73 | + 'LBL_CHART_TYPE' => 'Type', |
|
| 74 | + 'LBL_CHART_X_FIELD' => 'X Axis', |
|
| 75 | + 'LBL_CHART_Y_FIELD' => 'Y Axis', |
|
| 76 | + 'LBL_AOR_REPORTS_DASHLET' => 'Reports', |
|
| 77 | + 'LBL_DASHLET_TITLE' => 'Title', |
|
| 78 | + 'LBL_DASHLET_REPORT' => 'Report', |
|
| 79 | + 'LBL_DASHLET_CHOOSE_REPORT' => 'Please choose a report', |
|
| 80 | + 'LBL_DASHLET_SAVE' => 'Save', |
|
| 81 | + 'LBL_DASHLET_CHARTS' => 'Charts', |
|
| 82 | + 'LBL_DASHLET_ONLY_CHARTS' => 'Only show charts', |
|
| 83 | + 'LBL_AOR_SCHEDULED_REPORTS_AOR_REPORTS_FROM_AOR_SCHEDULED_REPORTS_TITLE' => 'Scheduled Reports', |
|
| 84 | + 'LBL_UPDATE_PARAMETERS' => 'Update', |
|
| 85 | + 'LBL_PARAMETERS' => 'Parameters', |
|
| 86 | 86 | 'LBL_TOOLTIP_DRAG_DROP_ELEMS' => 'Drag and drop elements into field or condition area', |
| 87 | 87 | 'LBL_MAIN_GROUPS' => 'Main Group:', |
| 88 | 88 | ); |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // config|_override.php |
| 4 | -if(is_file('../../../config.php')) { |
|
| 4 | +if (is_file('../../../config.php')) { |
|
| 5 | 5 | require_once('../../../config.php'); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | // load up the config_override.php file. This is used to provide default user settings |
| 9 | -if(is_file('../../../config_override.php')) { |
|
| 9 | +if (is_file('../../../config_override.php')) { |
|
| 10 | 10 | require_once('../../../config_override.php'); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | -if(!isset($sugar_config['theme_settings']['SuiteR'])) return; |
|
| 13 | +if (!isset($sugar_config['theme_settings']['SuiteR'])) return; |
|
| 14 | 14 | |
| 15 | 15 | //set file type back to css from php |
| 16 | 16 | header("Content-type: text/css; charset: UTF-8"); |
@@ -33,21 +33,21 @@ discard block |
||
| 33 | 33 | /* Dashlet CSS */ |
| 34 | 34 | |
| 35 | 35 | .dashletPanel .h3Row{ |
| 36 | -background: #<?php echo $sugar_config['theme_settings']['SuiteR']['dashlet'];?>; |
|
| 36 | +background: #<?php echo $sugar_config['theme_settings']['SuiteR']['dashlet']; ?>; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | .dashletPanel .h3Row h3{ |
| 40 | -color: #<?php echo $sugar_config['theme_settings']['SuiteR']['dashlet_headertext'];?> !important; |
|
| 40 | +color: #<?php echo $sugar_config['theme_settings']['SuiteR']['dashlet_headertext']; ?> !important; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | .dashletPanel .h3Row .dashletToolSet .icon{ |
| 44 | -fill: #<?php echo $sugar_config['theme_settings']['SuiteR']['dashlet_headertext'];?> !important; |
|
| 44 | +fill: #<?php echo $sugar_config['theme_settings']['SuiteR']['dashlet_headertext']; ?> !important; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /* Top navigation bar CSS */ |
| 48 | 48 | |
| 49 | 49 | .navbar-inverse { |
| 50 | -background:#<?php echo $sugar_config['theme_settings']['SuiteR']['navbar'];?> !important; |
|
| 50 | +background:#<?php echo $sugar_config['theme_settings']['SuiteR']['navbar']; ?> !important; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | .headerlinks a:link, .headerlinks a:visited, .navbar-inverse .navbar-brand, .moremenu a, a[id^=grouptab], a[id^=moduleTab] { |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | #searchform .btn |
| 77 | 77 | { |
| 78 | -background:#<?php echo $sugar_config['theme_settings']['SuiteR']['navbar'];?> !important; |
|
| 79 | -color: #<?php echo $sugar_config['theme_settings']['SuiteR']['icon'];?> !important; |
|
| 78 | +background:#<?php echo $sugar_config['theme_settings']['SuiteR']['navbar']; ?> !important; |
|
| 79 | +color: #<?php echo $sugar_config['theme_settings']['SuiteR']['icon']; ?> !important; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | #usermenu a{ |
@@ -84,27 +84,27 @@ discard block |
||
| 84 | 84 | public $id; |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * When createing a bean, you can specify a value in the id column as |
|
| 88 | - * long as that value is unique. During save, if the system finds an |
|
| 89 | - * id, it assumes it is an update. Setting new_with_id to true will |
|
| 90 | - * make sure the system performs an insert instead of an update. |
|
| 91 | - * |
|
| 92 | - * @var BOOL -- default false |
|
| 93 | - */ |
|
| 94 | - var $new_with_id = false; |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * How deep logic hooks can go |
|
| 99 | - * @var int |
|
| 100 | - */ |
|
| 101 | - protected $max_logic_depth = 10; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Disble vardefs. This should be set to true only for beans that do not have varders. Tracker is an example |
|
| 105 | - * |
|
| 106 | - * @var BOOL -- default false |
|
| 107 | - */ |
|
| 87 | + * When createing a bean, you can specify a value in the id column as |
|
| 88 | + * long as that value is unique. During save, if the system finds an |
|
| 89 | + * id, it assumes it is an update. Setting new_with_id to true will |
|
| 90 | + * make sure the system performs an insert instead of an update. |
|
| 91 | + * |
|
| 92 | + * @var BOOL -- default false |
|
| 93 | + */ |
|
| 94 | + var $new_with_id = false; |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * How deep logic hooks can go |
|
| 99 | + * @var int |
|
| 100 | + */ |
|
| 101 | + protected $max_logic_depth = 10; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Disble vardefs. This should be set to true only for beans that do not have varders. Tracker is an example |
|
| 105 | + * |
|
| 106 | + * @var BOOL -- default false |
|
| 107 | + */ |
|
| 108 | 108 | var $disable_vardefs = false; |
| 109 | 109 | |
| 110 | 110 | |
@@ -116,20 +116,20 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | var $new_assigned_user_name; |
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * An array of booleans. This array is cleared out when data is loaded. |
|
| 121 | - * As date/times are converted, a "1" is placed under the key, the field is converted. |
|
| 122 | - * |
|
| 123 | - * @var Array of booleans |
|
| 124 | - */ |
|
| 125 | - var $processed_dates_times = array(); |
|
| 119 | + /** |
|
| 120 | + * An array of booleans. This array is cleared out when data is loaded. |
|
| 121 | + * As date/times are converted, a "1" is placed under the key, the field is converted. |
|
| 122 | + * |
|
| 123 | + * @var Array of booleans |
|
| 124 | + */ |
|
| 125 | + var $processed_dates_times = array(); |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Whether to process date/time fields for storage in the database in GMT |
|
| 129 | - * |
|
| 130 | - * @var BOOL |
|
| 131 | - */ |
|
| 132 | - var $process_save_dates =true; |
|
| 127 | + /** |
|
| 128 | + * Whether to process date/time fields for storage in the database in GMT |
|
| 129 | + * |
|
| 130 | + * @var BOOL |
|
| 131 | + */ |
|
| 132 | + var $process_save_dates =true; |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * This signals to the bean that it is being saved in a mass mode. |
@@ -140,20 +140,20 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | var $save_from_post = true; |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * When running a query on related items using the method: retrieve_by_string_fields |
|
| 145 | - * this value will be set to true if more than one item matches the search criteria. |
|
| 146 | - * |
|
| 147 | - * @var BOOL |
|
| 148 | - */ |
|
| 149 | - var $duplicates_found = false; |
|
| 143 | + /** |
|
| 144 | + * When running a query on related items using the method: retrieve_by_string_fields |
|
| 145 | + * this value will be set to true if more than one item matches the search criteria. |
|
| 146 | + * |
|
| 147 | + * @var BOOL |
|
| 148 | + */ |
|
| 149 | + var $duplicates_found = false; |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * true if this bean has been deleted, false otherwise. |
|
| 153 | - * |
|
| 154 | - * @var BOOL |
|
| 155 | - */ |
|
| 156 | - var $deleted = 0; |
|
| 151 | + /** |
|
| 152 | + * true if this bean has been deleted, false otherwise. |
|
| 153 | + * |
|
| 154 | + * @var BOOL |
|
| 155 | + */ |
|
| 156 | + var $deleted = 0; |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * Should the date modified column of the bean be updated during save? |
@@ -201,22 +201,22 @@ discard block |
||
| 201 | 201 | var $table_name = ''; |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * This is the singular name of the bean. (i.e. Contact). |
|
| 205 | - * |
|
| 206 | - * @var String |
|
| 207 | - */ |
|
| 204 | + * This is the singular name of the bean. (i.e. Contact). |
|
| 205 | + * |
|
| 206 | + * @var String |
|
| 207 | + */ |
|
| 208 | 208 | var $object_name = ''; |
| 209 | 209 | |
| 210 | 210 | /** Set this to true if you query contains a sub-select and bean is converting both select statements |
| 211 | - * into count queries. |
|
| 212 | - */ |
|
| 211 | + * into count queries. |
|
| 212 | + */ |
|
| 213 | 213 | var $ungreedy_count=false; |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * The name of the module folder for this type of bean. |
|
| 217 | - * |
|
| 218 | - * @var String |
|
| 219 | - */ |
|
| 216 | + * The name of the module folder for this type of bean. |
|
| 217 | + * |
|
| 218 | + * @var String |
|
| 219 | + */ |
|
| 220 | 220 | var $module_dir = ''; |
| 221 | 221 | var $module_name = ''; |
| 222 | 222 | var $field_name_map; |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | var $importable = false; |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * Set to true in the child beans if the module use the special notification template |
|
| 253 | - */ |
|
| 252 | + * Set to true in the child beans if the module use the special notification template |
|
| 253 | + */ |
|
| 254 | 254 | var $special_notification = false; |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | protected $loaded_relationships = array(); |
| 284 | 284 | |
| 285 | - /** |
|
| 285 | + /** |
|
| 286 | 286 | * set to true if dependent fields updated |
| 287 | 287 | */ |
| 288 | 288 | protected $is_updated_dependent_fields = false; |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | return; |
| 662 | 662 | |
| 663 | 663 | foreach ($this->field_defs as $field => $value) { |
| 664 | - if( !empty($this->$field) |
|
| 664 | + if( !empty($this->$field) |
|
| 665 | 665 | && ((isset($value['default']) && $this->$field == $value['default']) || (!empty($value['display_default']) && $this->$field == $value['display_default'])) |
| 666 | 666 | ) { |
| 667 | 667 | $this->$field = null; |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | $this->$field = $this->parseDateDefault($value['display_default']); |
| 711 | 711 | } |
| 712 | 712 | break; |
| 713 | - case 'datetime': |
|
| 713 | + case 'datetime': |
|
| 714 | 714 | case 'datetimecombo': |
| 715 | 715 | if(!empty($value['display_default'])){ |
| 716 | 716 | $this->$field = $this->parseDateDefault($value['display_default'], true); |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | $this->$field = $value['default']; |
| 724 | 724 | break; |
| 725 | 725 | case 'bool': |
| 726 | - if(isset($this->$field)){ |
|
| 727 | - break; |
|
| 728 | - } |
|
| 726 | + if(isset($this->$field)){ |
|
| 727 | + break; |
|
| 728 | + } |
|
| 729 | 729 | default: |
| 730 | 730 | if ( isset($value['default']) && $value['default'] !== '' ) { |
| 731 | 731 | $this->$field = htmlentities($value['default'], ENT_QUOTES, 'UTF-8'); |
@@ -788,10 +788,10 @@ discard block |
||
| 788 | 788 | /** |
| 789 | 789 | * This method has been deprecated. |
| 790 | 790 | * |
| 791 | - * @see removeRelationshipMeta() |
|
| 791 | + * @see removeRelationshipMeta() |
|
| 792 | 792 | * @deprecated 4.5.1 - Nov 14, 2006 |
| 793 | 793 | * @static |
| 794 | - */ |
|
| 794 | + */ |
|
| 795 | 795 | static function remove_relationship_meta($key,$db,$log,$tablename,$dictionary,$module_dir) |
| 796 | 796 | { |
| 797 | 797 | SugarBean::removeRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
@@ -927,10 +927,10 @@ discard block |
||
| 927 | 927 | |
| 928 | 928 | /** |
| 929 | 929 | * This method has been deprecated. |
| 930 | - * @see createRelationshipMeta() |
|
| 930 | + * @see createRelationshipMeta() |
|
| 931 | 931 | * @deprecated 4.5.1 - Nov 14, 2006 |
| 932 | 932 | * @static |
| 933 | - */ |
|
| 933 | + */ |
|
| 934 | 934 | static function create_relationship_meta($key,&$db,&$log,$tablename,$dictionary,$module_dir) |
| 935 | 935 | { |
| 936 | 936 | SugarBean::createRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | |
| 1085 | 1085 | $linked_fields=array(); |
| 1086 | 1086 | |
| 1087 | - // require_once('data/Link.php'); |
|
| 1087 | + // require_once('data/Link.php'); |
|
| 1088 | 1088 | |
| 1089 | 1089 | $fieldDefs = $this->getFieldDefinitions(); |
| 1090 | 1090 | |
@@ -1314,8 +1314,8 @@ discard block |
||
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
| 1317 | - * Cleans char, varchar, text, etc. fields of XSS type materials |
|
| 1318 | - */ |
|
| 1317 | + * Cleans char, varchar, text, etc. fields of XSS type materials |
|
| 1318 | + */ |
|
| 1319 | 1319 | function cleanBean() { |
| 1320 | 1320 | foreach($this->field_defs as $key => $def) { |
| 1321 | 1321 | |
@@ -1338,14 +1338,14 @@ discard block |
||
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | /** |
| 1341 | - * Implements a generic insert and update logic for any SugarBean |
|
| 1342 | - * This method only works for subclasses that implement the same variable names. |
|
| 1343 | - * This method uses the presence of an id field that is not null to signify and update. |
|
| 1344 | - * The id field should not be set otherwise. |
|
| 1345 | - * |
|
| 1346 | - * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email. |
|
| 1347 | - * @todo Add support for field type validation and encoding of parameters. |
|
| 1348 | - */ |
|
| 1341 | + * Implements a generic insert and update logic for any SugarBean |
|
| 1342 | + * This method only works for subclasses that implement the same variable names. |
|
| 1343 | + * This method uses the presence of an id field that is not null to signify and update. |
|
| 1344 | + * The id field should not be set otherwise. |
|
| 1345 | + * |
|
| 1346 | + * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email. |
|
| 1347 | + * @todo Add support for field type validation and encoding of parameters. |
|
| 1348 | + */ |
|
| 1349 | 1349 | function save($check_notify = FALSE) |
| 1350 | 1350 | { |
| 1351 | 1351 | $this->in_save = true; |
@@ -1362,14 +1362,14 @@ discard block |
||
| 1362 | 1362 | $isUpdate = false; |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - if ( $this->new_with_id == true ) |
|
| 1366 | - { |
|
| 1367 | - $isUpdate = false; |
|
| 1368 | - } |
|
| 1369 | - if(empty($this->date_modified) || $this->update_date_modified) |
|
| 1370 | - { |
|
| 1371 | - $this->date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 1372 | - } |
|
| 1365 | + if ( $this->new_with_id == true ) |
|
| 1366 | + { |
|
| 1367 | + $isUpdate = false; |
|
| 1368 | + } |
|
| 1369 | + if(empty($this->date_modified) || $this->update_date_modified) |
|
| 1370 | + { |
|
| 1371 | + $this->date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 1372 | + } |
|
| 1373 | 1373 | |
| 1374 | 1374 | $this->_checkOptimisticLocking($action, $isUpdate); |
| 1375 | 1375 | |
@@ -1483,10 +1483,10 @@ discard block |
||
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | |
| 1486 | - /* BEGIN - SECURITY GROUPS - inheritance */ |
|
| 1487 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 1488 | - SecurityGroup::inherit($this,$isUpdate); |
|
| 1489 | - /* END - SECURITY GROUPS */ |
|
| 1486 | + /* BEGIN - SECURITY GROUPS - inheritance */ |
|
| 1487 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 1488 | + SecurityGroup::inherit($this,$isUpdate); |
|
| 1489 | + /* END - SECURITY GROUPS */ |
|
| 1490 | 1490 | //If we aren't in setup mode and we have a current user and module, then we track |
| 1491 | 1491 | if(isset($GLOBALS['current_user']) && isset($this->module_dir)) |
| 1492 | 1492 | { |
@@ -1527,8 +1527,8 @@ discard block |
||
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | /** |
| 1530 | - * Determines which users receive a notification |
|
| 1531 | - */ |
|
| 1530 | + * Determines which users receive a notification |
|
| 1531 | + */ |
|
| 1532 | 1532 | function get_notification_recipients() { |
| 1533 | 1533 | $notify_user = new User(); |
| 1534 | 1534 | $notify_user->retrieve($this->assigned_user_id); |
@@ -1545,11 +1545,11 @@ discard block |
||
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | /** |
| 1548 | - * Handles sending out email notifications when items are first assigned to users |
|
| 1549 | - * |
|
| 1550 | - * @param string $notify_user user to notify |
|
| 1551 | - * @param string $admin the admin user that sends out the notification |
|
| 1552 | - */ |
|
| 1548 | + * Handles sending out email notifications when items are first assigned to users |
|
| 1549 | + * |
|
| 1550 | + * @param string $notify_user user to notify |
|
| 1551 | + * @param string $admin the admin user that sends out the notification |
|
| 1552 | + */ |
|
| 1553 | 1553 | function send_assignment_notifications($notify_user, $admin) |
| 1554 | 1554 | { |
| 1555 | 1555 | global $current_user; |
@@ -1580,7 +1580,7 @@ discard block |
||
| 1580 | 1580 | $notify_mail->FromName = $from_name; |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - $oe = new OutboundEmail(); |
|
| 1583 | + $oe = new OutboundEmail(); |
|
| 1584 | 1584 | $oe = $oe->getUserMailerSettings($current_user); |
| 1585 | 1585 | //only send if smtp server is defined |
| 1586 | 1586 | if($sendEmail){ |
@@ -1616,9 +1616,9 @@ discard block |
||
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | /** |
| 1619 | - * This function handles create the email notifications email. |
|
| 1620 | - * @param string $notify_user the user to send the notification email to |
|
| 1621 | - */ |
|
| 1619 | + * This function handles create the email notifications email. |
|
| 1620 | + * @param string $notify_user the user to send the notification email to |
|
| 1621 | + */ |
|
| 1622 | 1622 | function create_notification_email($notify_user) { |
| 1623 | 1623 | global $sugar_version; |
| 1624 | 1624 | global $sugar_config; |
@@ -2027,104 +2027,104 @@ discard block |
||
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | 2029 | /** |
| 2030 | - * This function retrieves a record of the appropriate type from the DB. |
|
| 2031 | - * It fills in all of the fields from the DB into the object it was called on. |
|
| 2032 | - * |
|
| 2033 | - * @param $id - If ID is specified, it overrides the current value of $this->id. If not specified the current value of $this->id will be used. |
|
| 2034 | - * @return this - The object that it was called apon or null if exactly 1 record was not found. |
|
| 2035 | - * |
|
| 2036 | - */ |
|
| 2037 | - |
|
| 2038 | - function check_date_relationships_load() |
|
| 2039 | - { |
|
| 2040 | - global $disable_date_format; |
|
| 2041 | - global $timedate; |
|
| 2042 | - if (empty($timedate)) |
|
| 2043 | - $timedate=TimeDate::getInstance(); |
|
| 2044 | - |
|
| 2045 | - if(empty($this->field_defs)) |
|
| 2046 | - { |
|
| 2047 | - return; |
|
| 2048 | - } |
|
| 2049 | - foreach($this->field_defs as $fieldDef) |
|
| 2050 | - { |
|
| 2051 | - $field = $fieldDef['name']; |
|
| 2052 | - if(!isset($this->processed_dates_times[$field])) |
|
| 2053 | - { |
|
| 2054 | - $this->processed_dates_times[$field] = '1'; |
|
| 2055 | - if(empty($this->$field)) continue; |
|
| 2056 | - if($field == 'date_modified' || $field == 'date_entered') |
|
| 2057 | - { |
|
| 2058 | - $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
|
| 2059 | - if(empty($disable_date_format)) { |
|
| 2060 | - $this->$field = $timedate->to_display_date_time($this->$field); |
|
| 2061 | - } |
|
| 2062 | - } |
|
| 2063 | - elseif(isset($this->field_name_map[$field]['type'])) |
|
| 2064 | - { |
|
| 2065 | - $type = $this->field_name_map[$field]['type']; |
|
| 2066 | - |
|
| 2067 | - if($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
| 2068 | - { |
|
| 2069 | - $type = $this->field_name_map[$field]['type']; |
|
| 2070 | - } |
|
| 2071 | - |
|
| 2072 | - if($type == 'date') |
|
| 2073 | - { |
|
| 2074 | - if($this->$field == '0000-00-00') |
|
| 2075 | - { |
|
| 2076 | - $this->$field = ''; |
|
| 2077 | - } elseif(!empty($this->field_name_map[$field]['rel_field'])) |
|
| 2078 | - { |
|
| 2079 | - $rel_field = $this->field_name_map[$field]['rel_field']; |
|
| 2080 | - |
|
| 2081 | - if(!empty($this->$rel_field)) |
|
| 2082 | - { |
|
| 2083 | - if(empty($disable_date_format)) { |
|
| 2084 | - $mergetime = $timedate->merge_date_time($this->$field,$this->$rel_field); |
|
| 2085 | - $this->$field = $timedate->to_display_date($mergetime); |
|
| 2086 | - $this->$rel_field = $timedate->to_display_time($mergetime); |
|
| 2087 | - } |
|
| 2088 | - } |
|
| 2089 | - } |
|
| 2090 | - else |
|
| 2091 | - { |
|
| 2092 | - if(empty($disable_date_format)) { |
|
| 2093 | - $this->$field = $timedate->to_display_date($this->$field, false); |
|
| 2094 | - } |
|
| 2095 | - } |
|
| 2096 | - } elseif($type == 'datetime' || $type == 'datetimecombo') |
|
| 2097 | - { |
|
| 2098 | - if($this->$field == '0000-00-00 00:00:00') |
|
| 2099 | - { |
|
| 2100 | - $this->$field = ''; |
|
| 2101 | - } |
|
| 2102 | - else |
|
| 2103 | - { |
|
| 2104 | - if(empty($disable_date_format)) { |
|
| 2105 | - $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
|
| 2106 | - } |
|
| 2107 | - } |
|
| 2108 | - } elseif($type == 'time') |
|
| 2109 | - { |
|
| 2110 | - if($this->$field == '00:00:00') |
|
| 2111 | - { |
|
| 2112 | - $this->$field = ''; |
|
| 2113 | - } else |
|
| 2114 | - { |
|
| 2115 | - //$this->$field = from_db_convert($this->$field, 'time'); |
|
| 2116 | - if(empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
| 2117 | - { |
|
| 2118 | - $this->$field = $timedate->to_display_time($this->$field,true, false); |
|
| 2119 | - } |
|
| 2120 | - } |
|
| 2121 | - } elseif($type == 'encrypt' && empty($disable_date_format)){ |
|
| 2122 | - $this->$field = $this->decrypt_after_retrieve($this->$field); |
|
| 2123 | - } |
|
| 2124 | - } |
|
| 2125 | - } |
|
| 2126 | - } |
|
| 2127 | - } |
|
| 2030 | + * This function retrieves a record of the appropriate type from the DB. |
|
| 2031 | + * It fills in all of the fields from the DB into the object it was called on. |
|
| 2032 | + * |
|
| 2033 | + * @param $id - If ID is specified, it overrides the current value of $this->id. If not specified the current value of $this->id will be used. |
|
| 2034 | + * @return this - The object that it was called apon or null if exactly 1 record was not found. |
|
| 2035 | + * |
|
| 2036 | + */ |
|
| 2037 | + |
|
| 2038 | + function check_date_relationships_load() |
|
| 2039 | + { |
|
| 2040 | + global $disable_date_format; |
|
| 2041 | + global $timedate; |
|
| 2042 | + if (empty($timedate)) |
|
| 2043 | + $timedate=TimeDate::getInstance(); |
|
| 2044 | + |
|
| 2045 | + if(empty($this->field_defs)) |
|
| 2046 | + { |
|
| 2047 | + return; |
|
| 2048 | + } |
|
| 2049 | + foreach($this->field_defs as $fieldDef) |
|
| 2050 | + { |
|
| 2051 | + $field = $fieldDef['name']; |
|
| 2052 | + if(!isset($this->processed_dates_times[$field])) |
|
| 2053 | + { |
|
| 2054 | + $this->processed_dates_times[$field] = '1'; |
|
| 2055 | + if(empty($this->$field)) continue; |
|
| 2056 | + if($field == 'date_modified' || $field == 'date_entered') |
|
| 2057 | + { |
|
| 2058 | + $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
|
| 2059 | + if(empty($disable_date_format)) { |
|
| 2060 | + $this->$field = $timedate->to_display_date_time($this->$field); |
|
| 2061 | + } |
|
| 2062 | + } |
|
| 2063 | + elseif(isset($this->field_name_map[$field]['type'])) |
|
| 2064 | + { |
|
| 2065 | + $type = $this->field_name_map[$field]['type']; |
|
| 2066 | + |
|
| 2067 | + if($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
| 2068 | + { |
|
| 2069 | + $type = $this->field_name_map[$field]['type']; |
|
| 2070 | + } |
|
| 2071 | + |
|
| 2072 | + if($type == 'date') |
|
| 2073 | + { |
|
| 2074 | + if($this->$field == '0000-00-00') |
|
| 2075 | + { |
|
| 2076 | + $this->$field = ''; |
|
| 2077 | + } elseif(!empty($this->field_name_map[$field]['rel_field'])) |
|
| 2078 | + { |
|
| 2079 | + $rel_field = $this->field_name_map[$field]['rel_field']; |
|
| 2080 | + |
|
| 2081 | + if(!empty($this->$rel_field)) |
|
| 2082 | + { |
|
| 2083 | + if(empty($disable_date_format)) { |
|
| 2084 | + $mergetime = $timedate->merge_date_time($this->$field,$this->$rel_field); |
|
| 2085 | + $this->$field = $timedate->to_display_date($mergetime); |
|
| 2086 | + $this->$rel_field = $timedate->to_display_time($mergetime); |
|
| 2087 | + } |
|
| 2088 | + } |
|
| 2089 | + } |
|
| 2090 | + else |
|
| 2091 | + { |
|
| 2092 | + if(empty($disable_date_format)) { |
|
| 2093 | + $this->$field = $timedate->to_display_date($this->$field, false); |
|
| 2094 | + } |
|
| 2095 | + } |
|
| 2096 | + } elseif($type == 'datetime' || $type == 'datetimecombo') |
|
| 2097 | + { |
|
| 2098 | + if($this->$field == '0000-00-00 00:00:00') |
|
| 2099 | + { |
|
| 2100 | + $this->$field = ''; |
|
| 2101 | + } |
|
| 2102 | + else |
|
| 2103 | + { |
|
| 2104 | + if(empty($disable_date_format)) { |
|
| 2105 | + $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
|
| 2106 | + } |
|
| 2107 | + } |
|
| 2108 | + } elseif($type == 'time') |
|
| 2109 | + { |
|
| 2110 | + if($this->$field == '00:00:00') |
|
| 2111 | + { |
|
| 2112 | + $this->$field = ''; |
|
| 2113 | + } else |
|
| 2114 | + { |
|
| 2115 | + //$this->$field = from_db_convert($this->$field, 'time'); |
|
| 2116 | + if(empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
| 2117 | + { |
|
| 2118 | + $this->$field = $timedate->to_display_time($this->$field,true, false); |
|
| 2119 | + } |
|
| 2120 | + } |
|
| 2121 | + } elseif($type == 'encrypt' && empty($disable_date_format)){ |
|
| 2122 | + $this->$field = $this->decrypt_after_retrieve($this->$field); |
|
| 2123 | + } |
|
| 2124 | + } |
|
| 2125 | + } |
|
| 2126 | + } |
|
| 2127 | + } |
|
| 2128 | 2128 | |
| 2129 | 2129 | /** |
| 2130 | 2130 | * This function processes the fields before save. |
@@ -2136,21 +2136,21 @@ discard block |
||
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | 2138 | /** |
| 2139 | - * Removes formatting from values posted from the user interface. |
|
| 2139 | + * Removes formatting from values posted from the user interface. |
|
| 2140 | 2140 | * It only unformats numbers. Function relies on user/system prefernce for format strings. |
| 2141 | 2141 | * |
| 2142 | 2142 | * Internal Function, do not override. |
| 2143 | - */ |
|
| 2143 | + */ |
|
| 2144 | 2144 | function unformat_all_fields() |
| 2145 | 2145 | { |
| 2146 | 2146 | $GLOBALS['log']->deprecated('SugarBean.php: unformat_all_fields() is deprecated'); |
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | 2149 | /** |
| 2150 | - * This functions adds formatting to all number fields before presenting them to user interface. |
|
| 2150 | + * This functions adds formatting to all number fields before presenting them to user interface. |
|
| 2151 | 2151 | * |
| 2152 | 2152 | * Internal function, do not override. |
| 2153 | - */ |
|
| 2153 | + */ |
|
| 2154 | 2154 | function format_all_fields() |
| 2155 | 2155 | { |
| 2156 | 2156 | $GLOBALS['log']->deprecated('SugarBean.php: format_all_fields() is deprecated'); |
@@ -2190,8 +2190,8 @@ discard block |
||
| 2190 | 2190 | case 'datetimecombo': |
| 2191 | 2191 | if(empty($this->$field)) break; |
| 2192 | 2192 | if ($this->$field == 'NULL') { |
| 2193 | - $this->$field = ''; |
|
| 2194 | - break; |
|
| 2193 | + $this->$field = ''; |
|
| 2194 | + break; |
|
| 2195 | 2195 | } |
| 2196 | 2196 | if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/',$this->$field) ) { |
| 2197 | 2197 | // This appears to be formatted in user date/time |
@@ -2202,8 +2202,8 @@ discard block |
||
| 2202 | 2202 | case 'date': |
| 2203 | 2203 | if(empty($this->$field)) break; |
| 2204 | 2204 | if ($this->$field == 'NULL') { |
| 2205 | - $this->$field = ''; |
|
| 2206 | - break; |
|
| 2205 | + $this->$field = ''; |
|
| 2206 | + break; |
|
| 2207 | 2207 | } |
| 2208 | 2208 | if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$this->$field) ) { |
| 2209 | 2209 | // This date appears to be formatted in the user's format |
@@ -2214,8 +2214,8 @@ discard block |
||
| 2214 | 2214 | case 'time': |
| 2215 | 2215 | if(empty($this->$field)) break; |
| 2216 | 2216 | if ($this->$field == 'NULL') { |
| 2217 | - $this->$field = ''; |
|
| 2218 | - break; |
|
| 2217 | + $this->$field = ''; |
|
| 2218 | + break; |
|
| 2219 | 2219 | } |
| 2220 | 2220 | if ( preg_match('/(am|pm)/i',$this->$field) ) { |
| 2221 | 2221 | // This time appears to be formatted in the user's format |
@@ -2235,7 +2235,7 @@ discard block |
||
| 2235 | 2235 | $reformatted = true; |
| 2236 | 2236 | } |
| 2237 | 2237 | break; |
| 2238 | - case 'uint': |
|
| 2238 | + case 'uint': |
|
| 2239 | 2239 | case 'ulong': |
| 2240 | 2240 | case 'long': |
| 2241 | 2241 | case 'short': |
@@ -2248,21 +2248,21 @@ discard block |
||
| 2248 | 2248 | $this->$field = (int)unformat_number($this->$field); |
| 2249 | 2249 | $reformatted = true; |
| 2250 | 2250 | } |
| 2251 | - break; |
|
| 2252 | - case 'bool': |
|
| 2251 | + break; |
|
| 2252 | + case 'bool': |
|
| 2253 | 2253 | if (empty($this->$field)) { |
| 2254 | - $this->$field = false; |
|
| 2255 | - } else if(true === $this->$field || 1 == $this->$field) { |
|
| 2256 | - $this->$field = true; |
|
| 2257 | - } else if(in_array(strval($this->$field), $boolean_false_values)) { |
|
| 2258 | - $this->$field = false; |
|
| 2259 | - $reformatted = true; |
|
| 2260 | - } else { |
|
| 2261 | - $this->$field = true; |
|
| 2262 | - $reformatted = true; |
|
| 2263 | - } |
|
| 2264 | - break; |
|
| 2265 | - case 'encrypt': |
|
| 2254 | + $this->$field = false; |
|
| 2255 | + } else if(true === $this->$field || 1 == $this->$field) { |
|
| 2256 | + $this->$field = true; |
|
| 2257 | + } else if(in_array(strval($this->$field), $boolean_false_values)) { |
|
| 2258 | + $this->$field = false; |
|
| 2259 | + $reformatted = true; |
|
| 2260 | + } else { |
|
| 2261 | + $this->$field = true; |
|
| 2262 | + $reformatted = true; |
|
| 2263 | + } |
|
| 2264 | + break; |
|
| 2265 | + case 'encrypt': |
|
| 2266 | 2266 | $this->$field = $this->encrpyt_before_save($this->$field); |
| 2267 | 2267 | break; |
| 2268 | 2268 | } |
@@ -2284,7 +2284,7 @@ discard block |
||
| 2284 | 2284 | * @param boolean $deleted Optional, default true, if set to false deleted filter will not be added. |
| 2285 | 2285 | * |
| 2286 | 2286 | * Internal function, do not override. |
| 2287 | - */ |
|
| 2287 | + */ |
|
| 2288 | 2288 | function retrieve($id = -1, $encode=true,$deleted=true) |
| 2289 | 2289 | { |
| 2290 | 2290 | |
@@ -2340,18 +2340,18 @@ discard block |
||
| 2340 | 2340 | $this->custom_fields->fill_relationships(); |
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | - $this->is_updated_dependent_fields = false; |
|
| 2343 | + $this->is_updated_dependent_fields = false; |
|
| 2344 | 2344 | $this->fill_in_additional_detail_fields(); |
| 2345 | 2345 | $this->fill_in_relationship_fields(); |
| 2346 | 2346 | // save related fields values for audit |
| 2347 | - foreach ($this->get_related_fields() as $rel_field_name) |
|
| 2348 | - { |
|
| 2349 | - $field_name = $rel_field_name['name']; |
|
| 2350 | - if (! empty($this->$field_name)) |
|
| 2351 | - { |
|
| 2352 | - $this->fetched_rel_row[$rel_field_name['name']] = $this->$field_name; |
|
| 2353 | - } |
|
| 2354 | - } |
|
| 2347 | + foreach ($this->get_related_fields() as $rel_field_name) |
|
| 2348 | + { |
|
| 2349 | + $field_name = $rel_field_name['name']; |
|
| 2350 | + if (! empty($this->$field_name)) |
|
| 2351 | + { |
|
| 2352 | + $this->fetched_rel_row[$rel_field_name['name']] = $this->$field_name; |
|
| 2353 | + } |
|
| 2354 | + } |
|
| 2355 | 2355 | //make a copy of fields in the relationship_fields array. These field values will be used to |
| 2356 | 2356 | //clear relationship. |
| 2357 | 2357 | foreach ( $this->field_defs as $key => $def ) |
@@ -2364,7 +2364,7 @@ discard block |
||
| 2364 | 2364 | } |
| 2365 | 2365 | else |
| 2366 | 2366 | $this->rel_fields_before_value[$key]=null; |
| 2367 | - } |
|
| 2367 | + } |
|
| 2368 | 2368 | } |
| 2369 | 2369 | if (isset($this->relationship_fields) && is_array($this->relationship_fields)) |
| 2370 | 2370 | { |
@@ -2419,14 +2419,14 @@ discard block |
||
| 2419 | 2419 | |
| 2420 | 2420 | |
| 2421 | 2421 | /** |
| 2422 | - * Add any required joins to the list count query. The joins are required if there |
|
| 2423 | - * is a field in the $where clause that needs to be joined. |
|
| 2424 | - * |
|
| 2425 | - * @param string $query |
|
| 2426 | - * @param string $where |
|
| 2427 | - * |
|
| 2428 | - * Internal Function, do Not override. |
|
| 2429 | - */ |
|
| 2422 | + * Add any required joins to the list count query. The joins are required if there |
|
| 2423 | + * is a field in the $where clause that needs to be joined. |
|
| 2424 | + * |
|
| 2425 | + * @param string $query |
|
| 2426 | + * @param string $where |
|
| 2427 | + * |
|
| 2428 | + * Internal Function, do Not override. |
|
| 2429 | + */ |
|
| 2430 | 2430 | function add_list_count_joins(&$query, $where) |
| 2431 | 2431 | { |
| 2432 | 2432 | $custom_join = $this->getCustomJoin(); |
@@ -2435,15 +2435,15 @@ discard block |
||
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | 2437 | /** |
| 2438 | - * Changes the select expression of the given query to be 'count(*)' so you |
|
| 2439 | - * can get the number of items the query will return. This is used to |
|
| 2440 | - * populate the upper limit on ListViews. |
|
| 2438 | + * Changes the select expression of the given query to be 'count(*)' so you |
|
| 2439 | + * can get the number of items the query will return. This is used to |
|
| 2440 | + * populate the upper limit on ListViews. |
|
| 2441 | 2441 | * |
| 2442 | 2442 | * @param string $query Select query string |
| 2443 | 2443 | * @return string count query |
| 2444 | 2444 | * |
| 2445 | 2445 | * Internal function, do not override. |
| 2446 | - */ |
|
| 2446 | + */ |
|
| 2447 | 2447 | function create_list_count_query($query) |
| 2448 | 2448 | { |
| 2449 | 2449 | // remove the 'order by' clause which is expected to be at the end of the query |
@@ -2496,21 +2496,21 @@ discard block |
||
| 2496 | 2496 | } |
| 2497 | 2497 | |
| 2498 | 2498 | /** |
| 2499 | - * This function returns a paged list of the current object type. It is intended to allow for |
|
| 2500 | - * hopping back and forth through pages of data. It only retrieves what is on the current page. |
|
| 2501 | - * |
|
| 2502 | - * @internal This method must be called on a new instance. It trashes the values of all the fields in the current one. |
|
| 2503 | - * @param string $order_by |
|
| 2504 | - * @param string $where Additional where clause |
|
| 2505 | - * @param int $row_offset Optaional,default 0, starting row number |
|
| 2506 | - * @param init $limit Optional, default -1 |
|
| 2507 | - * @param int $max Optional, default -1 |
|
| 2508 | - * @param boolean $show_deleted Optional, default 0, if set to 1 system will show deleted records. |
|
| 2509 | - * @return array Fetched data. |
|
| 2510 | - * |
|
| 2511 | - * Internal function, do not override. |
|
| 2512 | - * |
|
| 2513 | - */ |
|
| 2499 | + * This function returns a paged list of the current object type. It is intended to allow for |
|
| 2500 | + * hopping back and forth through pages of data. It only retrieves what is on the current page. |
|
| 2501 | + * |
|
| 2502 | + * @internal This method must be called on a new instance. It trashes the values of all the fields in the current one. |
|
| 2503 | + * @param string $order_by |
|
| 2504 | + * @param string $where Additional where clause |
|
| 2505 | + * @param int $row_offset Optaional,default 0, starting row number |
|
| 2506 | + * @param init $limit Optional, default -1 |
|
| 2507 | + * @param int $max Optional, default -1 |
|
| 2508 | + * @param boolean $show_deleted Optional, default 0, if set to 1 system will show deleted records. |
|
| 2509 | + * @return array Fetched data. |
|
| 2510 | + * |
|
| 2511 | + * Internal function, do not override. |
|
| 2512 | + * |
|
| 2513 | + */ |
|
| 2514 | 2514 | function get_list($order_by = "", $where = "", $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $singleSelect=false, $select_fields = array()) |
| 2515 | 2515 | { |
| 2516 | 2516 | $GLOBALS['log']->debug("get_list: order_by = '$order_by' and where = '$where' and limit = '$limit'"); |
@@ -2540,15 +2540,15 @@ discard block |
||
| 2540 | 2540 | } |
| 2541 | 2541 | |
| 2542 | 2542 | /** |
| 2543 | - * Prefixes column names with this bean's table name. |
|
| 2544 | - * |
|
| 2545 | - * @param string $order_by Order by clause to be processed |
|
| 2546 | - * @param SugarBean $submodule name of the module this order by clause is for |
|
| 2547 | - * @param boolean $suppress_table_name Whether table name should be suppressed |
|
| 2548 | - * @return string Processed order by clause |
|
| 2549 | - * |
|
| 2550 | - * Internal function, do not override. |
|
| 2551 | - */ |
|
| 2543 | + * Prefixes column names with this bean's table name. |
|
| 2544 | + * |
|
| 2545 | + * @param string $order_by Order by clause to be processed |
|
| 2546 | + * @param SugarBean $submodule name of the module this order by clause is for |
|
| 2547 | + * @param boolean $suppress_table_name Whether table name should be suppressed |
|
| 2548 | + * @return string Processed order by clause |
|
| 2549 | + * |
|
| 2550 | + * Internal function, do not override. |
|
| 2551 | + */ |
|
| 2552 | 2552 | public function process_order_by($order_by, $submodule = null, $suppress_table_name = false) |
| 2553 | 2553 | { |
| 2554 | 2554 | if (empty($order_by)) |
@@ -2622,21 +2622,21 @@ discard block |
||
| 2622 | 2622 | |
| 2623 | 2623 | |
| 2624 | 2624 | /** |
| 2625 | - * Returns a detail object like retrieving of the current object type. |
|
| 2626 | - * |
|
| 2627 | - * It is intended for use in navigation buttons on the DetailView. It will pass an offset and limit argument to the sql query. |
|
| 2628 | - * @internal This method must be called on a new instance. It overrides the values of all the fields in the current one. |
|
| 2629 | - * |
|
| 2630 | - * @param string $order_by |
|
| 2631 | - * @param string $where Additional where clause |
|
| 2632 | - * @param int $row_offset Optaional,default 0, starting row number |
|
| 2633 | - * @param init $limit Optional, default -1 |
|
| 2634 | - * @param int $max Optional, default -1 |
|
| 2635 | - * @param boolean $show_deleted Optioanl, default 0, if set to 1 system will show deleted records. |
|
| 2636 | - * @return array Fetched data. |
|
| 2637 | - * |
|
| 2638 | - * Internal function, do not override. |
|
| 2639 | - */ |
|
| 2625 | + * Returns a detail object like retrieving of the current object type. |
|
| 2626 | + * |
|
| 2627 | + * It is intended for use in navigation buttons on the DetailView. It will pass an offset and limit argument to the sql query. |
|
| 2628 | + * @internal This method must be called on a new instance. It overrides the values of all the fields in the current one. |
|
| 2629 | + * |
|
| 2630 | + * @param string $order_by |
|
| 2631 | + * @param string $where Additional where clause |
|
| 2632 | + * @param int $row_offset Optaional,default 0, starting row number |
|
| 2633 | + * @param init $limit Optional, default -1 |
|
| 2634 | + * @param int $max Optional, default -1 |
|
| 2635 | + * @param boolean $show_deleted Optioanl, default 0, if set to 1 system will show deleted records. |
|
| 2636 | + * @return array Fetched data. |
|
| 2637 | + * |
|
| 2638 | + * Internal function, do not override. |
|
| 2639 | + */ |
|
| 2640 | 2640 | function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
| 2641 | 2641 | { |
| 2642 | 2642 | $GLOBALS['log']->debug("get_detail: order_by = '$order_by' and where = '$where' and limit = '$limit' and offset = '$offset'"); |
@@ -2660,25 +2660,25 @@ discard block |
||
| 2660 | 2660 | } |
| 2661 | 2661 | } |
| 2662 | 2662 | |
| 2663 | - /* BEGIN - SECURITY GROUPS */ |
|
| 2664 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 2665 | - { |
|
| 2666 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 2667 | - global $current_user; |
|
| 2668 | - $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 2669 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 2670 | - if(!empty($owner_where)){ |
|
| 2671 | - if(empty($where)) |
|
| 2672 | - { |
|
| 2673 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
| 2674 | - } else { |
|
| 2675 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 2676 | - } |
|
| 2677 | - } else { |
|
| 2678 | - $where .= ' AND '. $group_where; |
|
| 2679 | - } |
|
| 2680 | - } |
|
| 2681 | - /* END - SECURITY GROUPS */ |
|
| 2663 | + /* BEGIN - SECURITY GROUPS */ |
|
| 2664 | + if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 2665 | + { |
|
| 2666 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 2667 | + global $current_user; |
|
| 2668 | + $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 2669 | + $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 2670 | + if(!empty($owner_where)){ |
|
| 2671 | + if(empty($where)) |
|
| 2672 | + { |
|
| 2673 | + $where = " (". $owner_where." or ".$group_where.") "; |
|
| 2674 | + } else { |
|
| 2675 | + $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 2676 | + } |
|
| 2677 | + } else { |
|
| 2678 | + $where .= ' AND '. $group_where; |
|
| 2679 | + } |
|
| 2680 | + } |
|
| 2681 | + /* END - SECURITY GROUPS */ |
|
| 2682 | 2682 | $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted, $offset); |
| 2683 | 2683 | |
| 2684 | 2684 | //Add Limit and Offset to query |
@@ -2688,16 +2688,16 @@ discard block |
||
| 2688 | 2688 | } |
| 2689 | 2689 | |
| 2690 | 2690 | /** |
| 2691 | - * Fetches data from all related tables. |
|
| 2692 | - * |
|
| 2693 | - * @param object $child_seed |
|
| 2694 | - * @param string $related_field_name relation to fetch data for |
|
| 2695 | - * @param string $order_by Optional, default empty |
|
| 2696 | - * @param string $where Optional, additional where clause |
|
| 2697 | - * @return array Fetched data. |
|
| 2698 | - * |
|
| 2699 | - * Internal function, do not override. |
|
| 2700 | - */ |
|
| 2691 | + * Fetches data from all related tables. |
|
| 2692 | + * |
|
| 2693 | + * @param object $child_seed |
|
| 2694 | + * @param string $related_field_name relation to fetch data for |
|
| 2695 | + * @param string $order_by Optional, default empty |
|
| 2696 | + * @param string $where Optional, additional where clause |
|
| 2697 | + * @return array Fetched data. |
|
| 2698 | + * |
|
| 2699 | + * Internal function, do not override. |
|
| 2700 | + */ |
|
| 2701 | 2701 | function get_related_list($child_seed,$related_field_name, $order_by = "", $where = "", |
| 2702 | 2702 | $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
| 2703 | 2703 | { |
@@ -3073,13 +3073,13 @@ discard block |
||
| 3073 | 3073 | |
| 3074 | 3074 | |
| 3075 | 3075 | /** |
| 3076 | - * Returns a full (ie non-paged) list of the current object type. |
|
| 3077 | - * |
|
| 3078 | - * @param string $order_by the order by SQL parameter. defaults to "" |
|
| 3079 | - * @param string $where where clause. defaults to "" |
|
| 3080 | - * @param boolean $check_dates. defaults to false |
|
| 3081 | - * @param int $show_deleted show deleted records. defaults to 0 |
|
| 3082 | - */ |
|
| 3076 | + * Returns a full (ie non-paged) list of the current object type. |
|
| 3077 | + * |
|
| 3078 | + * @param string $order_by the order by SQL parameter. defaults to "" |
|
| 3079 | + * @param string $where where clause. defaults to "" |
|
| 3080 | + * @param boolean $check_dates. defaults to false |
|
| 3081 | + * @param int $show_deleted show deleted records. defaults to 0 |
|
| 3082 | + */ |
|
| 3083 | 3083 | function get_full_list($order_by = "", $where = "", $check_dates=false, $show_deleted = 0) |
| 3084 | 3084 | { |
| 3085 | 3085 | $GLOBALS['log']->debug("get_full_list: order_by = '$order_by' and where = '$where'"); |
@@ -3107,7 +3107,7 @@ discard block |
||
| 3107 | 3107 | * @param boolean $singleSelect Optional, default false. |
| 3108 | 3108 | * @return String select query string, optionally an array value will be returned if $return_array= true. |
| 3109 | 3109 | */ |
| 3110 | - function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
|
| 3110 | + function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
|
| 3111 | 3111 | { |
| 3112 | 3112 | global $beanFiles, $beanList; |
| 3113 | 3113 | $selectedFields = array(); |
@@ -3127,41 +3127,41 @@ discard block |
||
| 3127 | 3127 | $where .= ' AND '. $owner_where; |
| 3128 | 3128 | } |
| 3129 | 3129 | } |
| 3130 | - /* BEGIN - SECURITY GROUPS */ |
|
| 3131 | - global $current_user, $sugar_config; |
|
| 3132 | - if($this->module_dir == 'Users' && !is_admin($current_user) |
|
| 3133 | - && isset($sugar_config['securitysuite_filter_user_list']) |
|
| 3134 | - && $sugar_config['securitysuite_filter_user_list'] == true |
|
| 3135 | - ) { |
|
| 3136 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3137 | - global $current_user; |
|
| 3138 | - $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
|
| 3139 | - //$group_where = "user_name = 'admin'"; |
|
| 3140 | - if(empty($where)) |
|
| 3141 | - { |
|
| 3142 | - $where = " (".$group_where.") "; |
|
| 3143 | - } else { |
|
| 3144 | - $where .= " AND (".$group_where.") "; |
|
| 3145 | - } |
|
| 3146 | - } else |
|
| 3147 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 3148 | - { |
|
| 3149 | - require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3150 | - global $current_user; |
|
| 3151 | - $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 3152 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 3153 | - if(!empty($owner_where)){ |
|
| 3154 | - if(empty($where)) |
|
| 3155 | - { |
|
| 3156 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
| 3157 | - } else { |
|
| 3158 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 3159 | - } |
|
| 3160 | - } else { |
|
| 3161 | - $where .= ' AND '. $group_where; |
|
| 3162 | - } |
|
| 3163 | - } |
|
| 3164 | - /* END - SECURITY GROUPS */ |
|
| 3130 | + /* BEGIN - SECURITY GROUPS */ |
|
| 3131 | + global $current_user, $sugar_config; |
|
| 3132 | + if($this->module_dir == 'Users' && !is_admin($current_user) |
|
| 3133 | + && isset($sugar_config['securitysuite_filter_user_list']) |
|
| 3134 | + && $sugar_config['securitysuite_filter_user_list'] == true |
|
| 3135 | + ) { |
|
| 3136 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3137 | + global $current_user; |
|
| 3138 | + $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
|
| 3139 | + //$group_where = "user_name = 'admin'"; |
|
| 3140 | + if(empty($where)) |
|
| 3141 | + { |
|
| 3142 | + $where = " (".$group_where.") "; |
|
| 3143 | + } else { |
|
| 3144 | + $where .= " AND (".$group_where.") "; |
|
| 3145 | + } |
|
| 3146 | + } else |
|
| 3147 | + if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 3148 | + { |
|
| 3149 | + require_once('modules/SecurityGroups/SecurityGroup.php'); |
|
| 3150 | + global $current_user; |
|
| 3151 | + $owner_where = $this->getOwnerWhere($current_user->id); |
|
| 3152 | + $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 3153 | + if(!empty($owner_where)){ |
|
| 3154 | + if(empty($where)) |
|
| 3155 | + { |
|
| 3156 | + $where = " (". $owner_where." or ".$group_where.") "; |
|
| 3157 | + } else { |
|
| 3158 | + $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 3159 | + } |
|
| 3160 | + } else { |
|
| 3161 | + $where .= ' AND '. $group_where; |
|
| 3162 | + } |
|
| 3163 | + } |
|
| 3164 | + /* END - SECURITY GROUPS */ |
|
| 3165 | 3165 | if(!empty($params['distinct'])) |
| 3166 | 3166 | { |
| 3167 | 3167 | $distinct = ' DISTINCT '; |
@@ -3247,24 +3247,24 @@ discard block |
||
| 3247 | 3247 | |
| 3248 | 3248 | $used_join_key = array(); |
| 3249 | 3249 | |
| 3250 | - //walk through the fields and for every relationship field add their relationship_info field |
|
| 3251 | - //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field |
|
| 3252 | - $addrelate = array(); |
|
| 3253 | - foreach($fields as $field=>$value) |
|
| 3254 | - { |
|
| 3255 | - if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && |
|
| 3256 | - $this->field_defs[$field]['source'] == 'non-db') |
|
| 3257 | - { |
|
| 3258 | - $addrelatefield = $this->get_relationship_field($field); |
|
| 3259 | - if ($addrelatefield) |
|
| 3260 | - $addrelate[$addrelatefield] = true; |
|
| 3261 | - } |
|
| 3262 | - if(!empty($this->field_defs[$field]['id_name'])){ |
|
| 3263 | - $addrelate[$this->field_defs[$field]['id_name']] = true; |
|
| 3264 | - } |
|
| 3265 | - } |
|
| 3266 | - |
|
| 3267 | - $fields = array_merge($addrelate, $fields); |
|
| 3250 | + //walk through the fields and for every relationship field add their relationship_info field |
|
| 3251 | + //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field |
|
| 3252 | + $addrelate = array(); |
|
| 3253 | + foreach($fields as $field=>$value) |
|
| 3254 | + { |
|
| 3255 | + if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && |
|
| 3256 | + $this->field_defs[$field]['source'] == 'non-db') |
|
| 3257 | + { |
|
| 3258 | + $addrelatefield = $this->get_relationship_field($field); |
|
| 3259 | + if ($addrelatefield) |
|
| 3260 | + $addrelate[$addrelatefield] = true; |
|
| 3261 | + } |
|
| 3262 | + if(!empty($this->field_defs[$field]['id_name'])){ |
|
| 3263 | + $addrelate[$this->field_defs[$field]['id_name']] = true; |
|
| 3264 | + } |
|
| 3265 | + } |
|
| 3266 | + |
|
| 3267 | + $fields = array_merge($addrelate, $fields); |
|
| 3268 | 3268 | |
| 3269 | 3269 | foreach($fields as $field=>$value) |
| 3270 | 3270 | { |
@@ -3297,7 +3297,7 @@ discard block |
||
| 3297 | 3297 | //in opportunities module remove the contact_role/opportunity_role field. |
| 3298 | 3298 | if (isset($data['relationship_fields']) and !empty($data['relationship_fields'])) |
| 3299 | 3299 | { |
| 3300 | - $process_field = false; |
|
| 3300 | + $process_field = false; |
|
| 3301 | 3301 | foreach ($data['relationship_fields'] as $field_name) |
| 3302 | 3302 | { |
| 3303 | 3303 | if (isset($fields[$field_name])) |
@@ -3307,8 +3307,8 @@ discard block |
||
| 3307 | 3307 | } |
| 3308 | 3308 | } |
| 3309 | 3309 | |
| 3310 | - if (!$process_field) |
|
| 3311 | - continue; |
|
| 3310 | + if (!$process_field) |
|
| 3311 | + continue; |
|
| 3312 | 3312 | } |
| 3313 | 3313 | |
| 3314 | 3314 | if( (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) )) |
@@ -3416,27 +3416,27 @@ discard block |
||
| 3416 | 3416 | $rel_module = $this->$linkField->getRelatedModuleName(); |
| 3417 | 3417 | $table_joined = !empty($joined_tables[$params['join_table_alias']]) || (!empty($joined_tables[$params['join_table_link_alias']]) && isset($data['link_type']) && $data['link_type'] == 'relationship_info'); |
| 3418 | 3418 | |
| 3419 | - //if rname is set to 'name', and bean files exist, then check if field should be a concatenated name |
|
| 3420 | - global $beanFiles, $beanList; |
|
| 3419 | + //if rname is set to 'name', and bean files exist, then check if field should be a concatenated name |
|
| 3420 | + global $beanFiles, $beanList; |
|
| 3421 | 3421 | // °3/21/2014 FIX NS-TEAM - Relationship fields could not be displayed in subpanels |
| 3422 | 3422 | //if($data['rname'] && !empty($beanFiles[$beanList[$rel_module]])) { |
| 3423 | 3423 | if(isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) { |
| 3424 | 3424 | |
| 3425 | - //create an instance of the related bean |
|
| 3426 | - require_once($beanFiles[$beanList[$rel_module]]); |
|
| 3427 | - $rel_mod = new $beanList[$rel_module](); |
|
| 3428 | - //if bean has first and last name fields, then name should be concatenated |
|
| 3429 | - if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){ |
|
| 3430 | - $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name'); |
|
| 3431 | - } |
|
| 3432 | - } |
|
| 3425 | + //create an instance of the related bean |
|
| 3426 | + require_once($beanFiles[$beanList[$rel_module]]); |
|
| 3427 | + $rel_mod = new $beanList[$rel_module](); |
|
| 3428 | + //if bean has first and last name fields, then name should be concatenated |
|
| 3429 | + if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){ |
|
| 3430 | + $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name'); |
|
| 3431 | + } |
|
| 3432 | + } |
|
| 3433 | 3433 | |
| 3434 | 3434 | |
| 3435 | - if($join['type'] == 'many-to-many') |
|
| 3436 | - { |
|
| 3437 | - if(empty($ret_array['secondary_select'])) |
|
| 3438 | - { |
|
| 3439 | - $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id "; |
|
| 3435 | + if($join['type'] == 'many-to-many') |
|
| 3436 | + { |
|
| 3437 | + if(empty($ret_array['secondary_select'])) |
|
| 3438 | + { |
|
| 3439 | + $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id "; |
|
| 3440 | 3440 | |
| 3441 | 3441 | if(!empty($beanFiles[$beanList[$rel_module]]) && $join_primary) |
| 3442 | 3442 | { |
@@ -3548,42 +3548,42 @@ discard block |
||
| 3548 | 3548 | // and this code changes accounts to jt4 as there is a self join with the accounts table. |
| 3549 | 3549 | //Martin fix #27494 |
| 3550 | 3550 | if(isset($data['db_concat_fields'])){ |
| 3551 | - $buildWhere = false; |
|
| 3551 | + $buildWhere = false; |
|
| 3552 | 3552 | if(in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) |
| 3553 | - { |
|
| 3554 | - $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
|
| 3555 | - if(preg_match($exp, $where, $matches)) |
|
| 3556 | - { |
|
| 3557 | - $search_expression = $matches[0]; |
|
| 3558 | - //Create three search conditions - first + last, first, last |
|
| 3559 | - $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
| 3560 | - $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
| 3561 | - $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
|
| 3562 | - $buildWhere = true; |
|
| 3563 | - $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
| 3564 | - } |
|
| 3565 | - } |
|
| 3566 | - |
|
| 3567 | - if(!$buildWhere) |
|
| 3568 | - { |
|
| 3569 | - $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
|
| 3570 | - $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
|
| 3571 | - |
|
| 3572 | - // For relationship fields replace their alias by the corresponsding link table and r_name |
|
| 3573 | - if(isset($data['relationship_fields'])) |
|
| 3574 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3575 | - { |
|
| 3576 | - $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
|
| 3577 | - $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
| 3578 | - } |
|
| 3579 | - } |
|
| 3553 | + { |
|
| 3554 | + $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
|
| 3555 | + if(preg_match($exp, $where, $matches)) |
|
| 3556 | + { |
|
| 3557 | + $search_expression = $matches[0]; |
|
| 3558 | + //Create three search conditions - first + last, first, last |
|
| 3559 | + $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
| 3560 | + $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
| 3561 | + $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
|
| 3562 | + $buildWhere = true; |
|
| 3563 | + $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
| 3564 | + } |
|
| 3565 | + } |
|
| 3566 | + |
|
| 3567 | + if(!$buildWhere) |
|
| 3568 | + { |
|
| 3569 | + $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
|
| 3570 | + $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
|
| 3571 | + |
|
| 3572 | + // For relationship fields replace their alias by the corresponsding link table and r_name |
|
| 3573 | + if(isset($data['relationship_fields'])) |
|
| 3574 | + foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3575 | + { |
|
| 3576 | + $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
|
| 3577 | + $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
| 3578 | + } |
|
| 3579 | + } |
|
| 3580 | 3580 | }else{ |
| 3581 | 3581 | $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where); |
| 3582 | 3582 | |
| 3583 | - // For relationship fields replace their alias by the corresponsding link table and r_name |
|
| 3584 | - if(isset($data['relationship_fields'])) |
|
| 3585 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3586 | - $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
|
| 3583 | + // For relationship fields replace their alias by the corresponsding link table and r_name |
|
| 3584 | + if(isset($data['relationship_fields'])) |
|
| 3585 | + foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3586 | + $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
|
| 3587 | 3587 | } |
| 3588 | 3588 | if(!$table_joined) |
| 3589 | 3589 | { |
@@ -3612,12 +3612,12 @@ discard block |
||
| 3612 | 3612 | |
| 3613 | 3613 | } |
| 3614 | 3614 | |
| 3615 | - if ($ifListForExport) { |
|
| 3616 | - if(isset($this->field_defs['email1'])) { |
|
| 3617 | - $ret_array['select'].= " ,email_addresses.email_address email1"; |
|
| 3618 | - $ret_array['from'].= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
| 3619 | - } |
|
| 3620 | - } |
|
| 3615 | + if ($ifListForExport) { |
|
| 3616 | + if(isset($this->field_defs['email1'])) { |
|
| 3617 | + $ret_array['select'].= " ,email_addresses.email_address email1"; |
|
| 3618 | + $ret_array['from'].= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
| 3619 | + } |
|
| 3620 | + } |
|
| 3621 | 3621 | |
| 3622 | 3622 | $where_auto = '1=1'; |
| 3623 | 3623 | if($show_deleted == 0) |
@@ -3652,20 +3652,20 @@ discard block |
||
| 3652 | 3652 | return $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by']; |
| 3653 | 3653 | } |
| 3654 | 3654 | |
| 3655 | - // Check if field is defined through a relationship_info field, add this field when not present |
|
| 3656 | - function get_relationship_field($field) |
|
| 3657 | - { |
|
| 3658 | - foreach ($this->field_defs as $field_def => $value) |
|
| 3659 | - { |
|
| 3660 | - if (isset($value['relationship_fields']) && |
|
| 3661 | - in_array($field, $value['relationship_fields']) && |
|
| 3655 | + // Check if field is defined through a relationship_info field, add this field when not present |
|
| 3656 | + function get_relationship_field($field) |
|
| 3657 | + { |
|
| 3658 | + foreach ($this->field_defs as $field_def => $value) |
|
| 3659 | + { |
|
| 3660 | + if (isset($value['relationship_fields']) && |
|
| 3661 | + in_array($field, $value['relationship_fields']) && |
|
| 3662 | 3662 | (!isset($value['link_type']) || $value['link_type'] != 'relationship_info') |
| 3663 | 3663 | ) |
| 3664 | - return $field_def; |
|
| 3665 | - } |
|
| 3664 | + return $field_def; |
|
| 3665 | + } |
|
| 3666 | 3666 | |
| 3667 | - return false; |
|
| 3668 | - } |
|
| 3667 | + return false; |
|
| 3668 | + } |
|
| 3669 | 3669 | |
| 3670 | 3670 | /** |
| 3671 | 3671 | * Returns parent record data for objects that store relationship information |
@@ -3772,8 +3772,8 @@ discard block |
||
| 3772 | 3772 | global $sugar_config; |
| 3773 | 3773 | $db = DBManagerFactory::getInstance('listviews'); |
| 3774 | 3774 | /** |
| 3775 | - * if the row_offset is set to 'end' go to the end of the list |
|
| 3776 | - */ |
|
| 3775 | + * if the row_offset is set to 'end' go to the end of the list |
|
| 3776 | + */ |
|
| 3777 | 3777 | $toEnd = strval($row_offset) == 'end'; |
| 3778 | 3778 | $GLOBALS['log']->debug("process_list_query: ".$query); |
| 3779 | 3779 | if($max_per_page == -1) |
@@ -3901,13 +3901,13 @@ discard block |
||
| 3901 | 3901 | } |
| 3902 | 3902 | |
| 3903 | 3903 | /** |
| 3904 | - * Returns the number of rows that the given SQL query should produce |
|
| 3904 | + * Returns the number of rows that the given SQL query should produce |
|
| 3905 | 3905 | * |
| 3906 | 3906 | * Internal function, do not override. |
| 3907 | 3907 | * @param string $query valid select query |
| 3908 | 3908 | * @param boolean $is_count_query Optional, Default false, set to true if passed query is a count query. |
| 3909 | 3909 | * @return int count of rows found |
| 3910 | - */ |
|
| 3910 | + */ |
|
| 3911 | 3911 | function _get_num_rows_in_query($query, $is_count_query=false) |
| 3912 | 3912 | { |
| 3913 | 3913 | $num_rows_in_query = 0; |
@@ -3949,8 +3949,8 @@ discard block |
||
| 3949 | 3949 | { |
| 3950 | 3950 | $db = DBManagerFactory::getInstance('listviews'); |
| 3951 | 3951 | /** |
| 3952 | - * if the row_offset is set to 'end' go to the end of the list |
|
| 3953 | - */ |
|
| 3952 | + * if the row_offset is set to 'end' go to the end of the list |
|
| 3953 | + */ |
|
| 3954 | 3954 | $toEnd = strval($row_offset) == 'end'; |
| 3955 | 3955 | global $sugar_config; |
| 3956 | 3956 | $use_count_query=false; |
@@ -4188,7 +4188,7 @@ discard block |
||
| 4188 | 4188 | } |
| 4189 | 4189 | if(!empty($sugar_config['disable_count_query']) && !empty($limit)) |
| 4190 | 4190 | { |
| 4191 | - //C.L. Bug 43535 - Use the $index value to set the $rows_found value here |
|
| 4191 | + //C.L. Bug 43535 - Use the $index value to set the $rows_found value here |
|
| 4192 | 4192 | $rows_found = isset($index) ? $index : $row_offset + count($list); |
| 4193 | 4193 | |
| 4194 | 4194 | if(count($list) >= $limit) |
@@ -4338,28 +4338,28 @@ discard block |
||
| 4338 | 4338 | } |
| 4339 | 4339 | |
| 4340 | 4340 | /** |
| 4341 | - * Tracks the viewing of a detail record. |
|
| 4342 | - * This leverages get_summary_text() which is object specific. |
|
| 4343 | - * |
|
| 4344 | - * Internal function, do not override. |
|
| 4345 | - * @param string $user_id - String value of the user that is viewing the record. |
|
| 4346 | - * @param string $current_module - String value of the module being processed. |
|
| 4347 | - * @param string $current_view - String value of the current view |
|
| 4348 | - */ |
|
| 4349 | - function track_view($user_id, $current_module, $current_view='') |
|
| 4350 | - { |
|
| 4351 | - $trackerManager = TrackerManager::getInstance(); |
|
| 4352 | - if($monitor = $trackerManager->getMonitor('tracker')){ |
|
| 4353 | - $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb()); |
|
| 4354 | - $monitor->setValue('user_id', $user_id); |
|
| 4355 | - $monitor->setValue('module_name', $current_module); |
|
| 4356 | - $monitor->setValue('action', $current_view); |
|
| 4357 | - $monitor->setValue('item_id', $this->id); |
|
| 4358 | - $monitor->setValue('item_summary', $this->get_summary_text()); |
|
| 4359 | - $monitor->setValue('visible', $this->tracker_visibility); |
|
| 4360 | - $trackerManager->saveMonitor($monitor); |
|
| 4361 | - } |
|
| 4362 | - } |
|
| 4341 | + * Tracks the viewing of a detail record. |
|
| 4342 | + * This leverages get_summary_text() which is object specific. |
|
| 4343 | + * |
|
| 4344 | + * Internal function, do not override. |
|
| 4345 | + * @param string $user_id - String value of the user that is viewing the record. |
|
| 4346 | + * @param string $current_module - String value of the module being processed. |
|
| 4347 | + * @param string $current_view - String value of the current view |
|
| 4348 | + */ |
|
| 4349 | + function track_view($user_id, $current_module, $current_view='') |
|
| 4350 | + { |
|
| 4351 | + $trackerManager = TrackerManager::getInstance(); |
|
| 4352 | + if($monitor = $trackerManager->getMonitor('tracker')){ |
|
| 4353 | + $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb()); |
|
| 4354 | + $monitor->setValue('user_id', $user_id); |
|
| 4355 | + $monitor->setValue('module_name', $current_module); |
|
| 4356 | + $monitor->setValue('action', $current_view); |
|
| 4357 | + $monitor->setValue('item_id', $this->id); |
|
| 4358 | + $monitor->setValue('item_summary', $this->get_summary_text()); |
|
| 4359 | + $monitor->setValue('visible', $this->tracker_visibility); |
|
| 4360 | + $trackerManager->saveMonitor($monitor); |
|
| 4361 | + } |
|
| 4362 | + } |
|
| 4363 | 4363 | |
| 4364 | 4364 | /** |
| 4365 | 4365 | * Returns the summary text that should show up in the recent history list for this object. |
@@ -4372,12 +4372,12 @@ discard block |
||
| 4372 | 4372 | } |
| 4373 | 4373 | |
| 4374 | 4374 | /** |
| 4375 | - * This is designed to be overridden and add specific fields to each record. |
|
| 4376 | - * This allows the generic query to fill in the major fields, and then targeted |
|
| 4377 | - * queries to get related fields and add them to the record. The contact's |
|
| 4378 | - * account for instance. This method is only used for populating extra fields |
|
| 4379 | - * in lists. |
|
| 4380 | - */ |
|
| 4375 | + * This is designed to be overridden and add specific fields to each record. |
|
| 4376 | + * This allows the generic query to fill in the major fields, and then targeted |
|
| 4377 | + * queries to get related fields and add them to the record. The contact's |
|
| 4378 | + * account for instance. This method is only used for populating extra fields |
|
| 4379 | + * in lists. |
|
| 4380 | + */ |
|
| 4381 | 4381 | function fill_in_additional_list_fields(){ |
| 4382 | 4382 | if(!empty($this->field_defs['parent_name']) && empty($this->parent_name)){ |
| 4383 | 4383 | $this->fill_in_additional_parent_fields(); |
@@ -4385,12 +4385,12 @@ discard block |
||
| 4385 | 4385 | } |
| 4386 | 4386 | |
| 4387 | 4387 | /** |
| 4388 | - * This is designed to be overridden and add specific fields to each record. |
|
| 4389 | - * This allows the generic query to fill in the major fields, and then targeted |
|
| 4390 | - * queries to get related fields and add them to the record. The contact's |
|
| 4391 | - * account for instance. This method is only used for populating extra fields |
|
| 4392 | - * in the detail form |
|
| 4393 | - */ |
|
| 4388 | + * This is designed to be overridden and add specific fields to each record. |
|
| 4389 | + * This allows the generic query to fill in the major fields, and then targeted |
|
| 4390 | + * queries to get related fields and add them to the record. The contact's |
|
| 4391 | + * account for instance. This method is only used for populating extra fields |
|
| 4392 | + * in the detail form |
|
| 4393 | + */ |
|
| 4394 | 4394 | function fill_in_additional_detail_fields() |
| 4395 | 4395 | { |
| 4396 | 4396 | if(!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)){ |
@@ -4398,20 +4398,20 @@ discard block |
||
| 4398 | 4398 | $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
| 4399 | 4399 | |
| 4400 | 4400 | } |
| 4401 | - if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
| 4402 | - $this->created_by_name = get_assigned_user_name($this->created_by); |
|
| 4403 | - if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
| 4404 | - $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
|
| 4401 | + if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
| 4402 | + $this->created_by_name = get_assigned_user_name($this->created_by); |
|
| 4403 | + if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
| 4404 | + $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
|
| 4405 | 4405 | |
| 4406 | - if(!empty($this->field_defs['parent_name'])){ |
|
| 4407 | - $this->fill_in_additional_parent_fields(); |
|
| 4408 | - } |
|
| 4406 | + if(!empty($this->field_defs['parent_name'])){ |
|
| 4407 | + $this->fill_in_additional_parent_fields(); |
|
| 4408 | + } |
|
| 4409 | 4409 | } |
| 4410 | 4410 | |
| 4411 | 4411 | /** |
| 4412 | - * This is desgined to be overridden or called from extending bean. This method |
|
| 4413 | - * will fill in any parent_name fields. |
|
| 4414 | - */ |
|
| 4412 | + * This is desgined to be overridden or called from extending bean. This method |
|
| 4413 | + * will fill in any parent_name fields. |
|
| 4414 | + */ |
|
| 4415 | 4415 | function fill_in_additional_parent_fields() { |
| 4416 | 4416 | |
| 4417 | 4417 | if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){ |
@@ -4452,8 +4452,8 @@ discard block |
||
| 4452 | 4452 | } |
| 4453 | 4453 | |
| 4454 | 4454 | /** |
| 4455 | - * Fill in fields where type = relate |
|
| 4456 | - */ |
|
| 4455 | + * Fill in fields where type = relate |
|
| 4456 | + */ |
|
| 4457 | 4457 | function fill_in_relationship_fields(){ |
| 4458 | 4458 | global $fill_in_rel_depth; |
| 4459 | 4459 | if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
@@ -4477,7 +4477,7 @@ discard block |
||
| 4477 | 4477 | |
| 4478 | 4478 | if (empty($this->$id_name)) |
| 4479 | 4479 | { |
| 4480 | - $this->fill_in_link_field($id_name, $field); |
|
| 4480 | + $this->fill_in_link_field($id_name, $field); |
|
| 4481 | 4481 | } |
| 4482 | 4482 | if(!empty($this->$id_name) && ( $this->object_name != $related_module || ( $this->object_name == $related_module && $this->$id_name != $this->id ))){ |
| 4483 | 4483 | if(isset($GLOBALS['beanList'][ $related_module])){ |
@@ -4503,7 +4503,7 @@ discard block |
||
| 4503 | 4503 | if(!empty($this->$id_name) && isset($this->$name)) |
| 4504 | 4504 | { |
| 4505 | 4505 | if(!isset($field['additionalFields'])) |
| 4506 | - $field['additionalFields'] = array(); |
|
| 4506 | + $field['additionalFields'] = array(); |
|
| 4507 | 4507 | if(!empty($field['rname'])) |
| 4508 | 4508 | { |
| 4509 | 4509 | $field['additionalFields'][$field['rname']]= $name; |
@@ -4521,8 +4521,8 @@ discard block |
||
| 4521 | 4521 | } |
| 4522 | 4522 | |
| 4523 | 4523 | /** |
| 4524 | - * This is a helper function that is used to quickly created indexes when creating tables. |
|
| 4525 | - */ |
|
| 4524 | + * This is a helper function that is used to quickly created indexes when creating tables. |
|
| 4525 | + */ |
|
| 4526 | 4526 | function create_index($query) |
| 4527 | 4527 | { |
| 4528 | 4528 | $GLOBALS['log']->info("create_index: $query"); |
@@ -4534,21 +4534,21 @@ discard block |
||
| 4534 | 4534 | * This function should be overridden in each module. It marks an item as deleted. |
| 4535 | 4535 | * |
| 4536 | 4536 | * If it is not overridden, then marking this type of item is not allowed |
| 4537 | - */ |
|
| 4538 | - function mark_deleted($id) |
|
| 4539 | - { |
|
| 4540 | - global $current_user; |
|
| 4541 | - $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4537 | + */ |
|
| 4538 | + function mark_deleted($id) |
|
| 4539 | + { |
|
| 4540 | + global $current_user; |
|
| 4541 | + $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4542 | 4542 | $id = $this->db->quote($id); |
| 4543 | - if(isset($_SESSION['show_deleted'])) |
|
| 4544 | - { |
|
| 4545 | - $this->mark_undeleted($id); |
|
| 4546 | - } |
|
| 4547 | - else |
|
| 4548 | - { |
|
| 4549 | - // call the custom business logic |
|
| 4550 | - $custom_logic_arguments['id'] = $id; |
|
| 4551 | - $this->call_custom_logic("before_delete", $custom_logic_arguments); |
|
| 4543 | + if(isset($_SESSION['show_deleted'])) |
|
| 4544 | + { |
|
| 4545 | + $this->mark_undeleted($id); |
|
| 4546 | + } |
|
| 4547 | + else |
|
| 4548 | + { |
|
| 4549 | + // call the custom business logic |
|
| 4550 | + $custom_logic_arguments['id'] = $id; |
|
| 4551 | + $this->call_custom_logic("before_delete", $custom_logic_arguments); |
|
| 4552 | 4552 | $this->deleted = 1; |
| 4553 | 4553 | $this->mark_relationships_deleted($id); |
| 4554 | 4554 | if ( isset($this->field_defs['modified_user_id']) ) { |
@@ -4581,16 +4581,16 @@ discard block |
||
| 4581 | 4581 | * Restores data deleted by call to mark_deleted() function. |
| 4582 | 4582 | * |
| 4583 | 4583 | * Internal function, do not override. |
| 4584 | - */ |
|
| 4584 | + */ |
|
| 4585 | 4585 | function mark_undeleted($id) |
| 4586 | 4586 | { |
| 4587 | 4587 | // call the custom business logic |
| 4588 | 4588 | $custom_logic_arguments['id'] = $id; |
| 4589 | 4589 | $this->call_custom_logic("before_restore", $custom_logic_arguments); |
| 4590 | 4590 | |
| 4591 | - $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4592 | - $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'"; |
|
| 4593 | - $this->db->query($query, true,"Error marking record undeleted: "); |
|
| 4591 | + $date_modified = $GLOBALS['timedate']->nowDb(); |
|
| 4592 | + $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'"; |
|
| 4593 | + $this->db->query($query, true,"Error marking record undeleted: "); |
|
| 4594 | 4594 | |
| 4595 | 4595 | $this->restoreFiles(); |
| 4596 | 4596 | |
@@ -4598,17 +4598,17 @@ discard block |
||
| 4598 | 4598 | $this->call_custom_logic("after_restore", $custom_logic_arguments); |
| 4599 | 4599 | } |
| 4600 | 4600 | |
| 4601 | - /** |
|
| 4602 | - * This function deletes relationships to this object. It should be overridden |
|
| 4603 | - * to handle the relationships of the specific object. |
|
| 4604 | - * This function is called when the item itself is being deleted. |
|
| 4605 | - * |
|
| 4606 | - * @param int $id id of the relationship to delete |
|
| 4607 | - */ |
|
| 4608 | - function mark_relationships_deleted($id) |
|
| 4609 | - { |
|
| 4601 | + /** |
|
| 4602 | + * This function deletes relationships to this object. It should be overridden |
|
| 4603 | + * to handle the relationships of the specific object. |
|
| 4604 | + * This function is called when the item itself is being deleted. |
|
| 4605 | + * |
|
| 4606 | + * @param int $id id of the relationship to delete |
|
| 4607 | + */ |
|
| 4608 | + function mark_relationships_deleted($id) |
|
| 4609 | + { |
|
| 4610 | 4610 | $this->delete_linked($id); |
| 4611 | - } |
|
| 4611 | + } |
|
| 4612 | 4612 | |
| 4613 | 4613 | /** |
| 4614 | 4614 | * Returns path for files of bean or false on error |
@@ -4788,16 +4788,16 @@ discard block |
||
| 4788 | 4788 | } |
| 4789 | 4789 | |
| 4790 | 4790 | /** |
| 4791 | - * This function is used to execute the query and create an array template objects |
|
| 4792 | - * from the resulting ids from the query. |
|
| 4793 | - * It is currently used for building sub-panel arrays. |
|
| 4794 | - * |
|
| 4795 | - * @param string $query - the query that should be executed to build the list |
|
| 4796 | - * @param object $template - The object that should be used to copy the records. |
|
| 4797 | - * @param int $row_offset Optional, default 0 |
|
| 4798 | - * @param int $limit Optional, default -1 |
|
| 4799 | - * @return array |
|
| 4800 | - */ |
|
| 4791 | + * This function is used to execute the query and create an array template objects |
|
| 4792 | + * from the resulting ids from the query. |
|
| 4793 | + * It is currently used for building sub-panel arrays. |
|
| 4794 | + * |
|
| 4795 | + * @param string $query - the query that should be executed to build the list |
|
| 4796 | + * @param object $template - The object that should be used to copy the records. |
|
| 4797 | + * @param int $row_offset Optional, default 0 |
|
| 4798 | + * @param int $limit Optional, default -1 |
|
| 4799 | + * @return array |
|
| 4800 | + */ |
|
| 4801 | 4801 | function build_related_list($query, &$template, $row_offset = 0, $limit = -1) |
| 4802 | 4802 | { |
| 4803 | 4803 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
@@ -4833,17 +4833,17 @@ discard block |
||
| 4833 | 4833 | return $list; |
| 4834 | 4834 | } |
| 4835 | 4835 | |
| 4836 | - /** |
|
| 4837 | - * This function is used to execute the query and create an array template objects |
|
| 4838 | - * from the resulting ids from the query. |
|
| 4839 | - * It is currently used for building sub-panel arrays. It supports an additional |
|
| 4840 | - * where clause that is executed as a filter on the results |
|
| 4841 | - * |
|
| 4842 | - * @param string $query - the query that should be executed to build the list |
|
| 4843 | - * @param object $template - The object that should be used to copy the records. |
|
| 4844 | - */ |
|
| 4845 | - function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0) |
|
| 4846 | - { |
|
| 4836 | + /** |
|
| 4837 | + * This function is used to execute the query and create an array template objects |
|
| 4838 | + * from the resulting ids from the query. |
|
| 4839 | + * It is currently used for building sub-panel arrays. It supports an additional |
|
| 4840 | + * where clause that is executed as a filter on the results |
|
| 4841 | + * |
|
| 4842 | + * @param string $query - the query that should be executed to build the list |
|
| 4843 | + * @param object $template - The object that should be used to copy the records. |
|
| 4844 | + */ |
|
| 4845 | + function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0) |
|
| 4846 | + { |
|
| 4847 | 4847 | $db = DBManagerFactory::getInstance('listviews'); |
| 4848 | 4848 | // No need to do an additional query |
| 4849 | 4849 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
@@ -4904,7 +4904,7 @@ discard block |
||
| 4904 | 4904 | } |
| 4905 | 4905 | |
| 4906 | 4906 | return $list; |
| 4907 | - } |
|
| 4907 | + } |
|
| 4908 | 4908 | |
| 4909 | 4909 | /** |
| 4910 | 4910 | * Constructs an comma separated list of ids from passed query results. |
@@ -4940,15 +4940,15 @@ discard block |
||
| 4940 | 4940 | } |
| 4941 | 4941 | |
| 4942 | 4942 | /** |
| 4943 | - * Optionally copies values from fetched row into the bean. |
|
| 4944 | - * |
|
| 4945 | - * Internal function, do not override. |
|
| 4946 | - * |
|
| 4947 | - * @param string $query - the query that should be executed to build the list |
|
| 4948 | - * @param object $template - The object that should be used to copy the records |
|
| 4949 | - * @param array $field_list List of fields. |
|
| 4950 | - * @return array |
|
| 4951 | - */ |
|
| 4943 | + * Optionally copies values from fetched row into the bean. |
|
| 4944 | + * |
|
| 4945 | + * Internal function, do not override. |
|
| 4946 | + * |
|
| 4947 | + * @param string $query - the query that should be executed to build the list |
|
| 4948 | + * @param object $template - The object that should be used to copy the records |
|
| 4949 | + * @param array $field_list List of fields. |
|
| 4950 | + * @return array |
|
| 4951 | + */ |
|
| 4952 | 4952 | function build_related_list2($query, &$template, &$field_list) |
| 4953 | 4953 | { |
| 4954 | 4954 | $GLOBALS['log']->debug("Finding linked values $this->object_name: ".$query); |
@@ -5121,19 +5121,19 @@ discard block |
||
| 5121 | 5121 | $row = $this->convertRow($row); |
| 5122 | 5122 | $this->fetched_row = $row; |
| 5123 | 5123 | $this->fromArray($row); |
| 5124 | - $this->is_updated_dependent_fields = false; |
|
| 5124 | + $this->is_updated_dependent_fields = false; |
|
| 5125 | 5125 | $this->fill_in_additional_detail_fields(); |
| 5126 | 5126 | return $this; |
| 5127 | 5127 | } |
| 5128 | 5128 | |
| 5129 | 5129 | /** |
| 5130 | - * This method is called during an import before inserting a bean |
|
| 5131 | - * Define an associative array called $special_fields |
|
| 5132 | - * the keys are user defined, and don't directly map to the bean's fields |
|
| 5133 | - * the value is the method name within that bean that will do extra |
|
| 5134 | - * processing for that field. example: 'full_name'=>'get_names_from_full_name' |
|
| 5135 | - * |
|
| 5136 | - */ |
|
| 5130 | + * This method is called during an import before inserting a bean |
|
| 5131 | + * Define an associative array called $special_fields |
|
| 5132 | + * the keys are user defined, and don't directly map to the bean's fields |
|
| 5133 | + * the value is the method name within that bean that will do extra |
|
| 5134 | + * processing for that field. example: 'full_name'=>'get_names_from_full_name' |
|
| 5135 | + * |
|
| 5136 | + */ |
|
| 5137 | 5137 | function process_special_fields() |
| 5138 | 5138 | { |
| 5139 | 5139 | foreach ($this->special_functions as $func_name) |
@@ -5267,8 +5267,8 @@ discard block |
||
| 5267 | 5267 | { |
| 5268 | 5268 | $where = ''; |
| 5269 | 5269 | |
| 5270 | - // make sure there is a date modified |
|
| 5271 | - $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
|
| 5270 | + // make sure there is a date modified |
|
| 5271 | + $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
|
| 5272 | 5272 | |
| 5273 | 5273 | $row=null; |
| 5274 | 5274 | if($check_duplicates) |
@@ -5345,30 +5345,30 @@ discard block |
||
| 5345 | 5345 | } |
| 5346 | 5346 | |
| 5347 | 5347 | /** |
| 5348 | - * Trigger custom logic for this module that is defined for the provided hook |
|
| 5349 | - * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php. |
|
| 5350 | - * That file should define the $hook_version that should be used. |
|
| 5351 | - * It should also define the $hook_array. The $hook_array will be a two dimensional array |
|
| 5352 | - * the first dimension is the name of the event, the second dimension is the information needed |
|
| 5353 | - * to fire the hook. Each entry in the top level array should be defined on a single line to make it |
|
| 5354 | - * easier to automatically replace this file. There should be no contents of this file that are not replacable. |
|
| 5355 | - * |
|
| 5356 | - * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1'); |
|
| 5357 | - * This sample line creates a before_save hook. The hooks are procesed in the order in which they |
|
| 5358 | - * are added to the array. The second dimension is an array of: |
|
| 5359 | - * processing index (for sorting before exporting the array) |
|
| 5360 | - * A logic type hook |
|
| 5361 | - * label/type |
|
| 5362 | - * php file to include |
|
| 5363 | - * php class the method is in |
|
| 5364 | - * php method to call |
|
| 5365 | - * |
|
| 5366 | - * The method signature for version 1 hooks is: |
|
| 5367 | - * function NAME(&$bean, $event, $arguments) |
|
| 5368 | - * $bean - $this bean passed in by reference. |
|
| 5369 | - * $event - The string for the current event (i.e. before_save) |
|
| 5370 | - * $arguments - An array of arguments that are specific to the event. |
|
| 5371 | - */ |
|
| 5348 | + * Trigger custom logic for this module that is defined for the provided hook |
|
| 5349 | + * The custom logic file is located under custom/modules/[CURRENT_MODULE]/logic_hooks.php. |
|
| 5350 | + * That file should define the $hook_version that should be used. |
|
| 5351 | + * It should also define the $hook_array. The $hook_array will be a two dimensional array |
|
| 5352 | + * the first dimension is the name of the event, the second dimension is the information needed |
|
| 5353 | + * to fire the hook. Each entry in the top level array should be defined on a single line to make it |
|
| 5354 | + * easier to automatically replace this file. There should be no contents of this file that are not replacable. |
|
| 5355 | + * |
|
| 5356 | + * $hook_array['before_save'][] = Array(1, testtype, 'custom/modules/Leads/test12.php', 'TestClass', 'lead_before_save_1'); |
|
| 5357 | + * This sample line creates a before_save hook. The hooks are procesed in the order in which they |
|
| 5358 | + * are added to the array. The second dimension is an array of: |
|
| 5359 | + * processing index (for sorting before exporting the array) |
|
| 5360 | + * A logic type hook |
|
| 5361 | + * label/type |
|
| 5362 | + * php file to include |
|
| 5363 | + * php class the method is in |
|
| 5364 | + * php method to call |
|
| 5365 | + * |
|
| 5366 | + * The method signature for version 1 hooks is: |
|
| 5367 | + * function NAME(&$bean, $event, $arguments) |
|
| 5368 | + * $bean - $this bean passed in by reference. |
|
| 5369 | + * $event - The string for the current event (i.e. before_save) |
|
| 5370 | + * $arguments - An array of arguments that are specific to the event. |
|
| 5371 | + */ |
|
| 5372 | 5372 | function call_custom_logic($event, $arguments = null) |
| 5373 | 5373 | { |
| 5374 | 5374 | if(!isset($this->processed) || $this->processed == false){ |
@@ -5432,14 +5432,14 @@ discard block |
||
| 5432 | 5432 | return false; |
| 5433 | 5433 | } |
| 5434 | 5434 | /** |
| 5435 | - * Check whether the user has access to a particular view for the current bean/module |
|
| 5436 | - * @param $view string required, the view to determine access for i.e. DetailView, ListView... |
|
| 5437 | - * @param $is_owner bool optional, this is part of the ACL check if the current user is an owner they will receive different access |
|
| 5438 | - */ |
|
| 5439 | - /* BEGIN - SECURITY GROUPS - aclaccess */ |
|
| 5440 | - /** |
|
| 5435 | + * Check whether the user has access to a particular view for the current bean/module |
|
| 5436 | + * @param $view string required, the view to determine access for i.e. DetailView, ListView... |
|
| 5437 | + * @param $is_owner bool optional, this is part of the ACL check if the current user is an owner they will receive different access |
|
| 5438 | + */ |
|
| 5439 | + /* BEGIN - SECURITY GROUPS - aclaccess */ |
|
| 5440 | + /** |
|
| 5441 | 5441 | function ACLAccess($view,$is_owner='not_set') |
| 5442 | - */ |
|
| 5442 | + */ |
|
| 5443 | 5443 | function ACLAccess($view,$is_owner='not_set',$in_group='not_set') |
| 5444 | 5444 | { |
| 5445 | 5445 | global $current_user; |
@@ -5447,61 +5447,61 @@ discard block |
||
| 5447 | 5447 | return true; |
| 5448 | 5448 | } |
| 5449 | 5449 | $not_set = false; |
| 5450 | - /** |
|
| 5450 | + /** |
|
| 5451 | 5451 | if($is_owner == 'not_set') |
| 5452 | - */ |
|
| 5453 | - if($is_owner === 'not_set') //eggsurplus: should be === |
|
| 5452 | + */ |
|
| 5453 | + if($is_owner === 'not_set') //eggsurplus: should be === |
|
| 5454 | 5454 | { |
| 5455 | 5455 | $not_set = true; |
| 5456 | 5456 | $is_owner = $this->isOwner($current_user->id); |
| 5457 | 5457 | } |
| 5458 | - // DJM - OBS Customizations - May 2009 |
|
| 5459 | - // Moved this code to convert to lowercase from below. |
|
| 5460 | - // Added new action variable. |
|
| 5461 | - $view = strtolower($view); |
|
| 5462 | - $action = ''; |
|
| 5463 | - // DJM - OBS Customizations - END CHANGE |
|
| 5464 | - if($in_group === 'not_set') |
|
| 5465 | - { |
|
| 5466 | - require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 5467 | - // DJM - OBS Customizations - May 2009 |
|
| 5468 | - // Added the following switch statement to convert the view |
|
| 5469 | - // into an action value. As per the switch below. |
|
| 5470 | - // Added the action parameter to the groupHasAccess call. |
|
| 5471 | - switch ($view) |
|
| 5472 | - { |
|
| 5473 | - case 'list': |
|
| 5474 | - case 'index': |
|
| 5475 | - case 'listview': |
|
| 5476 | - $action = "list"; |
|
| 5477 | - break; |
|
| 5478 | - case 'edit': |
|
| 5479 | - case 'save': |
|
| 5480 | - case 'popupeditview': |
|
| 5481 | - case 'editview': |
|
| 5482 | - $action = "edit"; |
|
| 5483 | - break; |
|
| 5484 | - case 'view': |
|
| 5485 | - case 'detail': |
|
| 5486 | - case 'detailview': |
|
| 5487 | - $action = "view"; |
|
| 5488 | - break; |
|
| 5489 | - case 'delete': |
|
| 5490 | - $action = "delete" ; |
|
| 5491 | - break; |
|
| 5492 | - case 'export': |
|
| 5493 | - $action = "export"; |
|
| 5494 | - break; |
|
| 5495 | - case 'import': |
|
| 5496 | - $action = "import"; |
|
| 5497 | - break; |
|
| 5498 | - default: |
|
| 5499 | - $action = ""; |
|
| 5500 | - break; |
|
| 5501 | - } |
|
| 5502 | - $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); |
|
| 5503 | - // DJM - OBS Customizations - END CHANGE |
|
| 5504 | - } |
|
| 5458 | + // DJM - OBS Customizations - May 2009 |
|
| 5459 | + // Moved this code to convert to lowercase from below. |
|
| 5460 | + // Added new action variable. |
|
| 5461 | + $view = strtolower($view); |
|
| 5462 | + $action = ''; |
|
| 5463 | + // DJM - OBS Customizations - END CHANGE |
|
| 5464 | + if($in_group === 'not_set') |
|
| 5465 | + { |
|
| 5466 | + require_once("modules/SecurityGroups/SecurityGroup.php"); |
|
| 5467 | + // DJM - OBS Customizations - May 2009 |
|
| 5468 | + // Added the following switch statement to convert the view |
|
| 5469 | + // into an action value. As per the switch below. |
|
| 5470 | + // Added the action parameter to the groupHasAccess call. |
|
| 5471 | + switch ($view) |
|
| 5472 | + { |
|
| 5473 | + case 'list': |
|
| 5474 | + case 'index': |
|
| 5475 | + case 'listview': |
|
| 5476 | + $action = "list"; |
|
| 5477 | + break; |
|
| 5478 | + case 'edit': |
|
| 5479 | + case 'save': |
|
| 5480 | + case 'popupeditview': |
|
| 5481 | + case 'editview': |
|
| 5482 | + $action = "edit"; |
|
| 5483 | + break; |
|
| 5484 | + case 'view': |
|
| 5485 | + case 'detail': |
|
| 5486 | + case 'detailview': |
|
| 5487 | + $action = "view"; |
|
| 5488 | + break; |
|
| 5489 | + case 'delete': |
|
| 5490 | + $action = "delete" ; |
|
| 5491 | + break; |
|
| 5492 | + case 'export': |
|
| 5493 | + $action = "export"; |
|
| 5494 | + break; |
|
| 5495 | + case 'import': |
|
| 5496 | + $action = "import"; |
|
| 5497 | + break; |
|
| 5498 | + default: |
|
| 5499 | + $action = ""; |
|
| 5500 | + break; |
|
| 5501 | + } |
|
| 5502 | + $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); |
|
| 5503 | + // DJM - OBS Customizations - END CHANGE |
|
| 5504 | + } |
|
| 5505 | 5505 | //if we don't implent acls return true |
| 5506 | 5506 | if(!$this->bean_implements('ACL')) |
| 5507 | 5507 | return true; |
@@ -5511,10 +5511,10 @@ discard block |
||
| 5511 | 5511 | case 'list': |
| 5512 | 5512 | case 'index': |
| 5513 | 5513 | case 'listview': |
| 5514 | - /** |
|
| 5514 | + /** |
|
| 5515 | 5515 | return ACLController::checkAccess($this->module_dir,'list', true); |
| 5516 | - */ |
|
| 5517 | - return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group); |
|
| 5516 | + */ |
|
| 5517 | + return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group); |
|
| 5518 | 5518 | case 'edit': |
| 5519 | 5519 | case 'save': |
| 5520 | 5520 | if( !$is_owner && $not_set && !empty($this->id)){ |
@@ -5529,32 +5529,32 @@ discard block |
||
| 5529 | 5529 | } |
| 5530 | 5530 | case 'popupeditview': |
| 5531 | 5531 | case 'editview': |
| 5532 | - /** |
|
| 5532 | + /** |
|
| 5533 | 5533 | return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype); |
| 5534 | - */ |
|
| 5535 | - return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group); |
|
| 5534 | + */ |
|
| 5535 | + return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group); |
|
| 5536 | 5536 | case 'view': |
| 5537 | 5537 | case 'detail': |
| 5538 | 5538 | case 'detailview': |
| 5539 | - /** |
|
| 5539 | + /** |
|
| 5540 | 5540 | return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype); |
| 5541 | - */ |
|
| 5542 | - return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group); |
|
| 5541 | + */ |
|
| 5542 | + return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group); |
|
| 5543 | 5543 | case 'delete': |
| 5544 | - /** |
|
| 5544 | + /** |
|
| 5545 | 5545 | return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype); |
| 5546 | - */ |
|
| 5547 | - return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group); |
|
| 5546 | + */ |
|
| 5547 | + return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group); |
|
| 5548 | 5548 | case 'export': |
| 5549 | - /** |
|
| 5549 | + /** |
|
| 5550 | 5550 | return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype); |
| 5551 | - */ |
|
| 5552 | - return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group); |
|
| 5551 | + */ |
|
| 5552 | + return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group); |
|
| 5553 | 5553 | case 'import': |
| 5554 | - /** |
|
| 5554 | + /** |
|
| 5555 | 5555 | return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype); |
| 5556 | - */ |
|
| 5557 | - return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group); |
|
| 5556 | + */ |
|
| 5557 | + return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group); |
|
| 5558 | 5558 | } |
| 5559 | 5559 | //if it is not one of the above views then it should be implemented on the page level |
| 5560 | 5560 | return true; |
@@ -5562,10 +5562,10 @@ discard block |
||
| 5562 | 5562 | /* END - SECURITY GROUPS */ |
| 5563 | 5563 | |
| 5564 | 5564 | /** |
| 5565 | - * Get owner field |
|
| 5566 | - * |
|
| 5567 | - * @return STRING |
|
| 5568 | - */ |
|
| 5565 | + * Get owner field |
|
| 5566 | + * |
|
| 5567 | + * @return STRING |
|
| 5568 | + */ |
|
| 5569 | 5569 | function getOwnerField($returnFieldName = false) |
| 5570 | 5570 | { |
| 5571 | 5571 | if (isset($this->field_defs['assigned_user_id'])) |
@@ -5582,11 +5582,11 @@ discard block |
||
| 5582 | 5582 | } |
| 5583 | 5583 | |
| 5584 | 5584 | /** |
| 5585 | - * Returns true of false if the user_id passed is the owner |
|
| 5586 | - * |
|
| 5587 | - * @param GUID $user_id |
|
| 5588 | - * @return boolean |
|
| 5589 | - */ |
|
| 5585 | + * Returns true of false if the user_id passed is the owner |
|
| 5586 | + * |
|
| 5587 | + * @param GUID $user_id |
|
| 5588 | + * @return boolean |
|
| 5589 | + */ |
|
| 5590 | 5590 | function isOwner($user_id) |
| 5591 | 5591 | { |
| 5592 | 5592 | //if we don't have an id we must be the owner as we are creating it |
@@ -5615,11 +5615,11 @@ discard block |
||
| 5615 | 5615 | return false; |
| 5616 | 5616 | } |
| 5617 | 5617 | /** |
| 5618 | - * Gets there where statement for checking if a user is an owner |
|
| 5619 | - * |
|
| 5620 | - * @param GUID $user_id |
|
| 5621 | - * @return STRING |
|
| 5622 | - */ |
|
| 5618 | + * Gets there where statement for checking if a user is an owner |
|
| 5619 | + * |
|
| 5620 | + * @param GUID $user_id |
|
| 5621 | + * @return STRING |
|
| 5622 | + */ |
|
| 5623 | 5623 | function getOwnerWhere($user_id) |
| 5624 | 5624 | { |
| 5625 | 5625 | if(isset($this->field_defs['assigned_user_id'])) |
@@ -5634,12 +5634,12 @@ discard block |
||
| 5634 | 5634 | } |
| 5635 | 5635 | |
| 5636 | 5636 | /** |
| 5637 | - * |
|
| 5638 | - * Used in order to manage ListView links and if they should |
|
| 5639 | - * links or not based on the ACL permissions of the user |
|
| 5640 | - * |
|
| 5641 | - * @return ARRAY of STRINGS |
|
| 5642 | - */ |
|
| 5637 | + * |
|
| 5638 | + * Used in order to manage ListView links and if they should |
|
| 5639 | + * links or not based on the ACL permissions of the user |
|
| 5640 | + * |
|
| 5641 | + * @return ARRAY of STRINGS |
|
| 5642 | + */ |
|
| 5643 | 5643 | function listviewACLHelper() |
| 5644 | 5644 | { |
| 5645 | 5645 | $array_assign = array(); |
@@ -5655,10 +5655,10 @@ discard block |
||
| 5655 | 5655 | } |
| 5656 | 5656 | |
| 5657 | 5657 | /** |
| 5658 | - * returns this bean as an array |
|
| 5659 | - * |
|
| 5660 | - * @return array of fields with id, name, access and category |
|
| 5661 | - */ |
|
| 5658 | + * returns this bean as an array |
|
| 5659 | + * |
|
| 5660 | + * @return array of fields with id, name, access and category |
|
| 5661 | + */ |
|
| 5662 | 5662 | function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false) |
| 5663 | 5663 | { |
| 5664 | 5664 | static $cache = array(); |
@@ -5688,10 +5688,10 @@ discard block |
||
| 5688 | 5688 | } |
| 5689 | 5689 | |
| 5690 | 5690 | /** |
| 5691 | - * Converts an array into an acl mapping name value pairs into files |
|
| 5692 | - * |
|
| 5693 | - * @param Array $arr |
|
| 5694 | - */ |
|
| 5691 | + * Converts an array into an acl mapping name value pairs into files |
|
| 5692 | + * |
|
| 5693 | + * @param Array $arr |
|
| 5694 | + */ |
|
| 5695 | 5695 | function fromArray($arr) |
| 5696 | 5696 | { |
| 5697 | 5697 | foreach($arr as $name=>$value) |
@@ -5709,13 +5709,13 @@ discard block |
||
| 5709 | 5709 | public function convertRow($row) |
| 5710 | 5710 | { |
| 5711 | 5711 | foreach($this->field_defs as $name => $fieldDef) |
| 5712 | - { |
|
| 5713 | - // skip empty fields and non-db fields |
|
| 5712 | + { |
|
| 5713 | + // skip empty fields and non-db fields |
|
| 5714 | 5714 | if (isset($name) && !empty($row[$name])) { |
| 5715 | 5715 | $row[$name] = $this->convertField($row[$name], $fieldDef); |
| 5716 | 5716 | } |
| 5717 | 5717 | } |
| 5718 | - return $row; |
|
| 5718 | + return $row; |
|
| 5719 | 5719 | } |
| 5720 | 5720 | |
| 5721 | 5721 | /** |
@@ -5763,18 +5763,18 @@ discard block |
||
| 5763 | 5763 | return !empty($GLOBALS['dictionary'][$this->object_name]['custom_fields']); |
| 5764 | 5764 | } |
| 5765 | 5765 | |
| 5766 | - /** |
|
| 5767 | - * Ensure that fields within order by clauses are properly qualified with |
|
| 5768 | - * their tablename. This qualification is a requirement for sql server support. |
|
| 5769 | - * |
|
| 5770 | - * @param string $order_by original order by from the query |
|
| 5771 | - * @param string $qualify prefix for columns in the order by list. |
|
| 5772 | - * @return prefixed |
|
| 5773 | - * |
|
| 5774 | - * Internal function do not override. |
|
| 5775 | - */ |
|
| 5776 | - function create_qualified_order_by( $order_by, $qualify) |
|
| 5777 | - { // if the column is empty, but the sort order is defined, the value will throw an error, so do not proceed if no order by is given |
|
| 5766 | + /** |
|
| 5767 | + * Ensure that fields within order by clauses are properly qualified with |
|
| 5768 | + * their tablename. This qualification is a requirement for sql server support. |
|
| 5769 | + * |
|
| 5770 | + * @param string $order_by original order by from the query |
|
| 5771 | + * @param string $qualify prefix for columns in the order by list. |
|
| 5772 | + * @return prefixed |
|
| 5773 | + * |
|
| 5774 | + * Internal function do not override. |
|
| 5775 | + */ |
|
| 5776 | + function create_qualified_order_by( $order_by, $qualify) |
|
| 5777 | + { // if the column is empty, but the sort order is defined, the value will throw an error, so do not proceed if no order by is given |
|
| 5778 | 5778 | if (empty($order_by)) |
| 5779 | 5779 | { |
| 5780 | 5780 | return $order_by; |
@@ -5789,17 +5789,17 @@ discard block |
||
| 5789 | 5789 | $comma = ", "; |
| 5790 | 5790 | } |
| 5791 | 5791 | return $order_by_clause; |
| 5792 | - } |
|
| 5792 | + } |
|
| 5793 | 5793 | |
| 5794 | - /** |
|
| 5795 | - * Combined the contents of street field 2 thru 4 into the main field |
|
| 5796 | - * |
|
| 5797 | - * @param string $street_field |
|
| 5798 | - */ |
|
| 5794 | + /** |
|
| 5795 | + * Combined the contents of street field 2 thru 4 into the main field |
|
| 5796 | + * |
|
| 5797 | + * @param string $street_field |
|
| 5798 | + */ |
|
| 5799 | 5799 | |
| 5800 | - function add_address_streets( |
|
| 5801 | - $street_field |
|
| 5802 | - ) |
|
| 5800 | + function add_address_streets( |
|
| 5801 | + $street_field |
|
| 5802 | + ) |
|
| 5803 | 5803 | { |
| 5804 | 5804 | if (isset($this->$street_field)) { |
| 5805 | 5805 | $street_field_2 = $street_field.'_2'; |
@@ -5853,9 +5853,9 @@ discard block |
||
| 5853 | 5853 | } |
| 5854 | 5854 | |
| 5855 | 5855 | /** |
| 5856 | - * Moved from save() method, functionality is the same, but this is intended to handle |
|
| 5857 | - * Optimistic locking functionality. |
|
| 5858 | - */ |
|
| 5856 | + * Moved from save() method, functionality is the same, but this is intended to handle |
|
| 5857 | + * Optimistic locking functionality. |
|
| 5858 | + */ |
|
| 5859 | 5859 | private function _checkOptimisticLocking($action, $isUpdate){ |
| 5860 | 5860 | if($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])){ |
| 5861 | 5861 | if(isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name) |
@@ -5894,8 +5894,8 @@ discard block |
||
| 5894 | 5894 | } |
| 5895 | 5895 | |
| 5896 | 5896 | /** |
| 5897 | - * Send assignment notifications and invites for meetings and calls |
|
| 5898 | - */ |
|
| 5897 | + * Send assignment notifications and invites for meetings and calls |
|
| 5898 | + */ |
|
| 5899 | 5899 | private function _sendNotifications($check_notify){ |
| 5900 | 5900 | if($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true. |
| 5901 | 5901 | && !$this->isOwner($this->created_by) ) // cn: bug 42727 no need to send email to owner (within workflow) |
@@ -5983,11 +5983,11 @@ discard block |
||
| 5983 | 5983 | $result = sugar_cache_retrieve($cache_key); |
| 5984 | 5984 | if(!empty($result)) |
| 5985 | 5985 | { |
| 5986 | - // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. |
|
| 5987 | - if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
| 5988 | - { |
|
| 5989 | - return null; |
|
| 5990 | - } |
|
| 5986 | + // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. |
|
| 5987 | + if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
| 5988 | + { |
|
| 5989 | + return null; |
|
| 5990 | + } |
|
| 5991 | 5991 | |
| 5992 | 5992 | return $result; |
| 5993 | 5993 | } |
@@ -6004,7 +6004,7 @@ discard block |
||
| 6004 | 6004 | if(empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) |
| 6005 | 6005 | { |
| 6006 | 6006 | // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation |
| 6007 | - sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
|
| 6007 | + sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
|
| 6008 | 6008 | return null; |
| 6009 | 6009 | } |
| 6010 | 6010 | |
@@ -6015,8 +6015,8 @@ discard block |
||
| 6015 | 6015 | |
| 6016 | 6016 | // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation |
| 6017 | 6017 | sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
| 6018 | - return null; |
|
| 6019 | - } |
|
| 6018 | + return null; |
|
| 6019 | + } |
|
| 6020 | 6020 | |
| 6021 | 6021 | /** |
| 6022 | 6022 | * Returns the ACL category for this module; defaults to the SugarBean::$acl_category if defined |
@@ -6037,10 +6037,10 @@ discard block |
||
| 6037 | 6037 | * @param string $where |
| 6038 | 6038 | * @return string SQL query |
| 6039 | 6039 | */ |
| 6040 | - public function create_export_query($order_by, $where) |
|
| 6041 | - { |
|
| 6042 | - return $this->create_new_list_query($order_by, $where, array(), array(), 0, '', false, $this, true, true); |
|
| 6043 | - } |
|
| 6040 | + public function create_export_query($order_by, $where) |
|
| 6041 | + { |
|
| 6042 | + return $this->create_new_list_query($order_by, $where, array(), array(), 0, '', false, $this, true, true); |
|
| 6043 | + } |
|
| 6044 | 6044 | |
| 6045 | 6045 | /** |
| 6046 | 6046 | * Determine whether the given field is a relate field |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @var BOOL |
| 131 | 131 | */ |
| 132 | - var $process_save_dates =true; |
|
| 132 | + var $process_save_dates = true; |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * This signals to the bean that it is being saved in a mass mode. |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | /** Set this to true if you query contains a sub-select and bean is converting both select statements |
| 211 | 211 | * into count queries. |
| 212 | 212 | */ |
| 213 | - var $ungreedy_count=false; |
|
| 213 | + var $ungreedy_count = false; |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * The name of the module folder for this type of bean. |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | var $additional_column_fields = array(); |
| 228 | 228 | var $relationship_fields = array(); |
| 229 | 229 | var $current_notify_user; |
| 230 | - var $fetched_row=false; |
|
| 230 | + var $fetched_row = false; |
|
| 231 | 231 | var $fetched_rel_row = array(); |
| 232 | 232 | var $layout_def; |
| 233 | 233 | var $force_load_details = false; |
| 234 | 234 | var $optimistic_lock = false; |
| 235 | 235 | var $disable_custom_fields = false; |
| 236 | 236 | var $number_formatting_done = false; |
| 237 | - var $process_field_encrypted=false; |
|
| 237 | + var $process_field_encrypted = false; |
|
| 238 | 238 | /* |
| 239 | 239 | * The default ACL type |
| 240 | 240 | */ |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $this->db = DBManagerFactory::getInstance(); |
| 318 | 318 | if (empty($this->module_name)) |
| 319 | 319 | $this->module_name = $this->module_dir; |
| 320 | - if((false == $this->disable_vardefs && empty($loaded_defs[$this->object_name])) || !empty($GLOBALS['reload_vardefs'])) |
|
| 320 | + if ((false == $this->disable_vardefs && empty($loaded_defs[$this->object_name])) || !empty($GLOBALS['reload_vardefs'])) |
|
| 321 | 321 | { |
| 322 | 322 | VardefManager::loadVardef($this->module_dir, $this->object_name); |
| 323 | 323 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | if (!empty($dictionary[$this->object_name]['fields'])) { |
| 326 | 326 | foreach ($dictionary[$this->object_name]['fields'] as $key=>$value_array) { |
| 327 | 327 | $column_fields[] = $key; |
| 328 | - if(!empty($value_array['required']) && !empty($value_array['name'])) { |
|
| 328 | + if (!empty($value_array['required']) && !empty($value_array['name'])) { |
|
| 329 | 329 | $this->required_fields[$value_array['name']] = 1; |
| 330 | 330 | } |
| 331 | 331 | } |
@@ -333,57 +333,57 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | //setup custom fields |
| 336 | - if(!isset($this->custom_fields) && |
|
| 336 | + if (!isset($this->custom_fields) && |
|
| 337 | 337 | empty($this->disable_custom_fields)) |
| 338 | 338 | { |
| 339 | 339 | $this->setupCustomFields($this->module_dir); |
| 340 | 340 | } |
| 341 | 341 | //load up field_arrays from CacheHandler; |
| 342 | - if(empty($this->list_fields)) |
|
| 342 | + if (empty($this->list_fields)) |
|
| 343 | 343 | $this->list_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'list_fields'); |
| 344 | - if(empty($this->column_fields)) |
|
| 344 | + if (empty($this->column_fields)) |
|
| 345 | 345 | $this->column_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'column_fields'); |
| 346 | - if(empty($this->required_fields)) |
|
| 346 | + if (empty($this->required_fields)) |
|
| 347 | 347 | $this->required_fields = $this->_loadCachedArray($this->module_dir, $this->object_name, 'required_fields'); |
| 348 | 348 | |
| 349 | - if(isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) |
|
| 349 | + if (isset($GLOBALS['dictionary'][$this->object_name]) && !$this->disable_vardefs) |
|
| 350 | 350 | { |
| 351 | 351 | $this->field_name_map = $dictionary[$this->object_name]['fields']; |
| 352 | - $this->field_defs = $dictionary[$this->object_name]['fields']; |
|
| 352 | + $this->field_defs = $dictionary[$this->object_name]['fields']; |
|
| 353 | 353 | |
| 354 | - if(!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
| 354 | + if (!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
| 355 | 355 | { |
| 356 | - $this->optimistic_lock=true; |
|
| 356 | + $this->optimistic_lock = true; |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | - $loaded_defs[$this->object_name]['column_fields'] =& $this->column_fields; |
|
| 360 | - $loaded_defs[$this->object_name]['list_fields'] =& $this->list_fields; |
|
| 361 | - $loaded_defs[$this->object_name]['required_fields'] =& $this->required_fields; |
|
| 362 | - $loaded_defs[$this->object_name]['field_name_map'] =& $this->field_name_map; |
|
| 363 | - $loaded_defs[$this->object_name]['field_defs'] =& $this->field_defs; |
|
| 359 | + $loaded_defs[$this->object_name]['column_fields'] = & $this->column_fields; |
|
| 360 | + $loaded_defs[$this->object_name]['list_fields'] = & $this->list_fields; |
|
| 361 | + $loaded_defs[$this->object_name]['required_fields'] = & $this->required_fields; |
|
| 362 | + $loaded_defs[$this->object_name]['field_name_map'] = & $this->field_name_map; |
|
| 363 | + $loaded_defs[$this->object_name]['field_defs'] = & $this->field_defs; |
|
| 364 | 364 | } |
| 365 | 365 | else |
| 366 | 366 | { |
| 367 | - $this->column_fields =& $loaded_defs[$this->object_name]['column_fields'] ; |
|
| 368 | - $this->list_fields =& $loaded_defs[$this->object_name]['list_fields']; |
|
| 369 | - $this->required_fields =& $loaded_defs[$this->object_name]['required_fields']; |
|
| 370 | - $this->field_name_map =& $loaded_defs[$this->object_name]['field_name_map']; |
|
| 371 | - $this->field_defs =& $loaded_defs[$this->object_name]['field_defs']; |
|
| 367 | + $this->column_fields = & $loaded_defs[$this->object_name]['column_fields']; |
|
| 368 | + $this->list_fields = & $loaded_defs[$this->object_name]['list_fields']; |
|
| 369 | + $this->required_fields = & $loaded_defs[$this->object_name]['required_fields']; |
|
| 370 | + $this->field_name_map = & $loaded_defs[$this->object_name]['field_name_map']; |
|
| 371 | + $this->field_defs = & $loaded_defs[$this->object_name]['field_defs']; |
|
| 372 | 372 | $this->added_custom_field_defs = true; |
| 373 | 373 | |
| 374 | - if(!isset($this->custom_fields) && |
|
| 374 | + if (!isset($this->custom_fields) && |
|
| 375 | 375 | empty($this->disable_custom_fields)) |
| 376 | 376 | { |
| 377 | 377 | $this->setupCustomFields($this->module_dir, false); |
| 378 | 378 | } |
| 379 | - if(!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
| 379 | + if (!empty($dictionary[$this->object_name]['optimistic_locking'])) |
|
| 380 | 380 | { |
| 381 | - $this->optimistic_lock=true; |
|
| 381 | + $this->optimistic_lock = true; |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if($this->bean_implements('ACL') && !empty($GLOBALS['current_user'])){ |
|
| 386 | - $this->acl_fields = (isset($dictionary[$this->object_name]['acl_fields']) && $dictionary[$this->object_name]['acl_fields'] === false)?false:true; |
|
| 385 | + if ($this->bean_implements('ACL') && !empty($GLOBALS['current_user'])) { |
|
| 386 | + $this->acl_fields = (isset($dictionary[$this->object_name]['acl_fields']) && $dictionary[$this->object_name]['acl_fields'] === false) ? false : true; |
|
| 387 | 387 | } |
| 388 | 388 | $this->populateDefaultValues(); |
| 389 | 389 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | if (!isset($this->audit_enabled_fields)) |
| 428 | 428 | { |
| 429 | 429 | |
| 430 | - $this->audit_enabled_fields=array(); |
|
| 430 | + $this->audit_enabled_fields = array(); |
|
| 431 | 431 | foreach ($this->field_defs as $field => $properties) |
| 432 | 432 | { |
| 433 | 433 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | ) |
| 438 | 438 | { |
| 439 | 439 | |
| 440 | - $this->audit_enabled_fields[$field]=$properties; |
|
| 440 | + $this->audit_enabled_fields[$field] = $properties; |
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | function create_audit_table() |
| 505 | 505 | { |
| 506 | 506 | global $dictionary; |
| 507 | - $table_name=$this->get_audit_table_name(); |
|
| 507 | + $table_name = $this->get_audit_table_name(); |
|
| 508 | 508 | |
| 509 | 509 | require('metadata/audit_templateMetaData.php'); |
| 510 | 510 | |
| 511 | 511 | // Bug: 52583 Need ability to customize template for audit tables |
| 512 | - $custom = 'custom/metadata/audit_templateMetaData_' . $this->getTableName() . '.php'; |
|
| 512 | + $custom = 'custom/metadata/audit_templateMetaData_'.$this->getTableName().'.php'; |
|
| 513 | 513 | if (file_exists($custom)) |
| 514 | 514 | { |
| 515 | 515 | require($custom); |
@@ -519,14 +519,14 @@ discard block |
||
| 519 | 519 | $indices = $dictionary['audit']['indices']; |
| 520 | 520 | |
| 521 | 521 | // Renaming template indexes to fit the particular audit table (removed the brittle hard coding) |
| 522 | - foreach($indices as $nr => $properties){ |
|
| 523 | - $indices[$nr]['name'] = 'idx_' . strtolower($this->getTableName()) . '_' . $properties['name']; |
|
| 522 | + foreach ($indices as $nr => $properties) { |
|
| 523 | + $indices[$nr]['name'] = 'idx_'.strtolower($this->getTableName()).'_'.$properties['name']; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | $engine = null; |
| 527 | - if(isset($dictionary['audit']['engine'])) { |
|
| 527 | + if (isset($dictionary['audit']['engine'])) { |
|
| 528 | 528 | $engine = $dictionary['audit']['engine']; |
| 529 | - } else if(isset($dictionary[$this->getObjectName()]['engine'])) { |
|
| 529 | + } else if (isset($dictionary[$this->getObjectName()]['engine'])) { |
|
| 530 | 530 | $engine = $dictionary[$this->getObjectName()]['engine']; |
| 531 | 531 | } |
| 532 | 532 | |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | public function getTableName() |
| 547 | 547 | { |
| 548 | - if(isset($this->table_name)) |
|
| 548 | + if (isset($this->table_name)) |
|
| 549 | 549 | { |
| 550 | 550 | return $this->table_name; |
| 551 | 551 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | function getIndices() |
| 580 | 580 | { |
| 581 | 581 | global $dictionary; |
| 582 | - if(isset($dictionary[$this->getObjectName()]['indices'])) |
|
| 582 | + if (isset($dictionary[$this->getObjectName()]['indices'])) |
|
| 583 | 583 | { |
| 584 | 584 | return $dictionary[$this->getObjectName()]['indices']; |
| 585 | 585 | } |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | function getFieldDefinition($name) |
| 600 | 600 | { |
| 601 | - if ( !isset($this->field_defs[$name]) ) |
|
| 601 | + if (!isset($this->field_defs[$name])) |
|
| 602 | 602 | return false; |
| 603 | 603 | |
| 604 | 604 | return $this->field_defs[$name]; |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | function getPrimaryFieldDefinition() |
| 617 | 617 | { |
| 618 | 618 | $def = $this->getFieldDefinition("id"); |
| 619 | - if(empty($def)) { |
|
| 619 | + if (empty($def)) { |
|
| 620 | 620 | $def = $this->getFieldDefinition(0); |
| 621 | 621 | } |
| 622 | 622 | if (empty($def)) { |
@@ -639,13 +639,13 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | function getFieldValue($name) |
| 641 | 641 | { |
| 642 | - if (!isset($this->$name)){ |
|
| 642 | + if (!isset($this->$name)) { |
|
| 643 | 643 | return FALSE; |
| 644 | 644 | } |
| 645 | - if($this->$name === TRUE){ |
|
| 645 | + if ($this->$name === TRUE) { |
|
| 646 | 646 | return 1; |
| 647 | 647 | } |
| 648 | - if($this->$name === FALSE){ |
|
| 648 | + if ($this->$name === FALSE) { |
|
| 649 | 649 | return 0; |
| 650 | 650 | } |
| 651 | 651 | return $this->$name; |
@@ -657,17 +657,17 @@ discard block |
||
| 657 | 657 | */ |
| 658 | 658 | public function unPopulateDefaultValues() |
| 659 | 659 | { |
| 660 | - if ( !is_array($this->field_defs) ) |
|
| 660 | + if (!is_array($this->field_defs)) |
|
| 661 | 661 | return; |
| 662 | 662 | |
| 663 | 663 | foreach ($this->field_defs as $field => $value) { |
| 664 | - if( !empty($this->$field) |
|
| 664 | + if (!empty($this->$field) |
|
| 665 | 665 | && ((isset($value['default']) && $this->$field == $value['default']) || (!empty($value['display_default']) && $this->$field == $value['display_default'])) |
| 666 | 666 | ) { |
| 667 | 667 | $this->$field = null; |
| 668 | 668 | continue; |
| 669 | 669 | } |
| 670 | - if(!empty($this->$field) && !empty($value['display_default']) && in_array($value['type'], array('date', 'datetime', 'datetimecombo')) && |
|
| 670 | + if (!empty($this->$field) && !empty($value['display_default']) && in_array($value['type'], array('date', 'datetime', 'datetimecombo')) && |
|
| 671 | 671 | $this->$field == $this->parseDateDefault($value['display_default'], ($value['type'] != 'date'))) { |
| 672 | 672 | $this->$field = null; |
| 673 | 673 | } |
@@ -684,10 +684,10 @@ discard block |
||
| 684 | 684 | protected function parseDateDefault($value, $time = false) |
| 685 | 685 | { |
| 686 | 686 | global $timedate; |
| 687 | - if($time) { |
|
| 687 | + if ($time) { |
|
| 688 | 688 | $dtAry = explode('&', $value, 2); |
| 689 | 689 | $dateValue = $timedate->getNow(true)->modify($dtAry[0]); |
| 690 | - if(!empty($dtAry[1])) { |
|
| 690 | + if (!empty($dtAry[1])) { |
|
| 691 | 691 | $timeValue = $timedate->fromString($dtAry[1]); |
| 692 | 692 | $dateValue->setTime($timeValue->hour, $timeValue->min, $timeValue->sec); |
| 693 | 693 | } |
@@ -697,37 +697,37 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - function populateDefaultValues($force=false){ |
|
| 701 | - if ( !is_array($this->field_defs) ) |
|
| 700 | + function populateDefaultValues($force = false) { |
|
| 701 | + if (!is_array($this->field_defs)) |
|
| 702 | 702 | return; |
| 703 | - foreach($this->field_defs as $field=>$value){ |
|
| 704 | - if((isset($value['default']) || !empty($value['display_default'])) && ($force || empty($this->$field))){ |
|
| 703 | + foreach ($this->field_defs as $field=>$value) { |
|
| 704 | + if ((isset($value['default']) || !empty($value['display_default'])) && ($force || empty($this->$field))) { |
|
| 705 | 705 | $type = $value['type']; |
| 706 | 706 | |
| 707 | - switch($type){ |
|
| 707 | + switch ($type) { |
|
| 708 | 708 | case 'date': |
| 709 | - if(!empty($value['display_default'])){ |
|
| 709 | + if (!empty($value['display_default'])) { |
|
| 710 | 710 | $this->$field = $this->parseDateDefault($value['display_default']); |
| 711 | 711 | } |
| 712 | 712 | break; |
| 713 | 713 | case 'datetime': |
| 714 | 714 | case 'datetimecombo': |
| 715 | - if(!empty($value['display_default'])){ |
|
| 715 | + if (!empty($value['display_default'])) { |
|
| 716 | 716 | $this->$field = $this->parseDateDefault($value['display_default'], true); |
| 717 | 717 | } |
| 718 | 718 | break; |
| 719 | 719 | case 'multienum': |
| 720 | - if(empty($value['default']) && !empty($value['display_default'])) |
|
| 720 | + if (empty($value['default']) && !empty($value['display_default'])) |
|
| 721 | 721 | $this->$field = $value['display_default']; |
| 722 | 722 | else |
| 723 | 723 | $this->$field = $value['default']; |
| 724 | 724 | break; |
| 725 | 725 | case 'bool': |
| 726 | - if(isset($this->$field)){ |
|
| 726 | + if (isset($this->$field)) { |
|
| 727 | 727 | break; |
| 728 | 728 | } |
| 729 | 729 | default: |
| 730 | - if ( isset($value['default']) && $value['default'] !== '' ) { |
|
| 730 | + if (isset($value['default']) && $value['default'] !== '') { |
|
| 731 | 731 | $this->$field = htmlentities($value['default'], ENT_QUOTES, 'UTF-8'); |
| 732 | 732 | } else { |
| 733 | 733 | $this->$field = ''; |
@@ -755,20 +755,20 @@ discard block |
||
| 755 | 755 | * |
| 756 | 756 | * Internal function, do not override. |
| 757 | 757 | */ |
| 758 | - static function removeRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir) |
|
| 758 | + static function removeRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir) |
|
| 759 | 759 | { |
| 760 | 760 | //load the module dictionary if not supplied. |
| 761 | 761 | if ((!isset($dictionary) or empty($dictionary)) && !empty($module_dir)) |
| 762 | 762 | { |
| 763 | - $filename='modules/'. $module_dir . '/vardefs.php'; |
|
| 764 | - if(file_exists($filename)) |
|
| 763 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
| 764 | + if (file_exists($filename)) |
|
| 765 | 765 | { |
| 766 | 766 | include($filename); |
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) |
| 770 | 770 | { |
| 771 | - $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename. " does not exist"); |
|
| 771 | + $GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
| 772 | 772 | display_notice("meta data absent for table ".$tablename." keyed to $key "); |
| 773 | 773 | } |
| 774 | 774 | else |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | $RelationshipDefs = $dictionary[$key]['relationships']; |
| 779 | 779 | foreach ($RelationshipDefs as $rel_name) |
| 780 | 780 | { |
| 781 | - Relationship::delete($rel_name,$db); |
|
| 781 | + Relationship::delete($rel_name, $db); |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | } |
@@ -792,9 +792,9 @@ discard block |
||
| 792 | 792 | * @deprecated 4.5.1 - Nov 14, 2006 |
| 793 | 793 | * @static |
| 794 | 794 | */ |
| 795 | - static function remove_relationship_meta($key,$db,$log,$tablename,$dictionary,$module_dir) |
|
| 795 | + static function remove_relationship_meta($key, $db, $log, $tablename, $dictionary, $module_dir) |
|
| 796 | 796 | { |
| 797 | - SugarBean::removeRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
|
| 797 | + SugarBean::removeRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | |
@@ -813,14 +813,14 @@ discard block |
||
| 813 | 813 | * |
| 814 | 814 | * Internal function, do not override. |
| 815 | 815 | */ |
| 816 | - static function createRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir,$iscustom=false) |
|
| 816 | + static function createRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir, $iscustom = false) |
|
| 817 | 817 | { |
| 818 | 818 | //load the module dictionary if not supplied. |
| 819 | 819 | if (empty($dictionary) && !empty($module_dir)) |
| 820 | 820 | { |
| 821 | - if($iscustom) |
|
| 821 | + if ($iscustom) |
|
| 822 | 822 | { |
| 823 | - $filename='custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php'; |
|
| 823 | + $filename = 'custom/modules/'.$module_dir.'/Ext/Vardefs/vardefs.ext.php'; |
|
| 824 | 824 | } |
| 825 | 825 | else |
| 826 | 826 | { |
@@ -829,33 +829,33 @@ discard block |
||
| 829 | 829 | // a very special case for the Employees module |
| 830 | 830 | // this must be done because the Employees/vardefs.php does an include_once on |
| 831 | 831 | // Users/vardefs.php |
| 832 | - $filename='modules/Users/vardefs.php'; |
|
| 832 | + $filename = 'modules/Users/vardefs.php'; |
|
| 833 | 833 | } |
| 834 | 834 | else |
| 835 | 835 | { |
| 836 | - $filename='modules/'. $module_dir . '/vardefs.php'; |
|
| 836 | + $filename = 'modules/'.$module_dir.'/vardefs.php'; |
|
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | - if(file_exists($filename)) |
|
| 840 | + if (file_exists($filename)) |
|
| 841 | 841 | { |
| 842 | 842 | include($filename); |
| 843 | 843 | // cn: bug 7679 - dictionary entries defined as $GLOBALS['name'] not found |
| 844 | - if(empty($dictionary) || !empty($GLOBALS['dictionary'][$key])) |
|
| 844 | + if (empty($dictionary) || !empty($GLOBALS['dictionary'][$key])) |
|
| 845 | 845 | { |
| 846 | 846 | $dictionary = $GLOBALS['dictionary']; |
| 847 | 847 | } |
| 848 | 848 | } |
| 849 | 849 | else |
| 850 | 850 | { |
| 851 | - $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename); |
|
| 851 | + $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found".$filename); |
|
| 852 | 852 | return; |
| 853 | 853 | } |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) |
| 857 | 857 | { |
| 858 | - $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename. " does not exist"); |
|
| 858 | + $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table ".$tablename." does not exist"); |
|
| 859 | 859 | display_notice("meta data absent for table ".$tablename." keyed to $key "); |
| 860 | 860 | } |
| 861 | 861 | else |
@@ -865,23 +865,23 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | $RelationshipDefs = $dictionary[$key]['relationships']; |
| 867 | 867 | |
| 868 | - $delimiter=','; |
|
| 868 | + $delimiter = ','; |
|
| 869 | 869 | global $beanList; |
| 870 | - $beanList_ucase=array_change_key_case ( $beanList ,CASE_UPPER); |
|
| 870 | + $beanList_ucase = array_change_key_case($beanList, CASE_UPPER); |
|
| 871 | 871 | foreach ($RelationshipDefs as $rel_name=>$rel_def) |
| 872 | 872 | { |
| 873 | 873 | if (isset($rel_def['lhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['lhs_module'])])) { |
| 874 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' lhs module is missing ' . $rel_def['lhs_module']); |
|
| 874 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' lhs module is missing '.$rel_def['lhs_module']); |
|
| 875 | 875 | continue; |
| 876 | 876 | } |
| 877 | 877 | if (isset($rel_def['rhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['rhs_module'])])) { |
| 878 | - $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' rhs module is missing ' . $rel_def['rhs_module']); |
|
| 878 | + $GLOBALS['log']->debug('skipping orphaned relationship record '.$rel_name.' rhs module is missing '.$rel_def['rhs_module']); |
|
| 879 | 879 | continue; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | |
| 883 | 883 | //check whether relationship exists or not first. |
| 884 | - if (Relationship::exists($rel_name,$db)) |
|
| 884 | + if (Relationship::exists($rel_name, $db)) |
|
| 885 | 885 | { |
| 886 | 886 | $GLOBALS['log']->debug('Skipping, reltionship already exists '.$rel_name); |
| 887 | 887 | } |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | $seed = BeanFactory::getBean("Relationships"); |
| 891 | 891 | $keys = array_keys($seed->field_defs); |
| 892 | 892 | $toInsert = array(); |
| 893 | - foreach($keys as $key) |
|
| 893 | + foreach ($keys as $key) |
|
| 894 | 894 | { |
| 895 | 895 | if ($key == "id") |
| 896 | 896 | { |
@@ -909,10 +909,10 @@ discard block |
||
| 909 | 909 | |
| 910 | 910 | |
| 911 | 911 | $column_list = implode(",", array_keys($toInsert)); |
| 912 | - $value_list = "'" . implode("','", array_values($toInsert)) . "'"; |
|
| 912 | + $value_list = "'".implode("','", array_values($toInsert))."'"; |
|
| 913 | 913 | |
| 914 | 914 | //create the record. todo add error check. |
| 915 | - $insert_string = "INSERT into relationships (" .$column_list. ") values (".$value_list.")"; |
|
| 915 | + $insert_string = "INSERT into relationships (".$column_list.") values (".$value_list.")"; |
|
| 916 | 916 | $db->query($insert_string, true); |
| 917 | 917 | } |
| 918 | 918 | } |
@@ -931,9 +931,9 @@ discard block |
||
| 931 | 931 | * @deprecated 4.5.1 - Nov 14, 2006 |
| 932 | 932 | * @static |
| 933 | 933 | */ |
| 934 | - static function create_relationship_meta($key,&$db,&$log,$tablename,$dictionary,$module_dir) |
|
| 934 | + static function create_relationship_meta($key, &$db, &$log, $tablename, $dictionary, $module_dir) |
|
| 935 | 935 | { |
| 936 | - SugarBean::createRelationshipMeta($key,$db,$tablename,$dictionary,$module_dir); |
|
| 936 | + SugarBean::createRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | |
@@ -946,8 +946,8 @@ discard block |
||
| 946 | 946 | */ |
| 947 | 947 | public function __clone() |
| 948 | 948 | { |
| 949 | - if(!empty($this->loaded_relationships)) { |
|
| 950 | - foreach($this->loaded_relationships as $rel) { |
|
| 949 | + if (!empty($this->loaded_relationships)) { |
|
| 950 | + foreach ($this->loaded_relationships as $rel) { |
|
| 951 | 951 | unset($this->$rel); |
| 952 | 952 | } |
| 953 | 953 | } |
@@ -1021,8 +1021,8 @@ discard block |
||
| 1021 | 1021 | function load_relationships() |
| 1022 | 1022 | { |
| 1023 | 1023 | $GLOBALS['log']->debug("SugarBean.load_relationships, Loading all relationships of type link."); |
| 1024 | - $linked_fields=$this->get_linked_fields(); |
|
| 1025 | - foreach($linked_fields as $name=>$properties) |
|
| 1024 | + $linked_fields = $this->get_linked_fields(); |
|
| 1025 | + foreach ($linked_fields as $name=>$properties) |
|
| 1026 | 1026 | { |
| 1027 | 1027 | $this->load_relationship($name); |
| 1028 | 1028 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
| 1045 | 1045 | * |
| 1046 | 1046 | * Internal function, do not override. |
| 1047 | 1047 | */ |
| 1048 | - function get_linked_beans($field_name,$bean_name = '', $order_by = '', $begin_index = 0, $end_index = -1, $deleted=0, $optional_where="") |
|
| 1048 | + function get_linked_beans($field_name, $bean_name = '', $order_by = '', $begin_index = 0, $end_index = -1, $deleted = 0, $optional_where = "") |
|
| 1049 | 1049 | { |
| 1050 | 1050 | //if bean_name is Case then use aCase |
| 1051 | - if($bean_name=="Case") |
|
| 1051 | + if ($bean_name == "Case") |
|
| 1052 | 1052 | $bean_name = "aCase"; |
| 1053 | 1053 | |
| 1054 | - if($this->load_relationship($field_name)) { |
|
| 1054 | + if ($this->load_relationship($field_name)) { |
|
| 1055 | 1055 | if ($this->$field_name instanceof Link) { |
| 1056 | 1056 | // some classes are still based on Link, e.g. TeamSetLink |
| 1057 | 1057 | return array_values($this->$field_name->getBeans(new $bean_name(), $order_by, $begin_index, $end_index, $deleted, $optional_where)); |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | function get_linked_fields() |
| 1083 | 1083 | { |
| 1084 | 1084 | |
| 1085 | - $linked_fields=array(); |
|
| 1085 | + $linked_fields = array(); |
|
| 1086 | 1086 | |
| 1087 | 1087 | // require_once('data/Link.php'); |
| 1088 | 1088 | |
@@ -1093,9 +1093,9 @@ discard block |
||
| 1093 | 1093 | { |
| 1094 | 1094 | foreach ($fieldDefs as $name=>$properties) |
| 1095 | 1095 | { |
| 1096 | - if (array_search('link',$properties) === 'type') |
|
| 1096 | + if (array_search('link', $properties) === 'type') |
|
| 1097 | 1097 | { |
| 1098 | - $linked_fields[$name]=$properties; |
|
| 1098 | + $linked_fields[$name] = $properties; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | } |
| 1101 | 1101 | } |
@@ -1115,38 +1115,38 @@ discard block |
||
| 1115 | 1115 | { |
| 1116 | 1116 | $importableFields = array(); |
| 1117 | 1117 | |
| 1118 | - $fieldDefs= $this->getFieldDefinitions(); |
|
| 1118 | + $fieldDefs = $this->getFieldDefinitions(); |
|
| 1119 | 1119 | |
| 1120 | 1120 | if (!empty($fieldDefs)) { |
| 1121 | 1121 | foreach ($fieldDefs as $key=>$value_array) { |
| 1122 | - if ( (isset($value_array['importable']) |
|
| 1122 | + if ((isset($value_array['importable']) |
|
| 1123 | 1123 | && (is_string($value_array['importable']) && $value_array['importable'] == 'false' |
| 1124 | 1124 | || is_bool($value_array['importable']) && $value_array['importable'] == false)) |
| 1125 | 1125 | || (isset($value_array['type']) && $value_array['type'] == 'link') |
| 1126 | 1126 | || (isset($value_array['auto_increment']) |
| 1127 | - && ($value_array['type'] == true || $value_array['type'] == 'true')) ) { |
|
| 1127 | + && ($value_array['type'] == true || $value_array['type'] == 'true'))) { |
|
| 1128 | 1128 | // only allow import if we force it |
| 1129 | 1129 | if (isset($value_array['importable']) |
| 1130 | 1130 | && (is_string($value_array['importable']) && $value_array['importable'] == 'true' |
| 1131 | 1131 | || is_bool($value_array['importable']) && $value_array['importable'] == true)) { |
| 1132 | - $importableFields[$key]=$value_array; |
|
| 1132 | + $importableFields[$key] = $value_array; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | } |
| 1135 | 1135 | else { |
| 1136 | 1136 | |
| 1137 | 1137 | //Expose the cooresponding id field of a relate field if it is only defined as a link so that users can relate records by id during import |
| 1138 | - if( isset($value_array['type']) && ($value_array['type'] == 'relate') && isset($value_array['id_name']) ) |
|
| 1138 | + if (isset($value_array['type']) && ($value_array['type'] == 'relate') && isset($value_array['id_name'])) |
|
| 1139 | 1139 | { |
| 1140 | 1140 | $idField = $value_array['id_name']; |
| 1141 | - if( isset($fieldDefs[$idField]) && isset($fieldDefs[$idField]['type'] ) && $fieldDefs[$idField]['type'] == 'link' ) |
|
| 1141 | + if (isset($fieldDefs[$idField]) && isset($fieldDefs[$idField]['type']) && $fieldDefs[$idField]['type'] == 'link') |
|
| 1142 | 1142 | { |
| 1143 | 1143 | $tmpFieldDefs = $fieldDefs[$idField]; |
| 1144 | - $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir) . " " . $GLOBALS['app_strings']['LBL_ID']; |
|
| 1145 | - $importableFields[$idField]=$tmpFieldDefs; |
|
| 1144 | + $tmpFieldDefs['vname'] = translate($value_array['vname'], $this->module_dir)." ".$GLOBALS['app_strings']['LBL_ID']; |
|
| 1145 | + $importableFields[$idField] = $tmpFieldDefs; |
|
| 1146 | 1146 | } |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - $importableFields[$key]=$value_array; |
|
| 1149 | + $importableFields[$key] = $value_array; |
|
| 1150 | 1150 | } |
| 1151 | 1151 | } |
| 1152 | 1152 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | function get_related_fields() |
| 1165 | 1165 | { |
| 1166 | 1166 | |
| 1167 | - $related_fields=array(); |
|
| 1167 | + $related_fields = array(); |
|
| 1168 | 1168 | |
| 1169 | 1169 | // require_once('data/Link.php'); |
| 1170 | 1170 | |
@@ -1175,9 +1175,9 @@ discard block |
||
| 1175 | 1175 | { |
| 1176 | 1176 | foreach ($fieldDefs as $name=>$properties) |
| 1177 | 1177 | { |
| 1178 | - if (array_search('relate',$properties) === 'type') |
|
| 1178 | + if (array_search('relate', $properties) === 'type') |
|
| 1179 | 1179 | { |
| 1180 | - $related_fields[$name]=$properties; |
|
| 1180 | + $related_fields[$name] = $properties; |
|
| 1181 | 1181 | } |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | $importable_fields = $this->get_importable_fields(); |
| 1196 | 1196 | $required_fields = array(); |
| 1197 | 1197 | |
| 1198 | - foreach ( $importable_fields as $name => $properties ) { |
|
| 1199 | - if ( isset($properties['importable']) && is_string($properties['importable']) && $properties['importable'] == 'required' ) { |
|
| 1198 | + foreach ($importable_fields as $name => $properties) { |
|
| 1199 | + if (isset($properties['importable']) && is_string($properties['importable']) && $properties['importable'] == 'required') { |
|
| 1200 | 1200 | $required_fields[$name] = $properties; |
| 1201 | 1201 | } |
| 1202 | 1202 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | */ |
| 1212 | 1212 | function delete_linked($id) |
| 1213 | 1213 | { |
| 1214 | - $linked_fields=$this->get_linked_fields(); |
|
| 1214 | + $linked_fields = $this->get_linked_fields(); |
|
| 1215 | 1215 | foreach ($linked_fields as $name => $value) |
| 1216 | 1216 | { |
| 1217 | 1217 | if ($this->load_relationship($name)) |
@@ -1237,18 +1237,18 @@ discard block |
||
| 1237 | 1237 | $key = $this->getObjectName(); |
| 1238 | 1238 | if (!array_key_exists($key, $dictionary)) |
| 1239 | 1239 | { |
| 1240 | - $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name. " does not exist"); |
|
| 1240 | + $GLOBALS['log']->fatal("create_tables: Metadata for table ".$this->table_name." does not exist"); |
|
| 1241 | 1241 | display_notice("meta data absent for table ".$this->table_name." keyed to $key "); |
| 1242 | 1242 | } |
| 1243 | 1243 | else |
| 1244 | 1244 | { |
| 1245 | - if(!$this->db->tableExists($this->table_name)) |
|
| 1245 | + if (!$this->db->tableExists($this->table_name)) |
|
| 1246 | 1246 | { |
| 1247 | 1247 | $this->db->createTable($this); |
| 1248 | - if($this->bean_implements('ACL')){ |
|
| 1249 | - if(!empty($this->acltype)){ |
|
| 1248 | + if ($this->bean_implements('ACL')) { |
|
| 1249 | + if (!empty($this->acltype)) { |
|
| 1250 | 1250 | ACLAction::addActions($this->getACLCategory(), $this->acltype); |
| 1251 | - }else{ |
|
| 1251 | + } else { |
|
| 1252 | 1252 | ACLAction::addActions($this->getACLCategory()); |
| 1253 | 1253 | } |
| 1254 | 1254 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | { |
| 1258 | 1258 | echo "Table already exists : $this->table_name<br>"; |
| 1259 | 1259 | } |
| 1260 | - if($this->is_AuditEnabled()){ |
|
| 1260 | + if ($this->is_AuditEnabled()) { |
|
| 1261 | 1261 | if (!$this->db->tableExists($this->get_audit_table_name())) { |
| 1262 | 1262 | $this->create_audit_table(); |
| 1263 | 1263 | } |
@@ -1278,16 +1278,16 @@ discard block |
||
| 1278 | 1278 | $key = $this->getObjectName(); |
| 1279 | 1279 | if (!array_key_exists($key, $dictionary)) |
| 1280 | 1280 | { |
| 1281 | - $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name. " does not exist"); |
|
| 1281 | + $GLOBALS['log']->fatal("drop_tables: Metadata for table ".$this->table_name." does not exist"); |
|
| 1282 | 1282 | echo "meta data absent for table ".$this->table_name."<br>\n"; |
| 1283 | 1283 | } else { |
| 1284 | - if(empty($this->table_name))return; |
|
| 1284 | + if (empty($this->table_name))return; |
|
| 1285 | 1285 | if ($this->db->tableExists($this->table_name)) |
| 1286 | 1286 | |
| 1287 | 1287 | $this->db->dropTable($this); |
| 1288 | - if ($this->db->tableExists($this->table_name. '_cstm')) |
|
| 1288 | + if ($this->db->tableExists($this->table_name.'_cstm')) |
|
| 1289 | 1289 | { |
| 1290 | - $this->db->dropTableName($this->table_name. '_cstm'); |
|
| 1290 | + $this->db->dropTableName($this->table_name.'_cstm'); |
|
| 1291 | 1291 | DynamicField::deleteCache(); |
| 1292 | 1292 | } |
| 1293 | 1293 | if ($this->db->tableExists($this->get_audit_table_name())) { |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | * @param string $module_name setting up custom fields for this module. |
| 1307 | 1307 | * @param boolean $clean_load Optional, default true, rebuilds the cache if set to true. |
| 1308 | 1308 | */ |
| 1309 | - function setupCustomFields($module_name, $clean_load=true) |
|
| 1309 | + function setupCustomFields($module_name, $clean_load = true) |
|
| 1310 | 1310 | { |
| 1311 | 1311 | $this->custom_fields = new DynamicField($module_name); |
| 1312 | 1312 | $this->custom_fields->setup($this); |
@@ -1317,17 +1317,17 @@ discard block |
||
| 1317 | 1317 | * Cleans char, varchar, text, etc. fields of XSS type materials |
| 1318 | 1318 | */ |
| 1319 | 1319 | function cleanBean() { |
| 1320 | - foreach($this->field_defs as $key => $def) { |
|
| 1320 | + foreach ($this->field_defs as $key => $def) { |
|
| 1321 | 1321 | |
| 1322 | 1322 | if (isset($def['type'])) { |
| 1323 | - $type=$def['type']; |
|
| 1323 | + $type = $def['type']; |
|
| 1324 | 1324 | } |
| 1325 | - if(isset($def['dbType'])) |
|
| 1325 | + if (isset($def['dbType'])) |
|
| 1326 | 1326 | $type .= $def['dbType']; |
| 1327 | 1327 | |
| 1328 | - if($def['type'] == 'html' || $def['type'] == 'longhtml') { |
|
| 1328 | + if ($def['type'] == 'html' || $def['type'] == 'longhtml') { |
|
| 1329 | 1329 | $this->$key = SugarCleaner::cleanHtml($this->$key, true); |
| 1330 | - } elseif((strpos($type, 'char') !== false || |
|
| 1330 | + } elseif ((strpos($type, 'char') !== false || |
|
| 1331 | 1331 | strpos($type, 'text') !== false || |
| 1332 | 1332 | $type == 'enum') && |
| 1333 | 1333 | !empty($this->$key) |
@@ -1357,24 +1357,24 @@ discard block |
||
| 1357 | 1357 | global $current_user, $action; |
| 1358 | 1358 | |
| 1359 | 1359 | $isUpdate = true; |
| 1360 | - if(empty($this->id)) |
|
| 1360 | + if (empty($this->id)) |
|
| 1361 | 1361 | { |
| 1362 | 1362 | $isUpdate = false; |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - if ( $this->new_with_id == true ) |
|
| 1365 | + if ($this->new_with_id == true) |
|
| 1366 | 1366 | { |
| 1367 | 1367 | $isUpdate = false; |
| 1368 | 1368 | } |
| 1369 | - if(empty($this->date_modified) || $this->update_date_modified) |
|
| 1369 | + if (empty($this->date_modified) || $this->update_date_modified) |
|
| 1370 | 1370 | { |
| 1371 | 1371 | $this->date_modified = $GLOBALS['timedate']->nowDb(); |
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | $this->_checkOptimisticLocking($action, $isUpdate); |
| 1375 | 1375 | |
| 1376 | - if(!empty($this->modified_by_name)) $this->old_modified_by_name = $this->modified_by_name; |
|
| 1377 | - if($this->update_modified_by) |
|
| 1376 | + if (!empty($this->modified_by_name)) $this->old_modified_by_name = $this->modified_by_name; |
|
| 1377 | + if ($this->update_modified_by) |
|
| 1378 | 1378 | { |
| 1379 | 1379 | $this->modified_user_id = 1; |
| 1380 | 1380 | |
@@ -1386,18 +1386,18 @@ discard block |
||
| 1386 | 1386 | } |
| 1387 | 1387 | if ($this->deleted != 1) |
| 1388 | 1388 | $this->deleted = 0; |
| 1389 | - if(!$isUpdate) |
|
| 1389 | + if (!$isUpdate) |
|
| 1390 | 1390 | { |
| 1391 | 1391 | if (empty($this->date_entered)) |
| 1392 | 1392 | { |
| 1393 | 1393 | $this->date_entered = $this->date_modified; |
| 1394 | 1394 | } |
| 1395 | - if($this->set_created_by == true) |
|
| 1395 | + if ($this->set_created_by == true) |
|
| 1396 | 1396 | { |
| 1397 | 1397 | // created by should always be this user |
| 1398 | 1398 | $this->created_by = (isset($current_user)) ? $current_user->id : ""; |
| 1399 | 1399 | } |
| 1400 | - if( $this->new_with_id == false) |
|
| 1400 | + if ($this->new_with_id == false) |
|
| 1401 | 1401 | { |
| 1402 | 1402 | $this->id = create_guid(); |
| 1403 | 1403 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
| 1415 | 1415 | $this->save_relationship_changes($isUpdate); |
| 1416 | 1416 | $GLOBALS['saving_relationships'] = false; |
| 1417 | 1417 | } |
| 1418 | - if($isUpdate && !$this->update_date_entered) |
|
| 1418 | + if ($isUpdate && !$this->update_date_entered) |
|
| 1419 | 1419 | { |
| 1420 | 1420 | unset($this->date_entered); |
| 1421 | 1421 | } |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | $this->emailAddress->save($this->id, $this->module_dir); |
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | - if(isset($this->custom_fields)) |
|
| 1440 | + if (isset($this->custom_fields)) |
|
| 1441 | 1441 | { |
| 1442 | 1442 | $this->custom_fields->bean = $this; |
| 1443 | 1443 | $this->custom_fields->save($isUpdate); |
@@ -1447,12 +1447,12 @@ discard block |
||
| 1447 | 1447 | $this->preprocess_fields_on_save(); |
| 1448 | 1448 | |
| 1449 | 1449 | //construct the SQL to create the audit record if auditing is enabled. |
| 1450 | - $auditDataChanges=array(); |
|
| 1450 | + $auditDataChanges = array(); |
|
| 1451 | 1451 | if ($this->is_AuditEnabled()) { |
| 1452 | 1452 | if ($isUpdate && !isset($this->fetched_row)) { |
| 1453 | 1453 | $GLOBALS['log']->debug('Auditing: Retrieve was not called, audit record will not be created.'); |
| 1454 | 1454 | } else { |
| 1455 | - $auditDataChanges=$this->db->getAuditDataChanges($this); |
|
| 1455 | + $auditDataChanges = $this->db->getAuditDataChanges($this); |
|
| 1456 | 1456 | } |
| 1457 | 1457 | } |
| 1458 | 1458 | |
@@ -1468,12 +1468,12 @@ discard block |
||
| 1468 | 1468 | { |
| 1469 | 1469 | foreach ($auditDataChanges as $change) |
| 1470 | 1470 | { |
| 1471 | - $this->db->save_audit_records($this,$change); |
|
| 1471 | + $this->db->save_audit_records($this, $change); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | |
| 1476 | - if (empty($GLOBALS['resavingRelatedBeans'])){ |
|
| 1476 | + if (empty($GLOBALS['resavingRelatedBeans'])) { |
|
| 1477 | 1477 | SugarRelationship::resaveRelatedBeans(); |
| 1478 | 1478 | } |
| 1479 | 1479 | |
@@ -1485,10 +1485,10 @@ discard block |
||
| 1485 | 1485 | |
| 1486 | 1486 | /* BEGIN - SECURITY GROUPS - inheritance */ |
| 1487 | 1487 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
| 1488 | - SecurityGroup::inherit($this,$isUpdate); |
|
| 1488 | + SecurityGroup::inherit($this, $isUpdate); |
|
| 1489 | 1489 | /* END - SECURITY GROUPS */ |
| 1490 | 1490 | //If we aren't in setup mode and we have a current user and module, then we track |
| 1491 | - if(isset($GLOBALS['current_user']) && isset($this->module_dir)) |
|
| 1491 | + if (isset($GLOBALS['current_user']) && isset($this->module_dir)) |
|
| 1492 | 1492 | { |
| 1493 | 1493 | $this->track_view($current_user->id, $this->module_dir, 'save'); |
| 1494 | 1494 | } |
@@ -1518,7 +1518,7 @@ discard block |
||
| 1518 | 1518 | AND (modified_user_id != '$modified_user_id' OR date_modified > $date)"; |
| 1519 | 1519 | $result = $this->db->query($query); |
| 1520 | 1520 | |
| 1521 | - if($this->db->fetchByAssoc($result)) |
|
| 1521 | + if ($this->db->fetchByAssoc($result)) |
|
| 1522 | 1522 | { |
| 1523 | 1523 | return true; |
| 1524 | 1524 | } |
@@ -1554,11 +1554,11 @@ discard block |
||
| 1554 | 1554 | { |
| 1555 | 1555 | global $current_user; |
| 1556 | 1556 | |
| 1557 | - if(($this->object_name == 'Meeting' || $this->object_name == 'Call') || $notify_user->receive_notifications) |
|
| 1557 | + if (($this->object_name == 'Meeting' || $this->object_name == 'Call') || $notify_user->receive_notifications) |
|
| 1558 | 1558 | { |
| 1559 | 1559 | $sendToEmail = $notify_user->emailAddress->getPrimaryAddress($notify_user); |
| 1560 | 1560 | $sendEmail = TRUE; |
| 1561 | - if(empty($sendToEmail)) { |
|
| 1561 | + if (empty($sendToEmail)) { |
|
| 1562 | 1562 | $GLOBALS['log']->warn("Notifications: no e-mail address set for user {$notify_user->user_name}, cancelling send"); |
| 1563 | 1563 | $sendEmail = FALSE; |
| 1564 | 1564 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
| 1566 | 1566 | $notify_mail = $this->create_notification_email($notify_user); |
| 1567 | 1567 | $notify_mail->setMailerForSystem(); |
| 1568 | 1568 | |
| 1569 | - if(empty($admin->settings['notify_send_from_assigning_user'])) { |
|
| 1569 | + if (empty($admin->settings['notify_send_from_assigning_user'])) { |
|
| 1570 | 1570 | $notify_mail->From = $admin->settings['notify_fromaddress']; |
| 1571 | 1571 | $notify_mail->FromName = (empty($admin->settings['notify_fromname'])) ? "" : $admin->settings['notify_fromname']; |
| 1572 | 1572 | } else { |
@@ -1583,31 +1583,31 @@ discard block |
||
| 1583 | 1583 | $oe = new OutboundEmail(); |
| 1584 | 1584 | $oe = $oe->getUserMailerSettings($current_user); |
| 1585 | 1585 | //only send if smtp server is defined |
| 1586 | - if($sendEmail){ |
|
| 1586 | + if ($sendEmail) { |
|
| 1587 | 1587 | $smtpVerified = false; |
| 1588 | 1588 | |
| 1589 | 1589 | //first check the user settings |
| 1590 | - if(!empty($oe->mail_smtpserver)){ |
|
| 1590 | + if (!empty($oe->mail_smtpserver)) { |
|
| 1591 | 1591 | $smtpVerified = true; |
| 1592 | 1592 | } |
| 1593 | 1593 | |
| 1594 | 1594 | //if still not verified, check against the system settings |
| 1595 | - if (!$smtpVerified){ |
|
| 1595 | + if (!$smtpVerified) { |
|
| 1596 | 1596 | $oe = $oe->getSystemMailerSettings(); |
| 1597 | - if(!empty($oe->mail_smtpserver)){ |
|
| 1597 | + if (!empty($oe->mail_smtpserver)) { |
|
| 1598 | 1598 | $smtpVerified = true; |
| 1599 | 1599 | } |
| 1600 | 1600 | } |
| 1601 | 1601 | //if smtp was not verified against user or system, then do not send out email |
| 1602 | - if (!$smtpVerified){ |
|
| 1602 | + if (!$smtpVerified) { |
|
| 1603 | 1603 | $GLOBALS['log']->fatal("Notifications: error sending e-mail, smtp server was not found "); |
| 1604 | 1604 | //break out |
| 1605 | 1605 | return; |
| 1606 | 1606 | } |
| 1607 | 1607 | |
| 1608 | - if(!$notify_mail->Send()) { |
|
| 1608 | + if (!$notify_mail->Send()) { |
|
| 1609 | 1609 | $GLOBALS['log']->fatal("Notifications: error sending e-mail (method: {$notify_mail->Mailer}), (error: {$notify_mail->ErrorInfo})"); |
| 1610 | - }else{ |
|
| 1610 | + } else { |
|
| 1611 | 1611 | $GLOBALS['log']->info("Notifications: e-mail successfully sent"); |
| 1612 | 1612 | } |
| 1613 | 1613 | } |
@@ -1636,15 +1636,15 @@ discard block |
||
| 1636 | 1636 | $GLOBALS['log']->debug("Notifications: user has e-mail defined"); |
| 1637 | 1637 | |
| 1638 | 1638 | $notify_mail = new SugarPHPMailer(); |
| 1639 | - $notify_mail->AddAddress($notify_address,$locale->translateCharsetMIME(trim($notify_name), 'UTF-8', $OBCharset)); |
|
| 1639 | + $notify_mail->AddAddress($notify_address, $locale->translateCharsetMIME(trim($notify_name), 'UTF-8', $OBCharset)); |
|
| 1640 | 1640 | |
| 1641 | - if(empty($_SESSION['authenticated_user_language'])) { |
|
| 1641 | + if (empty($_SESSION['authenticated_user_language'])) { |
|
| 1642 | 1642 | $current_language = $sugar_config['default_language']; |
| 1643 | 1643 | } else { |
| 1644 | 1644 | $current_language = $_SESSION['authenticated_user_language']; |
| 1645 | 1645 | } |
| 1646 | 1646 | $xtpl = new XTemplate(get_notify_template_file($current_language)); |
| 1647 | - if($this->module_dir == "Cases") { |
|
| 1647 | + if ($this->module_dir == "Cases") { |
|
| 1648 | 1648 | $template_name = "Case"; //we should use Case, you can refer to the en_us.notify_template.html. |
| 1649 | 1649 | } |
| 1650 | 1650 | else { |
@@ -1653,23 +1653,23 @@ discard block |
||
| 1653 | 1653 | |
| 1654 | 1654 | $this->current_notify_user = $notify_user; |
| 1655 | 1655 | |
| 1656 | - if(in_array('set_notification_body', get_class_methods($this))) { |
|
| 1656 | + if (in_array('set_notification_body', get_class_methods($this))) { |
|
| 1657 | 1657 | $xtpl = $this->set_notification_body($xtpl, $this); |
| 1658 | 1658 | } else { |
| 1659 | 1659 | $xtpl->assign("OBJECT", translate('LBL_MODULE_NAME')); |
| 1660 | 1660 | $template_name = "Default"; |
| 1661 | 1661 | } |
| 1662 | - if(!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) { |
|
| 1662 | + if (!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) { |
|
| 1663 | 1663 | $template_name = $beanList[$this->module_dir].'Special'; |
| 1664 | 1664 | } |
| 1665 | - if($this->special_notification) { |
|
| 1665 | + if ($this->special_notification) { |
|
| 1666 | 1666 | $template_name = $beanList[$this->module_dir].'Special'; |
| 1667 | 1667 | } |
| 1668 | 1668 | $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name); |
| 1669 | 1669 | $xtpl->assign("ASSIGNER", $current_user->name); |
| 1670 | 1670 | $port = ''; |
| 1671 | 1671 | |
| 1672 | - if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { |
|
| 1672 | + if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { |
|
| 1673 | 1673 | $port = $_SERVER['SERVER_PORT']; |
| 1674 | 1674 | } |
| 1675 | 1675 | |
@@ -1679,27 +1679,27 @@ discard block |
||
| 1679 | 1679 | |
| 1680 | 1680 | $httpHost = $_SERVER['HTTP_HOST']; |
| 1681 | 1681 | |
| 1682 | - if($colon = strpos($httpHost, ':')) { |
|
| 1683 | - $httpHost = substr($httpHost, 0, $colon); |
|
| 1682 | + if ($colon = strpos($httpHost, ':')) { |
|
| 1683 | + $httpHost = substr($httpHost, 0, $colon); |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | $parsedSiteUrl = parse_url($sugar_config['site_url']); |
| 1687 | 1687 | $host = $parsedSiteUrl['host']; |
| 1688 | - if(!isset($parsedSiteUrl['port'])) { |
|
| 1688 | + if (!isset($parsedSiteUrl['port'])) { |
|
| 1689 | 1689 | $parsedSiteUrl['port'] = 80; |
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | $port = ($parsedSiteUrl['port'] != 80) ? ":".$parsedSiteUrl['port'] : ''; |
| 1693 | 1693 | $path = !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : ""; |
| 1694 | - $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; |
|
| 1694 | + $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; |
|
| 1695 | 1695 | |
| 1696 | 1696 | $xtpl->assign("URL", $cleanUrl."/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); |
| 1697 | 1697 | $xtpl->assign("SUGAR", "Sugar v{$sugar_version}"); |
| 1698 | 1698 | $xtpl->parse($template_name); |
| 1699 | - $xtpl->parse($template_name . "_Subject"); |
|
| 1699 | + $xtpl->parse($template_name."_Subject"); |
|
| 1700 | 1700 | |
| 1701 | 1701 | $notify_mail->Body = from_html(trim($xtpl->text($template_name))); |
| 1702 | - $notify_mail->Subject = from_html($xtpl->text($template_name . "_Subject")); |
|
| 1702 | + $notify_mail->Subject = from_html($xtpl->text($template_name."_Subject")); |
|
| 1703 | 1703 | |
| 1704 | 1704 | // cn: bug 8568 encode notify email in User's outbound email encoding |
| 1705 | 1705 | $notify_mail->prepForOutbound(); |
@@ -1762,7 +1762,7 @@ discard block |
||
| 1762 | 1762 | // $rel_id and $rel_link are not emty - request is from subpanel |
| 1763 | 1763 | // $rel_link contains relationship name - checked by call load_relationship |
| 1764 | 1764 | $isRelationshipLoaded = $this->load_relationship($rel_link); |
| 1765 | - if ($isRelationshipLoaded && !empty($this->$rel_link) && $this->$rel_link->getRelationshipObject() && $this->$rel_link->getRelationshipObject()->getLHSModule() == $this->$rel_link->getRelationshipObject()->getRHSModule() ) |
|
| 1765 | + if ($isRelationshipLoaded && !empty($this->$rel_link) && $this->$rel_link->getRelationshipObject() && $this->$rel_link->getRelationshipObject()->getLHSModule() == $this->$rel_link->getRelationshipObject()->getRHSModule()) |
|
| 1766 | 1766 | { |
| 1767 | 1767 | $new_rel_link = $this->$rel_link->getRelationshipObject()->getLHSLink(); |
| 1768 | 1768 | } |
@@ -1802,14 +1802,14 @@ discard block |
||
| 1802 | 1802 | |
| 1803 | 1803 | if (in_array($id, $exclude)) continue; |
| 1804 | 1804 | |
| 1805 | - if(!empty($this->$id)) |
|
| 1805 | + if (!empty($this->$id)) |
|
| 1806 | 1806 | { |
| 1807 | 1807 | // Bug #44930 We do not need to update main related field if it is changed from sub-panel. |
| 1808 | 1808 | if ($rel_name == $new_rel_link && $this->$id != $new_rel_id) |
| 1809 | 1809 | { |
| 1810 | 1810 | $new_rel_id = ''; |
| 1811 | 1811 | } |
| 1812 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: '.$rel_name . ' = ' . $this->$id); |
|
| 1812 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - adding a relationship record: '.$rel_name.' = '.$this->$id); |
|
| 1813 | 1813 | //already related the new relationship id so let's set it to false so we don't add it again using the _REQUEST['relate_i'] mechanism in a later block |
| 1814 | 1814 | $this->load_relationship($rel_name); |
| 1815 | 1815 | $rel_add = $this->$rel_name->add($this->$id); |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | } else { |
| 1821 | 1821 | //if before value is not empty then attempt to delete relationship |
| 1822 | 1822 | if (!empty($this->rel_fields_before_value[$id])) { |
| 1823 | - $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute' . $rel_name); |
|
| 1823 | + $GLOBALS['log']->debug('save_relationship_changes(): From relationship_field array - attempting to remove the relationship record, using relationship attribute'.$rel_name); |
|
| 1824 | 1824 | $this->load_relationship($rel_name); |
| 1825 | 1825 | $this->$rel_name->delete($this->id, $this->rel_fields_before_value[$id]); |
| 1826 | 1826 | } |
@@ -1863,30 +1863,30 @@ discard block |
||
| 1863 | 1863 | |
| 1864 | 1864 | if (!empty($this->rel_fields_before_value[$idName]) && empty($this->$idName)) { |
| 1865 | 1865 | //if before value is not empty then attempt to delete relationship |
| 1866 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record: {$def [ 'link' ]} = {$this->rel_fields_before_value[$def [ 'id_name' ]]}"); |
|
| 1866 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record: {$def ['link']} = {$this->rel_fields_before_value[$def ['id_name']]}"); |
|
| 1867 | 1867 | $success = $this->$def ['link']->delete($this->id, $this->rel_fields_before_value[$def ['id_name']]); |
| 1868 | 1868 | // just need to make sure it's true and not an array as it's possible to return an array |
| 1869 | - if($success == true) { |
|
| 1869 | + if ($success == true) { |
|
| 1870 | 1870 | $modified_relationships['remove']['success'][] = $def['link']; |
| 1871 | 1871 | } else { |
| 1872 | 1872 | $modified_relationships['remove']['failure'][] = $def['link']; |
| 1873 | 1873 | } |
| 1874 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned " . var_export($success, true)); |
|
| 1874 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to remove the relationship record returned ".var_export($success, true)); |
|
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | if (!empty($this->$idName) && is_string($this->$idName)) { |
| 1878 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def [ 'link' ]} = {$this->$def [ 'id_name' ]}"); |
|
| 1878 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - attempting to add a relationship record - {$def ['link']} = {$this->$def ['id_name']}"); |
|
| 1879 | 1879 | |
| 1880 | 1880 | $success = $this->$linkField->add($this->$idName); |
| 1881 | 1881 | |
| 1882 | 1882 | // just need to make sure it's true and not an array as it's possible to return an array |
| 1883 | - if($success == true) { |
|
| 1883 | + if ($success == true) { |
|
| 1884 | 1884 | $modified_relationships['add']['success'][] = $linkField; |
| 1885 | 1885 | } else { |
| 1886 | 1886 | $modified_relationships['add']['failure'][] = $linkField; |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | - $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned " . var_export($success, true)); |
|
| 1889 | + $GLOBALS['log']->debug("save_relationship_changes(): From field_defs - add a relationship record returned ".var_export($success, true)); |
|
| 1890 | 1890 | } |
| 1891 | 1891 | } else { |
| 1892 | 1892 | $GLOBALS['log']->fatal("Failed to load relationship {$linkField} while saving {$this->module_dir}"); |
@@ -2040,48 +2040,48 @@ discard block |
||
| 2040 | 2040 | global $disable_date_format; |
| 2041 | 2041 | global $timedate; |
| 2042 | 2042 | if (empty($timedate)) |
| 2043 | - $timedate=TimeDate::getInstance(); |
|
| 2043 | + $timedate = TimeDate::getInstance(); |
|
| 2044 | 2044 | |
| 2045 | - if(empty($this->field_defs)) |
|
| 2045 | + if (empty($this->field_defs)) |
|
| 2046 | 2046 | { |
| 2047 | 2047 | return; |
| 2048 | 2048 | } |
| 2049 | - foreach($this->field_defs as $fieldDef) |
|
| 2049 | + foreach ($this->field_defs as $fieldDef) |
|
| 2050 | 2050 | { |
| 2051 | 2051 | $field = $fieldDef['name']; |
| 2052 | - if(!isset($this->processed_dates_times[$field])) |
|
| 2052 | + if (!isset($this->processed_dates_times[$field])) |
|
| 2053 | 2053 | { |
| 2054 | 2054 | $this->processed_dates_times[$field] = '1'; |
| 2055 | - if(empty($this->$field)) continue; |
|
| 2056 | - if($field == 'date_modified' || $field == 'date_entered') |
|
| 2055 | + if (empty($this->$field)) continue; |
|
| 2056 | + if ($field == 'date_modified' || $field == 'date_entered') |
|
| 2057 | 2057 | { |
| 2058 | 2058 | $this->$field = $this->db->fromConvert($this->$field, 'datetime'); |
| 2059 | - if(empty($disable_date_format)) { |
|
| 2059 | + if (empty($disable_date_format)) { |
|
| 2060 | 2060 | $this->$field = $timedate->to_display_date_time($this->$field); |
| 2061 | 2061 | } |
| 2062 | 2062 | } |
| 2063 | - elseif(isset($this->field_name_map[$field]['type'])) |
|
| 2063 | + elseif (isset($this->field_name_map[$field]['type'])) |
|
| 2064 | 2064 | { |
| 2065 | 2065 | $type = $this->field_name_map[$field]['type']; |
| 2066 | 2066 | |
| 2067 | - if($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
| 2067 | + if ($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) |
|
| 2068 | 2068 | { |
| 2069 | 2069 | $type = $this->field_name_map[$field]['type']; |
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | - if($type == 'date') |
|
| 2072 | + if ($type == 'date') |
|
| 2073 | 2073 | { |
| 2074 | - if($this->$field == '0000-00-00') |
|
| 2074 | + if ($this->$field == '0000-00-00') |
|
| 2075 | 2075 | { |
| 2076 | 2076 | $this->$field = ''; |
| 2077 | - } elseif(!empty($this->field_name_map[$field]['rel_field'])) |
|
| 2077 | + } elseif (!empty($this->field_name_map[$field]['rel_field'])) |
|
| 2078 | 2078 | { |
| 2079 | 2079 | $rel_field = $this->field_name_map[$field]['rel_field']; |
| 2080 | 2080 | |
| 2081 | - if(!empty($this->$rel_field)) |
|
| 2081 | + if (!empty($this->$rel_field)) |
|
| 2082 | 2082 | { |
| 2083 | - if(empty($disable_date_format)) { |
|
| 2084 | - $mergetime = $timedate->merge_date_time($this->$field,$this->$rel_field); |
|
| 2083 | + if (empty($disable_date_format)) { |
|
| 2084 | + $mergetime = $timedate->merge_date_time($this->$field, $this->$rel_field); |
|
| 2085 | 2085 | $this->$field = $timedate->to_display_date($mergetime); |
| 2086 | 2086 | $this->$rel_field = $timedate->to_display_time($mergetime); |
| 2087 | 2087 | } |
@@ -2089,36 +2089,36 @@ discard block |
||
| 2089 | 2089 | } |
| 2090 | 2090 | else |
| 2091 | 2091 | { |
| 2092 | - if(empty($disable_date_format)) { |
|
| 2092 | + if (empty($disable_date_format)) { |
|
| 2093 | 2093 | $this->$field = $timedate->to_display_date($this->$field, false); |
| 2094 | 2094 | } |
| 2095 | 2095 | } |
| 2096 | - } elseif($type == 'datetime' || $type == 'datetimecombo') |
|
| 2096 | + } elseif ($type == 'datetime' || $type == 'datetimecombo') |
|
| 2097 | 2097 | { |
| 2098 | - if($this->$field == '0000-00-00 00:00:00') |
|
| 2098 | + if ($this->$field == '0000-00-00 00:00:00') |
|
| 2099 | 2099 | { |
| 2100 | 2100 | $this->$field = ''; |
| 2101 | 2101 | } |
| 2102 | 2102 | else |
| 2103 | 2103 | { |
| 2104 | - if(empty($disable_date_format)) { |
|
| 2104 | + if (empty($disable_date_format)) { |
|
| 2105 | 2105 | $this->$field = $timedate->to_display_date_time($this->$field, true, true); |
| 2106 | 2106 | } |
| 2107 | 2107 | } |
| 2108 | - } elseif($type == 'time') |
|
| 2108 | + } elseif ($type == 'time') |
|
| 2109 | 2109 | { |
| 2110 | - if($this->$field == '00:00:00') |
|
| 2110 | + if ($this->$field == '00:00:00') |
|
| 2111 | 2111 | { |
| 2112 | 2112 | $this->$field = ''; |
| 2113 | 2113 | } else |
| 2114 | 2114 | { |
| 2115 | 2115 | //$this->$field = from_db_convert($this->$field, 'time'); |
| 2116 | - if(empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
| 2116 | + if (empty($this->field_name_map[$field]['rel_field']) && empty($disable_date_format)) |
|
| 2117 | 2117 | { |
| 2118 | - $this->$field = $timedate->to_display_time($this->$field,true, false); |
|
| 2118 | + $this->$field = $timedate->to_display_time($this->$field, true, false); |
|
| 2119 | 2119 | } |
| 2120 | 2120 | } |
| 2121 | - } elseif($type == 'encrypt' && empty($disable_date_format)){ |
|
| 2121 | + } elseif ($type == 'encrypt' && empty($disable_date_format)) { |
|
| 2122 | 2122 | $this->$field = $this->decrypt_after_retrieve($this->$field); |
| 2123 | 2123 | } |
| 2124 | 2124 | } |
@@ -2172,52 +2172,52 @@ discard block |
||
| 2172 | 2172 | static $boolean_false_values = array('off', 'false', '0', 'no'); |
| 2173 | 2173 | |
| 2174 | 2174 | |
| 2175 | - foreach($this->field_defs as $field=>$def) |
|
| 2175 | + foreach ($this->field_defs as $field=>$def) |
|
| 2176 | 2176 | { |
| 2177 | - if ( !isset($this->$field) ) { |
|
| 2177 | + if (!isset($this->$field)) { |
|
| 2178 | 2178 | continue; |
| 2179 | 2179 | } |
| 2180 | - if ( (isset($def['source'])&&$def['source']=='non-db') || $field == 'deleted' ) { |
|
| 2180 | + if ((isset($def['source']) && $def['source'] == 'non-db') || $field == 'deleted') { |
|
| 2181 | 2181 | continue; |
| 2182 | 2182 | } |
| 2183 | - if ( isset($this->fetched_row[$field]) && $this->$field == $this->fetched_row[$field] ) { |
|
| 2183 | + if (isset($this->fetched_row[$field]) && $this->$field == $this->fetched_row[$field]) { |
|
| 2184 | 2184 | // Don't hand out warnings because the field was untouched between retrieval and saving, most database drivers hand pretty much everything back as strings. |
| 2185 | 2185 | continue; |
| 2186 | 2186 | } |
| 2187 | 2187 | $reformatted = false; |
| 2188 | - switch($def['type']) { |
|
| 2188 | + switch ($def['type']) { |
|
| 2189 | 2189 | case 'datetime': |
| 2190 | 2190 | case 'datetimecombo': |
| 2191 | - if(empty($this->$field)) break; |
|
| 2191 | + if (empty($this->$field)) break; |
|
| 2192 | 2192 | if ($this->$field == 'NULL') { |
| 2193 | 2193 | $this->$field = ''; |
| 2194 | 2194 | break; |
| 2195 | 2195 | } |
| 2196 | - if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/',$this->$field) ) { |
|
| 2196 | + if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $this->$field)) { |
|
| 2197 | 2197 | // This appears to be formatted in user date/time |
| 2198 | 2198 | $this->$field = $timedate->to_db($this->$field); |
| 2199 | 2199 | $reformatted = true; |
| 2200 | 2200 | } |
| 2201 | 2201 | break; |
| 2202 | 2202 | case 'date': |
| 2203 | - if(empty($this->$field)) break; |
|
| 2203 | + if (empty($this->$field)) break; |
|
| 2204 | 2204 | if ($this->$field == 'NULL') { |
| 2205 | 2205 | $this->$field = ''; |
| 2206 | 2206 | break; |
| 2207 | 2207 | } |
| 2208 | - if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$this->$field) ) { |
|
| 2208 | + if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $this->$field)) { |
|
| 2209 | 2209 | // This date appears to be formatted in the user's format |
| 2210 | 2210 | $this->$field = $timedate->to_db_date($this->$field, false); |
| 2211 | 2211 | $reformatted = true; |
| 2212 | 2212 | } |
| 2213 | 2213 | break; |
| 2214 | 2214 | case 'time': |
| 2215 | - if(empty($this->$field)) break; |
|
| 2215 | + if (empty($this->$field)) break; |
|
| 2216 | 2216 | if ($this->$field == 'NULL') { |
| 2217 | 2217 | $this->$field = ''; |
| 2218 | 2218 | break; |
| 2219 | 2219 | } |
| 2220 | - if ( preg_match('/(am|pm)/i',$this->$field) ) { |
|
| 2220 | + if (preg_match('/(am|pm)/i', $this->$field)) { |
|
| 2221 | 2221 | // This time appears to be formatted in the user's format |
| 2222 | 2222 | $this->$field = $timedate->fromUserTime($this->$field)->format(TimeDate::DB_TIME_FORMAT); |
| 2223 | 2223 | $reformatted = true; |
@@ -2227,10 +2227,10 @@ discard block |
||
| 2227 | 2227 | case 'decimal': |
| 2228 | 2228 | case 'currency': |
| 2229 | 2229 | case 'float': |
| 2230 | - if ( $this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
| 2230 | + if ($this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
| 2231 | 2231 | continue; |
| 2232 | 2232 | } |
| 2233 | - if ( is_string($this->$field) ) { |
|
| 2233 | + if (is_string($this->$field)) { |
|
| 2234 | 2234 | $this->$field = (float)unformat_number($this->$field); |
| 2235 | 2235 | $reformatted = true; |
| 2236 | 2236 | } |
@@ -2241,10 +2241,10 @@ discard block |
||
| 2241 | 2241 | case 'short': |
| 2242 | 2242 | case 'tinyint': |
| 2243 | 2243 | case 'int': |
| 2244 | - if ( $this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
| 2244 | + if ($this->$field === '' || $this->$field == NULL || $this->$field == 'NULL') { |
|
| 2245 | 2245 | continue; |
| 2246 | 2246 | } |
| 2247 | - if ( is_string($this->$field) ) { |
|
| 2247 | + if (is_string($this->$field)) { |
|
| 2248 | 2248 | $this->$field = (int)unformat_number($this->$field); |
| 2249 | 2249 | $reformatted = true; |
| 2250 | 2250 | } |
@@ -2252,9 +2252,9 @@ discard block |
||
| 2252 | 2252 | case 'bool': |
| 2253 | 2253 | if (empty($this->$field)) { |
| 2254 | 2254 | $this->$field = false; |
| 2255 | - } else if(true === $this->$field || 1 == $this->$field) { |
|
| 2255 | + } else if (true === $this->$field || 1 == $this->$field) { |
|
| 2256 | 2256 | $this->$field = true; |
| 2257 | - } else if(in_array(strval($this->$field), $boolean_false_values)) { |
|
| 2257 | + } else if (in_array(strval($this->$field), $boolean_false_values)) { |
|
| 2258 | 2258 | $this->$field = false; |
| 2259 | 2259 | $reformatted = true; |
| 2260 | 2260 | } else { |
@@ -2266,7 +2266,7 @@ discard block |
||
| 2266 | 2266 | $this->$field = $this->encrpyt_before_save($this->$field); |
| 2267 | 2267 | break; |
| 2268 | 2268 | } |
| 2269 | - if ( $reformatted ) { |
|
| 2269 | + if ($reformatted) { |
|
| 2270 | 2270 | $GLOBALS['log']->deprecated('Formatting correction: '.$this->module_dir.'->'.$field.' had formatting automatically corrected. This will be removed in the future, please upgrade your external code'); |
| 2271 | 2271 | } |
| 2272 | 2272 | } |
@@ -2285,7 +2285,7 @@ discard block |
||
| 2285 | 2285 | * |
| 2286 | 2286 | * Internal function, do not override. |
| 2287 | 2287 | */ |
| 2288 | - function retrieve($id = -1, $encode=true,$deleted=true) |
|
| 2288 | + function retrieve($id = -1, $encode = true, $deleted = true) |
|
| 2289 | 2289 | { |
| 2290 | 2290 | |
| 2291 | 2291 | $custom_logic_arguments['id'] = $id; |
@@ -2297,27 +2297,27 @@ discard block |
||
| 2297 | 2297 | } |
| 2298 | 2298 | $custom_join = $this->getCustomJoin(); |
| 2299 | 2299 | |
| 2300 | - $query = "SELECT $this->table_name.*". $custom_join['select']. " FROM $this->table_name "; |
|
| 2300 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name "; |
|
| 2301 | 2301 | |
| 2302 | 2302 | $query .= $custom_join['join']; |
| 2303 | 2303 | $query .= " WHERE $this->table_name.id = ".$this->db->quoted($id); |
| 2304 | 2304 | if ($deleted) $query .= " AND $this->table_name.deleted=0"; |
| 2305 | 2305 | $GLOBALS['log']->debug("Retrieve $this->object_name : ".$query); |
| 2306 | - $result = $this->db->limitQuery($query,0,1,true, "Retrieving record by id $this->table_name:$id found "); |
|
| 2307 | - if(empty($result)) |
|
| 2306 | + $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record by id $this->table_name:$id found "); |
|
| 2307 | + if (empty($result)) |
|
| 2308 | 2308 | { |
| 2309 | 2309 | return null; |
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | 2312 | $row = $this->db->fetchByAssoc($result, $encode); |
| 2313 | - if(empty($row)) |
|
| 2313 | + if (empty($row)) |
|
| 2314 | 2314 | { |
| 2315 | 2315 | return null; |
| 2316 | 2316 | } |
| 2317 | 2317 | |
| 2318 | 2318 | //make copy of the fetched row for construction of audit record and for business logic/workflow |
| 2319 | 2319 | $row = $this->convertRow($row); |
| 2320 | - $this->fetched_row=$row; |
|
| 2320 | + $this->fetched_row = $row; |
|
| 2321 | 2321 | $this->populateFromRow($row); |
| 2322 | 2322 | |
| 2323 | 2323 | // fix defect #52438. implement the same logic as sugar_currency_format |
@@ -2326,16 +2326,16 @@ discard block |
||
| 2326 | 2326 | |
| 2327 | 2327 | global $module, $action; |
| 2328 | 2328 | //Just to get optimistic locking working for this release |
| 2329 | - if($this->optimistic_lock && $module == $this->module_dir && $action =='EditView' ) |
|
| 2329 | + if ($this->optimistic_lock && $module == $this->module_dir && $action == 'EditView') |
|
| 2330 | 2330 | { |
| 2331 | - $_SESSION['o_lock_id']= $id; |
|
| 2332 | - $_SESSION['o_lock_dm']= $this->date_modified; |
|
| 2331 | + $_SESSION['o_lock_id'] = $id; |
|
| 2332 | + $_SESSION['o_lock_dm'] = $this->date_modified; |
|
| 2333 | 2333 | $_SESSION['o_lock_on'] = $this->object_name; |
| 2334 | 2334 | } |
| 2335 | 2335 | $this->processed_dates_times = array(); |
| 2336 | 2336 | $this->check_date_relationships_load(); |
| 2337 | 2337 | |
| 2338 | - if(isset($this->custom_fields)) |
|
| 2338 | + if (isset($this->custom_fields)) |
|
| 2339 | 2339 | { |
| 2340 | 2340 | $this->custom_fields->fill_relationships(); |
| 2341 | 2341 | } |
@@ -2347,23 +2347,23 @@ discard block |
||
| 2347 | 2347 | foreach ($this->get_related_fields() as $rel_field_name) |
| 2348 | 2348 | { |
| 2349 | 2349 | $field_name = $rel_field_name['name']; |
| 2350 | - if (! empty($this->$field_name)) |
|
| 2350 | + if (!empty($this->$field_name)) |
|
| 2351 | 2351 | { |
| 2352 | 2352 | $this->fetched_rel_row[$rel_field_name['name']] = $this->$field_name; |
| 2353 | 2353 | } |
| 2354 | 2354 | } |
| 2355 | 2355 | //make a copy of fields in the relationship_fields array. These field values will be used to |
| 2356 | 2356 | //clear relationship. |
| 2357 | - foreach ( $this->field_defs as $key => $def ) |
|
| 2357 | + foreach ($this->field_defs as $key => $def) |
|
| 2358 | 2358 | { |
| 2359 | - if (isset($def [ 'type' ]) && $def [ 'type' ] == 'relate' && isset ( $def [ 'id_name'] ) && isset ( $def [ 'link'] ) && isset ( $def[ 'save' ])) { |
|
| 2359 | + if (isset($def ['type']) && $def ['type'] == 'relate' && isset ($def ['id_name']) && isset ($def ['link']) && isset ($def['save'])) { |
|
| 2360 | 2360 | if (isset($this->$key)) { |
| 2361 | - $this->rel_fields_before_value[$key]=$this->$key; |
|
| 2362 | - if (isset($this->$def [ 'id_name'])) |
|
| 2363 | - $this->rel_fields_before_value[$def [ 'id_name']]=$this->$def [ 'id_name']; |
|
| 2361 | + $this->rel_fields_before_value[$key] = $this->$key; |
|
| 2362 | + if (isset($this->$def ['id_name'])) |
|
| 2363 | + $this->rel_fields_before_value[$def ['id_name']] = $this->$def ['id_name']; |
|
| 2364 | 2364 | } |
| 2365 | 2365 | else |
| 2366 | - $this->rel_fields_before_value[$key]=null; |
|
| 2366 | + $this->rel_fields_before_value[$key] = null; |
|
| 2367 | 2367 | } |
| 2368 | 2368 | } |
| 2369 | 2369 | if (isset($this->relationship_fields) && is_array($this->relationship_fields)) |
@@ -2371,9 +2371,9 @@ discard block |
||
| 2371 | 2371 | foreach ($this->relationship_fields as $rel_id=>$rel_name) |
| 2372 | 2372 | { |
| 2373 | 2373 | if (isset($this->$rel_id)) |
| 2374 | - $this->rel_fields_before_value[$rel_id]=$this->$rel_id; |
|
| 2374 | + $this->rel_fields_before_value[$rel_id] = $this->$rel_id; |
|
| 2375 | 2375 | else |
| 2376 | - $this->rel_fields_before_value[$rel_id]=null; |
|
| 2376 | + $this->rel_fields_before_value[$rel_id] = null; |
|
| 2377 | 2377 | } |
| 2378 | 2378 | } |
| 2379 | 2379 | |
@@ -2396,16 +2396,16 @@ discard block |
||
| 2396 | 2396 | */ |
| 2397 | 2397 | function populateFromRow($row) |
| 2398 | 2398 | { |
| 2399 | - $nullvalue=''; |
|
| 2400 | - foreach($this->field_defs as $field=>$field_value) |
|
| 2399 | + $nullvalue = ''; |
|
| 2400 | + foreach ($this->field_defs as $field=>$field_value) |
|
| 2401 | 2401 | { |
| 2402 | - if(($field == 'user_preferences' && $this->module_dir == 'Users') || ($field == 'internal' && $this->module_dir == 'Cases') ) |
|
| 2402 | + if (($field == 'user_preferences' && $this->module_dir == 'Users') || ($field == 'internal' && $this->module_dir == 'Cases')) |
|
| 2403 | 2403 | continue; |
| 2404 | - if(isset($row[$field])) |
|
| 2404 | + if (isset($row[$field])) |
|
| 2405 | 2405 | { |
| 2406 | 2406 | $this->$field = $row[$field]; |
| 2407 | - $owner = $field . '_owner'; |
|
| 2408 | - if(!empty($row[$owner])){ |
|
| 2407 | + $owner = $field.'_owner'; |
|
| 2408 | + if (!empty($row[$owner])) { |
|
| 2409 | 2409 | $this->$owner = $row[$owner]; |
| 2410 | 2410 | } |
| 2411 | 2411 | } |
@@ -2447,48 +2447,48 @@ discard block |
||
| 2447 | 2447 | function create_list_count_query($query) |
| 2448 | 2448 | { |
| 2449 | 2449 | // remove the 'order by' clause which is expected to be at the end of the query |
| 2450 | - $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
| 2450 | + $pattern = '/\sORDER BY.*/is'; // ignores the case |
|
| 2451 | 2451 | $replacement = ''; |
| 2452 | 2452 | $query = preg_replace($pattern, $replacement, $query); |
| 2453 | 2453 | //handle distinct clause |
| 2454 | 2454 | $star = '*'; |
| 2455 | - if(substr_count(strtolower($query), 'distinct')){ |
|
| 2456 | - if (!empty($this->seed) && !empty($this->seed->table_name )) |
|
| 2457 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
| 2455 | + if (substr_count(strtolower($query), 'distinct')) { |
|
| 2456 | + if (!empty($this->seed) && !empty($this->seed->table_name)) |
|
| 2457 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
| 2458 | 2458 | else |
| 2459 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
| 2459 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
| 2460 | 2460 | |
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | // change the select expression to 'count(*)' |
| 2464 | - $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
| 2465 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
| 2464 | + $pattern = '/SELECT(.*?)(\s){1}FROM(\s){1}/is'; // ignores the case |
|
| 2465 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
| 2466 | 2466 | |
| 2467 | 2467 | //if the passed query has union clause then replace all instances of the pattern. |
| 2468 | 2468 | //this is very rare. I have seen this happening only from projects module. |
| 2469 | 2469 | //in addition to this added a condition that has union clause and uses |
| 2470 | 2470 | //sub-selects. |
| 2471 | - if (strstr($query," UNION ALL ") !== false) { |
|
| 2471 | + if (strstr($query, " UNION ALL ") !== false) { |
|
| 2472 | 2472 | |
| 2473 | 2473 | //separate out all the queries. |
| 2474 | - $union_qs=explode(" UNION ALL ", $query); |
|
| 2474 | + $union_qs = explode(" UNION ALL ", $query); |
|
| 2475 | 2475 | foreach ($union_qs as $key=>$union_query) { |
| 2476 | 2476 | $star = '*'; |
| 2477 | 2477 | preg_match($pattern, $union_query, $matches); |
| 2478 | 2478 | if (!empty($matches)) { |
| 2479 | 2479 | if (stristr($matches[0], "distinct")) { |
| 2480 | - if (!empty($this->seed) && !empty($this->seed->table_name )) |
|
| 2481 | - $star = 'DISTINCT ' . $this->seed->table_name . '.id'; |
|
| 2480 | + if (!empty($this->seed) && !empty($this->seed->table_name)) |
|
| 2481 | + $star = 'DISTINCT '.$this->seed->table_name.'.id'; |
|
| 2482 | 2482 | else |
| 2483 | - $star = 'DISTINCT ' . $this->table_name . '.id'; |
|
| 2483 | + $star = 'DISTINCT '.$this->table_name.'.id'; |
|
| 2484 | 2484 | } |
| 2485 | 2485 | } // if |
| 2486 | - $replacement = 'SELECT count(' . $star . ') c FROM '; |
|
| 2487 | - $union_qs[$key] = preg_replace($pattern, $replacement, $union_query,1); |
|
| 2486 | + $replacement = 'SELECT count('.$star.') c FROM '; |
|
| 2487 | + $union_qs[$key] = preg_replace($pattern, $replacement, $union_query, 1); |
|
| 2488 | 2488 | } |
| 2489 | - $modified_select_query=implode(" UNION ALL ",$union_qs); |
|
| 2489 | + $modified_select_query = implode(" UNION ALL ", $union_qs); |
|
| 2490 | 2490 | } else { |
| 2491 | - $modified_select_query = preg_replace($pattern, $replacement, $query,1); |
|
| 2491 | + $modified_select_query = preg_replace($pattern, $replacement, $query, 1); |
|
| 2492 | 2492 | } |
| 2493 | 2493 | |
| 2494 | 2494 | |
@@ -2511,15 +2511,15 @@ discard block |
||
| 2511 | 2511 | * Internal function, do not override. |
| 2512 | 2512 | * |
| 2513 | 2513 | */ |
| 2514 | - function get_list($order_by = "", $where = "", $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $singleSelect=false, $select_fields = array()) |
|
| 2514 | + function get_list($order_by = "", $where = "", $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $singleSelect = false, $select_fields = array()) |
|
| 2515 | 2515 | { |
| 2516 | 2516 | $GLOBALS['log']->debug("get_list: order_by = '$order_by' and where = '$where' and limit = '$limit'"); |
| 2517 | - if(isset($_SESSION['show_deleted'])) |
|
| 2517 | + if (isset($_SESSION['show_deleted'])) |
|
| 2518 | 2518 | { |
| 2519 | 2519 | $show_deleted = 1; |
| 2520 | 2520 | } |
| 2521 | 2521 | |
| 2522 | - if($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list') ) |
|
| 2522 | + if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) |
|
| 2523 | 2523 | { |
| 2524 | 2524 | global $current_user; |
| 2525 | 2525 | $owner_where = $this->getOwnerWhere($current_user->id); |
@@ -2527,15 +2527,15 @@ discard block |
||
| 2527 | 2527 | //rrs - because $this->getOwnerWhere() can return '' we need to be sure to check for it and |
| 2528 | 2528 | //handle it properly else you could get into a situation where you are create a where stmt like |
| 2529 | 2529 | //WHERE .. AND '' |
| 2530 | - if(!empty($owner_where)){ |
|
| 2531 | - if(empty($where)){ |
|
| 2530 | + if (!empty($owner_where)) { |
|
| 2531 | + if (empty($where)) { |
|
| 2532 | 2532 | $where = $owner_where; |
| 2533 | - }else{ |
|
| 2534 | - $where .= ' AND '. $owner_where; |
|
| 2533 | + } else { |
|
| 2534 | + $where .= ' AND '.$owner_where; |
|
| 2535 | 2535 | } |
| 2536 | 2536 | } |
| 2537 | 2537 | } |
| 2538 | - $query = $this->create_new_list_query($order_by, $where,$select_fields,array(), $show_deleted,'',false,null,$singleSelect); |
|
| 2538 | + $query = $this->create_new_list_query($order_by, $where, $select_fields, array(), $show_deleted, '', false, null, $singleSelect); |
|
| 2539 | 2539 | return $this->process_list_query($query, $row_offset, $limit, $max, $where); |
| 2540 | 2540 | } |
| 2541 | 2541 | |
@@ -2581,9 +2581,9 @@ discard block |
||
| 2581 | 2581 | |
| 2582 | 2582 | if (empty($field_defs['table']) && !$suppress_table_name) { |
| 2583 | 2583 | if ($source == 'db') { |
| 2584 | - $list_column[0] = $bean_queried->table_name . '.' . $list_column[0] ; |
|
| 2584 | + $list_column[0] = $bean_queried->table_name.'.'.$list_column[0]; |
|
| 2585 | 2585 | } elseif ($source == 'custom_fields') { |
| 2586 | - $list_column[0] = $bean_queried->table_name . '_cstm.' . $list_column[0] ; |
|
| 2586 | + $list_column[0] = $bean_queried->table_name.'_cstm.'.$list_column[0]; |
|
| 2587 | 2587 | } |
| 2588 | 2588 | } |
| 2589 | 2589 | |
@@ -2637,49 +2637,49 @@ discard block |
||
| 2637 | 2637 | * |
| 2638 | 2638 | * Internal function, do not override. |
| 2639 | 2639 | */ |
| 2640 | - function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
|
| 2640 | + function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0) |
|
| 2641 | 2641 | { |
| 2642 | 2642 | $GLOBALS['log']->debug("get_detail: order_by = '$order_by' and where = '$where' and limit = '$limit' and offset = '$offset'"); |
| 2643 | - if(isset($_SESSION['show_deleted'])) |
|
| 2643 | + if (isset($_SESSION['show_deleted'])) |
|
| 2644 | 2644 | { |
| 2645 | 2645 | $show_deleted = 1; |
| 2646 | 2646 | } |
| 2647 | 2647 | |
| 2648 | - if($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list') ) |
|
| 2648 | + if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) |
|
| 2649 | 2649 | { |
| 2650 | 2650 | global $current_user; |
| 2651 | 2651 | $owner_where = $this->getOwnerWhere($current_user->id); |
| 2652 | 2652 | |
| 2653 | - if(empty($where)) |
|
| 2653 | + if (empty($where)) |
|
| 2654 | 2654 | { |
| 2655 | 2655 | $where = $owner_where; |
| 2656 | 2656 | } |
| 2657 | 2657 | else |
| 2658 | 2658 | { |
| 2659 | - $where .= ' AND '. $owner_where; |
|
| 2659 | + $where .= ' AND '.$owner_where; |
|
| 2660 | 2660 | } |
| 2661 | 2661 | } |
| 2662 | 2662 | |
| 2663 | 2663 | /* BEGIN - SECURITY GROUPS */ |
| 2664 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 2664 | + if ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) |
|
| 2665 | 2665 | { |
| 2666 | 2666 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
| 2667 | 2667 | global $current_user; |
| 2668 | 2668 | $owner_where = $this->getOwnerWhere($current_user->id); |
| 2669 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 2670 | - if(!empty($owner_where)){ |
|
| 2671 | - if(empty($where)) |
|
| 2669 | + $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
|
| 2670 | + if (!empty($owner_where)) { |
|
| 2671 | + if (empty($where)) |
|
| 2672 | 2672 | { |
| 2673 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
| 2673 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
| 2674 | 2674 | } else { |
| 2675 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 2675 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
| 2676 | 2676 | } |
| 2677 | 2677 | } else { |
| 2678 | - $where .= ' AND '. $group_where; |
|
| 2678 | + $where .= ' AND '.$group_where; |
|
| 2679 | 2679 | } |
| 2680 | 2680 | } |
| 2681 | 2681 | /* END - SECURITY GROUPS */ |
| 2682 | - $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted, $offset); |
|
| 2682 | + $query = $this->create_new_list_query($order_by, $where, array(), array(), $show_deleted, $offset); |
|
| 2683 | 2683 | |
| 2684 | 2684 | //Add Limit and Offset to query |
| 2685 | 2685 | //$query .= " LIMIT 1 OFFSET $offset"; |
@@ -2698,13 +2698,13 @@ discard block |
||
| 2698 | 2698 | * |
| 2699 | 2699 | * Internal function, do not override. |
| 2700 | 2700 | */ |
| 2701 | - function get_related_list($child_seed,$related_field_name, $order_by = "", $where = "", |
|
| 2702 | - $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0) |
|
| 2701 | + function get_related_list($child_seed, $related_field_name, $order_by = "", $where = "", |
|
| 2702 | + $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0) |
|
| 2703 | 2703 | { |
| 2704 | 2704 | global $layout_edit_mode; |
| 2705 | 2705 | $query_array = array(); |
| 2706 | 2706 | |
| 2707 | - if(isset($layout_edit_mode) && $layout_edit_mode) |
|
| 2707 | + if (isset($layout_edit_mode) && $layout_edit_mode) |
|
| 2708 | 2708 | { |
| 2709 | 2709 | $response = array(); |
| 2710 | 2710 | $child_seed->assign_display_fields($child_seed->module_dir); |
@@ -2716,7 +2716,7 @@ discard block |
||
| 2716 | 2716 | return $response; |
| 2717 | 2717 | } |
| 2718 | 2718 | $GLOBALS['log']->debug("get_related_list: order_by = '$order_by' and where = '$where' and limit = '$limit'"); |
| 2719 | - if(isset($_SESSION['show_deleted'])) |
|
| 2719 | + if (isset($_SESSION['show_deleted'])) |
|
| 2720 | 2720 | { |
| 2721 | 2721 | $show_deleted = 1; |
| 2722 | 2722 | } |
@@ -2735,22 +2735,22 @@ discard block |
||
| 2735 | 2735 | } |
| 2736 | 2736 | |
| 2737 | 2737 | $entire_where = $query_array['where']; |
| 2738 | - if(!empty($where)) |
|
| 2738 | + if (!empty($where)) |
|
| 2739 | 2739 | { |
| 2740 | - if(empty($entire_where)) |
|
| 2740 | + if (empty($entire_where)) |
|
| 2741 | 2741 | { |
| 2742 | - $entire_where = ' WHERE ' . $where; |
|
| 2742 | + $entire_where = ' WHERE '.$where; |
|
| 2743 | 2743 | } |
| 2744 | 2744 | else |
| 2745 | 2745 | { |
| 2746 | - $entire_where .= ' AND ' . $where; |
|
| 2746 | + $entire_where .= ' AND '.$where; |
|
| 2747 | 2747 | } |
| 2748 | 2748 | } |
| 2749 | 2749 | |
| 2750 | - $query = 'SELECT '.$child_seed->table_name.'.* ' . $query_array['from'] . ' ' . $entire_where; |
|
| 2751 | - if(!empty($order_by)) |
|
| 2750 | + $query = 'SELECT '.$child_seed->table_name.'.* '.$query_array['from'].' '.$entire_where; |
|
| 2751 | + if (!empty($order_by)) |
|
| 2752 | 2752 | { |
| 2753 | - $query .= " ORDER BY " . $order_by; |
|
| 2753 | + $query .= " ORDER BY ".$order_by; |
|
| 2754 | 2754 | } |
| 2755 | 2755 | |
| 2756 | 2756 | return $child_seed->process_list_query($query, $row_offset, $limit, $max, $where); |
@@ -2761,27 +2761,27 @@ discard block |
||
| 2761 | 2761 | { |
| 2762 | 2762 | global $layout_edit_mode, $beanFiles, $beanList; |
| 2763 | 2763 | $subqueries = array(); |
| 2764 | - foreach($subpanel_list as $this_subpanel) |
|
| 2764 | + foreach ($subpanel_list as $this_subpanel) |
|
| 2765 | 2765 | { |
| 2766 | - if(!$this_subpanel->isDatasourceFunction() || ($this_subpanel->isDatasourceFunction() |
|
| 2766 | + if (!$this_subpanel->isDatasourceFunction() || ($this_subpanel->isDatasourceFunction() |
|
| 2767 | 2767 | && isset($this_subpanel->_instance_properties['generate_select']) |
| 2768 | - && $this_subpanel->_instance_properties['generate_select']==true)) |
|
| 2768 | + && $this_subpanel->_instance_properties['generate_select'] == true)) |
|
| 2769 | 2769 | { |
| 2770 | 2770 | //the custom query function must return an array with |
| 2771 | 2771 | if ($this_subpanel->isDatasourceFunction()) { |
| 2772 | 2772 | $shortcut_function_name = $this_subpanel->get_data_source_name(); |
| 2773 | - $parameters=$this_subpanel->get_function_parameters(); |
|
| 2773 | + $parameters = $this_subpanel->get_function_parameters(); |
|
| 2774 | 2774 | if (!empty($parameters)) |
| 2775 | 2775 | { |
| 2776 | 2776 | //if the import file function is set, then import the file to call the custom function from |
| 2777 | - if (is_array($parameters) && isset($parameters['import_function_file'])){ |
|
| 2777 | + if (is_array($parameters) && isset($parameters['import_function_file'])) { |
|
| 2778 | 2778 | //this call may happen multiple times, so only require if function does not exist |
| 2779 | - if(!function_exists($shortcut_function_name)){ |
|
| 2779 | + if (!function_exists($shortcut_function_name)) { |
|
| 2780 | 2780 | require_once($parameters['import_function_file']); |
| 2781 | 2781 | } |
| 2782 | 2782 | //call function from required file |
| 2783 | 2783 | $query_array = $shortcut_function_name($parameters); |
| 2784 | - }else{ |
|
| 2784 | + } else { |
|
| 2785 | 2785 | //call function from parent bean |
| 2786 | 2786 | $query_array = $parentbean->$shortcut_function_name($parameters); |
| 2787 | 2787 | } |
@@ -2790,9 +2790,9 @@ discard block |
||
| 2790 | 2790 | { |
| 2791 | 2791 | $query_array = $parentbean->$shortcut_function_name(); |
| 2792 | 2792 | } |
| 2793 | - } else { |
|
| 2793 | + } else { |
|
| 2794 | 2794 | $related_field_name = $this_subpanel->get_data_source_name(); |
| 2795 | - if (!$parentbean->load_relationship($related_field_name)){ |
|
| 2795 | + if (!$parentbean->load_relationship($related_field_name)) { |
|
| 2796 | 2796 | unset ($parentbean->$related_field_name); |
| 2797 | 2797 | continue; |
| 2798 | 2798 | } |
@@ -2801,15 +2801,15 @@ discard block |
||
| 2801 | 2801 | $table_where = preg_replace('/^\s*WHERE/i', '', $this_subpanel->get_where()); |
| 2802 | 2802 | $where_definition = preg_replace('/^\s*WHERE/i', '', $query_array['where']); |
| 2803 | 2803 | |
| 2804 | - if(!empty($table_where)) |
|
| 2804 | + if (!empty($table_where)) |
|
| 2805 | 2805 | { |
| 2806 | - if(empty($where_definition)) |
|
| 2806 | + if (empty($where_definition)) |
|
| 2807 | 2807 | { |
| 2808 | 2808 | $where_definition = $table_where; |
| 2809 | 2809 | } |
| 2810 | 2810 | else |
| 2811 | 2811 | { |
| 2812 | - $where_definition .= ' AND ' . $table_where; |
|
| 2812 | + $where_definition .= ' AND '.$table_where; |
|
| 2813 | 2813 | } |
| 2814 | 2814 | } |
| 2815 | 2815 | |
@@ -2824,21 +2824,21 @@ discard block |
||
| 2824 | 2824 | |
| 2825 | 2825 | |
| 2826 | 2826 | $list_fields = $this_subpanel->get_list_fields(); |
| 2827 | - foreach($list_fields as $list_key=>$list_field) |
|
| 2827 | + foreach ($list_fields as $list_key=>$list_field) |
|
| 2828 | 2828 | { |
| 2829 | - if(isset($list_field['usage']) && $list_field['usage'] == 'display_only') |
|
| 2829 | + if (isset($list_field['usage']) && $list_field['usage'] == 'display_only') |
|
| 2830 | 2830 | { |
| 2831 | 2831 | unset($list_fields[$list_key]); |
| 2832 | 2832 | } |
| 2833 | 2833 | } |
| 2834 | 2834 | |
| 2835 | 2835 | |
| 2836 | - if(!$subpanel_def->isCollection() && isset($list_fields[$order_by]) && isset($submodule->field_defs[$order_by])&& (!isset($submodule->field_defs[$order_by]['source']) || $submodule->field_defs[$order_by]['source'] == 'db')) |
|
| 2836 | + if (!$subpanel_def->isCollection() && isset($list_fields[$order_by]) && isset($submodule->field_defs[$order_by]) && (!isset($submodule->field_defs[$order_by]['source']) || $submodule->field_defs[$order_by]['source'] == 'db')) |
|
| 2837 | 2837 | { |
| 2838 | - $order_by = $submodule->table_name .'.'. $order_by; |
|
| 2838 | + $order_by = $submodule->table_name.'.'.$order_by; |
|
| 2839 | 2839 | } |
| 2840 | 2840 | $table_name = $this_subpanel->table_name; |
| 2841 | - $panel_name=$this_subpanel->name; |
|
| 2841 | + $panel_name = $this_subpanel->name; |
|
| 2842 | 2842 | $params = array(); |
| 2843 | 2843 | $params['distinct'] = $this_subpanel->distinct_query(); |
| 2844 | 2844 | |
@@ -2849,7 +2849,7 @@ discard block |
||
| 2849 | 2849 | // use single select in case when sorting by relate field |
| 2850 | 2850 | $singleSelect = $submodule->is_relate_field($order_by); |
| 2851 | 2851 | |
| 2852 | - $subquery = $submodule->create_new_list_query('',$subwhere ,$list_fields,$params, 0,'', true,$parentbean, $singleSelect); |
|
| 2852 | + $subquery = $submodule->create_new_list_query('', $subwhere, $list_fields, $params, 0, '', true, $parentbean, $singleSelect); |
|
| 2853 | 2853 | |
| 2854 | 2854 | $subquery['select'] = $subquery['select']." , '$panel_name' panel_name "; |
| 2855 | 2855 | $subquery['from'] = $subquery['from'].$query_array['join']; |
@@ -2881,27 +2881,27 @@ discard block |
||
| 2881 | 2881 | * |
| 2882 | 2882 | * Internal Function, do not overide. |
| 2883 | 2883 | */ |
| 2884 | - static function get_union_related_list($parentbean, $order_by = "", $sort_order='', $where = "", |
|
| 2885 | - $row_offset = 0, $limit=-1, $max=-1, $show_deleted = 0, $subpanel_def) |
|
| 2884 | + static function get_union_related_list($parentbean, $order_by = "", $sort_order = '', $where = "", |
|
| 2885 | + $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $subpanel_def) |
|
| 2886 | 2886 | { |
| 2887 | 2887 | $secondary_queries = array(); |
| 2888 | 2888 | global $layout_edit_mode, $beanFiles, $beanList; |
| 2889 | 2889 | |
| 2890 | - if(isset($_SESSION['show_deleted'])) |
|
| 2890 | + if (isset($_SESSION['show_deleted'])) |
|
| 2891 | 2891 | { |
| 2892 | 2892 | $show_deleted = 1; |
| 2893 | 2893 | } |
| 2894 | 2894 | $final_query = ''; |
| 2895 | 2895 | $final_query_rows = ''; |
| 2896 | - $subpanel_list=array(); |
|
| 2896 | + $subpanel_list = array(); |
|
| 2897 | 2897 | if ($subpanel_def->isCollection()) |
| 2898 | 2898 | { |
| 2899 | 2899 | $subpanel_def->load_sub_subpanels(); |
| 2900 | - $subpanel_list=$subpanel_def->sub_subpanels; |
|
| 2900 | + $subpanel_list = $subpanel_def->sub_subpanels; |
|
| 2901 | 2901 | } |
| 2902 | 2902 | else |
| 2903 | 2903 | { |
| 2904 | - $subpanel_list[]=$subpanel_def; |
|
| 2904 | + $subpanel_list[] = $subpanel_def; |
|
| 2905 | 2905 | } |
| 2906 | 2906 | |
| 2907 | 2907 | $first = true; |
@@ -2910,36 +2910,36 @@ discard block |
||
| 2910 | 2910 | //The second loop merges the queries and forces them to select the same number of columns |
| 2911 | 2911 | //All columns in a sub-subpanel group must have the same aliases |
| 2912 | 2912 | //If the subpanel is a datasource function, it can't be a collection so we just poll that function for the and return that |
| 2913 | - foreach($subpanel_list as $this_subpanel) |
|
| 2913 | + foreach ($subpanel_list as $this_subpanel) |
|
| 2914 | 2914 | { |
| 2915 | - if($this_subpanel->isDatasourceFunction() && empty($this_subpanel->_instance_properties['generate_select'])) |
|
| 2915 | + if ($this_subpanel->isDatasourceFunction() && empty($this_subpanel->_instance_properties['generate_select'])) |
|
| 2916 | 2916 | { |
| 2917 | 2917 | $shortcut_function_name = $this_subpanel->get_data_source_name(); |
| 2918 | - $parameters=$this_subpanel->get_function_parameters(); |
|
| 2918 | + $parameters = $this_subpanel->get_function_parameters(); |
|
| 2919 | 2919 | if (!empty($parameters)) |
| 2920 | 2920 | { |
| 2921 | 2921 | //if the import file function is set, then import the file to call the custom function from |
| 2922 | - if (is_array($parameters) && isset($parameters['import_function_file'])){ |
|
| 2922 | + if (is_array($parameters) && isset($parameters['import_function_file'])) { |
|
| 2923 | 2923 | //this call may happen multiple times, so only require if function does not exist |
| 2924 | - if(!function_exists($shortcut_function_name)){ |
|
| 2924 | + if (!function_exists($shortcut_function_name)) { |
|
| 2925 | 2925 | require_once($parameters['import_function_file']); |
| 2926 | 2926 | } |
| 2927 | 2927 | //call function from required file |
| 2928 | - $tmp_final_query = $shortcut_function_name($parameters); |
|
| 2929 | - }else{ |
|
| 2928 | + $tmp_final_query = $shortcut_function_name($parameters); |
|
| 2929 | + } else { |
|
| 2930 | 2930 | //call function from parent bean |
| 2931 | - $tmp_final_query = $parentbean->$shortcut_function_name($parameters); |
|
| 2931 | + $tmp_final_query = $parentbean->$shortcut_function_name($parameters); |
|
| 2932 | 2932 | } |
| 2933 | 2933 | } else { |
| 2934 | 2934 | $tmp_final_query = $parentbean->$shortcut_function_name(); |
| 2935 | 2935 | } |
| 2936 | - if(!$first) |
|
| 2936 | + if (!$first) |
|
| 2937 | 2937 | { |
| 2938 | - $final_query_rows .= ' UNION ALL ( '.$parentbean->create_list_count_query($tmp_final_query, $parameters) . ' )'; |
|
| 2939 | - $final_query .= ' UNION ALL ( '.$tmp_final_query . ' )'; |
|
| 2938 | + $final_query_rows .= ' UNION ALL ( '.$parentbean->create_list_count_query($tmp_final_query, $parameters).' )'; |
|
| 2939 | + $final_query .= ' UNION ALL ( '.$tmp_final_query.' )'; |
|
| 2940 | 2940 | } else { |
| 2941 | - $final_query_rows = '(' . $parentbean->create_list_count_query($tmp_final_query, $parameters) . ')'; |
|
| 2942 | - $final_query = '(' . $tmp_final_query . ')'; |
|
| 2941 | + $final_query_rows = '('.$parentbean->create_list_count_query($tmp_final_query, $parameters).')'; |
|
| 2942 | + $final_query = '('.$tmp_final_query.')'; |
|
| 2943 | 2943 | $first = false; |
| 2944 | 2944 | } |
| 2945 | 2945 | } |
@@ -2949,10 +2949,10 @@ discard block |
||
| 2949 | 2949 | { |
| 2950 | 2950 | $subqueries = SugarBean::build_sub_queries_for_union($subpanel_list, $subpanel_def, $parentbean, $order_by); |
| 2951 | 2951 | $all_fields = array(); |
| 2952 | - foreach($subqueries as $i => $subquery) |
|
| 2952 | + foreach ($subqueries as $i => $subquery) |
|
| 2953 | 2953 | { |
| 2954 | 2954 | $query_fields = $GLOBALS['db']->getSelectFieldsFromQuery($subquery['select']); |
| 2955 | - foreach($query_fields as $field => $select) |
|
| 2955 | + foreach ($query_fields as $field => $select) |
|
| 2956 | 2956 | { |
| 2957 | 2957 | if (!in_array($field, $all_fields)) |
| 2958 | 2958 | $all_fields[] = $field; |
@@ -2961,10 +2961,10 @@ discard block |
||
| 2961 | 2961 | } |
| 2962 | 2962 | $first = true; |
| 2963 | 2963 | //Now ensure the queries have the same set of fields in the same order. |
| 2964 | - foreach($subqueries as $subquery) |
|
| 2964 | + foreach ($subqueries as $subquery) |
|
| 2965 | 2965 | { |
| 2966 | 2966 | $subquery['select'] = "SELECT"; |
| 2967 | - foreach($all_fields as $field) |
|
| 2967 | + foreach ($all_fields as $field) |
|
| 2968 | 2968 | { |
| 2969 | 2969 | if (!isset($subquery['query_fields'][$field])) |
| 2970 | 2970 | { |
@@ -2975,56 +2975,56 @@ discard block |
||
| 2975 | 2975 | $subquery['select'] .= " {$subquery['query_fields'][$field]},"; |
| 2976 | 2976 | } |
| 2977 | 2977 | } |
| 2978 | - $subquery['select'] = substr($subquery['select'], 0 , strlen($subquery['select']) - 1); |
|
| 2978 | + $subquery['select'] = substr($subquery['select'], 0, strlen($subquery['select']) - 1); |
|
| 2979 | 2979 | //Put the query into the final_query |
| 2980 | - $query = $subquery['select'] . " " . $subquery['from'] . " " . $subquery['where']; |
|
| 2981 | - if(!$first) |
|
| 2980 | + $query = $subquery['select']." ".$subquery['from']." ".$subquery['where']; |
|
| 2981 | + if (!$first) |
|
| 2982 | 2982 | { |
| 2983 | - $query = ' UNION ALL ( '.$query . ' )'; |
|
| 2983 | + $query = ' UNION ALL ( '.$query.' )'; |
|
| 2984 | 2984 | $final_query_rows .= " UNION ALL "; |
| 2985 | 2985 | } else { |
| 2986 | - $query = '(' . $query . ')'; |
|
| 2986 | + $query = '('.$query.')'; |
|
| 2987 | 2987 | $first = false; |
| 2988 | 2988 | } |
| 2989 | 2989 | $query_array = $subquery['query_array']; |
| 2990 | - $select_position=strpos($query_array['select'],"SELECT"); |
|
| 2991 | - $distinct_position=strpos($query_array['select'],"DISTINCT"); |
|
| 2990 | + $select_position = strpos($query_array['select'], "SELECT"); |
|
| 2991 | + $distinct_position = strpos($query_array['select'], "DISTINCT"); |
|
| 2992 | 2992 | if (!empty($subquery['params']['distinct']) && !empty($subpanel_def->table_name)) |
| 2993 | 2993 | { |
| 2994 | - $query_rows = "( SELECT count(DISTINCT ". $subpanel_def->table_name . ".id)". $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
|
| 2994 | + $query_rows = "( SELECT count(DISTINCT ".$subpanel_def->table_name.".id)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
| 2995 | 2995 | } |
| 2996 | - elseif ($select_position !== false && $distinct_position!= false) |
|
| 2996 | + elseif ($select_position !== false && $distinct_position != false) |
|
| 2997 | 2997 | { |
| 2998 | - $query_rows = "( ".substr_replace($query_array['select'],"SELECT count(",$select_position,6). ")" . $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
|
| 2998 | + $query_rows = "( ".substr_replace($query_array['select'], "SELECT count(", $select_position, 6).")".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
| 2999 | 2999 | } |
| 3000 | 3000 | else |
| 3001 | 3001 | { |
| 3002 | 3002 | //resort to default behavior. |
| 3003 | - $query_rows = "( SELECT count(*)". $subquery['from_min'].$query_array['join']. $subquery['where'].' )'; |
|
| 3003 | + $query_rows = "( SELECT count(*)".$subquery['from_min'].$query_array['join'].$subquery['where'].' )'; |
|
| 3004 | 3004 | } |
| 3005 | - if(!empty($subquery['secondary_select'])) |
|
| 3005 | + if (!empty($subquery['secondary_select'])) |
|
| 3006 | 3006 | { |
| 3007 | 3007 | |
| 3008 | - $subquerystring= $subquery['secondary_select'] . $subquery['secondary_from'].$query_array['join']. $subquery['where']; |
|
| 3008 | + $subquerystring = $subquery['secondary_select'].$subquery['secondary_from'].$query_array['join'].$subquery['where']; |
|
| 3009 | 3009 | if (!empty($subquery['secondary_where'])) |
| 3010 | 3010 | { |
| 3011 | 3011 | if (empty($subquery['where'])) |
| 3012 | 3012 | { |
| 3013 | - $subquerystring.=" WHERE " .$subquery['secondary_where']; |
|
| 3013 | + $subquerystring .= " WHERE ".$subquery['secondary_where']; |
|
| 3014 | 3014 | } |
| 3015 | 3015 | else |
| 3016 | 3016 | { |
| 3017 | - $subquerystring.=" AND " .$subquery['secondary_where']; |
|
| 3017 | + $subquerystring .= " AND ".$subquery['secondary_where']; |
|
| 3018 | 3018 | } |
| 3019 | 3019 | } |
| 3020 | - $secondary_queries[]=$subquerystring; |
|
| 3020 | + $secondary_queries[] = $subquerystring; |
|
| 3021 | 3021 | } |
| 3022 | 3022 | $final_query .= $query; |
| 3023 | 3023 | $final_query_rows .= $query_rows; |
| 3024 | 3024 | } |
| 3025 | 3025 | } |
| 3026 | 3026 | |
| 3027 | - if(!empty($order_by)) |
|
| 3027 | + if (!empty($order_by)) |
|
| 3028 | 3028 | { |
| 3029 | 3029 | $isCollection = $subpanel_def->isCollection(); |
| 3030 | 3030 | if ($isCollection) { |
@@ -3038,20 +3038,20 @@ discard block |
||
| 3038 | 3038 | } |
| 3039 | 3039 | |
| 3040 | 3040 | if (!empty($sort_order)) { |
| 3041 | - $order_by .= ' ' . $sort_order; |
|
| 3041 | + $order_by .= ' '.$sort_order; |
|
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | 3044 | $order_by = $parentbean->process_order_by($order_by, $submodule, $suppress_table_name); |
| 3045 | 3045 | if (!empty($order_by)) { |
| 3046 | - $final_query .= ' ORDER BY ' . $order_by; |
|
| 3046 | + $final_query .= ' ORDER BY '.$order_by; |
|
| 3047 | 3047 | } |
| 3048 | 3048 | } |
| 3049 | 3049 | |
| 3050 | 3050 | |
| 3051 | - if(isset($layout_edit_mode) && $layout_edit_mode) |
|
| 3051 | + if (isset($layout_edit_mode) && $layout_edit_mode) |
|
| 3052 | 3052 | { |
| 3053 | 3053 | $response = array(); |
| 3054 | - if(!empty($submodule)) |
|
| 3054 | + if (!empty($submodule)) |
|
| 3055 | 3055 | { |
| 3056 | 3056 | $submodule->assign_display_fields($submodule->module_dir); |
| 3057 | 3057 | $response['list'] = array($submodule); |
@@ -3068,7 +3068,7 @@ discard block |
||
| 3068 | 3068 | return $response; |
| 3069 | 3069 | } |
| 3070 | 3070 | |
| 3071 | - return $parentbean->process_union_list_query($parentbean, $final_query, $row_offset, $limit, $max, '',$subpanel_def, $final_query_rows, $secondary_queries); |
|
| 3071 | + return $parentbean->process_union_list_query($parentbean, $final_query, $row_offset, $limit, $max, '', $subpanel_def, $final_query_rows, $secondary_queries); |
|
| 3072 | 3072 | } |
| 3073 | 3073 | |
| 3074 | 3074 | |
@@ -3080,14 +3080,14 @@ discard block |
||
| 3080 | 3080 | * @param boolean $check_dates. defaults to false |
| 3081 | 3081 | * @param int $show_deleted show deleted records. defaults to 0 |
| 3082 | 3082 | */ |
| 3083 | - function get_full_list($order_by = "", $where = "", $check_dates=false, $show_deleted = 0) |
|
| 3083 | + function get_full_list($order_by = "", $where = "", $check_dates = false, $show_deleted = 0) |
|
| 3084 | 3084 | { |
| 3085 | 3085 | $GLOBALS['log']->debug("get_full_list: order_by = '$order_by' and where = '$where'"); |
| 3086 | - if(isset($_SESSION['show_deleted'])) |
|
| 3086 | + if (isset($_SESSION['show_deleted'])) |
|
| 3087 | 3087 | { |
| 3088 | 3088 | $show_deleted = 1; |
| 3089 | 3089 | } |
| 3090 | - $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted); |
|
| 3090 | + $query = $this->create_new_list_query($order_by, $where, array(), array(), $show_deleted); |
|
| 3091 | 3091 | return $this->process_full_list_query($query, $check_dates); |
| 3092 | 3092 | } |
| 3093 | 3093 | |
@@ -3107,29 +3107,29 @@ discard block |
||
| 3107 | 3107 | * @param boolean $singleSelect Optional, default false. |
| 3108 | 3108 | * @return String select query string, optionally an array value will be returned if $return_array= true. |
| 3109 | 3109 | */ |
| 3110 | - function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean=null, $singleSelect = false, $ifListForExport = false) |
|
| 3110 | + function create_new_list_query($order_by, $where, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $parentbean = null, $singleSelect = false, $ifListForExport = false) |
|
| 3111 | 3111 | { |
| 3112 | 3112 | global $beanFiles, $beanList; |
| 3113 | 3113 | $selectedFields = array(); |
| 3114 | 3114 | $secondarySelectedFields = array(); |
| 3115 | 3115 | $ret_array = array(); |
| 3116 | 3116 | $distinct = ''; |
| 3117 | - if($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list') ) |
|
| 3117 | + if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) |
|
| 3118 | 3118 | { |
| 3119 | 3119 | global $current_user; |
| 3120 | 3120 | $owner_where = $this->getOwnerWhere($current_user->id); |
| 3121 | - if(empty($where)) |
|
| 3121 | + if (empty($where)) |
|
| 3122 | 3122 | { |
| 3123 | 3123 | $where = $owner_where; |
| 3124 | 3124 | } |
| 3125 | 3125 | else |
| 3126 | 3126 | { |
| 3127 | - $where .= ' AND '. $owner_where; |
|
| 3127 | + $where .= ' AND '.$owner_where; |
|
| 3128 | 3128 | } |
| 3129 | 3129 | } |
| 3130 | 3130 | /* BEGIN - SECURITY GROUPS */ |
| 3131 | 3131 | global $current_user, $sugar_config; |
| 3132 | - if($this->module_dir == 'Users' && !is_admin($current_user) |
|
| 3132 | + if ($this->module_dir == 'Users' && !is_admin($current_user) |
|
| 3133 | 3133 | && isset($sugar_config['securitysuite_filter_user_list']) |
| 3134 | 3134 | && $sugar_config['securitysuite_filter_user_list'] == true |
| 3135 | 3135 | ) { |
@@ -3137,36 +3137,36 @@ discard block |
||
| 3137 | 3137 | global $current_user; |
| 3138 | 3138 | $group_where = SecurityGroup::getGroupUsersWhere($current_user->id); |
| 3139 | 3139 | //$group_where = "user_name = 'admin'"; |
| 3140 | - if(empty($where)) |
|
| 3140 | + if (empty($where)) |
|
| 3141 | 3141 | { |
| 3142 | 3142 | $where = " (".$group_where.") "; |
| 3143 | 3143 | } else { |
| 3144 | 3144 | $where .= " AND (".$group_where.") "; |
| 3145 | 3145 | } |
| 3146 | 3146 | } else |
| 3147 | - if($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list') ) |
|
| 3147 | + if ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) |
|
| 3148 | 3148 | { |
| 3149 | 3149 | require_once('modules/SecurityGroups/SecurityGroup.php'); |
| 3150 | 3150 | global $current_user; |
| 3151 | 3151 | $owner_where = $this->getOwnerWhere($current_user->id); |
| 3152 | - $group_where = SecurityGroup::getGroupWhere($this->table_name,$this->module_dir,$current_user->id); |
|
| 3153 | - if(!empty($owner_where)){ |
|
| 3154 | - if(empty($where)) |
|
| 3152 | + $group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id); |
|
| 3153 | + if (!empty($owner_where)) { |
|
| 3154 | + if (empty($where)) |
|
| 3155 | 3155 | { |
| 3156 | - $where = " (". $owner_where." or ".$group_where.") "; |
|
| 3156 | + $where = " (".$owner_where." or ".$group_where.") "; |
|
| 3157 | 3157 | } else { |
| 3158 | - $where .= " AND (". $owner_where." or ".$group_where.") "; |
|
| 3158 | + $where .= " AND (".$owner_where." or ".$group_where.") "; |
|
| 3159 | 3159 | } |
| 3160 | 3160 | } else { |
| 3161 | - $where .= ' AND '. $group_where; |
|
| 3161 | + $where .= ' AND '.$group_where; |
|
| 3162 | 3162 | } |
| 3163 | 3163 | } |
| 3164 | 3164 | /* END - SECURITY GROUPS */ |
| 3165 | - if(!empty($params['distinct'])) |
|
| 3165 | + if (!empty($params['distinct'])) |
|
| 3166 | 3166 | { |
| 3167 | 3167 | $distinct = ' DISTINCT '; |
| 3168 | 3168 | } |
| 3169 | - if(empty($filter)) |
|
| 3169 | + if (empty($filter)) |
|
| 3170 | 3170 | { |
| 3171 | 3171 | $ret_array['select'] = " SELECT $distinct $this->table_name.* "; |
| 3172 | 3172 | } |
@@ -3176,21 +3176,21 @@ discard block |
||
| 3176 | 3176 | } |
| 3177 | 3177 | $ret_array['from'] = " FROM $this->table_name "; |
| 3178 | 3178 | $ret_array['from_min'] = $ret_array['from']; |
| 3179 | - $ret_array['secondary_from'] = $ret_array['from'] ; |
|
| 3179 | + $ret_array['secondary_from'] = $ret_array['from']; |
|
| 3180 | 3180 | $ret_array['where'] = ''; |
| 3181 | 3181 | $ret_array['order_by'] = ''; |
| 3182 | 3182 | //secondary selects are selects that need to be run after the primary query to retrieve additional info on main |
| 3183 | - if($singleSelect) |
|
| 3183 | + if ($singleSelect) |
|
| 3184 | 3184 | { |
| 3185 | - $ret_array['secondary_select']=& $ret_array['select']; |
|
| 3185 | + $ret_array['secondary_select'] = & $ret_array['select']; |
|
| 3186 | 3186 | $ret_array['secondary_from'] = & $ret_array['from']; |
| 3187 | 3187 | } |
| 3188 | 3188 | else |
| 3189 | 3189 | { |
| 3190 | 3190 | $ret_array['secondary_select'] = ''; |
| 3191 | 3191 | } |
| 3192 | - $custom_join = $this->getCustomJoin( empty($filter)? true: $filter ); |
|
| 3193 | - if((!isset($params['include_custom_fields']) || $params['include_custom_fields'])) |
|
| 3192 | + $custom_join = $this->getCustomJoin(empty($filter) ? true : $filter); |
|
| 3193 | + if ((!isset($params['include_custom_fields']) || $params['include_custom_fields'])) |
|
| 3194 | 3194 | { |
| 3195 | 3195 | $ret_array['select'] .= $custom_join['select']; |
| 3196 | 3196 | } |
@@ -3206,43 +3206,43 @@ discard block |
||
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | $joined_tables = array(); |
| 3209 | - if(!empty($params['joined_tables'])) |
|
| 3209 | + if (!empty($params['joined_tables'])) |
|
| 3210 | 3210 | { |
| 3211 | - foreach($params['joined_tables'] as $table) |
|
| 3211 | + foreach ($params['joined_tables'] as $table) |
|
| 3212 | 3212 | { |
| 3213 | 3213 | $joined_tables[$table] = 1; |
| 3214 | 3214 | } |
| 3215 | 3215 | } |
| 3216 | 3216 | |
| 3217 | - if(!empty($filter)) |
|
| 3217 | + if (!empty($filter)) |
|
| 3218 | 3218 | { |
| 3219 | 3219 | $filterKeys = array_keys($filter); |
| 3220 | - if(is_numeric($filterKeys[0])) |
|
| 3220 | + if (is_numeric($filterKeys[0])) |
|
| 3221 | 3221 | { |
| 3222 | 3222 | $fields = array(); |
| 3223 | - foreach($filter as $field) |
|
| 3223 | + foreach ($filter as $field) |
|
| 3224 | 3224 | { |
| 3225 | 3225 | $field = strtolower($field); |
| 3226 | 3226 | //remove out id field so we don't duplicate it |
| 3227 | - if ( $field == 'id' && !empty($filter) ) { |
|
| 3227 | + if ($field == 'id' && !empty($filter)) { |
|
| 3228 | 3228 | continue; |
| 3229 | 3229 | } |
| 3230 | - if(isset($this->field_defs[$field])) |
|
| 3230 | + if (isset($this->field_defs[$field])) |
|
| 3231 | 3231 | { |
| 3232 | - $fields[$field]= $this->field_defs[$field]; |
|
| 3232 | + $fields[$field] = $this->field_defs[$field]; |
|
| 3233 | 3233 | } |
| 3234 | 3234 | else |
| 3235 | 3235 | { |
| 3236 | 3236 | $fields[$field] = array('force_exists'=>true); |
| 3237 | 3237 | } |
| 3238 | 3238 | } |
| 3239 | - }else{ |
|
| 3240 | - $fields = $filter; |
|
| 3239 | + } else { |
|
| 3240 | + $fields = $filter; |
|
| 3241 | 3241 | } |
| 3242 | 3242 | } |
| 3243 | 3243 | else |
| 3244 | 3244 | { |
| 3245 | - $fields = $this->field_defs; |
|
| 3245 | + $fields = $this->field_defs; |
|
| 3246 | 3246 | } |
| 3247 | 3247 | |
| 3248 | 3248 | $used_join_key = array(); |
@@ -3250,7 +3250,7 @@ discard block |
||
| 3250 | 3250 | //walk through the fields and for every relationship field add their relationship_info field |
| 3251 | 3251 | //relationshipfield-aliases are resolved in SugarBean::create_new_list_query through their relationship_info field |
| 3252 | 3252 | $addrelate = array(); |
| 3253 | - foreach($fields as $field=>$value) |
|
| 3253 | + foreach ($fields as $field=>$value) |
|
| 3254 | 3254 | { |
| 3255 | 3255 | if (isset($this->field_defs[$field]) && isset($this->field_defs[$field]['source']) && |
| 3256 | 3256 | $this->field_defs[$field]['source'] == 'non-db') |
@@ -3259,27 +3259,27 @@ discard block |
||
| 3259 | 3259 | if ($addrelatefield) |
| 3260 | 3260 | $addrelate[$addrelatefield] = true; |
| 3261 | 3261 | } |
| 3262 | - if(!empty($this->field_defs[$field]['id_name'])){ |
|
| 3262 | + if (!empty($this->field_defs[$field]['id_name'])) { |
|
| 3263 | 3263 | $addrelate[$this->field_defs[$field]['id_name']] = true; |
| 3264 | 3264 | } |
| 3265 | 3265 | } |
| 3266 | 3266 | |
| 3267 | 3267 | $fields = array_merge($addrelate, $fields); |
| 3268 | 3268 | |
| 3269 | - foreach($fields as $field=>$value) |
|
| 3269 | + foreach ($fields as $field=>$value) |
|
| 3270 | 3270 | { |
| 3271 | 3271 | //alias is used to alias field names |
| 3272 | - $alias=''; |
|
| 3273 | - if (isset($value['alias'])) |
|
| 3272 | + $alias = ''; |
|
| 3273 | + if (isset($value['alias'])) |
|
| 3274 | 3274 | { |
| 3275 | - $alias =' as ' . $value['alias'] . ' '; |
|
| 3275 | + $alias = ' as '.$value['alias'].' '; |
|
| 3276 | 3276 | } |
| 3277 | 3277 | |
| 3278 | - if(empty($this->field_defs[$field]) || !empty($value['force_blank']) ) |
|
| 3278 | + if (empty($this->field_defs[$field]) || !empty($value['force_blank'])) |
|
| 3279 | 3279 | { |
| 3280 | - if(!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists']) |
|
| 3280 | + if (!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists']) |
|
| 3281 | 3281 | { |
| 3282 | - if ( isset($filter[$field]['force_default']) ) |
|
| 3282 | + if (isset($filter[$field]['force_default'])) |
|
| 3283 | 3283 | $ret_array['select'] .= ", {$filter[$field]['force_default']} $field "; |
| 3284 | 3284 | else |
| 3285 | 3285 | //spaces are a fix for length issue problem with unions. The union only returns the maximum number of characters from the first select statement. |
@@ -3311,14 +3311,14 @@ discard block |
||
| 3311 | 3311 | continue; |
| 3312 | 3312 | } |
| 3313 | 3313 | |
| 3314 | - if( (!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter) )) |
|
| 3314 | + if ((!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter))) |
|
| 3315 | 3315 | { |
| 3316 | 3316 | $ret_array['select'] .= ", $this->table_name.$field $alias"; |
| 3317 | 3317 | $selectedFields["$this->table_name.$field"] = true; |
| 3318 | - } else if( (!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter) )) { |
|
| 3318 | + } else if ((!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter))) { |
|
| 3319 | 3319 | //add this column only if it has NOT already been added to select statement string |
| 3320 | - $colPos = strpos($ret_array['select'],"$this->table_name"."_cstm".".$field"); |
|
| 3321 | - if(!$colPos || $colPos<0) |
|
| 3320 | + $colPos = strpos($ret_array['select'], "$this->table_name"."_cstm".".$field"); |
|
| 3321 | + if (!$colPos || $colPos < 0) |
|
| 3322 | 3322 | { |
| 3323 | 3323 | $ret_array['select'] .= ", $this->table_name"."_cstm".".$field $alias"; |
| 3324 | 3324 | } |
@@ -3326,22 +3326,22 @@ discard block |
||
| 3326 | 3326 | $selectedFields["$this->table_name.$field"] = true; |
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | - if($data['type'] != 'relate' && isset($data['db_concat_fields'])) |
|
| 3329 | + if ($data['type'] != 'relate' && isset($data['db_concat_fields'])) |
|
| 3330 | 3330 | { |
| 3331 | - $ret_array['select'] .= ", " . $this->db->concat($this->table_name, $data['db_concat_fields']) . " as $field"; |
|
| 3331 | + $ret_array['select'] .= ", ".$this->db->concat($this->table_name, $data['db_concat_fields'])." as $field"; |
|
| 3332 | 3332 | $selectedFields[$this->db->concat($this->table_name, $data['db_concat_fields'])] = true; |
| 3333 | 3333 | } |
| 3334 | 3334 | //Custom relate field or relate fields built in module builder which have no link field associated. |
| 3335 | 3335 | if ($data['type'] == 'relate' && (isset($data['custom_module']) || isset($data['ext2']))) { |
| 3336 | - $joinTableAlias = 'jt' . $jtcount; |
|
| 3336 | + $joinTableAlias = 'jt'.$jtcount; |
|
| 3337 | 3337 | $relateJoinInfo = $this->custom_fields->getRelateJoin($data, $joinTableAlias, false); |
| 3338 | 3338 | $ret_array['select'] .= $relateJoinInfo['select']; |
| 3339 | 3339 | $ret_array['from'] .= $relateJoinInfo['from']; |
| 3340 | 3340 | //Replace any references to the relationship in the where clause with the new alias |
| 3341 | 3341 | //If the link isn't set, assume that search used the local table for the field |
| 3342 | 3342 | $searchTable = isset($data['link']) ? $relateJoinInfo['rel_table'] : $this->table_name; |
| 3343 | - $field_name = $relateJoinInfo['rel_table'] . '.' . !empty($data['name'])?$data['name']:'name'; |
|
| 3344 | - $where = preg_replace('/(^|[\s(])' . $field_name . '/' , '${1}' . $relateJoinInfo['name_field'], $where); |
|
| 3343 | + $field_name = $relateJoinInfo['rel_table'].'.'.!empty($data['name']) ? $data['name'] : 'name'; |
|
| 3344 | + $where = preg_replace('/(^|[\s(])'.$field_name.'/', '${1}'.$relateJoinInfo['name_field'], $where); |
|
| 3345 | 3345 | $jtcount++; |
| 3346 | 3346 | } |
| 3347 | 3347 | //Parent Field |
@@ -3349,7 +3349,7 @@ discard block |
||
| 3349 | 3349 | //See if we need to join anything by inspecting the where clause |
| 3350 | 3350 | $match = preg_match('/(^|[\s(])parent_([a-zA-Z]+_?[a-zA-Z]+)_([a-zA-Z]+_?[a-zA-Z]+)\.name/', $where, $matches); |
| 3351 | 3351 | if ($match) { |
| 3352 | - $joinTableAlias = 'jt' . $jtcount; |
|
| 3352 | + $joinTableAlias = 'jt'.$jtcount; |
|
| 3353 | 3353 | $joinModule = $matches[2]; |
| 3354 | 3354 | $joinTable = $matches[3]; |
| 3355 | 3355 | $localTable = $this->table_name; |
@@ -3363,7 +3363,7 @@ discard block |
||
| 3363 | 3363 | if (isset($rel_mod->field_defs['name'])) |
| 3364 | 3364 | { |
| 3365 | 3365 | $name_field_def = $rel_mod->field_defs['name']; |
| 3366 | - if(isset($name_field_def['db_concat_fields'])) |
|
| 3366 | + if (isset($name_field_def['db_concat_fields'])) |
|
| 3367 | 3367 | { |
| 3368 | 3368 | $nameField = $this->db->concat($joinTableAlias, $name_field_def['db_concat_fields']); |
| 3369 | 3369 | } |
@@ -3372,7 +3372,7 @@ discard block |
||
| 3372 | 3372 | $ret_array['from'] .= " LEFT JOIN $joinTable $joinTableAlias |
| 3373 | 3373 | ON $localTable.{$data['id_name']} = $joinTableAlias.id"; |
| 3374 | 3374 | //Replace any references to the relationship in the where clause with the new alias |
| 3375 | - $where = preg_replace('/(^|[\s(])parent_' . $joinModule . '_' . $joinTable . '\.name/', '${1}' . $nameField, $where); |
|
| 3375 | + $where = preg_replace('/(^|[\s(])parent_'.$joinModule.'_'.$joinTable.'\.name/', '${1}'.$nameField, $where); |
|
| 3376 | 3376 | $jtcount++; |
| 3377 | 3377 | } |
| 3378 | 3378 | } |
@@ -3381,10 +3381,10 @@ discard block |
||
| 3381 | 3381 | { |
| 3382 | 3382 | $linkField = $data['link']; |
| 3383 | 3383 | $this->load_relationship($linkField); |
| 3384 | - if(!empty($this->$linkField)) |
|
| 3384 | + if (!empty($this->$linkField)) |
|
| 3385 | 3385 | { |
| 3386 | 3386 | $params = array(); |
| 3387 | - if(empty($join_type)) |
|
| 3387 | + if (empty($join_type)) |
|
| 3388 | 3388 | { |
| 3389 | 3389 | $params['join_type'] = ' LEFT JOIN '; |
| 3390 | 3390 | } |
@@ -3392,22 +3392,22 @@ discard block |
||
| 3392 | 3392 | { |
| 3393 | 3393 | $params['join_type'] = $join_type; |
| 3394 | 3394 | } |
| 3395 | - if(isset($data['join_name'])) |
|
| 3395 | + if (isset($data['join_name'])) |
|
| 3396 | 3396 | { |
| 3397 | 3397 | $params['join_table_alias'] = $data['join_name']; |
| 3398 | 3398 | } |
| 3399 | 3399 | else |
| 3400 | 3400 | { |
| 3401 | - $params['join_table_alias'] = 'jt' . $jtcount; |
|
| 3401 | + $params['join_table_alias'] = 'jt'.$jtcount; |
|
| 3402 | 3402 | |
| 3403 | 3403 | } |
| 3404 | - if(isset($data['join_link_name'])) |
|
| 3404 | + if (isset($data['join_link_name'])) |
|
| 3405 | 3405 | { |
| 3406 | 3406 | $params['join_table_link_alias'] = $data['join_link_name']; |
| 3407 | 3407 | } |
| 3408 | 3408 | else |
| 3409 | 3409 | { |
| 3410 | - $params['join_table_link_alias'] = 'jtl' . $jtcount; |
|
| 3410 | + $params['join_table_link_alias'] = 'jtl'.$jtcount; |
|
| 3411 | 3411 | } |
| 3412 | 3412 | $join_primary = !isset($data['join_primary']) || $data['join_primary']; |
| 3413 | 3413 | |
@@ -3420,126 +3420,126 @@ discard block |
||
| 3420 | 3420 | global $beanFiles, $beanList; |
| 3421 | 3421 | // °3/21/2014 FIX NS-TEAM - Relationship fields could not be displayed in subpanels |
| 3422 | 3422 | //if($data['rname'] && !empty($beanFiles[$beanList[$rel_module]])) { |
| 3423 | - if(isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) { |
|
| 3423 | + if (isset($data['rname']) && $data['rname'] == 'name' && !empty($beanFiles[$beanList[$rel_module]])) { |
|
| 3424 | 3424 | |
| 3425 | 3425 | //create an instance of the related bean |
| 3426 | 3426 | require_once($beanFiles[$beanList[$rel_module]]); |
| 3427 | 3427 | $rel_mod = new $beanList[$rel_module](); |
| 3428 | 3428 | //if bean has first and last name fields, then name should be concatenated |
| 3429 | - if(isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])){ |
|
| 3429 | + if (isset($rel_mod->field_name_map['first_name']) && isset($rel_mod->field_name_map['last_name'])) { |
|
| 3430 | 3430 | $data['db_concat_fields'] = array(0=>'first_name', 1=>'last_name'); |
| 3431 | 3431 | } |
| 3432 | 3432 | } |
| 3433 | 3433 | |
| 3434 | 3434 | |
| 3435 | - if($join['type'] == 'many-to-many') |
|
| 3435 | + if ($join['type'] == 'many-to-many') |
|
| 3436 | 3436 | { |
| 3437 | - if(empty($ret_array['secondary_select'])) |
|
| 3437 | + if (empty($ret_array['secondary_select'])) |
|
| 3438 | 3438 | { |
| 3439 | 3439 | $ret_array['secondary_select'] = " SELECT $this->table_name.id ref_id "; |
| 3440 | 3440 | |
| 3441 | - if(!empty($beanFiles[$beanList[$rel_module]]) && $join_primary) |
|
| 3441 | + if (!empty($beanFiles[$beanList[$rel_module]]) && $join_primary) |
|
| 3442 | 3442 | { |
| 3443 | 3443 | require_once($beanFiles[$beanList[$rel_module]]); |
| 3444 | 3444 | $rel_mod = new $beanList[$rel_module](); |
| 3445 | - if(isset($rel_mod->field_defs['assigned_user_id'])) |
|
| 3445 | + if (isset($rel_mod->field_defs['assigned_user_id'])) |
|
| 3446 | 3446 | { |
| 3447 | - $ret_array['secondary_select'].= " , ". $params['join_table_alias'] . ".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
| 3447 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".assigned_user_id {$field}_owner, '$rel_module' {$field}_mod"; |
|
| 3448 | 3448 | } |
| 3449 | 3449 | else |
| 3450 | 3450 | { |
| 3451 | - if(isset($rel_mod->field_defs['created_by'])) |
|
| 3451 | + if (isset($rel_mod->field_defs['created_by'])) |
|
| 3452 | 3452 | { |
| 3453 | - $ret_array['secondary_select'].= " , ". $params['join_table_alias'] . ".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
| 3453 | + $ret_array['secondary_select'] .= " , ".$params['join_table_alias'].".created_by {$field}_owner , '$rel_module' {$field}_mod"; |
|
| 3454 | 3454 | } |
| 3455 | 3455 | } |
| 3456 | 3456 | } |
| 3457 | 3457 | } |
| 3458 | 3458 | |
| 3459 | - if(isset($data['db_concat_fields'])) |
|
| 3459 | + if (isset($data['db_concat_fields'])) |
|
| 3460 | 3460 | { |
| 3461 | - $ret_array['secondary_select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
| 3461 | + $ret_array['secondary_select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
| 3462 | 3462 | } |
| 3463 | 3463 | else |
| 3464 | 3464 | { |
| 3465 | - if(!isset($data['relationship_fields'])) |
|
| 3465 | + if (!isset($data['relationship_fields'])) |
|
| 3466 | 3466 | { |
| 3467 | - $ret_array['secondary_select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
| 3467 | + $ret_array['secondary_select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
| 3468 | 3468 | } |
| 3469 | 3469 | } |
| 3470 | - if(!$singleSelect) |
|
| 3470 | + if (!$singleSelect) |
|
| 3471 | 3471 | { |
| 3472 | 3472 | $ret_array['select'] .= ", ' ' $field "; |
| 3473 | 3473 | } |
| 3474 | - $count_used =0; |
|
| 3475 | - foreach($used_join_key as $used_key) { |
|
| 3476 | - if($used_key == $join['rel_key']) $count_used++; |
|
| 3474 | + $count_used = 0; |
|
| 3475 | + foreach ($used_join_key as $used_key) { |
|
| 3476 | + if ($used_key == $join['rel_key']) $count_used++; |
|
| 3477 | 3477 | } |
| 3478 | - if($count_used <= 1) {//27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
|
| 3478 | + if ($count_used <= 1) {//27416, the $ret_array['secondary_select'] should always generate, regardless the dbtype |
|
| 3479 | 3479 | // add rel_key only if it was not aready added |
| 3480 | - if(!$singleSelect) |
|
| 3480 | + if (!$singleSelect) |
|
| 3481 | 3481 | { |
| 3482 | - $ret_array['select'] .= ", ' ' " . $join['rel_key'] . ' '; |
|
| 3482 | + $ret_array['select'] .= ", ' ' ".$join['rel_key'].' '; |
|
| 3483 | 3483 | } |
| 3484 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'].'.'. $join['rel_key'] .' ' . $join['rel_key']; |
|
| 3484 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$join['rel_key'].' '.$join['rel_key']; |
|
| 3485 | 3485 | } |
| 3486 | - if(isset($data['relationship_fields'])) |
|
| 3486 | + if (isset($data['relationship_fields'])) |
|
| 3487 | 3487 | { |
| 3488 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3488 | + foreach ($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3489 | 3489 | { |
| 3490 | - if(!empty( $secondarySelectedFields[$alias_name]))continue; |
|
| 3491 | - $ret_array['secondary_select'] .= ', ' . $params['join_table_link_alias'].'.'. $r_name .' ' . $alias_name; |
|
| 3490 | + if (!empty($secondarySelectedFields[$alias_name]))continue; |
|
| 3491 | + $ret_array['secondary_select'] .= ', '.$params['join_table_link_alias'].'.'.$r_name.' '.$alias_name; |
|
| 3492 | 3492 | $secondarySelectedFields[$alias_name] = true; |
| 3493 | 3493 | } |
| 3494 | 3494 | } |
| 3495 | - if(!$table_joined) |
|
| 3495 | + if (!$table_joined) |
|
| 3496 | 3496 | { |
| 3497 | - $ret_array['secondary_from'] .= ' ' . $join['join']. ' AND ' . $params['join_table_alias'].'.deleted=0'; |
|
| 3497 | + $ret_array['secondary_from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
| 3498 | 3498 | if (isset($data['link_type']) && $data['link_type'] == 'relationship_info' && ($parentbean instanceOf SugarBean)) |
| 3499 | 3499 | { |
| 3500 | - $ret_array['secondary_where'] = $params['join_table_link_alias'] . '.' . $join['rel_key']. "='" .$parentbean->id . "'"; |
|
| 3500 | + $ret_array['secondary_where'] = $params['join_table_link_alias'].'.'.$join['rel_key']."='".$parentbean->id."'"; |
|
| 3501 | 3501 | } |
| 3502 | 3502 | } |
| 3503 | 3503 | } |
| 3504 | 3504 | else |
| 3505 | 3505 | { |
| 3506 | - if(isset($data['db_concat_fields'])) |
|
| 3506 | + if (isset($data['db_concat_fields'])) |
|
| 3507 | 3507 | { |
| 3508 | - $ret_array['select'] .= ' , ' . $this->db->concat($params['join_table_alias'], $data['db_concat_fields']) . ' ' . $field; |
|
| 3508 | + $ret_array['select'] .= ' , '.$this->db->concat($params['join_table_alias'], $data['db_concat_fields']).' '.$field; |
|
| 3509 | 3509 | } |
| 3510 | 3510 | else |
| 3511 | 3511 | { |
| 3512 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $data['rname'] . ' ' . $field; |
|
| 3512 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$data['rname'].' '.$field; |
|
| 3513 | 3513 | } |
| 3514 | - if(isset($data['additionalFields'])){ |
|
| 3515 | - foreach($data['additionalFields'] as $k=>$v){ |
|
| 3514 | + if (isset($data['additionalFields'])) { |
|
| 3515 | + foreach ($data['additionalFields'] as $k=>$v) { |
|
| 3516 | 3516 | if (!empty($data['id_name']) && $data['id_name'] == $v && !empty($fields[$data['id_name']])) { |
| 3517 | 3517 | continue; |
| 3518 | 3518 | } |
| 3519 | - $ret_array['select'] .= ' , ' . $params['join_table_alias'] . '.' . $k . ' ' . $v; |
|
| 3519 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.'.$k.' '.$v; |
|
| 3520 | 3520 | } |
| 3521 | 3521 | } |
| 3522 | - if(!$table_joined) |
|
| 3522 | + if (!$table_joined) |
|
| 3523 | 3523 | { |
| 3524 | - $ret_array['from'] .= ' ' . $join['join']. ' AND ' . $params['join_table_alias'].'.deleted=0'; |
|
| 3525 | - if(!empty($beanList[$rel_module]) && !empty($beanFiles[$beanList[$rel_module]])) |
|
| 3524 | + $ret_array['from'] .= ' '.$join['join'].' AND '.$params['join_table_alias'].'.deleted=0'; |
|
| 3525 | + if (!empty($beanList[$rel_module]) && !empty($beanFiles[$beanList[$rel_module]])) |
|
| 3526 | 3526 | { |
| 3527 | 3527 | require_once($beanFiles[$beanList[$rel_module]]); |
| 3528 | 3528 | $rel_mod = new $beanList[$rel_module](); |
| 3529 | - if(isset($value['target_record_key']) && !empty($filter)) |
|
| 3529 | + if (isset($value['target_record_key']) && !empty($filter)) |
|
| 3530 | 3530 | { |
| 3531 | 3531 | $selectedFields[$this->table_name.'.'.$value['target_record_key']] = true; |
| 3532 | 3532 | $ret_array['select'] .= " , $this->table_name.{$value['target_record_key']} "; |
| 3533 | 3533 | } |
| 3534 | - if(isset($rel_mod->field_defs['assigned_user_id'])) |
|
| 3534 | + if (isset($rel_mod->field_defs['assigned_user_id'])) |
|
| 3535 | 3535 | { |
| 3536 | - $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.assigned_user_id ' . $field . '_owner'; |
|
| 3536 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.assigned_user_id '.$field.'_owner'; |
|
| 3537 | 3537 | } |
| 3538 | 3538 | else |
| 3539 | 3539 | { |
| 3540 | - $ret_array['select'] .= ' , ' .$params['join_table_alias'] . '.created_by ' . $field . '_owner'; |
|
| 3540 | + $ret_array['select'] .= ' , '.$params['join_table_alias'].'.created_by '.$field.'_owner'; |
|
| 3541 | 3541 | } |
| 3542 | - $ret_array['select'] .= " , '".$rel_module ."' " . $field . '_mod'; |
|
| 3542 | + $ret_array['select'] .= " , '".$rel_module."' ".$field.'_mod'; |
|
| 3543 | 3543 | |
| 3544 | 3544 | } |
| 3545 | 3545 | } |
@@ -3547,65 +3547,65 @@ discard block |
||
| 3547 | 3547 | // To fix SOAP stuff where we are trying to retrieve all the accounts data where accounts.id = .. |
| 3548 | 3548 | // and this code changes accounts to jt4 as there is a self join with the accounts table. |
| 3549 | 3549 | //Martin fix #27494 |
| 3550 | - if(isset($data['db_concat_fields'])){ |
|
| 3550 | + if (isset($data['db_concat_fields'])) { |
|
| 3551 | 3551 | $buildWhere = false; |
| 3552 | - if(in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) |
|
| 3552 | + if (in_array('first_name', $data['db_concat_fields']) && in_array('last_name', $data['db_concat_fields'])) |
|
| 3553 | 3553 | { |
| 3554 | 3554 | $exp = '/\(\s*?'.$data['name'].'.*?\%\'\s*?\)/'; |
| 3555 | - if(preg_match($exp, $where, $matches)) |
|
| 3555 | + if (preg_match($exp, $where, $matches)) |
|
| 3556 | 3556 | { |
| 3557 | 3557 | $search_expression = $matches[0]; |
| 3558 | 3558 | //Create three search conditions - first + last, first, last |
| 3559 | - $first_name_search = str_replace($data['name'], $params['join_table_alias'] . '.first_name', $search_expression); |
|
| 3560 | - $last_name_search = str_replace($data['name'], $params['join_table_alias'] . '.last_name', $search_expression); |
|
| 3559 | + $first_name_search = str_replace($data['name'], $params['join_table_alias'].'.first_name', $search_expression); |
|
| 3560 | + $last_name_search = str_replace($data['name'], $params['join_table_alias'].'.last_name', $search_expression); |
|
| 3561 | 3561 | $full_name_search = str_replace($data['name'], $this->db->concat($params['join_table_alias'], $data['db_concat_fields']), $search_expression); |
| 3562 | 3562 | $buildWhere = true; |
| 3563 | - $where = str_replace($search_expression, '(' . $full_name_search . ' OR ' . $first_name_search . ' OR ' . $last_name_search . ')', $where); |
|
| 3563 | + $where = str_replace($search_expression, '('.$full_name_search.' OR '.$first_name_search.' OR '.$last_name_search.')', $where); |
|
| 3564 | 3564 | } |
| 3565 | 3565 | } |
| 3566 | 3566 | |
| 3567 | - if(!$buildWhere) |
|
| 3567 | + if (!$buildWhere) |
|
| 3568 | 3568 | { |
| 3569 | 3569 | $db_field = $this->db->concat($params['join_table_alias'], $data['db_concat_fields']); |
| 3570 | 3570 | $where = preg_replace('/'.$data['name'].'/', $db_field, $where); |
| 3571 | 3571 | |
| 3572 | 3572 | // For relationship fields replace their alias by the corresponsding link table and r_name |
| 3573 | - if(isset($data['relationship_fields'])) |
|
| 3574 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3573 | + if (isset($data['relationship_fields'])) |
|
| 3574 | + foreach ($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3575 | 3575 | { |
| 3576 | 3576 | $db_field = $this->db->concat($params['join_table_link_alias'], $r_name); |
| 3577 | - $where = preg_replace('/' . $alias_name . '/', $db_field, $where); |
|
| 3577 | + $where = preg_replace('/'.$alias_name.'/', $db_field, $where); |
|
| 3578 | 3578 | } |
| 3579 | 3579 | } |
| 3580 | - }else{ |
|
| 3581 | - $where = preg_replace('/(^|[\s(])' . $data['name'] . '/', '${1}' . $params['join_table_alias'] . '.'.$data['rname'], $where); |
|
| 3580 | + } else { |
|
| 3581 | + $where = preg_replace('/(^|[\s(])'.$data['name'].'/', '${1}'.$params['join_table_alias'].'.'.$data['rname'], $where); |
|
| 3582 | 3582 | |
| 3583 | 3583 | // For relationship fields replace their alias by the corresponsding link table and r_name |
| 3584 | - if(isset($data['relationship_fields'])) |
|
| 3585 | - foreach($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3586 | - $where = preg_replace('/(^|[\s(])' . $alias_name . '/', '${1}' . $params['join_table_link_alias'] . '.'.$r_name, $where); |
|
| 3584 | + if (isset($data['relationship_fields'])) |
|
| 3585 | + foreach ($data['relationship_fields'] as $r_name=>$alias_name) |
|
| 3586 | + $where = preg_replace('/(^|[\s(])'.$alias_name.'/', '${1}'.$params['join_table_link_alias'].'.'.$r_name, $where); |
|
| 3587 | 3587 | } |
| 3588 | - if(!$table_joined) |
|
| 3588 | + if (!$table_joined) |
|
| 3589 | 3589 | { |
| 3590 | - $joined_tables[$params['join_table_alias']]=1; |
|
| 3591 | - $joined_tables[$params['join_table_link_alias']]=1; |
|
| 3590 | + $joined_tables[$params['join_table_alias']] = 1; |
|
| 3591 | + $joined_tables[$params['join_table_link_alias']] = 1; |
|
| 3592 | 3592 | } |
| 3593 | 3593 | |
| 3594 | 3594 | $jtcount++; |
| 3595 | 3595 | } |
| 3596 | 3596 | } |
| 3597 | 3597 | } |
| 3598 | - if(!empty($filter)) |
|
| 3598 | + if (!empty($filter)) |
|
| 3599 | 3599 | { |
| 3600 | - if(isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) |
|
| 3600 | + if (isset($this->field_defs['assigned_user_id']) && empty($selectedFields[$this->table_name.'.assigned_user_id'])) |
|
| 3601 | 3601 | { |
| 3602 | 3602 | $ret_array['select'] .= ", $this->table_name.assigned_user_id "; |
| 3603 | 3603 | } |
| 3604 | - else if(isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) |
|
| 3604 | + else if (isset($this->field_defs['created_by']) && empty($selectedFields[$this->table_name.'.created_by'])) |
|
| 3605 | 3605 | { |
| 3606 | 3606 | $ret_array['select'] .= ", $this->table_name.created_by "; |
| 3607 | 3607 | } |
| 3608 | - if(isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name.'.system_id'])) |
|
| 3608 | + if (isset($this->field_defs['system_id']) && empty($selectedFields[$this->table_name.'.system_id'])) |
|
| 3609 | 3609 | { |
| 3610 | 3610 | $ret_array['select'] .= ", $this->table_name.system_id "; |
| 3611 | 3611 | } |
@@ -3613,21 +3613,21 @@ discard block |
||
| 3613 | 3613 | } |
| 3614 | 3614 | |
| 3615 | 3615 | if ($ifListForExport) { |
| 3616 | - if(isset($this->field_defs['email1'])) { |
|
| 3617 | - $ret_array['select'].= " ,email_addresses.email_address email1"; |
|
| 3618 | - $ret_array['from'].= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
| 3616 | + if (isset($this->field_defs['email1'])) { |
|
| 3617 | + $ret_array['select'] .= " ,email_addresses.email_address email1"; |
|
| 3618 | + $ret_array['from'] .= " LEFT JOIN email_addr_bean_rel on {$this->table_name}.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='{$this->module_dir}' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1 LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id "; |
|
| 3619 | 3619 | } |
| 3620 | 3620 | } |
| 3621 | 3621 | |
| 3622 | 3622 | $where_auto = '1=1'; |
| 3623 | - if($show_deleted == 0) |
|
| 3623 | + if ($show_deleted == 0) |
|
| 3624 | 3624 | { |
| 3625 | 3625 | $where_auto = "$this->table_name.deleted=0"; |
| 3626 | - }else if($show_deleted == 1) |
|
| 3626 | + } else if ($show_deleted == 1) |
|
| 3627 | 3627 | { |
| 3628 | 3628 | $where_auto = "$this->table_name.deleted=1"; |
| 3629 | 3629 | } |
| 3630 | - if($where != "") |
|
| 3630 | + if ($where != "") |
|
| 3631 | 3631 | $ret_array['where'] = " where ($where) AND $where_auto"; |
| 3632 | 3632 | else |
| 3633 | 3633 | $ret_array['where'] = " where $where_auto"; |
@@ -3635,21 +3635,21 @@ discard block |
||
| 3635 | 3635 | //make call to process the order by clause |
| 3636 | 3636 | $order_by = $this->process_order_by($order_by); |
| 3637 | 3637 | if (!empty($order_by)) { |
| 3638 | - $ret_array['order_by'] = " ORDER BY " . $order_by; |
|
| 3638 | + $ret_array['order_by'] = " ORDER BY ".$order_by; |
|
| 3639 | 3639 | } |
| 3640 | - if($singleSelect) |
|
| 3640 | + if ($singleSelect) |
|
| 3641 | 3641 | { |
| 3642 | 3642 | unset($ret_array['secondary_where']); |
| 3643 | 3643 | unset($ret_array['secondary_from']); |
| 3644 | 3644 | unset($ret_array['secondary_select']); |
| 3645 | 3645 | } |
| 3646 | 3646 | |
| 3647 | - if($return_array) |
|
| 3647 | + if ($return_array) |
|
| 3648 | 3648 | { |
| 3649 | 3649 | return $ret_array; |
| 3650 | 3650 | } |
| 3651 | 3651 | |
| 3652 | - return $ret_array['select'] . $ret_array['from'] . $ret_array['where']. $ret_array['order_by']; |
|
| 3652 | + return $ret_array['select'].$ret_array['from'].$ret_array['where'].$ret_array['order_by']; |
|
| 3653 | 3653 | } |
| 3654 | 3654 | |
| 3655 | 3655 | // Check if field is defined through a relationship_info field, add this field when not present |
@@ -3680,13 +3680,13 @@ discard block |
||
| 3680 | 3680 | global $beanList, $beanFiles; |
| 3681 | 3681 | $templates = array(); |
| 3682 | 3682 | $parent_child_map = array(); |
| 3683 | - foreach($type_info as $children_info) |
|
| 3683 | + foreach ($type_info as $children_info) |
|
| 3684 | 3684 | { |
| 3685 | - foreach($children_info as $child_info) |
|
| 3685 | + foreach ($children_info as $child_info) |
|
| 3686 | 3686 | { |
| 3687 | - if($child_info['type'] == 'parent') |
|
| 3687 | + if ($child_info['type'] == 'parent') |
|
| 3688 | 3688 | { |
| 3689 | - if(empty($templates[$child_info['parent_type']])) |
|
| 3689 | + if (empty($templates[$child_info['parent_type']])) |
|
| 3690 | 3690 | { |
| 3691 | 3691 | //Test emails will have an invalid parent_type, don't try to load the non-existent parent bean |
| 3692 | 3692 | if ($child_info['parent_type'] == 'test') { |
@@ -3694,7 +3694,7 @@ discard block |
||
| 3694 | 3694 | } |
| 3695 | 3695 | $class = $beanList[$child_info['parent_type']]; |
| 3696 | 3696 | // Added to avoid error below; just silently fail and write message to log |
| 3697 | - if ( empty($beanFiles[$class]) ) { |
|
| 3697 | + if (empty($beanFiles[$class])) { |
|
| 3698 | 3698 | $GLOBALS['log']->error($this->object_name.'::retrieve_parent_fields() - cannot load class "'.$class.'", skip loading.'); |
| 3699 | 3699 | continue; |
| 3700 | 3700 | } |
@@ -3702,30 +3702,30 @@ discard block |
||
| 3702 | 3702 | $templates[$child_info['parent_type']] = new $class(); |
| 3703 | 3703 | } |
| 3704 | 3704 | |
| 3705 | - if(empty($queries[$child_info['parent_type']])) |
|
| 3705 | + if (empty($queries[$child_info['parent_type']])) |
|
| 3706 | 3706 | { |
| 3707 | 3707 | $queries[$child_info['parent_type']] = "SELECT id "; |
| 3708 | 3708 | $field_def = $templates[$child_info['parent_type']]->field_defs['name']; |
| 3709 | - if(isset($field_def['db_concat_fields'])) |
|
| 3709 | + if (isset($field_def['db_concat_fields'])) |
|
| 3710 | 3710 | { |
| 3711 | - $queries[$child_info['parent_type']] .= ' , ' . $this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']) . ' parent_name'; |
|
| 3711 | + $queries[$child_info['parent_type']] .= ' , '.$this->db->concat($templates[$child_info['parent_type']]->table_name, $field_def['db_concat_fields']).' parent_name'; |
|
| 3712 | 3712 | } |
| 3713 | 3713 | else |
| 3714 | 3714 | { |
| 3715 | 3715 | $queries[$child_info['parent_type']] .= ' , name parent_name'; |
| 3716 | 3716 | } |
| 3717 | - if(isset($templates[$child_info['parent_type']]->field_defs['assigned_user_id'])) |
|
| 3717 | + if (isset($templates[$child_info['parent_type']]->field_defs['assigned_user_id'])) |
|
| 3718 | 3718 | { |
| 3719 | - $queries[$child_info['parent_type']] .= ", assigned_user_id parent_name_owner , '{$child_info['parent_type']}' parent_name_mod";; |
|
| 3720 | - }else if(isset($templates[$child_info['parent_type']]->field_defs['created_by'])) |
|
| 3719 | + $queries[$child_info['parent_type']] .= ", assigned_user_id parent_name_owner , '{$child_info['parent_type']}' parent_name_mod"; ; |
|
| 3720 | + } else if (isset($templates[$child_info['parent_type']]->field_defs['created_by'])) |
|
| 3721 | 3721 | { |
| 3722 | 3722 | $queries[$child_info['parent_type']] .= ", created_by parent_name_owner, '{$child_info['parent_type']}' parent_name_mod"; |
| 3723 | 3723 | } |
| 3724 | - $queries[$child_info['parent_type']] .= " FROM " . $templates[$child_info['parent_type']]->table_name ." WHERE id IN ('{$child_info['parent_id']}'"; |
|
| 3724 | + $queries[$child_info['parent_type']] .= " FROM ".$templates[$child_info['parent_type']]->table_name." WHERE id IN ('{$child_info['parent_id']}'"; |
|
| 3725 | 3725 | } |
| 3726 | 3726 | else |
| 3727 | 3727 | { |
| 3728 | - if(empty($parent_child_map[$child_info['parent_id']])) |
|
| 3728 | + if (empty($parent_child_map[$child_info['parent_id']])) |
|
| 3729 | 3729 | $queries[$child_info['parent_type']] .= " ,'{$child_info['parent_id']}'"; |
| 3730 | 3730 | } |
| 3731 | 3731 | $parent_child_map[$child_info['parent_id']][] = $child_info['child_id']; |
@@ -3733,21 +3733,21 @@ discard block |
||
| 3733 | 3733 | } |
| 3734 | 3734 | } |
| 3735 | 3735 | $results = array(); |
| 3736 | - foreach($queries as $query) |
|
| 3736 | + foreach ($queries as $query) |
|
| 3737 | 3737 | { |
| 3738 | - $result = $this->db->query($query . ')'); |
|
| 3739 | - while($row = $this->db->fetchByAssoc($result)) |
|
| 3738 | + $result = $this->db->query($query.')'); |
|
| 3739 | + while ($row = $this->db->fetchByAssoc($result)) |
|
| 3740 | 3740 | { |
| 3741 | 3741 | $results[$row['id']] = $row; |
| 3742 | 3742 | } |
| 3743 | 3743 | } |
| 3744 | 3744 | |
| 3745 | 3745 | $child_results = array(); |
| 3746 | - foreach($parent_child_map as $parent_key=>$parent_child) |
|
| 3746 | + foreach ($parent_child_map as $parent_key=>$parent_child) |
|
| 3747 | 3747 | { |
| 3748 | - foreach($parent_child as $child) |
|
| 3748 | + foreach ($parent_child as $child) |
|
| 3749 | 3749 | { |
| 3750 | - if(isset( $results[$parent_key])) |
|
| 3750 | + if (isset($results[$parent_key])) |
|
| 3751 | 3751 | { |
| 3752 | 3752 | $child_results[$child] = $results[$parent_key]; |
| 3753 | 3753 | } |
@@ -3767,7 +3767,7 @@ discard block |
||
| 3767 | 3767 | * @param string $where Optional, additional filter criteria. |
| 3768 | 3768 | * @return array Fetched data |
| 3769 | 3769 | */ |
| 3770 | - function process_list_query($query, $row_offset, $limit= -1, $max_per_page = -1, $where = '') |
|
| 3770 | + function process_list_query($query, $row_offset, $limit = -1, $max_per_page = -1, $where = '') |
|
| 3771 | 3771 | { |
| 3772 | 3772 | global $sugar_config; |
| 3773 | 3773 | $db = DBManagerFactory::getInstance('listviews'); |
@@ -3776,33 +3776,33 @@ discard block |
||
| 3776 | 3776 | */ |
| 3777 | 3777 | $toEnd = strval($row_offset) == 'end'; |
| 3778 | 3778 | $GLOBALS['log']->debug("process_list_query: ".$query); |
| 3779 | - if($max_per_page == -1) |
|
| 3779 | + if ($max_per_page == -1) |
|
| 3780 | 3780 | { |
| 3781 | - $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
| 3781 | + $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
| 3782 | 3782 | } |
| 3783 | 3783 | // Check to see if we have a count query available. |
| 3784 | - if(empty($sugar_config['disable_count_query']) || $toEnd) |
|
| 3784 | + if (empty($sugar_config['disable_count_query']) || $toEnd) |
|
| 3785 | 3785 | { |
| 3786 | 3786 | $count_query = $this->create_list_count_query($query); |
| 3787 | - if(!empty($count_query) && (empty($limit) || $limit == -1)) |
|
| 3787 | + if (!empty($count_query) && (empty($limit) || $limit == -1)) |
|
| 3788 | 3788 | { |
| 3789 | 3789 | // We have a count query. Run it and get the results. |
| 3790 | 3790 | $result = $db->query($count_query, true, "Error running count query for $this->object_name List: "); |
| 3791 | 3791 | $assoc = $db->fetchByAssoc($result); |
| 3792 | - if(!empty($assoc['c'])) |
|
| 3792 | + if (!empty($assoc['c'])) |
|
| 3793 | 3793 | { |
| 3794 | 3794 | $rows_found = $assoc['c']; |
| 3795 | 3795 | $limit = $sugar_config['list_max_entries_per_page']; |
| 3796 | 3796 | } |
| 3797 | - if( $toEnd) |
|
| 3797 | + if ($toEnd) |
|
| 3798 | 3798 | { |
| 3799 | - $row_offset = (floor(($rows_found -1) / $limit)) * $limit; |
|
| 3799 | + $row_offset = (floor(($rows_found - 1) / $limit)) * $limit; |
|
| 3800 | 3800 | } |
| 3801 | 3801 | } |
| 3802 | 3802 | } |
| 3803 | 3803 | else |
| 3804 | 3804 | { |
| 3805 | - if((empty($limit) || $limit == -1)) |
|
| 3805 | + if ((empty($limit) || $limit == -1)) |
|
| 3806 | 3806 | { |
| 3807 | 3807 | $limit = $max_per_page + 1; |
| 3808 | 3808 | $max_per_page = $limit; |
@@ -3810,17 +3810,17 @@ discard block |
||
| 3810 | 3810 | |
| 3811 | 3811 | } |
| 3812 | 3812 | |
| 3813 | - if(empty($row_offset)) |
|
| 3813 | + if (empty($row_offset)) |
|
| 3814 | 3814 | { |
| 3815 | 3815 | $row_offset = 0; |
| 3816 | 3816 | } |
| 3817 | - if(!empty($limit) && $limit != -1 && $limit != -99) |
|
| 3817 | + if (!empty($limit) && $limit != -1 && $limit != -99) |
|
| 3818 | 3818 | { |
| 3819 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: "); |
|
| 3819 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $this->object_name list: "); |
|
| 3820 | 3820 | } |
| 3821 | 3821 | else |
| 3822 | 3822 | { |
| 3823 | - $result = $db->query($query,true,"Error retrieving $this->object_name list: "); |
|
| 3823 | + $result = $db->query($query, true, "Error retrieving $this->object_name list: "); |
|
| 3824 | 3824 | } |
| 3825 | 3825 | |
| 3826 | 3826 | $list = Array(); |
@@ -3843,21 +3843,21 @@ discard block |
||
| 3843 | 3843 | /** @var SugarBean $temp */ |
| 3844 | 3844 | $temp = new $class(); |
| 3845 | 3845 | |
| 3846 | - foreach($this->field_defs as $field=>$value) |
|
| 3846 | + foreach ($this->field_defs as $field=>$value) |
|
| 3847 | 3847 | { |
| 3848 | 3848 | if (isset($row[$field])) |
| 3849 | 3849 | { |
| 3850 | 3850 | $temp->$field = $row[$field]; |
| 3851 | - $owner_field = $field . '_owner'; |
|
| 3852 | - if(isset($row[$owner_field])) |
|
| 3851 | + $owner_field = $field.'_owner'; |
|
| 3852 | + if (isset($row[$owner_field])) |
|
| 3853 | 3853 | { |
| 3854 | 3854 | $temp->$owner_field = $row[$owner_field]; |
| 3855 | 3855 | } |
| 3856 | 3856 | |
| 3857 | 3857 | $GLOBALS['log']->debug("$temp->object_name({$row['id']}): ".$field." = ".$temp->$field); |
| 3858 | - }else if (isset($row[$this->table_name .'.'.$field])) |
|
| 3858 | + } else if (isset($row[$this->table_name.'.'.$field])) |
|
| 3859 | 3859 | { |
| 3860 | - $temp->$field = $row[$this->table_name .'.'.$field]; |
|
| 3860 | + $temp->$field = $row[$this->table_name.'.'.$field]; |
|
| 3861 | 3861 | } |
| 3862 | 3862 | else |
| 3863 | 3863 | { |
@@ -3867,7 +3867,7 @@ discard block |
||
| 3867 | 3867 | |
| 3868 | 3868 | $temp->check_date_relationships_load(); |
| 3869 | 3869 | $temp->fill_in_additional_list_fields(); |
| 3870 | - if($temp->hasCustomFields()) $temp->custom_fields->fill_relationships(); |
|
| 3870 | + if ($temp->hasCustomFields()) $temp->custom_fields->fill_relationships(); |
|
| 3871 | 3871 | $temp->call_custom_logic("process_record"); |
| 3872 | 3872 | |
| 3873 | 3873 | // fix defect #44206. implement the same logic as sugar_currency_format |
@@ -3877,17 +3877,17 @@ discard block |
||
| 3877 | 3877 | |
| 3878 | 3878 | $index++; |
| 3879 | 3879 | } |
| 3880 | - if(!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
| 3880 | + if (!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
| 3881 | 3881 | { |
| 3882 | 3882 | |
| 3883 | 3883 | $rows_found = $row_offset + count($list); |
| 3884 | 3884 | |
| 3885 | - if(!$toEnd) |
|
| 3885 | + if (!$toEnd) |
|
| 3886 | 3886 | { |
| 3887 | 3887 | $next_offset--; |
| 3888 | 3888 | $previous_offset++; |
| 3889 | 3889 | } |
| 3890 | - } else if(!isset($rows_found)){ |
|
| 3890 | + } else if (!isset($rows_found)) { |
|
| 3891 | 3891 | $rows_found = $row_offset + count($list); |
| 3892 | 3892 | } |
| 3893 | 3893 | |
@@ -3896,7 +3896,7 @@ discard block |
||
| 3896 | 3896 | $response['row_count'] = $rows_found; |
| 3897 | 3897 | $response['next_offset'] = $next_offset; |
| 3898 | 3898 | $response['previous_offset'] = $previous_offset; |
| 3899 | - $response['current_offset'] = $row_offset ; |
|
| 3899 | + $response['current_offset'] = $row_offset; |
|
| 3900 | 3900 | return $response; |
| 3901 | 3901 | } |
| 3902 | 3902 | |
@@ -3908,18 +3908,18 @@ discard block |
||
| 3908 | 3908 | * @param boolean $is_count_query Optional, Default false, set to true if passed query is a count query. |
| 3909 | 3909 | * @return int count of rows found |
| 3910 | 3910 | */ |
| 3911 | - function _get_num_rows_in_query($query, $is_count_query=false) |
|
| 3911 | + function _get_num_rows_in_query($query, $is_count_query = false) |
|
| 3912 | 3912 | { |
| 3913 | 3913 | $num_rows_in_query = 0; |
| 3914 | 3914 | if (!$is_count_query) |
| 3915 | 3915 | { |
| 3916 | 3916 | $count_query = SugarBean::create_list_count_query($query); |
| 3917 | 3917 | } else |
| 3918 | - $count_query=$query; |
|
| 3918 | + $count_query = $query; |
|
| 3919 | 3919 | |
| 3920 | 3920 | $result = $this->db->query($count_query, true, "Error running count query for $this->object_name List: "); |
| 3921 | 3921 | $row_num = 0; |
| 3922 | - while($row = $this->db->fetchByAssoc($result, true)) |
|
| 3922 | + while ($row = $this->db->fetchByAssoc($result, true)) |
|
| 3923 | 3923 | { |
| 3924 | 3924 | $num_rows_in_query += current($row); |
| 3925 | 3925 | } |
@@ -3944,7 +3944,7 @@ discard block |
||
| 3944 | 3944 | * @return array Fetched data. |
| 3945 | 3945 | */ |
| 3946 | 3946 | function process_union_list_query($parent_bean, $query, |
| 3947 | - $row_offset, $limit= -1, $max_per_page = -1, $where = '', $subpanel_def, $query_row_count='', $secondary_queries = array()) |
|
| 3947 | + $row_offset, $limit = -1, $max_per_page = -1, $where = '', $subpanel_def, $query_row_count = '', $secondary_queries = array()) |
|
| 3948 | 3948 | |
| 3949 | 3949 | { |
| 3950 | 3950 | $db = DBManagerFactory::getInstance('listviews'); |
@@ -3953,52 +3953,52 @@ discard block |
||
| 3953 | 3953 | */ |
| 3954 | 3954 | $toEnd = strval($row_offset) == 'end'; |
| 3955 | 3955 | global $sugar_config; |
| 3956 | - $use_count_query=false; |
|
| 3957 | - $processing_collection=$subpanel_def->isCollection(); |
|
| 3956 | + $use_count_query = false; |
|
| 3957 | + $processing_collection = $subpanel_def->isCollection(); |
|
| 3958 | 3958 | |
| 3959 | 3959 | $GLOBALS['log']->debug("process_union_list_query: ".$query); |
| 3960 | - if($max_per_page == -1) |
|
| 3960 | + if ($max_per_page == -1) |
|
| 3961 | 3961 | { |
| 3962 | - $max_per_page = $sugar_config['list_max_entries_per_subpanel']; |
|
| 3962 | + $max_per_page = $sugar_config['list_max_entries_per_subpanel']; |
|
| 3963 | 3963 | } |
| 3964 | - if(empty($query_row_count)) |
|
| 3964 | + if (empty($query_row_count)) |
|
| 3965 | 3965 | { |
| 3966 | 3966 | $query_row_count = $query; |
| 3967 | 3967 | } |
| 3968 | - $distinct_position=strpos($query_row_count,"DISTINCT"); |
|
| 3968 | + $distinct_position = strpos($query_row_count, "DISTINCT"); |
|
| 3969 | 3969 | |
| 3970 | - if ($distinct_position!= false) |
|
| 3970 | + if ($distinct_position != false) |
|
| 3971 | 3971 | { |
| 3972 | - $use_count_query=true; |
|
| 3972 | + $use_count_query = true; |
|
| 3973 | 3973 | } |
| 3974 | 3974 | $performSecondQuery = true; |
| 3975 | - if(empty($sugar_config['disable_count_query']) || $toEnd) |
|
| 3975 | + if (empty($sugar_config['disable_count_query']) || $toEnd) |
|
| 3976 | 3976 | { |
| 3977 | - $rows_found = $this->_get_num_rows_in_query($query_row_count,$use_count_query); |
|
| 3978 | - if($rows_found < 1) |
|
| 3977 | + $rows_found = $this->_get_num_rows_in_query($query_row_count, $use_count_query); |
|
| 3978 | + if ($rows_found < 1) |
|
| 3979 | 3979 | { |
| 3980 | 3980 | $performSecondQuery = false; |
| 3981 | 3981 | } |
| 3982 | - if(!empty($rows_found) && (empty($limit) || $limit == -1)) |
|
| 3982 | + if (!empty($rows_found) && (empty($limit) || $limit == -1)) |
|
| 3983 | 3983 | { |
| 3984 | 3984 | $limit = $max_per_page; |
| 3985 | 3985 | } |
| 3986 | - if( $toEnd) |
|
| 3986 | + if ($toEnd) |
|
| 3987 | 3987 | { |
| 3988 | - $row_offset = (floor(($rows_found -1) / $limit)) * $limit; |
|
| 3988 | + $row_offset = (floor(($rows_found - 1) / $limit)) * $limit; |
|
| 3989 | 3989 | |
| 3990 | 3990 | } |
| 3991 | 3991 | } |
| 3992 | 3992 | else |
| 3993 | 3993 | { |
| 3994 | - if((empty($limit) || $limit == -1)) |
|
| 3994 | + if ((empty($limit) || $limit == -1)) |
|
| 3995 | 3995 | { |
| 3996 | 3996 | $limit = $max_per_page + 1; |
| 3997 | 3997 | $max_per_page = $limit; |
| 3998 | 3998 | } |
| 3999 | 3999 | } |
| 4000 | 4000 | |
| 4001 | - if(empty($row_offset)) |
|
| 4001 | + if (empty($row_offset)) |
|
| 4002 | 4002 | { |
| 4003 | 4003 | $row_offset = 0; |
| 4004 | 4004 | } |
@@ -4006,15 +4006,15 @@ discard block |
||
| 4006 | 4006 | $previous_offset = $row_offset - $max_per_page; |
| 4007 | 4007 | $next_offset = $row_offset + $max_per_page; |
| 4008 | 4008 | |
| 4009 | - if($performSecondQuery) |
|
| 4009 | + if ($performSecondQuery) |
|
| 4010 | 4010 | { |
| 4011 | - if(!empty($limit) && $limit != -1 && $limit != -99) |
|
| 4011 | + if (!empty($limit) && $limit != -1 && $limit != -99) |
|
| 4012 | 4012 | { |
| 4013 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $parent_bean->object_name list: "); |
|
| 4013 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $parent_bean->object_name list: "); |
|
| 4014 | 4014 | } |
| 4015 | 4015 | else |
| 4016 | 4016 | { |
| 4017 | - $result = $db->query($query,true,"Error retrieving $this->object_name list: "); |
|
| 4017 | + $result = $db->query($query, true, "Error retrieving $this->object_name list: "); |
|
| 4018 | 4018 | } |
| 4019 | 4019 | //use -99 to return all |
| 4020 | 4020 | |
@@ -4024,22 +4024,22 @@ discard block |
||
| 4024 | 4024 | |
| 4025 | 4025 | $post_retrieve = array(); |
| 4026 | 4026 | $isFirstTime = true; |
| 4027 | - while($row) |
|
| 4027 | + while ($row) |
|
| 4028 | 4028 | { |
| 4029 | 4029 | $function_fields = array(); |
| 4030 | - if(($index < $row_offset + $max_per_page || $max_per_page == -99)) |
|
| 4030 | + if (($index < $row_offset + $max_per_page || $max_per_page == -99)) |
|
| 4031 | 4031 | { |
| 4032 | 4032 | if ($processing_collection) |
| 4033 | 4033 | { |
| 4034 | - $current_bean =$subpanel_def->sub_subpanels[$row['panel_name']]->template_instance; |
|
| 4035 | - if(!$isFirstTime) |
|
| 4034 | + $current_bean = $subpanel_def->sub_subpanels[$row['panel_name']]->template_instance; |
|
| 4035 | + if (!$isFirstTime) |
|
| 4036 | 4036 | { |
| 4037 | 4037 | $class = get_class($subpanel_def->sub_subpanels[$row['panel_name']]->template_instance); |
| 4038 | 4038 | $current_bean = new $class(); |
| 4039 | 4039 | } |
| 4040 | 4040 | } else { |
| 4041 | - $current_bean=$subpanel_def->template_instance; |
|
| 4042 | - if(!$isFirstTime) |
|
| 4041 | + $current_bean = $subpanel_def->template_instance; |
|
| 4042 | + if (!$isFirstTime) |
|
| 4043 | 4043 | { |
| 4044 | 4044 | $class = get_class($subpanel_def->template_instance); |
| 4045 | 4045 | $current_bean = new $class(); |
@@ -4049,9 +4049,9 @@ discard block |
||
| 4049 | 4049 | //set the panel name in the bean instance. |
| 4050 | 4050 | if (isset($row['panel_name'])) |
| 4051 | 4051 | { |
| 4052 | - $current_bean->panel_name=$row['panel_name']; |
|
| 4052 | + $current_bean->panel_name = $row['panel_name']; |
|
| 4053 | 4053 | } |
| 4054 | - foreach($current_bean->field_defs as $field=>$value) |
|
| 4054 | + foreach ($current_bean->field_defs as $field=>$value) |
|
| 4055 | 4055 | { |
| 4056 | 4056 | |
| 4057 | 4057 | if (isset($row[$field])) |
@@ -4059,60 +4059,60 @@ discard block |
||
| 4059 | 4059 | $current_bean->$field = $this->convertField($row[$field], $value); |
| 4060 | 4060 | unset($row[$field]); |
| 4061 | 4061 | } |
| 4062 | - else if (isset($row[$this->table_name .'.'.$field])) |
|
| 4062 | + else if (isset($row[$this->table_name.'.'.$field])) |
|
| 4063 | 4063 | { |
| 4064 | - $current_bean->$field = $this->convertField($row[$this->table_name .'.'.$field], $value); |
|
| 4065 | - unset($row[$this->table_name .'.'.$field]); |
|
| 4064 | + $current_bean->$field = $this->convertField($row[$this->table_name.'.'.$field], $value); |
|
| 4065 | + unset($row[$this->table_name.'.'.$field]); |
|
| 4066 | 4066 | } |
| 4067 | 4067 | else |
| 4068 | 4068 | { |
| 4069 | 4069 | $current_bean->$field = ""; |
| 4070 | 4070 | unset($row[$field]); |
| 4071 | 4071 | } |
| 4072 | - if(isset($value['source']) && $value['source'] == 'function') |
|
| 4072 | + if (isset($value['source']) && $value['source'] == 'function') |
|
| 4073 | 4073 | { |
| 4074 | - $function_fields[]=$field; |
|
| 4074 | + $function_fields[] = $field; |
|
| 4075 | 4075 | } |
| 4076 | 4076 | } |
| 4077 | - foreach($row as $key=>$value) |
|
| 4077 | + foreach ($row as $key=>$value) |
|
| 4078 | 4078 | { |
| 4079 | 4079 | $current_bean->$key = $value; |
| 4080 | 4080 | } |
| 4081 | - foreach($function_fields as $function_field) |
|
| 4081 | + foreach ($function_fields as $function_field) |
|
| 4082 | 4082 | { |
| 4083 | 4083 | $value = $current_bean->field_defs[$function_field]; |
| 4084 | 4084 | $can_execute = true; |
| 4085 | 4085 | $execute_params = array(); |
| 4086 | 4086 | $execute_function = array(); |
| 4087 | - if(!empty($value['function_class'])) |
|
| 4087 | + if (!empty($value['function_class'])) |
|
| 4088 | 4088 | { |
| 4089 | - $execute_function[] = $value['function_class']; |
|
| 4090 | - $execute_function[] = $value['function_name']; |
|
| 4089 | + $execute_function[] = $value['function_class']; |
|
| 4090 | + $execute_function[] = $value['function_name']; |
|
| 4091 | 4091 | } |
| 4092 | 4092 | else |
| 4093 | 4093 | { |
| 4094 | - $execute_function = $value['function_name']; |
|
| 4094 | + $execute_function = $value['function_name']; |
|
| 4095 | 4095 | } |
| 4096 | - foreach($value['function_params'] as $param ) |
|
| 4096 | + foreach ($value['function_params'] as $param) |
|
| 4097 | 4097 | { |
| 4098 | - if (empty($value['function_params_source']) or $value['function_params_source']=='parent') |
|
| 4098 | + if (empty($value['function_params_source']) or $value['function_params_source'] == 'parent') |
|
| 4099 | 4099 | { |
| 4100 | - if(empty($this->$param)) |
|
| 4100 | + if (empty($this->$param)) |
|
| 4101 | 4101 | { |
| 4102 | 4102 | $can_execute = false; |
| 4103 | - } else if($param == '$this') { |
|
| 4103 | + } else if ($param == '$this') { |
|
| 4104 | 4104 | $execute_params[] = $this; |
| 4105 | 4105 | } |
| 4106 | 4106 | else |
| 4107 | 4107 | { |
| 4108 | 4108 | $execute_params[] = $this->$param; |
| 4109 | 4109 | } |
| 4110 | - } else if ($value['function_params_source']=='this') |
|
| 4110 | + } else if ($value['function_params_source'] == 'this') |
|
| 4111 | 4111 | { |
| 4112 | - if(empty($current_bean->$param)) |
|
| 4112 | + if (empty($current_bean->$param)) |
|
| 4113 | 4113 | { |
| 4114 | 4114 | $can_execute = false; |
| 4115 | - } else if($param == '$this') { |
|
| 4115 | + } else if ($param == '$this') { |
|
| 4116 | 4116 | $execute_params[] = $current_bean; |
| 4117 | 4117 | } |
| 4118 | 4118 | else |
@@ -4126,18 +4126,18 @@ discard block |
||
| 4126 | 4126 | } |
| 4127 | 4127 | |
| 4128 | 4128 | } |
| 4129 | - if($can_execute) |
|
| 4129 | + if ($can_execute) |
|
| 4130 | 4130 | { |
| 4131 | - if(!empty($value['function_require'])) |
|
| 4131 | + if (!empty($value['function_require'])) |
|
| 4132 | 4132 | { |
| 4133 | 4133 | require_once($value['function_require']); |
| 4134 | 4134 | } |
| 4135 | 4135 | $current_bean->$function_field = call_user_func_array($execute_function, $execute_params); |
| 4136 | 4136 | } |
| 4137 | 4137 | } |
| 4138 | - if(!empty($current_bean->parent_type) && !empty($current_bean->parent_id)) |
|
| 4138 | + if (!empty($current_bean->parent_type) && !empty($current_bean->parent_id)) |
|
| 4139 | 4139 | { |
| 4140 | - if(!isset($post_retrieve[$current_bean->parent_type])) |
|
| 4140 | + if (!isset($post_retrieve[$current_bean->parent_type])) |
|
| 4141 | 4141 | { |
| 4142 | 4142 | $post_retrieve[$current_bean->parent_type] = array(); |
| 4143 | 4143 | } |
@@ -4151,22 +4151,22 @@ discard block |
||
| 4151 | 4151 | $row = $db->fetchByAssoc($result); |
| 4152 | 4152 | } |
| 4153 | 4153 | //now handle retrieving many-to-many relationships |
| 4154 | - if(!empty($list)) |
|
| 4154 | + if (!empty($list)) |
|
| 4155 | 4155 | { |
| 4156 | - foreach($secondary_queries as $query2) |
|
| 4156 | + foreach ($secondary_queries as $query2) |
|
| 4157 | 4157 | { |
| 4158 | 4158 | $result2 = $db->query($query2); |
| 4159 | 4159 | |
| 4160 | 4160 | $row2 = $db->fetchByAssoc($result2); |
| 4161 | - while($row2) |
|
| 4161 | + while ($row2) |
|
| 4162 | 4162 | { |
| 4163 | 4163 | $id_ref = $row2['ref_id']; |
| 4164 | 4164 | |
| 4165 | - if(isset($list[$id_ref])) |
|
| 4165 | + if (isset($list[$id_ref])) |
|
| 4166 | 4166 | { |
| 4167 | - foreach($row2 as $r2key=>$r2value) |
|
| 4167 | + foreach ($row2 as $r2key=>$r2value) |
|
| 4168 | 4168 | { |
| 4169 | - if($r2key != 'ref_id') |
|
| 4169 | + if ($r2key != 'ref_id') |
|
| 4170 | 4170 | { |
| 4171 | 4171 | $list[$id_ref]->$r2key = $r2value; |
| 4172 | 4172 | } |
@@ -4178,7 +4178,7 @@ discard block |
||
| 4178 | 4178 | |
| 4179 | 4179 | } |
| 4180 | 4180 | |
| 4181 | - if(isset($post_retrieve)) |
|
| 4181 | + if (isset($post_retrieve)) |
|
| 4182 | 4182 | { |
| 4183 | 4183 | $parent_fields = $this->retrieve_parent_fields($post_retrieve); |
| 4184 | 4184 | } |
@@ -4186,16 +4186,16 @@ discard block |
||
| 4186 | 4186 | { |
| 4187 | 4187 | $parent_fields = array(); |
| 4188 | 4188 | } |
| 4189 | - if(!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
| 4189 | + if (!empty($sugar_config['disable_count_query']) && !empty($limit)) |
|
| 4190 | 4190 | { |
| 4191 | 4191 | //C.L. Bug 43535 - Use the $index value to set the $rows_found value here |
| 4192 | 4192 | $rows_found = isset($index) ? $index : $row_offset + count($list); |
| 4193 | 4193 | |
| 4194 | - if(count($list) >= $limit) |
|
| 4194 | + if (count($list) >= $limit) |
|
| 4195 | 4195 | { |
| 4196 | 4196 | array_pop($list); |
| 4197 | 4197 | } |
| 4198 | - if(!$toEnd) |
|
| 4198 | + if (!$toEnd) |
|
| 4199 | 4199 | { |
| 4200 | 4200 | $next_offset--; |
| 4201 | 4201 | $previous_offset++; |
@@ -4204,7 +4204,7 @@ discard block |
||
| 4204 | 4204 | } |
| 4205 | 4205 | else |
| 4206 | 4206 | { |
| 4207 | - $row_found = 0; |
|
| 4207 | + $row_found = 0; |
|
| 4208 | 4208 | $parent_fields = array(); |
| 4209 | 4209 | } |
| 4210 | 4210 | $response = array(); |
@@ -4213,7 +4213,7 @@ discard block |
||
| 4213 | 4213 | $response['row_count'] = $rows_found; |
| 4214 | 4214 | $response['next_offset'] = $next_offset; |
| 4215 | 4215 | $response['previous_offset'] = $previous_offset; |
| 4216 | - $response['current_offset'] = $row_offset ; |
|
| 4216 | + $response['current_offset'] = $row_offset; |
|
| 4217 | 4217 | $response['query'] = $query; |
| 4218 | 4218 | |
| 4219 | 4219 | return $response; |
@@ -4233,35 +4233,35 @@ discard block |
||
| 4233 | 4233 | * @return array Fetched data. |
| 4234 | 4234 | * |
| 4235 | 4235 | */ |
| 4236 | - function process_detail_query($query, $row_offset, $limit= -1, $max_per_page = -1, $where = '', $offset = 0) |
|
| 4236 | + function process_detail_query($query, $row_offset, $limit = -1, $max_per_page = -1, $where = '', $offset = 0) |
|
| 4237 | 4237 | { |
| 4238 | 4238 | global $sugar_config; |
| 4239 | 4239 | $GLOBALS['log']->debug("process_detail_query: ".$query); |
| 4240 | - if($max_per_page == -1) |
|
| 4240 | + if ($max_per_page == -1) |
|
| 4241 | 4241 | { |
| 4242 | - $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
| 4242 | + $max_per_page = $sugar_config['list_max_entries_per_page']; |
|
| 4243 | 4243 | } |
| 4244 | 4244 | |
| 4245 | 4245 | // Check to see if we have a count query available. |
| 4246 | 4246 | $count_query = $this->create_list_count_query($query); |
| 4247 | 4247 | |
| 4248 | - if(!empty($count_query) && (empty($limit) || $limit == -1)) |
|
| 4248 | + if (!empty($count_query) && (empty($limit) || $limit == -1)) |
|
| 4249 | 4249 | { |
| 4250 | 4250 | // We have a count query. Run it and get the results. |
| 4251 | 4251 | $result = $this->db->query($count_query, true, "Error running count query for $this->object_name List: "); |
| 4252 | 4252 | $assoc = $this->db->fetchByAssoc($result); |
| 4253 | - if(!empty($assoc['c'])) |
|
| 4253 | + if (!empty($assoc['c'])) |
|
| 4254 | 4254 | { |
| 4255 | 4255 | $total_rows = $assoc['c']; |
| 4256 | 4256 | } |
| 4257 | 4257 | } |
| 4258 | 4258 | |
| 4259 | - if(empty($row_offset)) |
|
| 4259 | + if (empty($row_offset)) |
|
| 4260 | 4260 | { |
| 4261 | 4261 | $row_offset = 0; |
| 4262 | 4262 | } |
| 4263 | 4263 | |
| 4264 | - $result = $this->db->limitQuery($query, $offset, 1, true,"Error retrieving $this->object_name list: "); |
|
| 4264 | + $result = $this->db->limitQuery($query, $offset, 1, true, "Error retrieving $this->object_name list: "); |
|
| 4265 | 4265 | |
| 4266 | 4266 | $previous_offset = $row_offset - $max_per_page; |
| 4267 | 4267 | $next_offset = $row_offset + $max_per_page; |
@@ -4272,7 +4272,7 @@ discard block |
||
| 4272 | 4272 | $response = Array(); |
| 4273 | 4273 | $response['bean'] = $this; |
| 4274 | 4274 | if (empty($total_rows)) |
| 4275 | - $total_rows=0; |
|
| 4275 | + $total_rows = 0; |
|
| 4276 | 4276 | $response['row_count'] = $total_rows; |
| 4277 | 4277 | $response['next_offset'] = $next_offset; |
| 4278 | 4278 | $response['previous_offset'] = $previous_offset; |
@@ -4289,12 +4289,12 @@ discard block |
||
| 4289 | 4289 | * @return array Fetched data. |
| 4290 | 4290 | * |
| 4291 | 4291 | */ |
| 4292 | - function process_full_list_query($query, $check_date=false) |
|
| 4292 | + function process_full_list_query($query, $check_date = false) |
|
| 4293 | 4293 | { |
| 4294 | 4294 | |
| 4295 | 4295 | $GLOBALS['log']->debug("process_full_list_query: query is ".$query); |
| 4296 | 4296 | $result = $this->db->query($query, false); |
| 4297 | - $GLOBALS['log']->debug("process_full_list_query: result is ".print_r($result,true)); |
|
| 4297 | + $GLOBALS['log']->debug("process_full_list_query: result is ".print_r($result, true)); |
|
| 4298 | 4298 | $class = get_class($this); |
| 4299 | 4299 | $isFirstTime = true; |
| 4300 | 4300 | $bean = new $class(); |
@@ -4303,13 +4303,13 @@ discard block |
||
| 4303 | 4303 | while (($row = $bean->db->fetchByAssoc($result)) != null) |
| 4304 | 4304 | { |
| 4305 | 4305 | $row = $this->convertRow($row); |
| 4306 | - if(!$isFirstTime) |
|
| 4306 | + if (!$isFirstTime) |
|
| 4307 | 4307 | { |
| 4308 | 4308 | $bean = new $class(); |
| 4309 | 4309 | } |
| 4310 | 4310 | $isFirstTime = false; |
| 4311 | 4311 | |
| 4312 | - foreach($bean->field_defs as $field=>$value) |
|
| 4312 | + foreach ($bean->field_defs as $field=>$value) |
|
| 4313 | 4313 | { |
| 4314 | 4314 | if (isset($row[$field])) |
| 4315 | 4315 | { |
@@ -4321,7 +4321,7 @@ discard block |
||
| 4321 | 4321 | $bean->$field = ''; |
| 4322 | 4322 | } |
| 4323 | 4323 | } |
| 4324 | - if($check_date) |
|
| 4324 | + if ($check_date) |
|
| 4325 | 4325 | { |
| 4326 | 4326 | $bean->processed_dates_times = array(); |
| 4327 | 4327 | $bean->check_date_relationships_load(); |
@@ -4346,10 +4346,10 @@ discard block |
||
| 4346 | 4346 | * @param string $current_module - String value of the module being processed. |
| 4347 | 4347 | * @param string $current_view - String value of the current view |
| 4348 | 4348 | */ |
| 4349 | - function track_view($user_id, $current_module, $current_view='') |
|
| 4349 | + function track_view($user_id, $current_module, $current_view = '') |
|
| 4350 | 4350 | { |
| 4351 | 4351 | $trackerManager = TrackerManager::getInstance(); |
| 4352 | - if($monitor = $trackerManager->getMonitor('tracker')){ |
|
| 4352 | + if ($monitor = $trackerManager->getMonitor('tracker')) { |
|
| 4353 | 4353 | $monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb()); |
| 4354 | 4354 | $monitor->setValue('user_id', $user_id); |
| 4355 | 4355 | $monitor->setValue('module_name', $current_module); |
@@ -4378,8 +4378,8 @@ discard block |
||
| 4378 | 4378 | * account for instance. This method is only used for populating extra fields |
| 4379 | 4379 | * in lists. |
| 4380 | 4380 | */ |
| 4381 | - function fill_in_additional_list_fields(){ |
|
| 4382 | - if(!empty($this->field_defs['parent_name']) && empty($this->parent_name)){ |
|
| 4381 | + function fill_in_additional_list_fields() { |
|
| 4382 | + if (!empty($this->field_defs['parent_name']) && empty($this->parent_name)) { |
|
| 4383 | 4383 | $this->fill_in_additional_parent_fields(); |
| 4384 | 4384 | } |
| 4385 | 4385 | } |
@@ -4393,17 +4393,17 @@ discard block |
||
| 4393 | 4393 | */ |
| 4394 | 4394 | function fill_in_additional_detail_fields() |
| 4395 | 4395 | { |
| 4396 | - if(!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)){ |
|
| 4396 | + if (!empty($this->field_defs['assigned_user_name']) && !empty($this->assigned_user_id)) { |
|
| 4397 | 4397 | |
| 4398 | 4398 | $this->assigned_user_name = get_assigned_user_name($this->assigned_user_id); |
| 4399 | 4399 | |
| 4400 | 4400 | } |
| 4401 | - if(!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
| 4401 | + if (!empty($this->field_defs['created_by']) && !empty($this->created_by)) |
|
| 4402 | 4402 | $this->created_by_name = get_assigned_user_name($this->created_by); |
| 4403 | - if(!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
| 4403 | + if (!empty($this->field_defs['modified_user_id']) && !empty($this->modified_user_id)) |
|
| 4404 | 4404 | $this->modified_by_name = get_assigned_user_name($this->modified_user_id); |
| 4405 | 4405 | |
| 4406 | - if(!empty($this->field_defs['parent_name'])){ |
|
| 4406 | + if (!empty($this->field_defs['parent_name'])) { |
|
| 4407 | 4407 | $this->fill_in_additional_parent_fields(); |
| 4408 | 4408 | } |
| 4409 | 4409 | } |
@@ -4414,17 +4414,17 @@ discard block |
||
| 4414 | 4414 | */ |
| 4415 | 4415 | function fill_in_additional_parent_fields() { |
| 4416 | 4416 | |
| 4417 | - if(!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id){ |
|
| 4417 | + if (!empty($this->parent_id) && !empty($this->last_parent_id) && $this->last_parent_id == $this->parent_id) { |
|
| 4418 | 4418 | return false; |
| 4419 | - }else{ |
|
| 4419 | + } else { |
|
| 4420 | 4420 | $this->parent_name = ''; |
| 4421 | 4421 | } |
| 4422 | - if(!empty($this->parent_type)) { |
|
| 4422 | + if (!empty($this->parent_type)) { |
|
| 4423 | 4423 | $this->last_parent_id = $this->parent_id; |
| 4424 | 4424 | $this->getRelatedFields($this->parent_type, $this->parent_id, array('name'=>'parent_name', 'document_name' => 'parent_document_name', 'first_name'=>'parent_first_name', 'last_name'=>'parent_last_name')); |
| 4425 | - if(!empty($this->parent_first_name) || !empty($this->parent_last_name) ){ |
|
| 4425 | + if (!empty($this->parent_first_name) || !empty($this->parent_last_name)) { |
|
| 4426 | 4426 | $this->parent_name = $GLOBALS['locale']->getLocaleFormattedName($this->parent_first_name, $this->parent_last_name); |
| 4427 | - } else if(!empty($this->parent_document_name)){ |
|
| 4427 | + } else if (!empty($this->parent_document_name)) { |
|
| 4428 | 4428 | $this->parent_name = $this->parent_document_name; |
| 4429 | 4429 | } |
| 4430 | 4430 | } |
@@ -4434,7 +4434,7 @@ discard block |
||
| 4434 | 4434 | * Fill in a link field |
| 4435 | 4435 | */ |
| 4436 | 4436 | |
| 4437 | - function fill_in_link_field( $linkFieldName , $def) |
|
| 4437 | + function fill_in_link_field($linkFieldName, $def) |
|
| 4438 | 4438 | { |
| 4439 | 4439 | $idField = $linkFieldName; |
| 4440 | 4440 | //If the id_name provided really was an ID, don't try to load it as a link. Use the normal link |
@@ -4444,8 +4444,8 @@ discard block |
||
| 4444 | 4444 | } |
| 4445 | 4445 | if ($this->load_relationship($linkFieldName)) |
| 4446 | 4446 | { |
| 4447 | - $list=$this->$linkFieldName->get(); |
|
| 4448 | - $this->$idField = '' ; // match up with null value in $this->populateFromRow() |
|
| 4447 | + $list = $this->$linkFieldName->get(); |
|
| 4448 | + $this->$idField = ''; // match up with null value in $this->populateFromRow() |
|
| 4449 | 4449 | if (!empty($list)) |
| 4450 | 4450 | $this->$idField = $list[0]; |
| 4451 | 4451 | } |
@@ -4454,22 +4454,22 @@ discard block |
||
| 4454 | 4454 | /** |
| 4455 | 4455 | * Fill in fields where type = relate |
| 4456 | 4456 | */ |
| 4457 | - function fill_in_relationship_fields(){ |
|
| 4457 | + function fill_in_relationship_fields() { |
|
| 4458 | 4458 | global $fill_in_rel_depth; |
| 4459 | - if(empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
|
| 4459 | + if (empty($fill_in_rel_depth) || $fill_in_rel_depth < 0) |
|
| 4460 | 4460 | $fill_in_rel_depth = 0; |
| 4461 | 4461 | |
| 4462 | - if($fill_in_rel_depth > 1) |
|
| 4462 | + if ($fill_in_rel_depth > 1) |
|
| 4463 | 4463 | return; |
| 4464 | 4464 | |
| 4465 | 4465 | $fill_in_rel_depth++; |
| 4466 | 4466 | |
| 4467 | - foreach($this->field_defs as $field) |
|
| 4467 | + foreach ($this->field_defs as $field) |
|
| 4468 | 4468 | { |
| 4469 | - if(0 == strcmp($field['type'],'relate') && !empty($field['module'])) |
|
| 4469 | + if (0 == strcmp($field['type'], 'relate') && !empty($field['module'])) |
|
| 4470 | 4470 | { |
| 4471 | 4471 | $name = $field['name']; |
| 4472 | - if(empty($this->$name)) |
|
| 4472 | + if (empty($this->$name)) |
|
| 4473 | 4473 | { |
| 4474 | 4474 | // set the value of this relate field in this bean ($this->$field['name']) to the value of the 'name' field in the related module for the record identified by the value of $this->$field['id_name'] |
| 4475 | 4475 | $related_module = $field['module']; |
@@ -4479,11 +4479,11 @@ discard block |
||
| 4479 | 4479 | { |
| 4480 | 4480 | $this->fill_in_link_field($id_name, $field); |
| 4481 | 4481 | } |
| 4482 | - if(!empty($this->$id_name) && ( $this->object_name != $related_module || ( $this->object_name == $related_module && $this->$id_name != $this->id ))){ |
|
| 4483 | - if(isset($GLOBALS['beanList'][ $related_module])){ |
|
| 4482 | + if (!empty($this->$id_name) && ($this->object_name != $related_module || ($this->object_name == $related_module && $this->$id_name != $this->id))) { |
|
| 4483 | + if (isset($GLOBALS['beanList'][$related_module])) { |
|
| 4484 | 4484 | $class = $GLOBALS['beanList'][$related_module]; |
| 4485 | 4485 | |
| 4486 | - if(!empty($this->$id_name) && file_exists($GLOBALS['beanFiles'][$class]) && isset($this->$name)){ |
|
| 4486 | + if (!empty($this->$id_name) && file_exists($GLOBALS['beanFiles'][$class]) && isset($this->$name)) { |
|
| 4487 | 4487 | require_once($GLOBALS['beanFiles'][$class]); |
| 4488 | 4488 | $mod = new $class(); |
| 4489 | 4489 | |
@@ -4500,17 +4500,17 @@ discard block |
||
| 4500 | 4500 | } |
| 4501 | 4501 | } |
| 4502 | 4502 | } |
| 4503 | - if(!empty($this->$id_name) && isset($this->$name)) |
|
| 4503 | + if (!empty($this->$id_name) && isset($this->$name)) |
|
| 4504 | 4504 | { |
| 4505 | - if(!isset($field['additionalFields'])) |
|
| 4505 | + if (!isset($field['additionalFields'])) |
|
| 4506 | 4506 | $field['additionalFields'] = array(); |
| 4507 | - if(!empty($field['rname'])) |
|
| 4507 | + if (!empty($field['rname'])) |
|
| 4508 | 4508 | { |
| 4509 | - $field['additionalFields'][$field['rname']]= $name; |
|
| 4509 | + $field['additionalFields'][$field['rname']] = $name; |
|
| 4510 | 4510 | } |
| 4511 | 4511 | else |
| 4512 | 4512 | { |
| 4513 | - $field['additionalFields']['name']= $name; |
|
| 4513 | + $field['additionalFields']['name'] = $name; |
|
| 4514 | 4514 | } |
| 4515 | 4515 | $this->getRelatedFields($related_module, $this->$id_name, $field['additionalFields']); |
| 4516 | 4516 | } |
@@ -4540,7 +4540,7 @@ discard block |
||
| 4540 | 4540 | global $current_user; |
| 4541 | 4541 | $date_modified = $GLOBALS['timedate']->nowDb(); |
| 4542 | 4542 | $id = $this->db->quote($id); |
| 4543 | - if(isset($_SESSION['show_deleted'])) |
|
| 4543 | + if (isset($_SESSION['show_deleted'])) |
|
| 4544 | 4544 | { |
| 4545 | 4545 | $this->mark_undeleted($id); |
| 4546 | 4546 | } |
@@ -4551,7 +4551,7 @@ discard block |
||
| 4551 | 4551 | $this->call_custom_logic("before_delete", $custom_logic_arguments); |
| 4552 | 4552 | $this->deleted = 1; |
| 4553 | 4553 | $this->mark_relationships_deleted($id); |
| 4554 | - if ( isset($this->field_defs['modified_user_id']) ) { |
|
| 4554 | + if (isset($this->field_defs['modified_user_id'])) { |
|
| 4555 | 4555 | if (!empty($current_user)) { |
| 4556 | 4556 | $this->modified_user_id = $current_user->id; |
| 4557 | 4557 | } else { |
@@ -4561,7 +4561,7 @@ discard block |
||
| 4561 | 4561 | } else { |
| 4562 | 4562 | $query = "UPDATE $this->table_name set deleted=1 , date_modified = '$date_modified' where id='$id'"; |
| 4563 | 4563 | } |
| 4564 | - $this->db->query($query, true,"Error marking record deleted: "); |
|
| 4564 | + $this->db->query($query, true, "Error marking record deleted: "); |
|
| 4565 | 4565 | |
| 4566 | 4566 | SugarRelationship::resaveRelatedBeans(); |
| 4567 | 4567 | |
@@ -4589,8 +4589,8 @@ discard block |
||
| 4589 | 4589 | $this->call_custom_logic("before_restore", $custom_logic_arguments); |
| 4590 | 4590 | |
| 4591 | 4591 | $date_modified = $GLOBALS['timedate']->nowDb(); |
| 4592 | - $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='" . $this->db->quote($id) ."'"; |
|
| 4593 | - $this->db->query($query, true,"Error marking record undeleted: "); |
|
| 4592 | + $query = "UPDATE $this->table_name set deleted=0 , date_modified = '$date_modified' where id='".$this->db->quote($id)."'"; |
|
| 4593 | + $this->db->query($query, true, "Error marking record undeleted: "); |
|
| 4594 | 4594 | |
| 4595 | 4595 | $this->restoreFiles(); |
| 4596 | 4596 | |
@@ -4643,19 +4643,19 @@ discard block |
||
| 4643 | 4643 | |
| 4644 | 4644 | $directory = $this->deleteFileDirectory(); |
| 4645 | 4645 | |
| 4646 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
| 4646 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
| 4647 | 4647 | if (!$isCreated) { |
| 4648 | - sugar_mkdir('upload://deleted/' . $directory, 0777, true); |
|
| 4649 | - $isCreated = sugar_is_dir('upload://deleted/' . $directory); |
|
| 4648 | + sugar_mkdir('upload://deleted/'.$directory, 0777, true); |
|
| 4649 | + $isCreated = sugar_is_dir('upload://deleted/'.$directory); |
|
| 4650 | 4650 | } |
| 4651 | 4651 | if (!$isCreated) { |
| 4652 | 4652 | return false; |
| 4653 | 4653 | } |
| 4654 | 4654 | |
| 4655 | 4655 | foreach ($files as $file) { |
| 4656 | - if (file_exists('upload://' . $file)) { |
|
| 4657 | - if (!sugar_rename('upload://' . $file, 'upload://deleted/' . $directory . '/' . $file)) { |
|
| 4658 | - $GLOBALS['log']->error('Could not move file ' . $file . ' to deleted directory'); |
|
| 4656 | + if (file_exists('upload://'.$file)) { |
|
| 4657 | + if (!sugar_rename('upload://'.$file, 'upload://deleted/'.$directory.'/'.$file)) { |
|
| 4658 | + $GLOBALS['log']->error('Could not move file '.$file.' to deleted directory'); |
|
| 4659 | 4659 | } |
| 4660 | 4660 | } |
| 4661 | 4661 | } |
@@ -4675,7 +4675,7 @@ discard block |
||
| 4675 | 4675 | } |
| 4676 | 4676 | if (empty($record['id'])) { |
| 4677 | 4677 | $record['id'] = $db->quoted(create_guid()); |
| 4678 | - $db->query('INSERT INTO cron_remove_documents (' . implode(', ', array_keys($record)) . ') VALUES(' . implode(', ', $record) . ')'); |
|
| 4678 | + $db->query('INSERT INTO cron_remove_documents ('.implode(', ', array_keys($record)).') VALUES('.implode(', ', $record).')'); |
|
| 4679 | 4679 | } else { |
| 4680 | 4680 | $db->query("UPDATE cron_remove_documents SET date_modified={$record['date_modified']} WHERE id={$record['id']}"); |
| 4681 | 4681 | } |
@@ -4704,9 +4704,9 @@ discard block |
||
| 4704 | 4704 | $directory = $this->deleteFileDirectory(); |
| 4705 | 4705 | |
| 4706 | 4706 | foreach ($files as $file) { |
| 4707 | - if (sugar_is_file('upload://deleted/' . $directory . '/' . $file)) { |
|
| 4708 | - if (!sugar_rename('upload://deleted/' . $directory . '/' . $file, 'upload://' . $file)) { |
|
| 4709 | - $GLOBALS['log']->error('Could not move file ' . $directory . '/' . $file . ' from deleted directory'); |
|
| 4707 | + if (sugar_is_file('upload://deleted/'.$directory.'/'.$file)) { |
|
| 4708 | + if (!sugar_rename('upload://deleted/'.$directory.'/'.$file, 'upload://'.$file)) { |
|
| 4709 | + $GLOBALS['log']->error('Could not move file '.$directory.'/'.$file.' from deleted directory'); |
|
| 4710 | 4710 | } |
| 4711 | 4711 | } |
| 4712 | 4712 | } |
@@ -4715,7 +4715,7 @@ discard block |
||
| 4715 | 4715 | * @var DBManager $db |
| 4716 | 4716 | */ |
| 4717 | 4717 | global $db; |
| 4718 | - $db->query('DELETE FROM cron_remove_documents WHERE bean_id=' . $db->quoted($this->id)); |
|
| 4718 | + $db->query('DELETE FROM cron_remove_documents WHERE bean_id='.$db->quoted($this->id)); |
|
| 4719 | 4719 | |
| 4720 | 4720 | return true; |
| 4721 | 4721 | } |
@@ -4803,9 +4803,9 @@ discard block |
||
| 4803 | 4803 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
| 4804 | 4804 | $db = DBManagerFactory::getInstance('listviews'); |
| 4805 | 4805 | |
| 4806 | - if(!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) |
|
| 4806 | + if (!empty($row_offset) && $row_offset != 0 && !empty($limit) && $limit != -1) |
|
| 4807 | 4807 | { |
| 4808 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $template->object_name list: "); |
|
| 4808 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $template->object_name list: "); |
|
| 4809 | 4809 | } |
| 4810 | 4810 | else |
| 4811 | 4811 | { |
@@ -4815,16 +4815,16 @@ discard block |
||
| 4815 | 4815 | $list = Array(); |
| 4816 | 4816 | $isFirstTime = true; |
| 4817 | 4817 | $class = get_class($template); |
| 4818 | - while($row = $this->db->fetchByAssoc($result)) |
|
| 4818 | + while ($row = $this->db->fetchByAssoc($result)) |
|
| 4819 | 4819 | { |
| 4820 | - if(!$isFirstTime) |
|
| 4820 | + if (!$isFirstTime) |
|
| 4821 | 4821 | { |
| 4822 | 4822 | $template = new $class(); |
| 4823 | 4823 | } |
| 4824 | 4824 | $isFirstTime = false; |
| 4825 | 4825 | $record = $template->retrieve($row['id']); |
| 4826 | 4826 | |
| 4827 | - if($record != null) |
|
| 4827 | + if ($record != null) |
|
| 4828 | 4828 | { |
| 4829 | 4829 | // this copies the object into the array |
| 4830 | 4830 | $list[] = $template; |
@@ -4842,12 +4842,12 @@ discard block |
||
| 4842 | 4842 | * @param string $query - the query that should be executed to build the list |
| 4843 | 4843 | * @param object $template - The object that should be used to copy the records. |
| 4844 | 4844 | */ |
| 4845 | - function build_related_list_where($query, &$template, $where='', $in='', $order_by, $limit='', $row_offset = 0) |
|
| 4845 | + function build_related_list_where($query, &$template, $where = '', $in = '', $order_by, $limit = '', $row_offset = 0) |
|
| 4846 | 4846 | { |
| 4847 | 4847 | $db = DBManagerFactory::getInstance('listviews'); |
| 4848 | 4848 | // No need to do an additional query |
| 4849 | 4849 | $GLOBALS['log']->debug("Finding linked records $this->object_name: ".$query); |
| 4850 | - if(empty($in) && !empty($query)) |
|
| 4850 | + if (empty($in) && !empty($query)) |
|
| 4851 | 4851 | { |
| 4852 | 4852 | $idList = $this->build_related_in($query); |
| 4853 | 4853 | $in = $idList['in']; |
@@ -4863,19 +4863,19 @@ discard block |
||
| 4863 | 4863 | $query .= $custom_join['join']; |
| 4864 | 4864 | |
| 4865 | 4865 | $query .= " WHERE deleted=0 AND id IN $in"; |
| 4866 | - if(!empty($where)) |
|
| 4866 | + if (!empty($where)) |
|
| 4867 | 4867 | { |
| 4868 | 4868 | $query .= " AND $where"; |
| 4869 | 4869 | } |
| 4870 | 4870 | |
| 4871 | 4871 | |
| 4872 | - if(!empty($order_by)) |
|
| 4872 | + if (!empty($order_by)) |
|
| 4873 | 4873 | { |
| 4874 | 4874 | $query .= "ORDER BY $order_by"; |
| 4875 | 4875 | } |
| 4876 | 4876 | if (!empty($limit)) |
| 4877 | 4877 | { |
| 4878 | - $result = $db->limitQuery($query, $row_offset, $limit,true,"Error retrieving $this->object_name list: "); |
|
| 4878 | + $result = $db->limitQuery($query, $row_offset, $limit, true, "Error retrieving $this->object_name list: "); |
|
| 4879 | 4879 | } |
| 4880 | 4880 | else |
| 4881 | 4881 | { |
@@ -4887,16 +4887,16 @@ discard block |
||
| 4887 | 4887 | $class = get_class($template); |
| 4888 | 4888 | |
| 4889 | 4889 | $disable_security_flag = ($template->disable_row_level_security) ? true : false; |
| 4890 | - while($row = $db->fetchByAssoc($result)) |
|
| 4890 | + while ($row = $db->fetchByAssoc($result)) |
|
| 4891 | 4891 | { |
| 4892 | - if(!$isFirstTime) |
|
| 4892 | + if (!$isFirstTime) |
|
| 4893 | 4893 | { |
| 4894 | 4894 | $template = new $class(); |
| 4895 | 4895 | $template->disable_row_level_security = $disable_security_flag; |
| 4896 | 4896 | } |
| 4897 | 4897 | $isFirstTime = false; |
| 4898 | 4898 | $record = $template->retrieve($row['id']); |
| 4899 | - if($record != null) |
|
| 4899 | + if ($record != null) |
|
| 4900 | 4900 | { |
| 4901 | 4901 | // this copies the object into the array |
| 4902 | 4902 | $list[] = $template; |
@@ -4917,22 +4917,22 @@ discard block |
||
| 4917 | 4917 | $idList = array(); |
| 4918 | 4918 | $result = $this->db->query($query, true); |
| 4919 | 4919 | $ids = ''; |
| 4920 | - while($row = $this->db->fetchByAssoc($result)) |
|
| 4920 | + while ($row = $this->db->fetchByAssoc($result)) |
|
| 4921 | 4921 | { |
| 4922 | 4922 | $idList[] = $row['id']; |
| 4923 | - if(empty($ids)) |
|
| 4923 | + if (empty($ids)) |
|
| 4924 | 4924 | { |
| 4925 | - $ids = "('" . $row['id'] . "'"; |
|
| 4925 | + $ids = "('".$row['id']."'"; |
|
| 4926 | 4926 | } |
| 4927 | 4927 | else |
| 4928 | 4928 | { |
| 4929 | - $ids .= ",'" . $row['id'] . "'"; |
|
| 4929 | + $ids .= ",'".$row['id']."'"; |
|
| 4930 | 4930 | } |
| 4931 | 4931 | } |
| 4932 | - if(empty($ids)) |
|
| 4932 | + if (empty($ids)) |
|
| 4933 | 4933 | { |
| 4934 | 4934 | $ids = "('')"; |
| 4935 | - }else{ |
|
| 4935 | + } else { |
|
| 4936 | 4936 | $ids .= ')'; |
| 4937 | 4937 | } |
| 4938 | 4938 | |
@@ -4958,16 +4958,16 @@ discard block |
||
| 4958 | 4958 | $list = Array(); |
| 4959 | 4959 | $isFirstTime = true; |
| 4960 | 4960 | $class = get_class($template); |
| 4961 | - while($row = $this->db->fetchByAssoc($result)) |
|
| 4961 | + while ($row = $this->db->fetchByAssoc($result)) |
|
| 4962 | 4962 | { |
| 4963 | 4963 | // Create a blank copy |
| 4964 | 4964 | $copy = $template; |
| 4965 | - if(!$isFirstTime) |
|
| 4965 | + if (!$isFirstTime) |
|
| 4966 | 4966 | { |
| 4967 | 4967 | $copy = new $class(); |
| 4968 | 4968 | } |
| 4969 | 4969 | $isFirstTime = false; |
| 4970 | - foreach($field_list as $field) |
|
| 4970 | + foreach ($field_list as $field) |
|
| 4971 | 4971 | { |
| 4972 | 4972 | // Copy the relevant fields |
| 4973 | 4973 | $copy->$field = $row[$field]; |
@@ -4999,14 +4999,14 @@ discard block |
||
| 4999 | 4999 | |
| 5000 | 5000 | $return_array = Array(); |
| 5001 | 5001 | global $app_list_strings, $mod_strings; |
| 5002 | - foreach($this->field_defs as $field=>$value){ |
|
| 5002 | + foreach ($this->field_defs as $field=>$value) { |
|
| 5003 | 5003 | |
| 5004 | - if(isset($this->$field)){ |
|
| 5004 | + if (isset($this->$field)) { |
|
| 5005 | 5005 | |
| 5006 | 5006 | // cn: bug 12270 - sensitive fields being passed arbitrarily in listViews |
| 5007 | - if(isset($sensitiveFields[$field])) |
|
| 5007 | + if (isset($sensitiveFields[$field])) |
|
| 5008 | 5008 | continue; |
| 5009 | - if(!isset($cache[$field])) |
|
| 5009 | + if (!isset($cache[$field])) |
|
| 5010 | 5010 | $cache[$field] = strtoupper($field); |
| 5011 | 5011 | |
| 5012 | 5012 | //Fields hidden by Dependent Fields |
@@ -5016,30 +5016,30 @@ discard block |
||
| 5016 | 5016 | } |
| 5017 | 5017 | //cn: if $field is a _dom, detect and return VALUE not KEY |
| 5018 | 5018 | //cl: empty function check for meta-data enum types that have values loaded from a function |
| 5019 | - else if (((!empty($value['type']) && ($value['type'] == 'enum' || $value['type'] == 'radioenum') )) && empty($value['function'])){ |
|
| 5020 | - if(!empty($value['options']) && !empty($app_list_strings[$value['options']][$this->$field])){ |
|
| 5019 | + else if (((!empty($value['type']) && ($value['type'] == 'enum' || $value['type'] == 'radioenum'))) && empty($value['function'])) { |
|
| 5020 | + if (!empty($value['options']) && !empty($app_list_strings[$value['options']][$this->$field])) { |
|
| 5021 | 5021 | $return_array[$cache[$field]] = $app_list_strings[$value['options']][$this->$field]; |
| 5022 | 5022 | } |
| 5023 | 5023 | //nsingh- bug 21672. some modules such as manufacturers, Releases do not have a listing for select fields in the $app_list_strings. Must also check $mod_strings to localize. |
| 5024 | - elseif(!empty($value['options']) && !empty($mod_strings[$value['options']][$this->$field])) |
|
| 5024 | + elseif (!empty($value['options']) && !empty($mod_strings[$value['options']][$this->$field])) |
|
| 5025 | 5025 | { |
| 5026 | 5026 | $return_array[$cache[$field]] = $mod_strings[$value['options']][$this->$field]; |
| 5027 | 5027 | } |
| 5028 | - else{ |
|
| 5028 | + else { |
|
| 5029 | 5029 | $return_array[$cache[$field]] = $this->$field; |
| 5030 | 5030 | } |
| 5031 | 5031 | //end bug 21672 |
| 5032 | 5032 | // tjy: no need to do this str_replace as the changes in 29994 for ListViewGeneric.tpl for translation handle this now |
| 5033 | 5033 | // }elseif(!empty($value['type']) && $value['type'] == 'multienum'&& empty($value['function'])){ |
| 5034 | 5034 | // $return_array[strtoupper($field)] = str_replace('^,^', ', ', $this->$field ); |
| 5035 | - }elseif(!empty($value['custom_module']) && $value['type'] != 'currency'){ |
|
| 5035 | + }elseif (!empty($value['custom_module']) && $value['type'] != 'currency') { |
|
| 5036 | 5036 | // $this->format_field($value); |
| 5037 | 5037 | $return_array[$cache[$field]] = $this->$field; |
| 5038 | - }else{ |
|
| 5038 | + } else { |
|
| 5039 | 5039 | $return_array[$cache[$field]] = $this->$field; |
| 5040 | 5040 | } |
| 5041 | 5041 | // handle "Assigned User Name" |
| 5042 | - if($field == 'assigned_user_name'){ |
|
| 5042 | + if ($field == 'assigned_user_name') { |
|
| 5043 | 5043 | $return_array['ASSIGNED_USER_NAME'] = get_assigned_user_name($this->assigned_user_id); |
| 5044 | 5044 | } |
| 5045 | 5045 | } |
@@ -5061,7 +5061,7 @@ discard block |
||
| 5061 | 5061 | * @param boolean $deleted Optional, default true, if set to false deleted filter will not be added. |
| 5062 | 5062 | * @return string The WHERE clause |
| 5063 | 5063 | */ |
| 5064 | - function get_where($fields_array, $deleted=true) |
|
| 5064 | + function get_where($fields_array, $deleted = true) |
|
| 5065 | 5065 | { |
| 5066 | 5066 | $where_clause = ""; |
| 5067 | 5067 | foreach ($fields_array as $name=>$value) |
@@ -5071,10 +5071,10 @@ discard block |
||
| 5071 | 5071 | } |
| 5072 | 5072 | $name = $this->db->getValidDBName($name); |
| 5073 | 5073 | |
| 5074 | - $where_clause .= "$name = ".$this->db->quoted($value,false); |
|
| 5074 | + $where_clause .= "$name = ".$this->db->quoted($value, false); |
|
| 5075 | 5075 | } |
| 5076 | - if(!empty($where_clause)) { |
|
| 5077 | - if($deleted) { |
|
| 5076 | + if (!empty($where_clause)) { |
|
| 5077 | + if ($deleted) { |
|
| 5078 | 5078 | return "WHERE $where_clause AND deleted=0"; |
| 5079 | 5079 | } else { |
| 5080 | 5080 | return "WHERE $where_clause"; |
@@ -5094,24 +5094,24 @@ discard block |
||
| 5094 | 5094 | * @param boolean $deleted Optional, default true, if set to false deleted filter will not be added. |
| 5095 | 5095 | * @return object Instance of this bean with fetched data. |
| 5096 | 5096 | */ |
| 5097 | - function retrieve_by_string_fields($fields_array, $encode=true, $deleted=true) |
|
| 5097 | + function retrieve_by_string_fields($fields_array, $encode = true, $deleted = true) |
|
| 5098 | 5098 | { |
| 5099 | 5099 | $where_clause = $this->get_where($fields_array, $deleted); |
| 5100 | 5100 | $custom_join = $this->getCustomJoin(); |
| 5101 | - $query = "SELECT $this->table_name.*". $custom_join['select']. " FROM $this->table_name " . $custom_join['join']; |
|
| 5101 | + $query = "SELECT $this->table_name.*".$custom_join['select']." FROM $this->table_name ".$custom_join['join']; |
|
| 5102 | 5102 | $query .= " $where_clause"; |
| 5103 | 5103 | $GLOBALS['log']->debug("Retrieve $this->object_name: ".$query); |
| 5104 | 5104 | //requireSingleResult has been deprecated. |
| 5105 | 5105 | //$result = $this->db->requireSingleResult($query, true, "Retrieving record $where_clause:"); |
| 5106 | - $result = $this->db->limitQuery($query,0,1,true, "Retrieving record $where_clause:"); |
|
| 5106 | + $result = $this->db->limitQuery($query, 0, 1, true, "Retrieving record $where_clause:"); |
|
| 5107 | 5107 | |
| 5108 | 5108 | |
| 5109 | - if( empty($result)) |
|
| 5109 | + if (empty($result)) |
|
| 5110 | 5110 | { |
| 5111 | 5111 | return null; |
| 5112 | 5112 | } |
| 5113 | 5113 | $row = $this->db->fetchByAssoc($result, $encode); |
| 5114 | - if(empty($row)) |
|
| 5114 | + if (empty($row)) |
|
| 5115 | 5115 | { |
| 5116 | 5116 | return null; |
| 5117 | 5117 | } |
@@ -5138,7 +5138,7 @@ discard block |
||
| 5138 | 5138 | { |
| 5139 | 5139 | foreach ($this->special_functions as $func_name) |
| 5140 | 5140 | { |
| 5141 | - if ( method_exists($this,$func_name) ) |
|
| 5141 | + if (method_exists($this, $func_name)) |
|
| 5142 | 5142 | { |
| 5143 | 5143 | $this->$func_name(); |
| 5144 | 5144 | } |
@@ -5153,52 +5153,52 @@ discard block |
||
| 5153 | 5153 | { |
| 5154 | 5154 | } |
| 5155 | 5155 | |
| 5156 | - function getRelatedFields($module, $id, $fields, $return_array = false){ |
|
| 5157 | - if(empty($GLOBALS['beanList'][$module]))return ''; |
|
| 5156 | + function getRelatedFields($module, $id, $fields, $return_array = false) { |
|
| 5157 | + if (empty($GLOBALS['beanList'][$module]))return ''; |
|
| 5158 | 5158 | $object = BeanFactory::getObjectName($module); |
| 5159 | 5159 | |
| 5160 | 5160 | VardefManager::loadVardef($module, $object); |
| 5161 | - if(empty($GLOBALS['dictionary'][$object]['table']))return ''; |
|
| 5161 | + if (empty($GLOBALS['dictionary'][$object]['table']))return ''; |
|
| 5162 | 5162 | $table = $GLOBALS['dictionary'][$object]['table']; |
| 5163 | - $query = 'SELECT id'; |
|
| 5164 | - foreach($fields as $field=>$alias){ |
|
| 5165 | - if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])){ |
|
| 5166 | - $query .= ' ,' .$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias ; |
|
| 5167 | - }else if(!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
|
| 5163 | + $query = 'SELECT id'; |
|
| 5164 | + foreach ($fields as $field=>$alias) { |
|
| 5165 | + if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) { |
|
| 5166 | + $query .= ' ,'.$this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']).' as '.$alias; |
|
| 5167 | + } else if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && |
|
| 5168 | 5168 | (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || |
| 5169 | 5169 | $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) |
| 5170 | 5170 | { |
| 5171 | - $query .= ' ,' .$table . '.' . $field . ' as ' . $alias; |
|
| 5171 | + $query .= ' ,'.$table.'.'.$field.' as '.$alias; |
|
| 5172 | 5172 | } |
| 5173 | - if(!$return_array)$this->$alias = ''; |
|
| 5173 | + if (!$return_array)$this->$alias = ''; |
|
| 5174 | 5174 | } |
| 5175 | - if($query == 'SELECT id' || empty($id)){ |
|
| 5175 | + if ($query == 'SELECT id' || empty($id)) { |
|
| 5176 | 5176 | return ''; |
| 5177 | 5177 | } |
| 5178 | 5178 | |
| 5179 | 5179 | |
| 5180 | - if(isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) |
|
| 5180 | + if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) |
|
| 5181 | 5181 | { |
| 5182 | - $query .= " , ". $table . ".assigned_user_id owner"; |
|
| 5182 | + $query .= " , ".$table.".assigned_user_id owner"; |
|
| 5183 | 5183 | |
| 5184 | 5184 | } |
| 5185 | - else if(isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) |
|
| 5185 | + else if (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) |
|
| 5186 | 5186 | { |
| 5187 | - $query .= " , ". $table . ".created_by owner"; |
|
| 5187 | + $query .= " , ".$table.".created_by owner"; |
|
| 5188 | 5188 | |
| 5189 | 5189 | } |
| 5190 | - $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id='; |
|
| 5191 | - $result = $GLOBALS['db']->query($query . "'$id'" ); |
|
| 5190 | + $query .= ' FROM '.$table.' WHERE deleted=0 AND id='; |
|
| 5191 | + $result = $GLOBALS['db']->query($query."'$id'"); |
|
| 5192 | 5192 | $row = $GLOBALS['db']->fetchByAssoc($result); |
| 5193 | - if($return_array){ |
|
| 5193 | + if ($return_array) { |
|
| 5194 | 5194 | return $row; |
| 5195 | 5195 | } |
| 5196 | - $owner = (empty($row['owner']))?'':$row['owner']; |
|
| 5197 | - foreach($fields as $alias){ |
|
| 5198 | - $this->$alias = (!empty($row[$alias]))? $row[$alias]: ''; |
|
| 5199 | - $alias = $alias .'_owner'; |
|
| 5196 | + $owner = (empty($row['owner'])) ? '' : $row['owner']; |
|
| 5197 | + foreach ($fields as $alias) { |
|
| 5198 | + $this->$alias = (!empty($row[$alias])) ? $row[$alias] : ''; |
|
| 5199 | + $alias = $alias.'_owner'; |
|
| 5200 | 5200 | $this->$alias = $owner; |
| 5201 | - $a_mod = $alias .'_mod'; |
|
| 5201 | + $a_mod = $alias.'_mod'; |
|
| 5202 | 5202 | $this->$a_mod = $module; |
| 5203 | 5203 | } |
| 5204 | 5204 | |
@@ -5214,39 +5214,39 @@ discard block |
||
| 5214 | 5214 | function assign_display_fields($currentModule) |
| 5215 | 5215 | { |
| 5216 | 5216 | global $timedate; |
| 5217 | - foreach($this->column_fields as $field) |
|
| 5217 | + foreach ($this->column_fields as $field) |
|
| 5218 | 5218 | { |
| 5219 | - if(isset($this->field_name_map[$field]) && empty($this->$field)) |
|
| 5219 | + if (isset($this->field_name_map[$field]) && empty($this->$field)) |
|
| 5220 | 5220 | { |
| 5221 | - if($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') |
|
| 5221 | + if ($this->field_name_map[$field]['type'] != 'date' && $this->field_name_map[$field]['type'] != 'enum') |
|
| 5222 | 5222 | $this->$field = $field; |
| 5223 | - if($this->field_name_map[$field]['type'] == 'date') |
|
| 5223 | + if ($this->field_name_map[$field]['type'] == 'date') |
|
| 5224 | 5224 | { |
| 5225 | 5225 | $this->$field = $timedate->to_display_date('1980-07-09'); |
| 5226 | 5226 | } |
| 5227 | - if($this->field_name_map[$field]['type'] == 'enum') |
|
| 5227 | + if ($this->field_name_map[$field]['type'] == 'enum') |
|
| 5228 | 5228 | { |
| 5229 | 5229 | $dom = $this->field_name_map[$field]['options']; |
| 5230 | 5230 | global $current_language, $app_list_strings; |
| 5231 | 5231 | $mod_strings = return_module_language($current_language, $currentModule); |
| 5232 | 5232 | |
| 5233 | - if(isset($mod_strings[$dom])) |
|
| 5233 | + if (isset($mod_strings[$dom])) |
|
| 5234 | 5234 | { |
| 5235 | 5235 | $options = $mod_strings[$dom]; |
| 5236 | - foreach($options as $key=>$value) |
|
| 5236 | + foreach ($options as $key=>$value) |
|
| 5237 | 5237 | { |
| 5238 | - if(!empty($key) && empty($this->$field )) |
|
| 5238 | + if (!empty($key) && empty($this->$field)) |
|
| 5239 | 5239 | { |
| 5240 | 5240 | $this->$field = $key; |
| 5241 | 5241 | } |
| 5242 | 5242 | } |
| 5243 | 5243 | } |
| 5244 | - if(isset($app_list_strings[$dom])) |
|
| 5244 | + if (isset($app_list_strings[$dom])) |
|
| 5245 | 5245 | { |
| 5246 | 5246 | $options = $app_list_strings[$dom]; |
| 5247 | - foreach($options as $key=>$value) |
|
| 5247 | + foreach ($options as $key=>$value) |
|
| 5248 | 5248 | { |
| 5249 | - if(!empty($key) && empty($this->$field )) |
|
| 5249 | + if (!empty($key) && empty($this->$field)) |
|
| 5250 | 5250 | { |
| 5251 | 5251 | $this->$field = $key; |
| 5252 | 5252 | } |
@@ -5263,61 +5263,61 @@ discard block |
||
| 5263 | 5263 | * RELATIONSHIP HANDLING |
| 5264 | 5264 | */ |
| 5265 | 5265 | |
| 5266 | - function set_relationship($table, $relate_values, $check_duplicates = true,$do_update=false,$data_values=null) |
|
| 5266 | + function set_relationship($table, $relate_values, $check_duplicates = true, $do_update = false, $data_values = null) |
|
| 5267 | 5267 | { |
| 5268 | 5268 | $where = ''; |
| 5269 | 5269 | |
| 5270 | 5270 | // make sure there is a date modified |
| 5271 | 5271 | $date_modified = $this->db->convert("'".$GLOBALS['timedate']->nowDb()."'", 'datetime'); |
| 5272 | 5272 | |
| 5273 | - $row=null; |
|
| 5274 | - if($check_duplicates) |
|
| 5273 | + $row = null; |
|
| 5274 | + if ($check_duplicates) |
|
| 5275 | 5275 | { |
| 5276 | 5276 | $query = "SELECT * FROM $table "; |
| 5277 | 5277 | $where = "WHERE deleted = '0' "; |
| 5278 | - foreach($relate_values as $name=>$value) |
|
| 5278 | + foreach ($relate_values as $name=>$value) |
|
| 5279 | 5279 | { |
| 5280 | 5280 | $where .= " AND $name = '$value' "; |
| 5281 | 5281 | } |
| 5282 | 5282 | $query .= $where; |
| 5283 | - $result = $this->db->query($query, false, "Looking For Duplicate Relationship:" . $query); |
|
| 5284 | - $row=$this->db->fetchByAssoc($result); |
|
| 5283 | + $result = $this->db->query($query, false, "Looking For Duplicate Relationship:".$query); |
|
| 5284 | + $row = $this->db->fetchByAssoc($result); |
|
| 5285 | 5285 | } |
| 5286 | 5286 | |
| 5287 | - if(!$check_duplicates || empty($row) ) |
|
| 5287 | + if (!$check_duplicates || empty($row)) |
|
| 5288 | 5288 | { |
| 5289 | 5289 | unset($relate_values['id']); |
| 5290 | - if ( isset($data_values)) |
|
| 5290 | + if (isset($data_values)) |
|
| 5291 | 5291 | { |
| 5292 | - $relate_values = array_merge($relate_values,$data_values); |
|
| 5292 | + $relate_values = array_merge($relate_values, $data_values); |
|
| 5293 | 5293 | } |
| 5294 | - $query = "INSERT INTO $table (id, ". implode(',', array_keys($relate_values)) . ", date_modified) VALUES ('" . create_guid() . "', " . "'" . implode("', '", $relate_values) . "', ".$date_modified.")" ; |
|
| 5294 | + $query = "INSERT INTO $table (id, ".implode(',', array_keys($relate_values)).", date_modified) VALUES ('".create_guid()."', "."'".implode("', '", $relate_values)."', ".$date_modified.")"; |
|
| 5295 | 5295 | |
| 5296 | - $this->db->query($query, false, "Creating Relationship:" . $query); |
|
| 5296 | + $this->db->query($query, false, "Creating Relationship:".$query); |
|
| 5297 | 5297 | } |
| 5298 | 5298 | else if ($do_update) |
| 5299 | 5299 | { |
| 5300 | 5300 | $conds = array(); |
| 5301 | - foreach($data_values as $key=>$value) |
|
| 5301 | + foreach ($data_values as $key=>$value) |
|
| 5302 | 5302 | { |
| 5303 | - array_push($conds,$key."='".$this->db->quote($value)."'"); |
|
| 5303 | + array_push($conds, $key."='".$this->db->quote($value)."'"); |
|
| 5304 | 5304 | } |
| 5305 | - $query = "UPDATE $table SET ". implode(',', $conds).",date_modified=".$date_modified." ".$where; |
|
| 5306 | - $this->db->query($query, false, "Updating Relationship:" . $query); |
|
| 5305 | + $query = "UPDATE $table SET ".implode(',', $conds).",date_modified=".$date_modified." ".$where; |
|
| 5306 | + $this->db->query($query, false, "Updating Relationship:".$query); |
|
| 5307 | 5307 | } |
| 5308 | 5308 | } |
| 5309 | 5309 | |
| 5310 | 5310 | function retrieve_relationships($table, $values, $select_id) |
| 5311 | 5311 | { |
| 5312 | 5312 | $query = "SELECT $select_id FROM $table WHERE deleted = 0 "; |
| 5313 | - foreach($values as $name=>$value) |
|
| 5313 | + foreach ($values as $name=>$value) |
|
| 5314 | 5314 | { |
| 5315 | 5315 | $query .= " AND $name = '$value' "; |
| 5316 | 5316 | } |
| 5317 | 5317 | $query .= " ORDER BY $select_id "; |
| 5318 | - $result = $this->db->query($query, false, "Retrieving Relationship:" . $query); |
|
| 5318 | + $result = $this->db->query($query, false, "Retrieving Relationship:".$query); |
|
| 5319 | 5319 | $ids = array(); |
| 5320 | - while($row = $this->db->fetchByAssoc($result)) |
|
| 5320 | + while ($row = $this->db->fetchByAssoc($result)) |
|
| 5321 | 5321 | { |
| 5322 | 5322 | $ids[] = $row; |
| 5323 | 5323 | } |
@@ -5328,16 +5328,16 @@ discard block |
||
| 5328 | 5328 | function loadLayoutDefs() |
| 5329 | 5329 | { |
| 5330 | 5330 | global $layout_defs; |
| 5331 | - if(empty( $this->layout_def) && file_exists('modules/'. $this->module_dir . '/layout_defs.php')) |
|
| 5331 | + if (empty($this->layout_def) && file_exists('modules/'.$this->module_dir.'/layout_defs.php')) |
|
| 5332 | 5332 | { |
| 5333 | - include_once('modules/'. $this->module_dir . '/layout_defs.php'); |
|
| 5334 | - if(file_exists('custom/modules/'. $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
| 5333 | + include_once('modules/'.$this->module_dir.'/layout_defs.php'); |
|
| 5334 | + if (file_exists('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php')) |
|
| 5335 | 5335 | { |
| 5336 | - include_once('custom/modules/'. $this->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
| 5336 | + include_once('custom/modules/'.$this->module_dir.'/Ext/Layoutdefs/layoutdefs.ext.php'); |
|
| 5337 | 5337 | } |
| 5338 | - if ( empty( $layout_defs[get_class($this)])) |
|
| 5338 | + if (empty($layout_defs[get_class($this)])) |
|
| 5339 | 5339 | { |
| 5340 | - echo "\$layout_defs[" . get_class($this) . "]; does not exist"; |
|
| 5340 | + echo "\$layout_defs[".get_class($this)."]; does not exist"; |
|
| 5341 | 5341 | } |
| 5342 | 5342 | |
| 5343 | 5343 | $this->layout_def = $layout_defs[get_class($this)]; |
@@ -5371,12 +5371,12 @@ discard block |
||
| 5371 | 5371 | */ |
| 5372 | 5372 | function call_custom_logic($event, $arguments = null) |
| 5373 | 5373 | { |
| 5374 | - if(!isset($this->processed) || $this->processed == false){ |
|
| 5374 | + if (!isset($this->processed) || $this->processed == false) { |
|
| 5375 | 5375 | //add some logic to ensure we do not get into an infinite loop |
| 5376 | - if(!empty($this->logicHookDepth[$event])) { |
|
| 5377 | - if($this->logicHookDepth[$event] > $this->max_logic_depth) |
|
| 5376 | + if (!empty($this->logicHookDepth[$event])) { |
|
| 5377 | + if ($this->logicHookDepth[$event] > $this->max_logic_depth) |
|
| 5378 | 5378 | return; |
| 5379 | - }else |
|
| 5379 | + } else |
|
| 5380 | 5380 | $this->logicHookDepth[$event] = 0; |
| 5381 | 5381 | |
| 5382 | 5382 | //we have to put the increment operator here |
@@ -5421,7 +5421,7 @@ discard block |
||
| 5421 | 5421 | $GLOBALS['log']->fatal("SUGARBEAN: cannot find Real Key for custom field of type dropdown - cannot return Value."); |
| 5422 | 5422 | return false; |
| 5423 | 5423 | } |
| 5424 | - if(isset($realKey)) |
|
| 5424 | + if (isset($realKey)) |
|
| 5425 | 5425 | { |
| 5426 | 5426 | return $this->custom_fields->avail_fields[$name][$realKey]; |
| 5427 | 5427 | } |
@@ -5440,17 +5440,17 @@ discard block |
||
| 5440 | 5440 | /** |
| 5441 | 5441 | function ACLAccess($view,$is_owner='not_set') |
| 5442 | 5442 | */ |
| 5443 | - function ACLAccess($view,$is_owner='not_set',$in_group='not_set') |
|
| 5443 | + function ACLAccess($view, $is_owner = 'not_set', $in_group = 'not_set') |
|
| 5444 | 5444 | { |
| 5445 | 5445 | global $current_user; |
| 5446 | - if($current_user->isAdmin()) { |
|
| 5446 | + if ($current_user->isAdmin()) { |
|
| 5447 | 5447 | return true; |
| 5448 | 5448 | } |
| 5449 | 5449 | $not_set = false; |
| 5450 | 5450 | /** |
| 5451 | 5451 | if($is_owner == 'not_set') |
| 5452 | 5452 | */ |
| 5453 | - if($is_owner === 'not_set') //eggsurplus: should be === |
|
| 5453 | + if ($is_owner === 'not_set') //eggsurplus: should be === |
|
| 5454 | 5454 | { |
| 5455 | 5455 | $not_set = true; |
| 5456 | 5456 | $is_owner = $this->isOwner($current_user->id); |
@@ -5461,7 +5461,7 @@ discard block |
||
| 5461 | 5461 | $view = strtolower($view); |
| 5462 | 5462 | $action = ''; |
| 5463 | 5463 | // DJM - OBS Customizations - END CHANGE |
| 5464 | - if($in_group === 'not_set') |
|
| 5464 | + if ($in_group === 'not_set') |
|
| 5465 | 5465 | { |
| 5466 | 5466 | require_once("modules/SecurityGroups/SecurityGroup.php"); |
| 5467 | 5467 | // DJM - OBS Customizations - May 2009 |
@@ -5487,7 +5487,7 @@ discard block |
||
| 5487 | 5487 | $action = "view"; |
| 5488 | 5488 | break; |
| 5489 | 5489 | case 'delete': |
| 5490 | - $action = "delete" ; |
|
| 5490 | + $action = "delete"; |
|
| 5491 | 5491 | break; |
| 5492 | 5492 | case 'export': |
| 5493 | 5493 | $action = "export"; |
@@ -5499,11 +5499,11 @@ discard block |
||
| 5499 | 5499 | $action = ""; |
| 5500 | 5500 | break; |
| 5501 | 5501 | } |
| 5502 | - $in_group = SecurityGroup::groupHasAccess($this->module_dir,$this->id, $action); |
|
| 5502 | + $in_group = SecurityGroup::groupHasAccess($this->module_dir, $this->id, $action); |
|
| 5503 | 5503 | // DJM - OBS Customizations - END CHANGE |
| 5504 | 5504 | } |
| 5505 | 5505 | //if we don't implent acls return true |
| 5506 | - if(!$this->bean_implements('ACL')) |
|
| 5506 | + if (!$this->bean_implements('ACL')) |
|
| 5507 | 5507 | return true; |
| 5508 | 5508 | $view = strtolower($view); |
| 5509 | 5509 | switch ($view) |
@@ -5514,15 +5514,15 @@ discard block |
||
| 5514 | 5514 | /** |
| 5515 | 5515 | return ACLController::checkAccess($this->module_dir,'list', true); |
| 5516 | 5516 | */ |
| 5517 | - return ACLController::checkAccess($this->module_dir,'list', true, $this->acltype, $in_group); |
|
| 5517 | + return ACLController::checkAccess($this->module_dir, 'list', true, $this->acltype, $in_group); |
|
| 5518 | 5518 | case 'edit': |
| 5519 | 5519 | case 'save': |
| 5520 | - if( !$is_owner && $not_set && !empty($this->id)){ |
|
| 5520 | + if (!$is_owner && $not_set && !empty($this->id)) { |
|
| 5521 | 5521 | $class = get_class($this); |
| 5522 | 5522 | $temp = new $class(); |
| 5523 | - if(!empty($this->fetched_row) && !empty($this->fetched_row['id']) && !empty($this->fetched_row['assigned_user_id']) && !empty($this->fetched_row['created_by'])){ |
|
| 5523 | + if (!empty($this->fetched_row) && !empty($this->fetched_row['id']) && !empty($this->fetched_row['assigned_user_id']) && !empty($this->fetched_row['created_by'])) { |
|
| 5524 | 5524 | $temp->populateFromRow($this->fetched_row); |
| 5525 | - }else{ |
|
| 5525 | + } else { |
|
| 5526 | 5526 | $temp->retrieve($this->id); |
| 5527 | 5527 | } |
| 5528 | 5528 | $is_owner = $temp->isOwner($current_user->id); |
@@ -5532,29 +5532,29 @@ discard block |
||
| 5532 | 5532 | /** |
| 5533 | 5533 | return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype); |
| 5534 | 5534 | */ |
| 5535 | - return ACLController::checkAccess($this->module_dir,'edit', $is_owner, $this->acltype, $in_group); |
|
| 5535 | + return ACLController::checkAccess($this->module_dir, 'edit', $is_owner, $this->acltype, $in_group); |
|
| 5536 | 5536 | case 'view': |
| 5537 | 5537 | case 'detail': |
| 5538 | 5538 | case 'detailview': |
| 5539 | 5539 | /** |
| 5540 | 5540 | return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype); |
| 5541 | 5541 | */ |
| 5542 | - return ACLController::checkAccess($this->module_dir,'view', $is_owner, $this->acltype, $in_group); |
|
| 5542 | + return ACLController::checkAccess($this->module_dir, 'view', $is_owner, $this->acltype, $in_group); |
|
| 5543 | 5543 | case 'delete': |
| 5544 | 5544 | /** |
| 5545 | 5545 | return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype); |
| 5546 | 5546 | */ |
| 5547 | - return ACLController::checkAccess($this->module_dir,'delete', $is_owner, $this->acltype, $in_group); |
|
| 5547 | + return ACLController::checkAccess($this->module_dir, 'delete', $is_owner, $this->acltype, $in_group); |
|
| 5548 | 5548 | case 'export': |
| 5549 | 5549 | /** |
| 5550 | 5550 | return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype); |
| 5551 | 5551 | */ |
| 5552 | - return ACLController::checkAccess($this->module_dir,'export', $is_owner, $this->acltype, $in_group); |
|
| 5552 | + return ACLController::checkAccess($this->module_dir, 'export', $is_owner, $this->acltype, $in_group); |
|
| 5553 | 5553 | case 'import': |
| 5554 | 5554 | /** |
| 5555 | 5555 | return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype); |
| 5556 | 5556 | */ |
| 5557 | - return ACLController::checkAccess($this->module_dir,'import', true, $this->acltype, $in_group); |
|
| 5557 | + return ACLController::checkAccess($this->module_dir, 'import', true, $this->acltype, $in_group); |
|
| 5558 | 5558 | } |
| 5559 | 5559 | //if it is not one of the above views then it should be implemented on the page level |
| 5560 | 5560 | return true; |
@@ -5570,12 +5570,12 @@ discard block |
||
| 5570 | 5570 | { |
| 5571 | 5571 | if (isset($this->field_defs['assigned_user_id'])) |
| 5572 | 5572 | { |
| 5573 | - return $returnFieldName? 'assigned_user_id': $this->assigned_user_id; |
|
| 5573 | + return $returnFieldName ? 'assigned_user_id' : $this->assigned_user_id; |
|
| 5574 | 5574 | } |
| 5575 | 5575 | |
| 5576 | 5576 | if (isset($this->field_defs['created_by'])) |
| 5577 | 5577 | { |
| 5578 | - return $returnFieldName? 'created_by': $this->created_by; |
|
| 5578 | + return $returnFieldName ? 'created_by' : $this->created_by; |
|
| 5579 | 5579 | } |
| 5580 | 5580 | |
| 5581 | 5581 | return ''; |
@@ -5590,7 +5590,7 @@ discard block |
||
| 5590 | 5590 | function isOwner($user_id) |
| 5591 | 5591 | { |
| 5592 | 5592 | //if we don't have an id we must be the owner as we are creating it |
| 5593 | - if(!isset($this->id)) |
|
| 5593 | + if (!isset($this->id)) |
|
| 5594 | 5594 | { |
| 5595 | 5595 | return true; |
| 5596 | 5596 | } |
@@ -5601,13 +5601,13 @@ discard block |
||
| 5601 | 5601 | } |
| 5602 | 5602 | return false; |
| 5603 | 5603 | } elseif (isset($this->assigned_user_id)) { |
| 5604 | - if($this->assigned_user_id == $user_id) return true; |
|
| 5604 | + if ($this->assigned_user_id == $user_id) return true; |
|
| 5605 | 5605 | return false; |
| 5606 | 5606 | } |
| 5607 | 5607 | else |
| 5608 | 5608 | { |
| 5609 | 5609 | //other wise if there is a created_by that is the owner |
| 5610 | - if(isset($this->created_by) && $this->created_by == $user_id) |
|
| 5610 | + if (isset($this->created_by) && $this->created_by == $user_id) |
|
| 5611 | 5611 | { |
| 5612 | 5612 | return true; |
| 5613 | 5613 | } |
@@ -5622,11 +5622,11 @@ discard block |
||
| 5622 | 5622 | */ |
| 5623 | 5623 | function getOwnerWhere($user_id) |
| 5624 | 5624 | { |
| 5625 | - if(isset($this->field_defs['assigned_user_id'])) |
|
| 5625 | + if (isset($this->field_defs['assigned_user_id'])) |
|
| 5626 | 5626 | { |
| 5627 | 5627 | return " $this->table_name.assigned_user_id ='$user_id' "; |
| 5628 | 5628 | } |
| 5629 | - if(isset($this->field_defs['created_by'])) |
|
| 5629 | + if (isset($this->field_defs['created_by'])) |
|
| 5630 | 5630 | { |
| 5631 | 5631 | return " $this->table_name.created_by ='$user_id' "; |
| 5632 | 5632 | } |
@@ -5643,7 +5643,7 @@ discard block |
||
| 5643 | 5643 | function listviewACLHelper() |
| 5644 | 5644 | { |
| 5645 | 5645 | $array_assign = array(); |
| 5646 | - if($this->ACLAccess('DetailView')) |
|
| 5646 | + if ($this->ACLAccess('DetailView')) |
|
| 5647 | 5647 | { |
| 5648 | 5648 | $array_assign['MAIN'] = 'a'; |
| 5649 | 5649 | } |
@@ -5659,27 +5659,27 @@ discard block |
||
| 5659 | 5659 | * |
| 5660 | 5660 | * @return array of fields with id, name, access and category |
| 5661 | 5661 | */ |
| 5662 | - function toArray($dbOnly = false, $stringOnly = false, $upperKeys=false) |
|
| 5662 | + function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false) |
|
| 5663 | 5663 | { |
| 5664 | 5664 | static $cache = array(); |
| 5665 | 5665 | $arr = array(); |
| 5666 | 5666 | |
| 5667 | - foreach($this->field_defs as $field=>$data) |
|
| 5667 | + foreach ($this->field_defs as $field=>$data) |
|
| 5668 | 5668 | { |
| 5669 | - if( !$dbOnly || !isset($data['source']) || $data['source'] == 'db') |
|
| 5670 | - if(!$stringOnly || is_string($this->$field)) |
|
| 5671 | - if($upperKeys) |
|
| 5669 | + if (!$dbOnly || !isset($data['source']) || $data['source'] == 'db') |
|
| 5670 | + if (!$stringOnly || is_string($this->$field)) |
|
| 5671 | + if ($upperKeys) |
|
| 5672 | 5672 | { |
| 5673 | - if(!isset($cache[$field])){ |
|
| 5673 | + if (!isset($cache[$field])) { |
|
| 5674 | 5674 | $cache[$field] = strtoupper($field); |
| 5675 | 5675 | } |
| 5676 | 5676 | $arr[$cache[$field]] = $this->$field; |
| 5677 | 5677 | } |
| 5678 | 5678 | else |
| 5679 | 5679 | { |
| 5680 | - if(isset($this->$field)){ |
|
| 5680 | + if (isset($this->$field)) { |
|
| 5681 | 5681 | $arr[$field] = $this->$field; |
| 5682 | - }else{ |
|
| 5682 | + } else { |
|
| 5683 | 5683 | $arr[$field] = ''; |
| 5684 | 5684 | } |
| 5685 | 5685 | } |
@@ -5694,7 +5694,7 @@ discard block |
||
| 5694 | 5694 | */ |
| 5695 | 5695 | function fromArray($arr) |
| 5696 | 5696 | { |
| 5697 | - foreach($arr as $name=>$value) |
|
| 5697 | + foreach ($arr as $name=>$value) |
|
| 5698 | 5698 | { |
| 5699 | 5699 | $this->$name = $value; |
| 5700 | 5700 | } |
@@ -5708,7 +5708,7 @@ discard block |
||
| 5708 | 5708 | */ |
| 5709 | 5709 | public function convertRow($row) |
| 5710 | 5710 | { |
| 5711 | - foreach($this->field_defs as $name => $fieldDef) |
|
| 5711 | + foreach ($this->field_defs as $name => $fieldDef) |
|
| 5712 | 5712 | { |
| 5713 | 5713 | // skip empty fields and non-db fields |
| 5714 | 5714 | if (isset($name) && !empty($row[$name])) { |
@@ -5754,7 +5754,7 @@ discard block |
||
| 5754 | 5754 | |
| 5755 | 5755 | $this->fill_in_additional_list_fields(); |
| 5756 | 5756 | |
| 5757 | - if($this->hasCustomFields())$this->custom_fields->fill_relationships(); |
|
| 5757 | + if ($this->hasCustomFields())$this->custom_fields->fill_relationships(); |
|
| 5758 | 5758 | $this->call_custom_logic("process_record"); |
| 5759 | 5759 | } |
| 5760 | 5760 | |
@@ -5773,7 +5773,7 @@ discard block |
||
| 5773 | 5773 | * |
| 5774 | 5774 | * Internal function do not override. |
| 5775 | 5775 | */ |
| 5776 | - function create_qualified_order_by( $order_by, $qualify) |
|
| 5776 | + function create_qualified_order_by($order_by, $qualify) |
|
| 5777 | 5777 | { // if the column is empty, but the sort order is defined, the value will throw an error, so do not proceed if no order by is given |
| 5778 | 5778 | if (empty($order_by)) |
| 5779 | 5779 | { |
@@ -5782,10 +5782,10 @@ discard block |
||
| 5782 | 5782 | $order_by_clause = " ORDER BY "; |
| 5783 | 5783 | $tmp = explode(",", $order_by); |
| 5784 | 5784 | $comma = ' '; |
| 5785 | - foreach ( $tmp as $stmp) |
|
| 5785 | + foreach ($tmp as $stmp) |
|
| 5786 | 5786 | { |
| 5787 | - $stmp = (substr_count($stmp, ".") > 0?trim($stmp):"$qualify." . trim($stmp)); |
|
| 5788 | - $order_by_clause .= $comma . $stmp; |
|
| 5787 | + $stmp = (substr_count($stmp, ".") > 0 ? trim($stmp) : "$qualify.".trim($stmp)); |
|
| 5788 | + $order_by_clause .= $comma.$stmp; |
|
| 5789 | 5789 | $comma = ", "; |
| 5790 | 5790 | } |
| 5791 | 5791 | return $order_by_clause; |
@@ -5805,16 +5805,16 @@ discard block |
||
| 5805 | 5805 | $street_field_2 = $street_field.'_2'; |
| 5806 | 5806 | $street_field_3 = $street_field.'_3'; |
| 5807 | 5807 | $street_field_4 = $street_field.'_4'; |
| 5808 | - if ( isset($this->$street_field_2)) { |
|
| 5809 | - $this->$street_field .= "\n". $this->$street_field_2; |
|
| 5808 | + if (isset($this->$street_field_2)) { |
|
| 5809 | + $this->$street_field .= "\n".$this->$street_field_2; |
|
| 5810 | 5810 | unset($this->$street_field_2); |
| 5811 | 5811 | } |
| 5812 | - if ( isset($this->$street_field_3)) { |
|
| 5813 | - $this->$street_field .= "\n". $this->$street_field_3; |
|
| 5812 | + if (isset($this->$street_field_3)) { |
|
| 5813 | + $this->$street_field .= "\n".$this->$street_field_3; |
|
| 5814 | 5814 | unset($this->$street_field_3); |
| 5815 | 5815 | } |
| 5816 | - if ( isset($this->$street_field_4)) { |
|
| 5817 | - $this->$street_field .= "\n". $this->$street_field_4; |
|
| 5816 | + if (isset($this->$street_field_4)) { |
|
| 5817 | + $this->$street_field .= "\n".$this->$street_field_4; |
|
| 5818 | 5818 | unset($this->$street_field_4); |
| 5819 | 5819 | } |
| 5820 | 5820 | $this->$street_field = trim($this->$street_field, "\n"); |
@@ -5823,7 +5823,7 @@ discard block |
||
| 5823 | 5823 | |
| 5824 | 5824 | protected function getEncryptKey() |
| 5825 | 5825 | { |
| 5826 | - if(empty(self::$field_key)) { |
|
| 5826 | + if (empty(self::$field_key)) { |
|
| 5827 | 5827 | self::$field_key = blowfishGetKey('encrypt_field'); |
| 5828 | 5828 | } |
| 5829 | 5829 | return self::$field_key; |
@@ -5847,7 +5847,7 @@ discard block |
||
| 5847 | 5847 | */ |
| 5848 | 5848 | function decrypt_after_retrieve($value) |
| 5849 | 5849 | { |
| 5850 | - if(empty($value)) return $value; // no need to decrypt empty |
|
| 5850 | + if (empty($value)) return $value; // no need to decrypt empty |
|
| 5851 | 5851 | require_once("include/utils/encryption_utils.php"); |
| 5852 | 5852 | return blowfishDecode($this->getEncryptKey(), $value); |
| 5853 | 5853 | } |
@@ -5856,19 +5856,19 @@ discard block |
||
| 5856 | 5856 | * Moved from save() method, functionality is the same, but this is intended to handle |
| 5857 | 5857 | * Optimistic locking functionality. |
| 5858 | 5858 | */ |
| 5859 | - private function _checkOptimisticLocking($action, $isUpdate){ |
|
| 5860 | - if($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])){ |
|
| 5861 | - if(isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name) |
|
| 5859 | + private function _checkOptimisticLocking($action, $isUpdate) { |
|
| 5860 | + if ($this->optimistic_lock && !isset($_SESSION['o_lock_fs'])) { |
|
| 5861 | + if (isset($_SESSION['o_lock_id']) && $_SESSION['o_lock_id'] == $this->id && $_SESSION['o_lock_on'] == $this->object_name) |
|
| 5862 | 5862 | { |
| 5863 | - if($action == 'Save' && $isUpdate && isset($this->modified_user_id) && $this->has_been_modified_since($_SESSION['o_lock_dm'], $this->modified_user_id)) |
|
| 5863 | + if ($action == 'Save' && $isUpdate && isset($this->modified_user_id) && $this->has_been_modified_since($_SESSION['o_lock_dm'], $this->modified_user_id)) |
|
| 5864 | 5864 | { |
| 5865 | 5865 | $_SESSION['o_lock_class'] = get_class($this); |
| 5866 | 5866 | $_SESSION['o_lock_module'] = $this->module_dir; |
| 5867 | 5867 | $_SESSION['o_lock_object'] = $this->toArray(); |
| 5868 | 5868 | $saveform = "<form name='save' id='save' method='POST'>"; |
| 5869 | - foreach($_POST as $key=>$arg) |
|
| 5869 | + foreach ($_POST as $key=>$arg) |
|
| 5870 | 5870 | { |
| 5871 | - $saveform .= "<input type='hidden' name='". addslashes($key) ."' value='". addslashes($arg) ."'>"; |
|
| 5871 | + $saveform .= "<input type='hidden' name='".addslashes($key)."' value='".addslashes($arg)."'>"; |
|
| 5872 | 5872 | } |
| 5873 | 5873 | $saveform .= "</form><script>document.getElementById('save').submit();</script>"; |
| 5874 | 5874 | $_SESSION['o_lock_save'] = $saveform; |
@@ -5885,20 +5885,20 @@ discard block |
||
| 5885 | 5885 | } |
| 5886 | 5886 | else |
| 5887 | 5887 | { |
| 5888 | - if(isset($_SESSION['o_lock_object'])) { unset ($_SESSION['o_lock_object']); } |
|
| 5889 | - if(isset($_SESSION['o_lock_id'])) { unset ($_SESSION['o_lock_id']); } |
|
| 5890 | - if(isset($_SESSION['o_lock_dm'])) { unset ($_SESSION['o_lock_dm']); } |
|
| 5891 | - if(isset($_SESSION['o_lock_fs'])) { unset ($_SESSION['o_lock_fs']); } |
|
| 5892 | - if(isset($_SESSION['o_lock_save'])) { unset ($_SESSION['o_lock_save']); } |
|
| 5888 | + if (isset($_SESSION['o_lock_object'])) { unset ($_SESSION['o_lock_object']); } |
|
| 5889 | + if (isset($_SESSION['o_lock_id'])) { unset ($_SESSION['o_lock_id']); } |
|
| 5890 | + if (isset($_SESSION['o_lock_dm'])) { unset ($_SESSION['o_lock_dm']); } |
|
| 5891 | + if (isset($_SESSION['o_lock_fs'])) { unset ($_SESSION['o_lock_fs']); } |
|
| 5892 | + if (isset($_SESSION['o_lock_save'])) { unset ($_SESSION['o_lock_save']); } |
|
| 5893 | 5893 | } |
| 5894 | 5894 | } |
| 5895 | 5895 | |
| 5896 | 5896 | /** |
| 5897 | 5897 | * Send assignment notifications and invites for meetings and calls |
| 5898 | 5898 | */ |
| 5899 | - private function _sendNotifications($check_notify){ |
|
| 5900 | - if($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true. |
|
| 5901 | - && !$this->isOwner($this->created_by) ) // cn: bug 42727 no need to send email to owner (within workflow) |
|
| 5899 | + private function _sendNotifications($check_notify) { |
|
| 5900 | + if ($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true. |
|
| 5901 | + && !$this->isOwner($this->created_by)) // cn: bug 42727 no need to send email to owner (within workflow) |
|
| 5902 | 5902 | { |
| 5903 | 5903 | $admin = new Administration(); |
| 5904 | 5904 | $admin->retrieveSettings(); |
@@ -5909,7 +5909,7 @@ discard block |
||
| 5909 | 5909 | $GLOBALS['log']->info("Notifications: user assignment has changed, checking if user receives notifications"); |
| 5910 | 5910 | $sendNotifications = true; |
| 5911 | 5911 | } |
| 5912 | - elseif(isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1) |
|
| 5912 | + elseif (isset($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == 1) |
|
| 5913 | 5913 | { |
| 5914 | 5914 | // cn: bug 5795 Send Invites failing for Contacts |
| 5915 | 5915 | $sendNotifications = true; |
@@ -5920,7 +5920,7 @@ discard block |
||
| 5920 | 5920 | } |
| 5921 | 5921 | |
| 5922 | 5922 | |
| 5923 | - if($sendNotifications == true) |
|
| 5923 | + if ($sendNotifications == true) |
|
| 5924 | 5924 | { |
| 5925 | 5925 | $notify_list = $this->get_notification_recipients(); |
| 5926 | 5926 | foreach ($notify_list as $notify_user) |
@@ -5981,10 +5981,10 @@ discard block |
||
| 5981 | 5981 | |
| 5982 | 5982 | $cache_key = "load_cached_array.$module_dir.$module.$key"; |
| 5983 | 5983 | $result = sugar_cache_retrieve($cache_key); |
| 5984 | - if(!empty($result)) |
|
| 5984 | + if (!empty($result)) |
|
| 5985 | 5985 | { |
| 5986 | 5986 | // Use SugarCache::EXTERNAL_CACHE_NULL_VALUE to store null values in the cache. |
| 5987 | - if($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
| 5987 | + if ($result == SugarCache::EXTERNAL_CACHE_NULL_VALUE) |
|
| 5988 | 5988 | { |
| 5989 | 5989 | return null; |
| 5990 | 5990 | } |
@@ -5992,16 +5992,16 @@ discard block |
||
| 5992 | 5992 | return $result; |
| 5993 | 5993 | } |
| 5994 | 5994 | |
| 5995 | - if(file_exists('modules/'.$module_dir.'/'.$fileName)) |
|
| 5995 | + if (file_exists('modules/'.$module_dir.'/'.$fileName)) |
|
| 5996 | 5996 | { |
| 5997 | 5997 | // If the data was not loaded, try loading again.... |
| 5998 | - if(!isset($moduleDefs[$module])) |
|
| 5998 | + if (!isset($moduleDefs[$module])) |
|
| 5999 | 5999 | { |
| 6000 | 6000 | include('modules/'.$module_dir.'/'.$fileName); |
| 6001 | 6001 | $moduleDefs[$module] = $fields_array; |
| 6002 | 6002 | } |
| 6003 | 6003 | // Now that we have tried loading, make sure it was loaded |
| 6004 | - if(empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) |
|
| 6004 | + if (empty($moduleDefs[$module]) || empty($moduleDefs[$module][$module][$key])) |
|
| 6005 | 6005 | { |
| 6006 | 6006 | // It was not loaded.... Fail. Cache null to prevent future repeats of this calculation |
| 6007 | 6007 | sugar_cache_put($cache_key, SugarCache::EXTERNAL_CACHE_NULL_VALUE); |
@@ -6026,7 +6026,7 @@ discard block |
||
| 6026 | 6026 | */ |
| 6027 | 6027 | public function getACLCategory() |
| 6028 | 6028 | { |
| 6029 | - return !empty($this->acl_category)?$this->acl_category:$this->module_dir; |
|
| 6029 | + return !empty($this->acl_category) ? $this->acl_category : $this->module_dir; |
|
| 6030 | 6030 | } |
| 6031 | 6031 | |
| 6032 | 6032 | /** |
@@ -6075,7 +6075,7 @@ discard block |
||
| 6075 | 6075 | 'select' => '', |
| 6076 | 6076 | 'join' => '' |
| 6077 | 6077 | ); |
| 6078 | - if(isset($this->custom_fields)) |
|
| 6078 | + if (isset($this->custom_fields)) |
|
| 6079 | 6079 | { |
| 6080 | 6080 | $result = $this->custom_fields->getJOIN($expandedList, $includeRelates, $where); |
| 6081 | 6081 | } |
@@ -6097,7 +6097,7 @@ discard block |
||
| 6097 | 6097 | // walk through all currency-related fields |
| 6098 | 6098 | foreach ($this->field_defs as $this_field) { |
| 6099 | 6099 | if (isset($this_field['type']) && $this_field['type'] == 'relate' |
| 6100 | - && isset($this_field['module']) && $this_field['module'] == 'Currencies' |
|
| 6100 | + && isset($this_field['module']) && $this_field['module'] == 'Currencies' |
|
| 6101 | 6101 | && isset($this_field['id_name']) && $this_field['id_name'] == 'currency_id') { |
| 6102 | 6102 | // populate related properties manually |
| 6103 | 6103 | $this_property = $this_field['name']; |
@@ -48,8 +48,8 @@ |
||
| 48 | 48 | $mod_strings = array ( |
| 49 | 49 | 'LBL_DELETE_USER_CONFIRM' => 'When the User record is deleted, the corresponding Employee record will also be deleted. After the user is deleted, any workflow definitions and reports involving the user might need to be updated.<br/><br/> Deleting a User record cannot be undone.', |
| 50 | 50 | |
| 51 | - 'LBL_DELETE_GROUP_CONFIRM' => 'Are you sure you want to delete this Group User? Click OK to delete the User record.<br/>After clicking OK, you will be given the ability to reassign records assigned to the Group User to another user.', |
|
| 52 | - 'LBL_DELETE_PORTAL_CONFIRM' => 'Are you sure you want to delete this Portal API User? Click OK to delete the User record.', |
|
| 51 | + 'LBL_DELETE_GROUP_CONFIRM' => 'Are you sure you want to delete this Group User? Click OK to delete the User record.<br/>After clicking OK, you will be given the ability to reassign records assigned to the Group User to another user.', |
|
| 52 | + 'LBL_DELETE_PORTAL_CONFIRM' => 'Are you sure you want to delete this Portal API User? Click OK to delete the User record.', |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | 'LNK_IMPORT_USERS' => 'Import Users', |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | ********************************************************************************/ |
| 40 | 40 | /* BEGIN - SECURITY GROUPS */ |
| 41 | 41 | if(file_exists("modules/ACLActions/actiondefs.override.php")){ |
| 42 | - require_once("modules/ACLActions/actiondefs.override.php"); |
|
| 42 | + require_once("modules/ACLActions/actiondefs.override.php"); |
|
| 43 | 43 | } else { |
| 44 | 44 | require_once('modules/ACLActions/actiondefs.php'); |
| 45 | 45 | } |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * static addActions($category, $type='module') |
|
| 59 | - * Adds all default actions for a category/type |
|
| 60 | - * |
|
| 61 | - * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
| 62 | - * @param STRING $type - the type (e.g. 'module', 'field') |
|
| 63 | - */ |
|
| 58 | + * static addActions($category, $type='module') |
|
| 59 | + * Adds all default actions for a category/type |
|
| 60 | + * |
|
| 61 | + * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
| 62 | + * @param STRING $type - the type (e.g. 'module', 'field') |
|
| 63 | + */ |
|
| 64 | 64 | static function addActions($category, $type='module'){ |
| 65 | 65 | global $ACLActions; |
| 66 | 66 | $db = DBManagerFactory::getInstance(); |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * static removeActions($category, $type='module') |
|
| 95 | - * Removes all default actions for a category/type |
|
| 96 | - * |
|
| 97 | - * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
| 98 | - * @param STRING $type - the type (e.g. 'module', 'field') |
|
| 99 | - */ |
|
| 94 | + * static removeActions($category, $type='module') |
|
| 95 | + * Removes all default actions for a category/type |
|
| 96 | + * |
|
| 97 | + * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
|
| 98 | + * @param STRING $type - the type (e.g. 'module', 'field') |
|
| 99 | + */ |
|
| 100 | 100 | public static function removeActions($category, $type='module'){ |
| 101 | 101 | global $ACLActions; |
| 102 | 102 | $db = DBManagerFactory::getInstance(); |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | - * static AccessColor($access) |
|
| 122 | - * |
|
| 123 | - * returns the color associated with an access level |
|
| 124 | - * these colors exist in the definitions in modules/ACLActions/actiondefs.php |
|
| 125 | - * @param INT $access - the access level you want the color for |
|
| 126 | - * @return the color either name or hex representation or false if the level does not exist |
|
| 127 | - */ |
|
| 121 | + * static AccessColor($access) |
|
| 122 | + * |
|
| 123 | + * returns the color associated with an access level |
|
| 124 | + * these colors exist in the definitions in modules/ACLActions/actiondefs.php |
|
| 125 | + * @param INT $access - the access level you want the color for |
|
| 126 | + * @return the color either name or hex representation or false if the level does not exist |
|
| 127 | + */ |
|
| 128 | 128 | protected static function AccessColor($access){ |
| 129 | 129 | global $ACLActionAccessLevels; |
| 130 | 130 | if(isset($ACLActionAccessLevels[$access])){ |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | - * static AccessName($access) |
|
| 140 | - * |
|
| 141 | - * returns the translated name associated with an access level |
|
| 142 | - * these label definitions exist in the definitions in modules/ACLActions/actiondefs.php |
|
| 143 | - * @param INT $access - the access level you want the color for |
|
| 144 | - * @return the translated access level name or false if the level does not exist |
|
| 145 | - */ |
|
| 139 | + * static AccessName($access) |
|
| 140 | + * |
|
| 141 | + * returns the translated name associated with an access level |
|
| 142 | + * these label definitions exist in the definitions in modules/ACLActions/actiondefs.php |
|
| 143 | + * @param INT $access - the access level you want the color for |
|
| 144 | + * @return the translated access level name or false if the level does not exist |
|
| 145 | + */ |
|
| 146 | 146 | static function AccessName($access){ |
| 147 | 147 | global $ACLActionAccessLevels; |
| 148 | 148 | if(isset($ACLActionAccessLevels[$access])){ |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * static getAccessOptions() |
|
| 176 | - * this is used for building select boxes |
|
| 177 | - * @return array containg access levels (ints) as keys and access names as values |
|
| 178 | - */ |
|
| 175 | + * static getAccessOptions() |
|
| 176 | + * this is used for building select boxes |
|
| 177 | + * @return array containg access levels (ints) as keys and access names as values |
|
| 178 | + */ |
|
| 179 | 179 | protected static function getAccessOptions( $action, $type='module'){ |
| 180 | 180 | global $ACLActions; |
| 181 | 181 | $options = array(); |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * function static getDefaultActions() |
|
| 193 | - * This function will return a list of acl actions with their default access levels |
|
| 194 | - * |
|
| 195 | - * |
|
| 196 | - */ |
|
| 192 | + * function static getDefaultActions() |
|
| 193 | + * This function will return a list of acl actions with their default access levels |
|
| 194 | + * |
|
| 195 | + * |
|
| 196 | + */ |
|
| 197 | 197 | public static function getDefaultActions($type='module', $action=''){ |
| 198 | 198 | $query = "SELECT * FROM acl_actions WHERE deleted=0 "; |
| 199 | 199 | if(!empty($type)){ |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | - * static getUserActions($user_id,$refresh=false, $category='', $action='') |
|
| 221 | - * returns a list of user actions |
|
| 222 | - * @param GUID $user_id |
|
| 223 | - * @param BOOLEAN $refresh |
|
| 224 | - * @param STRING $category |
|
| 225 | - * @param STRING $action |
|
| 226 | - * @return ARRAY of ACLActionsArray |
|
| 227 | - */ |
|
| 220 | + * static getUserActions($user_id,$refresh=false, $category='', $action='') |
|
| 221 | + * returns a list of user actions |
|
| 222 | + * @param GUID $user_id |
|
| 223 | + * @param BOOLEAN $refresh |
|
| 224 | + * @param STRING $category |
|
| 225 | + * @param STRING $action |
|
| 226 | + * @return ARRAY of ACLActionsArray |
|
| 227 | + */ |
|
| 228 | 228 | |
| 229 | 229 | static function getUserActions($user_id,$refresh=false, $category='',$type='', $action=''){ |
| 230 | 230 | //check in the session if we already have it loaded |
@@ -256,15 +256,15 @@ discard block |
||
| 256 | 256 | if(!empty($type)){ |
| 257 | 257 | $additional_where .= " AND acl_actions.acltype = '$type' "; |
| 258 | 258 | } |
| 259 | - /* BEGIN - SECURITY GROUPS */ |
|
| 260 | - /** |
|
| 259 | + /* BEGIN - SECURITY GROUPS */ |
|
| 260 | + /** |
|
| 261 | 261 | $query = "SELECT acl_actions .*, acl_roles_actions.access_override |
| 262 | 262 | FROM acl_actions |
| 263 | 263 | LEFT JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' AND acl_roles_users.deleted = 0 |
| 264 | 264 | LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted=0 |
| 265 | 265 | WHERE acl_actions.deleted=0 $additional_where ORDER BY category,name"; |
| 266 | - */ |
|
| 267 | - $query = "(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role |
|
| 266 | + */ |
|
| 267 | + $query = "(SELECT acl_actions .*, acl_roles_actions.access_override, 1 as user_role |
|
| 268 | 268 | FROM acl_actions |
| 269 | 269 | INNER JOIN acl_roles_users ON acl_roles_users.user_id = '$user_id' AND acl_roles_users.deleted = 0 |
| 270 | 270 | LEFT JOIN acl_roles_actions ON acl_roles_actions.role_id = acl_roles_users.role_id AND acl_roles_actions.action_id = acl_actions.id AND acl_roles_actions.deleted=0 |
@@ -286,34 +286,34 @@ discard block |
||
| 286 | 286 | WHERE acl_actions.deleted = 0 ) |
| 287 | 287 | |
| 288 | 288 | ORDER BY user_role desc, category,name,access_override desc"; //want non-null to show first |
| 289 | - /* END - SECURITY GROUPS */ |
|
| 289 | + /* END - SECURITY GROUPS */ |
|
| 290 | 290 | $result = $db->query($query); |
| 291 | 291 | $selected_actions = array(); |
| 292 | - /* BEGIN - SECURITY GROUPS */ |
|
| 293 | - global $sugar_config; |
|
| 294 | - $has_user_role = false; //used for user_role_precedence |
|
| 295 | - $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
|
| 296 | - /* END - SECURITY GROUPS */ |
|
| 292 | + /* BEGIN - SECURITY GROUPS */ |
|
| 293 | + global $sugar_config; |
|
| 294 | + $has_user_role = false; //used for user_role_precedence |
|
| 295 | + $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
|
| 296 | + /* END - SECURITY GROUPS */ |
|
| 297 | 297 | while($row = $db->fetchByAssoc($result, FALSE) ){ |
| 298 | - /* BEGIN - SECURITY GROUPS */ |
|
| 299 | - if($has_user_role == false && $row['user_role'] == 1) { |
|
| 300 | - $has_user_role = true; |
|
| 301 | - } |
|
| 302 | - if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
| 303 | - $has_role = true; |
|
| 304 | - } |
|
| 305 | - //if user roles should take precedence over group roles and we have a user role |
|
| 306 | - //break when we get to processing the group roles |
|
| 307 | - if($has_user_role == true && $row['user_role'] == 0 |
|
| 308 | - && isset($sugar_config['securitysuite_user_role_precedence']) |
|
| 309 | - && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
| 310 | - { |
|
| 311 | - break; |
|
| 312 | - } |
|
| 313 | - if($row['user_role'] == -1 && $has_role == true) { |
|
| 314 | - break; //no need for default actions when a role is assigned to the user or user's group already |
|
| 315 | - } |
|
| 316 | - /* END - SECURITY GROUPS */ |
|
| 298 | + /* BEGIN - SECURITY GROUPS */ |
|
| 299 | + if($has_user_role == false && $row['user_role'] == 1) { |
|
| 300 | + $has_user_role = true; |
|
| 301 | + } |
|
| 302 | + if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
| 303 | + $has_role = true; |
|
| 304 | + } |
|
| 305 | + //if user roles should take precedence over group roles and we have a user role |
|
| 306 | + //break when we get to processing the group roles |
|
| 307 | + if($has_user_role == true && $row['user_role'] == 0 |
|
| 308 | + && isset($sugar_config['securitysuite_user_role_precedence']) |
|
| 309 | + && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
| 310 | + { |
|
| 311 | + break; |
|
| 312 | + } |
|
| 313 | + if($row['user_role'] == -1 && $has_role == true) { |
|
| 314 | + break; //no need for default actions when a role is assigned to the user or user's group already |
|
| 315 | + } |
|
| 316 | + /* END - SECURITY GROUPS */ |
|
| 317 | 317 | $acl = new ACLAction(); |
| 318 | 318 | $isOverride = false; |
| 319 | 319 | $acl->populateFromRow($row); |
@@ -326,16 +326,16 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | } |
| 328 | 328 | if(!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
| 329 | - || ( |
|
| 330 | - /* BEGIN - SECURITY GROUPS - additive security*/ |
|
| 331 | - ( |
|
| 332 | - (isset($sugar_config['securitysuite_additive']) && $sugar_config['securitysuite_additive'] == true |
|
| 333 | - && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] < $acl->aclaccess) |
|
| 334 | - || |
|
| 335 | - ((!isset($sugar_config['securitysuite_additive']) || $sugar_config['securitysuite_additive'] == false) |
|
| 336 | - && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] > $acl->aclaccess) |
|
| 337 | - ) |
|
| 338 | - /* END - SECURITY GROUPS */ |
|
| 329 | + || ( |
|
| 330 | + /* BEGIN - SECURITY GROUPS - additive security*/ |
|
| 331 | + ( |
|
| 332 | + (isset($sugar_config['securitysuite_additive']) && $sugar_config['securitysuite_additive'] == true |
|
| 333 | + && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] < $acl->aclaccess) |
|
| 334 | + || |
|
| 335 | + ((!isset($sugar_config['securitysuite_additive']) || $sugar_config['securitysuite_additive'] == false) |
|
| 336 | + && $selected_actions[$acl->category][$acl->acltype][$acl->name]['aclaccess'] > $acl->aclaccess) |
|
| 337 | + ) |
|
| 338 | + /* END - SECURITY GROUPS */ |
|
| 339 | 339 | && $isOverride |
| 340 | 340 | ) |
| 341 | 341 | || |
@@ -388,70 +388,70 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | - * (static/ non-static)function hasAccess($is_owner= false , $access = 0) |
|
| 392 | - * checks if a user has access to this acl if the user is an owner it will check if owners have access |
|
| 393 | - * |
|
| 394 | - * This function may either be used statically or not. If used staticlly a user must pass in an access level not equal to zero |
|
| 395 | - * @param boolean $is_owner |
|
| 396 | - * @param int $access |
|
| 397 | - * @return true or false |
|
| 398 | - */ |
|
| 399 | - /* BEGIN - SECURITY GROUPS */ |
|
| 400 | - /** |
|
| 391 | + * (static/ non-static)function hasAccess($is_owner= false , $access = 0) |
|
| 392 | + * checks if a user has access to this acl if the user is an owner it will check if owners have access |
|
| 393 | + * |
|
| 394 | + * This function may either be used statically or not. If used staticlly a user must pass in an access level not equal to zero |
|
| 395 | + * @param boolean $is_owner |
|
| 396 | + * @param int $access |
|
| 397 | + * @return true or false |
|
| 398 | + */ |
|
| 399 | + /* BEGIN - SECURITY GROUPS */ |
|
| 400 | + /** |
|
| 401 | 401 | static function hasAccess($is_owner=false, $access = 0){ |
| 402 | - */ |
|
| 403 | - static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
| 404 | - /** |
|
| 402 | + */ |
|
| 403 | + static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
| 404 | + /** |
|
| 405 | 405 | if($access != 0 && $access == ACL_ALLOW_ALL || ($is_owner && $access == ACL_ALLOW_OWNER))return true; |
| 406 | 406 | //if this exists, then this function is not static, so check the aclaccess parameter |
| 407 | 407 | if(isset($this) && isset($this->aclaccess)){ |
| 408 | 408 | if($this->aclaccess == ACL_ALLOW_ALL || ($is_owner && $this->aclaccess == ACL_ALLOW_OWNER)) |
| 409 | 409 | return true; |
| 410 | 410 | } |
| 411 | - */ |
|
| 412 | - if($access != 0 && ($access == ACL_ALLOW_ALL |
|
| 413 | - || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
| 414 | - || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
| 415 | - )) { |
|
| 416 | - return true; |
|
| 417 | - } |
|
| 411 | + */ |
|
| 412 | + if($access != 0 && ($access == ACL_ALLOW_ALL |
|
| 413 | + || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
| 414 | + || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
| 415 | + )) { |
|
| 416 | + return true; |
|
| 417 | + } |
|
| 418 | 418 | if(!is_null($action) && isset($action->aclaccess)){ |
| 419 | - if($action->aclaccess == ACL_ALLOW_ALL |
|
| 420 | - || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
|
| 421 | - || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
| 422 | - ) { |
|
| 423 | - return true; |
|
| 424 | - } |
|
| 425 | - } |
|
| 419 | + if($action->aclaccess == ACL_ALLOW_ALL |
|
| 420 | + || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
|
| 421 | + || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
|
| 422 | + ) { |
|
| 423 | + return true; |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | 426 | return false; |
| 427 | 427 | } |
| 428 | - /* END - SECURITY GROUPS */ |
|
| 429 | - |
|
| 430 | - /* BEGIN - SECURITY GROUPS */ |
|
| 431 | - /** |
|
| 432 | - * STATIC function userNeedsSecurityGroup($user_id, $category, $action,$type='module') |
|
| 433 | - * checks if a user should have ownership to do an action |
|
| 434 | - * |
|
| 435 | - * @param GUID $user_id |
|
| 436 | - * @param STRING $category |
|
| 437 | - * @param STRING $action |
|
| 438 | - * @param STRING $type |
|
| 439 | - * @return boolean |
|
| 440 | - */ |
|
| 441 | - static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
| 442 | - //check if we don't have it set in the cache if not lets reload the cache |
|
| 428 | + /* END - SECURITY GROUPS */ |
|
| 429 | + |
|
| 430 | + /* BEGIN - SECURITY GROUPS */ |
|
| 431 | + /** |
|
| 432 | + * STATIC function userNeedsSecurityGroup($user_id, $category, $action,$type='module') |
|
| 433 | + * checks if a user should have ownership to do an action |
|
| 434 | + * |
|
| 435 | + * @param GUID $user_id |
|
| 436 | + * @param STRING $category |
|
| 437 | + * @param STRING $action |
|
| 438 | + * @param STRING $type |
|
| 439 | + * @return boolean |
|
| 440 | + */ |
|
| 441 | + static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
| 442 | + //check if we don't have it set in the cache if not lets reload the cache |
|
| 443 | 443 | |
| 444 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 445 | - ACLAction::getUserActions($user_id, false); |
|
| 444 | + if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 445 | + ACLAction::getUserActions($user_id, false); |
|
| 446 | 446 | |
| 447 | - } |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 450 | - return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
|
| 451 | - } |
|
| 449 | + if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 450 | + return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
|
| 451 | + } |
|
| 452 | 452 | return false; |
| 453 | 453 | } |
| 454 | - /* END - SECURITY GROUPS */ |
|
| 454 | + /* END - SECURITY GROUPS */ |
|
| 455 | 455 | |
| 456 | 456 | |
| 457 | 457 | |
@@ -461,20 +461,20 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | |
| 463 | 463 | /** |
| 464 | - * static function userHasAccess($user_id, $category, $action, $is_owner = false) |
|
| 465 | - * |
|
| 466 | - * @param GUID $user_id the user id who you want to check access for |
|
| 467 | - * @param STRING $category the category you would like to check access for |
|
| 468 | - * @param STRING $action the action of that category you would like to check access for |
|
| 469 | - * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for |
|
| 470 | - */ |
|
| 471 | - /* BEGIN - SECURITY GROUPS - added $in_group */ |
|
| 472 | - /** |
|
| 464 | + * static function userHasAccess($user_id, $category, $action, $is_owner = false) |
|
| 465 | + * |
|
| 466 | + * @param GUID $user_id the user id who you want to check access for |
|
| 467 | + * @param STRING $category the category you would like to check access for |
|
| 468 | + * @param STRING $action the action of that category you would like to check access for |
|
| 469 | + * @param BOOLEAN OPTIONAL $is_owner if the object is owned by the user you are checking access for |
|
| 470 | + */ |
|
| 471 | + /* BEGIN - SECURITY GROUPS - added $in_group */ |
|
| 472 | + /** |
|
| 473 | 473 | public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){ |
| 474 | - */ |
|
| 475 | - public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
| 476 | - global $current_user; |
|
| 477 | - if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
| 474 | + */ |
|
| 475 | + public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
| 476 | + global $current_user; |
|
| 477 | + if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
| 478 | 478 | return true; |
| 479 | 479 | } |
| 480 | 480 | //check if we don't have it set in the cache if not lets reload the cache |
@@ -488,22 +488,22 @@ discard block |
||
| 488 | 488 | /** |
| 489 | 489 | return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
| 490 | 490 | */ |
| 491 | - return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
|
| 491 | + return ACLAction::hasAccess($is_owner, $in_group, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
|
| 492 | 492 | } |
| 493 | 493 | return false; |
| 494 | 494 | |
| 495 | 495 | } |
| 496 | - /* END - SECURITY GROUPS */ |
|
| 496 | + /* END - SECURITY GROUPS */ |
|
| 497 | 497 | /** |
| 498 | - * function getUserAccessLevel($user_id, $category, $action,$type='module') |
|
| 499 | - * returns the access level for a given category and action |
|
| 500 | - * |
|
| 501 | - * @param GUID $user_id |
|
| 502 | - * @param STRING $category |
|
| 503 | - * @param STRING $action |
|
| 504 | - * @param STRING $type |
|
| 505 | - * @return INT (ACCESS LEVEL) |
|
| 506 | - */ |
|
| 498 | + * function getUserAccessLevel($user_id, $category, $action,$type='module') |
|
| 499 | + * returns the access level for a given category and action |
|
| 500 | + * |
|
| 501 | + * @param GUID $user_id |
|
| 502 | + * @param STRING $category |
|
| 503 | + * @param STRING $action |
|
| 504 | + * @param STRING $type |
|
| 505 | + * @return INT (ACCESS LEVEL) |
|
| 506 | + */ |
|
| 507 | 507 | public static function getUserAccessLevel($user_id, $category, $action,$type='module'){ |
| 508 | 508 | if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
| 509 | 509 | ACLAction::getUserActions($user_id, false); |
@@ -520,15 +520,15 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
| 523 | - * STATIC function userNeedsOwnership($user_id, $category, $action,$type='module') |
|
| 524 | - * checks if a user should have ownership to do an action |
|
| 525 | - * |
|
| 526 | - * @param GUID $user_id |
|
| 527 | - * @param STRING $category |
|
| 528 | - * @param STRING $action |
|
| 529 | - * @param STRING $type |
|
| 530 | - * @return boolean |
|
| 531 | - */ |
|
| 523 | + * STATIC function userNeedsOwnership($user_id, $category, $action,$type='module') |
|
| 524 | + * checks if a user should have ownership to do an action |
|
| 525 | + * |
|
| 526 | + * @param GUID $user_id |
|
| 527 | + * @param STRING $category |
|
| 528 | + * @param STRING $action |
|
| 529 | + * @param STRING $type |
|
| 530 | + * @return boolean |
|
| 531 | + */ |
|
| 532 | 532 | public static function userNeedsOwnership($user_id, $category, $action,$type='module'){ |
| 533 | 533 | //check if we don't have it set in the cache if not lets reload the cache |
| 534 | 534 | |
@@ -545,12 +545,12 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | } |
| 547 | 547 | /** |
| 548 | - * |
|
| 549 | - * static pass by ref setupCategoriesMatrix(&$categories) |
|
| 550 | - * takes in an array of categories and modifes them adding display information |
|
| 551 | - * |
|
| 552 | - * @param unknown_type $categories |
|
| 553 | - */ |
|
| 548 | + * |
|
| 549 | + * static pass by ref setupCategoriesMatrix(&$categories) |
|
| 550 | + * takes in an array of categories and modifes them adding display information |
|
| 551 | + * |
|
| 552 | + * @param unknown_type $categories |
|
| 553 | + */ |
|
| 554 | 554 | public static function setupCategoriesMatrix(&$categories){ |
| 555 | 555 | global $ACLActions, $current_user; |
| 556 | 556 | $names = array(); |
@@ -593,11 +593,11 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | |
| 595 | 595 | /** |
| 596 | - * function toArray() |
|
| 597 | - * returns this acl as an array |
|
| 598 | - * |
|
| 599 | - * @return array of fields with id, name, access and category |
|
| 600 | - */ |
|
| 596 | + * function toArray() |
|
| 597 | + * returns this acl as an array |
|
| 598 | + * |
|
| 599 | + * @return array of fields with id, name, access and category |
|
| 600 | + */ |
|
| 601 | 601 | function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false){ |
| 602 | 602 | $array_fields = array('id', 'aclaccess'); |
| 603 | 603 | $arr = array(); |
@@ -608,11 +608,11 @@ discard block |
||
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
| 611 | - * function fromArray($arr) |
|
| 612 | - * converts an array into an acl mapping name value pairs into files |
|
| 613 | - * |
|
| 614 | - * @param Array $arr |
|
| 615 | - */ |
|
| 611 | + * function fromArray($arr) |
|
| 612 | + * converts an array into an acl mapping name value pairs into files |
|
| 613 | + * |
|
| 614 | + * @param Array $arr |
|
| 615 | + */ |
|
| 616 | 616 | function fromArray($arr){ |
| 617 | 617 | foreach($arr as $name=>$value){ |
| 618 | 618 | $this->$name = $value; |
@@ -620,10 +620,10 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /** |
| 623 | - * function clearSessionCache() |
|
| 624 | - * clears the session variable storing the cache information for acls |
|
| 625 | - * |
|
| 626 | - */ |
|
| 623 | + * function clearSessionCache() |
|
| 624 | + * clears the session variable storing the cache information for acls |
|
| 625 | + * |
|
| 626 | + */ |
|
| 627 | 627 | function clearSessionCache(){ |
| 628 | 628 | unset($_SESSION['ACL']); |
| 629 | 629 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
| 3 | 3 | /********************************************************************************* |
| 4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
| 5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
| 39 | 39 | ********************************************************************************/ |
| 40 | 40 | /* BEGIN - SECURITY GROUPS */ |
| 41 | -if(file_exists("modules/ACLActions/actiondefs.override.php")){ |
|
| 41 | +if (file_exists("modules/ACLActions/actiondefs.override.php")) { |
|
| 42 | 42 | require_once("modules/ACLActions/actiondefs.override.php"); |
| 43 | 43 | } else { |
| 44 | 44 | require_once('modules/ACLActions/actiondefs.php'); |
| 45 | 45 | } |
| 46 | 46 | /* END - SECURITY GROUPS */ |
| 47 | -class ACLAction extends SugarBean{ |
|
| 47 | +class ACLAction extends SugarBean { |
|
| 48 | 48 | var $module_dir = 'ACLActions'; |
| 49 | 49 | var $object_name = 'ACLAction'; |
| 50 | 50 | var $table_name = 'acl_actions'; |
| 51 | 51 | var $new_schema = true; |
| 52 | 52 | var $disable_custom_fields = true; |
| 53 | - function ACLAction(){ |
|
| 53 | + function ACLAction() { |
|
| 54 | 54 | parent::SugarBean(); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -61,17 +61,17 @@ discard block |
||
| 61 | 61 | * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
| 62 | 62 | * @param STRING $type - the type (e.g. 'module', 'field') |
| 63 | 63 | */ |
| 64 | - static function addActions($category, $type='module'){ |
|
| 64 | + static function addActions($category, $type = 'module') { |
|
| 65 | 65 | global $ACLActions; |
| 66 | 66 | $db = DBManagerFactory::getInstance(); |
| 67 | - if(isset($ACLActions[$type])){ |
|
| 68 | - foreach($ACLActions[$type]['actions'] as $action_name =>$action_def){ |
|
| 67 | + if (isset($ACLActions[$type])) { |
|
| 68 | + foreach ($ACLActions[$type]['actions'] as $action_name =>$action_def) { |
|
| 69 | 69 | |
| 70 | 70 | $action = new ACLAction(); |
| 71 | - $query = "SELECT * FROM " . $action->table_name . " WHERE name='$action_name' AND category = '$category' AND acltype='$type' AND deleted=0 "; |
|
| 71 | + $query = "SELECT * FROM ".$action->table_name." WHERE name='$action_name' AND category = '$category' AND acltype='$type' AND deleted=0 "; |
|
| 72 | 72 | $result = $db->query($query); |
| 73 | 73 | //only add if an action with that name and category don't exist |
| 74 | - $row=$db->fetchByAssoc($result); |
|
| 74 | + $row = $db->fetchByAssoc($result); |
|
| 75 | 75 | if ($row == null) { |
| 76 | 76 | $action->name = $action_name; |
| 77 | 77 | $action->category = $category; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - }else{ |
|
| 87 | + } else { |
|
| 88 | 88 | sugar_die("FAILED TO ADD: $category - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -97,22 +97,22 @@ discard block |
||
| 97 | 97 | * @param STRING $category - the category (e.g module name - Accounts, Contacts) |
| 98 | 98 | * @param STRING $type - the type (e.g. 'module', 'field') |
| 99 | 99 | */ |
| 100 | - public static function removeActions($category, $type='module'){ |
|
| 100 | + public static function removeActions($category, $type = 'module') { |
|
| 101 | 101 | global $ACLActions; |
| 102 | 102 | $db = DBManagerFactory::getInstance(); |
| 103 | - if(isset($ACLActions[$type])){ |
|
| 104 | - foreach($ACLActions[$type]['actions'] as $action_name =>$action_def){ |
|
| 103 | + if (isset($ACLActions[$type])) { |
|
| 104 | + foreach ($ACLActions[$type]['actions'] as $action_name =>$action_def) { |
|
| 105 | 105 | |
| 106 | 106 | $action = new ACLAction(); |
| 107 | - $query = "SELECT * FROM " . $action->table_name . " WHERE name='$action_name' AND category = '$category' AND acltype='$type' and deleted=0"; |
|
| 107 | + $query = "SELECT * FROM ".$action->table_name." WHERE name='$action_name' AND category = '$category' AND acltype='$type' and deleted=0"; |
|
| 108 | 108 | $result = $db->query($query); |
| 109 | 109 | //only add if an action with that name and category don't exist |
| 110 | - $row=$db->fetchByAssoc($result); |
|
| 110 | + $row = $db->fetchByAssoc($result); |
|
| 111 | 111 | if ($row != null) { |
| 112 | 112 | $action->mark_deleted($row['id']); |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | - }else{ |
|
| 115 | + } else { |
|
| 116 | 116 | sugar_die("FAILED TO REMOVE: $category : $name - TYPE $type NOT DEFINED IN modules/ACLActions/actiondefs.php"); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @param INT $access - the access level you want the color for |
| 126 | 126 | * @return the color either name or hex representation or false if the level does not exist |
| 127 | 127 | */ |
| 128 | - protected static function AccessColor($access){ |
|
| 128 | + protected static function AccessColor($access) { |
|
| 129 | 129 | global $ACLActionAccessLevels; |
| 130 | - if(isset($ACLActionAccessLevels[$access])){ |
|
| 130 | + if (isset($ACLActionAccessLevels[$access])) { |
|
| 131 | 131 | |
| 132 | 132 | return $ACLActionAccessLevels[$access]['color']; |
| 133 | 133 | } |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | * @param INT $access - the access level you want the color for |
| 144 | 144 | * @return the translated access level name or false if the level does not exist |
| 145 | 145 | */ |
| 146 | - static function AccessName($access){ |
|
| 146 | + static function AccessName($access) { |
|
| 147 | 147 | global $ACLActionAccessLevels; |
| 148 | - if(isset($ACLActionAccessLevels[$access])){ |
|
| 148 | + if (isset($ACLActionAccessLevels[$access])) { |
|
| 149 | 149 | return translate($ACLActionAccessLevels[$access]['label'], 'ACLActions'); |
| 150 | 150 | } |
| 151 | 151 | return false; |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | * @param INT $access - the access level you want the color for |
| 161 | 161 | * @return the access level label or false if the level does not exist |
| 162 | 162 | */ |
| 163 | - protected static function AccessLabel($access){ |
|
| 163 | + protected static function AccessLabel($access) { |
|
| 164 | 164 | global $ACLActionAccessLevels; |
| 165 | - if(isset($ACLActionAccessLevels[$access])){ |
|
| 166 | - $label=preg_replace('/(LBL_ACCESS_)(.*)/', '$2', $ACLActionAccessLevels[$access]['label']); |
|
| 165 | + if (isset($ACLActionAccessLevels[$access])) { |
|
| 166 | + $label = preg_replace('/(LBL_ACCESS_)(.*)/', '$2', $ACLActionAccessLevels[$access]['label']); |
|
| 167 | 167 | return strtolower($label); |
| 168 | 168 | |
| 169 | 169 | } |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | * this is used for building select boxes |
| 177 | 177 | * @return array containg access levels (ints) as keys and access names as values |
| 178 | 178 | */ |
| 179 | - protected static function getAccessOptions( $action, $type='module'){ |
|
| 179 | + protected static function getAccessOptions($action, $type = 'module') { |
|
| 180 | 180 | global $ACLActions; |
| 181 | 181 | $options = array(); |
| 182 | 182 | |
| 183 | - if(empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
| 184 | - foreach($ACLActions[$type]['actions'][$action]['aclaccess'] as $action){ |
|
| 183 | + if (empty($ACLActions[$type]['actions'][$action]['aclaccess']))return $options; |
|
| 184 | + foreach ($ACLActions[$type]['actions'][$action]['aclaccess'] as $action) { |
|
| 185 | 185 | $options[$action] = ACLAction::AccessName($action); |
| 186 | 186 | } |
| 187 | 187 | return $options; |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * |
| 196 | 196 | */ |
| 197 | - public static function getDefaultActions($type='module', $action=''){ |
|
| 197 | + public static function getDefaultActions($type = 'module', $action = '') { |
|
| 198 | 198 | $query = "SELECT * FROM acl_actions WHERE deleted=0 "; |
| 199 | - if(!empty($type)){ |
|
| 199 | + if (!empty($type)) { |
|
| 200 | 200 | $query .= " AND acltype='$type'"; |
| 201 | 201 | } |
| 202 | - if(!empty($action)){ |
|
| 202 | + if (!empty($action)) { |
|
| 203 | 203 | $query .= "AND name='$action'"; |
| 204 | 204 | } |
| 205 | 205 | $query .= " ORDER BY category"; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $db = DBManagerFactory::getInstance(); |
| 208 | 208 | $result = $db->query($query); |
| 209 | 209 | $default_actions = array(); |
| 210 | - while($row = $db->fetchByAssoc($result) ){ |
|
| 210 | + while ($row = $db->fetchByAssoc($result)) { |
|
| 211 | 211 | $acl = new ACLAction(); |
| 212 | 212 | $acl->populateFromRow($row); |
| 213 | 213 | $default_actions[] = $acl; |
@@ -226,19 +226,19 @@ discard block |
||
| 226 | 226 | * @return ARRAY of ACLActionsArray |
| 227 | 227 | */ |
| 228 | 228 | |
| 229 | - static function getUserActions($user_id,$refresh=false, $category='',$type='', $action=''){ |
|
| 229 | + static function getUserActions($user_id, $refresh = false, $category = '', $type = '', $action = '') { |
|
| 230 | 230 | //check in the session if we already have it loaded |
| 231 | - if(!$refresh && !empty($_SESSION['ACL'][$user_id])){ |
|
| 232 | - if(empty($category) && empty($action)){ |
|
| 231 | + if (!$refresh && !empty($_SESSION['ACL'][$user_id])) { |
|
| 232 | + if (empty($category) && empty($action)) { |
|
| 233 | 233 | return $_SESSION['ACL'][$user_id]; |
| 234 | - }else{ |
|
| 235 | - if(!empty($category) && isset($_SESSION['ACL'][$user_id][$category])){ |
|
| 236 | - if(empty($action)){ |
|
| 237 | - if(empty($type)){ |
|
| 234 | + } else { |
|
| 235 | + if (!empty($category) && isset($_SESSION['ACL'][$user_id][$category])) { |
|
| 236 | + if (empty($action)) { |
|
| 237 | + if (empty($type)) { |
|
| 238 | 238 | return $_SESSION['ACL'][$user_id][$category]; |
| 239 | 239 | } |
| 240 | 240 | return $_SESSION['ACL'][$user_id][$category][$type]; |
| 241 | - }else if(!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 241 | + } else if (!empty($type) && isset($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 242 | 242 | return $_SESSION['ACL'][$user_id][$category][$type][$action]; |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -247,13 +247,13 @@ discard block |
||
| 247 | 247 | //if we don't have it loaded then lets check against the db |
| 248 | 248 | $additional_where = ''; |
| 249 | 249 | $db = DBManagerFactory::getInstance(); |
| 250 | - if(!empty($category)){ |
|
| 250 | + if (!empty($category)) { |
|
| 251 | 251 | $additional_where .= " AND acl_actions.category = '$category' "; |
| 252 | 252 | } |
| 253 | - if(!empty($action)){ |
|
| 253 | + if (!empty($action)) { |
|
| 254 | 254 | $additional_where .= " AND acl_actions.name = '$action' "; |
| 255 | 255 | } |
| 256 | - if(!empty($type)){ |
|
| 256 | + if (!empty($type)) { |
|
| 257 | 257 | $additional_where .= " AND acl_actions.acltype = '$type' "; |
| 258 | 258 | } |
| 259 | 259 | /* BEGIN - SECURITY GROUPS */ |
@@ -294,38 +294,38 @@ discard block |
||
| 294 | 294 | $has_user_role = false; //used for user_role_precedence |
| 295 | 295 | $has_role = false; //used to determine if default actions can be ignored. If a user has a defined role don't use the defaults |
| 296 | 296 | /* END - SECURITY GROUPS */ |
| 297 | - while($row = $db->fetchByAssoc($result, FALSE) ){ |
|
| 297 | + while ($row = $db->fetchByAssoc($result, FALSE)) { |
|
| 298 | 298 | /* BEGIN - SECURITY GROUPS */ |
| 299 | - if($has_user_role == false && $row['user_role'] == 1) { |
|
| 299 | + if ($has_user_role == false && $row['user_role'] == 1) { |
|
| 300 | 300 | $has_user_role = true; |
| 301 | 301 | } |
| 302 | - if($has_role == false && ($row['user_role'] == 1 || $row['user_role'] ==0)) { |
|
| 302 | + if ($has_role == false && ($row['user_role'] == 1 || $row['user_role'] == 0)) { |
|
| 303 | 303 | $has_role = true; |
| 304 | 304 | } |
| 305 | 305 | //if user roles should take precedence over group roles and we have a user role |
| 306 | 306 | //break when we get to processing the group roles |
| 307 | - if($has_user_role == true && $row['user_role'] == 0 |
|
| 307 | + if ($has_user_role == true && $row['user_role'] == 0 |
|
| 308 | 308 | && isset($sugar_config['securitysuite_user_role_precedence']) |
| 309 | - && $sugar_config['securitysuite_user_role_precedence'] == true ) |
|
| 309 | + && $sugar_config['securitysuite_user_role_precedence'] == true) |
|
| 310 | 310 | { |
| 311 | 311 | break; |
| 312 | 312 | } |
| 313 | - if($row['user_role'] == -1 && $has_role == true) { |
|
| 313 | + if ($row['user_role'] == -1 && $has_role == true) { |
|
| 314 | 314 | break; //no need for default actions when a role is assigned to the user or user's group already |
| 315 | 315 | } |
| 316 | 316 | /* END - SECURITY GROUPS */ |
| 317 | 317 | $acl = new ACLAction(); |
| 318 | - $isOverride = false; |
|
| 318 | + $isOverride = false; |
|
| 319 | 319 | $acl->populateFromRow($row); |
| 320 | - if(!empty($row['access_override'])){ |
|
| 320 | + if (!empty($row['access_override'])) { |
|
| 321 | 321 | $acl->aclaccess = $row['access_override']; |
| 322 | 322 | $isOverride = true; |
| 323 | 323 | } |
| 324 | - if(!isset($selected_actions[$acl->category])){ |
|
| 324 | + if (!isset($selected_actions[$acl->category])) { |
|
| 325 | 325 | $selected_actions[$acl->category] = array(); |
| 326 | 326 | |
| 327 | 327 | } |
| 328 | - if(!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
|
| 328 | + if (!isset($selected_actions[$acl->category][$acl->acltype][$acl->name]) |
|
| 329 | 329 | || ( |
| 330 | 330 | /* BEGIN - SECURITY GROUPS - additive security*/ |
| 331 | 331 | ( |
@@ -353,18 +353,18 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | //only set the session variable if it was a full list; |
| 356 | - if(empty($category) && empty($action)){ |
|
| 357 | - if(!isset($_SESSION['ACL'])){ |
|
| 356 | + if (empty($category) && empty($action)) { |
|
| 357 | + if (!isset($_SESSION['ACL'])) { |
|
| 358 | 358 | $_SESSION['ACL'] = array(); |
| 359 | 359 | } |
| 360 | 360 | $_SESSION['ACL'][$user_id] = $selected_actions; |
| 361 | - }else{ |
|
| 362 | - if(empty($action) && !empty($category)){ |
|
| 363 | - if(!empty($type)){ |
|
| 364 | - $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type];} |
|
| 361 | + } else { |
|
| 362 | + if (empty($action) && !empty($category)) { |
|
| 363 | + if (!empty($type)) { |
|
| 364 | + $_SESSION['ACL'][$user_id][$category][$type] = $selected_actions[$category][$type]; } |
|
| 365 | 365 | $_SESSION['ACL'][$user_id][$category] = $selected_actions[$category]; |
| 366 | - }else{ |
|
| 367 | - if(!empty($action) && !empty($category) && !empty($type)){ |
|
| 366 | + } else { |
|
| 367 | + if (!empty($action) && !empty($category) && !empty($type)) { |
|
| 368 | 368 | $_SESSION['ACL'][$user_id][$category][$type][$action] = $selected_actions[$category][$action]; |
| 369 | 369 | |
| 370 | 370 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | /** |
| 401 | 401 | static function hasAccess($is_owner=false, $access = 0){ |
| 402 | 402 | */ |
| 403 | - static function hasAccess($is_owner=false, $in_group=false, $access = 0, ACLAction $action = null){ |
|
| 403 | + static function hasAccess($is_owner = false, $in_group = false, $access = 0, ACLAction $action = null) { |
|
| 404 | 404 | /** |
| 405 | 405 | if($access != 0 && $access == ACL_ALLOW_ALL || ($is_owner && $access == ACL_ALLOW_OWNER))return true; |
| 406 | 406 | //if this exists, then this function is not static, so check the aclaccess parameter |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | return true; |
| 410 | 410 | } |
| 411 | 411 | */ |
| 412 | - if($access != 0 && ($access == ACL_ALLOW_ALL |
|
| 413 | - || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP) ) //if owner that's better than in group so count it...better way to clean this up? |
|
| 412 | + if ($access != 0 && ($access == ACL_ALLOW_ALL |
|
| 413 | + || ($is_owner && ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) //if owner that's better than in group so count it...better way to clean this up? |
|
| 414 | 414 | || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
| 415 | 415 | )) { |
| 416 | 416 | return true; |
| 417 | 417 | } |
| 418 | - if(!is_null($action) && isset($action->aclaccess)){ |
|
| 419 | - if($action->aclaccess == ACL_ALLOW_ALL |
|
| 418 | + if (!is_null($action) && isset($action->aclaccess)) { |
|
| 419 | + if ($action->aclaccess == ACL_ALLOW_ALL |
|
| 420 | 420 | || ($is_owner && $action->aclaccess == ($access == ACL_ALLOW_OWNER || $access == ACL_ALLOW_GROUP)) |
| 421 | 421 | || ($in_group && $access == ACL_ALLOW_GROUP) //need to pass if in group with access somehow |
| 422 | 422 | ) { |
@@ -438,15 +438,15 @@ discard block |
||
| 438 | 438 | * @param STRING $type |
| 439 | 439 | * @return boolean |
| 440 | 440 | */ |
| 441 | - static function userNeedsSecurityGroup($user_id, $category, $action,$type='module'){ |
|
| 441 | + static function userNeedsSecurityGroup($user_id, $category, $action, $type = 'module') { |
|
| 442 | 442 | //check if we don't have it set in the cache if not lets reload the cache |
| 443 | 443 | |
| 444 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 444 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 445 | 445 | ACLAction::getUserActions($user_id, false); |
| 446 | 446 | |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 449 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 450 | 450 | return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_GROUP; |
| 451 | 451 | } |
| 452 | 452 | return false; |
@@ -472,19 +472,19 @@ discard block |
||
| 472 | 472 | /** |
| 473 | 473 | public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false){ |
| 474 | 474 | */ |
| 475 | - public static function userHasAccess($user_id, $category, $action,$type='module', $is_owner = false, $in_group = false){ |
|
| 475 | + public static function userHasAccess($user_id, $category, $action, $type = 'module', $is_owner = false, $in_group = false) { |
|
| 476 | 476 | global $current_user; |
| 477 | - if($current_user->isAdminForModule($category)&& !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])){ |
|
| 477 | + if ($current_user->isAdminForModule($category) && !isset($_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'])) { |
|
| 478 | 478 | return true; |
| 479 | 479 | } |
| 480 | 480 | //check if we don't have it set in the cache if not lets reload the cache |
| 481 | - if(ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
| 482 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 481 | + if (ACLAction::getUserAccessLevel($user_id, $category, 'access', $type) < ACL_ALLOW_ENABLED) return false; |
|
| 482 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 483 | 483 | ACLAction::getUserActions($user_id, false); |
| 484 | 484 | |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 487 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 488 | 488 | /** |
| 489 | 489 | return ACLAction::hasAccess($is_owner, $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess']); |
| 490 | 490 | */ |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | * @param STRING $type |
| 505 | 505 | * @return INT (ACCESS LEVEL) |
| 506 | 506 | */ |
| 507 | - public static function getUserAccessLevel($user_id, $category, $action,$type='module'){ |
|
| 508 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 507 | + public static function getUserAccessLevel($user_id, $category, $action, $type = 'module') { |
|
| 508 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 509 | 509 | ACLAction::getUserActions($user_id, false); |
| 510 | 510 | |
| 511 | 511 | } |
| 512 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 512 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 513 | 513 | if (!empty($_SESSION['ACL'][$user_id][$category][$type]['admin']) && $_SESSION['ACL'][$user_id][$category][$type]['admin']['aclaccess'] >= ACL_ALLOW_ADMIN) |
| 514 | 514 | { |
| 515 | 515 | // If you have admin access for a module, all ACL's are allowed |
@@ -529,16 +529,16 @@ discard block |
||
| 529 | 529 | * @param STRING $type |
| 530 | 530 | * @return boolean |
| 531 | 531 | */ |
| 532 | - public static function userNeedsOwnership($user_id, $category, $action,$type='module'){ |
|
| 532 | + public static function userNeedsOwnership($user_id, $category, $action, $type = 'module') { |
|
| 533 | 533 | //check if we don't have it set in the cache if not lets reload the cache |
| 534 | 534 | |
| 535 | - if(empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 535 | + if (empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 536 | 536 | ACLAction::getUserActions($user_id, false); |
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | |
| 541 | - if(!empty($_SESSION['ACL'][$user_id][$category][$type][$action])){ |
|
| 541 | + if (!empty($_SESSION['ACL'][$user_id][$category][$type][$action])) { |
|
| 542 | 542 | return $_SESSION['ACL'][$user_id][$category][$type][$action]['aclaccess'] == ACL_ALLOW_OWNER; |
| 543 | 543 | } |
| 544 | 544 | return false; |
@@ -551,18 +551,18 @@ discard block |
||
| 551 | 551 | * |
| 552 | 552 | * @param unknown_type $categories |
| 553 | 553 | */ |
| 554 | - public static function setupCategoriesMatrix(&$categories){ |
|
| 554 | + public static function setupCategoriesMatrix(&$categories) { |
|
| 555 | 555 | global $ACLActions, $current_user; |
| 556 | 556 | $names = array(); |
| 557 | 557 | $disabled = array(); |
| 558 | - foreach($categories as $cat_name=>$category){ |
|
| 559 | - foreach($category as $type_name=>$type){ |
|
| 560 | - foreach($type as $act_name=>$action){ |
|
| 558 | + foreach ($categories as $cat_name=>$category) { |
|
| 559 | + foreach ($category as $type_name=>$type) { |
|
| 560 | + foreach ($type as $act_name=>$action) { |
|
| 561 | 561 | $names[$act_name] = translate($ACLActions[$type_name]['actions'][$act_name]['label'], 'ACLActions'); |
| 562 | 562 | $categories[$cat_name][$type_name][$act_name]['accessColor'] = ACLAction::AccessColor($action['aclaccess']); |
| 563 | - if($type_name== 'module'){ |
|
| 563 | + if ($type_name == 'module') { |
|
| 564 | 564 | |
| 565 | - if($act_name != 'aclaccess' && $categories[$cat_name]['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED){ |
|
| 565 | + if ($act_name != 'aclaccess' && $categories[$cat_name]['module']['access']['aclaccess'] == ACL_ALLOW_DISABLED) { |
|
| 566 | 566 | $categories[$cat_name][$type_name][$act_name]['accessColor'] = 'darkgray'; |
| 567 | 567 | $disabled[] = $cat_name; |
| 568 | 568 | } |
@@ -571,19 +571,19 @@ discard block |
||
| 571 | 571 | $categories[$cat_name][$type_name][$act_name]['accessName'] = ACLAction::AccessName($action['aclaccess']); |
| 572 | 572 | $categories[$cat_name][$type_name][$act_name]['accessLabel'] = ACLAction::AccessLabel($action['aclaccess']); |
| 573 | 573 | |
| 574 | - if($cat_name=='Users'&& $act_name=='admin'){ |
|
| 575 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT]=ACLAction::AccessName(ACL_ALLOW_DEFAULT);; |
|
| 576 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV]=ACLAction::AccessName(ACL_ALLOW_DEV);; |
|
| 574 | + if ($cat_name == 'Users' && $act_name == 'admin') { |
|
| 575 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEFAULT] = ACLAction::AccessName(ACL_ALLOW_DEFAULT); ; |
|
| 576 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'][ACL_ALLOW_DEV] = ACLAction::AccessName(ACL_ALLOW_DEV); ; |
|
| 577 | 577 | } |
| 578 | - else{ |
|
| 579 | - $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
|
| 578 | + else { |
|
| 579 | + $categories[$cat_name][$type_name][$act_name]['accessOptions'] = ACLAction::getAccessOptions($act_name, $type_name); |
|
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if(!is_admin($current_user)){ |
|
| 586 | - foreach($disabled as $cat_name){ |
|
| 585 | + if (!is_admin($current_user)) { |
|
| 586 | + foreach ($disabled as $cat_name) { |
|
| 587 | 587 | unset($categories[$cat_name]); |
| 588 | 588 | } |
| 589 | 589 | } |
@@ -598,10 +598,10 @@ discard block |
||
| 598 | 598 | * |
| 599 | 599 | * @return array of fields with id, name, access and category |
| 600 | 600 | */ |
| 601 | - function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false){ |
|
| 601 | + function toArray($dbOnly = false, $stringOnly = false, $upperKeys = false) { |
|
| 602 | 602 | $array_fields = array('id', 'aclaccess'); |
| 603 | 603 | $arr = array(); |
| 604 | - foreach($array_fields as $field){ |
|
| 604 | + foreach ($array_fields as $field) { |
|
| 605 | 605 | $arr[$field] = $this->$field; |
| 606 | 606 | } |
| 607 | 607 | return $arr; |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | * |
| 614 | 614 | * @param Array $arr |
| 615 | 615 | */ |
| 616 | - function fromArray($arr){ |
|
| 617 | - foreach($arr as $name=>$value){ |
|
| 616 | + function fromArray($arr) { |
|
| 617 | + foreach ($arr as $name=>$value) { |
|
| 618 | 618 | $this->$name = $value; |
| 619 | 619 | } |
| 620 | 620 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | * clears the session variable storing the cache information for acls |
| 625 | 625 | * |
| 626 | 626 | */ |
| 627 | - function clearSessionCache(){ |
|
| 627 | + function clearSessionCache() { |
|
| 628 | 628 | unset($_SESSION['ACL']); |
| 629 | 629 | } |
| 630 | 630 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @author SalesAgility <[email protected]> |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | -function display_lines($focus, $field, $value, $view){ |
|
| 25 | +function display_lines($focus, $field, $value, $view) { |
|
| 26 | 26 | |
| 27 | 27 | global $sugar_config, $locale, $app_list_strings, $mod_strings; |
| 28 | 28 | |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | $html = ''; |
| 33 | 33 | |
| 34 | - if($view == 'EditView'){ |
|
| 34 | + if ($view == 'EditView') { |
|
| 35 | 35 | |
| 36 | 36 | $html .= '<script src="modules/AOS_Products_Quotes/line_items.js"></script>'; |
| 37 | - if(file_exists('custom/modules/AOS_Products_Quotes/line_items.js')){ |
|
| 37 | + if (file_exists('custom/modules/AOS_Products_Quotes/line_items.js')) { |
|
| 38 | 38 | $html .= '<script src="custom/modules/AOS_Products_Quotes/line_items.js"></script>'; |
| 39 | 39 | } |
| 40 | 40 | $html .= '<script language="javascript">var sig_digits = '.$locale->getPrecision().';'; |
@@ -45,18 +45,18 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $html .= "<table border='0' cellspacing='4' width='37.5%' id='lineItems'></table>"; |
| 47 | 47 | |
| 48 | - if($enable_groups){ |
|
| 48 | + if ($enable_groups) { |
|
| 49 | 49 | $html .= "<div style='padding-top: 10px; padding-bottom:10px;'>"; |
| 50 | 50 | $html .= "<input type=\"button\" tabindex=\"116\" class=\"button\" value=\"".$mod_strings['LBL_ADD_GROUP']."\" id=\"addGroup\" onclick=\"insertGroup(0)\" />"; |
| 51 | 51 | $html .= "</div>"; |
| 52 | 52 | } |
| 53 | 53 | $html .= '<input type="hidden" name="vathidden" id="vathidden" value="'.get_select_options_with_id($app_list_strings['vat_list'], '').'"> |
| 54 | 54 | <input type="hidden" name="discounthidden" id="discounthidden" value="'.get_select_options_with_id($app_list_strings['discount_list'], '').'">'; |
| 55 | - if($focus->id != '') { |
|
| 55 | + if ($focus->id != '') { |
|
| 56 | 56 | require_once('modules/AOS_Products_Quotes/AOS_Products_Quotes.php'); |
| 57 | 57 | require_once('modules/AOS_Line_Item_Groups/AOS_Line_Item_Groups.php'); |
| 58 | 58 | |
| 59 | - $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '" . $focus->object_name . "' AND pg.parent_id = '" . $focus->id . "' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC"; |
|
| 59 | + $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '".$focus->object_name."' AND pg.parent_id = '".$focus->id."' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC"; |
|
| 60 | 60 | |
| 61 | 61 | $result = $focus->db->query($sql); |
| 62 | 62 | $html .= "<script> |
@@ -75,17 +75,17 @@ discard block |
||
| 75 | 75 | $group_item = json_encode($group_item->toArray()); |
| 76 | 76 | } |
| 77 | 77 | $html .= "<script> |
| 78 | - insertLineItems(" . $line_item . "," . $group_item . "); |
|
| 78 | + insertLineItems(" . $line_item.",".$group_item."); |
|
| 79 | 79 | </script>"; |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | - if(!$enable_groups){ |
|
| 83 | + if (!$enable_groups) { |
|
| 84 | 84 | $html .= '<script>insertGroup();</script>'; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - else if($view == 'DetailView'){ |
|
| 88 | + else if ($view == 'DetailView') { |
|
| 89 | 89 | $params = array('currency_id' => $focus->currency_id); |
| 90 | 90 | |
| 91 | 91 | $sql = "SELECT pg.id, pg.group_id FROM aos_products_quotes pg LEFT JOIN aos_line_item_groups lig ON pg.group_id = lig.id WHERE pg.parent_type = '".$focus->object_name."' AND pg.parent_id = '".$focus->id."' AND pg.deleted = 0 ORDER BY lig.number ASC, pg.number ASC"; |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | $line_item->retrieve($row['id']); |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - if($enable_groups && ($group_id != $row['group_id'] || $i == 0)){ |
|
| 112 | + if ($enable_groups && ($group_id != $row['group_id'] || $i == 0)) { |
|
| 113 | 113 | $html .= $groupStart.$product.$service.$groupEnd; |
| 114 | - if($i != 0)$html .= "<tr><td colspan='9' nowrap='nowrap'><br></td></tr>"; |
|
| 114 | + if ($i != 0)$html .= "<tr><td colspan='9' nowrap='nowrap'><br></td></tr>"; |
|
| 115 | 115 | $groupStart = ''; |
| 116 | 116 | $groupEnd = ''; |
| 117 | 117 | $product = ''; |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | $groupEnd .= "<td class='tabDetailViewDL' style='text-align: right;padding:2px;'>".currency_format_number($group_item->total_amount, $params)."</td>"; |
| 153 | 153 | $groupEnd .= "</tr>"; |
| 154 | 154 | } |
| 155 | - if($line_item->product_id != '0' && $line_item->product_id != null){ |
|
| 156 | - if($productCount == 0) |
|
| 155 | + if ($line_item->product_id != '0' && $line_item->product_id != null) { |
|
| 156 | + if ($productCount == 0) |
|
| 157 | 157 | { |
| 158 | 158 | $product .= "<tr>"; |
| 159 | 159 | $product .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'> </td>"; |
@@ -169,26 +169,26 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $product .= "<tr>"; |
| 172 | - $product_note = wordwrap($line_item->description,40,"<br />\n"); |
|
| 172 | + $product_note = wordwrap($line_item->description, 40, "<br />\n"); |
|
| 173 | 173 | $product .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>".++$productCount."</td>"; |
| 174 | - $product .= "<td class='tabDetailViewDF' style='padding:2px;'>".stripDecimalPointsAndTrailingZeroes(format_number($line_item->product_qty),$sep[1])."</td>"; |
|
| 174 | + $product .= "<td class='tabDetailViewDF' style='padding:2px;'>".stripDecimalPointsAndTrailingZeroes(format_number($line_item->product_qty), $sep[1])."</td>"; |
|
| 175 | 175 | |
| 176 | 176 | $product .= "<td class='tabDetailViewDF' style='padding:2px;'><a href='index.php?module=AOS_Products&action=DetailView&record=".$line_item->product_id."' class='tabDetailViewDFLink'>".$line_item->name."</a><br />".$product_note."</td>"; |
| 177 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price,$params)."</td>"; |
|
| 177 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price, $params)."</td>"; |
|
| 178 | 178 | |
| 179 | 179 | $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".get_discount_string($line_item->discount, $line_item->product_discount, $params, $locale, $sep)."</td>"; |
| 180 | 180 | |
| 181 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price,$params )."</td>"; |
|
| 182 | - if($locale->getPrecision()){ |
|
| 183 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".rtrim(rtrim(format_number($line_item->vat), '0'),$sep[1])."%</td>"; |
|
| 181 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price, $params)."</td>"; |
|
| 182 | + if ($locale->getPrecision()) { |
|
| 183 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".rtrim(rtrim(format_number($line_item->vat), '0'), $sep[1])."%</td>"; |
|
| 184 | 184 | } else { |
| 185 | 185 | $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".format_number($line_item->vat)."%</td>"; |
| 186 | 186 | } |
| 187 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt,$params )."</td>"; |
|
| 188 | - $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price,$params )."</td>"; |
|
| 187 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt, $params)."</td>"; |
|
| 188 | + $product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price, $params)."</td>"; |
|
| 189 | 189 | $product .= "</tr>"; |
| 190 | 190 | } else { |
| 191 | - if($serviceCount == 0) |
|
| 191 | + if ($serviceCount == 0) |
|
| 192 | 192 | { |
| 193 | 193 | $service .= "<tr>"; |
| 194 | 194 | $service .= "<td width='5%' class='tabDetailViewDL' style='text-align: left;padding:2px;' scope='row'> </td>"; |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | $service .= "<tr>"; |
| 206 | 206 | $service .= "<td class='tabDetailViewDF' style='text-align: left; padding:2px;'>".++$serviceCount."</td>"; |
| 207 | 207 | $service .= "<td class='tabDetailViewDF' style='padding:2px;' colspan='2'>".$line_item->name."</td>"; |
| 208 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price,$params)."</td>"; |
|
| 208 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_list_price, $params)."</td>"; |
|
| 209 | 209 | |
| 210 | 210 | $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".get_discount_string($line_item->discount, $line_item->product_discount, $params, $locale, $sep)."</td>"; |
| 211 | 211 | |
| 212 | 212 | |
| 213 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price,$params)."</td>"; |
|
| 213 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_unit_price, $params)."</td>"; |
|
| 214 | 214 | $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".rtrim(rtrim(format_number($line_item->vat), '0'), $sep[1])."%</td>"; |
| 215 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt,$params )."</td>"; |
|
| 216 | - $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price,$params )."</td>"; |
|
| 215 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt, $params)."</td>"; |
|
| 216 | + $service .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->product_total_price, $params)."</td>"; |
|
| 217 | 217 | $service .= "</tr>"; |
| 218 | 218 | |
| 219 | 219 | } |
@@ -230,22 +230,22 @@ discard block |
||
| 230 | 230 | //field was 0. |
| 231 | 231 | //The approach below will strip off the fractional part if it is only zeroes (and in this case the decimal separator |
| 232 | 232 | //will also be stripped off) The custom decimal separator is passed in to the function from the locale settings |
| 233 | -function stripDecimalPointsAndTrailingZeroes($inputString,$decimalSeparator) |
|
| 233 | +function stripDecimalPointsAndTrailingZeroes($inputString, $decimalSeparator) |
|
| 234 | 234 | { |
| 235 | - return preg_replace('/'.preg_quote($decimalSeparator).'[0]+$/','',$inputString); |
|
| 235 | + return preg_replace('/'.preg_quote($decimalSeparator).'[0]+$/', '', $inputString); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | -function get_discount_string($type, $amount, $params, $locale, $sep){ |
|
| 239 | - if($amount != '' && $amount != '0.00') |
|
| 238 | +function get_discount_string($type, $amount, $params, $locale, $sep) { |
|
| 239 | + if ($amount != '' && $amount != '0.00') |
|
| 240 | 240 | { |
| 241 | - if($type == 'Amount') |
|
| 241 | + if ($type == 'Amount') |
|
| 242 | 242 | { |
| 243 | - return currency_format_number($amount,$params )."</td>"; |
|
| 243 | + return currency_format_number($amount, $params)."</td>"; |
|
| 244 | 244 | } |
| 245 | - else if($locale->getPrecision()) |
|
| 245 | + else if ($locale->getPrecision()) |
|
| 246 | 246 | { |
| 247 | - return rtrim(rtrim(format_number($amount), '0'),$sep[1])."%"; |
|
| 248 | - } else{ |
|
| 247 | + return rtrim(rtrim(format_number($amount), '0'), $sep[1])."%"; |
|
| 248 | + } else { |
|
| 249 | 249 | return format_number($amount)."%"; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | -function display_shipping_vat($focus, $field, $value, $view){ |
|
| 258 | +function display_shipping_vat($focus, $field, $value, $view) { |
|
| 259 | 259 | |
| 260 | - if($view == 'EditView'){ |
|
| 260 | + if ($view == 'EditView') { |
|
| 261 | 261 | global $app_list_strings; |
| 262 | 262 | |
| 263 | - if($value != '') $value = format_number($value); |
|
| 263 | + if ($value != '') $value = format_number($value); |
|
| 264 | 264 | |
| 265 | 265 | $html = "<input id='shipping_tax_amt' type='text' tabindex='0' title='' value='".$value."' maxlength='26,6' size='22' name='shipping_tax_amt' onblur='calculateTotal(\"lineItems\");'>"; |
| 266 | 266 | $html .= "<select name='shipping_tax' id='shipping_tax' onchange='calculateTotal(\"lineItems\");' >".get_select_options_with_id($app_list_strings['vat_list'], (isset($focus->shipping_tax) ? $focus->shipping_tax : ''))."</select>"; |
@@ -51,22 +51,22 @@ discard block |
||
| 51 | 51 | function save_lines($post_data, $parent, $groups = array(), $key = '') |
| 52 | 52 | { |
| 53 | 53 | |
| 54 | - $line_count = isset($post_data[$key . 'name']) ? count($post_data[$key . 'name']) : 0; |
|
| 54 | + $line_count = isset($post_data[$key.'name']) ? count($post_data[$key.'name']) : 0; |
|
| 55 | 55 | $j = 0; |
| 56 | 56 | for ($i = 0; $i < $line_count; ++$i) { |
| 57 | 57 | |
| 58 | - if ($post_data[$key . 'deleted'][$i] == 1) { |
|
| 59 | - $this->mark_deleted($post_data[$key . 'id'][$i]); |
|
| 58 | + if ($post_data[$key.'deleted'][$i] == 1) { |
|
| 59 | + $this->mark_deleted($post_data[$key.'id'][$i]); |
|
| 60 | 60 | } else { |
| 61 | 61 | $product_quote = new AOS_Products_Quotes(); |
| 62 | 62 | foreach ($this->field_defs as $field_def) { |
| 63 | 63 | $field_name = $field_def['name']; |
| 64 | - if (isset($post_data[$key . $field_name][$i])) { |
|
| 65 | - $product_quote->$field_name = $post_data[$key . $field_name][$i]; |
|
| 64 | + if (isset($post_data[$key.$field_name][$i])) { |
|
| 65 | + $product_quote->$field_name = $post_data[$key.$field_name][$i]; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | - if (isset($post_data[$key . 'group_number'][$i])) { |
|
| 69 | - $product_quote->group_id = $groups[$post_data[$key . 'group_number'][$i]]; |
|
| 68 | + if (isset($post_data[$key.'group_number'][$i])) { |
|
| 69 | + $product_quote->group_id = $groups[$post_data[$key.'group_number'][$i]]; |
|
| 70 | 70 | } |
| 71 | 71 | if (trim($product_quote->product_id) != '' && trim($product_quote->name) != '' && trim($product_quote->product_unit_price) != '') { |
| 72 | 72 | $product_quote->number = ++$j; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $product_quote->currency_id = $parent->currency_id; |
| 76 | 76 | $product_quote->parent_type = $parent->object_name; |
| 77 | 77 | $product_quote->save(); |
| 78 | - $_POST[$key . 'id'][$i] = $product_quote->id; |
|
| 78 | + $_POST[$key.'id'][$i] = $product_quote->id; |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | } |