@@ -21,9 +21,9 @@ |
||
| 21 | 21 | * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr})
|
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -define('APP_PHP_PATH', dirname(__FILE__) . '/');
|
|
| 25 | -define('APP_SET_PATH', dirname(__FILE__) . '/');
|
|
| 26 | -define('APP_UI_PATH', dirname(__FILE__) . '/ui/');
|
|
| 27 | -define('APP_WIDGETS_PATH', APP_UI_PATH . 'widgets/');
|
|
| 28 | -define('APP_CTRL_PATH', dirname(__FILE__) . '/'); |
|
| 29 | -define('APP_PORTLET_PATH', APP_PHP_PATH . 'portlet/'); |
|
| 30 | 24 | \ No newline at end of file |
| 25 | +define('APP_PHP_PATH', dirname(__FILE__).'/');
|
|
| 26 | +define('APP_SET_PATH', dirname(__FILE__).'/');
|
|
| 27 | +define('APP_UI_PATH', dirname(__FILE__).'/ui/');
|
|
| 28 | +define('APP_WIDGETS_PATH', APP_UI_PATH.'widgets/');
|
|
| 29 | +define('APP_CTRL_PATH', dirname(__FILE__).'/'); |
|
| 30 | +define('APP_PORTLET_PATH', APP_PHP_PATH.'portlet/'); |
|
| 31 | 31 | \ No newline at end of file |
@@ -109,9 +109,9 @@ |
||
| 109 | 109 | public function isUpdatable() |
| 110 | 110 | { |
| 111 | 111 | return $this->all(); |
| 112 | - if($this->App() |
|
| 112 | + if ($this->App() |
|
| 113 | 113 | ->Access() |
| 114 | - ->administer()){ |
|
| 114 | + ->administer()) { |
|
| 115 | 115 | return $this->all(); |
| 116 | 116 | } |
| 117 | 117 | return $this->none(); |
@@ -123,8 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if(strpos($rawField, ':') === false){ |
| 125 | 125 | $fieldName = $rawField; |
| 126 | - } |
|
| 127 | - else{ |
|
| 126 | + } else{ |
|
| 128 | 127 | list ($fieldName, $parameters) = explode(':', $rawField); |
| 129 | 128 | $parameters = explode(';', $parameters); |
| 130 | 129 | foreach ($parameters as $parameter){ |
@@ -322,15 +321,13 @@ discard block |
||
| 322 | 321 | if(strpos($fieldName, '/') !== false){ |
| 323 | 322 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 324 | 323 | $field = $recordSet->$oneField()->$foreignField; |
| 325 | - } |
|
| 326 | - else{ |
|
| 324 | + } else{ |
|
| 327 | 325 | $field = $recordSet->$fieldName; |
| 328 | 326 | } |
| 329 | 327 | foreach ($condition as $op => $value){ |
| 330 | 328 | if(! is_array($value)){ |
| 331 | 329 | $criteria = $field->$op($value); |
| 332 | - } |
|
| 333 | - else{ |
|
| 330 | + } else{ |
|
| 334 | 331 | foreach ($value as $foreignClassName => $foreignValues){ |
| 335 | 332 | $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
| 336 | 333 | $foreignSet = $App->$foreignClassName(); |
@@ -339,8 +336,7 @@ discard block |
||
| 339 | 336 | foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
| 340 | 337 | if($foreignFieldName === '_foreignField'){ |
| 341 | 338 | $foreignField = $foreignConditions; |
| 342 | - } |
|
| 343 | - else{ |
|
| 339 | + } else{ |
|
| 344 | 340 | foreach ($foreignConditions as $key => $val){ |
| 345 | 341 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 346 | 342 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $App = app_App(); |
| 69 | 69 | static $fieldsLayouts = null; |
| 70 | 70 | |
| 71 | - if(! isset($fieldsLayouts)){ |
|
| 71 | + if (!isset($fieldsLayouts)) { |
|
| 72 | 72 | $fieldsLayouts = array( |
| 73 | 73 | self::FIELDS_LAYOUT_VERTICAL_LABEL => $App->translate('Vertical label'), |
| 74 | 74 | self::FIELDS_LAYOUT_HORIZONTAL_LABEL => $App->translate('Horizontal label'), |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getRawFields() |
| 87 | 87 | { |
| 88 | - if(empty($this->fields)){ |
|
| 88 | + if (empty($this->fields)) { |
|
| 89 | 89 | return array(); |
| 90 | 90 | } |
| 91 | 91 | return explode(',', $this->fields); |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function getFields() |
| 112 | 112 | { |
| 113 | - if(empty($this->fields)){ |
|
| 113 | + if (empty($this->fields)) { |
|
| 114 | 114 | return array(); |
| 115 | 115 | } |
| 116 | 116 | $fields = json_decode($this->fields, true); |
| 117 | 117 | |
| 118 | - if(json_last_error() === JSON_ERROR_NONE){ |
|
| 119 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 118 | + if (json_last_error() === JSON_ERROR_NONE) { |
|
| 119 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 120 | 120 | $fields = app_utf8Decode($fields); |
| 121 | 121 | } |
| 122 | 122 | return $fields; |
@@ -124,19 +124,19 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $fields = array(); |
| 126 | 126 | $rawFields = $this->getRawFields(); |
| 127 | - foreach ($rawFields as $rawField){ |
|
| 128 | - if(empty($rawField)){ |
|
| 127 | + foreach ($rawFields as $rawField) { |
|
| 128 | + if (empty($rawField)) { |
|
| 129 | 129 | continue; |
| 130 | 130 | } |
| 131 | 131 | $params = array(); |
| 132 | 132 | |
| 133 | - if(strpos($rawField, ':') === false){ |
|
| 133 | + if (strpos($rawField, ':') === false) { |
|
| 134 | 134 | $fieldName = $rawField; |
| 135 | 135 | } |
| 136 | - else{ |
|
| 136 | + else { |
|
| 137 | 137 | list ($fieldName, $parameters) = explode(':', $rawField); |
| 138 | 138 | $parameters = explode(';', $parameters); |
| 139 | - foreach ($parameters as $parameter){ |
|
| 139 | + foreach ($parameters as $parameter) { |
|
| 140 | 140 | list ($key, $value) = explode('=', $parameter); |
| 141 | 141 | $params[$key] = $value; |
| 142 | 142 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function getField($searchedFieldName) |
| 171 | 171 | { |
| 172 | - if(empty($this->fields)){ |
|
| 172 | + if (empty($this->fields)) { |
|
| 173 | 173 | return null; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | public function addField($fieldName, $parameters = null) |
| 187 | 187 | { |
| 188 | 188 | $fields = $this->getFields(); |
| 189 | - if(! isset($parameters)){ |
|
| 189 | + if (!isset($parameters)) { |
|
| 190 | 190 | $fields[$fieldName] = array( |
| 191 | 191 | 'block' => '' |
| 192 | 192 | ); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | $fields[$fieldName]['fieldname'] = $fieldName; |
| 196 | 196 | $fields[$fieldName]['parameters'] = $parameters; |
| 197 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 197 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 198 | 198 | $fields = app_utf8Encode($fields); |
| 199 | 199 | } |
| 200 | 200 | $this->fields = json_encode($fields); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | $fields = $this->getFields(); |
| 210 | 210 | unset($fields[$removedFieldName]); |
| 211 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 211 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 212 | 212 | $fields = app_utf8Encode($fields); |
| 213 | 213 | } |
| 214 | 214 | $this->fields = json_encode($fields); |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | $isFieldsGroup = false; |
| 228 | 228 | $fields = $this->getFields(); |
| 229 | - if(strpos($updatedFieldName, '_fieldsGroup') !== false){ |
|
| 229 | + if (strpos($updatedFieldName, '_fieldsGroup') !== false) { |
|
| 230 | 230 | $isFieldsGroup = true; |
| 231 | 231 | list (, $groupPos) = explode('_fieldsGroup', $updatedFieldName); |
| 232 | - if(! isset($groupPos) || empty($groupPos)){ |
|
| 232 | + if (!isset($groupPos) || empty($groupPos)) { |
|
| 233 | 233 | $groupPos = 0; |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | - if(! isset($fields[$updatedFieldName])){ |
|
| 237 | - if($isFieldsGroup){ |
|
| 238 | - while (isset($fields[$updatedFieldName . $groupPos])){ |
|
| 239 | - $groupPos ++; |
|
| 236 | + if (!isset($fields[$updatedFieldName])) { |
|
| 237 | + if ($isFieldsGroup) { |
|
| 238 | + while (isset($fields[$updatedFieldName.$groupPos])) { |
|
| 239 | + $groupPos++; |
|
| 240 | 240 | } |
| 241 | 241 | $updatedFieldName .= $groupPos; |
| 242 | 242 | } |
| 243 | 243 | $this->addField($updatedFieldName, $parameters); |
| 244 | 244 | return $this; |
| 245 | 245 | } |
| 246 | - if(! isset($parameters)){ |
|
| 246 | + if (!isset($parameters)) { |
|
| 247 | 247 | $fields[$updatedFieldName] = array( |
| 248 | 248 | 'block' => '' |
| 249 | 249 | ); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | $fields[$updatedFieldName]['fieldname'] = $updatedFieldName; |
| 253 | 253 | $fields[$updatedFieldName]['parameters'] = $parameters; |
| 254 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 254 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 255 | 255 | $fields = app_utf8Encode($fields); |
| 256 | 256 | } |
| 257 | 257 | $this->fields = json_encode($fields); |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | public function addFieldToGroup($fieldGroupName, $fieldName, $parameters = null) |
| 262 | 262 | { |
| 263 | 263 | $fields = $this->getFields(); |
| 264 | - if(! isset($fields[$fieldGroupName])){ |
|
| 264 | + if (!isset($fields[$fieldGroupName])) { |
|
| 265 | 265 | return $this; |
| 266 | 266 | } |
| 267 | 267 | $groupFields = isset($fields[$fieldGroupName]['fields']) ? $fields[$fieldGroupName]['fields'] : array(); |
| 268 | - if(! isset($parameters)){ |
|
| 268 | + if (!isset($parameters)) { |
|
| 269 | 269 | $groupFields[$fieldName] = array( |
| 270 | 270 | 'block' => '' |
| 271 | 271 | ); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $groupFields[$fieldName]['fieldname'] = $fieldName; |
| 275 | 275 | $groupFields[$fieldName]['parameters'] = $parameters; |
| 276 | 276 | $fields[$fieldGroupName]['fields'] = $groupFields; |
| 277 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 277 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 278 | 278 | $fields = app_utf8Encode($fields); |
| 279 | 279 | } |
| 280 | 280 | $this->fields = json_encode($fields); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | { |
| 289 | 289 | $fields = $this->getFields(); |
| 290 | 290 | unset($fields[$fieldGroupName]['fields'][$removedFieldName]); |
| 291 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 291 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 292 | 292 | $fields = app_utf8Encode($fields); |
| 293 | 293 | } |
| 294 | 294 | $this->fields = json_encode($fields); |
@@ -305,15 +305,15 @@ discard block |
||
| 305 | 305 | public function updateFieldGroup($fieldGroupName, $updatedFieldName, $parameters = null) |
| 306 | 306 | { |
| 307 | 307 | $fields = $this->getFields(); |
| 308 | - if(! isset($fields[$fieldGroupName])){ |
|
| 308 | + if (!isset($fields[$fieldGroupName])) { |
|
| 309 | 309 | return $this; |
| 310 | 310 | } |
| 311 | 311 | $groupFields = isset($fields[$fieldGroupName]['fields']) ? $fields[$fieldGroupName]['fields'] : array(); |
| 312 | - if(! isset($groupFields[$updatedFieldName])){ |
|
| 312 | + if (!isset($groupFields[$updatedFieldName])) { |
|
| 313 | 313 | $this->addFieldToGroup($fieldGroupName, $updatedFieldName, $parameters); |
| 314 | 314 | return $this; |
| 315 | 315 | } |
| 316 | - if(! isset($parameters)){ |
|
| 316 | + if (!isset($parameters)) { |
|
| 317 | 317 | $groupFields[$updatedFieldName] = array( |
| 318 | 318 | 'block' => '' |
| 319 | 319 | ); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $groupFields[$updatedFieldName]['fieldname'] = $updatedFieldName; |
| 324 | 324 | $groupFields[$updatedFieldName]['parameters'] = $parameters; |
| 325 | 325 | $fields[$fieldGroupName]['fields'] = $groupFields; |
| 326 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 326 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 327 | 327 | $fields = app_utf8Encode($fields); |
| 328 | 328 | } |
| 329 | 329 | $this->fields = json_encode($fields); |
@@ -337,46 +337,46 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public function isVisibleForRecord(AppRecord $record) |
| 339 | 339 | { |
| 340 | - if(empty($this->visibilityCriteria)){ |
|
| 340 | + if (empty($this->visibilityCriteria)) { |
|
| 341 | 341 | return true; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $App = \bab_functionality::get('App'); |
| 345 | 345 | $recordSet = $record->getParentSet(); |
| 346 | 346 | $arrCriteria = json_decode($this->visibilityCriteria, true); |
| 347 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 347 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 348 | 348 | $arrCriteria = app_utf8Decode($arrCriteria); |
| 349 | 349 | } |
| 350 | - foreach ($arrCriteria as $fieldName => $condition){ |
|
| 351 | - if(strpos($fieldName, '/') !== false){ |
|
| 350 | + foreach ($arrCriteria as $fieldName => $condition) { |
|
| 351 | + if (strpos($fieldName, '/') !== false) { |
|
| 352 | 352 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 353 | 353 | $field = $recordSet->$oneField()->$foreignField; |
| 354 | 354 | } |
| 355 | - else{ |
|
| 355 | + else { |
|
| 356 | 356 | $field = $recordSet->$fieldName; |
| 357 | 357 | } |
| 358 | - foreach ($condition as $op => $value){ |
|
| 359 | - if(! is_array($value)){ |
|
| 358 | + foreach ($condition as $op => $value) { |
|
| 359 | + if (!is_array($value)) { |
|
| 360 | 360 | $criteria = $field->$op($value); |
| 361 | 361 | } |
| 362 | - else{ |
|
| 363 | - foreach ($value as $foreignClassName => $foreignValues){ |
|
| 364 | - $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
|
| 362 | + else { |
|
| 363 | + foreach ($value as $foreignClassName => $foreignValues) { |
|
| 364 | + $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName).'Set'; |
|
| 365 | 365 | $foreignSet = $App->$foreignClassName(); |
| 366 | 366 | $foreignField = ''; |
| 367 | 367 | $foreignCondition = ''; |
| 368 | - foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
|
| 369 | - if($foreignFieldName === '_foreignField'){ |
|
| 368 | + foreach ($foreignValues as $foreignFieldName => $foreignConditions) { |
|
| 369 | + if ($foreignFieldName === '_foreignField') { |
|
| 370 | 370 | $foreignField = $foreignConditions; |
| 371 | 371 | } |
| 372 | - else{ |
|
| 373 | - foreach ($foreignConditions as $key => $val){ |
|
| 372 | + else { |
|
| 373 | + foreach ($foreignConditions as $key => $val) { |
|
| 374 | 374 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | - if(method_exists($foreignSet, 'getDefaultCriteria')){ |
|
| 379 | + if (method_exists($foreignSet, 'getDefaultCriteria')) { |
|
| 380 | 380 | $foreignCondition = $foreignCondition->_AND_($foreignSet->getDefaultCriteria()); |
| 381 | 381 | } |
| 382 | 382 | $criteria = $field->in($foreignCondition, $foreignField); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public function selectUserSSE($user = null) |
| 62 | 62 | {
|
| 63 | - if(!isset($user)){
|
|
| 63 | + if (!isset($user)) {
|
|
| 64 | 64 | $App = $this->App(); |
| 65 | 65 | $user = $App->getCurrentUser(); |
| 66 | 66 | } |
@@ -82,29 +82,29 @@ discard block |
||
| 82 | 82 | $userSSEReloads = $this->select($this->user->is($user)->_AND_($this->type->is(AppSSE::TYPE_RELOAD_SELECTOR))); |
| 83 | 83 | $reloadSelectors = array(); |
| 84 | 84 | $now = date('Y-m-d H:i:s');
|
| 85 | - foreach ($userSSEReloads as $sseMsg){
|
|
| 85 | + foreach ($userSSEReloads as $sseMsg) {
|
|
| 86 | 86 | $reloadSelectors[] = $sseMsg->data; |
| 87 | - if($delete && $now > date($sseMsg->deleteOn)){
|
|
| 87 | + if ($delete && $now > date($sseMsg->deleteOn)) {
|
|
| 88 | 88 | $sseMsg->delete(); |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if(!empty($reloadSelectors)){
|
|
| 92 | + if (!empty($reloadSelectors)) {
|
|
| 93 | 93 | $sseData .= '"reloadSelector":'.bab_json_encode($reloadSelectors); |
| 94 | 94 | $hasData = true; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $userSSEBrowserNotifications = $this->select($this->user->is($user)->_AND_($this->type->is(AppSSE::TYPE_BROWSER_NOTIFICATION))); |
| 98 | 98 | $browserNotifications = array(); |
| 99 | - foreach ($userSSEBrowserNotifications as $sseMsg){
|
|
| 99 | + foreach ($userSSEBrowserNotifications as $sseMsg) {
|
|
| 100 | 100 | $browserNotifications[] = $sseMsg->data; |
| 101 | - if($delete){
|
|
| 101 | + if ($delete) {
|
|
| 102 | 102 | $sseMsg->delete(); |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if(!empty($browserNotifications)){
|
|
| 107 | - if($hasData){
|
|
| 106 | + if (!empty($browserNotifications)) {
|
|
| 107 | + if ($hasData) {
|
|
| 108 | 108 | $sseData .= ', '; |
| 109 | 109 | } |
| 110 | 110 | $sseData .= '"browserNotifications":'.bab_json_encode($browserNotifications); |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | {
|
| 126 | 126 | $App = $this->App(); |
| 127 | 127 | $users = array(); |
| 128 | - if(!isset($for)){
|
|
| 128 | + if (!isset($for)) {
|
|
| 129 | 129 | $users[] = $App->getCurrentUser(); |
| 130 | 130 | } |
| 131 | - else if(!is_array($for)){
|
|
| 132 | - if($for === 'all'){
|
|
| 131 | + else if (!is_array($for)) {
|
|
| 132 | + if ($for === 'all') {
|
|
| 133 | 133 | $users = $App->getLoggedUsers(); |
| 134 | 134 | } |
| 135 | - else{
|
|
| 135 | + else {
|
|
| 136 | 136 | $users[] = $for; |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $deleteOn = self::getDeleteOn(); |
| 141 | - foreach ($users as $user){
|
|
| 141 | + foreach ($users as $user) {
|
|
| 142 | 142 | $record = $this->newRecord(); |
| 143 | 143 | $record->user = $user; |
| 144 | 144 | $record->data = $reloadSelector; |
@@ -164,20 +164,20 @@ discard block |
||
| 164 | 164 | {
|
| 165 | 165 | $App = $this->App(); |
| 166 | 166 | $users = array(); |
| 167 | - if(!isset($for)){
|
|
| 167 | + if (!isset($for)) {
|
|
| 168 | 168 | $users[] = $App->getCurrentUser(); |
| 169 | 169 | } |
| 170 | - else if(!is_array($for)){
|
|
| 171 | - if($for === 'all'){
|
|
| 170 | + else if (!is_array($for)) {
|
|
| 171 | + if ($for === 'all') {
|
|
| 172 | 172 | $users = $App->getLoggedUsers(); |
| 173 | 173 | } |
| 174 | - else{
|
|
| 174 | + else {
|
|
| 175 | 175 | $users[] = $for; |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $deleteOn = self::getDeleteOn(); |
| 180 | - foreach ($users as $user){
|
|
| 180 | + foreach ($users as $user) {
|
|
| 181 | 181 | $record = $this->newRecord(); |
| 182 | 182 | $record->user = $user; |
| 183 | 183 | $record->data = bab_json_encode($data); |
@@ -127,12 +127,10 @@ discard block |
||
| 127 | 127 | $users = array(); |
| 128 | 128 | if(!isset($for)){
|
| 129 | 129 | $users[] = $App->getCurrentUser(); |
| 130 | - } |
|
| 131 | - else if(!is_array($for)){
|
|
| 130 | + } else if(!is_array($for)){
|
|
| 132 | 131 | if($for === 'all'){
|
| 133 | 132 | $users = $App->getLoggedUsers(); |
| 134 | - } |
|
| 135 | - else{
|
|
| 133 | + } else{
|
|
| 136 | 134 | $users[] = $for; |
| 137 | 135 | } |
| 138 | 136 | } |
@@ -166,12 +164,10 @@ discard block |
||
| 166 | 164 | $users = array(); |
| 167 | 165 | if(!isset($for)){
|
| 168 | 166 | $users[] = $App->getCurrentUser(); |
| 169 | - } |
|
| 170 | - else if(!is_array($for)){
|
|
| 167 | + } else if(!is_array($for)){
|
|
| 171 | 168 | if($for === 'all'){
|
| 172 | 169 | $users = $App->getLoggedUsers(); |
| 173 | - } |
|
| 174 | - else{
|
|
| 170 | + } else{
|
|
| 175 | 171 | $users[] = $for; |
| 176 | 172 | } |
| 177 | 173 | } |
@@ -351,8 +351,7 @@ discard block |
||
| 351 | 351 | if(isset($linkType)){ |
| 352 | 352 | if(is_array($linkType)){ |
| 353 | 353 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 354 | - } |
|
| 355 | - else{ |
|
| 354 | + } else{ |
|
| 356 | 355 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 357 | 356 | } |
| 358 | 357 | } |
@@ -379,8 +378,7 @@ discard block |
||
| 379 | 378 | if(isset($linkType)){ |
| 380 | 379 | if(is_array($linkType)){ |
| 381 | 380 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 382 | - } |
|
| 383 | - else{ |
|
| 381 | + } else{ |
|
| 384 | 382 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 385 | 383 | } |
| 386 | 384 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $value = $this->oParentSet->getBackend()->getRecordValue($this, $sFieldName); |
| 60 | 60 | $field = $this->oParentSet->$sFieldName; |
| 61 | - if(! is_null($value) && $field instanceof ORMFkField){ |
|
| 61 | + if (!is_null($value) && $field instanceof ORMFkField) { |
|
| 62 | 62 | |
| 63 | 63 | $sClassName = $field->getForeignSetName(); |
| 64 | 64 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function App() |
| 95 | 95 | { |
| 96 | - if(! isset($this->app)){ |
|
| 96 | + if (!isset($this->app)) { |
|
| 97 | 97 | // If the app object was not specified (through the setApp() method), |
| 98 | 98 | // we set it as parent set's App. |
| 99 | 99 | $this->setApp($this->getParentSet() |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $App = $this->App(); |
| 115 | 115 | $rClass = new \ReflectionClass(get_class($this)); |
| 116 | 116 | $component = $App->getComponentByName($rClass->getShortName()); |
| 117 | - if(isset($component)){ |
|
| 117 | + if (isset($component)) { |
|
| 118 | 118 | return $component->getRecordClassName(); |
| 119 | 119 | // list(, $classname) = explode('_', $component->getRecordClassName()); |
| 120 | 120 | // return $classname; |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function getRef() |
| 132 | 132 | { |
| 133 | - if(! isset($this->id)){ |
|
| 133 | + if (!isset($this->id)) { |
|
| 134 | 134 | throw new AppException('Trying to get the reference string of a record without an id.'); |
| 135 | 135 | } |
| 136 | 136 | $classname = $this->getClassName(); |
| 137 | - return $classname . ':' . $this->id; |
|
| 137 | + return $classname.':'.$this->id; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $App = $this->App(); |
| 163 | 163 | |
| 164 | - if(! isset($deletedStatus)){ |
|
| 164 | + if (!isset($deletedStatus)) { |
|
| 165 | 165 | $deletedStatus = AppTraceableRecord::DELETED_STATUS_DELETED; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // referenced elements. |
| 174 | 174 | $manyRelations = $set->getHasManyRelations(); |
| 175 | 175 | |
| 176 | - foreach ($manyRelations as $manyRelation){ |
|
| 176 | + foreach ($manyRelations as $manyRelation) { |
|
| 177 | 177 | /* @var $manyRelation ORMManyRelation */ |
| 178 | 178 | |
| 179 | 179 | $foreignSetClassName = $manyRelation->getForeignSetClassName(); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 189 | 189 | |
| 190 | - foreach ($foreignRecords as $foreignRecord){ |
|
| 190 | + foreach ($foreignRecords as $foreignRecord) { |
|
| 191 | 191 | $foreignRecord->$foreignSetFieldName = 0; |
| 192 | 192 | $foreignRecord->save(); |
| 193 | 193 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 200 | 200 | |
| 201 | - foreach ($foreignRecords as $foreignRecord){ |
|
| 201 | + foreach ($foreignRecords as $foreignRecord) { |
|
| 202 | 202 | $foreignRecord->delete(); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | // referenced elements. |
| 245 | 245 | $manyRelations = $set->getHasManyRelations(); |
| 246 | 246 | |
| 247 | - foreach ($manyRelations as $manyRelation){ |
|
| 247 | + foreach ($manyRelations as $manyRelation) { |
|
| 248 | 248 | /* @var $manyRelation ORMManyRelation */ |
| 249 | 249 | |
| 250 | 250 | $foreignSetClassName = $manyRelation->getForeignSetClassName(); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | // $foreignSet = new $foreignSetClassName($App); |
| 255 | 255 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 256 | 256 | |
| 257 | - foreach ($foreignRecords as $foreignRecord){ |
|
| 257 | + foreach ($foreignRecords as $foreignRecord) { |
|
| 258 | 258 | $foreignRecord->$foreignSetFieldName = $id; |
| 259 | 259 | $foreignRecord->save(); |
| 260 | 260 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $links = $linkSet->select($linkSet->sourceClass->is($recordClassName) |
| 268 | 268 | ->_AND_($linkSet->sourceId->is($recordId))); |
| 269 | 269 | |
| 270 | - foreach ($links as $link){ |
|
| 270 | + foreach ($links as $link) { |
|
| 271 | 271 | $link->sourceId = $id; |
| 272 | 272 | $link->save(); |
| 273 | 273 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $links = $linkSet->select($linkSet->targetClass->is($recordClassName) |
| 276 | 276 | ->_AND_($linkSet->targetId->is($recordId))); |
| 277 | 277 | |
| 278 | - foreach ($links as $link){ |
|
| 278 | + foreach ($links as $link) { |
|
| 279 | 279 | $link->targetId = $id; |
| 280 | 280 | $link->save(); |
| 281 | 281 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | $relatedRecords = array(); |
| 302 | 302 | |
| 303 | - foreach ($manyRelations as $manyRelation){ |
|
| 303 | + foreach ($manyRelations as $manyRelation) { |
|
| 304 | 304 | /* @var $manyRelation ORMManyRelation */ |
| 305 | 305 | |
| 306 | 306 | $foreignSetClassName = $manyRelation->getForeignSetClassName(); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | // $foreignSet = new $foreignSetClassName($App); |
| 312 | 312 | $foreignRecords = $foreignSet->select($foreignSet->$foreignSetFieldName->is($recordId)); |
| 313 | 313 | |
| 314 | - if($foreignRecords->count() > 0){ |
|
| 314 | + if ($foreignRecords->count() > 0) { |
|
| 315 | 315 | $relatedRecords[$foreignSetClassName] = $foreignRecords; |
| 316 | 316 | } |
| 317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | { |
| 329 | 329 | $path = $this->App()->uploadPath(); |
| 330 | 330 | |
| 331 | - if(null === $path){ |
|
| 331 | + if (null === $path) { |
|
| 332 | 332 | throw new \Exception('Missing upload path information'); |
| 333 | 333 | return null; |
| 334 | 334 | } |
@@ -348,12 +348,12 @@ discard block |
||
| 348 | 348 | $linkSet = $App->LinkSet(); |
| 349 | 349 | |
| 350 | 350 | $sourceClass = $source->getClassName(); |
| 351 | - if(strpos($sourceClass, '\\')){ |
|
| 351 | + if (strpos($sourceClass, '\\')) { |
|
| 352 | 352 | $targetClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $targetClass = $this->getClassName(); |
| 356 | - if(strpos($targetClass, '\\')){ |
|
| 356 | + if (strpos($targetClass, '\\')) { |
|
| 357 | 357 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | ->_AND_($linkSet->sourceId->is($source->id)) |
| 362 | 362 | ->_AND_($linkSet->targetClass->is($targetClass)) |
| 363 | 363 | ->_AND_($linkSet->targetId->is($this->id)); |
| 364 | - if(isset($linkType)){ |
|
| 365 | - if(is_array($linkType)){ |
|
| 364 | + if (isset($linkType)) { |
|
| 365 | + if (is_array($linkType)) { |
|
| 366 | 366 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 367 | 367 | } |
| 368 | - else{ |
|
| 368 | + else { |
|
| 369 | 369 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -388,22 +388,22 @@ discard block |
||
| 388 | 388 | $linkSet = $App->LinkSet(); |
| 389 | 389 | |
| 390 | 390 | $sourceClass = $this->getClassName(); |
| 391 | - if(strpos($sourceClass, '\\')){ |
|
| 391 | + if (strpos($sourceClass, '\\')) { |
|
| 392 | 392 | $targetClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $targetClass = $target->getClassName(); |
| 396 | - if(strpos($targetClass, '\\')){ |
|
| 396 | + if (strpos($targetClass, '\\')) { |
|
| 397 | 397 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $criteria = $linkSet->all($linkSet->targetClass->is($targetClass), $linkSet->targetId->is($target->id), $linkSet->sourceClass->is($sourceClass), $linkSet->sourceId->is($this->id)); |
| 401 | 401 | |
| 402 | - if(isset($linkType)){ |
|
| 403 | - if(is_array($linkType)){ |
|
| 402 | + if (isset($linkType)) { |
|
| 403 | + if (is_array($linkType)) { |
|
| 404 | 404 | $criteria = $criteria->_AND_($linkSet->type->in($linkType)); |
| 405 | 405 | } |
| 406 | - else{ |
|
| 406 | + else { |
|
| 407 | 407 | $criteria = $criteria->_AND_($linkSet->type->is($linkType)); |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | protected function importProperty($name, $value) |
| 467 | 467 | { |
| 468 | - if(((string) $this->$name) !== ((string) $value)){ |
|
| 468 | + if (((string) $this->$name) !== ((string) $value)) { |
|
| 469 | 469 | $this->$name = $value; |
| 470 | 470 | return 1; |
| 471 | 471 | } |
@@ -485,13 +485,13 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | protected function importDate($name, $value) |
| 487 | 487 | { |
| 488 | - if(preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)){ |
|
| 488 | + if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
|
| 489 | 489 | return $this->importProperty($name, $value); |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | // try in DD/MM/YYYY format |
| 493 | 493 | |
| 494 | - if(preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)){ |
|
| 494 | + if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)) { |
|
| 495 | 495 | |
| 496 | 496 | $value = sprintf('%04d-%02d-%02d', (int) $matches['year'], (int) $matches['month'], (int) $matches['day']); |
| 497 | 497 | |
@@ -511,11 +511,11 @@ discard block |
||
| 511 | 511 | $customContainers->groupBy($customContainerSet->view); |
| 512 | 512 | |
| 513 | 513 | $views = array(); |
| 514 | - foreach ($customContainers as $customContainer){ |
|
| 514 | + foreach ($customContainers as $customContainer) { |
|
| 515 | 515 | $views[] = $customContainer->view; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - if(empty($views)){ |
|
| 518 | + if (empty($views)) { |
|
| 519 | 519 | $views[] = ''; |
| 520 | 520 | } |
| 521 | 521 | |
@@ -599,9 +599,9 @@ discard block |
||
| 599 | 599 | */ |
| 600 | 600 | public function requireReadable($message = null) |
| 601 | 601 | { |
| 602 | - if(! $this->isReadable()){ |
|
| 602 | + if (!$this->isReadable()) { |
|
| 603 | 603 | $App = $this->App(); |
| 604 | - if(! isset($message)){ |
|
| 604 | + if (!isset($message)) { |
|
| 605 | 605 | $message = $App->translate('Access denied'); |
| 606 | 606 | } |
| 607 | 607 | throw new AppAccessException($message); |
@@ -617,9 +617,9 @@ discard block |
||
| 617 | 617 | */ |
| 618 | 618 | public function requireUpdatable($message = null) |
| 619 | 619 | { |
| 620 | - if(! $this->isUpdatable()){ |
|
| 620 | + if (!$this->isUpdatable()) { |
|
| 621 | 621 | $App = $this->App(); |
| 622 | - if(! isset($message)){ |
|
| 622 | + if (!isset($message)) { |
|
| 623 | 623 | $message = $App->translate('Access denied'); |
| 624 | 624 | } |
| 625 | 625 | throw new AppAccessException($message); |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function requireDeletable($message = null) |
| 637 | 637 | { |
| 638 | - if(! $this->isDeletable()){ |
|
| 638 | + if (!$this->isDeletable()) { |
|
| 639 | 639 | $App = $this->App(); |
| 640 | - if(! isset($message)){ |
|
| 640 | + if (!isset($message)) { |
|
| 641 | 641 | $message = $App->translate('Access denied'); |
| 642 | 642 | } |
| 643 | 643 | throw new AppAccessException($message); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public function getSource() |
| 46 | 46 | { |
| 47 | 47 | $App = $this->App(); |
| 48 | - return $App->getRecordByRef($this->sourceClass . ':' . $this->sourceId); |
|
| 48 | + return $App->getRecordByRef($this->sourceClass.':'.$this->sourceId); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function getTarget() |
| 55 | 55 | { |
| 56 | 56 | $App = $this->App(); |
| 57 | - return $App->getRecordByRef($this->targetClass . ':' . $this->targetId); |
|
| 57 | + return $App->getRecordByRef($this->targetClass.':'.$this->targetId); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | |
| 66 | 66 | public function selectUserNotifications($user = null, $seen = false) |
| 67 | 67 | { |
| 68 | - if(! isset($user)){ |
|
| 68 | + if (!isset($user)) { |
|
| 69 | 69 | $App = $this->App(); |
| 70 | 70 | $user = $App->getCurrentUser(); |
| 71 | 71 | } |
@@ -170,8 +170,7 @@ discard block |
||
| 170 | 170 | if(isset($linkType)){ |
| 171 | 171 | if(is_array($linkType)){ |
| 172 | 172 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 173 | - } |
|
| 174 | - else{ |
|
| 173 | + } else{ |
|
| 175 | 174 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 176 | 175 | } |
| 177 | 176 | } |
@@ -207,8 +206,7 @@ discard block |
||
| 207 | 206 | if(isset($linkType)){ |
| 208 | 207 | if(is_array($linkType)){ |
| 209 | 208 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 210 | - } |
|
| 211 | - else{ |
|
| 209 | + } else{ |
|
| 212 | 210 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 213 | 211 | } |
| 214 | 212 | } |
@@ -230,8 +228,7 @@ discard block |
||
| 230 | 228 | if(isset($linkType)){ |
| 231 | 229 | if(is_array($linkType)){ |
| 232 | 230 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 233 | - } |
|
| 234 | - else{ |
|
| 231 | + } else{ |
|
| 235 | 232 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 236 | 233 | } |
| 237 | 234 | } |
@@ -263,8 +260,7 @@ discard block |
||
| 263 | 260 | if(isset($linkType)){ |
| 264 | 261 | if(is_array($linkType)){ |
| 265 | 262 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 266 | - } |
|
| 267 | - else{ |
|
| 263 | + } else{ |
|
| 268 | 264 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 269 | 265 | } |
| 270 | 266 | } |
@@ -329,8 +325,7 @@ discard block |
||
| 329 | 325 | if(isset($linkType)){ |
| 330 | 326 | if(is_array($linkType)){ |
| 331 | 327 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 332 | - } |
|
| 333 | - else{ |
|
| 328 | + } else{ |
|
| 334 | 329 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 335 | 330 | } |
| 336 | 331 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $link = $this->newRecord(); |
| 93 | 93 | $sourceClass = $source->getClassName(); |
| 94 | - if(strpos($sourceClass, '\\')){ |
|
| 94 | + if (strpos($sourceClass, '\\')) { |
|
| 95 | 95 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 96 | 96 | } |
| 97 | 97 | $targetClass = $target->getClassName(); |
| 98 | - if(strpos($targetClass, '\\')){ |
|
| 98 | + if (strpos($targetClass, '\\')) { |
|
| 99 | 99 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 100 | 100 | } |
| 101 | 101 | $link->sourceClass = $sourceClass; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function joinSource($sourceClass) |
| 116 | 116 | { |
| 117 | - if(strpos($sourceClass, '\\')){ |
|
| 117 | + if (strpos($sourceClass, '\\')) { |
|
| 118 | 118 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 119 | 119 | } |
| 120 | - if(! $this->sourceId instanceof $sourceClass){ |
|
| 121 | - $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
| 120 | + if (!$this->sourceId instanceof $sourceClass) { |
|
| 121 | + $this->hasOne('sourceId', $sourceClass.'Set'); |
|
| 122 | 122 | $this->join('sourceId'); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function joinTarget($targetClass = null) |
| 130 | 130 | { |
| 131 | - if(strpos($targetClass, '\\')){ |
|
| 131 | + if (strpos($targetClass, '\\')) { |
|
| 132 | 132 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 133 | 133 | } |
| 134 | - if(! $this->targetId instanceof $targetClass){ |
|
| 135 | - $this->hasOne('targetId', $targetClass . 'Set'); |
|
| 134 | + if (!$this->targetId instanceof $targetClass) { |
|
| 135 | + $this->hasOne('targetId', $targetClass.'Set'); |
|
| 136 | 136 | $this->join('targetId'); |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function sourceIsA($recordClass) |
| 145 | 145 | { |
| 146 | - if(strpos($recordClass, '\\')){ |
|
| 146 | + if (strpos($recordClass, '\\')) { |
|
| 147 | 147 | $recordClass = (new \ReflectionClass($recordClass))->getShortName(); |
| 148 | 148 | } |
| 149 | 149 | return $this->sourceClass->is($recordClass); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function targetIsA($recordClass) |
| 166 | 166 | { |
| 167 | - if(strpos($recordClass, '\\')){ |
|
| 167 | + if (strpos($recordClass, '\\')) { |
|
| 168 | 168 | $recordClass = (new \ReflectionClass($recordClass))->getShortName(); |
| 169 | 169 | } |
| 170 | 170 | return $this->targetClass->is($recordClass); |
@@ -187,24 +187,24 @@ discard block |
||
| 187 | 187 | $criteria = $this->sourceIs($object); |
| 188 | 188 | |
| 189 | 189 | |
| 190 | - if(isset($targetClass)){ |
|
| 191 | - if(strpos($targetClass, '\\')){ |
|
| 190 | + if (isset($targetClass)) { |
|
| 191 | + if (strpos($targetClass, '\\')) { |
|
| 192 | 192 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 193 | 193 | } |
| 194 | 194 | $this->joinTarget($targetClass); |
| 195 | 195 | $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if(isset($linkType)){ |
|
| 199 | - if(is_array($linkType)){ |
|
| 198 | + if (isset($linkType)) { |
|
| 199 | + if (is_array($linkType)) { |
|
| 200 | 200 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 201 | 201 | } |
| 202 | - else{ |
|
| 202 | + else { |
|
| 203 | 203 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if(is_a($this->targetId, 'app_TraceableRecordSet')){ |
|
| 207 | + if (is_a($this->targetId, 'app_TraceableRecordSet')) { |
|
| 208 | 208 | $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -219,27 +219,27 @@ discard block |
||
| 219 | 219 | $sourceClass = null; |
| 220 | 220 | $sourceIds = array(); |
| 221 | 221 | |
| 222 | - foreach ($objects as $obj){ |
|
| 223 | - if(is_null($sourceClass)){ |
|
| 222 | + foreach ($objects as $obj) { |
|
| 223 | + if (is_null($sourceClass)) { |
|
| 224 | 224 | $sourceClass = $obj->getClassName(); |
| 225 | 225 | } |
| 226 | 226 | $sourceIds[] = $obj->id; |
| 227 | 227 | } |
| 228 | 228 | $criteria = $this->sourceId->in($sourceIds)->_AND_($this->sourceClass->is($sourceClass)); |
| 229 | 229 | |
| 230 | - if(isset($targetClass)){ |
|
| 231 | - if(strpos($targetClass, '\\')){ |
|
| 230 | + if (isset($targetClass)) { |
|
| 231 | + if (strpos($targetClass, '\\')) { |
|
| 232 | 232 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 233 | 233 | } |
| 234 | 234 | $this->joinTarget($targetClass); |
| 235 | 235 | $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if(isset($linkType)){ |
|
| 239 | - if(is_array($linkType)){ |
|
| 238 | + if (isset($linkType)) { |
|
| 239 | + if (is_array($linkType)) { |
|
| 240 | 240 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 241 | 241 | } |
| 242 | - else{ |
|
| 242 | + else { |
|
| 243 | 243 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -253,19 +253,19 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | $criteria = $this->targetIs($object); |
| 255 | 255 | |
| 256 | - if(isset($sourceClass)){ |
|
| 257 | - if(strpos($sourceClass, '\\')){ |
|
| 256 | + if (isset($sourceClass)) { |
|
| 257 | + if (strpos($sourceClass, '\\')) { |
|
| 258 | 258 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 259 | 259 | } |
| 260 | 260 | $this->joinSource($sourceClass); |
| 261 | 261 | $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if(isset($linkType)){ |
|
| 265 | - if(is_array($linkType)){ |
|
| 264 | + if (isset($linkType)) { |
|
| 265 | + if (is_array($linkType)) { |
|
| 266 | 266 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 267 | 267 | } |
| 268 | - else{ |
|
| 268 | + else { |
|
| 269 | 269 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -281,27 +281,27 @@ discard block |
||
| 281 | 281 | $targetClass = null; |
| 282 | 282 | $targetIds = array(); |
| 283 | 283 | |
| 284 | - foreach ($objects as $obj){ |
|
| 285 | - if(is_null($targetClass)){ |
|
| 284 | + foreach ($objects as $obj) { |
|
| 285 | + if (is_null($targetClass)) { |
|
| 286 | 286 | $targetClass = $obj->getClassName(); |
| 287 | 287 | } |
| 288 | 288 | $targetIds[] = $obj->id; |
| 289 | 289 | } |
| 290 | 290 | $criteria = $this->targetId->in($targetIds)->_AND_($this->targetClass->is($targetClass)); |
| 291 | 291 | |
| 292 | - if(isset($sourceClass)){ |
|
| 293 | - if(strpos($sourceClass, '\\')){ |
|
| 292 | + if (isset($sourceClass)) { |
|
| 293 | + if (strpos($sourceClass, '\\')) { |
|
| 294 | 294 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 295 | 295 | } |
| 296 | 296 | $this->joinSource($sourceClass); |
| 297 | 297 | $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if(isset($linkType)){ |
|
| 301 | - if(is_array($linkType)){ |
|
| 300 | + if (isset($linkType)) { |
|
| 301 | + if (is_array($linkType)) { |
|
| 302 | 302 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 303 | 303 | } |
| 304 | - else{ |
|
| 304 | + else { |
|
| 305 | 305 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -325,20 +325,20 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | $criteria = $set->sourceId->is($object->id)->_AND_($set->sourceClass->is($object->getClassName())); |
| 327 | 327 | |
| 328 | - if(null !== $targetClass){ |
|
| 329 | - if(strpos($targetClass, '\\')){ |
|
| 328 | + if (null !== $targetClass) { |
|
| 329 | + if (strpos($targetClass, '\\')) { |
|
| 330 | 330 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 331 | 331 | } |
| 332 | 332 | $criteria = $criteria->_AND_($set->targetClass->is($targetClass)); |
| 333 | 333 | } |
| 334 | - if(null !== $linkType){ |
|
| 334 | + if (null !== $linkType) { |
|
| 335 | 335 | $criteria = $criteria->_AND_($set->type->is($linkType)); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if($deleteTarget){ |
|
| 339 | - foreach ($set->select($criteria) as $link){ |
|
| 338 | + if ($deleteTarget) { |
|
| 339 | + foreach ($set->select($criteria) as $link) { |
|
| 340 | 340 | |
| 341 | - $className = $link->targetClass . 'Set'; |
|
| 341 | + $className = $link->targetClass.'Set'; |
|
| 342 | 342 | |
| 343 | 343 | // remove prefix |
| 344 | 344 | |
@@ -363,22 +363,22 @@ discard block |
||
| 363 | 363 | public function deleteLink($source, $target, $linkType = null) |
| 364 | 364 | { |
| 365 | 365 | $sourceClass = $source->getClassName(); |
| 366 | - if(strpos($sourceClass, '\\')){ |
|
| 366 | + if (strpos($sourceClass, '\\')) { |
|
| 367 | 367 | $sourceClass = (new \ReflectionClass($sourceClass))->getShortName(); |
| 368 | 368 | } |
| 369 | 369 | $targetClass = $target->getClassName(); |
| 370 | - if(strpos($targetClass, '\\')){ |
|
| 370 | + if (strpos($targetClass, '\\')) { |
|
| 371 | 371 | $targetClass = (new \ReflectionClass($targetClass))->getShortName(); |
| 372 | 372 | } |
| 373 | 373 | $criteria = $this->sourceId->is($source->id) |
| 374 | 374 | ->_AND_($this->sourceClass->is($sourceClass)) |
| 375 | 375 | ->_AND_($this->targetId->is($target->id)) |
| 376 | 376 | ->_AND_($this->targetClass->is($targetClass)); |
| 377 | - if(isset($linkType)){ |
|
| 378 | - if(is_array($linkType)){ |
|
| 377 | + if (isset($linkType)) { |
|
| 378 | + if (is_array($linkType)) { |
|
| 379 | 379 | $criteria = $criteria->_AND_($this->type->in($linkType)); |
| 380 | 380 | } |
| 381 | - else{ |
|
| 381 | + else { |
|
| 382 | 382 | $criteria = $criteria->_AND_($this->type->is($linkType)); |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -83,15 +83,13 @@ discard block |
||
| 83 | 83 | if(strpos($fieldName, '/') !== false){ |
| 84 | 84 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 85 | 85 | $field = $recordSet->$oneField()->$foreignField; |
| 86 | - } |
|
| 87 | - else{ |
|
| 86 | + } else{ |
|
| 88 | 87 | $field = $recordSet->$fieldName; |
| 89 | 88 | } |
| 90 | 89 | foreach ($condition as $op => $value){ |
| 91 | 90 | if(! is_array($value)){ |
| 92 | 91 | $criteria = $field->$op($value); |
| 93 | - } |
|
| 94 | - else{ |
|
| 92 | + } else{ |
|
| 95 | 93 | foreach ($value as $foreignClassName => $foreignValues){ |
| 96 | 94 | $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
| 97 | 95 | $foreignSet = $App->$foreignClassName(); |
@@ -100,8 +98,7 @@ discard block |
||
| 100 | 98 | foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
| 101 | 99 | if($foreignFieldName === '_foreignField'){ |
| 102 | 100 | $foreignField = $foreignConditions; |
| 103 | - } |
|
| 104 | - else{ |
|
| 101 | + } else{ |
|
| 105 | 102 | foreach ($foreignConditions as $key => $val){ |
| 106 | 103 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 107 | 104 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | static $layouts = null; |
| 58 | 58 | |
| 59 | - if(! isset($layouts)){ |
|
| 59 | + if (!isset($layouts)) { |
|
| 60 | 60 | $layouts = array( |
| 61 | 61 | self::LAYOUT_VERTICAL_BOX => app_translate('Vertical box'), |
| 62 | 62 | self::LAYOUT_HORIZONTAL_BOX => app_translate('Horizontal box'), |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function isVisibleForRecord(AppRecord $record) |
| 75 | 75 | { |
| 76 | - if(empty($this->visibilityCriteria)){ |
|
| 76 | + if (empty($this->visibilityCriteria)) { |
|
| 77 | 77 | return true; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -81,39 +81,39 @@ discard block |
||
| 81 | 81 | $recordSet = $record->getParentSet(); |
| 82 | 82 | |
| 83 | 83 | $arrCriteria = json_decode($this->visibilityCriteria, true); |
| 84 | - if(bab_charset::getIso() != bab_charset::UTF_8){ |
|
| 84 | + if (bab_charset::getIso() != bab_charset::UTF_8) { |
|
| 85 | 85 | $arrCriteria = app_utf8Encode($arrCriteria); |
| 86 | 86 | } |
| 87 | - foreach ($arrCriteria as $fieldName => $condition){ |
|
| 88 | - if(strpos($fieldName, '/') !== false){ |
|
| 87 | + foreach ($arrCriteria as $fieldName => $condition) { |
|
| 88 | + if (strpos($fieldName, '/') !== false) { |
|
| 89 | 89 | list ($oneField, $foreignField) = explode('/', $fieldName); |
| 90 | 90 | $field = $recordSet->$oneField()->$foreignField; |
| 91 | 91 | } |
| 92 | - else{ |
|
| 92 | + else { |
|
| 93 | 93 | $field = $recordSet->$fieldName; |
| 94 | 94 | } |
| 95 | - foreach ($condition as $op => $value){ |
|
| 96 | - if(! is_array($value)){ |
|
| 95 | + foreach ($condition as $op => $value) { |
|
| 96 | + if (!is_array($value)) { |
|
| 97 | 97 | $criteria = $field->$op($value); |
| 98 | 98 | } |
| 99 | - else{ |
|
| 100 | - foreach ($value as $foreignClassName => $foreignValues){ |
|
| 101 | - $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName) . 'Set'; |
|
| 99 | + else { |
|
| 100 | + foreach ($value as $foreignClassName => $foreignValues) { |
|
| 101 | + $foreignClassName = str_replace($App->classPrefix, '', $foreignClassName).'Set'; |
|
| 102 | 102 | $foreignSet = $App->$foreignClassName(); |
| 103 | 103 | $foreignField = ''; |
| 104 | 104 | $foreignCondition = ''; |
| 105 | - foreach ($foreignValues as $foreignFieldName => $foreignConditions){ |
|
| 106 | - if($foreignFieldName === '_foreignField'){ |
|
| 105 | + foreach ($foreignValues as $foreignFieldName => $foreignConditions) { |
|
| 106 | + if ($foreignFieldName === '_foreignField') { |
|
| 107 | 107 | $foreignField = $foreignConditions; |
| 108 | 108 | } |
| 109 | - else{ |
|
| 110 | - foreach ($foreignConditions as $key => $val){ |
|
| 109 | + else { |
|
| 110 | + foreach ($foreignConditions as $key => $val) { |
|
| 111 | 111 | $foreignCondition = $foreignSet->$foreignFieldName->$key($val); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - if(method_exists($foreignSet, 'getDefaultCriteria')){ |
|
| 116 | + if (method_exists($foreignSet, 'getDefaultCriteria')) { |
|
| 117 | 117 | $foreignCondition = $foreignCondition->_AND_($foreignSet->getDefaultCriteria()); |
| 118 | 118 | } |
| 119 | 119 | $criteria = $field->in($foreignCondition, $foreignField); |