1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
8
|
|
|
* @link https://vistart.me/ |
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
10
|
|
|
* @license https://vistart.me/license/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace rhosocial\organization\web\user\controllers\organization; |
14
|
|
|
|
15
|
|
|
use rhosocial\organization\exceptions\RevokePreventedException; |
16
|
|
|
use rhosocial\organization\web\user\controllers\OrganizationController; |
17
|
|
|
use Yii; |
18
|
|
|
use yii\base\Action; |
19
|
|
|
use yii\base\InvalidParamException; |
20
|
|
|
use yii\web\BadRequestHttpException; |
21
|
|
|
use yii\web\ServerErrorHttpException; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @version 1.0 |
25
|
|
|
* @author vistart <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class RevokeAction extends Action |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Revoke organization or department. |
31
|
|
|
* @param string|integer $id |
32
|
|
|
* @throws ServerErrorHttpException |
33
|
|
|
*/ |
34
|
|
|
public function run($id) |
35
|
|
|
{ |
36
|
|
|
try { |
37
|
|
|
Yii::$app->user->identity->revokeOrganization($id, true); |
38
|
|
|
} catch (InvalidParamException $ex) { |
39
|
|
|
throw new BadRequestHttpException(Yii::t('organization', $ex->getMessage())); |
40
|
|
|
} catch (RevokePreventedException $ex) { |
41
|
|
|
throw new BadRequestHttpException(Yii::t('organization', $ex->getMessage())); |
42
|
|
|
} catch (\Exception $ex) { |
43
|
|
|
throw new ServerErrorHttpException($ex->getMessage()); |
44
|
|
|
} |
45
|
|
|
Yii::$app->session->setFlash(OrganizationController::SESSION_KEY_RESULT, OrganizationController::RESULT_SUCCESS); |
46
|
|
|
Yii::$app->session->setFlash(OrganizationController::SESSION_KEY_MESSAGE, "($id) " . $this->controller->organizationRevokeSuccessMessage); |
47
|
|
|
return $this->controller->redirect(['list']); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|