File indexing completed on 2024-12-22 05:33:31

0001 <?php
0002 
0003 /**
0004  *  ocs-webserver
0005  *
0006  *  Copyright 2016 by pling GmbH.
0007  *
0008  *    This file is part of ocs-webserver.
0009  *
0010  *    This program is free software: you can redistribute it and/or modify
0011  *    it under the terms of the GNU Affero General Public License as
0012  *    published by the Free Software Foundation, either version 3 of the
0013  *    License, or (at your option) any later version.
0014  *
0015  *    This program is distributed in the hope that it will be useful,
0016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *    GNU Affero General Public License for more details.
0019  *
0020  *    You should have received a copy of the GNU Affero General Public License
0021  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022  **/
0023 class CommunityController extends Local_Controller_Action_DomainSwitch
0024 {
0025 
0026     public function indexAction()
0027     {
0028         // $allDomainCatIds =
0029         //     Zend_Registry::isRegistered('store_category_list') ? Zend_Registry::get('store_category_list') : null;
0030 
0031         // $modelCategories = new Default_Model_DbTable_ProjectCategory();
0032         // if (isset($allDomainCatIds)) {
0033         //     $this->view->categories = $allDomainCatIds;
0034         // } else {
0035         //     $this->view->categories = $modelCategories->fetchMainCatIdsOrdered();
0036         // }        
0037         $this->view->noheader = true;
0038     }
0039 
0040     public function indexreactAction()
0041     {
0042         $tableMembers = new Default_Model_Project();        
0043         $modelInfo = new Default_Model_Info();
0044         $countProjects = $tableMembers->fetchTotalProjectsCount(false);
0045         $countActiveMembers = $modelInfo->countTotalActiveMembers();   
0046         $isadmin = 0;
0047         if(Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') {
0048             $isadmin = 1;
0049         }
0050 
0051         $json_data = array(
0052             'status'     => 'ok',                            
0053             'data'       => array(
0054                 'countProjects' => $countProjects,
0055                 'countActiveMembers' => $countActiveMembers,
0056                 'isadmin' => $isadmin
0057             )
0058         );       
0059         $this->view->json_data = $json_data;
0060     }
0061 
0062 
0063     public function getjsonAction()
0064     {
0065         $this->_helper->layout->disableLayout();
0066         $this->_helper->viewRenderer->setNoRender(true);
0067         $event = $this->getParam('e'); 
0068         $modelInfo = new Default_Model_Info();
0069         switch($event) {
0070               case 'supporters':            
0071                 $json_data = array(
0072                     'status'     => 'ok',                            
0073                     'data'       => $modelInfo->getNewActiveSupportersForSectionAll(100)
0074                 );  
0075                 $this->view->json_data = $json_data;
0076                 break;
0077               case 'newmembers':
0078                 $json_data = array(
0079                     'status'     => 'ok',                            
0080                     'data'       => $modelInfo->getNewActiveMembers(100)
0081                 );  
0082                 $this->view->json_data = $json_data;
0083                 break;
0084               case 'topmembers':
0085                 $json_data = array(
0086                     'status'     => 'ok',                            
0087                     'data'       => $modelInfo->getTopScoreUsers(100)
0088                 );  
0089                 $this->view->json_data = $json_data;
0090                 break;
0091                case 'plingedprojects':
0092                 $json_data = array(
0093                     'status'     => 'ok',                            
0094                     'data'       => $modelInfo->getNewActivePlingProduct(100)
0095                 );  
0096                 $this->view->json_data = $json_data;
0097                 break;
0098                 case 'mostplingedcreators':
0099                  $pageLimit = 100;
0100                  $page = (int)$this->getParam('page', 1);                            
0101                  $nopage = (int)$this->getParam('nopage', 0);                                             
0102                  $json_data = array(
0103                      'status'     => 'ok',     
0104                      'pageLimit'  => $pageLimit, 
0105                      'page'       => $page,
0106                      'nopage'     => $nopage,
0107                      'totalcount' => $modelInfo->getMostPlingedCreatorsTotalCnt(),
0108                      'data'       => $modelInfo->getMostPlingedCreators($pageLimit, ($page - 1) * $pageLimit)
0109                  );  
0110                  $this->view->json_data = $json_data;
0111                  break;
0112                  case 'mostplingedproducts':
0113                   $pageLimit = 100;
0114                   $page = (int)$this->getParam('page', 1);                            
0115                   $nopage = (int)$this->getParam('nopage', 0);                                             
0116                   $json_data = array(
0117                       'status'     => 'ok',     
0118                       'pageLimit'  => $pageLimit, 
0119                       'page'       => $page,
0120                       'nopage'     => $nopage,
0121                       'totalcount' => $modelInfo->getMostPlingedProductsTotalCnt(),
0122                       'data'       => $modelInfo->getMostPlingedProducts($pageLimit, ($page - 1) * $pageLimit)
0123                   );  
0124                   $this->view->json_data = $json_data;
0125                   break;
0126                   case 'toplistmembers':
0127                    $pageLimit = 100;
0128                    $page = (int)$this->getParam('page', 1);                            
0129                    $nopage = (int)$this->getParam('nopage', 0);                                             
0130                    $json_data = array(
0131                        'status'     => 'ok',     
0132                        'pageLimit'  => $pageLimit, 
0133                        'page'       => $page,
0134                        'nopage'     => $nopage,
0135                        'totalcount' => 1000,
0136                        'data'       => $modelInfo->getTopScoreUsers($pageLimit, ($page - 1) * $pageLimit)
0137                    );  
0138                    $this->view->json_data = $json_data;
0139                    break;
0140           default:
0141            
0142         } 
0143 
0144         $this->_helper->json($this->view->json_data);      
0145         
0146     }
0147 
0148     public function supportersAction()
0149     {
0150         $this->_helper->layout->disableLayout();
0151         $modelInfo = new Default_Model_Info();
0152         $this->view->supporters = $modelInfo->getSupporters(100);
0153     }
0154     public function newmembersAction()
0155     {
0156         $this->_helper->layout->disableLayout();
0157         $modelInfo = new Default_Model_Info();
0158         $this->view->users = $modelInfo->getNewActiveMembers(100);
0159     }
0160     public function topmembersAction()
0161     {
0162         $this->_helper->layout->disableLayout();
0163         $modelInfo = new Default_Model_Info();
0164         $this->view->users = $modelInfo->getTopScoreUsers(100);
0165     }
0166     public function plingedprojectsAction()
0167     {
0168         $this->_helper->layout->disableLayout();
0169         $modelInfo = new Default_Model_Info();
0170         $this->view->projects = $modelInfo->getNewActivePlingProduct(100);
0171     }
0172     public function mostplingedcreatorsAction()
0173     {
0174         $this->_helper->layout->disableLayout();
0175         $modelInfo = new Default_Model_Info();        
0176         $pageLimit = 100;
0177         $page = (int)$this->getParam('page', 1);                            
0178         $nopage = (int)$this->getParam('nopage', 0);                            
0179         $modelInfo = new Default_Model_Info(); 
0180         $this->view->page =$page;       
0181         $this->view->nopage =$nopage;       
0182         $this->view->pageLimit =$pageLimit;
0183         $this->view->totalcount = $modelInfo->getMostPlingedCreatorsTotalCnt();        
0184         $this->view->users = $modelInfo->getMostPlingedCreators($pageLimit, ($page - 1) * $pageLimit);
0185 
0186     }
0187     public function mostplingedproductsAction()
0188     {
0189         $this->_helper->layout->disableLayout();
0190         $pageLimit = 100;
0191         $page = (int)$this->getParam('page', 1);                            
0192         $nopage = (int)$this->getParam('nopage', 0);                            
0193         $modelInfo = new Default_Model_Info(); 
0194         $this->view->page =$page;       
0195         $this->view->nopage =$nopage;       
0196         $this->view->pageLimit =$pageLimit;
0197         $this->view->totalcount = $modelInfo->getMostPlingedProductsTotalCnt();        
0198         $this->view->projects = $modelInfo->getMostPlingedProducts($pageLimit, ($page - 1) * $pageLimit);
0199     }
0200 
0201     public function toplistmembersAction()
0202     {
0203         $this->_helper->layout->disableLayout();
0204         $modelInfo = new Default_Model_Info();        
0205         $pageLimit = 100;
0206         $page = (int)$this->getParam('page', 1);                            
0207         $nopage = (int)$this->getParam('nopage', 0);                            
0208         $modelInfo = new Default_Model_Info(); 
0209         $this->view->page =$page;       
0210         $this->view->nopage =$nopage;       
0211         $this->view->pageLimit =$pageLimit;
0212         $this->view->totalcount = 1000;      
0213         $this->view->users = $modelInfo->getTopScoreUsers($pageLimit, ($page - 1) * $pageLimit);
0214     }
0215 
0216 }