/** * Do username/password check here * * @param $user * @param $password * @param $remember * @return bool * @throws Kohana_Exception */ protected function _login($user, $password, $remember) { if (!is_array($user)) { $user = Model_Manager::getManager(['login' => strtoupper($user)]); } if (is_string($password)) { // Create a hashed password $password = $this->hash($password); } // If the passwords match, perform a login if (empty($user['PASSWORD']) || $user['PASSWORD'] !== $password) { Messages::put('Неправильный логин или пароль', 'error'); return false; } if ($user['AGENT_STATE'] != 1) { Messages::put('Доступ запрещен', 'error'); return false; } if ($user['STATE_ID'] != 1) { Messages::put('Доступ запрещен', 'error'); return false; } // Finish the login $this->complete_login($user); $db = Oracle::init(); $data = ['p_manager_id' => $user['MANAGER_ID'], 'p_params' => $_SERVER['HTTP_USER_AGENT'] . ';' . $_SERVER['REMOTE_ADDR']]; $db->procedure('auth_user', $data); return true; }
public static function getInstance() { if (empty(self::$_instance)) { $db = new Db(); $context = Context::getInstance(); self::$_instance = new self($db, $context); } return self::$_instance; }
/** * а вот тут уже аяксово получаем инфу по конкретному менеджеру */ public function action_manager() { $managerId = $this->request->param('id'); $manager = Model_Manager::getManager($managerId); if (empty($manager)) { $this->html('<div class="error_block">Ошибка</div>'); } $managerSettingsForm = View::factory('forms/manager/settings'); $managerSettingsForm->set('manager', $manager)->set('width', 100)->set('reload', 0)->set('changeRole', 1); $popupManagerAddClients = Common::popupForm('Добавление клиентов', 'manager/add_clients'); $html = View::factory('ajax/control/manager')->bind('managerId', $managerId)->bind('manager', $manager)->bind('managerSettingsForm', $managerSettingsForm)->bind('popupManagerAddClients', $popupManagerAddClients); $this->html($html); }
public function __construct() { $this->context = Context::getInstance(); $this->model = Model_Manager::getInstance(); $this->container = Service_Container::getInstance(); $this->view = new AppView(); $this->view->page = !empty($_GET['page']) ? strtolower($_GET['page']) : 'user'; $this->view->action = !empty($_GET['action']) ? strtolower($_GET['page']) : 'index'; if (!empty($this->_JS)) { $this->addJSLibraries(); } $this->context->buildParams(); if (!empty($_GET['msg'])) { $this->showMessage(); } }
/** * список доступный клиентов */ public function action_managers_clients() { $params = $this->request->post('params'); $clients = Model_Manager::getClientsList($params); $this->jsonResult(true, $clients); }
public function __construct() { $this->context = Context::getInstance(); $this->model = Model_Manager::getInstance(); $this->container = Service_Container::getInstance(); }
public function getSearch($criterias, $offset = 0, $limit = 0) { $concerts = array(); $contextUserId = $this->context->get('user_id'); $where = ''; if (!empty($criterias['search_keyword'])) { $where .= " AND concert_libel REGEXP :search_keyword "; } if (!empty($criterias['search_style'])) { $where .= " AND band_style REGEXP :search_style "; } if (!empty($criterias['search_distance'])) { $longitude = $this->context->get('ville_longitude_deg'); $latitude = $this->context->get('ville_latitude_deg'); $where .= ' AND ville_longitude_deg BETWEEN :longitude_begin AND :longitude_end AND ville_latitude_deg BETWEEN :latitude_begin AND :latitude_end '; } $sql = 'SELECT * FROM concert JOIN ( city, concert_band, band ) ON ( concert.ville_id = city.ville_id AND concert.concert_id = concert_band.concert_id AND band.band_id = concert_band.band_id ) WHERE concert.ville_id > 0 ' . $where . ' AND flyer_url IS NOT NULL AND fb_event IS NOT NULL AND date > UNIX_TIMESTAMP() ORDER BY date ASC LIMIT :limit_begin, :limit_end; '; $sql = str_replace(',)', ')', $sql); $sql = str_replace(', )', ')', $sql); $stmt = $this->db->prepare($sql); if (!empty($criterias['search_keyword'])) { $keywords = explode(' ', $criterias['search_keyword']); $regexp = implode('|', $keywords); $stmt->bindValue('search_keyword', $regexp, PDO::PARAM_STR); } if (!empty($criterias['search_style'])) { $result = Model_Manager::getInstance()->find('style', array('style_keyword'), array('style_id' => $criterias['search_style'])); $keywords = explode(',', $result[0]['style_keyword']); $regexp = implode('|', $keywords); $stmt->bindValue('search_style', $regexp, PDO::PARAM_STR); } if (!empty($criterias['search_distance'])) { $ratio = COEF_DISTANCE * $criterias['search_distance']; $stmt->bindValue('longitude_begin', $longitude - $ratio, PDO::PARAM_INT); $stmt->bindValue('longitude_end', $longitude + $ratio, PDO::PARAM_INT); $stmt->bindValue('latitude_begin', $latitude - $ratio, PDO::PARAM_INT); $stmt->bindValue('latitude_end', $latitude + $ratio, PDO::PARAM_INT); } $stmt->bindValue('limit_begin', $offset * (NB_SEARCH_RESULTS * 3), PDO::PARAM_INT); $stmt->bindValue('limit_end', empty($limit) ? NB_SEARCH_RESULTS * 3 : $limit, PDO::PARAM_INT); $concertRows = $this->db->executeStmt($stmt)->fetchAll(); $tmp_id = 0; foreach ($concertRows as $key => $concert) { if ($tmp_id != $concert['concert_id']) { $bands = array(); } if (!empty($concert['bands'])) { $bands = $concerts[$concert['concert_id']]['bands']; } $concerts[$concert['concert_id']] = $concert; $bands[] = array('band_id' => $concert['band_id'], 'band_libel' => $concert['band_libel'], 'band_website' => $concert['band_website'], 'band_style' => $concert['band_style']); $concerts[$concert['concert_id']]['bands'] = $bands; $tmp_id = $concert['concert_id']; } return $concerts; }
/** * получаем список клиентов для combobox */ public function action_list_manager_sale() { $res = Model_Manager::getManagersList(['search' => $this->_search, 'role_id' => [Access::ROLE_MANAGER_SALE, Access::ROLE_MANAGER_SALE_SUPPORT], 'agent_id' => $this->_user['AGENT_ID'], 'manager_id' => $this->_ids]); if (empty($res)) { $this->jsonResult(false); } $return = []; foreach ($res as $item) { $return[] = ['name' => $item['M_NAME'], 'value' => $item['MANAGER_ID']]; } $this->jsonResult(true, $return); }