/** * Check if current user has access to the resource * @param string|array $access The Access needed * @param string $resource The resource * @param boolean */ function zbase_auth_check_access($access, $resource = null) { if (strtolower($access) == 'guest') { return true; } if (zbase_auth_has()) { return (bool) zbase_auth_user()->hasAccess(strtolower($access), $resource); } return false; }
/** * Create a URL Based from a route $name * @param type $name * @param type $params */ function zbase_url_from_route($name, $params = [], $relative = false) { if (!\Route::has($name)) { return '#'; } $routes = zbase_config_get('routes'); $prefix = ''; $name = str_replace('admin.', zbase_admin_key() . '.', $name); $name = str_replace('admin', zbase_admin_key(), $name); $usernameRouteEnabled = zbase_route_username(); if (isset($routes[$name]['usernameroute'])) { if ($routes[$name]['usernameroute'] === false) { $usernameRouteEnabled = false; } } if (!empty($usernameRouteEnabled)) { $usernameRouteParameterName = zbase_route_username_prefix(); $usernameRoute = zbase_route_username_get(); $username = zbase_route_input(zbase_route_username_prefix(), false); if (!empty($username)) { $username = strtolower($username); $user = zbase_user_by('username', $username); if ($user instanceof \Zbase\Entity\Laravel\User\User && $user->hasUrl()) { $usernameRoute = true; } } if (empty($usernameRoute) && zbase_auth_has() && zbase_is_back()) { $username = zbase_auth_user()->username(); $usernameRoute = true; } if (!empty($usernameRoute)) { $prefix = $usernameRouteParameterName; if (empty($params[$usernameRouteParameterName])) { $params[$usernameRouteParameterName] = $username; } } } $name = $prefix . $name; if (!empty($relative)) { $home = route('index'); $url = str_replace($home, '', route($name, $params)); } else { $url = route($name, $params); } if ($usernameRouteEnabled && !empty($usernameRoute)) { $url = str_replace($usernameRoute . '/' . $usernameRoute, '/' . $usernameRoute . '/', $url); } return $url; }
<?php /** * Dx * * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Mar 5, 2016 11:51:42 PM * @file dsstore/module.php * */ return ['id' => 'system', 'enable' => true, 'access' => 'only::sudo', 'class' => null, 'backend' => true, 'frontend' => false, 'url' => ['backend' => 'system/{action?}/{id?}/{task?}'], 'navigation' => ['back' => ['enable' => true, 'nav' => ['order' => 9998, 'route' => ['name' => 'admin.dsorders'], 'icon' => 'fa fa-gears', 'label' => 'System', 'title' => 'System', 'children' => [['route' => ['name' => 'admin.system', 'params' => ['action' => 'maintenance']], 'icon' => 'fa fa-flash', 'label' => 'Maintenance', 'title' => 'Maintenance'], ['route' => ['name' => 'admin.system', 'params' => ['action' => 'telegram']], 'icon' => 'fa fa-flash', 'label' => 'Telegram', 'title' => 'Telegram']]]]], 'controller' => ['back' => ['action' => ['telegram' => ['page' => ['title' => 'Telegram Integration', 'headTitle' => 'Telegram Integration', 'subTitle' => '', 'breadcrumbs' => [['label' => 'Telegram Integration']]]], 'maintenance' => ['page' => ['title' => 'System Maintenance', 'headTitle' => 'System Maintenance', 'subTitle' => '', 'breadcrumbs' => [['label' => 'System Maintenance']]]], 'maintenance-mode-on' => ['page' => ['title' => 'System Maintenance - WEBSITE IN MAINTENANCE MODE!', 'headTitle' => 'System Maintenance', 'subTitle' => '', 'breadcrumbs' => [['label' => 'System Maintenance']]]], 'maintenance-mode-off' => ['page' => ['title' => 'System Maintenance', 'headTitle' => 'System Maintenance', 'subTitle' => '', 'breadcrumbs' => [['label' => 'System Maintenance']]]]]]], 'routes' => [], 'widgets' => ['back' => ['controller' => ['action' => ['maintenance' => ['system-maintenance-form' => null], 'telegram' => ['telegram-settings-form' => null], 'telegram-disable' => function () { zbase()->telegram()->disableUserTelegram(zbase_auth_user()); return redirect()->to(zbase_url_previous()); }, 'post-telegram' => function () { zbase()->telegram()->saveSettings(zbase_request_inputs()); return ['telegram-settings-form' => null]; }, 'post-maintenance' => function () { zbase()->system()->scheduleDowntime(zbase_request_inputs()); return ['system-maintenance-form' => null]; }, 'maintenance-mode-on' => function () { zbase()->system()->startMaintenance(); return redirect()->to(zbase_url_previous()); }, 'maintenance-mode-off' => function () { zbase()->system()->stopMaintenance(); return redirect()->to(zbase_url_previous()); }]]]]];
/** * Check if current user has access * * @return boolean */ public function postUserHasAccess(User $user = null) { if (method_exists($this, 'userHasAccess')) { return $this->userHasAccess($user); } $user = !empty($user) ? $user : zbase_auth_user(); if ($user->id() == $this->postOwnerId()) { return true; } if ($user->isAdmin()) { return true; } return true; }
<br /> <br /> <br /> MESSAGE: ------------------- <br /> <?php echo $message; } ?> <br /> <br /> <br /> --- DETAILS: <?php $error = 'Date: ' . zbase_date_now()->format('Y-m-d h:i:s A') . "<br />"; $error .= 'URL: ' . zbase_url_uri() . "<br />"; $error .= 'Is Posting: ' . (zbase_request_is_post() ? 'Yes' : 'No') . "<br />"; $error .= 'Is AJAX: ' . (zbase_request_is_ajax() ? 'Yes' : 'No') . "<br />"; $error .= 'Data: ' . json_encode(zbase_request_inputs()) . "<br />"; $error .= 'Routes: ' . json_encode(zbase_route_inputs()) . "<br />"; $error .= 'IP Address: ' . zbase_ip() . "<br /><br /"; if (zbase_auth_has()) { $user = zbase_auth_user(); $error .= 'User: '******' ' . $user->username() . '[' . $user->id() . ']' . "<br />"; } echo $error; ?> <?php echo zbase_view_render(zbase_view_file_contents('email.footer'));
/** * 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)); } }
$adminView = true; $moduleName = 'admin-user'; $selectedUser = zbase_user_byid(zbase_route_input('id')); if (!$selectedUser instanceof \Zbase\Entity\Laravel\User\User) { zbase_abort(404); exit; } $page = []; $page['title'] = '<span class="userDisplayName' . $selectedUser->id() . '">' . $selectedUser->roleTitle() . ' - ' . $selectedUser->id() . ': ' . $selectedUser->displayName() . '</span>' . $selectedUser->statusText(); $page['headTitle'] = $selectedUser->displayName(); $page['subTitle'] = $selectedUser->email() . '|' . $selectedUser->username() . '|' . $selectedUser->cityStateCountry(); zbase_view_page_details(['page' => $page]); $breadcrumbs = [['label' => 'Users', 'route' => ['name' => 'admin.users']], ['label' => '<span class="userDisplayName' . $selectedUser->id() . '">' . $selectedUser->displayName() . '</span>', 'link' => '#', 'title' => $selectedUser->displayName()]]; zbase_view_breadcrumb($breadcrumbs); } else { $selectedUser = zbase_auth_user(); } $accountTabs = []; $accountContents = []; $accountContents[] = ['position' => 10, 'groupId' => 'information', 'content' => function () use($selectedUser) { return zbase_view_render(zbase_view_file_module('account.views.information', 'account', 'zbase'), ['user' => $selectedUser]); }]; $accountContents[] = ['position' => 10, 'groupId' => 'notification', 'content' => function () use($selectedUser) { return zbase_view_render(zbase_view_file_module('account.views.notifications', 'account', 'zbase'), ['user' => $selectedUser]); }]; $accountContents = zbase_module_widget_contents('account', 'account', zbase_section(), $adminView, null, $accountContents); $accountTabs = zbase_module_widget_contents('account', 'account', zbase_section(), $adminView, 'tabs'); $widgetConfig = ['config' => ['entity' => ['entity' => $selectedUser]]]; ?> <div class="zbase-ui-wrapper zbase-ui-tabs" id="zbase-ui-tabs-accounttabs"> <ul class="nav nav-tabs">
/** * Filter Query * @param array $filters Array of Filters * @param array $sorting Array of Sorting * @param array $options some options * @return array */ public function queryFilters($filters, $sorting = [], $options = []) { $queryFilters = []; if (!empty($filters)) { /** * run through a given filters, possibly valid query filters */ if (!empty($filters)) { foreach ($filters as $fK => $fV) { if (!empty($fV['eq']) && !empty($fV['eq']['field']) && !empty($fV['eq']['value'])) { if (!preg_match('/' . static::$nodeNamePrefix . '\\./', $fV['eq']['field'])) { $fV['eq']['field'] = static::$nodeNamePrefix . '.' . $fV['eq']['field']; } $queryFilters[$fK] = $fV; } } } $isPublic = !empty($filters['public']) ? true : false; if (!empty($isPublic)) { $queryFilters['status'] = ['eq' => ['field' => static::$nodeNamePrefix . '.status', 'value' => 2]]; } $currentUser = !empty($filters['currentUser']) ? true : false; if (!empty($currentUser)) { $queryFilters['user'] = ['eq' => ['field' => static::$nodeNamePrefix . '.user_id', 'value' => zbase_auth_user()->id()]]; } if (!empty($filters['category'])) { $categoryObject = zbase_entity(static::$nodeNamePrefix . '_category', [], true); /** * We have category as a filter, * Then search for the selected category * @var strings[]|integers[]|EntityInterface[] */ $filterCategories = $filters['category']; /** * We need category Ids To be able to do a cross-table-pivot search * Examine the given filter if its an array of strings or integers or just a string or an integer */ $filterCategoryIds = []; if (is_array($filterCategories)) { foreach ($filterCategories as $filterCategory) { if (!$filterCategory instanceof Interfaces\EntityInterface) { $filterCategory = $categoryObject::searchCategory(trim($filterCategory), $isPublic); } if ($filterCategory instanceof Interfaces\EntityInterface && !$filterCategory->isRoot()) { $filterCategoryIds[] = $filterCategory->id(); continue; } } } else { $filterCategory = $categoryObject::searchCategory(trim($filterCategories), $isPublic); if ($filterCategory instanceof Interfaces\EntityInterface && !$filterCategory->isRoot()) { $filterCategoryIds[] = $filterCategory->id(); } } if (!empty($filterCategoryIds)) { $queryFilters['pivot.category_id'] = ['in' => ['field' => 'pivot.category_id', 'values' => $filterCategoryIds]]; } unset($filters['category']); } if (!empty($this->filterableColumns)) { $processedFilters = []; foreach ($filters as $filterName => $filterValue) { if (empty($filterValue)) { continue; } if (in_array($filterName, $processedFilters)) { continue; } if (array_key_exists($filterName, $this->filterableColumns)) { $column = $this->filterableColumns[$filterName]['column']; $filterType = $this->filterableColumns[$filterName]['filterType']; $options = $this->filterableColumns[$filterName]['options']; $columnType = $this->filterableColumns[$filterName]['type']; if ($filterType == 'between') { $startValue = $filterValue; $endValue = null; if (preg_match('/\\:/', $filterType)) { $filterTypeEx = explode(':', $filterType); if (!empty($filterTypeEx[1])) { $endFilterName = $filterTypeEx[1]; $processedFilters[] = $endFilterName; if (!empty($filters[$endFilterName])) { $endValue = $filters[$endFilterName]; } } } if ($columnType == 'timestamp') { $timestampFormat = zbase_data_get($options, 'timestamp.format', 'Y-m-d'); $startValue = zbase_date_from_format($timestampFormat, $startValue); if ($startValue instanceof \DateTime) { $startValue->hour = 0; $startValue->minute = 0; $startValue->second = 0; } if (empty($endValue)) { $endValue = clone $startValue; $endValue->hour = 23; $endValue->minute = 59; $endValue->second = 59; } else { $endValue = zbase_date_from_format($timestampFormat, $endValue); } /** * Argument is the other end of the between */ $queryFilters[$filterName] = [$filterType => ['field' => static::$nodeNamePrefix . '.' . $column, 'from' => $startValue->format(DATE_FORMAT_DB), 'to' => $endValue->format(DATE_FORMAT_DB)]]; } } else { $queryFilters[$filterName] = [$filterType => ['field' => static::$nodeNamePrefix . '.' . $column, 'value' => $filterValue]]; } $processedFilters[] = $filterName; } } } } return $queryFilters; }
/** * First step in updating email address. * - Code will be sent to the old email address with a verification code * @param string $newEmailAddress * @return boolean */ public function updateRequestEmailAddress($newEmailAddress) { if (!empty($newEmailAddress) && $this->email() != $newEmailAddress) { zbase_db_transaction_start(); try { /** * Admin is changing the email Address */ if (zbase_auth_user()->id() != $this->id() && zbase_auth_user()->isAdmin()) { /** * Send a request code to the old email address * option: email_verification_code: code; new_email: $newEmail Address */ $oldEmail = $this->email(); $this->email = $newEmailAddress; $this->email_verified = 0; $this->save(); zbase_alert('info', _zt($this->displayFullDetails() . ' email address was updated to <strong>%email%</strong> from <strong>' . $oldEmail . '</strong>.', ['%email%' => $this->email()])); $this->log('user::updateRequestEmailAddress', null, ['new_email' => $newEmailAddress, 'admin_id' => zbase_auth_user()->id()]); } else { /** * Send a request code to the old email address * option: email_verification_code: code; new_email: $newEmail Address */ $code = zbase_generate_code(); $this->setDataOption('email_updaterequest_code', $code); $this->setDataOption('email_new', $newEmailAddress); $this->setDataOption('email_new_request_date', zbase_date_now()); $this->save(); $url = zbase_url_from_route('update-email-request', ['email' => $this->email(), 'token' => $code]); $urlText = null; if (zbase_is_dev()) { $urlText = '<a href="' . $url . '">' . $url . '</a>'; zbase()->json()->setVariable('updateRequestEmailAddress', $url); } zbase_alert('info', _zt('We sent an email to %email% with a link to complete the process of updating your email address.' . $urlText, ['%email%' => $this->email()])); zbase_messenger_email($this->email(), 'account-noreply', _zt('New Email address update request'), zbase_view_file_contents('email.account.newEmailAddressRequest'), ['entity' => $this, 'newEmailAddress' => $newEmailAddress, 'code' => $code, 'url' => $url]); $this->log('user::updateRequestEmailAddress', null, ['new_email' => $newEmailAddress]); } zbase_db_transaction_commit(); return true; } catch (\Zbase\Exceptions\RuntimeException $e) { zbase_db_transaction_rollback(); return false; } } else { zbase_alert('info', _zt('We sent an email to %email% with a link to complete the process of updating your email address.', ['%email%' => $this->email()])); } }
<?php /** * Dx * * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Mar 8, 2016 10:37:59 AM * @file widget.php * @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.account.widgets.notifications.enable', true); }, 'config' => ['entity' => ['name' => 'user', 'method' => 'currentUser', 'repo' => ['method' => 'currentUser']], 'event' => ['email' => ['post' => ['redirect' => ['enable' => false]]]], 'form' => ['startTag' => ['action' => function () { if (zbase_is_back()) { return zbase_url_from_route('admin.account', ['action' => 'email']); } }, '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.']]]]]];
* Dx * * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Aug 23, 2016 5:57:34 PM * @file telegram-user.blade.php * @project Zbase * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php. */ $user = zbase_auth_user(); $hasTelegram = zbase()->telegram()->checkUserTelegram(zbase_auth_user()); if (empty($hasTelegram)) { $codeCheck = zbase()->telegram()->checkUserCode(zbase_auth_user()); } $telegramBot = zbase()->telegram()->botusername(); $code = zbase()->telegram()->userCode($user); ?> <div class="col-md-12"> <h2>Receive Real-Time Updates and Notifications via Telegram</h2> <hr /> <h3>What is Telegram?</h3> <p>Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.</p> <p>Download and install telegram here: <a href="https://telegram.org/" target="_blank">https://telegram.org/</a></p> <hr /> <?php if (empty($hasTelegram)) { ?> <p>
/** * Return the entity * @return Zbase\Widget\EntityInterface */ public function entity() { if (empty($this->hasEntity())) { return false; } if (is_null($this->_entity)) { $entityName = $this->_v('entity.name', null); if (!empty($this->_nodeSupport)) { $entityName = $this->getNodeNamespace() . '_' . strtolower($this->_nodeName); } if (!is_null($entityName)) { $entity = $this->_v('entity.entity', null); if ($entity instanceof \Zbase\Entity\Laravel\Entity) { $this->_entityObject = zbase()->entity($entityName, [], true); $this->_entity = $entity; return $this->_entity; } if ($entity instanceof \Zbase\Post\PostInterface) { $this->_entityObject = $entity; $this->_entity = $entity; return $this->_entity; } $this->_entity = $this->_entityObject = $entity = zbase()->entity($entityName, [], true); $repoById = $this->_v('entity.repo.byId', null); $repoByFilter = $this->_v('entity.repo.byFilter', null); if (is_null($repoById)) { $repoById = $this->_v('entity.repo.byAlphaId', null); if (!empty($repoById)) { $byAlpha = true; } else { $repoById = $this->_v('entity.repo.bySlug', null); if (!empty($repoById)) { $bySlug = true; } } } if (is_array($repoById)) { if (!empty($repoById['route'])) { $id = zbase_route_input($repoById['route']); } if ($this->isNodeCategoryBrowsing()) { $repoItemBySlug = $this->_v('entity.repo.item.bySlug', null); $repoItemByAlpha = $this->_v('entity.repo.item.byAlpha', null); $repoItemById = $this->_v('entity.repo.item.byId', null); /** * Browse by category * /CategorySlug/ - should show all category items * /CategorySlug/ItemName - show item * * Module should have a "default" entry as the wildcard catchAll action */ if (!empty($repoItemByAlpha)) { $itemRouteParameterName = $this->_v('entity.repo.item.byAlpha.route', null); $childAlphaId = zbase_route_input($itemRouteParameterName); if (!empty($childAlphaId)) { $this->_childEntity = zbase()->entity($this->nodePrefix(), [], true)->repository()->byAlphaId($childAlphaId); if (!$this->_childEntity instanceof \Zbase\Entity\Laravel\Node\Node) { $this->setViewFile(zbase_view_file_contents('errors.404')); return zbase_abort(404); } } } if (!empty($repoItemBySlug)) { $itemRouteParameterName = $this->_v('entity.repo.item.bySlug.route', null); $childAlphaId = zbase_route_input($itemRouteParameterName); if (!empty($childAlphaId)) { $this->_childEntity = zbase()->entity($this->nodePrefix(), [], true)->repository()->bySlug($childAlphaId); if (!$this->_childEntity instanceof \Zbase\Entity\Laravel\Node\Node) { $this->setViewFile(zbase_view_file_contents('errors.404')); return zbase_abort(404); } } } if (!empty($repoItemById)) { $itemRouteParameterName = $this->_v('entity.repo.item.byId.route', null); $childAlphaId = zbase_route_input($itemRouteParameterName); if (!empty($childAlphaId)) { $this->_childEntity = zbase()->entity($this->nodePrefix(), [], true)->repository()->byId($childAlphaId); if (!$this->_childEntity instanceof \Zbase\Entity\Laravel\Node\Node) { $this->setViewFile(zbase_view_file_contents('errors.404')); return zbase_abort(404); } } } } if (!empty($repoById['request']) && zbase_is_post() == 'post') { $id = zbase_request_input($repoById['request']); } if (!empty($id)) { $filters = $this->_v('entity.filter.query', []); $sorting = $this->_v('entity.sorting.query', []); $selects = ['*']; $joins = []; $this->_urlHasRequest = true; if ($this->isNode()) { zbase()->json()->addVariable('id', $id); if (!empty($repoById) && !empty($id) && empty($byAlpha) && empty($bySlug)) { $filters['id'] = ['eq' => ['field' => $entity->getKeyName(), 'value' => $id]]; } if ($this->isCurrentUser()) { $filters['user'] = ['eq' => ['field' => 'user_id', 'value' => zbase_auth_user()->id()]]; } if ($this->isPublic()) { $filters['status'] = ['eq' => ['field' => 'status', 'value' => 2]]; } if (!empty($byAlpha)) { $filters['alpha'] = ['eq' => ['field' => 'alpha_id', 'value' => $id]]; } if (!empty($bySlug)) { $filters['slug'] = ['eq' => ['field' => 'slug', 'value' => $id]]; } if (method_exists($entity, 'querySelects')) { $selects = $entity->querySelects($filters, ['widget' => $this]); } if (method_exists($entity, 'queryJoins')) { $joins = $entity->queryJoins($filters, $this->getRequestSorting(), ['widget' => $this]); } if (method_exists($entity, 'querySorting')) { $sorting = $entity->querySorting($sorting, $filters, ['widget' => $this]); } if (method_exists($entity, 'queryFilters')) { $filters = $entity->queryFilters($filters, $sorting, ['widget' => $this]); } /** * Merge filters from widget configuration * entity.filter.query */ $filters = array_merge($filters, $this->_v('entity.filter.query', [])); $sorting = array_merge($sorting, $this->_v('entity.sorting.query', [])); $action = $this->getAction(); $debug = zbase_request_query_input('__widgetEntityDebug', false); if ($this->isAdmin()) { if ($action == 'restore' || $action == 'ddelete') { return $this->_entity = $entity->repository()->onlyTrashed()->all($selects, $filters, $sorting, $joins)->first(); } } else { if ($entity->hasSoftDelete() && $this->isCurrentUser()) { if ($action == 'restore' || $action == 'ddelete') { return $this->_entity = $entity->repository()->onlyTrashed()->all($selects, $filters, $sorting, $joins)->first(); } return $this->_entity = $entity->repository()->setDebug($debug)->withTrashed()->all($selects, $filters, $sorting, $joins)->first(); } } return $this->_entity = $entity->repository()->setDebug($debug)->all($selects, $filters, $sorting, $joins)->first(); } } } else { if (!empty($repoByFilter)) { $filters = []; $sorting = []; $selects = ['*']; $joins = []; $singleRow = $this->_v('entity.singlerow', true); if ($this->isCurrentUser()) { $filters['user'] = ['eq' => ['field' => 'user_id', 'value' => zbase_auth_user()->id()]]; } if ($this->isPublic()) { $filters['status'] = ['eq' => ['field' => 'status', 'value' => 2]]; } $filters = array_merge($filters, $this->_v('entity.filter.query', [])); $sorting = array_merge($sorting, $this->_v('entity.sorting.query', [])); if (!empty($singleRow)) { return $this->_entity = $entity->repository()->all($selects, $filters, $sorting, $joins)->first(); } else { return $this->_entity = $entity->repository()->all($selects, $filters, $sorting, $joins); } } } $repoMethod = $this->_v('entity.method', null); if (!is_null($repoMethod)) { return $this->_entity = $this->_entityObject->{$repoMethod}(); } $this->_entityIsDefault = true; return $this->_entity = $this->_entityObject; } } return $this->_entity; }
public function boot() { parent::boot(); $this->loadViewsFrom(__DIR__ . '/../resources/views', zbase_tag()); $this->loadViewsFrom(__DIR__ . '/../modules', zbase_tag() . 'modules'); if (!zbase_is_testing()) { $this->mergeConfigFrom(__DIR__ . '/../config/config.php', zbase_tag()); $packages = zbase()->packages(); if (!empty($packages)) { foreach ($packages as $packageName) { $packagePath = zbase_package($packageName)->path(); $this->loadViewsFrom($packagePath . 'modules', $packageName . 'modules'); if (zbase_file_exists($packagePath . 'resources/views')) { $this->loadViewsFrom($packagePath . 'resources/views', $packageName); } if (zbase_file_exists($packagePath . 'resources/assets')) { $this->publishes([$packagePath . 'resources/assets' => zbase_public_path(zbase_path_asset($packageName))], 'public'); } if (zbase_file_exists($packagePath . '/Http/Controllers/Laravel/routes.php')) { require $packagePath . '/Http/Controllers/Laravel/routes.php'; } } } $this->app['config'][zbase_tag()] = array_replace_recursive($this->app['config'][zbase_tag()], zbase()->getPackagesMergedConfigs()); } else { $this->loadViewsFrom(__DIR__ . '/../tests/resources/views', zbase_tag() . 'test'); copy(__DIR__ . '/../config/entities/user.php', __DIR__ . '/../tests/config/entities/user.php'); $this->mergeConfigFrom(__DIR__ . '/../tests/config/config.php', zbase_tag()); } $this->publishes([__DIR__ . '/../resources/assets' => zbase_public_path(zbase_path_asset())], 'public'); $this->publishes([__DIR__ . '/../database/migrations' => base_path('database/migrations'), __DIR__ . '/../database/seeds' => base_path('database/seeds'), __DIR__ . '/../database/factories' => base_path('database/factories')], 'migrations'); $this->app['config']['database.connections.mysql.prefix'] = zbase_db_prefix(); $this->app['config']['auth.providers.users.model'] = get_class(zbase_entity('user')); $this->app['config']['auth.passwords.users.table'] = zbase_config_get('entity.user_tokens.table.name'); $this->app['config']['auth.passwords.users.email'] = zbase_view_file_contents('auth.password.email.password'); require __DIR__ . '/Http/Controllers/Laravel/routes.php'; zbase()->prepareWidgets(); /** * Validator to check for account password * @TODO should be placed somewhere else other than here, and just call */ \Validator::extend('accountPassword', function ($attribute, $value, $parameters, $validator) { if (zbase_auth_has()) { $user = zbase_auth_user(); if (zbase_bcrypt_check($value, $user->password)) { return true; } } return false; }); \Validator::replacer('accountPassword', function ($message, $attribute, $rule, $parameters) { return _zt('Account password don\'t match.'); }); /** * */ \Validator::extend('passwordStrengthCheck', function ($attribute, $value, $parameters, $validator) { // if(!preg_match("#[0-9]+#", $value)) // { // //$errors[] = "Password must include at least one number!"; // return false; // } // // if(!preg_match("#[a-zA-Z]+#", $value)) // { // //$errors[] = "Password must include at least one letter!"; // return false; // } return true; }); \Validator::replacer('passwordStrengthCheck', function ($message, $attribute, $rule, $parameters) { return _zt('New password is too weak.'); }); // dd(zbase_config_get('email.account-noreply.email')); // dd(\Zbase\Utility\Service\Flickr::findByTags(['heavy equipment','dozers','loader'])); }
<?php if (zbase()->telegram()->isEnabled()) { ?> <?php $hasTelegram = zbase()->telegram()->checkUserTelegram(zbase_auth_user()); ?> <?php if (empty($hasTelegram)) { ?> <?php } }
</span> ' . $notification->displayMessage() . ' <span class="time"> ' . $notification->displayTime() . ' </span> </a> </li>'; } return $string; } return null; }]]], 'controller' => ['back' => ['action' => ['index' => ['page' => ['title' => 'Notifications', 'headTitle' => 'Notifications', 'subTitle' => '', 'breadcrumbs' => [['label' => 'Notifications']]]]]]], 'routes' => [], 'widgets' => ['back' => ['controller' => ['action' => ['index' => ['notifications-list' => null], 'json-seen' => ['notifications-list' => function () { zbase_auth_user()->notificationSeen(); return null; }], 'json-fetch' => ['notifications-fetch' => function () { $notifications = zbase_auth_user()->notificationsNotNotified(); if (!empty($notifications)) { $string = null; foreach ($notifications as $notification) { $string .= '<li data-id="' . $notification->id() . '" id="notifications-list-' . $notification->id() . '"> <a href="' . $notification->url() . '"> <span class="label label-sm label-icon label-' . $notification->displayColor() . '"> <i class="fa ' . $notification->displayIcon() . '"></i> </span> ' . $notification->displayMessage() . ' <span class="time"> ' . $notification->displayTime() . ' </span> </a> </li>'; }
/** * Filter Query * @param array $filters Array of Filters * @param array $sorting Array of Sorting * @param array $options some options * @return array */ public function queryFilters($filters, $sorting = [], $options = []) { $queryFilters = []; if (!empty($filters)) { if (!empty($filters['alpha'])) { $queryFilters['alpha'] = ['eq' => ['field' => 'messages_recipient.alpha_id', 'value' => $filters['alpha']['eq']['value']]]; } $isPublic = !empty($filters['public']) ? true : false; if (!empty($isPublic)) { $queryFilters['status'] = ['eq' => ['field' => 'messages_recipient.status', 'value' => 2]]; } $currentUser = !empty($filters['currentUser']) ? true : false; if (!empty($currentUser)) { $queryFilters['user'] = ['eq' => ['field' => 'messages_recipient.user_id', 'value' => zbase_auth_user()->id()]]; } } return $queryFilters; }
/** * Dx * * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Aug 23, 2016 4:12:15 PM * @file accountinfo.blade.php * @project ZbaseAgse * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php. */ $addressCoverage = null; $roleTitle = $user->roleTitle(); $isAdmin = zbase_auth_user()->isAdmin(); $contents = []; $contents[] = ['position' => 10, 'content' => function () use($user) { return zbase_view_render(zbase_view_file_module('account.views.accountInformation', 'account', 'zbase'), ['user' => $user]); }]; $contents = zbase_module_widget_contents('account', 'account', zbase_section(), $isAdmin, 'informationInner', $contents); ?> <div class="row"> <div class="col-md-2"> <img class="img-responsive thumbnail" src="<?php echo $user->avatarUrl(); ?> " alt="<?php echo $user->displayName(); ?> ">
/** * Return the Current User * @return aray */ public static function current() { if (zbase_auth_has()) { return ['user' => self::userApi(static::findUserById(zbase_auth_user()->id(), true))]; } return []; }
/** * Prepare Repository */ protected function _repo() { if (!empty($this->_entity)) { // <editor-fold defaultstate="collapsed" desc="PostInterface"> /** * PostInterface * August 26, 2016 */ if ($this->_entity instanceof \Zbase\Post\PostInterface) { $entityObject = $this->entityObject(); $entity = $this->_entity; $entityName = $entity->postTableName(); $perPage = $entity->postRowsPerPage(); $filters = []; $sorting = []; $joins = []; $urlFilters = []; $selects = ['*']; if ($entity instanceof \Illuminate\Database\Eloquent\Collection) { $entity = $this->_entity->first(); if ($entity instanceof \Zbase\Interfaces\EntityInterface) { $perPage = $entity->postRowsPerPage(); } } $this->_repoPerPage = zbase_request_query_input('pp', $perPage); if ($this->isExporting()) { $this->_repoPerPage = 9999999; } $repo = $entityObject->repository(); if ($this->isNode()) { /** * Filters from the URL */ $urlFilters = $this->getRequestFilters(); if ($this->isNodeCategory() && $entity instanceof \Zbase\Entity\Laravel\Node\Nested) { /** * We are getting the nodes on each category * switch to node entityObject */ $entityObject = zbase_entity($entityName . '_category', [], true); $repo = $entityObject->repository(); $categories = $entity->getDescendantsAndSelf(); if (!empty($categories)) { foreach ($categories as $category) { $urlFilters['category'][] = $category; } } } if ($this->isPublic()) { $urlFilters['public'] = true; } if ($this->isCurrentUser()) { $urlFilters['currentUser'] = true; } $filters = $entityObject->postDatatableQueryFilters($urlFilters, $this); $selects = $entityObject->postDatatableQuerySelects($this); $joins = $entityObject->postDatatableQueryJoins($this); $sorting = $entityObject->postDatatableQuerySorting($this->getRequestSorting(), $this); /** * Merge filters from widget configuration * entity.filter.query */ if (!empty($filters)) { $filters = array_merge($filters, $this->_v('entity.filter.query', [])); } else { $widgetFilter = $this->_v('entity.filter.query', false); if (!empty($widgetFilter)) { $filters = $widgetFilter; } } } $this->_repoSelects = $selects; $this->_repoJoins = $joins; $this->_repoSorts = $sorting; $this->_repoFilters = $filters; $this->_repo = $repo; return $this->_repo; } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="EntityInterface"> /** * Will be deprecated in favor of PostInterface */ $entityObject = $this->entityObject(); $entity = $this->_entity; $perPage = 10; if ($entity instanceof \Illuminate\Database\Eloquent\Collection) { $entity = $this->_entity->first(); if ($entity instanceof \Zbase\Interfaces\EntityInterface) { $perPage = $entity->getPerPage(); } } $this->_repoPerPage = zbase_request_query_input('pp', $this->_v('row.perpage', $perPage)); if ($this->isExporting()) { $this->_repoPerPage = 99999999999; } $repo = $entityObject->repository()->perPage($this->_repoPerPage); $filters = []; $sorting = []; $joins = []; $selects = ['*']; if ($this->isNode()) { $urlFilters = $this->getRequestFilters(); if ($this->isNodeCategory() && $entity instanceof \Zbase\Entity\Laravel\Node\Nested) { /** * We are getting the nodes on each category * switch to node entityObject */ $entityObject = zbase_entity($entityObject::$nodeNamePrefix, [], true); $repo = $entityObject->repository()->perPage(zbase_request_query_input('pp', $this->_v('row.perpage', $perPage))); $categories = $this->_entity->getDescendantsAndSelf(); if (!empty($categories)) { foreach ($categories as $category) { $urlFilters['category'][] = $category; } } } if ($this->isPublic()) { $urlFilters['public'] = true; } if ($this->isCurrentUser()) { $urlFilters['currentUser'] = true; } if (!empty($urlFilters)) { if (method_exists($entityObject, 'queryFilters')) { $filters = $entityObject->queryFilters($urlFilters, $this->getRequestSorting(), ['widget' => $this]); } else { if (!empty($urlFilters['public'])) { $filters['status'] = 2; } if (!empty($urlFilters['currentUser'])) { $filters['user_id'] = zbase_auth_user()->id(); } } } else { if (method_exists($entityObject, 'queryFilters')) { $filters = $entityObject->queryFilters($urlFilters, $this->getRequestSorting(), ['widget' => $this]); } } if (method_exists($entityObject, 'querySelects')) { $selects = $entityObject->querySelects($urlFilters, ['widget' => $this]); } if (method_exists($entityObject, 'queryJoins')) { $joins = $entityObject->queryJoins($urlFilters, $this->getRequestSorting(), ['widget' => $this]); } if (method_exists($entityObject, 'querySorting')) { $sorting = $entityObject->querySorting($this->getRequestSorting(), $urlFilters, ['widget' => $this]); } /** * Merge filters from widget configuration * entity.filter.query */ if (!empty($filters)) { $filters = array_merge($filters, $this->_v('entity.filter.query', [])); } else { $widgetFilter = $this->_v('entity.filter.query', false); if (!empty($widgetFilter)) { $filters = $widgetFilter; } } if ($this->isExporting()) { if (method_exists($entityObject, 'queryExportFilters')) { $filters = $entityObject->queryExportFilters($filters, ['widget' => $this]); } } if ($this->isSearchable() && $this->isSearching()) { if (method_exists($entityObject, 'querySearchFilters')) { $filters = $entityObject->querySearchFilters($filters, ['widget' => $this]); } } // dd($joins, $sorting, $filters); } $this->_repoSelects = $selects; $this->_repoJoins = $joins; $this->_repoSorts = $sorting; $this->_repoFilters = $filters; $debug = zbase_request_query_input($this->id() . '__debug', false); $repo->setDebug($debug); $repo->setQueryName($this->getWidgetPrefix('Repo')); $this->_repo = $repo; return $this->_repo; // </editor-fold> } }
/** * Render HTML before </body> * * @return string */ function zbase_view_render_body() { $str = ''; zbase()->view()->prepare(); $onloadScripts = zbase_view_placeholder_render('body_scripts_onload'); $str .= zbase_view_placeholder_render('body_javascripts'); $str .= zbase_view_placeholder_render('body_footer_html'); $str .= EOF . '<script type="text/javascript">'; $str .= EOF . zbase_view_compile(zbase_view_placeholder_render('body_scripts')); if (!empty(zbase_auth_is_duplex())) { $onloadScripts .= 'jQuery(\'body\').append(\'<div style="margin:0px auto;z-index:999999;background:yellow;width: auto;position:absolute;top:0px;padding:5px;margin-top:2px;margin-left:2px;">You are loggedin as: ' . zbase_auth_user()->displayFullDetails() . ' <a class="btn btn-danger btn-sm" href="' . zbase_url_from_route('admin.duplex', ['action' => 'unduplex']) . '">SignOut</a></div>\');'; } if (!empty($onloadScripts)) { $str .= EOF . 'jQuery(document).ready(function(){' . EOF . $onloadScripts . EOF . '});'; } $str .= EOF . '</script>'; return $str; }
* * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Mar 8, 2016 10:37:59 AM * @file widget.php * @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.account.widgets.username.enable', true); }, 'config' => ['entity' => ['name' => 'user', 'node' => ['enable' => true], 'repo' => ['byId' => ['route' => 'id']]], 'event' => ['username' => ['post' => ['redirect' => ['enable' => false]]]], 'submit' => ['button' => ['label' => 'Update Username']], 'form' => ['startTag' => ['action' => function () { return zbase_url_from_route('admin.users', ['action' => 'username', 'id' => zbase_route_input('id')]); }, '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.']]]]]];
<?php /** * Dx * * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Aug 23, 2016 6:00:01 PM * @file notifications.blade.php * @project Zbase * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php. */ if (zbase()->telegram()->isEnabled() && zbase_config_get('modules.account.widgets.account.tab.telegram', true)) { ?> <?php echo zbase_view_render(zbase_view_file_module('account.views.telegram-user', 'account', 'zbase'), ['user' => zbase_auth_user()]); }
echo zbase_view_render(zbase_view_file('partial.notification-bar')); ?> <!-- BEGIN USER LOGIN DROPDOWN --> <?php if (zbase_auth_has()) { ?> <li class="dropdown user"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <img style="width:28px;" alt="" src="<?php echo zbase_auth_user()->avatarUrl(['w' => 30]); ?> "/> <span class="username"> <?php echo zbase_auth_user()->displayName(); ?> </span> <i class="fa fa-angle-down"></i> </a> <ul class="dropdown-menu"> <?php $headerPullDownMenu = zbase_config_get('theme'); ?> <li> <a href="<?php echo zbase_url_from_route('account'); ?> "> <i class="fa fa-user"></i> My Profile </a>
/** * Receive the File/Image * * @param \Zbase\Entity\Laravel\Entity $parentObject The Parent */ public function receiveFile(\Zbase\Entity\Laravel\Entity $parentObject) { try { $index = 'file'; $entityName = $this->entityName; $defaultImageFormat = zbase_config_get('node.files.image.format', 'png'); $folder = zbase_storage_path() . '/' . zbase_tag() . '/' . $this->actionUrlRouteName() . '/' . $parentObject->id() . '/'; zbase_directory_check($folder, true); $nodeFileObject = zbase_entity($entityName, [], true); $nodeFiles = $parentObject->childrenFiles(); if (preg_match('/http\\:/', $index) || preg_match('/https\\:/', $index)) { // File given is a URL if ($nodeFileObject->isUrlToFile()) { $filename = zbase_file_name_from_file(basename($index), time(), true); $uploadedFile = zbase_file_download_from_url($index, $folder . $filename); } else { $this->is_primary = empty($nodeFiles) ? 1 : 0; $this->status = 2; $this->mimetype = null; $this->size = null; $this->filename = null; $this->url = $index; $this->{$this->parentObjectIndexId} = $parentObject->id(); $this->user_id = zbase_auth_has() ? zbase_auth_user()->id() : null; $this->save(); return true; } } if (zbase_file_exists($index)) { $uploadedFile = $index; $filename = basename($index); } if (!empty($_FILES[$index]['name'])) { $filename = zbase_file_name_from_file($_FILES[$index]['name'], time(), true); $uploadedFile = zbase_file_upload_image($index, $folder, $filename, $defaultImageFormat); } if (!empty($uploadedFile) && zbase_file_exists($uploadedFile)) { $this->is_primary = empty($nodeFiles) ? 1 : 0; $this->status = 2; $this->user_id = zbase_auth_has() ? zbase_auth_user()->id() : null; $this->mimetype = zbase_file_mime_type($uploadedFile); $this->size = zbase_file_size($uploadedFile); $this->filename = basename($uploadedFile); $this->{$this->parentObjectIndexId} = $parentObject->id(); if (empty($nodeFiles)) { $parentObject->image = $this->filename; $parentObject->save(); } $this->save(); return true; } } catch (\Zbase\Exceptions\RuntimeException $e) { if (zbase_is_dev()) { dd($e); } zbase_abort(500); } return false; }