Exemplo n.º 1
0
 private function __construct()
 {
     $mode = isset($_GET['mode']) ? $_GET['mode'] : false;
     require 'core/models/class.Access.php';
     switch ($mode) {
         case 'login':
             $login = new Access();
             $login->Login();
             break;
         case 'reg':
             if (isset($_POST['faccion'])) {
                 $reg = new Access();
                 $reg->Register();
             } else {
                 $lng = new Lang();
                 $template = new Smarty();
                 $template->assign(array('x_user' => $lng->x_user, 'x_pass' => $lng->x_pass, 'x_email' => $lng->x_email, 'x_registrarme' => $lng->x_registrarme));
                 $template->display('public/registro.xnv');
             }
             break;
         default:
             $lng = new Lang();
             $template = new Smarty();
             $template->assign(array('x_user' => $lng->x_user, 'x_pass' => $lng->x_pass, 'x_recordar' => $lng->x_recordar, 'x_submit' => $lng->x_submit));
             $template->display('public/index.xnv');
             break;
     }
     unset($lng, $template);
 }
Exemplo n.º 2
0
 public function delete()
 {
     $Access = new Access($this->data->id);
     $Access->delete();
     $go = '>auth/Access/formFind';
     $this->renderPrompt('information', "Access [{$this->data->idAccess}] removido.", $go);
 }
Exemplo n.º 3
0
 public function getNoParentRootTeam()
 {
     $query = " SELECT * ";
     $query .= " FROM  utenti ";
     $query .= " WHERE parent > " . BASE_PARENT_ROOT;
     $query .= " AND   active = '" . VALUE_YES . "'";
     $query .= " ORDER BY parent,cognome ASC ";
     $acc = new Access();
     $res = $acc->select($query);
     return $res;
 }
Exemplo n.º 4
0
 public static function init()
 {
     $config = Config::load('modules');
     self::$default_modules = $config['default'];
     $db = DB::get();
     $modules = array();
     $enabled_modules = array();
     if (!empty($config['table'])) {
         $table = new $config['table']();
         $modules = $table->whereBy('module_enabled', 'Y')->column('module_key');
         $enabled_modules = array_merge($enabled_modules, $modules);
     }
     self::$enabled_modules = array_merge(self::$default_modules, $enabled_modules);
     $app = App::get();
     Access::reset();
     self::$paths = array();
     foreach (self::$enabled_modules as $v) {
         $cl = 'Pina\\Modules\\' . $v . '\\' . $v . 'Module';
         $path = '';
         if (class_exists($cl)) {
             $c = new $cl();
             $path = $c->path();
         } else {
             $path = App::path() . '/default/Modules/' . $v;
         }
         self::$paths[$v] = $path;
     }
     foreach (self::$paths as $base) {
         $path = $base . '/' . $app . '/init.php';
         if (is_file($path)) {
             include_once $path;
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($idTree)
 {
     $modelTree = Tree::model()->find('id=:id AND module=:module AND organization=:organization', array(':id' => $idTree, ':module' => 'news', ':organization' => Yii::app()->session['code_no']));
     if ($modelTree === null) {
         throw new CHttpException(404, 'Страница не найдена.');
     }
     if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree))) {
         throw new CHttpException(403, 'Доступ запрещен.');
     }
     $model = new News();
     $model->id_tree = $idTree;
     $model->flag_enable = true;
     $model->date_start_pub = date('d.m.Y');
     $model->date_end_pub = date('01.m.Y', PHP_INT_MAX);
     $model->author = Yii::app()->user->name;
     $model->general_page = 0;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['News'])) {
         $model->attributes = $_POST['News'];
         $model->log_change = LogChange::setLog($model->log_change, 'создание');
         if ($model->save()) {
             // сохраняем файлы
             $model->saveFiles($model->id, $idTree);
             // сохраняем изображения
             $model->saveImages($model->id, $idTree);
             // сохраняем миниатюра изображения
             $model->saveThumbailForNews($model);
             $this->redirect(array('view', 'id' => $model->id, 'idTree' => $idTree));
         }
     }
     $this->render('create', array('model' => $model, 'idTree' => $idTree));
 }
