[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Faq/ -> Faq.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header$
  17   * Description:  Defines the Account SugarBean Account entity with the necessary
  18   * methods and variables.
  19   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  20   * All Rights Reserved.
  21   * Contributor(s): ______________________________________..
  22   ********************************************************************************/
  23  
  24  // Faq is used to store vtiger_faq information.
  25  class Faq extends CRMEntity {
  26      var $log;
  27      var $db;
  28      var $table_name = "vtiger_faq";
  29      var $table_index= 'id';
  30      //fix for Custom Field for FAQ 
  31          var $tab_name = Array('vtiger_crmentity','vtiger_faq','vtiger_faqcf');  
  32          var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_faq'=>'id','vtiger_faqcomments'=>'faqid','vtiger_faqcf'=>'faqid');  
  33          var $customFieldTable = Array('vtiger_faqcf', 'faqid');  
  34  
  35      var $entity_table = "vtiger_crmentity";
  36  
  37      var $column_fields = Array();
  38  
  39      var $sortby_fields = Array('question','category','id');
  40  
  41      // This is the list of vtiger_fields that are in the lists.
  42      var $list_fields = Array(
  43                  'FAQ Id'=>Array('faq'=>'id'),
  44                  'Question'=>Array('faq'=>'question'),
  45                  'Category'=>Array('faq'=>'category'),
  46                  'Product Name'=>Array('faq'=>'product_id'),
  47                  'Created Time'=>Array('crmentity'=>'createdtime'),
  48                  'Modified Time'=>Array('crmentity'=>'modifiedtime')
  49                  );
  50  
  51      var $list_fields_name = Array(
  52                          'FAQ Id'=>'',
  53                          'Question'=>'question',
  54                          'Category'=>'faqcategories',
  55                          'Product Name'=>'product_id',
  56                          'Created Time'=>'createdtime',
  57                          'Modified Time'=>'modifiedtime'
  58                        );
  59      var $list_link_field= 'question';
  60  
  61      var $search_fields = Array(
  62                  'Account Name'=>Array('account'=>'accountname'),
  63                  'City'=>Array('accountbillads'=>'bill_city'),
  64                  );
  65  
  66      var $search_fields_name = Array(
  67                          'Account Name'=>'accountname',
  68                          'City'=>'bill_city',
  69                        );
  70  
  71      //Added these variables which are used as default order by and sortorder in ListView
  72      var $default_order_by = 'id';
  73      var $default_sort_order = 'DESC';
  74  
  75      var $mandatory_fields = Array('question','faq_answer','createdtime' ,'modifiedtime');
  76  
  77      // For Alphabetical search
  78      var $def_basicsearch_col = 'question';
  79  
  80      /**    Constructor which will set the column_fields in this object
  81       */
  82  	function Faq() {
  83          $this->log =LoggerManager::getLogger('faq');
  84          $this->log->debug("Entering Faq() method ...");
  85          $this->db = PearDatabase::getInstance();
  86          $this->column_fields = getColumnFields('Faq');
  87          $this->log->debug("Exiting Faq method ...");
  88      }
  89  
  90  	function save_module($module)
  91      {
  92          //Inserting into Faq comment table
  93          $this->insertIntoFAQCommentTable('vtiger_faqcomments', $module);
  94  
  95      }
  96  
  97  
  98      /** Function to insert values in vtiger_faqcomments table for the specified module,
  99          * @param $table_name -- table name:: Type varchar
 100          * @param $module -- module:: Type varchar
 101        */
 102  	function insertIntoFAQCommentTable($table_name, $module)
 103      {
 104          global $log;
 105          $log->info("in insertIntoFAQCommentTable  ".$table_name."    module is  ".$module);
 106              global $adb;
 107  
 108              $current_time = $adb->formatDate(date('Y-m-d H:i:s'), true);
 109  
 110          if($this->column_fields['comments'] != '')
 111              $comment = $this->column_fields['comments'];
 112          else
 113              $comment = $_REQUEST['comments'];
 114  
 115          if($comment != '')
 116          {
 117              $params = array('', $this->id, from_html($comment), $current_time);
 118              $sql = "insert into vtiger_faqcomments values(?, ?, ?, ?)";
 119              $adb->pquery($sql, $params);
 120          }
 121      }
 122  
 123  
 124      /*
 125       * Function to get the primary query part of a report
 126       * @param - $module Primary module name
 127       * returns the query string formed on fetching the related data for report for primary module
 128       */
 129  	function generateReportsQuery($module, $queryPlanner) {
 130                   $moduletable = $this->table_name;
 131                   $moduleindex = $this->table_index;
 132  
 133                   $query = "from $moduletable
 134                      inner join vtiger_crmentity on vtiger_crmentity.crmid=$moduletable.$moduleindex
 135                      left join vtiger_products as vtiger_products$module on vtiger_products$module.productid = vtiger_faq.product_id
 136                      left join vtiger_groups as vtiger_groups$module on vtiger_groups$module.groupid = vtiger_crmentity.smownerid
 137                      left join vtiger_users as vtiger_users$module on vtiger_users$module.id = vtiger_crmentity.smownerid
 138                      left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid
 139                      left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
 140                      left join vtiger_users as vtiger_lastModifiedBy".$module." on vtiger_lastModifiedBy".$module.".id = vtiger_crmentity.modifiedby";
 141                  return $query;
 142      }
 143  
 144      /*
 145       * Function to get the relation tables for related modules
 146       * @param - $secmodule secondary module name
 147       * returns the array with table names and fieldnames storing relations between module and this module
 148       */
 149  	function setRelationTables($secmodule){
 150          $rel_tables = array (
 151              "Documents" => array("vtiger_senotesrel"=>array("crmid","notesid"),"vtiger_faq"=>"id"),
 152          );
 153          return $rel_tables[$secmodule];
 154      }
 155  
 156  	function clearSingletonSaveFields() {
 157          $this->column_fields['comments'] = '';
 158      }
 159  
 160  }
 161  ?>


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