1: <?php
2:
3: /*****************************************************************************************
4: * X2Engine Open Source Edition is a customer relationship management program developed by
5: * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
6: *
7: * This program is free software; you can redistribute it and/or modify it under
8: * the terms of the GNU Affero General Public License version 3 as published by the
9: * Free Software Foundation with the addition of the following permission added
10: * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11: * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
12: * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13: *
14: * This program is distributed in the hope that it will be useful, but WITHOUT
15: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16: * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17: * details.
18: *
19: * You should have received a copy of the GNU Affero General Public License along with
20: * this program; if not, see http://www.gnu.org/licenses or write to the Free
21: * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22: * 02110-1301 USA.
23: *
24: * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
25: * California 95067, USA. or at email address [email protected].
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: Yii::import('application.models.embedded.*');
39:
40: /**
41: * Authentication data for using a Google account to send email.
42: *
43: * Similar to EmailAccount but with certain details already filled in
44: * @package application.models.embedded
45: * @author Demitri Morgan <[email protected]>
46: */
47: class GMailAccount extends EmailAccount {
48:
49: public $email = '';
50: public $imapNoValidate = false;
51: public $imapPort = 993;
52: public $imapSecurity = 'ssl';
53: public $imapServer = 'imap.gmail.com';
54: public $password = '';
55: public $port = 587;
56: public $security = 'tls';
57: public $senderName = '';
58: public $server = 'smtp.gmail.com';
59: public $user = '';
60:
61: public function attributeLabels(){
62: return array(
63: 'senderName' => Yii::t('app','Sender Name'),
64: 'email' => Yii::t('app','Google ID'),
65: 'password' => Yii::t('app','Password'),
66: 'imapPort' => Yii::t('app','IMAP Port'),
67: 'imapServer' => Yii::t('app','IMAP Server'),
68: 'imapSecurity' => Yii::t('app','IMAP Security'),
69: 'imapNoValidate' => Yii::t('app','Disable SSL Validation'),
70: );
71: }
72:
73: public function modelLabel() {
74: return Yii::t('app','Google Email Account');
75: }
76:
77: public function renderInput ($attr) {
78: switch($attr){
79: case 'email':
80: echo '<p class="fieldhelp-thin-small">'.Yii::t('app', '([email protected])').
81: '</p>';
82: echo CHtml::activeTextField($this, $attr, $this->htmlOptions($attr));
83: break;
84: case 'password':
85: echo X2Html::x2ActivePasswordField ($this, $attr, $this->htmlOptions ($attr), true);
86: break;
87: default:
88: parent::renderInput ($attr);
89: }
90: }
91:
92: public function renderInputs(){
93: $this->password = null;
94: echo CHtml::activeLabel($this, 'senderName');
95: $this->renderInput ('senderName');
96: echo CHtml::activeLabel($this, 'email');
97: $this->renderInput ('email');
98: echo CHtml::activeLabel($this, 'password');
99: $this->renderInput ('password');
100: echo '<br/>';
101: echo '<br/>';
102: echo CHtml::tag ('h3', array (), Yii::t('app', 'IMAP Configuration'));
103: echo '<hr/>';
104: echo CHtml::activeLabel($this, 'imapPort');
105: $this->renderInput ('imapPort');
106: echo CHtml::activeLabel($this, 'imapSecurity');
107: $this->renderInput ('imapSecurity');
108: echo CHtml::activeLabel($this, 'imapNoValidate');
109: $this->renderInput ('imapNoValidate');
110: echo CHtml::activeLabel($this, 'imapServer');
111: $this->renderInput ('imapServer');
112: echo CHtml::errorSummary($this);
113: }
114:
115: public function rules(){
116: return array(
117: array('email','email'),
118: array('senderName,email,password', 'required'),
119: array('senderName,email,password,imapPort,imapSecurity,imapNoValidate,imapServer', 'safe'),
120: );
121: }
122:
123: }
124:
125: ?>
126: