[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/EmailTemplates/models/ -> Record.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  class EmailTemplates_Record_Model extends Vtiger_Record_Model {
  12      
  13      /**

  14       * Function to get the id of the record

  15       * @return <Number> - Record Id

  16       */
  17  	public function getId() {
  18          return $this->get('templateid');
  19      }
  20      
  21      /**

  22       * Function to set the id of the record

  23       * @param <type> $value - id value

  24       * @return <Object> - current instance

  25       */
  26  	public function setId($value) {
  27          return $this->set('templateid',$value);
  28      }
  29      
  30      /**

  31       * Function to delete the email template

  32       * @param type $recordIds

  33       */
  34  	public function delete(){
  35          $this->getModule()->deleteRecord($this);
  36      }
  37      
  38      /**

  39       * Function to delete all the email templates

  40       * @param type $recordIds

  41       */
  42  	public function deleteAllRecords(){
  43          $this->getModule()->deleteAllRecords();
  44      }
  45      
  46      /**

  47       * Function to get template fields

  48       * To get the fields from module, which has the email field

  49       * @return <arrray> template fields

  50       */
  51  	public function getEmailTemplateFields(){
  52          return $this->getModule()->getAllModuleEmailTemplateFields();
  53      }
  54      
  55      /**

  56       * Function to get the Email Template Record

  57       * @param type $record

  58       * @return <EmailTemplate_Record_Model>

  59       */
  60      
  61  	public function getTemplateData($record){
  62          return $this->getModule()->getTemplateData($record);
  63      }
  64      
  65      /**

  66       * Function to get the Detail View url for the record

  67       * @return <String> - Record Detail View Url

  68       */
  69  	public function getDetailViewUrl() {
  70          $module = $this->getModule();
  71          return 'index.php?module='.$this->getModuleName().'&view='.$module->getDetailViewName().'&record='.$this->getId();
  72      }
  73      
  74      /**

  75       * Function to get the instance of Custom View module, given custom view id

  76       * @param <Integer> $cvId

  77       * @return CustomView_Record_Model instance, if exists. Null otherwise

  78       */
  79  	public static function getInstanceById($templateId, $module=null) {
  80          $db = PearDatabase::getInstance();
  81          $sql = 'SELECT * FROM vtiger_emailtemplates WHERE templateid = ?';
  82          $params = array($templateId);
  83          $result = $db->pquery($sql, $params);
  84          if($db->num_rows($result) > 0) {
  85              $row = $db->query_result_rowdata($result, 0);
  86              $recordModel = new self();
  87              return $recordModel->setData($row)->setModule('EmailTemplates');
  88          }
  89          return null;
  90      }
  91      
  92  }


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