コード例 #1
0
 public function fetchDaysWithOrWoutGym($date1, $date2, Model_User $user)
 {
     $select = "SELECT count(*) as total, date from `" . $this->_name . "`\r\n\t\t\t\t\t\tWHERE userId = " . $user->getId() . " \r\n\t\t\t\t\t\t\tAND\tdate between '" . $date1 . "' and '" . $date2 . "'\r\n\t\t\t\t\t\t\t\tGROUP BY date";
     $data = $this->_db->query($select)->fetchAll();
     $datesInBetween = array($date1);
     while (end($datesInBetween) < $date2) {
         $datesInBetween[] = date('Y-m-d', strtotime(end($datesInBetween) . ' +1 day'));
     }
     $final['datesInBetween'] = implode(', ', $datesInBetween);
     $final['daysWithGym'] = null;
     foreach ($datesInBetween as $dates) {
         foreach ($data as $date) {
             if (in_array($dates, $date)) {
                 $final['daysWithGym'][] = $date['date'];
             }
         }
         if (is_array($final['daysWithGym'])) {
             if (!in_array($dates, $final['daysWithGym'])) {
                 $final['daysWithoutGym'][] = $dates;
             }
         }
     }
     $final['countDaysWithGym'] = count($final['daysWithGym']);
     $final['countDaysWithoutGym'] = count($final['daysWithoutGym']);
     return $final;
 }
コード例 #2
0
ファイル: notice.php プロジェクト: Alexander711/naav1
 /**
  * Возврващает все доступные уведомления для пользователя
  * @param Model_User $user
  * @return array
  */
 public function get_notices(Model_User $user)
 {
     $notices = array();
     $notice_config = Kohana::$config->load('notices_types');
     $notices_types = $notice_config['types'];
     $services = $user->get_user_services_ids();
     $selected_columns = $notice_config['selected_columns'];
     $query = DB::select()->from('notices')->select_array($selected_columns)->join(array('notices_services', 'notices_services'), 'left')->on('notices.id', '=', 'notices_services.notice_id')->join(array('notices_users', 'notices_users'), 'left')->on('notices.id', '=', 'notices_users.notice_id')->where('notices_users.user_id', '=', $user->id);
     if (!empty($services)) {
         $query->or_where('notices_services.service_id', 'in', $services);
     }
     $iteration = 0;
     foreach ($query->execute() as $q) {
         $config = $notices_types[$q['type']];
         if ($iteration == $q['id']) {
             $iteration++;
         }
         $id = $config['unique'] == false ? $q['id'] : $iteration;
         if (!isset($notices[$id])) {
             $notices[$id] = array('title' => $q['title'], 'text' => $q['text'], 'date' => $q[$config['date_column']], 'read' => $q[$config['read_column']]);
         }
         if ($config['for'] == 'service') {
             $service = DB::select(array('services.name', 'name'), array('org_type.name', 'org_type'))->from('services')->join(array('org_types', 'org_type'))->on('org_type.id', '=', 'services.org_type')->where('services.id', '=', $q['service_id'])->execute()->current();
             $notices[$id]['for'][] = $service['org_type'] . ' ' . '&laquo;' . $service['name'] . '&raquo;';
         }
         $iteration++;
     }
     usort($notices, array($this, 'sort_func'));
     return $notices;
 }
コード例 #3
0
ファイル: CacheController.php プロジェクト: Lazaro-Gallo/psmn
 public function indexAction()
 {
     //$this->_redirect('/?cache');
     //desabilita layout
     //$this->_helper->layout()->disableLayout();
     //echo "teste";
     $this->cache = Zend_Registry::get('cache_FS');
     $devol = new Model_User();
     $user = $devol->getUserById(66);
     //var_dump('user: '******'cache: ', $this->cache);
     $userCache = $this->cache->load('userCache');
     echo "<br><br><br>";
     //var_dump('userCache: ', $userCache);
     //recupera do cache
     if ($userCache == false) {
         //add fechall from db into cache
         $this->cache->save($user, 'userCache');
     }
     echo "<br><br>------------------------";
     $this->cache->save('conteudo variavel teste2 eh este!!', 'teste2');
     $this->cache->save('conteudo variavel teste3 eh este!!', 'teste3');
     echo "<br>teste2: " . $this->cache->load('teste2');
     echo "<br>teste3: " . $this->cache->load('teste3');
 }
コード例 #4
0
ファイル: users.php プロジェクト: aliasnash/flirt-web-p
 function profile()
 {
     $idu = isset($_SESSION['idu']) ? $_SESSION['idu'] : 0;
     $iduser = isset($_GET['id']) ? $_GET['id'] : 0;
     $this->stat->saveStat($idu, "users/profile [{$iduser}]");
     if (!empty($idu)) {
         if (!empty($iduser)) {
             $model = new Model_User();
             $profiles = $model->getUserProfile($idu, $iduser);
             if (count($profiles) > 0) {
                 $profile = $profiles[0];
             }
             if (!empty($profile)) {
                 $photos = $model->getPhotoList($iduser);
                 $this->template->vars('photos', $photos);
                 $this->template->vars('profile', $profile);
                 $this->template->view('index', $idu > 0);
             } else {
                 header('Location:' . WEB_APP);
             }
         } else {
             header('Location:' . WEB_APP);
         }
     } else {
         header('Location:' . WEB_APP . '/enter');
     }
 }
コード例 #5
0
ファイル: orm.php プロジェクト: alle/auto-modeler
 /**
  * Logs a user in.
  *
  * @param   string   username
  * @param   string   password
  * @param   boolean  enable autologin
  * @return  boolean
  */
 protected function _login($user, $password, $remember)
 {
     if (!is_object($user)) {
         $username = $user;
         // Load the user
         $user = new Model_User($username);
     }
     // If the passwords match, perform a login
     if ($user->has('roles', 1) and $user->password === $password) {
         if ($remember === TRUE) {
             // Create a new autologin token
             $token = ORM::factory('user_token');
             // Set token data
             $token->user_id = $user->id;
             $token->expires = time() + $this->_config['lifetime'];
             $token->save();
             // Set the autologin cookie
             Cookie::set('authautologin', $token->token, $this->_config['lifetime']);
         }
         // Finish the login
         $this->complete_login($user);
         return TRUE;
     }
     // Login failed
     return FALSE;
 }
コード例 #6
0
ファイル: Install.php プロジェクト: reGative/Phorumph
 public function action_index()
 {
     $count = ORM::factory('User')->count_all();
     if ($count === 0) {
         $this->template->content = View::factory('install/index');
         if ($this->request->method() === Request::POST) {
             if (!Security::check($this->request->param('id'))) {
                 throw new Exception("Bad token!");
             }
             $post = Validation::factory($_POST)->rule('username', 'not_empty')->rule('email', 'not_empty')->rule('email', 'email')->rule('password', 'not_empty')->rule('password', 'min_length', array(':value', '8'))->rule('password2x', 'not_empty')->rule('password', 'matches', array(':validation', 'password', 'password2x'));
             if ($post->check()) {
                 $user = new Model_User();
                 $post = $this->request->post();
                 $user->values($post)->save();
                 $adminRole = ORM::factory('Role')->where('name', '=', 'admin')->find();
                 $loginRole = ORM::factory('Role')->where('name', '=', 'login')->find();
                 $user->add('roles', $loginRole);
                 $user->add('roles', $adminRole);
                 $this->redirect('install/successful');
             } else {
                 $this->redirect('install/oops');
             }
         }
     } else {
         $this->redirect('');
     }
 }
コード例 #7
0
 public function indexAction()
 {
     $this->view->data = "hello";
     $muser = new Model_User();
     $q = $muser->listall2();
     print_r($q);
 }
コード例 #8
0
ファイル: Password.php プロジェクト: reGative/Phorumph
 public function action_do()
 {
     $user_id = $this->request->param('id');
     $hash = $this->request->param('id2');
     $password_recovery = new Model_Password_Recovery();
     $check_hash = $password_recovery->check($user_id, $hash);
     if ($check_hash !== true) {
         throw new Exception("This hash is not a password recovery request!");
     }
     $view = View::factory('forgot_password/recovery');
     if ($this->request->method() === Request::POST) {
         if (!Security::check($this->request->post('csrf_secure'))) {
             throw new Exception("Bad token!");
         }
         $password = $this->request->post('password');
         $confirm = $this->request->post('confirm');
         if ($password !== $confirm) {
             throw new Exception("Passwords did not match!");
         }
         $user = new Model_User();
         $password = crypt($password, 'generatedsalt');
         $change_password = $user->recover_password($password, $user_id);
         if (!$change_password) {
             throw new Exception("Error with changing a password!");
         }
         $chmod_attemp = $password_recovery->chmod_attemp($hash);
         if (!$chmod_attemp) {
             throw new Exception("False");
         }
         $this->redirect('');
     }
     $this->template->content = $view->render();
 }
