[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
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 Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model { 12 13 /** 14 * Function to get Id of this record instance 15 * @return <Integer> Id 16 */ 17 public function getId() { 18 return $this->get('id'); 19 } 20 21 /** 22 * Function to get Name of this record instance 23 * @return <String> Name 24 */ 25 public function getName() { 26 return ''; 27 } 28 29 /** 30 * Function to get module of this record instance 31 * @return <Settings_Webforms_Module_Model> $moduleModel 32 */ 33 public function getModule() { 34 return $this->module; 35 } 36 37 /** 38 * Function to set module instance to this record instance 39 * @param <Settings_Webforms_Module_Model> $moduleModel 40 * @return <Settings_Webforms_Record_Model> this record 41 */ 42 public function setModule($moduleModel) { 43 $this->module = $moduleModel; 44 return $this; 45 } 46 47 /** 48 * Function to get Edit view url 49 * @return <String> Url 50 */ 51 public function getEditViewUrl() { 52 $moduleModel = $this->getModule(); 53 return 'index.php?module='.$moduleModel->getName().'&parent='.$moduleModel->getParentName().'&view=Edit&record='.$this->getId(); 54 } 55 56 /** 57 * Function to get Delete url 58 * @return <String> Url 59 */ 60 public function getDeleteUrl() { 61 $moduleModel = $this->getModule(); 62 return 'index.php?module='.$moduleModel->getName().'&parent='.$moduleModel->getParentName().'&action=Delete&record='.$this->getId(); 63 } 64 65 /** 66 * Function to get record links 67 * @return <Array> list of link models <Vtiger_Link_Model> 68 */ 69 public function getRecordLinks() { 70 $links = array(); 71 $recordLinks = array( 72 array( 73 'linktype' => 'LISTVIEWRECORD', 74 'linklabel' => 'LBL_EDIT', 75 'linkurl' => "javascript:Settings_SMSNotifier_List_Js.triggerEdit(event, '".$this->getEditViewUrl()."');", 76 'linkicon' => 'icon-pencil' 77 ), 78 array( 79 'linktype' => 'LISTVIEWRECORD', 80 'linklabel' => 'LBL_DELETE', 81 'linkurl' => "javascript:Settings_SMSNotifier_List_Js.triggerDelete(event, '".$this->getDeleteUrl()."');", 82 'linkicon' => 'icon-trash' 83 ) 84 ); 85 foreach($recordLinks as $recordLink) { 86 $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink); 87 } 88 89 return $links; 90 } 91 92 /** 93 * Function to getDisplay value of every field 94 * @param <String> field name 95 * @return <String> field value 96 */ 97 public function getDisplayValue($key) { 98 $value = $this->get($key); 99 if ($key === 'isactive') { 100 if ($value) { 101 $value = 'Yes'; 102 } else { 103 $value = 'No'; 104 } 105 } 106 return $value; 107 } 108 109 /** 110 * Function to get Editable fields for this instance 111 * @return <Array> field models list <Settings_SMSNotifier_Field_Model> 112 */ 113 public function getEditableFields() { 114 $editableFieldsList = $this->getModule()->getEditableFields(); 115 return $editableFieldsList; 116 } 117 118 /** 119 * Function to save the record 120 */ 121 public function save() { 122 $db = PearDatabase::getInstance(); 123 124 $params = array($this->get('providertype'), $this->get('isactive'), $this->get('username'), $this->get('password'), $this->get('parameters')); 125 $id = $this->getId(); 126 127 if ($id) { 128 $query = 'UPDATE vtiger_smsnotifier_servers SET providertype = ?, isactive = ?, username = ?, password = ?, parameters = ? WHERE id = ?'; 129 array_push($params, $id); 130 } else { 131 $query = 'INSERT INTO vtiger_smsnotifier_servers(providertype, isactive, username, password, parameters) VALUES(?, ?, ?, ?, ?)'; 132 } 133 $db->pquery($query, $params); 134 } 135 136 /** 137 * Function to get record instance by using id and moduleName 138 * @param <Integer> $recordId 139 * @param <String> $qualifiedModuleName 140 * @return <Settings_Webforms_Record_Model> RecordModel 141 */ 142 static public function getInstanceById($recordId, $qualifiedModuleName) { 143 $db = PearDatabase::getInstance(); 144 $result = $db->pquery('SELECT * FROM vtiger_smsnotifier_servers WHERE id = ?', array($recordId)); 145 146 if ($db->num_rows($result)) { 147 $moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName); 148 $rowData = $db->query_result_rowdata($result, 0); 149 150 $recordModel = new self(); 151 $recordModel->setData($rowData)->setModule($moduleModel); 152 153 $parameters = Zend_Json::decode(decode_html($recordModel->get('parameters'))); 154 foreach ($parameters as $fieldName => $fieldValue) { 155 $recordModel->set($fieldName, $fieldValue); 156 } 157 158 return $recordModel; 159 } 160 return false; 161 } 162 163 /** 164 * Function to get clean record instance by using moduleName 165 * @param <String> $qualifiedModuleName 166 * @return <Settings_SMSNotifier_Record_Model> 167 */ 168 static public function getCleanInstance($qualifiedModuleName) { 169 $recordModel = new self(); 170 $moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName); 171 return $recordModel->setModule($moduleModel); 172 } 173 }
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 |