[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Vtiger/models/ -> Notebook.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 Vtiger_Notebook_Model extends Vtiger_Widget_Model {
  12      
  13  	public function getContent() {
  14          $data = Zend_Json::decode(decode_html($this->get('data')));
  15          return $data['contents'];
  16          
  17      }
  18      
  19  	public function getLastSavedDate() {
  20          $data = Zend_Json::decode(decode_html($this->get('data')));
  21          return $data['lastSavedOn'];
  22          
  23      }
  24      
  25  	public function save($request) {
  26          $db = PearDatabase::getInstance();
  27          $content = $request->get('contents');
  28          $noteBookId = $request->get('widgetid');
  29          $date_var = date("Y-m-d H:i:s");
  30          $date = $db->formatDate($date_var, true);
  31          
  32          $dataValue = array();
  33          $dataValue['contents'] = $content;
  34          $dataValue['lastSavedOn'] = $date;
  35          
  36          $data = Zend_Json::encode((object) $dataValue);
  37          $this->set('data', $data);
  38          
  39          
  40          $db->pquery('UPDATE vtiger_module_dashboard_widgets SET data=? WHERE id=?', array($data, $noteBookId));
  41      }
  42  
  43  	public static function getUserInstance($widgetId) {
  44              $currentUser = Users_Record_Model::getCurrentUserModel();
  45  
  46              $db = PearDatabase::getInstance();
  47              
  48              $result = $db->pquery('SELECT vtiger_module_dashboard_widgets.* FROM vtiger_module_dashboard_widgets 
  49              INNER JOIN vtiger_links ON vtiger_links.linkid = vtiger_module_dashboard_widgets.linkid 
  50              WHERE linktype = ? AND vtiger_module_dashboard_widgets.id = ? AND vtiger_module_dashboard_widgets.userid = ?', array('DASHBOARDWIDGET', $widgetId, $currentUser->getId()));
  51              
  52              $self = new self();
  53              if($db->num_rows($result)) {
  54                  $row = $db->query_result_rowdata($result, 0);
  55                  $self->setData($row);
  56              }
  57          return $self;
  58          
  59      }
  60      
  61  }


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