Exemplo n.º 6
0
 /**
  * 用户组绑定权限
  */
 public function actionIndex($id)
 {
     $id = (int) $id;
     $model = Group::model()->findByPk($id);
     if ($model->access) {
         foreach ($model->access as $g) {
             $access[] = $g->access_id;
         }
     }
     $cache = cache('auth_controller_file');
     if (!$cache) {
         $d = $this->_get_modules(\Yii::getPathOfAlias('application.modules'));
         if ($d) {
             Access::generate($d);
         }
         DirHelper::$kep_list_file = false;
         cache('auth_controller_file', true);
     }
     $rows = DB::all('access', array('select' => "id,name,pid"));
     foreach ($rows as $v) {
         $out[$v['id']] = $v;
     }
     $rows = ArrHelper::_tree_id($rows);
     if ($_POST) {
         $auth = $_POST['auth'];
         GroupAccess::saveAccess($id, $auth);
         cache('acl', false);
         flash('success', __('set access success'));
         $this->redirect(url('admin/auth/index', array('id' => $id)));
     }
     return $this->render('index', array('rows' => $rows, 'out' => $out, 'model' => $model, 'id' => $id, 'access' => $access));
 }
Exemplo n.º 7
0
function studentController()
{
    if (!Access::check('student')) {
        abort404();
    }
    view('students');
}
Exemplo n.º 8
0
 public static function load($blog_id = null, $user_id = null, $include_count = true, $offset = 0, $limit = BLOG_DISPLAY_LIMIT)
 {
     $filters = array();
     $current_user = \Warden::current_user();
     $result = array('data' => array(), 'count' => 0);
     if (empty($blog_id)) {
         if (empty($user_id)) {
             $filters['public_flag'] = true;
             //only load public blogs if not loading a specific user's blog
             if (!$current_user || !\Access::can('publicize_any_blog', $current_user)) {
                 $filters['publish_flag'] = true;
                 //only load published blogs if the user is not privileged to publicize any blog
             }
         } else {
             if (!$current_user || $user_id != $current_user->id) {
                 $filters['publish_flag'] = true;
                 //only load published blogs if the user is loading a blog that's not their own
             }
             $filters['user_id'] = $user_id;
             //load blogs for the specified user only
         }
         $result['data'] = static::get_where($filters, $offset, $limit);
     } else {
         $result['data'] = static::get_where(array('id' => $blog_id, 0, 1));
     }
     if (!empty($result['data'])) {
         $result['count'] = $include_count ? static::get_count($filters) : count($result['data']);
     }
     return $result;
 }
Exemplo n.º 9
0
 public function getAdminEntitiesIDs($entity_name)
 {
     if (\Auth::check()) {
         return array_flatten(\Access::where('user_id', \Auth::user()->id)->where('entity_name', $entity_name)->get(['entity_id'])->toArray());
     }
     return [];
 }
Exemplo n.º 10
0
function teacherController()
{
    if (!Access::check('teacher')) {
        abort404();
    }
    view('teachers');
}
Exemplo n.º 11
0
 public function action_delete()
 {
     $result = array('status' => false, 'error' => array());
     try {
         $input = Input::post();
         if (empty($input) || empty($input['id'])) {
             throw new Exception('You must specify a blog to delete.');
         }
         $blog = Model_Blog::find($input['id']);
         if (!$blog) {
             throw new Exception('Blog not found.');
         }
         if (!\Access::can('delete_any_blog', $this->user) && (!\Access::can('delete_own_blog', $this->user) || !Model_Agency_Contact::is_confirmed($blog->user_id, $this->user))) {
             throw new Exception('You are not authorized to delete this blog');
         }
         try {
             $blog->delete();
             $result['status'] = true;
         } catch (\Orm\ValidationFailed $ex) {
             $result['error'] = $ex->getMessage();
         } catch (Exception $ex) {
             $msg = $ex->getMessage();
             $result['error'] = $msg ? $msg : 'Oops, something went wrong.';
         }
     } catch (Exception $ex) {
         $result['error'] = $ex->getMessage();
     }
     return $this->response($result);
 }
Exemplo n.º 12
0
 /**
  * 返回access 里面name
  */
 function access()
 {
     $model = Access::find()->all();
     $t = \app\core\Arr::parentTree($model, $this->access_id);
     unset($s);
     foreach ($t as $v) {
         $s .= $v . ".";
     }
     return substr($s, 0, -1);
 }