コード例 #9
0
 /**
  * 职位设置
  */
 public function actionSetup()
 {
     $this->_modelUser = $this->_getGlobalData('Model_User', 'object');
     $this->_setupFilePath = CACHE_DIR . '/program/position.cache.php';
     if (file_exists($this->_setupFilePath)) {
         $dataList = $this->_getGlobalData('program/position');
         foreach ($dataList as $key => &$list) {
             $list['url_del'] = Tools::url(CONTROL, 'SetupDel', array('zp' => 'Program', 'Id' => $key));
         }
     } else {
         $dataList = null;
     }
     if ($dataList !== null) {
         $users = $this->_modelUser->findByDepartment(self::DEPARTMENT_IT);
         foreach ($users as $user) {
             if (!$user['position_id']) {
                 continue;
             }
             if (array_key_exists($user['position_id'], $dataList)) {
                 if (!is_array($dataList[$user['position_id']]['users'])) {
                     $dataList[$user['position_id']]['users'] = array();
                 }
                 array_push($dataList[$user['position_id']]['users'], $user);
             }
         }
     }
     $this->_view->assign('dataList', $dataList);
     $this->_utilMsg->createPackageNavBar();
     $this->_view->display();
 }
コード例 #10
0
ファイル: Service.php プロジェクト: maxwroc/PHP
 /**
  * Maskuje nazwiska i adresy email uzytkownikow
  */
 public function maskUserNamesAction()
 {
     $oUser = new Model_User();
     $aUsers = $oUser->getAll();
     foreach ($aUsers as $aUser) {
         if (in_array($aUser['name'], array('Chodorowski', 'TestUser'))) {
             continue;
         }
         $oUser = new Model_User();
         $oUser->user_id = $aUser['user_id'];
         // pick random name
         $sName = chr(rand(65, 90));
         $sName .= chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122));
         $sName .= chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122)) . chr(rand(97, 122));
         $oUser->name = $sName;
         $oUser->email = sprintf('*****@*****.**', strtolower($aUser['fname']), strtolower($sName));
         // save
         if (!$oUser->save()) {
             break;
         }
         unset($oUser);
     }
     // foreach
     $this->indexAction('Maskowanie wykonane pomyslnie.');
 }
コード例 #11
0
ファイル: pages.php プロジェクト: reGative/Cosmoss
 public function action_create()
 {
     $this->template->page_title = 'Create Page';
     $user = new Model_User();
     $session = Session::instance()->get('user');
     $view = View::factory('cp/pages/create');
     $view->author = $user->get_user_by_session_id($session);
     if ($this->request->method() === Request::POST) {
         if (!Security::check($this->request->post('csrf_token'))) {
             throw new HTTP_Exception_401("Bad token!");
         }
         $post_title = $this->request->post('title');
         $post_content = $this->request->post('content');
         $post_author = $this->request->post('author');
         $post_date = time();
         if (empty($post_title) && empty($post_content) && empty($post_author) && empty($post_date)) {
             throw new Exception('Please don`t make empty fields!');
         }
         $page = new Model_Page();
         $data = array('title' => $post_title, 'content' => $post_content, 'author' => $post_author, 'date' => $date);
         $insert_page = $page->insert_page($data);
         if (!$insert_page) {
             throw new Exception('Check if you are connected to database!');
         }
         $this->request->redirect('cp/pages');
     }
     $this->template->content = $view->render();
 }
コード例 #12
0
ファイル: User.php プロジェクト: kminkov/Blog
 public function login(Model_User $user)
 {
     $select = $this->_db->select()->from(array('u' => 'users'))->where('email = ?', $user->email)->where('password = ?', $user->password);
     $data = (array) $this->_db->fetchRow($select);
     $user->setOptions($data);
     return $user;
 }
コード例 #13
0
ファイル: Priv.php プロジェクト: laiello/quickbug
 /**
  * 检测用户是否对URI有访问权限的
  *
  * @param unknown_type $userid
  * @return boolean
  */
 public static function check($userid, $controller, $action)
 {
     // 非普通用户不查检权限
     if (QP_Session_Session::get('login_priv') != 1) {
         return true;
     }
     // 得到配置
     $privcfg = QP_Sys::config('privconfig');
     // 如果不使用权限则永远返回 true
     if (!$privcfg['enable']) {
         return true;
     }
     // 判断是否在全局访问的资源中
     $allRes = strtolower($controller . '_*');
     $currentRes = strtolower($controller . '_' . $action);
     if (in_array($currentRes, $privcfg['allow']) || in_array($allRes, $privcfg['allow'])) {
         return true;
     }
     // 得到用户所在的组的所有权限
     $userModel = new Model_User();
     $userInfo = $userModel->userinfo($userid);
     $privModel = new Model_Priv();
     $resourceArr = $privModel->getResource($userInfo['groupid']);
     // 判断是否在权限组中
     return in_array($currentRes, $resourceArr) || in_array($allRes, $resourceArr);
 }
