Exemplo n.º 1
0
 /**
  * standardowa metoda init jest nadpisywana tylko w Base.
  * Do użytku na konkretnych kontrolerach należy wykożystywać metodę base_init
  */
 public function init()
 {
     $this->view->headTitle($this->headTitle);
     $this->_helper->redirector->setExit(false);
     // context switching
     $cs = $this->_helper->contextSwitch();
     $cs->initContext();
     // redirect to default action when try to use json context as html
     $action = $this->_request->getActionName();
     $controller = $this->_request->getControllerName();
     if (in_array('json', $cs->getActionContexts($action)) && !$this->getRequest()->isXmlHttpRequest() && count($cs->getActionContexts($action)) == 1) {
         $logic = new Logic_User();
         $landing = $logic->getDefaultAction();
         $this->_helper->redirector->setGotoUrl($landing);
     }
     // konfiguracja kontekstu dla Base.Ajax
     $cs->setCallback('json', 'post', array($this, '_postAjaxContext'));
     // jesli jest zapytanie ajaxowe to przelaczamy sie na jsona
     if ($this->getRequest()->isXmlHttpRequest()) {
         $cs->initContext('json');
     }
     //        if ($this->navResource) {
     //            $navigation = Zend_Registry::get(Zend_Application_Resource_Navigation::DEFAULT_REGISTRY_KEY);
     //            $page = $navigation->findOneBy('resource', $this->navResource);
     //            $page->setActive(true);
     //        }
     if ($order = $this->getRequest()->getParam('order')) {
         $this->view->order = $order;
     }
     if ($sort = $this->getRequest()->getParam('sort')) {
         $this->view->sort = $sort;
     }
     $this->base_init();
 }
Exemplo n.º 2
0
 protected function resetpassdfaction()
 {
     $sql = "SELECT id_user from profile where id in  (SELECT id_profile from profile_role  where  id_role in (39,42,41,44,48,38)) group by id_user";
     $model = new User();
     $u = $model->getAdapter()->query($sql);
     $users = $u->fetchAll();
     $logic = new Logic_User();
     foreach ($users as $user) {
         $logic->resetPassword($user['id_user']);
     }
 }
Exemplo n.º 3
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     if ($identity = Zend_Auth::getInstance()->getIdentity()) {
         $id = $identity->id;
         $u = new Logic_User();
         if ($u->isLocked($id)) {
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
             $redirector->setGotoSimple('logout', 'auth', null, array('id' => $id));
         }
         Zend_Layout::getMvcInstance()->getView()->login = $identity->login;
     }
 }
Exemplo n.º 4
0
 protected function _process()
 {
     try {
         $logic = new Logic_User();
         $ex = $logic->deleter();
         foreach ($ex as $e) {
             $this->logger->warn($this->_printEx($e));
         }
     } catch (Exception $e) {
         $this->logger->crit($this->_printEx($e));
         exit(1);
     }
 }
Exemplo n.º 5
0
 public function createUser($data)
 {
     $tetaModel = new TetaEmployeer();
     $userModel = new Logic_User();
     $boAdapter = Zend_Registry::get('bo');
     $boUser = $boAdapter->select()->from('users')->where('elogin like ?', $data['login_bo'])->where('employee_name ilike ?', mb_convert_encoding($data['name'], "LATIN2", "UTF-8"))->where('employee_surname ilike ?', mb_convert_encoding($data['surname'], "LATIN2", "UTF-8"))->query()->fetchAll();
     $boUser = array_shift($boUser);
     $tetaRow = $tetaModel->fetchRow($tetaModel->select()->where('NR_PESEL = ?', $data['pesel'])->where('IMIE like upper(?)', $data['name'])->where('NAZWISKO like upper(?)', $data['surname']));
     if (!$tetaRow) {
         throw new Exception('Brak podanego użytkownika w bazie TETA!');
     }
     if (empty($boUser)) {
         throw new Exception('Brak podanego użytkownika w bazie Back Office!');
     }
     $user = $userModel->_createUserFromBo($tetaRow, $boUser);
 }