Exemplo n.º 13
0
 /**
  * has_access
  * This function returns true or false if the current user
  * has access to this playlist
  */
 public function has_access()
 {
     if (!Access::check('interface', '25')) {
         return false;
     }
     if ($this->user == $GLOBALS['user']->id) {
         return true;
     } else {
         return Access::check('interface', '100');
     }
 }
Exemplo n.º 14
0
function checkPass($chave)
{
    session::delete('id_user');
    if (!Access::where('accesskey', $chave)->exists()) {
        return true;
    } else {
        $a = Access::where('accesskey', $chave)->get();
        session::set('id_user', $a[0]->id_user);
        return false;
    }
}
Exemplo n.º 15
0
function update_preferences($pref_id = 0)
{
    /* Get current keys */
    $sql = "SELECT `id`,`name`,`type` FROM `preference`";
    /* If it isn't the System Account's preferences */
    if ($pref_id != '-1') {
        $sql .= " WHERE `catagory` != 'system'";
    }
    $db_results = Dba::read($sql);
    $results = array();
    // Collect the current possible keys
    while ($r = Dba::fetch_assoc($db_results)) {
        $results[] = array('id' => $r['id'], 'name' => $r['name'], 'type' => $r['type']);
    }
    // end collecting keys
    /* Foreach through possible keys and assign them */
    foreach ($results as $data) {
        /* Get the Value from POST/GET var called $data */
        $name = $data['name'];
        $apply_to_all = 'check_' . $data['name'];
        $new_level = 'level_' . $data['name'];
        $id = $data['id'];
        $value = scrub_in($_REQUEST[$name]);
        /* Some preferences require some extra checks to be performed */
        switch ($name) {
            case 'transcode_bitrate':
                $value = Stream::validate_bitrate($value);
                break;
            default:
                break;
        }
        if (preg_match('/_pass$/', $name)) {
            if ($value == '******') {
                unset($_REQUEST[$name]);
            } else {
                if (preg_match('/md5_pass$/', $name)) {
                    $value = md5($value);
                }
            }
        }
        /* Run the update for this preference only if it's set */
        if (isset($_REQUEST[$name])) {
            Preference::update($id, $pref_id, $value, $_REQUEST[$apply_to_all]);
        }
        if (Access::check('interface', '100') && $_REQUEST[$new_level]) {
            Preference::update_level($id, $_REQUEST[$new_level]);
        }
    }
    // end foreach preferences
    // Now that we've done that we need to invalidate the cached preverences
    Preference::clear_from_session();
}
Exemplo n.º 16
0
 /**
  * страница работы с клиентом
  */
 public function action_client()
 {
     $clientId = $this->request->param('id');
     Access::check('client', $clientId);
     $client = Model_Client::getClient($clientId);
     $contracts = Model_Contract::getContracts($clientId);
     if (empty($client)) {
         throw new HTTP_Exception_404();
     }
     $popupContractAdd = Common::popupForm('Добавление нового договора', 'contract/add');
     $popupCabinetCreate = Common::popupForm('Создание личного кабинета', 'client/cabinet_create');
     $this->tpl->bind('client', $client)->bind('contracts', $contracts)->bind('popupContractAdd', $popupContractAdd)->bind('popupCabinetCreate', $popupCabinetCreate);
 }
Exemplo n.º 17
0
 /**
  * @covers Xoops\Core\Cache\Access::clear
  * @covers Xoops\Core\Cache\Access::write
  * @covers Xoops\Core\Cache\Access::read
  */
 public function testClear()
 {
     $key = 'offhand/name';
     $value = 'Fred';
     $ret = $this->object->write($key, $value);
     $this->assertTrue($ret);
     $ret = $this->object->read($key);
     $this->assertSame($ret, $value);
     $ret = $this->object->clear();
     $this->assertTrue($ret);
     $ret = $this->object->read($key);
     $this->assertFalse($ret);
 }
Exemplo n.º 18
0
 /**
  * 返回access 里面name
  */
 function access($access_id = null)
 {
     $model = Access::model()->findAll();
     if (!$access_id) {
         $access_id = $this->access_id;
     }
     $t = \ArrHelper::parentTree($model, $access_id);
     unset($s);
     foreach ($t as $v) {
         $s .= $v . ".";
     }
     return substr($s, 0, -1);
 }
