当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Users::countUsers方法代码示例

本文整理汇总了PHP中Model_Users::countUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Users::countUsers方法的具体用法?PHP Model_Users::countUsers怎么用?PHP Model_Users::countUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Users的用法示例。


在下文中一共展示了Model_Users::countUsers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user_id')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     if (JO_Session::get('msg_success')) {
         $this->view->msg_error = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     }
     if (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $this->view->questions = $questions = Model_Quiz::getAllQuestions(0, 0, '', 'RAND()');
     $this->view->answers = $answers = Model_Quiz::getAllAnswers(0, 0, '', true);
     if ($request->isPost()) {
         $rightAnswers = 0;
         $user_answers = $request->getPost('answers');
         if (is_array($user_answers)) {
             foreach ($user_answers as $question => $answer) {
                 if (isset($answers[$question][$answer]) && $answers[$question][$answer]['right'] == 'true') {
                     $rightAnswers++;
                 }
             }
         }
         if ($rightAnswers > 0 && count($questions) == $rightAnswers) {
             $_SESSION['user']['quiz'] = 'true';
             JO_Session::set('quiz', 'true');
             Model_Users::updateQuiz(JO_Session::get('user_id'), 'true');
             JO_Session::set('msg_success', 'You have successfully completed the quiz');
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=upload'));
         } else {
             JO_Session::set('msg_error', 'You have to answer all questions correctly. You have ' . $rightAnswers . ' right answers from ' . $question . ' questions');
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz'));
         }
     }
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     $this->getLayout()->meta_title = $this->translate('Quiz');
     $this->getLayout()->meta_description = $this->translate('Quiz');
     $this->view->page_name = $this->translate('Quiz');
     /* CRUMBS */
     $this->view->crumbs = array();
     $this->view->crumbs[] = array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl());
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
开发者ID:noikiy,项目名称:PD,代码行数:49,代码来源:QuizController.php