コード例 #14
0
ファイル: Admin.php プロジェクト: relyd/aidstream
 public function deleteOrganisationById($orgId)
 {
     $wepModel = new Model_Wep();
     // Delete Activities
     $actCollModel = new Model_ActivityCollection();
     $activities = $actCollModel->getActivityIdsByAccount($orgId);
     $activityModel = new Model_Activity();
     foreach ($activities as $activity) {
         $activityModel->deleteActivityById($activity['id']);
     }
     // Delete Defaults
     $wepModel->deleteRow('default_field_groups', 'account_id', $orgId);
     $wepModel->deleteRow('default_field_values', 'account_id', $orgId);
     // Delete registry info
     $regModel = new Model_RegistryInfo();
     $regModel->deleteRegistryInfo($orgId);
     // Delete Users
     $userModel = new Model_User();
     $users = $userModel->getAllUsersByAccountId($orgId);
     foreach ($users as $user) {
         $this->deleteUserById($user['user_id']);
     }
     // Delete account
     $wepModel->deleteRow('iati_activities', 'account_id', $orgId);
     $wepModel->deleteRow('account', 'id', $orgId);
 }
コード例 #15
0
ファイル: Auth.php プロジェクト: adrianpl20/oop
 public function action_login()
 {
     if ($this->logged === TRUE) {
         header('Location: /');
         exit;
     }
     $model_Auth = new Model_Auth();
     // obsluga formularza
     if (isset($_POST['send'])) {
         $valid = $model_Auth->loginValidation($_POST);
         if ($valid === TRUE) {
             $model_User = new Model_User();
             $userid = $model_User->getIdFromName($_POST['name']);
             // loguje użytkownika
             Auth::instance()->login($userid);
             // przekierowanie na glowna strone
             header('Location: /');
             exit;
         }
     }
     // wybieram widok
     $this->view = View::factory('template');
     // ustawiam dane w widoku
     $this->view->title = 'Zaloguj się';
     $this->view->content = View::factory('auth/login');
     $this->view->content->valid = $valid;
 }
コード例 #16
0
 public function fetchOneByDate($date, Model_User $user)
 {
     $select = $this->select($date);
     $select->where('date = ?', $date);
     $select->where('userId = ?', $user->getId());
     return $this->fetchRow($select);
 }
コード例 #17
0
ファイル: UserController.php プロジェクト: Zerone/ImJob.org
 public function registerAction()
 {
     $request = $this->getRequest();
     $form = new Form_User_Registration();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $model = new Model_User($form->getValues());
             $user_id = $model->save();
             $model->setId($user_id);
             $globalSession = Zend_Registry::get('dlo.session');
             $globalSession->user = $model;
             //Zend_Loader::loadClass('Zend_View');
             $view = new Zend_View();
             $view->activationLink = "http://DrivingLessonOnline.com/user/verify-email/id/" . $model->getId() . "/guid/" . hash('sha1', $model->getSalt() . $model->getId() . $model->getPassword()) . "/";
             $view->setBasePath(APPLICATION_PATH . "/views/");
             $mailBodyHtml = $view->render('Templates/Account-Activation-Email.phtml');
             //send email verification email before user can start using their account.
             $mail = new Zend_Mail();
             $mail->setBodyHtml($mailBodyHtml);
             $mail->setFrom('*****@*****.**', 'Registration');
             $mail->addTo($model->getEmail(), $model->getDisplayName());
             $mail->setSubject($model->getDisplayName() . ' activiate your account for Driving Lesson Online.com');
             $mail->send();
             //thank user and inform to check their email to enable their account.
             $this->_redirect('/user/registered');
         }
     }
     $this->view->form = $form;
 }
コード例 #18
0
ファイル: validate.php プロジェクト: nhan7285/php7285
 public function user_registered($user, $loi)
 {
     $muser = new Model_User();
     if ($muser->check_username($user) == FALSE) {
         $this->_err[] = $loi;
     }
 }
コード例 #19
0
ファイル: Template.php プロジェクト: reGative/Phorumph
 public function before()
 {
     $config = Kohana::$config->load('common');
     $this->template = $config->template_name;
     parent::before();
     if (Auth::instance()->logged_in()) {
         $user = new Model_User();
         $this->template->topbar = View::factory('profile/topbar')->set('users', $user->where('id', '=', Auth::instance()->get_user()->pk())->find())->set('users_levels', $user->get_level(Auth::instance()->get_user()->pk()));
     } else {
         $this->template->topbar = View::factory('login');
     }
     $this->template->stylesheets = $config->stylesheets;
     $this->template->site_name = $config->site_name;
     if (Auth::instance()->logged_in()) {
         $user_id = Auth::instance()->get_user()->pk();
         $roles = ORM::factory('Roles_User')->get_last_role_id($user_id);
         foreach ($roles as $role) {
             if ($role->role_id == 1) {
                 if ($this->request->directory() == 'dashboard') {
                     $this->request->redirect('');
                 }
                 if ($this->request->uri() == 'dashboard') {
                     $this->request->redirect('');
                 }
             }
         }
     } else {
         if ($this->request->directory() == 'dashboard') {
             $this->request->redirect('');
         }
         if ($this->request->uri() == 'dashboard') {
             $this->request->redirect('');
         }
     }
 }
コード例 #20
0
ファイル: User.php プロジェクト: jiak94/api
 public function retrieveInfo($userId, $token)
 {
     $rs = array();
     $model = new Model_User();
     $rs = $model->retrieveInfo($userId, $token);
     return $rs;
 }
コード例 #21
0
ファイル: UserController.php プロジェクト: mtaha1990/onlineDR
 public function deleteAction()
 {
     $id = $this->_request->getParam('id');
     $mdlUseruserModel = new Model_User();
     $mdlUseruserModel->deleteUser($id);
     return $this->_forward('list');
 }
コード例 #22
0
 public function fetchByDate($date, Model_User $user)
 {
     $select = $this->select();
     $select->where('date = ?', $date);
     $select->where('userId = ?', $user->getId());
     return $this->fetchAll($select)->toArray();
 }
コード例 #23
0
 public function signupAction()
 {
     $this->view->title = "User Registration.";
     $this->view->headTitle($this->view->title, 'PREPEND');
     $form = new Form_Signup();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $formvalues = $form->getValues();
             $user = new Model_User();
             $db = $user->getAdapter();
             $db->beginTransaction();
             try {
                 $user->fill($formvalues);
                 $user->eStatus = 1;
                 $user->eAlerts = 1;
                 $user->eRights = 1;
                 $user->dRegDate = time();
                 // $user->sendActivationEmail();
                 $user->save();
                 $group = new Model_SubGroup();
                 $group->find('vGroupCodeId', $formvalues['iSGroupCode']);
                 $assign = new Model_SubGroupUserAssign();
                 $assign->iSGroupId = $group->iSGroupId;
                 $assign->iUserId = $user->iUserId;
                 $assign->save();
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollBack();
                 echo $e->getMessage();
             }
             $this->_helper->redirector('login');
         }
     }
     $this->view->form = $form;
 }
コード例 #24
0
ファイル: friendsuggestions.php プロジェクト: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        $friends = array();
        $suggestions = $this->user->find_friend_suggestions();
        if ($suggestions) {
            $randoms = array_rand($suggestions, min($this->limit, count($suggestions)));
            foreach ($randoms as $friend_id) {
                $friend = Model_User::find_user_light($friend_id);
                $friends[$friend['username']] = array('user' => $friend, 'score' => $suggestions[$friend_id]);
            }
            ?>

<ul class="media-list">
	<?php 
            foreach ($friends as $friend) {
                ?>

	<?php 
                echo new View_Users_Friend($friend['user'], $friend['score']);
                ?>

	<?php 
            }
            ?>
</ul>

<?php 
        } else {
            echo __('Darn, no friend suggestions available. You might want to consider adding some friends first?');
        }
        return ob_get_clean();
    }
コード例 #25
0
ファイル: UserTest.php プロジェクト: kenncapara/emaxx
 public function testUserSetup()
 {
     $u = new Model_User();
     $u->username = '******';
     $u->password = '******';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = '******';
     $u->password = '******';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = '******';
     $u->password = '******';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = '******';
     $u->password = '******';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = '******';
     $u->password = '******';
     $u->roles = array('user');
     $u->save();
     $u = new Model_User();
     $u->username = '******';
     $u->password = '******';
     $u->roles = array('admin');
     $u->save();
 }