Exemplo n.º 19
0
/**
 * 2007-2015 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <*****@*****.**>
 * @copyright 2007-2015 PrestaShop SA
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */
function ps_1702_right_management()
{
    $actions = array('CREATE', 'READ', 'UPDATE', 'DELETE');
    /**
     * Add roles
     */
    foreach (array('TAB', 'MODULE') as $element) {
        foreach ($actions as $action) {
            Db::getInstance()->execute('
                INSERT INTO `' . _DB_PREFIX_ . 'authorization_role`
                (`slug`)
                SELECT CONCAT("ROLE_MOD_' . $element . '_", UCASE(`class_name`), "_' . $action . '")
                FROM `' . _DB_PREFIX_ . strtolower($element) . '`
            ');
        }
    }
    /**
     * Add access
     */
    $accessObject = new Access();
    // Tabs
    $oldAccess = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'access_old`');
    foreach ($oldAccess as $currOldAccess) {
        foreach (array('view', 'add', 'edit', 'delete') as $action) {
            if (array_key_exists($action, $currOldAccess) && $currOldAccess[$action] == '1') {
                $accessObject->updateLgcAccess($currOldAccess['id_profile'], $currOldAccess['id_tab'], $action, true);
            }
        }
    }
    // Modules
    $oldAccess = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'module_access_old`');
    foreach ($oldAccess as $currOldAccess) {
        foreach (array('configure', 'view', 'uninstall') as $action) {
            if (array_key_exists($action, $currOldAccess) && $currOldAccess[$action] == '1') {
                $accessObject->updateLgcAccess($currOldAccess['id_profile'], $currOldAccess['id_tab'], $action, true);
            }
        }
    }
}
Exemplo n.º 20
0
 private function configuration()
 {
     Assets::$test = TRUE;
     // Delete in real
     $this->fc = FrontController::getInstance();
     $this->controller = strtolower(str_replace('Controller', '', $this->fc->getController()));
     $this->action = strtolower(str_replace('Action', '', $this->fc->getAction()));
     $this->view = new View();
     $this->params = $this->fc->getParams();
     if ($this->controller == 'error') {
         return;
     }
     // Users and Access
     $this->mu = M_Users::Instance();
     $this->user = $this->mu->GetUser();
     $accessByIp = IpAccess::isAccess($_SERVER['REMOTE_ADDR']);
     if ((!$accessByIp || $this->user->locked) && $this->controller != 'authorization') {
         $expire = time() + 3600 * 24 * 100;
         setcookie('rUrl', $_SERVER['REQUEST_URI'], $expire, "/");
         $this->redirect(array('authorization', 'login'));
         exit;
     }
     $access = new Access();
     $access->fillFromUser($this->user);
     $access->setAccessParams($this->controller, $this->action);
     $sectionAccess = $access->sectionAccess();
     $actionAccess = $access->actionAccess();
     if (!$sectionAccess || !$actionAccess) {
         if ($this->user->isGuest) {
             $expire = time() + 3600 * 24 * 100;
             setcookie('rUrl', $_SERVER['REQUEST_URI'], $expire, "/");
             $this->redirect(array('authorization', 'login'));
         }
         $pageArr = $access->UserAccessPage;
         $redirectArray = $pageArr ? $pageArr : array('error', '');
         $this->redirect($redirectArray);
     }
     $this->access = $access;
     $sInfo = $access->actionAccess(array('service', 'info')) ? true : false;
     $this->fc->setSInfo($sInfo);
     unset($access);
     $this->pageTitle = __('pageTitle');
     $array = array('access' => $this->access, 'controller' => $this->controller, 'action' => $this->action, 'user' => $this->user);
     $this->setMainVars($array);
     if (!empty($_POST)) {
         $_POST = AF::clearDataArray($_POST);
     }
     // Set user
     AF::setUser($this->user);
     AF::setUserAccess($this->access);
     //$sectionID = ( isset($this->params['id']) && is_numeric($this->params['id']) ) ? $this->params['id'] : '';
     //Log::createLog($this->user->user_id, $this->action."Action", $this->controller, $sectionID);
 }
Exemplo n.º 21
0
 public function action_login()
 {
     $this->template->title = 'User &raquo; Login';
     $this->template->content = $this->action_get_login_form();
     $post = Input::post();
     if (!empty($post)) {
         //get the destination path to redirect to upon login
         $destination = empty($_REQUEST['destination']) ? '/welcome' : $_REQUEST['destination'];
         $this->template->content->destination = $destination;
         //add server-side validation
         $validation = $this->template->content->validation;
         $validation->add_field('username_or_email', 'Username or Email', 'required');
         $validation->add_field('password', 'Password', 'required');
         if ($validation->run()) {
             try {
                 $authenticated_flag = false;
                 if ($this->user && \Access::can('impersonate_any_user', $this->user)) {
                     Warden::logout();
                     $authenticated_flag = Warden::force_login($validation->validated('username_or_email'), true);
                 } else {
                     $authenticated_flag = Warden::authenticate($validation->validated('username_or_email'), $validation->validated('password'), Input::post('remember_me'));
                 }
                 if ($authenticated_flag) {
                     Response::redirect(Uri::create($destination, array(), array(), false));
                 } else {
                     Session::set_flash('error', 'Invalid username/email or password entered.');
                 }
             } catch (Warden\Failure $failure) {
                 switch ($failure->reason()) {
                     case 'unconfirmed':
                         //user is unconfirmed - let them know they need to confirm and activate their account
                         Session::set_flash('error', $failure->getMessage());
                         $this->template->content = View::forge('user/unconfirmed');
                         $this->template->content->user = $failure->get_user();
                         $this->template->content->user->send_confirmation_instructions();
                         break;
                     case 'locked':
                         Session::set_flash('error', array('Your account has been locked due to too many consecutive failed login attempts.', 'Check your email for instructions on unlocking your account. Or you can wait a few days and try again.'));
                         break;
                     default:
                         Session::set_flash('error', $failure->getMessage());
                 }
             } catch (Exception $ex) {
                 Session::set_flash('error', $ex->getMessage());
             }
         } else {
             Session::set_flash('error', 'Invalid username/email or password entered.');
         }
     }
 }
Exemplo n.º 22
0
 /** 
         Функция возвращает массив с правами пользователей
         на разделы в зависимости от выбранного режима section->use_organization = true|false
             если true - возвращает права по организациям access_organization->right_(view|create|edit|delete)
             если false - возвращает права на текущий раздел access->right_(view|create|edit|delete) 
         Передаваемые параметры:
             $section_id (обязательный) - ИД Раздела (Section->id)
             $org_id (не обязательный, по умолчанию = 0) - ИД
         Результат:
             array('allow|deny'
                 {,actions=array('index'|,'admin'|,'create'|,'edit'|,'delete')}
                 ,users=>array('имя текущего пользователя')
             )
     **/
 public static function getAccessRight($section_id, $org_id = 0)
 {
     if (Yii::app()->user->role_admin) {
         return array('allow', 'users' => array(Yii::app()->user->name));
     }
     $result_array = array('users' => array(Yii::app()->user->name));
     $result_actions = array();
     $modelSection = Section::model()->findByPk($section_id);
     if (count($modelSection) == 0) {
         return $result_array;
     }
     $tableAccess = Access::model()->tableSchema->rawName;
     $tableAccessOrganization = Yii::app()->db->tablePrefix . 'access_organization';
     $tableGroupUser = Yii::app()->db->tablePrefix . 'group_user';
     $model = Yii::app()->db->createCommand()->select('t.id,t.date_create,t.date_modification,' . (!$modelSection->use_organization ? 't.right_view,t.right_create,t.right_edit,t.right_delete' : ($org_id == 0 && $modelSection->use_organization ? 'a_o.right_view,' : 'a_o.right_view,') . 'a_o.right_view,a_o.right_create,a_o.right_edit,a_o.right_delete'))->from('{{access}} t')->leftJoin($tableAccessOrganization . ' a_o', '[t].[id]=[a_o].[id_access]' . (!($org_id == 0 && $modelSection->use_organization) ? ' AND [a_o].[id_organization]=' . $org_id : ''))->where('[t].[id_section]=' . $section_id . ' AND ([t].[id_user]=' . Yii::app()->user->id . ' OR ' . '[t].[id_group] IN (select [g_u].[id_group] from ' . $tableGroupUser . ' [g_u] ' . 'where [g_u].[id_user]=' . Yii::app()->user->id . '))')->queryAll();
     foreach ($model as $value) {
         if ($value['right_view'] == true) {
             if (!in_array('index', $result_actions)) {
                 $result_actions[] = 'index';
             }
             if (!in_array('admin', $result_actions)) {
                 $result_actions[] = 'admin';
             }
         }
         if (!($modelSection->use_organization && $org_id == 0)) {
             if ($value['right_create'] == true) {
                 if (!in_array('create', $result_actions)) {
                     $result_actions[] = 'create';
                 }
             }
             if ($value['right_edit'] == true) {
                 if (!in_array('edit', $result_actions)) {
                     $result_actions[] = 'edit';
                 }
             }
             if ($value['right_delete'] == true) {
                 if (!in_array('delete', $result_actions)) {
                     $result_actions[] = 'delete';
                 }
             }
         }
     }
     if (count($result_actions)) {
         $result_array = array_merge($result_array, array('allow', 'actions' => $result_actions));
     } else {
         $result_array = array_merge($result_array, array('deny'));
     }
     return $result_array;
 }
Exemplo n.º 23
0
 /**
  * Loads default home page.
  */
 public function index($lang = 'ch')
 {
     if (!file_exists('application/views/' . $lang . '/index.php')) {
         // Whoops, we don't have a page for that!
         show_404();
     }
     $this->load->model('video_model', 'video');
     $data['video'] = $this->video->get_last_video(Access::isLoggedIn());
     $this->load->library('javascript_plugins');
     $plugins = $this->javascript_plugins;
     $footer_data['js_plugins'] = $plugins->generate(array($plugins::FlowPlayer));
     $this->loadHeader($lang);
     $this->load->view($lang . '/index', $data);
     $this->load->view('templates/footer', $footer_data);
 }
Exemplo n.º 24
0
 /**
  * Loads prayer history page.
  */
 public function prayerhistory($lang = 'ch')
 {
     if (!Access::hasPrivilege(Access::PRI_READ_PRAYER)) {
         // TODO: show authentication error.
         show_404();
     }
     if (!file_exists('application/views/' . $lang . '/request/requesthistory.php')) {
         // Whoops, we don't have a page for that!
         show_404();
     }
     $this->load->model('request_model', 'request');
     $data['requests'] = $this->request->get_requests($lang);
     $this->loadHeader($lang);
     $this->load->view($lang . '/request/requesthistory', $data);
     $this->load->view('templates/footer');
 }
Exemplo n.º 25
0
 public static function account_validate($username, $firstname, $lastname, $email)
 {
     $user = new Access();
     if (empty($username)) {
         validate::$er_message = '<i style="color: red;">Username field cannot be left empty</i><br/>';
         return false;
     }
     if (empty($email)) {
         validate::$er_message .= '<i style="color: red;">Email field cannot be left empty</i><br/>';
         return false;
     }
     if (empty($firstname)) {
         return true;
     }
     if (strlen($firstname) > 10 || strlen($firstname) < 2) {
         validate::$er_message = '<i style="color: red;">First name must be greater the 2 characters and less the 10 characters long! </i><br/>';
         return false;
     }
     if (is_numeric($firstname)) {
         validate::$er_message = '<i style="color: red;">First name must be letters only!</i><br/>';
         return false;
     }
     if (empty($lastname)) {
         return true;
     }
     if (strlen($lastname) > 10 || strlen($lastname) < 2) {
         validate::$er_message = '<i style="color: red;">Last name must be greater the 2 characters and less the 10 characters long! </i><br/>';
         return false;
     }
     if (is_numeric($lastname)) {
         validate::$er_message = '<i style="color: red;">Last name must be letters only!</i><br/>';
         return false;
     }
     if (User::ifUserExist($email) == true && $email == $user->get_email($_SESSION['uid'])) {
         return true;
     } elseif (User::ifUserExist($email) == true && $email !== $user->get_email($_SESSION['uid'])) {
         validate::$er_message = '<i style="color: red;">Someone else is already using that email address!</i><br/>';
         return false;
     }
     if (Validate::is_valid_email($email) == false) {
         validate::$er_message .= '<i style="color: red;">Please enter a valid email address!</i><br/>';
         return false;
     } else {
         return true;
     }
 }
Exemplo n.º 26
0
 public function __construct()
 {
     parent::__construct();
     $this->session = Session::instance();
     require Kohana::find_file('vendor', 'classTextile');
     require Kohana::find_file('vendor', 'Markdown');
     $this->auth = Auth::instance();
     $this->access = Access::instance();
     $this->filebrowser = Filebrowser::instance();
     $this->filekind = FileKind::instance();
     Subfolio::set_filebrowser($this->filebrowser);
     Subfolio::set_auth($this->auth);
     Subfolio::set_template($this->template);
     Subfolio::set_filekind($this->filekind);
     $this->template->site_title = Kohana::config('filebrowser.site_name');
     $this->template->page_title = "";
 }
 public function deleteAcesso($delete)
 {
     try {
         $transaction = $this->beginTransaction();
         if (is_array($delete)) {
             foreach ($delete as $id) {
                 Access::create($id)->delete();
             }
         } else {
             Access::create($delete)->delete();
         }
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollback();
         throw new EModelException('Error');
     }
 }
Exemplo n.º 28
0
 public function __construct()
 {
     $this->usr_id = Auth::getUserID();
     if (!Access::canAccessReports($this->usr_id)) {
         throw new LogicException('Invalid role');
     }
     $this->prj_id = Auth::getCurrentProject();
     $this->activity_types = !empty($_REQUEST['activity_types']) ? (array) $_REQUEST['activity_types'] : array();
     $this->report_type = isset($_REQUEST['report_type']) ? (string) $_REQUEST['report_type'] : null;
     $this->unit = $this->getParam('unit', array('hour', 'day'));
     $this->amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : null;
     $this->developer = isset($_REQUEST['developer']) ? $_REQUEST['developer'] : null;
     $this->start_date = $this->parseDate(isset($_POST['start']) ? $_POST['start'] : null);
     $this->end_date = $this->parseDate(isset($_POST['end']) ? $_POST['end'] : null);
     $this->sort_order = $this->getParam('sort_order', array('ASC', 'DESC'));
     if (CRM::hasCustomerIntegration($this->prj_id)) {
         $this->crm = CRM::getInstance($this->prj_id);
     }
 }
Exemplo n.º 29
0
 public function LogarAction()
 {
     $this->view->setFile('index');
     $this->load('Storage\\Session');
     $data = $this->request->post();
     if (!$this->session->exists('attemptAccess')) {
         $this->session->set('attemptAccess', 0);
         $this->session->set('accessUser', $data['username']);
     } else {
         if ($this->session->get('accessUser') !== $data['username']) {
             $this->session->set('attemptAccess', 0);
             $this->session->set('accessUser', $data['username']);
         }
     }
     $access = Access::start_processing($data, $this);
     if (!is_null($access->user) and !$access->error and $access->status) {
         Access::end_processing($access, $this);
     }
     $this->load('Helpers\\Alert', $access->errors[0]);
 }
Exemplo n.º 30
0
 function privilegeAction()
 {
     $model = new User();
     $model->allFIelds = true;
     $id = AF::get($this->params, 'id', 0);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->setByID($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $access = new Access();
     $access->fillFromUser($model);
     $userAccess = $access->getUserUpdateAccess();
     ksort($userAccess);
     if (isset($_POST['ajax'])) {
         $newAcces = AF::get($_POST, 'array');
         if ($newAcces) {
             $access->setUserAccess($newAcces);
             // hack to get the uesrs_access table to update instead of insert
             $msql = SafeMySQL::getInstance();
             $sql = "SELECT * FROM ?n WHERE user_id = ?i";
             $result = $msql->getRow($sql, $access->tableName(), $access->user_id);
             if (!empty($result)) {
                 $access->setIsNewRecord(0);
             }
             if ($access->save()) {
                 $model->user_id_updated = $this->user->user_id;
                 $model->updated = 'NOW():sql';
                 $model->IsNewRecord = false;
                 $model->save();
                 Message::echoJsonSuccess(__('user_access_updated'));
             } else {
                 Message::echoJsonError(__('user_access_not_updated'));
             }
         } else {
             Message::echoJsonError(__('user_access_not_updated'));
         }
     }
     Assets::js('jquery.form');
     $this->addToPageTitle('User privilege');
     $this->render('privilege', array('userAccess' => $userAccess, 'model' => $model));
 }