Example #1
0
 /**
  * Controller Action
  * 	This will be called validating the form
  * @param string $action
  */
 public function controller($action)
 {
     $this->setAction($action);
     $repoMethod = $this->_v('repo.method', 'count');
     if ($repoMethod == 'update') {
         $ret = $this->entity()->widgetController(zbase_request_method(), $this->getAction(), [], $this);
         $actionMessages = $this->entity()->getActionMessages($this->getAction());
         if (!empty($actionMessages)) {
             foreach ($actionMessages as $alertType => $alertMessages) {
                 if (is_array($alertMessages)) {
                     foreach ($alertMessages as $alertMessage) {
                         zbase_alert($alertType, $alertMessage);
                     }
                 }
             }
         }
         if (!empty($ret)) {
             $url = zbase_url_previous();
             return zbase_redirect()->to($url);
         }
     }
     if (!$this->checkUrlRequest()) {
         return zbase_abort(404);
     }
     $this->_rows();
 }
Example #2
0
 /**
  * Event after Action
  * @param string $action
  * @param string $url The Default URL to redirect
  */
 protected function _postEvent($action)
 {
     if ($this->isPublic() && $this->isNode() && $this->isCreating()) {
         return zbase_redirect()->to($this->entity()->alphaUrl());
     }
     $isAjax = zbase_request_is_ajax();
     $requestMethod = strtolower(zbase_request_method());
     if ($isAjax) {
         if ($requestMethod == 'post') {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post-json.post', $this->_v('event.' . $action . '.post-json'));
         } else {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post-json', $this->_v('event.' . zbase_section() . '.' . $action . '.post'));
         }
     } else {
         if ($requestMethod == 'post') {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post.post', $this->_v('event.' . $action . '.post.post', null));
         } else {
             $e = $this->_v('event.' . zbase_section() . '.' . $action . '.post', $this->_v('event.' . $action . '.post', null));
         }
     }
     if (is_null($e)) {
         if (zbase_is_back()) {
             if ($this->isCreating()) {
                 $action = 'update';
             }
             $byAlphaId = $this->_v('entity.repo.byAlphaId.route', false);
             if ($this->entityIsPostInterface($this->entity())) {
                 if (!empty($byAlphaId)) {
                     $params = ['action' => $action, 'id' => $this->entity()->postAlphaId()];
                 } else {
                     $params = ['action' => $action, 'id' => $this->entity()->postId()];
                 }
             } else {
                 if (!empty($byAlphaId)) {
                     $params = ['action' => $action, 'id' => $this->entity()->alphaId()];
                 } else {
                     $params = ['action' => $action, 'id' => $this->entity()->id()];
                 }
             }
         } else {
             $params = ['action' => $action, 'id' => $this->entity()->alphaId()];
         }
         if ($action == 'delete') {
             $params = [];
         }
         $url = $this->getModule()->url(zbase_section(), $params);
         if ($action == 'restore' || $action == 'ddelete') {
             $url = zbase_url_previous();
         }
     }
     if (!empty($e)) {
         if (!empty($e['data'])) {
             if ($isAjax) {
                 zbase()->json()->addVariables($e['data']);
             }
         }
         if (!empty($e['route'])) {
             $params = zbase_route_inputs();
             if (!empty($e['route']['params'])) {
                 $params = array_merge($params, $e['route']['params']);
             }
             if (zbase_is_back()) {
                 $byAlphaId = $this->_v('entity.repo.byAlphaId.route', false);
                 if (!empty($byAlphaId)) {
                     $params['id'] = $this->entity()->alphaId();
                 } else {
                     $params['id'] = $this->entity()->id();
                 }
             }
             if ($action == 'ddelete') {
                 if (isset($params['id']) && isset($params['action'])) {
                     unset($params['id']);
                     unset($params['action']);
                 }
             }
             $e['route']['params'] = $params;
             $url = zbase_url_from_config($e);
         }
         $toUrl = zbase_value_get($e, 'url', false);
         if (!empty($toUrl)) {
             $url = $toUrl;
         }
     }
     $enableRedirect = $this->_v('event.' . zbase_section() . '.' . $action . '.post.redirect.enable', $this->_v('event.' . $action . '.post.redirect.enable', true));
     if (!empty($url) && !empty($enableRedirect)) {
         return zbase_redirect()->to($url);
     }
     return true;
 }
Example #3
0
 /**
  * Log the user out of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function logout()
 {
     \Auth::guard($this->getGuard())->logout();
     return zbase_redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
 }
Example #4
0
/**
 * Redirect with message
 * @param string $to
 * @param string $message
 * @TODO Add message
 * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
 */
function zbase_redirect_with_message($to, $message)
{
    zbase_alert('error', $message);
    return zbase_redirect($to);
}
Example #5
0
}, 'json-profile' => function () {
    return zbase_config_get('modules.account.widgets.controller.profile', ['account-profile' => null]);
}, 'image' => function () {
    return zbase_config_get('modules.account.widgets.controller.image', ['account-image' => null]);
}, 'resend-email-verification' => function () {
    zbase_auth_user()->resendEmailVerificationCode();
    return zbase_redirect()->to(zbase_url_previous());
}, 'json-resend-email-verification' => function () {
    zbase_auth_user()->resendEmailVerificationCode();
    return zbase_redirect()->to(zbase_url_previous());
}, 'json-telegram-check' => function () {
    $r = zbase()->telegram()->checkUserCode(zbase_auth_user());
    if ($r) {
        zbase()->json()->addVariable('telegramHooked', 1);
        return zbase_redirect()->to(zbase_url_from_route('admin.account'));
    } else {
        dd('waiting to hooked...');
    }
}, 'telegram-disable' => function () {
    zbase()->telegram()->disableUserTelegram(zbase_auth_user());
    return redirect()->to(zbase_url_previous());
}, 'email-verify' => function () {
    $emailAddress = zbase_route_input('task');
    $code = zbase_request_input('c');
    $user = zbase_user_by('email', $emailAddress);
    if (!empty($user)) {
        $user->verifyEmailAddress($code);
        return zbase_redirect(zbase_url_from_route('home'));
    }
    return zbase_abort(404);
}]]];