-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ | |
use Craft; | ||
use flipbox\craft\ember\records\ActiveRecord; | ||
use flipbox\craft\ember\records\SortableTrait; | ||
use flipbox\organizations\Organizations; | ||
use flipbox\organizations\queries\OrganizationTypeAssociationQuery; | ||
use yii\helpers\Json; | ||
|
||
/** | ||
* @author Flipbox Factory <[email protected]> | ||
|
@@ -103,12 +105,29 @@ public function beforeSave($insert) | |
*/ | ||
public function afterSave($insert, $changedAttributes) | ||
{ | ||
$this->autoReOrder( | ||
'typeId', | ||
[ | ||
'organizationId' => $this->organizationId | ||
] | ||
); | ||
try { | ||
$this->autoReOrder( | ||
'typeId', | ||
[ | ||
'organizationId' => $this->organizationId | ||
] | ||
); | ||
} catch (\Exception $e) { | ||
Organizations::error( | ||
sprintf( | ||
"Exception caught while trying to reorder '%s'. Exception: [%s].", | ||
(string)get_class($this), | ||
(string)Json::encode([ | ||
'Trace' => $e->getTraceAsString(), | ||
'File' => $e->getFile(), | ||
'Line' => $e->getLine(), | ||
'Code' => $e->getCode(), | ||
'Message' => $e->getMessage() | ||
]) | ||
), | ||
__METHOD__ | ||
); | ||
} | ||
|
||
parent::afterSave($insert, $changedAttributes); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
use flipbox\organizations\Organizations; | ||
use flipbox\organizations\queries\UserAssociationQuery; | ||
use yii\db\ActiveQueryInterface; | ||
use yii\helpers\Json; | ||
|
||
/** | ||
* @author Flipbox Factory <[email protected]> | ||
|
@@ -182,23 +183,40 @@ public function beforeSave($insert) | |
*/ | ||
public function afterSave($insert, $changedAttributes) | ||
{ | ||
if (Organizations::getInstance()->getSettings()->getEnforceUserSortOrder()) { | ||
$this->autoReOrder( | ||
'userId', | ||
[ | ||
'organizationId' => $this->organizationId | ||
], | ||
'userOrder' | ||
); | ||
} | ||
try { | ||
if (Organizations::getInstance()->getSettings()->getEnforceUserSortOrder()) { | ||
$this->autoReOrder( | ||
'userId', | ||
[ | ||
'organizationId' => $this->organizationId | ||
], | ||
'userOrder' | ||
); | ||
} | ||
|
||
if (Organizations::getInstance()->getSettings()->getEnforceOrganizationSortOrder()) { | ||
$this->autoReOrder( | ||
'organizationId', | ||
[ | ||
'userId' => $this->userId | ||
], | ||
'organizationOrder' | ||
if (Organizations::getInstance()->getSettings()->getEnforceOrganizationSortOrder()) { | ||
$this->autoReOrder( | ||
'organizationId', | ||
[ | ||
'userId' => $this->userId | ||
], | ||
'organizationOrder' | ||
); | ||
} | ||
} catch (\Exception $e) { | ||
Organizations::error( | ||
sprintf( | ||
"Exception caught while trying to reorder '%s'. Exception: [%s].", | ||
(string)get_class($this), | ||
(string)Json::encode([ | ||
'Trace' => $e->getTraceAsString(), | ||
'File' => $e->getFile(), | ||
'Line' => $e->getLine(), | ||
'Code' => $e->getCode(), | ||
'Message' => $e->getMessage() | ||
]) | ||
), | ||
__METHOD__ | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,10 @@ | |
use flipbox\craft\ember\helpers\ModelHelper; | ||
use flipbox\craft\ember\records\ActiveRecord; | ||
use flipbox\craft\ember\records\SortableTrait; | ||
use flipbox\organizations\Organizations; | ||
use flipbox\organizations\queries\UserTypeAssociationQuery; | ||
use yii\db\ActiveQueryInterface; | ||
use yii\helpers\Json; | ||
|
||
/** | ||
* @author Flipbox Factory <[email protected]> | ||
|
@@ -103,12 +105,29 @@ public function beforeSave($insert) | |
*/ | ||
public function afterSave($insert, $changedAttributes) | ||
{ | ||
$this->autoReOrder( | ||
'typeId', | ||
[ | ||
'userId' => $this->userId | ||
] | ||
); | ||
try { | ||
$this->autoReOrder( | ||
'typeId', | ||
[ | ||
'userId' => $this->userId | ||
] | ||
); | ||
} catch (\Exception $e) { | ||
Organizations::error( | ||
sprintf( | ||
"Exception caught while trying to reorder '%s'. Exception: [%s].", | ||
(string)get_class($this), | ||
(string)Json::encode([ | ||
'Trace' => $e->getTraceAsString(), | ||
'File' => $e->getFile(), | ||
'Line' => $e->getLine(), | ||
'Code' => $e->getCode(), | ||
'Message' => $e->getMessage() | ||
]) | ||
), | ||
__METHOD__ | ||
); | ||
} | ||
|
||
parent::afterSave($insert, $changedAttributes); | ||
} | ||
|