/** * Return Search URL * @return string */ public function getSearchUrl() { return $this->_v('searchable.url', zbase_url_from_current()); }
}], 'formConfiguration' => ['submit' => ['button' => ['enable' => false]]]], 'username' => ['type' => 'tab', 'label' => 'Username', 'id' => 'username', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.username', true); }, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['username' => ['type' => 'text', 'id' => 'username', 'enable' => function () { return zbase_config_get('auth.username.enable', false); }, 'label' => 'Username', 'entity' => ['property' => 'username'], 'angular' => ['ngModel' => 'currentUser.username'], 'validations' => ['required' => ['enable' => true, 'message' => 'Username is required.'], 'unique' => ['enable' => true, 'text' => function () { return 'unique:' . zbase_entity('user')->getTable() . ',username,' . zbase_auth_user()->id() . ',user_id'; }, 'message' => 'Username already exists.'], 'regex' => ['enable' => true, 'text' => function () { return 'regex:/^[a-z][a-z0-9]{5,31}$/'; }, 'message' => 'Invalid username.'], 'min' => ['enable' => true, 'text' => function () { return 'min:5'; }, 'message' => 'Username should be of 5 up to 32 characters.'], 'max' => ['enable' => true, 'text' => function () { return 'max:32'; }, 'message' => 'Username should be of 5 up to 32 characters.'], 'not_in' => ['enable' => true, 'text' => function () { $notAllowedUsernames = (require zbase_path_library('notallowedusernames.php')); $notAllowedUsernames[] = zbase_auth_user()->username(); return 'not_in:' . implode(',', $notAllowedUsernames); }, 'message' => 'Please provide a different username.']]]]], 'email' => ['type' => 'tab', 'label' => 'Email Address', 'id' => 'email', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.email', true); }, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['email' => ['type' => 'email', 'id' => 'email', 'label' => 'Email Address', 'entity' => ['property' => 'email'], 'angular' => ['ngModel' => 'currentUser.email'], 'html' => ['attributes' => ['input' => ['autocomplete' => 'off']]], 'validations' => ['required' => ['enable' => true, 'message' => 'Email address is required.'], 'unique' => ['enable' => true, 'text' => function () { return 'unique:' . zbase_entity('user')->getTable() . ',email,' . zbase_auth_user()->id() . ',user_id'; }, 'message' => 'Email address already exists.'], 'not_in' => ['enable' => true, 'text' => function () { return 'not_in:' . zbase_auth_user()->email; }, 'message' => 'Please provide a different email address.']]]]], 'password' => ['type' => 'tab', 'label' => 'Update Password', 'id' => 'password', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.password', true); }, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['header' => ['ui' => ['type' => 'component.pageHeader', 'id' => 'header', 'text' => 'To update password, enter your current password.']], 'password' => ['type' => 'password', 'id' => 'password', 'label' => null, 'validations' => ['required' => ['enable' => true, 'message' => 'Enter your account password.'], 'accountPassword' => ['enable' => true, 'message' => 'Account password don\'t match.']]]]], 'images' => ['type' => 'tab', 'label' => 'Profile Image', 'id' => 'images', 'group' => 'accountTab', 'enable' => function () { return zbase_config_get('modules.account.widgets.account.tab.images', true); }, 'position' => 90, 'formConfiguration' => ['angular' => ['form' => ['startTag' => ['html' => ['attributes' => ['ng-controller' => 'adminAccountMainController', 'flow-init' => function () { return '{headers:{\'X-CSRF-TOKEN\': \'' . zbase_csrf_token() . '\'}, target: \'' . zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'updateProfileImage']) . '\'}'; }, 'flow-files-submitted' => '$flow.upload();']]]], 'submit' => ['button' => ['enable' => false]]]], 'elements' => ['file' => ['type' => 'file', 'id' => 'file', 'label' => 'Update Image', 'action' => function () { return zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'updateProfileImage']); }, 'entity' => ['property' => 'file'], 'html' => ['attributes' => ['input' => ['style' => 'width: 100px;']], 'content' => ['pre' => ['enable' => true, 'view' => zbase_view_file_contents('node.files.files')]]]]]]]]];
$perPages = $ui->getRowsPerPages(); if ($paginator instanceof \Illuminate\Pagination\LengthAwarePaginator) { $perPageRequest = zbase_request_query_input('pp', false); if (!empty($perPageRequest) && !zbase_is_angular()) { $paginator->appends(['pp' => $perPageRequest]); } $presenter = new \Illuminate\Pagination\BootstrapThreePresenter($paginator); if (zbase_is_angular()) { echo str_replace(array('?page=', 'class="pagination', route('index')), array('/page/', 'class="pagination pagination-pages pagination-sm', '#'), $presenter->render()); } else { echo str_replace(array('class="pagination'), array('class="pagination pagination-pages pagination-sm'), $presenter->render()); } if (!zbase_is_angular()) { echo '<ul class="pagination pagination-perpage pagination-sm">'; if ($paginator->lastPage() > 1 && !empty($perPages)) { echo '<li><a class="btn disabled" href="#">Rows</a></li>'; } if (!empty($perPages)) { foreach ($perPages as $perPage) { if ($paginator->total() > $perPage) { echo '<li><a data-perpage="' . $perPage . '" ' . 'href="' . zbase_url_from_current(['pp' => $perPage], false) . '" ' . ($paginator->perPage() == $perPage ? 'class="active"' : '') . '>' . $perPage . '</a>' . '</li>'; } } } if ($paginator->total() > $paginator->perPage()) { echo '<li><a data-perpage="all" href="' . zbase_url_from_current(['pp' => $paginator->total()], false) . '" ' . ($paginator->perPage() > $perPageRequest ? 'class="pagination-view-all active"' : '') . ' title="View all rows">' . 'View all' . '</a></li>'; } echo '</ul>'; } }
ob_start(); ?> <script type="text/javascript"> jQuery('#btnTelegramEnable').click(function (e) { e.preventDefault(); jQuery(this).hide(); jQuery('#telegramConnetingInfo').show(); setInterval(function () { zbase_ajax_post('<?php echo zbase_url_from_route('admin.account', ['action' => 'telegram-check']); ?> ', {}, function (e) { if (e.telegramHooked !== undefined) { window.location = '<?php echo zbase_url_from_current(); ?> '; } }, {}); }, 5000); window.open(jQuery(this).attr('href')); }); </script> <?php $script = ob_get_clean(); zbase_view_script_add('telegramEnabler', $script, true); ?> <?php } else {
$sortingOptions = []; if (!empty($sortables)) { foreach ($sortables as $column => $sortable) { $sort = zbase_data_get($sortable, 'options.sort'); if (!empty($sort) && is_array($sort)) { foreach ($sort as $s) { if (!empty($s['label'])) { $selected = ''; if (!empty($currentSorting) && array_key_exists($column, $currentSorting)) { $selected = ' selected="selected"'; $currentDir = $currentSorting[$column]; $params = ['sort' => [$column => strtolower($currentDir) == 'asc' ? 'desc' : 'asc']]; } else { $params = ['sort' => [$column => 'asc']]; } $url = zbase_url_from_current($params); $sortingOptions[] = '<option ' . $selected . ' value="' . $url . '">' . $s['label'] . '</option>'; } } } } } if (!empty($sortingOptions)) { ?> <div class="form-group"> <select class="form-control" onchange="window.location = jQuery(this).val();"> <option value="<?php echo zbase_url(); ?> ">Sort</option> <?php
/** * Update email Address Request * Process the link that was sent into the email when * a user wanted to update his email address to a new email address * * routename: update-email-request, expect: email and token * @return */ public function emailUpdateRequestVerify() { $email = $this->getRouteParameter('email', false); $token = $this->getRouteParameter('token', false); if (!empty($email) && !empty($token)) { $user = zbase_user_by('email', $email); if ($user instanceof \Zbase\Entity\Laravel\User\User) { if (zbase_auth_has()) { $updated = $user->checkEmailRequestUpdate($token); if (!empty($updated)) { zbase_session_set('update-email-address', true); return redirect()->to(zbase_url_from_route('home')); } else { zbase_alert('error', 'There was an error updating your email address. Kindly try again.'); } } else { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect()->to(zbase_url_from_route('login')); } } } return $this->notfound(); }
* @project Expression project.name is undefined on line 13, column 15 in Templates/Scripting/EmptyPHP.php. * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php. * */ return ['type' => 'form', 'enable' => function () { return zbase_config_get('modules.users.widgets.adminUser', true); }, 'config' => ['form_tab' => false, 'form' => ['startTag' => ['html' => ['attributes' => ['ng-controller' => 'adminUsersController']]]], 'submit' => ['button' => ['label' => 'Update', 'html' => ['attributes' => ['ng-click' => 'ANGULAR_WIDGET_MODULE_SCOPENAME.updateSelectedItem()']]]], 'entity' => ['node' => ['enable' => true], 'name' => 'user', 'repo' => ['byId' => ['route' => 'id']]], 'event' => ['view' => ['post' => ['redirect' => ['enable' => false]]]], 'html' => ['content' => ['pre' => ['enable' => true, 'html' => function () { return zbase_widget('admin-users', [], true, ['config' => ['searchable' => ['onload' => false]]]); }]]], 'tabs' => ['account' => ['type' => 'tab', 'label' => 'Account', 'id' => 'account', 'group' => 'accountTab', 'enable' => true, 'position' => 100, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['roleName' => ['type' => 'select', 'id' => 'role', 'label' => 'Role', 'multiOptions' => 'userRoles', 'entity' => ['property' => 'roleName']], 'status' => ['type' => 'select', 'id' => 'status', 'label' => 'Status', 'multiOptions' => 'userStatus', 'entity' => ['property' => 'status']]]], 'profile' => ['type' => 'tab', 'label' => 'Profile', 'id' => 'profile', 'group' => 'accountTab', 'enable' => true, 'position' => 100, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['first_name' => ['type' => 'text', 'id' => 'first_name', 'enable' => true, 'label' => 'First Name', 'angular' => ['ngModel' => ['prefix' => 'currentUser.profile']], 'entity' => ['property' => 'first_name']], 'last_name' => ['type' => 'text', 'id' => 'last_name', 'enable' => true, 'label' => 'Last Name', 'angular' => ['ngModel' => ['prefix' => 'currentUser.profile']], 'entity' => ['property' => 'last_name']]]], 'username' => ['type' => 'tab', 'label' => 'Username', 'id' => 'username', 'group' => 'accountTab', 'enable' => true, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['username' => ['type' => 'text', 'id' => 'username', 'enable' => function () { return zbase_config_get('auth.username.enable', false); }, 'label' => 'Username', 'entity' => ['property' => 'username'], 'angular' => ['ngModel' => 'currentUser.username'], 'validations' => ['required' => ['enable' => true, 'message' => 'Username is required.'], 'unique' => ['enable' => true, 'text' => function () { return 'unique:' . zbase_entity('user')->getTable() . ',username,' . zbase_auth_user()->id() . ',user_id'; }, 'message' => 'Username already exists.'], 'regex' => ['enable' => true, 'text' => function () { return 'regex:/^[a-z][a-z0-9]{5,31}$/'; }, 'message' => 'Invalid username.'], 'min' => ['enable' => true, 'text' => function () { return 'min:5'; }, 'message' => 'Username should be of 5 up to 32 characters.'], 'max' => ['enable' => true, 'text' => function () { return 'max:32'; }, 'message' => 'Username should be of 5 up to 32 characters.'], 'not_in' => ['enable' => true, 'text' => function () { $notAllowedUsernames = (require zbase_path_library('notallowedusernames.php')); $notAllowedUsernames[] = zbase_auth_user()->username(); return 'not_in:' . implode(',', $notAllowedUsernames); }, 'message' => 'Please provide a different username.']]]]], 'email' => ['type' => 'tab', 'label' => 'Email Address', 'id' => 'email', 'group' => 'accountTab', 'enable' => true, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['email' => ['type' => 'email', 'id' => 'email', 'label' => 'Email Address', 'entity' => ['property' => 'email'], 'angular' => ['ngModel' => 'currentUser.email'], 'html' => ['attributes' => ['input' => ['autocomplete' => 'off']]], 'validations' => ['required' => ['enable' => true, 'message' => 'Email address is required.'], 'unique' => ['enable' => true, 'text' => function () { return 'unique:' . zbase_entity('user')->getTable() . ',email,' . zbase_auth_user()->id() . ',user_id'; }, 'message' => 'Email address already exists.'], 'not_in' => ['enable' => true, 'text' => function () { return 'not_in:' . zbase_auth_user()->email; }, 'message' => 'Please provide a different email address.']]]]], 'passwordx' => ['type' => 'tab', 'label' => 'Update Password', 'id' => 'passwordx', 'group' => 'accountTab', 'enable' => true, 'formConfiguration' => ['form' => ['startTag' => ['action' => zbase_url_from_current(), 'html' => ['attributes' => ['class' => ['zbase-ajax-form']]]]]], 'elements' => ['password' => ['type' => 'password', 'id' => 'password', 'label' => 'Enter new Password', 'validations' => ['required' => ['enable' => true, 'message' => 'Enter new password.'], 'same' => ['enable' => true, 'text' => 'required|confirmed|min:6']]], 'password_confirmation' => ['type' => 'password', 'id' => 'password_confirmation', 'label' => 'Confirm new Password', 'validations' => ['required' => ['enable' => true, 'message' => 'Enter new password.']]]]], 'images' => ['type' => 'tab', 'label' => 'Profile Image', 'id' => 'images', 'group' => 'accountTab', 'enable' => true, 'position' => 90, 'formConfiguration' => ['angular' => ['form' => ['startTag' => ['html' => ['attributes' => ['ng-controller' => 'adminAccountMainController', 'flow-init' => function () { return '{headers:{\'X-CSRF-TOKEN\': \'' . zbase_csrf_token() . '\'}, target: \'' . zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'updateProfileImage']) . '\'}'; }, 'flow-files-submitted' => '$flow.upload();']]]], 'submit' => ['button' => ['enable' => false]]]], 'elements' => ['file' => ['type' => 'file', 'id' => 'file', 'label' => 'Update Image', 'action' => function () { return zbase_api_url(['module' => 'account', 'object' => 'user', 'method' => 'updateProfileImage']); }, 'entity' => ['property' => 'file'], 'html' => ['attributes' => ['input' => ['style' => 'width: 100px;']], 'content' => ['pre' => ['enable' => true, 'view' => zbase_view_file_contents('node.files.files')]]]]]]]]];
/** * Create a route * @param string $name The Route Name * @param array $route The Route configuration * @return Response */ function zbase_route_response($name, $route) { if (!empty(zbase_is_maintenance())) { return zbase_response(view(zbase_view_file('maintenance'))); } $redirect = zbase_value_get($route, 'redirect', false); if (!empty($redirect)) { return redirect()->to($redirect); } $response = zbase_value_get($route, 'response', false); if (!empty($response)) { return $response; } /** * If we are using username in routes, * we have to check if the username exists in DB. * This is checked in zbase_route_username_get() * if the zbase_route_username_get() returns false, means * that the route is not a username or username didn't exists. * Here we check against all other Routes if the prefix is in our * list of routes, if not found, throw NotFoundHttpException */ $useUsernameRoute = zbase_route_username(); $usernameRoute = zbase_route_username_get(); $usernameRouteCheck = zbase_data_get($route, 'usernameRouteCheck', true); if (empty($usernameRouteCheck)) { /** * Will not check for username route */ $useUsernameRoute = false; } //if($usernameRoute === false && !empty($useUsernameRoute)) if ($name == 'index' && zbase_auth_has() && !empty($useUsernameRoute)) { return redirect()->to('/' . zbase_auth_real()->username); } if ($usernameRoute === false && !empty($useUsernameRoute)) { $uri = zbase_url_uri(); $adminKey = zbase_admin_key(); if (!empty($uri)) { $uriEx = explode('/', $uri); if (!empty($uriEx)) { foreach ($uriEx as $uriV) { if (!empty($uriV)) { /** * If it isn't an admin key, check it against given Routes */ if ($uriV !== $adminKey) { $routes = zbase_config_get('routes', []); if (!empty($routes)) { foreach ($routes as $rName => $r) { if (!empty($r['enable']) && !empty($r['url'])) { $urlEx = explode('/', $r['url']); if (!empty($urlEx)) { foreach ($urlEx as $urlExV) { if (!empty($urlExV)) { if ($uriV == $urlExV) { /** * Found it, valid URL */ $validUrlPrefix = true; } /** * Will deal only with the first not empty value so break it. */ break; } } } } if (!empty($validUrlPrefix)) { /** * Found it, break it */ $name = $rName; $route = $r; break; } } } } else { return redirect(zbase_url_from_route('home')); } /** * Will deal only with the first not empty value so break it. */ break; } } if (empty($validUrlPrefix)) { /** * Only if routeName is not the index */ if ($name != 'index') { // $response = new \Zbase\Exceptions\NotFoundHttpException(); // return $response->render(zbase_request(), $response); } } } } } $usernameRoutePrefix = zbase_route_username_prefix(); $originalRouteName = str_replace($usernameRoutePrefix, '', $name); zbase()->setCurrentRouteName($name); $guest = true; $authed = false; $guestOnly = false; $middleware = !empty($route['middleware']) ? $route['middleware'] : false; $backend = !empty($route['backend']) ? $route['backend'] : false; if ($name == 'password-reset' && zbase_auth_has()) { \Auth::guard()->logout(); return redirect(zbase_url_from_current()); } if (!empty($backend)) { // zbase_in_back(); } if (preg_match('/\\?usernameroute/', zbase_url_uri()) > 0 && !empty($useUsernameRoute) && zbase_auth_has()) { return redirect()->to('/' . zbase_auth_user()->username() . '/home'); } if (!empty($useUsernameRoute) && zbase_auth_has() && $usernameRoute != zbase_auth_user()->username()) { return redirect(zbase_url_from_route($originalRouteName, [$usernameRoutePrefix => zbase_auth_user()->username()])); } if (!empty($middleware)) { if (is_array($middleware)) { $access = isset($middleware['access']) ? $middleware['access'] : false; if (!empty($access) && is_array($access)) { if (!zbase_auth_has()) { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('login')); } if (zbase_auth_has() && !zbase_auth_is($access)) { return zbase_abort(401, ucfirst($access) . ' is needed to access the page.'); } } else { $guest = isset($middleware['guest']) ? $middleware['guest'] : false; $authed = isset($middleware['auth']) ? $middleware['auth'] : false; $adminAuthed = isset($middleware['admin']) ? $middleware['admin'] : false; if ($adminAuthed) { $authed = true; } $guestOnly = isset($middleware['guestOnly']) ? $middleware['guestOnly'] : false; } } } if (empty($access)) { if (!empty($backend)) { if (!empty($usernameRoute)) { /** * If user is loggedIn and this is admin side and this is not logIn page, * redirect to users dashboard. * User can only access his own dashboard via /{usernameroute?}/admin */ if (zbase_auth_has() && zbase_auth_is(zbase_route_username_minimum_access()) && zbase_is_back() && $usernameRoute != zbase_auth_user()->username()) { return redirect(zbase_url_from_route('admin', [$usernameRoutePrefix => zbase_auth_user()->username])); } if ((empty(zbase_auth_has()) || !zbase_auth_is('user')) && $name != $usernameRoutePrefix . 'admin.login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('admin.login')); } } else { if ((empty(zbase_auth_has()) || !zbase_auth_is('admin')) && $name != 'admin.login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('admin.login')); } } } else { if (!empty($guestOnly) && zbase_auth_has()) { return redirect(zbase_url_from_route('home')); } if (!empty($usernameRoute)) { if (!empty($authed) && !zbase_auth_has() && $name != $usernameRoutePrefix . 'login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('login')); } } else { if (!empty($authed) && !zbase_auth_has() && $name != 'login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('login')); } } } } $params = zbase_route_inputs(); $requestMethod = zbase_request_method(); $controller = !empty($route['controller']) ? $route['controller'] : null; $command = !empty($route['command']) ? $route['command'] : false; if (!empty($command) && $command instanceof \Closure) { $command(); exit; } if (!empty($controller) && !empty($controller['name']) && !empty($route['controller']['enable'])) { $controllerName = !empty($route['controller']['name']) ? $route['controller']['name'] : null; $controllerMethod = !empty($route['controller']['method'][$requestMethod]) ? $route['controller']['method'][$requestMethod] : (!empty($route['controller']['method']) ? $route['controller']['method'] : 'index'); if (!empty($controllerName)) { $controllerConfig = zbase_config_get('controller.class.' . $controllerName, null); if (!empty($controllerConfig) && !empty($controllerConfig['enable'])) { $controllerClass = zbase_controller_create_name(zbase_config_get('controller.class.' . $controllerName . '.name', Zbase\Http\Controllers\__FRAMEWORK__\PageController::class)); $controllerObject = zbase_object_factory($controllerClass, !empty($route['controller']['params']) ? $route['controller']['params'] : []); zbase()->setController($controllerObject->setName($controllerName)->setActionName($controllerMethod)->setRouteParameters($params)); zbase_view_page_details($route); return zbase_response($controllerObject->{$controllerMethod}()); } } } $view = !empty($route['view']) ? $route['view'] : null; if (!empty($view) && !empty($view['name']) && !empty($route['view']['enable'])) { zbase_view_page_details($route); if (!empty($route['view']['content'])) { $params['content'] = zbase_data_get($route['view']['content'], null); } if ($view['name'] == 'type.js') { zbase_response_format_set('javascript'); } return zbase_response(zbase_view_render(zbase_view_file($view['name']), $params)); } }