Exemplo n.º 6
0
 public function add($value, array &$invalid)
 {
     $form = new Logic_User_Form_Import();
     $logic = new Logic_User();
     if ($value['login'] == null) {
         $login = explode("@", $value['email']);
         $value['login'] = $login[0];
     }
     $form->setDefaults($value);
     if ($form->isValid($value)) {
         $logic->createUserImport($form, $sendEmail = false);
     } else {
         echo "Error in: " . $form->getElement('surname')->getValue();
         $invalid[] = $value;
     }
 }
Exemplo n.º 7
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     if ($identity = Zend_Auth::getInstance()->getIdentity()) {
         $id = $identity->id;
         $u = new Logic_User();
         if ($u->ifPasswordExpire($id) && ($request->getControllerName() != 'user' || $request->getActionName() != 'changepassword')) {
             if ($request->isXmlHttpRequest()) {
                 $request->setControllerName('user');
                 $request->setActionName('changepassword');
                 $view = Zend_Layout::getMvcInstance()->getView();
                 $view->redirect = '/user/changepassword';
             } else {
                 $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
                 $redirector->gotoSimpleAndExit('changepassword', 'user', null, array());
             }
         }
     }
 }
Exemplo n.º 8
0
 public function baseInit()
 {
     $branch = Zend_Auth::getInstance()->getIdentity()->id_branch;
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $userEvent = new Logic_UserEvent();
     $assignedUsers = $userEvent->showUsers($this->getAttrib('id_next_event'));
     $assignedUsers = $assignedUsers->toArray();
     $alreadyAssignedUsers = array();
     if (isset($assignedUsers)) {
         foreach ($assignedUsers as $assignedUser) {
             $alreadyAssignedUsers[] = $assignedUser['id_euser'];
         }
     }
     $users = new Logic_User();
     $select = $users->getUsersInBranch($branch);
     $doradcyList = array();
     $doradcy = $db->fetchAll($select);
     unset($select);
     $profileRole = new ProfileRole();
     $config = Zend_Registry::get('config');
     foreach ($doradcy as $key => $value) {
         $ru = $profileRole->fetchAll("id_profile = " . $value['profile_id'])->toArray();
         if ($value['role_count'] == 1 && $ru[0]['id_role'] == $config['role']['assistant']) {
             unset($doradcy[$key]);
         }
     }
     foreach ($doradcy as $key) {
         if (!in_array($key['id'], $alreadyAssignedUsers)) {
             $doradcyList[$key['id']] = $key['first_name'] . " " . $key['surname'];
         }
     }
     //        $doradcy = $users->query($doradcy);
     $this->addElement('select', 'user', array('label' => 'Wybierz doradcę:', 'required' => true, 'MultiOptions' => $this->addClearStart($doradcyList)));
     $this->submit();
     $this->cancel();
 }
Exemplo n.º 9
0
 public function showAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $id = $this->_helper->IdConvert->hexToStr($id);
     $logic = new Logic_Branch();
     $logicUser = new Logic_User();
     $userModel = new User();
     $profileRole = new ProfileRole();
     $select = $logicUser->getUsersInBranch($id);
     $user_data = $userModel->fetchAll($select)->toArray();
     $config = Zend_Registry::get('config');
     foreach ($user_data as $key => $value) {
         $ru = $profileRole->fetchAll("id_profile = " . $value['profile_id'])->toArray();
         if ($value['role_count'] == 1 && $ru[0]['id_role'] == $config['role']['assistant']) {
             unset($user_data[$key]);
         }
     }
     $data = array();
     try {
         $data = $logic->showBranch($id);
         $headers = $data->getHeaderMappings();
         $this->view->advisers = count($user_data);
         $headers['advisers'] = array('title' => 'Ilość doradców', 'sort' => false);
     } catch (Logic_Branch_Exception $e) {
         $this->_helper->messenger->error();
         $this->_helper->redirector('index');
         return;
     }
     if ($data['map_image'] != "") {
         $data['map_image'] = '<img src="/static/img/' . $data['map_image'] . '" />';
     }
     $this->view->data = $data;
     $this->view->data_headers = $headers;
 }
