PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/x2engine/protected/models/Changelog.php

https://gitlab.com/e0/X2CRM
PHP | 154 lines | 62 code | 11 blank | 81 comment | 0 complexity | 11fbc3dc849441035db3b68e467ce804 MD5 | raw file
  1. <?php
  2. /***********************************************************************************
  3. * X2CRM is a customer relationship management program developed by
  4. * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License version 3 as published by the
  8. * Free Software Foundation with the addition of the following permission added
  9. * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  10. * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
  11. * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License along with
  19. * this program; if not, see http://www.gnu.org/licenses or write to the Free
  20. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  21. * 02110-1301 USA.
  22. *
  23. * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
  24. * California 95067, USA. on our website at www.x2crm.com, or at our
  25. * email address: contact@x2engine.com.
  26. *
  27. * The interactive user interfaces in modified source and object code versions
  28. * of this program must display Appropriate Legal Notices, as required under
  29. * Section 5 of the GNU Affero General Public License version 3.
  30. *
  31. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  32. * these Appropriate Legal Notices must retain the display of the "Powered by
  33. * X2Engine" logo. If the display of the logo is not reasonably feasible for
  34. * technical reasons, the Appropriate Legal Notices must display the words
  35. * "Powered by X2Engine".
  36. **********************************************************************************/
  37. /**
  38. * This is the model class for table "x2_changelog".
  39. *
  40. * The followings are the available columns in table 'x2_changelog':
  41. * @property integer $id
  42. * @property string $type
  43. * @property integer $itemId
  44. * @property string $changedBy
  45. * @property string $changed
  46. * @property string $fieldName
  47. * @property string $oldValue
  48. * @property string $newValue
  49. * @property boolean $diff
  50. * @property integer $timestamp
  51. */
  52. class Changelog extends CActiveRecord {
  53. /**
  54. * Returns the static model of the specified AR class.
  55. * @param string $className active record class name.
  56. * @return Changelog the static model class
  57. */
  58. public static function model($className=__CLASS__) {
  59. return parent::model($className);
  60. }
  61. /**
  62. * @return string the associated database table name
  63. */
  64. public function tableName() {
  65. return 'x2_changelog';
  66. }
  67. /**
  68. * @return array validation rules for model attributes.
  69. */
  70. public function rules() {
  71. return array();
  72. // array('type, itemId, changedBy', 'required'),
  73. // array('itemId, timestamp', 'numerical', 'integerOnly'=>true),
  74. // array('type, changedBy', 'length', 'max'=>50),
  75. // array('fieldName', 'length', 'max'=>255),
  76. // array('diff', 'boolean'),
  77. // array('changed, oldValue, newValue', 'safe'),
  78. // array('id, type, itemId, changedBy, changed, fieldName, oldValue, newValue, timestamp', 'safe', 'on'=>'search'),
  79. // );
  80. }
  81. public function behaviors() {
  82. return array(
  83. 'ERememberFiltersBehavior' => array(
  84. 'class' => 'application.components.behaviors.ERememberFiltersBehavior',
  85. 'defaults'=>array(),
  86. 'defaultStickOnClear'=>false
  87. ),
  88. );
  89. }
  90. /**
  91. * @return array relational rules.
  92. */
  93. public function relations() {
  94. return array();
  95. }
  96. /**
  97. * @return array customized attribute labels (name=>label)
  98. */
  99. public function attributeLabels() {
  100. return array(
  101. 'id' => Yii::t('admin','ID'),
  102. 'type' => Yii::t('admin','Type'),
  103. 'itemId' => Yii::t('admin','Item'),
  104. 'changedBy' => Yii::t('admin','Changed By'),
  105. 'changed' => Yii::t('admin','Changed'),
  106. 'fieldName' => Yii::t('admin','Field Name'),
  107. 'oldValue' => Yii::t('admin','Old Value'),
  108. 'newValue' => Yii::t('admin','New Value'),
  109. 'diff' => Yii::t('admin','Diff'),
  110. 'timestamp' => Yii::t('admin','Timestamp'),
  111. );
  112. }
  113. /**
  114. * Retrieves a list of models based on the current search/filter conditions.
  115. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  116. */
  117. public function search() {
  118. // Warning: Please modify the following code to remove attributes that
  119. // should not be searched.
  120. $criteria=new CDbCriteria;
  121. $parameters = array('limit'=>ceil(Profile::getResultsPerPage()));
  122. $criteria->scopes = array('findAll'=>array($parameters));
  123. $criteria->compare('id',$this->id);
  124. $criteria->compare('type',$this->type,true);
  125. $criteria->compare('itemId',$this->itemId);
  126. $criteria->compare('changedBy',$this->changedBy,true);
  127. $criteria->compare('recordName',$this->recordName,true);
  128. $criteria->compare('fieldName',$this->fieldName,true);
  129. $criteria->compare('oldValue',$this->oldValue,true);
  130. $criteria->compare('newValue',$this->newValue,true);
  131. $criteria->compare('diff',$this->diff,true);
  132. $criteria->compare('timestamp',$this->timestamp);
  133. return new SmartActiveDataProvider(get_class($this), array(
  134. 'sort'=>array(
  135. 'defaultOrder'=>'timestamp DESC',
  136. ),
  137. 'pagination'=>array(
  138. 'pageSize'=>Profile::getResultsPerPage(),
  139. ),
  140. 'criteria'=>$criteria,
  141. ));
  142. }
  143. }