1: <?php
2: /*****************************************************************************************
3: * X2Engine Open Source Edition 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. or at email address [email protected].
25: *
26: * The interactive user interfaces in modified source and object code versions
27: * of this program must display Appropriate Legal Notices, as required under
28: * Section 5 of the GNU Affero General Public License version 3.
29: *
30: * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31: * these Appropriate Legal Notices must retain the display of the "Powered by
32: * X2Engine" logo. If the display of the logo is not reasonably feasible for
33: * technical reasons, the Appropriate Legal Notices must display the words
34: * "Powered by X2Engine".
35: *****************************************************************************************/
36:
37: /**
38: * This is the model class for table "x2_web_forms".
39: *
40: * @package application.modules.marketing.models
41: */
42: class WebForm extends CActiveRecord {
43: public static function model($className=__CLASS__) {
44: return parent::model($className);
45: }
46:
47: public function tableName() {
48: return 'x2_web_forms';
49: }
50:
51: public function rules() {
52: return array(
53: array('name, type, visibility, assignedTo, createdBy, updatedBy, createDate, lastUpdated', 'required'),
54: array('description, modelName, fields', 'safe'),
55: array('id, visibility, createDate, lastUpdated', 'numerical', 'integerOnly'=>true),
56: array('name, type, modelName', 'length', 'max'=>100),
57: array('generateLead', 'boolean'),
58: array('redirectUrl', 'url', 'defaultScheme' => 'http'),
59: array('description', 'length', 'max'=>255),
60: array('assignedTo, createdBy, updatedBy', 'length', 'max'=>20),
61: // The following rule is used by search().
62: // Please remove those attributes that should not be searched.
63: array('id, name, type, description, modelName, fields, params, css, header, visibility, assignedTo, createdBy, updatedBy, createDate, lastUpdated', 'safe', 'on'=>'search'),
64: );
65: }
66:
67: public function attributeLabels() {
68: return array(
69: 'id'=>Yii::t('marketing', 'ID'),
70: 'name'=>Yii::t('marketing', 'Name'),
71: 'type'=>Yii::t('marketing', 'Type'),
72: 'description'=>Yii::t('marketing', 'Description'),
73: 'modelName'=>Yii::t('marketing', 'Model Name'),
74: 'fields'=>Yii::t('marketing', 'Fields'),
75: 'params'=>Yii::t('marketing', 'Parameters'),
76: 'css'=>Yii::t('marketing', 'CSS'),
77: 'header'=>Yii::t('marketing', 'Header Code'),
78: 'visibility'=>Yii::t('marketing', 'Visibility'),
79: 'assignedTo'=>Yii::t('marketing', 'Assigned To'),
80: 'createdBy'=>Yii::t('marketing', 'Created By'),
81: 'updatedBy'=>Yii::t('marketing', 'Updated By'),
82: 'createDate'=>Yii::t('marketing', 'Create Date'),
83: 'lastUpdated'=>Yii::t('marketing', 'Last Updated'),
84: );
85: }
86:
87: protected function beforeSave() {
88: if (!empty($this->params)) {
89: $this->params = json_encode($this->params);
90: }
91: return parent::beforeSave();
92: }
93:
94: protected function afterFind() {
95: if (!empty($this->params)) {
96: $this->params = json_decode($this->params);
97: }
98: parent::afterFind();
99: }
100:
101: public function getDisplayName ($plural=true, $ofModule=true) {
102: return Yii::t('marketing', 'Web Form');
103: }
104:
105: }
106: ?>
107: