[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/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  include_once ('config.php');
  25  require_once ('include/logging.php');
  26  require_once ('include/database/PearDatabase.php');
  27  require_once ('data/SugarBean.php');
  28  require_once ('data/CRMEntity.php');
  29  require_once ('include/utils/utils.php');
  30  
  31  // Faq is used to store vtiger_faq information.
  32  class Faq extends CRMEntity {
  33      var $log;
  34      var $db;
  35  
  36      var $tab_name = Array('vtiger_crmentity','vtiger_faq');
  37      var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_faq'=>'id','vtiger_faqcomments'=>'faqid');
  38                  
  39      var $entity_table = "vtiger_crmentity";
  40      
  41      var $column_fields = Array();
  42          
  43      var $sortby_fields = Array('question','category','id');        
  44  
  45      // This is the list of vtiger_fields that are in the lists.
  46      var $list_fields = Array(
  47                  'FAQ Id'=>Array('faq'=>'id'),
  48                  'Question'=>Array('faq'=>'question'),
  49                  'Category'=>Array('faq'=>'category'),
  50                  'Product Name'=>Array('faq'=>'product_id'), 
  51                  'Created Time'=>Array('crmentity'=>'createdtime'), 
  52                  'Modified Time'=>Array('crmentity'=>'modifiedtime') 
  53                  );
  54      
  55      var $list_fields_name = Array(
  56                          'FAQ Id'=>'',
  57                          'Question'=>'question',
  58                          'Category'=>'faqcategories',
  59                          'Product Name'=>'product_id',
  60                      'Created Time'=>'createdtime',
  61                      'Modified Time'=>'modifiedtime' 
  62                        );
  63      var $list_link_field= 'question';
  64  
  65      var $search_fields = Array(
  66                  'Account Name'=>Array('account'=>'accountname'),
  67                  'City'=>Array('accountbillads'=>'bill_city'), 
  68                  );
  69      
  70      var $search_fields_name = Array(
  71                          'Account Name'=>'accountname',
  72                          'City'=>'bill_city',
  73                        );
  74  
  75      //Added these variables which are used as default order by and sortorder in ListView
  76      var $default_order_by = 'id';
  77      var $default_sort_order = 'DESC';
  78  
  79      /**    Constructor which will set the column_fields in this object
  80       */
  81  	function Faq() {
  82          $this->log =LoggerManager::getLogger('faq');
  83          $this->log->debug("Entering Faq() method ...");
  84          $this->db = new PearDatabase();
  85          $this->column_fields = getColumnFields('Faq');
  86          $this->log->debug("Exiting Faq method ...");
  87      }
  88  
  89  	function save_module($module)
  90      {
  91          //Inserting into Faq comment table
  92          $this->insertIntoFAQCommentTable('vtiger_faqcomments', $module);
  93          
  94      }
  95  
  96  
  97      /** Function to insert values in vtiger_faqcomments table for the specified module,
  98          * @param $table_name -- table name:: Type varchar
  99          * @param $module -- module:: Type varchar
 100        */    
 101  	function insertIntoFAQCommentTable($table_name, $module)
 102      {
 103          global $log;
 104          $log->info("in insertIntoFAQCommentTable  ".$table_name."    module is  ".$module);
 105              global $adb;
 106  
 107              $current_time = $adb->formatDate(date('YmdHis'));
 108  
 109          if($this->column_fields['comments'] != '')
 110              $comment = $this->column_fields['comments'];
 111          else
 112              $comment = $_REQUEST['comments'];
 113  
 114          if($comment != '')
 115          {
 116              $comment = addslashes($comment);
 117              $sql = "insert into vtiger_faqcomments values('',".$this->id.",'".$comment."',".$current_time.")";    
 118              $adb->query($sql);
 119          }
 120      }    
 121      
 122  
 123      /**     Function to get the list of comments for the given FAQ id
 124           *      @param  int  $faqid - FAQ id
 125       *      @return list $list - return the list of comments and comment informations as a html output where as these comments and comments informations will be formed in div tag.
 126          **/    
 127  	function getFAQComments($faqid)
 128      {
 129          global $log;
 130          $log->debug("Entering getFAQComments(".$faqid.") method ...");
 131          global $mod_strings;
 132          $sql = "select * from vtiger_faqcomments where faqid=".$faqid;
 133          $result = $this->db->query($sql);
 134          $noofrows = $this->db->num_rows($result);
 135  
 136          if($noofrows == 0)
 137          {
 138              $log->debug("Exiting getFAQComments method ...");
 139              return '';
 140          }
 141  
 142          $list .= '<div style="overflow: auto;height:200px;width:100%;">';
 143          for($i=0;$i<$noofrows;$i++)
 144          {
 145              $comment = $this->db->query_result($result,$i,'comments');
 146              $createdtime = $this->db->query_result($result,$i,'createdtime');
 147              if($comment != '')
 148              {
 149                  //this div is to display the comment
 150                  $list .= '<div valign="top" style="width:99%;padding-top:10px;" class="dataField">'.make_clickable(nl2br($comment)).'</div>';
 151                  
 152                  //this div is to display the created time
 153                  $list .= '<div valign="top" style="width:99%;border-bottom:1px dotted #CCCCCC;padding-bottom:5px;" class="dataLabel"><font color=darkred>'.$mod_strings['Created Time'];
 154                  $list .= ' : '.$createdtime.'</font></div>';
 155              }
 156          }
 157          $list .= '</div>';
 158          $log->debug("Exiting getFAQComments method ...");
 159          return $list;
 160      }
 161      
 162  
 163  }
 164  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7