[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /*+********************************************************************************** 4 * The contents of this file are subject to the vtiger CRM Public License Version 1.1 5 * ("License"); You may not use this file except in compliance with the License 6 * The Original Code is: vtiger CRM Open Source 7 * The Initial Developer of the Original Code is vtiger. 8 * Portions created by vtiger are Copyright (C) vtiger. 9 * All Rights Reserved. 10 ************************************************************************************/ 11 12 class Settings_Vtiger_Announcement_Model extends Vtiger_Base_Model { 13 14 const tableName = 'vtiger_announcement'; 15 16 17 public function save() { 18 $db = PearDatabase::getInstance(); 19 $currentUser = Users_Record_Model::getCurrentUserModel(); 20 $currentDate = date('Y-m-d H:i:s'); 21 $checkQuery = 'SELECT 1 FROM '.self::tableName.' WHERE creatorid=?'; 22 $result = $db->pquery($checkQuery,array($currentUser->getId())); 23 if($db->num_rows($result) > 0) { 24 $query = 'UPDATE '.self::tableName.' SET announcement=?,time=? WHERE creatorid=?'; 25 $params = array($this->get('announcement'),$db->formatDate($currentDate, true),$currentUser->getId()); 26 }else{ 27 $query = 'INSERT INTO '.self::tableName.' VALUES(?,?,?,?)'; 28 $params = array($currentUser->getId(),$this->get('announcement'),'announcement',$db->formatDate($currentDate, true)); 29 } 30 $db->pquery($query,$params); 31 } 32 33 public static function getInstanceByCreator(Users_Record_Model $user) { 34 $db = PearDatabase::getInstance(); 35 $query = 'SELECT * FROM '.self::tableName.' WHERE creatorid=?'; 36 $result = $db->pquery($query,array($user->getId())); 37 $instance = new self(); 38 if($db->num_rows($result) > 0) { 39 $row = $db->query_result_rowdata($result,0); 40 $instance->setData($row); 41 } 42 return $instance; 43 } 44 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |