예제 #1
0
 *
 * @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.']]]]]];
예제 #2
0
 /**
  * Get a validator for an incoming registration request.
  *
  * @param  array  $data
  * @TODO check if role is given, check it against the list of ROLES from DB
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function registerValidator(array $data)
 {
     $userEntity = zbase_entity('user');
     $messages = [];
     $rules = ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:' . zbase_config_get('entity.user.table.name')];
     if (!isset($data['name'])) {
         unset($rules['name']);
     }
     $messages['email.unique'] = 'Email address used already.';
     if ($userEntity->usernameEnabled()) {
         $rules['username'] = '******' . zbase_config_get('entity.user.table.name') . '|not_in:' . implode(',', require zbase_path_library('notallowedusernames.php'));
         $messages['username.unique'] = 'Username already exists.';
         $messages['username.regex'] = 'Username should be of alphanumeric in small letters';
         $messages['username.not_in'] = 'Username already exists.';
     }
     if ($userEntity->passwordAutoGenerate()) {
         $data['password'] = $userEntity->generatePassword();
         $data['raw_password'] = $data['password'];
     } else {
         $rules['password'] = '******';
         $rules['password_confirmation'] = 'same:password';
         $messages['password.min'] = 'Password too short.';
         $messages['password_confirmation.same'] = 'Passwords not the same. Kindly verify password.';
     }
     if (!empty($data['role'])) {
         $roles = zbase()->entity('user_roles', [], true)->listAllRoles();
         if (!empty($roles)) {
             $rules['role'] = 'in:' . implode(',', $roles);
             $messages['role.in'] = 'Kindly select a role in the given list.';
         }
     }
     $moreValidations = $this->getRegistrationValidation();
     if (!empty($moreValidations['rules'])) {
         $rules = array_merge($rules, $moreValidations['rules']);
     }
     if (!empty($moreValidations['messages'])) {
         $messages = array_merge($messages, $moreValidations['messages']);
     }
     return Validator::make($data, $rules, $messages);
 }
예제 #3
0
<?php

$provinces = (require_once zbase_path_library('Geo/PH/state.php'));
$provincesArray = [];
foreach ($provinces as $province => $cities) {
    foreach ($cities as $city) {
        $c = ['id' => $city . ', ' . $province, 'text' => $city . ', ' . $province];
        $provincesArray[] = $c;
    }
}
echo 'var PHCITIES =  ' . json_encode($provincesArray) . ';';
예제 #4
0
 /**
  * Return the Country States
  * @param string $country ISO2 CountryName
  * @return array [ISO2 => StateName]
  */
 public function getCountryStates($country)
 {
     $file = zbase_path_library('Geo/' . strtoupper($country) . '/states.php');
     if (zbase_file_exists($file)) {
         return require $file;
     }
 }
예제 #5
0
/**
 * Check if Username route is valid
 *
 * @return boolean
 */
function zbase_route_username_get()
{
    $username = zbase_route_input(zbase_route_username_prefix(), false);
    if (!empty($username)) {
        $username = strtolower($username);
        $notAllowedUsernames = (array) (require_once zbase_path_library('notallowedusernames.php'));
        if (in_array($username, $notAllowedUsernames)) {
            return false;
        }
        /**
         * Check if valid username
         */
        $user = zbase_user_by('username', $username);
        if ($user instanceof \Zbase\Entity\Laravel\User\User) {
            return $username;
        }
    }
    return false;
}