示例2: indexAction

 public function indexAction()
 {
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     $pageID = $this->getRequest()->getRequest('page_id');
     $this->view->page = Model_Pages::get($pageID);
     if ($this->view->page['sub_of'] == 0) {
         $headPage = $this->view->page;
         $subPages = Model_Pages::getSubPages($pageID);
         //		if(!$subPages) {
         //			$this->view->usersCount = Model_Users::countUsers();
         //			$this->view->itemsCount = Model_Items::countItems();
         //		}
     } else {
         $headPage = Model_Pages::get($this->view->page['sub_of']);
         $subPages = Model_Pages::getSubPages($this->view->page['sub_of']);
         $crumbs = array();
         $parentPages = Model_Pages::getPageParents($this->view->page['sub_of']);
         if ($parentPages) {
             $cnt = count($parentPages);
             for ($i = 0; $i < $cnt; $i++) {
                 $crumbs[$i + 1] = array('name' => $parentPages[$i]['name'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&page_id=' . $parentPages[$i]['id'] . '&name=' . WM_Router::clearName($parentPages[$i]['name'])));
             }
         }
     }
     $this->view->crumbs = array(array('name' => $this->view->translate('Home'), 'href' => $this->getRequest()->getBaseUrl()));
     if (isset($crumbs)) {
         $this->view->crumbs += $crumbs;
     }
     if ($subPages) {
         $this->view->subPages[] = array('name' => $headPage['name'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&page_id=' . $headPage['id'] . '&name=' . WM_Router::clearName($headPage['name'])), 'is_selected' => $headPage['id'] == $pageID ? true : false);
         foreach ($subPages as $page) {
             $this->view->subPages[] = array('name' => $page['name'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&page_id=' . $page['id'] . '&name=' . WM_Router::clearName($page['name'])), 'is_selected' => $page['id'] == $pageID ? true : false);
         }
     }
     if (!$this->view->page) {
         $this->forward('error', 'error404');
     }
     $model_images = new Model_Images();
     $this->view->page['text'] = html_entity_decode($this->view->page['text'], ENT_QUOTES, 'utf-8');
     $this->view->page['text'] = $model_images->fixEditorText($this->view->page['text']);
     $this->getLayout()->meta_title = $this->view->page['meta_title'];
     $this->getLayout()->meta_description = $this->view->page['meta_description'];
     $this->getLayout()->meta_keywords = $this->view->page['meta_keywords'];
     $this->view->quiz_link = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=quiz');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
开发者ID:noikiy,项目名称:PD,代码行数:49,代码来源:PagesController.php

示例3: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $model_images = new Model_Images();
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     /* LAST ITEM */
     $lastItem = Model_Items::getLastItem();
     if ($lastItem) {
         $thumb = $model_images->resizeWidth($lastItem['theme_preview_thumbnail'], 200);
         $thumb_size = getimagesize($thumb);
         if ($thumb_size[1] > 161) {
             $image = new JO_GDThumb($thumb);
             $image->crop(0, 0, $thumb_size[0], 161);
             $image->save($thumb);
         }
         $this->view->lastItem = array('name' => $lastItem['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $lastItem['module'] . '&controller=items&item_id=' . $lastItem['id'] . '&name=' . $lastItem['name']), 'thumb' => $thumb);
     }
     /* FREE ITEM */
     $this->view->freeItems = '';
     $freeItems = Model_Items::getFreeFiles();
     if ($freeItems) {
         foreach ($freeItems as $fi) {
             $cats = explode(',', $fi['categories']);
             $cat_name = Helper_Items::getCategory($cats[1]);
             $thumb = $model_images->resizeWidth($fi['theme_preview_thumbnail'], JO_Registry::forceGet($fi['module'] . '_items_thumb_width'));
             $thumb_size = getimagesize($thumb);
             if ($thumb_size[1] > JO_Registry::forceGet($fi['module'] . '_items_thumb_height')) {
                 $image = new JO_GDThumb($thumb);
                 $image->crop(0, 0, $thumb_size[0], JO_Registry::forceGet($fi['module'] . '_items_thumb_height'));
                 $image->save($thumb);
             }
             $this->view->freeItems[] = array('href' => WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $fi['id'] . '&name=' . WM_Router::clearName($fi['name'])), 'thumb' => $thumb, 'cat_name' => $cat_name['name'], 'name' => $fi['name']);
         }
     }
     /* ITEMS */
     $this->view->items = array();
     $listType = $request->getParam('list_type');
     if (is_null($listType)) {
         $listType = 'recent';
     }
     $this->view->all_items = array('name' => $this->view->translate('View all items'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&action=' . $listType));
     switch ($listType) {
         case 'featured':
             JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri());
             $this->view->title_items = $this->view->translate('Featured Items');
             $featuredItems = Model_Items::getWeekly($request->getParam('category_filter'));
             if ($featuredItems) {
                 foreach ($featuredItems as $n => $item) {
                     if (!empty($item['demo_url'])) {
                         $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
                     }
                     $this->view->items[] = Helper_Items::returnViewIndex($item);
                 }
             }
             break;
         case 'author':
             JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri());
             $this->view->title_items = $this->view->translate('Featured Author');
             $this->view->author = Model_Users::getFeatUser();
             if ($this->view->author) {
                 $this->view->author['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username=' . $this->view->author['username']);
                 $this->view->author['userhref_pf'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username=' . $this->view->author['username']);
                 if ($this->view->author['avatar']) {
                     $this->view->author['avatar'] = $model_images->resize($this->view->author['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
                 } else {
                     $this->view->author['avatar'] = 'data/themes/images/avatar-author.png';
                 }
                 $this->view->items = array();
                 $items = Model_Items::getByUser($this->view->author['user_id'], 0, 11, false);
                 if (empty($items)) {
                     $items = array(0 => array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes'));
                 }
                 if ($items) {
                     foreach ($items as $n => $item) {
                         if (!empty($item['demo_url'])) {
                             $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
                         }
                         $this->view->items[] = Helper_Items::returnViewIndex($item);
                     }
                 }
             }
             $this->view->all_items = array('name' => $this->view->translate('View portfolio'), 'href' => $this->view->author['userhref_pf']);
             break;
         default:
             /* RECENT ITEMS */
             JO_Session::set('redirect', $request->getBaseUrl());
             $this->view->title_items = $this->view->translate('Recent Items');
             $recentItems = Model_Items::getRecent($request->getParam('category_filter'));
             if ($recentItems) {
                 foreach ($recentItems as $n => $item) {
                     if (!empty($item['demo_url'])) {
                         $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
                     }
                     $this->view->items[] = Helper_Items::returnViewIndex($item);
                 }
             }
             shuffle($this->view->items);
     }
     $this->view->listType = $listType;
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:PD,代码行数:101,代码来源:IndexController.php

示例4: reset_passwordAction

 public function reset_passwordAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user_id')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit'));
     }
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     $this->getLayout()->meta_title = $this->translate('Reset password');
     $this->getLayout()->meta_description = $this->translate('Reset password');
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     } elseif (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     } elseif (JO_Session::get('error')) {
         $this->view->error = JO_Session::get('error');
         JO_Session::clear('error');
     }
     if ($request->isPost() && $request->getPost('send')) {
         $this->view->username = trim($request->getPost('username'));
         $this->view->email = trim($request->getPost('email'));
         $this->view->error = array();
         if (empty($this->view->username)) {
             $this->view->error['username'] = $this->translate('You must type your username');
         } elseif (!preg_match('/^[a-zA-Z0-9_]+$/i', $this->view->username)) {
             $this->view->error['username'] = $this->translate('The username you have entered is not valid');
         }
         if (empty($this->view->email)) {
             $this->view->error['email'] = $this->translate('You must type your email');
         } elseif (!Model_Users::ValidMail($this->view->email)) {
             $this->view->error['email'] = $this->translate('You must type valid email');
         }
         if (empty($this->view->error)) {
             $user = Model_Users::getByEmail($this->view->email);
             if ($user) {
                 $alphabet = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9');
                 $password = '';
                 for ($i = 0; $i < 7; $i++) {
                     $random_number = rand(0, count($alphabet) - 1);
                     $password .= $alphabet[$random_number];
                 }
                 Model_Users::editPass($user['user_id'], $password);
                 $is_mail_smtp = JO_Registry::forceGet('config_mail_smtp');
                 $mail = new JO_Mail();
                 if ($is_mail_smtp) {
                     $mail->setSMTPParams(JO_Registry::forceGet('config_mail_smtp_host'), JO_Registry::forceGet('config_mail_smtp_port'), JO_Registry::forceGet('config_mail_smtp_user'), JO_Registry::forceGet('config_mail_smtp_password'));
                 }
                 $domain = $request->getDomain();
                 $mail->setFrom('noreply@' . $domain);
                 $mail->setReturnPath('noreply@' . $domain);
                 $mail->setSubject($this->translate('Reset password') . ' ' . JO_Registry::get('store_meta_title'));
                 $html = 'Your new password for ' . $user['username'] . ' is ' . $password;
                 $mail->setHTML($html);
                 $result = (int) $mail->send(array($request->getPost('email')), $is_mail_smtp ? 'smtp' : 'mail');
                 JO_Session::set('msg_success', $this->translate('Your new password was send to your email'));
             } else {
                 JO_Session::set('msg_error', $this->translate('No match found between your username and the email you have input '));
             }
         } else {
             JO_Session::set('error', $this->view->error);
         }
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=reset_password'));
     }
     $this->view->lost_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=lost_username');
     $this->view->new_account = WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
开发者ID:noikiy,项目名称:PD,代码行数:71,代码来源:UsersController.php


注:本文中的Model_Users::countUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。