コード例 #26
0
ファイル: Post.php プロジェクト: laiello/digitalus-cms
 public function openPost($postId)
 {
     $post = $this->find($postId)->current();
     if ($post) {
         $mdlContentNode = new Model_PageNode();
         $content = $mdlContentNode->fetchContentArray($post->id, null, null, $this->getDefaultLanguage());
         $objPost = new stdClass();
         $objPost->id = $post->id;
         $objPost->title = $post->name;
         $objPost->dateCreated = $post->create_date;
         $objPost->blogId = $post->parent_id;
         if (isset($content['teaser'])) {
             $objPost->teaser = $content['teaser'];
         } else {
             $objPost->teaser = null;
         }
         if (isset($content['content'])) {
             $objPost->content = $content['content'];
         } else {
             $objPost->content = null;
         }
         $mdlUser = new Model_User();
         $author = $mdlUser->find($post->name)->current();
         if ($author) {
             $objPost->author = $author->first_name . ' ' . $author->last_name;
         } else {
             $objPost->author = null;
         }
         $objPost->name = $post->name;
         return $objPost;
     } else {
         return null;
     }
 }
コード例 #27
0
 /**
  * Handle GET requests.
  */
 public function action_get()
 {
     try {
         if (is_numeric($id_user = $this->request->param('id'))) {
             $user = new Model_User($id_user);
             if ($user->loaded() and $user->status == Model_User::STATUS_ACTIVE) {
                 $res = $user->as_array();
                 $res['image'] = $user->get_profile_image();
                 //remove the hidden fields
                 foreach ($res as $key => $value) {
                     if (in_array($key, $this->_hidden_fields)) {
                         unset($res[$key]);
                     }
                 }
                 $this->rest_output(array('user' => $res));
             } else {
                 $this->_error(__('User not found'), 404);
             }
         } else {
             $this->_error(__('User not found'), 404);
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
         return;
     }
 }
コード例 #28
0
ファイル: Page.php プロジェクト: robsta/brightfamecms
 public function createPage($pageName, $parentId = 0, $contentTemplate = null, $showOnMenu = null)
 {
     if (empty($pageName)) {
         $pageName = $this->_defaultPageName;
     }
     if ($contentTemplate == null) {
         $contentTemplate = $this->_defaultTemplate;
     }
     if ($showOnMenu !== null) {
         if ($showOnMenu == true) {
             $makeMenuLinks = 1;
         } else {
             $makeMenuLinks = 0;
         }
     } else {
         $settings = new Model_SiteSettings();
         $makeMenuLinks = $settings->get('add_menu_links');
     }
     $u = new Model_User();
     $user = $u->getCurrentUser();
     if ($user) {
         $userId = $user->id;
     } else {
         $userId = 0;
     }
     //first create the new page
     $data = array('namespace' => $this->_namespace, 'create_date' => time(), 'author_id' => $userId, 'name' => $pageName, 'content_template' => $contentTemplate, 'parent_id' => $parentId, 'show_on_menu' => $makeMenuLinks);
     $this->insert($data);
     $id = $this->_db->lastInsertId();
     $this->_flushCache();
     //return the new page
     return $this->find($id)->current();
 }
コード例 #29
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('User Profile')));
     $seoname = $this->request->param('seoname', NULL);
     if ($seoname !== NULL) {
         $user = new Model_User();
         $user->where('seoname', '=', $seoname)->limit(1)->cached()->find();
         if ($user->loaded()) {
             $this->template->title = __('User Profile') . ' - ' . $user->name;
             //$this->template->meta_description = $user->name;//@todo phpseo
             $this->template->bind('content', $content);
             $ads = new Model_Ad();
             $ads = $ads->where('id_user', '=', $user->id_user)->where('status', '=', Model_Ad::STATUS_PUBLISHED)->order_by('created', 'desc')->cached()->find_all();
             // case when user dont have any ads
             if ($ads->count() == 0) {
                 $profile_ads = NULL;
             }
             $this->template->content = View::factory('pages/userprofile', array('user' => $user, 'profile_ads' => $ads));
         } else {
             //throw 404
             throw HTTP_Exception::factory(404, __('Page not found'));
         }
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
コード例 #30
0
 /**
  * 检测是否满足点单条件
  */
 private function _checkOrderCondition()
 {
     Tools::import('Model.User');
     $user = new Model_User();
     if (!$user->isSelectTable()) {
         Tools::alertMsg($this->_uMsg->errorPrompt[011], Tools::url('Default', 'Index'));
     }
 }