Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoyigi committed Nov 22, 2021
2 parents efd709c + cb55107 commit 3cada99
Show file tree
Hide file tree
Showing 157 changed files with 863 additions and 415 deletions.
2 changes: 1 addition & 1 deletion app/admin/actions/AssigneeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function assigneeBindFormEvents()
return;

$assignable = $widget->model;
if (!$assignable->hasAssignToGroup() OR $assignable->hasAssignTo())
if (!$assignable->hasAssignToGroup() || $assignable->hasAssignTo())
return;

// Let the allocator handle assignment when auto assign is enabled
Expand Down
4 changes: 2 additions & 2 deletions app/admin/actions/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function makeCalendar($alias)
$widget->bindToController();

// Prep the optional toolbar widget
if (isset($modelConfig['toolbar']) AND isset($this->controller->widgets['toolbar'])) {
if (isset($modelConfig['toolbar']) && isset($this->controller->widgets['toolbar'])) {
$this->toolbarWidget = $this->controller->widgets['toolbar'];
if ($this->toolbarWidget instanceof \Admin\Widgets\Toolbar)
$this->toolbarWidget->reInitialize($modelConfig['toolbar']);
Expand All @@ -139,7 +139,7 @@ protected function makeCalendar($alias)

public function renderCalendar($alias = null)
{
if (is_null($alias) OR !isset($this->listConfig[$alias]))
if (is_null($alias) || !isset($this->listConfig[$alias]))
$alias = $this->primaryAlias;

$list = [];
Expand Down
16 changes: 8 additions & 8 deletions app/admin/actions/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function initForm($model, $context = null)
$this->formWidget->bindToController();

// Prep the optional toolbar widget
if (isset($modelConfig['toolbar']) AND isset($this->controller->widgets['toolbar'])) {
if (isset($modelConfig['toolbar']) && isset($this->controller->widgets['toolbar'])) {
$this->toolbarWidget = $this->controller->widgets['toolbar'];
if ($this->toolbarWidget instanceof Toolbar) {
$this->toolbarWidget->reInitialize($modelConfig['toolbar']);
Expand Down Expand Up @@ -440,11 +440,11 @@ protected function createModel()
public function makeRedirect($context = null, $model = null)
{
$redirectUrl = null;
if (post('new') AND !ends_with($context, '-new')) {
if (post('new') && !ends_with($context, '-new')) {
$context .= '-new';
}

if (post('close') AND !ends_with($context, '-close')) {
if (post('close') && !ends_with($context, '-close')) {
$context .= '-close';
}

Expand All @@ -454,7 +454,7 @@ public function makeRedirect($context = null, $model = null)

$redirectUrl = $this->getRedirectUrl($context);

if ($model AND $redirectUrl) {
if ($model && $redirectUrl) {
$redirectUrl = parse_values($model->getAttributes(), $redirectUrl);
}

Expand Down Expand Up @@ -502,20 +502,20 @@ protected function prepareModelsToSave($model, $saveData)
*/
protected function setModelAttributes($model, $saveData)
{
if (!is_array($saveData) OR !$model) {
if (!is_array($saveData) || !$model) {
return;
}

$this->modelsToSave[] = $model;

$singularTypes = ['belongsTo', 'hasOne', 'morphOne'];
foreach ($saveData as $attribute => $value) {
$isNested = ($attribute == 'pivot' OR (
$model->hasRelation($attribute) AND
$isNested = ($attribute == 'pivot' || (
$model->hasRelation($attribute) &&
in_array($model->getRelationType($attribute), $singularTypes)
));

if ($isNested AND is_array($value) AND $model->{$attribute}) {
if ($isNested && is_array($value) && $model->{$attribute}) {
$this->setModelAttributes($model->{$attribute}, $value);
}
elseif ($value !== FormField::NO_SAVE_DATA) {
Expand Down
10 changes: 5 additions & 5 deletions app/admin/actions/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function index()
public function index_onDelete()
{
$checkedIds = post('checked');
if (!$checkedIds OR !is_array($checkedIds) OR !count($checkedIds)) {
if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) {
flash()->success(lang('admin::lang.list.delete_empty'));

return $this->controller->refreshList();
Expand Down Expand Up @@ -165,7 +165,7 @@ public function makeLists()
*/
public function makeList($alias)
{
if (!$alias OR !isset($this->listConfig[$alias]))
if (!$alias || !isset($this->listConfig[$alias]))
$alias = $this->primaryAlias;

$listConfig = $this->controller->getListConfig($alias);
Expand Down Expand Up @@ -210,7 +210,7 @@ public function makeList($alias)
$widget->bindToController();

// Prep the optional toolbar widget
if (isset($this->controller->widgets['toolbar']) AND (isset($listConfig['toolbar']) OR isset($modelConfig['toolbar']))) {
if (isset($this->controller->widgets['toolbar']) && (isset($listConfig['toolbar']) || isset($modelConfig['toolbar']))) {
$this->toolbarWidget = $this->controller->widgets['toolbar'];
if ($this->toolbarWidget instanceof \Admin\Widgets\Toolbar)
$this->toolbarWidget->reInitialize($listConfig['toolbar'] ?? $modelConfig['toolbar']);
Expand Down Expand Up @@ -266,7 +266,7 @@ public function makeList($alias)

public function renderList($alias = null)
{
if (is_null($alias) OR !isset($this->listConfig[$alias]))
if (is_null($alias) || !isset($this->listConfig[$alias]))
$alias = $this->primaryAlias;

$list = [];
Expand All @@ -290,7 +290,7 @@ public function refreshList($alias = null)
$this->makeLists();
}

if (!$alias OR !isset($this->listConfig[$alias])) {
if (!$alias || !isset($this->listConfig[$alias])) {
$alias = $this->primaryAlias;
}

Expand Down
2 changes: 1 addition & 1 deletion app/admin/actions/LocationAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function locationBindEvents()

Event::listen('admin.filter.extendQuery', function ($filterWidget, $query, $scope) {
if (array_get($scope->config, 'locationAware') === TRUE
AND (bool)$this->getConfig('applyScopeOnListQuery', TRUE)
&& (bool)$this->getConfig('applyScopeOnListQuery', TRUE)
) $this->locationApplyScope($query);
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/activitytypes/AssigneeUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function log(Assignable_logs_model $assignableLog, User $user = nu

$recipients = [];
foreach ($assignableLog->assignable->listGroupAssignees() as $assignee) {
if ($user AND $assignee->getKey() === $user->staff->getKey()) continue;
if ($user && $assignee->getKey() === $user->staff->getKey()) continue;
$recipients[] = $assignee->user;
}

Expand Down
4 changes: 2 additions & 2 deletions app/admin/activitytypes/StatusUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public static function log(Status_history_model $history, User $user = null)
$type = $history->isForOrder() ? self::ORDER_UPDATED_TYPE : self::RESERVATION_UPDATED_TYPE;

$recipients = [];
if ($history->object->assignee AND $history->object->assignee->getKey() !== $user->staff->getKey())
if ($history->object->assignee && $history->object->assignee->getKey() !== $user->staff->getKey())
$recipients[] = $history->object->assignee->user;

$statusHistory = $history->object->getLatestStatusHistory();
if ($history->object->customer AND $statusHistory AND $statusHistory->notify)
if ($history->object->customer && $statusHistory && $statusHistory->notify)
$recipients[] = $history->object->customer;

activity()->logActivity(new self($type, $history->object, $user), $recipients);
Expand Down
24 changes: 12 additions & 12 deletions app/admin/classes/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function initialize()
$toolbar->bindToController();

// Media Manager widget is available on all admin pages
if ($this->currentUser AND $this->currentUser->hasPermission('Admin.MediaManager')) {
if ($this->currentUser && $this->currentUser->hasPermission('Admin.MediaManager')) {
$manager = new MediaManager($this, ['alias' => 'mediamanager']);
$manager->bindToController();
}
Expand All @@ -188,7 +188,7 @@ public function remap($action, $params)
}

// Determine if this request is a public action or authentication is required
$requireAuthentication = !(in_array($action, $this->publicActions) OR !$this->requireAuthentication);
$requireAuthentication = !(in_array($action, $this->publicActions) || !$this->requireAuthentication);

// Ensures that a user is logged in, if required
if ($requireAuthentication) {
Expand All @@ -199,7 +199,7 @@ public function remap($action, $params)
}

// Check that user has permission to view this page
if ($this->requiredPermissions AND !$this->getUser()->hasAnyPermission($this->requiredPermissions)) {
if ($this->requiredPermissions && !$this->getUser()->hasAnyPermission($this->requiredPermissions)) {
return Response::make(Request::ajax()
? lang('admin::lang.alert_user_restricted')
: View::make('admin::access_denied'), 403
Expand All @@ -215,7 +215,7 @@ public function remap($action, $params)
}

// Execute post handler and AJAX event
if ($handlerResponse = $this->processHandlers() AND $handlerResponse !== TRUE) {
if (($handlerResponse = $this->processHandlers()) && $handlerResponse !== TRUE) {
return $handlerResponse;
}

Expand Down Expand Up @@ -280,10 +280,10 @@ protected function execPageAction($action, $params)
array_unshift($params, $action);

// Execute the action
$result = call_user_func_array([$this, $action], $params);
$result = call_user_func_array([$this, $action], array_values($params));

// Render the controller view if not already loaded
if (is_null($result) AND !$this->suppressView) {
if (is_null($result) && !$this->suppressView) {
return $this->makeView($this->fatalError ? 'admin::error' : $action);
}

Expand Down Expand Up @@ -313,7 +313,7 @@ protected function makeMainMenuWidget()
*/
public function getHandler()
{
if (Request::ajax() AND $handler = Request::header('X-IGNITER-REQUEST-HANDLER'))
if (Request::ajax() && $handler = Request::header('X-IGNITER-REQUEST-HANDLER'))
return trim($handler);

if ($handler = post('_handler'))
Expand Down Expand Up @@ -465,8 +465,8 @@ protected function runHandler($handler, $params)
throw new Exception(sprintf(lang('admin::lang.alert_widget_not_bound_to_controller'), $widgetName));
}

if (($widget = $this->widgets[$widgetName]) AND method_exists($widget, $handlerName)) {
$result = call_user_func_array([$widget, $handlerName], $params);
if (($widget = $this->widgets[$widgetName]) && method_exists($widget, $handlerName)) {
$result = call_user_func_array([$widget, $handlerName], array_values($params));

return $result ?: TRUE;
}
Expand All @@ -476,14 +476,14 @@ protected function runHandler($handler, $params)
$pageHandler = $this->action.'_'.$handler;

if ($this->methodExists($pageHandler)) {
$result = call_user_func_array([$this, $pageHandler], $params);
$result = call_user_func_array([$this, $pageHandler], array_values($params));

return $result ?: TRUE;
}

// Process page global handler (onSomething)
if ($this->methodExists($handler)) {
$result = call_user_func_array([$this, $handler], $params);
$result = call_user_func_array([$this, $handler], array_values($params));

return $result ?: TRUE;
}
Expand All @@ -494,7 +494,7 @@ protected function runHandler($handler, $params)

foreach ((array)$this->widgets as $widget) {
if ($widget->methodExists($handler)) {
$result = call_user_func_array([$widget, $handler], $params);
$result = call_user_func_array([$widget, $handler], array_values($params));

return $result ?: TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/classes/BaseWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function getConfig($name = null, $default = null)
$result = isset($this->config[$fieldName]) ? $this->config[$fieldName] : $default;

foreach ($nameArray as $key) {
if (!is_array($result) OR !array_key_exists($key, $result))
if (!is_array($result) || !array_key_exists($key, $result))
return $default;

$result = $result[$key];
Expand Down
14 changes: 7 additions & 7 deletions app/admin/classes/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,14 @@ protected function filterAttributes($attributes, $position = 'field')
$attributes = $this->filterTriggerAttributes($attributes, $position);
$attributes = $this->filterPresetAttributes($attributes, $position);

if ($position == 'field' AND $this->disabled) {
if ($position == 'field' && $this->disabled) {
$attributes += ['disabled' => 'disabled'];
}

if ($position == 'field' && $this->readOnly) {
$attributes += ['readonly' => 'readonly'];

if ($this->type == 'checkbox' OR $this->type == 'switch') {
if ($this->type == 'checkbox' || $this->type == 'switch') {
$attributes += ['onclick' => 'return false;'];
}
}
Expand All @@ -482,7 +482,7 @@ protected function filterAttributes($attributes, $position = 'field')
*/
protected function filterTriggerAttributes($attributes, $position = 'field')
{
if (!$this->trigger OR !is_array($this->trigger)) {
if (!$this->trigger || !is_array($this->trigger)) {
return $attributes;
}

Expand All @@ -491,12 +491,12 @@ protected function filterTriggerAttributes($attributes, $position = 'field')
$triggerCondition = array_get($this->trigger, 'condition');

// Apply these to container
if (in_array($triggerAction, ['hide', 'show']) AND $position != 'container') {
if (in_array($triggerAction, ['hide', 'show']) && $position != 'container') {
return $attributes;
}

// Apply these to field/input
if (in_array($triggerAction, ['enable', 'disable', 'empty']) AND $position != 'field') {
if (in_array($triggerAction, ['enable', 'disable', 'empty']) && $position != 'field') {
return $attributes;
}

Expand Down Expand Up @@ -529,7 +529,7 @@ protected function filterTriggerAttributes($attributes, $position = 'field')
*/
protected function filterPresetAttributes($attributes, $position = 'field')
{
if (!$this->preset OR $position != 'field') {
if (!$this->preset || $position != 'field') {
return $attributes;
}

Expand Down Expand Up @@ -705,7 +705,7 @@ protected function getFieldNameFromData($fieldName, $data, $default = null)
// To support relations only the last field should return th
// relation value, all others will look up the relation object as normal.
foreach ($keyParts as $key) {
if ($result instanceof Model AND $result->hasRelation($key)) {
if ($result instanceof Model && $result->hasRelation($key)) {
if ($key == $lastField) {
$result = $result->getRelationValue($key) ?: $default;
}
Expand Down
6 changes: 3 additions & 3 deletions app/admin/classes/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function current()
}
else {
$id = $this->getSession('id');
if (!$id AND $this->hasOneLocation() AND !$this->getAuth()->isSuperUser())
if (!$id && $this->hasOneLocation() && !$this->getAuth()->isSuperUser())
$id = $this->getDefaultLocation();

if ($id AND !$this->isAttachedToAuth($id))
if ($id && !$this->isAttachedToAuth($id))
$id = $this->getDefaultLocation();
}

if ($id AND $model = $this->getById($id))
if ($id && $model = $this->getById($id))
$this->setCurrent($model);

return $this->model;
Expand Down
4 changes: 2 additions & 2 deletions app/admin/classes/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getVisibleNavItems()
$navItems = $this->filterPermittedNavItems($navItems);

foreach ($navItems as $code => &$navItem) {
if (!isset($navItem['child']) OR !count($navItem['child'])) {
if (!isset($navItem['child']) || !count($navItem['child'])) {
continue;
}

Expand Down Expand Up @@ -216,7 +216,7 @@ public function registerNavItems($definitions = null, $parent = null)
}

foreach ($definitions as $name => $definition) {
if (isset($definition['child']) AND count($definition['child'])) {
if (isset($definition['child']) && count($definition['child'])) {
$this->registerNavItems($definition['child'], $name);
}

Expand Down
2 changes: 1 addition & 1 deletion app/admin/classes/PaymentGateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function createPartials()
foreach ($paymentMethods as $paymentMethod) {
$class = $paymentMethod->getGatewayClass();

if (!$class OR get_parent_class($class) != BasePaymentGateway::class)
if (!$class || get_parent_class($class) != BasePaymentGateway::class)
continue;

$partialName = 'payregister/'.strtolower(class_basename($class));
Expand Down
Loading

0 comments on commit 3cada99

Please sign in to comment.