Exemplo n.º 1
0
 public function docUserLogAction()
 {
     //$this->_helper->layout->setLayout('main');
     $users = new Model_Users();
     $doc_user_log = $users->getDocUserLog();
     $this->view->result = $doc_user_log;
 }
Exemplo n.º 2
0
 public function sendMails($data)
 {
     $config = (include_once 'config/main.php');
     $result = array('status' => 'success', 'message' => 'Сообщения успешно разосланы!');
     // Получаем всех пользователей
     $model = new Model_Users();
     $users = $model->getUsersMailing(intval($data['id_group']));
     if (!$users) {
         $result['status'] = 'error';
         $result['message'] = 'Пользователи не найдены!';
         return $result;
     }
     //Формируем адресатов
     $addresses = [];
     for ($i = 0; $i < count($users); $i++) {
         if ($users[$i]->name) {
             $addresses[$i]['name'] = $users[$i]->name;
         } else {
             $addresses[$i]['name'] = 'пользователь сайта LoftShop';
         }
         $addresses[$i]['email'] = $users[$i]->email;
     }
     $username = '******';
     $letter = ['preview' => $data['subject'], 'title' => $data['title'], 'username' => $username, 'body' => $data['body']];
     $bodyHtml = $this->view->render('admin/mailing/letter_template.twig', array('letter' => $letter));
     $bodyText = 'Здравствуйте, ' . $username . '! ' . $data['body'] . ' С уважением, администрация сайта LoftShop!';
     $sendStatus = $this->sendMailMany($config['email']['adminname'], $config['email']['adminemail'], $config['email']['adminpassword'], $addresses, $data['subject'], $bodyHtml, $bodyText);
     if (!$sendStatus) {
         $result['status'] = 'error';
         $result['message'] = 'Не удалось отправить сообщения=(';
         return $result;
     }
     return $result;
 }
Exemplo n.º 3
0
 public function deleteAction()
 {
     $role = new Model_Users();
     $role_id = $_GET['role_id'];
     $role->deleteRole($role_id);
     $this->redirect('giaovu/role/list');
 }
Exemplo n.º 4
0
 function index()
 {
     $model = new Model_Users();
     $userInfo = $model->getUser(2);
     $this->template->vars('userInfo', $userInfo);
     $this->template->view('index');
 }
Exemplo n.º 5
0
 public function calificacionautomatica($idempresa, $users, $estado)
 {
     if ($estado == "4") {
         $proyecto = 1;
         if ($users == "564") {
             $userid = 564;
             $deptocalifica = 2;
         } else {
             $ouser = new Model_Users();
             $deptocalifica = $ouser->iddeptouser($users->id);
             $userid = $users->id;
         }
         $notafinal1 = $this->califica($idempresa, $proyecto, $deptocalifica);
         $calificaciones = ORM::factory('calificaciones');
         $calificaciones->id_empresa = $idempresa;
         $calificaciones->id_user = $userid;
         $calificaciones->calificacion = $notafinal1;
         $calificaciones->comentario = "Nota para proyectos en Vivienda Nueva (GENERADO POR EL SISTEMA)";
         $calificaciones->fecha_registro = date('Y-m-d H:i:s');
         $calificaciones->id_clasificacion = "1";
         $calificaciones->save();
         $proyecto = 2;
         $notafinal2 = $this->califica($idempresa, $proyecto, $deptocalifica);
         $calificaciones = ORM::factory('calificaciones');
         $calificaciones->id_empresa = $idempresa;
         $calificaciones->id_user = $userid;
         $calificaciones->calificacion = $notafinal2;
         $calificaciones->comentario = "Nota para proyectos PMAR (GENERADO POR EL SISTEMA)";
         $calificaciones->fecha_registro = date('Y-m-d H:i:s');
         $calificaciones->id_clasificacion = "1";
         $calificaciones->save();
     }
 }
