[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/ListView/ -> RelatedListViewSession.php (source)

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4  * ("License"); You may not use this file except in compliance with the License
   5  * The Original Code is:  vtiger CRM Open Source
   6  * The Initial Developer of the Original Code is vtiger.
   7  * Portions created by vtiger are Copyright (C) vtiger.
   8  * All Rights Reserved.
   9  *
  10  ********************************************************************************/
  11  
  12  require_once ('include/logging.php');
  13  require_once ('include/ListView/ListViewSession.php');
  14  
  15  /**initializes Related ListViewSession
  16   * Portions created by vtigerCRM are Copyright (C) vtigerCRM.
  17   * All Rights Reserved.
  18   */
  19  class RelatedListViewSession {
  20  
  21      var $module = null;
  22      var $start = null;
  23      var $sorder = null;
  24      var $sortby = null;
  25      var $page_view = null;
  26  
  27  	function RelatedListViewSession() {
  28          global $log,$currentModule;
  29          $log->debug("Entering RelatedListViewSession() method ...");
  30  
  31          $this->module = $currentModule;
  32          $this->start =1;
  33      }
  34  
  35  	public static function addRelatedModuleToSession($relationId, $header) {
  36          global $currentModule;
  37          $_SESSION['relatedlist'][$currentModule][$relationId] = $header;
  38          $start = RelatedListViewSession::getRequestStartPage();
  39          RelatedListViewSession::saveRelatedModuleStartPage($relationId, $start);
  40      }
  41  
  42  	public static function removeRelatedModuleFromSession($relationId, $header) {
  43          global $currentModule;
  44  
  45          unset($_SESSION['relatedlist'][$currentModule][$relationId]);
  46      }
  47  
  48  	public static function getRelatedModulesFromSession() {
  49          global $currentModule;
  50  
  51          $allRelatedModuleList = isPresentRelatedLists($currentModule);
  52          $moduleList = array();
  53          if(is_array($_SESSION['relatedlist'][$currentModule])){
  54              foreach ($allRelatedModuleList as $relationId=>$label) {
  55                  if(array_key_exists($relationId, $_SESSION['relatedlist'][$currentModule])){
  56                      $moduleList[] = $_SESSION['relatedlist'][$currentModule][$relationId];
  57                  }
  58              }
  59          }
  60          return $moduleList;
  61      }
  62  
  63  	public static function saveRelatedModuleStartPage($relationId, $start) {
  64          global $currentModule;
  65  
  66          $_SESSION['rlvs'][$currentModule][$relationId]['start'] = $start;
  67      }
  68  
  69  	public static function getCurrentPage($relationId) {
  70          global $currentModule;
  71  
  72          if(!empty($_SESSION['rlvs'][$currentModule][$relationId]['start'])){
  73              return $_SESSION['rlvs'][$currentModule][$relationId]['start'];
  74          }
  75          return 1;
  76      }
  77  
  78  	public static function getRequestStartPage(){
  79          $start = $_REQUEST['start'];
  80          if(!is_numeric($start)){
  81              $start = 1;
  82          }
  83          if($start < 1){
  84              $start = 1;
  85          }
  86          $start = ceil($start);
  87          return $start;
  88      }
  89  
  90  	public static function getRequestCurrentPage($relationId, $query) {
  91          global $list_max_entries_per_page, $adb;
  92  
  93          $start = 1;
  94          if(!empty($_REQUEST['start'])){
  95              $start = $_REQUEST['start'];
  96              if($start == 'last'){
  97                  $count_result = $adb->query( Vtiger_Functions::mkCountQuery( $query));
  98                  $noofrows = $adb->query_result($count_result,0,"count");
  99                  if($noofrows > 0){
 100                      $start = ceil($noofrows/$list_max_entries_per_page);
 101                  }
 102              }
 103              if(!is_numeric($start)){
 104                  $start = 1;
 105              }elseif($start < 1){
 106                  $start = 1;
 107              }
 108              $start = ceil($start);
 109          }else {
 110              $start = RelatedListViewSession::getCurrentPage($relationId);
 111          }
 112          return $start;
 113      }
 114  
 115  }
 116  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1