Exemplo n.º 10
0
 public function deleteAction()
 {
     $request = $this->getRequest();
     $id = $this->_helper->IdConvert->hexToStr($request->getParam('id'));
     /*$userModel = new User();
       $user = $userModel->findOne($id);*/
     /*if ($user->timelock_start) {
           $blockadeDate = new Zend_Date($user->timelock_start);
           $this->_helper->messenger->error('Konto użytkownika jest w trakcie usuwania. Planowana data usunięcia konta: ' . $blockadeDate->toString('YYYY-MM-dd') . '.');
           $this->_helper->redirector('index');
           return;
       }*/
     $form = new Logic_User_Form_Delete();
     if ($request->isPost()) {
         if ($form->isCancelled($this->getRequest()->getPost())) {
             $this->_helper->redirector('index', null, null);
             return;
         }
         if ($form->isValid($request->getPost())) {
             try {
                 $logic = new Logic_User();
                 $logic->delete($id, $form);
                 if ($form->getValue('blockade_start') <= date('c')) {
                     $this->_helper->messenger->success('Usunięto konto użytkownika');
                 } else {
                     $this->_helper->messenger->success('Konto użytkownika zostanie usunięte w dniu ' . $form->getValue('blockade_start') . '.');
                 }
                 $this->_helper->redirector('index');
                 return;
             } catch (Logic_User_Exception $e) {
                 $this->_helper->messenger->error($e->getMessage());
             }
         }
     }
     $this->view->form = $form;
 }
Exemplo n.º 11
0
 public function logoutAction()
 {
     $uzytkownik = new Logic_User();
     $instance = Zend_Auth::getInstance();
     $login = $instance->getIdentity()->login;
     $uzytkownik->logout($login);
     $instance->clearIdentity();
     //wyczysicic wyszystkie przetrzenie namespaceow
     $namespaces_to_invalidate = array(SESSION_NAMESPACE_DORADCA_SEARCH, SESSION_NAMESPACE_KLIENT_SEARCH, SESSION_NAMESPACE_FILTERS);
     foreach ($namespaces_to_invalidate as $ns_name) {
         $ns = new Zend_Session_Namespace($ns_name);
         $ns->unsetAll();
     }
     Zend_Session::destroy();
     $this->_helper->redirector('login', 'auth', null, array('msg' => $this->getRequest()->getParam('msg', false)));
 }
Exemplo n.º 12
0
 public function undeleteAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $logic = new Logic_User();
     $logic->find($id);
     $login = $logic->getFullLogin();
     try {
         $logic->undelete();
         $cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('rolecache');
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
         $this->_helper->success();
         $this->_helper->AdminActionLog->undelete('uzytkownik', 'przywrócenie ' . $logic->getFullName() . ' (login: '******')', 'error', $logic);
         $this->_helper->redirector('index');
         return;
     } catch (Logic_Uzytkownik_Exception $e) {
         $this->_helper->AdminActionLog->undelete('uzytkownik', 'przywrócenie ' . $logic->getFullName() . ' (login: '******')', 'error', $logic);
         $this->_helper->error(MSG_ERROR, $e);
     }
 }
Exemplo n.º 13
0
 public static function getAdminPanelLogModel()
 {
     if (self::$_adminLog === null) {
         self::$_adminLog = new AdminPanel();
     }
     return self::$_adminLog;
 }
Exemplo n.º 14
0
 /**
  * Pobranie instacji Klienta na podstawie id użytkownika (potrzebne dla wywołań via CLI)
  * @param integer $idUser
  * @return Logic_Client
  * @throws Logic_Exception
  */
 public static function getInstanceByClient($clientId)
 {
     $user = new Logic_User();
     $clientId = $user->getAssignetWsClientId($idUser);
     if (null === $clientId) {
         throw new Logic_Exception("User with ID={$idUser} does not have any Client assigned!");
     }
     $client = new Wsclient();
     $clientRow = $client->getClient($clientId);
     if (null === $clientRow) {
         throw new Logic_Exception("Client with ID={$clientId} is not present or it has been ghosted!");
     }
     return self::getInstance(null, $clientRow->id);
 }