Exemplo n.º 6
0
 protected static function _getArticleObjectFromData(\stdClass $article_data)
 {
     $author = new Model_Users($article_data->author_username);
     $author->prop('id', $article_data->author_id);
     $category = new Model_Categories($article_data->category_name);
     $category->prop('id', $article_data->category_id);
     return new Model_Articles(['id' => $article_data->id, 'title' => $article_data->title, 'introduction' => $article_data->introduction, 'content' => $article_data->content, 'date_publication' => $article_data->date_publication, 'date_last_update' => $article_data->date_last_update, 'is_published' => $article_data->is_published, 'author' => $author, 'category' => $category]);
 }
Exemplo n.º 7
0
 public function recoverAction()
 {
     $user_id = $_GET['user_id'];
     $user = new Model_Users();
     //$user->deleteUserRole($user_id);
     $user->recoverUser($user_id);
     $this->redirect('giaovu/user/list');
 }
Exemplo n.º 8
0
 public function action_index()
 {
     $oUser = new Model_Users();
     $users = $oUser->listaGeneral();
     if (sizeof($users) > 0) {
         $this->template->content = View::factory('admin/users')->bind('users', $users);
     }
 }
Exemplo n.º 9
0
 public function isValid($value, $context = null)
 {
     $usersModel = new Model_Users();
     if ($usersModel->userIsValid($context['email'], $value)) {
         return true;
     }
     $this->_error(self::NOT_MATCH);
     return false;
 }
Exemplo n.º 10
0
 public function isValid($value)
 {
     $usersModel = new Model_Users();
     if ($usersModel->emailExists($value)) {
         $this->_error(self::MAIL_TAKEN);
         return false;
     }
     return true;
 }
Exemplo n.º 11
0
 public function delete()
 {
     if (!($id = $this->getRequest()->getId())) {
         $this->getResponse()->setBody(array('status' => 'failed', 'message' => 'ID required'));
         return;
     }
     $this->users->delete(addslashes($id));
     $this->getResponse()->setBody(array('status' => 'success', 'message' => 'User deleted'));
 }
Exemplo n.º 12
0
 public function isValid($value)
 {
     $modelUsers = new Model_Users();
     $user = $modelUsers->fetchWithEmail($value);
     if (!$user) {
         $this->_error(self::INVALID_USER_EMAIL);
         return false;
     }
     return true;
 }
Exemplo n.º 13
0
 /**
  *@TODO: better error trapping
  */
 public function activateAction()
 {
     $sid = $this->_getParam('session');
     $uid = $this->_user->identity();
     $user_session = Game_Model_Gamesessions::getInstance()->get($sid);
     $user_session->activate($uid);
     $this->_active_session = $user_session;
     $params = array('message' => 'Session Activated');
     $this->forward('index', NULL, NULL, $params);
 }
Exemplo n.º 14
0
 public function get()
 {
     $fields = $this->getRequest()->getParam('fields', false);
     if ($id = $this->getRequest()->getId()) {
         $this->getResponse()->setBody($this->regions->getRegion($id, $fields));
         return;
     }
     $order = $this->getRequest()->getParam('order', false);
     $count = $this->getRequest()->getParam('count', false);
     $this->getResponse()->setBody($this->regions->getRegions($fields, $order, $count));
 }
Exemplo n.º 15
0
 /**
  * Autenticação de Usuário
  *
  * Apresentando como primeiro parâmetro o e-mail do usuário e como segundo o
  * seu hash cadastrado no sistema, será apresentado um token de autenticação
  * resultante se as credenciais apresentadas estiverem válidas.
  *
  * @param  string $email E-mail Utilizado pelo Usuário
  * @param  string $hash  Hash Cadastrado para o E-mail
  * @return string Token de Autenticação
  */
 public function login()
 {
     // Captura de Parâmetros
     $email = (string) func_get_arg(0);
     $hash = (string) func_get_arg(1);
     // Camada de Modelo
     $model = new Model_Users();
     // Processamento
     $result = $model->login($email, $hash);
     // Apresentação
     return $result;
 }
 public function indexAction()
 {
     $form = new Form_Cadmin_UserSearch();
     $form_add = new Form_Cadmin_User();
     $params = array();
     $users = new Model_Users();
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $loginid = $form->getValue('login_id');
             $role_id = $form->getValue('role');
             if (!empty($loginid)) {
                 $params['loginId'] = $loginid;
             }
             if (!empty($role_id)) {
                 $params['role'] = $role_id;
             }
         }
     } else {
         $loginid = $this->_getParam('login_id');
         $role_id = $this->_getParam('role');
         if (!empty($loginid)) {
             $params['loginId'] = $loginid;
             $form->login_id->setValue($loginid);
         }
         if (!empty($role_id)) {
             $params['role'] = $role_id;
             $form->role->setValue($role_id);
         }
     }
     $sort = $this->_getParam("sort", "asc");
     $order = $this->_getParam("order", "login_id");
     $users->form_values = $params;
     $result = $users->getUsers($order, $sort);
     //Paginate the contest results
     $paginator = Zend_Paginator::factory($result);
     $page = $this->_getParam("page", 1);
     $counter = $this->_getParam("counter", 10);
     $paginator->setCurrentPageNumber((int) $page);
     $paginator->setItemCountPerPage((int) $counter);
     $this->view->form = $form;
     $this->view->form_add = $form_add;
     $this->view->paginator = $paginator;
     $this->view->sort = $sort;
     $this->view->order = $order;
     $this->view->counter = $counter;
     $this->view->pagination_params = $params;
     $base_url = Zend_Registry::get('baseurl');
     $this->view->inlineScript()->appendFile($base_url . '/js/all_level_combos.js');
     $this->view->inlineScript()->appendFile($base_url . '/common/bootstrap/extend/jasny-bootstrap/js/jasny-bootstrap.min.js');
     $this->view->inlineScript()->appendFile($base_url . '/common/bootstrap/extend/jasny-bootstrap/js/bootstrap-fileupload.js');
     $this->view->headLink()->appendStylesheet($base_url . '/common/bootstrap/extend/jasny-bootstrap/css/jasny-bootstrap.min.css');
     $this->view->headLink()->appendStylesheet($base_url . '/common/bootstrap/extend/jasny-bootstrap/css/jasny-bootstrap-responsive.min.css');
 }
 /**
  * Function addeditAction for add and edit the user's information.
  */
 public function addeditAction()
 {
     $asUser = Zend_Json_Decoder::decode($this->getRequest()->getParam('ssUserDetail'), Zend_Json::TYPE_ARRAY);
     if ($asUser['id_user'] == 0) {
         $oUser = new Model_Users();
         $oUser->saveUser($asUser);
     } else {
         $oUser = Model_UsersTable::updateUser($asUser);
     }
     $asResponse = array('status' => 'success', 'massage' => 'Record added or edited successfully');
     echo Zend_Json_Encoder::encode($asResponse);
     exit;
 }
Exemplo n.º 18
0
 public function accountAction()
 {
     $lecturer_id = $this->sessionGlobal->lecturer_id;
     $user = new Model_Users();
     $findUser = $user->findOneUser($lecturer_id);
     $this->view->findUser = $findUser;
     if ($this->_request->isPost()) {
         $data = $this->_getParam('searchParam');
         $user->updateUser($data);
         echo "Thành công";
         header("Refresh:0");
     }
 }
 public function isValid($value)
 {
     if ($value == $this->excludeAddress) {
         return true;
     }
     $modelUsers = new Model_Users();
     $user = $modelUsers->fetchWithEmail($value);
     if ($user) {
         $this->_error('Email already registered');
         return false;
     }
     return true;
 }
 public function searchAction()
 {
     $q = $this->_getParam('q');
     if ($q) {
         $modelUsers = new Model_Users();
         $users = $modelUsers->search($q);
         $this->view->users = $users;
         $this->view->q = $q;
         $this->view->usersFound = count($users);
     } else {
         $this->view->usersFound = 0;
     }
     $this->_helper->layout->disableLayout();
 }
