[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Calendar/ -> iCalLastImport.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  require_once  'vtlib/Vtiger/Utils.php';
  11  
  12  class iCalLastImport {
  13  
  14      var $tableName = 'vtiger_ical_import';
  15      var $fields = array('id', 'userid', 'entitytype', 'crmid');
  16      var $fieldData = array();
  17      
  18  	function  __construct() {
  19      }
  20  
  21  	function clearRecords($userId) {
  22          $adb = PearDatabase::getInstance();
  23          if(Vtiger_Utils::CheckTable($this->tableName)) {
  24              $adb->pquery('DELETE FROM '.$this->tableName .' WHERE userid = ?', array($userId));
  25          }
  26      }
  27  
  28  	function setFields($data) {
  29          if(!empty($data)) {
  30              foreach($data as $name => $value) {
  31                  $this->fieldData[$name] = $value;
  32              }
  33          }
  34      }
  35  
  36  	function save() {
  37          $adb = PearDatabase::getInstance();
  38  
  39          if(count($this->fieldData) == 0) return;
  40          
  41          if(!Vtiger_Utils::CheckTable($this->tableName)) {
  42              Vtiger_Utils::CreateTable(
  43                  $this->tableName,
  44                  "(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  45                      userid INT NOT NULL,
  46                      entitytype VARCHAR(200) NOT NULL,
  47                      crmid INT NOT NULL)",
  48                  true);
  49          }
  50  
  51          $fieldNames = array_keys($this->fieldData);
  52          $fieldValues = array_values($this->fieldData);
  53          $adb->pquery('INSERT INTO '.$this->tableName.'('. implode(',',$fieldNames) .') VALUES ('. generateQuestionMarks($fieldValues) .')',
  54                  array($fieldValues));
  55      }
  56  
  57  	function undo($moduleName, $userId) {
  58          $adb = PearDatabase::getInstance();
  59          if(Vtiger_Utils::CheckTable($this->tableName)) {
  60              $result = $adb->pquery('UPDATE vtiger_crmentity SET deleted=1 WHERE crmid IN
  61                                  (SELECT crmid FROM '.$this->tableName .' WHERE userid = ? AND entitytype = ?)',
  62                          array($userId, $moduleName));
  63              return $adb->getAffectedRowCount($result);
  64          }
  65      }
  66  }
  67  ?>


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