Exemplo n.º 21
0
 public function saveUser($oFormValue = array())
 {
     if (!is_array($oFormValue) || empty($oFormValue)) {
         return false;
     }
     $ousers = new Model_Users();
     $ousers->email = $oFormValue['email'];
     $ousers->password = md5($oFormValue['password']);
     $ousers->first_name = ucfirst($oFormValue['first_name']);
     $ousers->last_name = ucfirst($oFormValue['last_name']);
     $ousers->city = ucfirst($oFormValue['city']);
     $ousers->save();
     return true;
 }
Exemplo n.º 22
0
 public function indexAction()
 {
     $where = '';
     $category = null;
     if ($this->getRequest()->getQuery('username')) {
         $userinfo = Model_Users::getByUsername($this->getRequest()->getQuery('username'));
         if ($userinfo) {
             $where = "users.username = '******'username') . "'";
         }
     }
     if ($this->getRequest()->getQuery('category')) {
         $catinfo = Model_Categories::get($this->getRequest()->getQuery('category'));
         if ($catinfo) {
             $category = $this->getRequest()->getQuery('category');
         }
     }
     $items = Model_Items::getAll($category, 0, 20, 'id desc', $where);
     $this->view->item = array();
     if ($items) {
         $model_images = new Model_Images();
         $categories = Model_Categories::get_all();
         foreach ($items as $item) {
             $categories_string = '';
             if ($category) {
                 foreach ($item['categories'] as $cats) {
                     if (in_array($category, $cats)) {
                         foreach ($cats as $cat) {
                             if (isset($categories[$cat]['name'])) {
                                 $categories_string .= $categories_string ? ' › ' : '';
                                 $categories_string .= $categories[$cat]['name'];
                             }
                         }
                         break;
                     }
                 }
             } else {
                 $cats = array_pop($item['categories']);
                 if ($cats && is_array($cats)) {
                     foreach ($cats as $cat) {
                         if (isset($categories[$cat]['name'])) {
                             $categories_string .= $categories_string ? ' › ' : '';
                             $categories_string .= $categories[$cat]['name'];
                         }
                     }
                 }
             }
             if ((int) JO_Registry::get($item['module'] . '_items_preview_width') && (int) JO_Registry::get($item['module'] . '_items_preview_height')) {
                 $item['theme_preview_thumbnail'] = $this->getRequest()->getBaseUrl() . $model_images->resize($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'), JO_Registry::forceGet($item['module'] . '_items_preview_height'), true);
             } elseif ((int) JO_Registry::get($item['module'] . '_items_preview_width')) {
                 $item['theme_preview_thumbnail'] = $this->getRequest()->getBaseUrl() . $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
             } elseif ((int) JO_Registry::get($item['module'] . '_items_preview_height')) {
                 $item['theme_preview_thumbnail'] = $this->getRequest()->getBaseUrl() . $model_images->resizeHeight($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_height'));
             } else {
                 $item['theme_preview_thumbnail'] = false;
             }
             $this->view->item[] = array('title' => $item['name'], 'link' => WM_Router::create($this->getRequest()->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&item_id=' . $item['id']), 'description' => html_entity_decode($item['description'], ENT_QUOTES, 'utf-8'), 'author' => $item['username'], 'category' => $categories_string, 'guid' => $item['id'], 'enclosure' => $item['theme_preview_thumbnail'], 'pubDate' => JO_Date::getInstance($item['datetime'], JO_Date::RSS_FULL, true)->toString());
         }
     }
     echo $this->renderScript('rss');
 }
Exemplo n.º 23
0
 public function action_index()
 {
     try {
         $helper = new FacebookRedirectLoginHelper(Config::get('login_url'));
         $session = $helper->getSessionFromRedirect();
     } catch (FacebookRequestException $ex) {
         // When Facebook returns an error
     } catch (\Exception $ex) {
         // When validation fails or other local issues
     }
     if (isset($session)) {
         //login succes
         $long_lived_session = $session->getLongLivedSession();
         $access_token = $long_lived_session->getToken();
         //*** Call api to get user info
         $user_info = $this->facebook->get_user_information($access_token);
         //*** Check if user has existed
         $user = Model_Users::find('first', array('where' => array('fb_id' => $user_info->getId())));
         if (empty($user)) {
             // Register user
             if (Model_Users::register_user($user_info, $access_token)) {
                 //Success
             }
         }
         //*** Set session for user
         Fuel\Core\Session::set('user_token', $long_lived_session->getToken());
         Fuel\Core\Session::set('user_id', $user_info->getId());
         //*** Redirect to home
         \Fuel\Core\Response::redirect('fanpage/index');
     } else {
         // login fail
         $this->template->login_url = $helper->getLoginUrl();
     }
 }
Exemplo n.º 24
0
 public static function createUser($data)
 {
     $db = JO_Db::getDefaultAdapter();
     if (!$data['username'] || Model_Users::getByUsername($data['username'])) {
         return false;
     }
     if (!$data['email'] || Model_Users::getByEmail($data['email'])) {
         return false;
     }
     $db->insert(Model_Users::getPrefixDB() . 'users', array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'firmname' => $data['firmname'], 'profile_title' => $data['profile_title'], 'profile_desc' => $data['profile_desc'], 'register_datetime' => $data['register_datetime'], 'status' => 'activate'));
     $user_id = $db->lastInsertId();
     if ($user_id) {
         $upload_path = BASE_PATH . '/uploads';
         $user_path = '/users/' . JO_Date::getInstance($data['register_datetime'], 'yy/mm/')->toString() . $user_id . '/';
         $upload_path .= $user_path;
         if ($data['avatar'] && @getimagesize($data['avatar'])) {
             $name = basename($data['avatar']);
             if (copy($data['avatar'], $upload_path . $name)) {
                 $db->update('users', array('avatar' => $user_path . $name), array('user_id' => $user_id));
             }
         }
         if ($data['homeimage'] && @getimagesize($data['homeimage'])) {
             $name = basename($data['homeimage']);
             if (copy($data['homeimage'], $upload_path . $name)) {
                 $db->update('users', array('homeimage' => $user_path . $name), array('user_id' => $user_id));
             }
         }
         return Model_Users::getUser($user_id);
     }
 }
Exemplo n.º 25
0
 public function getPercentRow($user)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(Model_Users::getPrefixDB() . 'users', 'commission_percent')->where('user_id= ?', $user['user_id'])->limit(1, 0);
     $user_data = $db->fetchRow($query);
     if ($user_data && round($user_data['commission_percent']) > 0) {
         return array('percent' => floatval($user_data['commission_percent']), 'to' => 0);
     }
     $no_exclusive_author_percent = 30;
     if (JO_Registry::get('no_exclusive_author_percent')) {
         $no_exclusive_author_percent = (int) JO_Registry::get('no_exclusive_author_percent');
     }
     $exclusive_author_percent = 40;
     if (JO_Registry::get('exclusive_author_percent')) {
         $exclusive_author_percent = (int) JO_Registry::get('exclusive_author_percent');
     }
     if ($user['exclusive_author'] == 'false') {
         $percent = array('percent' => $no_exclusive_author_percent, 'to' => 0);
     } else {
         $query = $db->select()->from(Model_Users::getPrefixDB() . 'percents')->where("`from` <= ? AND (`to` > ? OR `to` = 0)", $user['sold']);
         $data = $db->fetchRow($query);
         if (count($data) == 0) {
             $percent = array('percent' => $exclusive_author_percent, 'to' => 0);
         } else {
             $percent = $data;
         }
     }
     return $percent;
 }
Exemplo n.º 26
0
 public function put_index($id, $username, $email, $password = null, $id_group = null)
 {
     // Force to edit the current user if they don't have the proper permissions
     if (!$this->_currentUser->hasPermission(Model_Groups::PERM_MANAGE_USERS)) {
         $id = $this->_currentUser->getId();
     }
     $user = Model_Users::getById($id);
     $propsUpdate = ['username' => $username, 'email' => $email];
     if ($id_group !== null && !empty($id_group) && $this->_currentUser->hasPermission(Model_Groups::PERM_MANAGE_USERS)) {
         $group = Model_Groups::getById($id_group);
         $propsUpdate['usergroup'] = $group;
     } else {
         $user->load('usergroup');
     }
     if ($password !== null && !empty($password)) {
         $propsUpdate['password'] = Library_String::hash(trim($password));
     }
     $user->setProps($propsUpdate);
     Model_Users::update($user);
     // Disconnect the user if they changed their own profile
     if ($id === $this->_currentUser->getId()) {
         $this->response->redirect('../login/out', 200);
     } else {
         $this->response->redirect('../users', 200);
     }
 }
Exemplo n.º 27
0
 public static function getWithdraws($from, $to)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(Model_Users::getPrefixDB() . 'withdraw')->where("`paid` = 'true'")->order('paid_datetime');
     $d = explode('-', $from);
     if (count($d) == 3 && checkdate($d[1], $d[2], $d[0])) {
         $query->where('`paid_datetime` >= ?', $from);
     }
     $d = explode('-', $to);
     if (count($d) == 3 && checkdate($d[1], $d[2], $d[0])) {
         $query->where('`paid_datetime` <= ?', $to);
     }
     $results = $db->fetchAll($query);
     $return = array();
     if ($results) {
         foreach ($results as $result) {
             $date = explode(' ', $result['paid_datetime']);
             $date = $date[0];
             if (!isset($return[$date]['amount'])) {
                 $return[$date]['amount'] = 0;
             }
             $return[$date]['amount'] += $result['amount'];
         }
     }
     return $return;
 }
Exemplo n.º 28
0
 /**
  *
  * @param <type> $pResource
  * @return <type>
  */
 public function is_allowed($pResource, Model_Users $pUser = NULL)
 {
     if (!$pUser) {
         $pUser = Model_Users::current_user();
     }
     return self::acl()->isAllowed($pUser ? $pUser->role : Model_Roles::ROLE_ANONYMOUS, $pResource);
 }
Exemplo n.º 29
0
 public static function getTableInstance()
 {
     if (!self::$_table) {
         self::$_table = new Model_Table_Users();
     }
     return self::$_table;
 }
Exemplo n.º 30
0
    /**
     *
     * @param Ultimatum_Model_Ultplayergroupknowledge $pScan
     * @return string
     */
    public function game(Ultimatum_Model_Ultplayergroupknowledge $pScan)
    {
        $game = Zend_Registry::get('ultimatum_game');
        if ($game) {
            $user = Model_Users::current_user();
            ob_start();
            ?>
<fieldset id="ultimatum_game">
    <legend>Ultimatum</legend>
<b>Game:</b> <?php 
            echo $game;
            ?>
, turn <?php 
            echo $game->turn();
            if ($user && $user->can('ultimatum_manage')) {
                echo $this->view->zupallinkbutton("/ultimatum/game/nextturn/game/" . $game->identity(), 'Next Turn');
            }
            ?>
<br />
<?php 
            echo $this->view->zupallinkbutton("/ultimatum/game/switch/", 'Stop Playing');
            ?>
</fieldset>
<?php 
            return ob_get_clean();
        } else {
            return '';
        }
    }