1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
37:
38: 39: 40: 41: 42: 43:
44: class EmailDropboxSettings extends JSONEmbeddedModel {
45:
46: public $alias = null;
47: public $createContact = 1;
48: public $zapLineBreaks = 0;
49: public $emptyContact = 1;
50: public $logging = 0;
51: public $ignoreEmptyName = 0;
52: public $caseFlag = 'case #';
53:
54: public function attributeLabels() {
55: return array(
56: 'alias' => Yii::t('admin', 'Email capture address'),
57: 'createContact' => Yii::t('admin', "Create contacts from emails"),
58: 'zapLineBreaks' => Yii::t('admin', 'Zap line breaks'),
59: 'emptyContact' => Yii::t('admin', 'Create contacts when first and last name are missing'),
60: 'logging' => Yii::t('admin', 'Enable logging'),
61: 'ignoreEmptyName' => Yii::t('admin','Ignore empty sender name in forwarded message parse'),
62: 'caseFlag' => Yii::t('admin','Case attachment flag')
63: );
64: }
65:
66: public function rules() {
67: return array(
68: array('alias','email','allowEmpty'=>true),
69: array('createContact,zapLineBreaks,emptyContact,logging,ignoreEmptyName','boolean'),
70: array('alias,caseFlag,createContact,zapLineBreaks,emptyContact,logging,ignoreEmptyName','safe'),
71: );
72: }
73:
74: public function attributeNames() {
75: return array_keys($this->attributeLabels());
76: }
77:
78: public function detailView() {
79:
80: }
81:
82: 83: 84: 85: 86: 87:
88: public function labelOptions($name,$htmlOptions) {
89: return array_merge(array('for'=>$this->resolveName($name)),$htmlOptions);
90: }
91:
92: public function modelLabel() {
93: return Yii::t('admin','Email Capture Settings');
94: }
95:
96: public function renderInputs() {
97: $htmlOptions = array('style'=>'display:inline-block;margin-right: 10px;');
98: echo CHtml::activeCheckBox($this,'createContact',$this->htmlOptions('createContact',$htmlOptions));
99: echo CHtml::activeLabel($this,'createContact',$this->labelOptions('createContact',$htmlOptions));
100: echo X2Html::hint(Yii::t('admin', 'If disabled, the email dropbox will ignore any emails that are to or from addresses not matching any contacts in X2Engine. If enabled, new contacts will be created automatically using name info contained in the email.'));
101: echo '<br />';
102: echo '<div style="margin-left:20px;'.((bool) $this->createContact ? '' : 'display:none').'" id="empty-contact">';
103: echo CHtml::activeCheckBox($this,'emptyContact',$this->htmlOptions('emptyContact',$htmlOptions));
104: echo CHtml::activeLabel($this,'emptyContact',$this->labelOptions('emptyContact',$htmlOptions));
105: echo X2Html::hint(Yii::t('admin', "If enabled, the email dropbox will create a new contact record associated with a new unique email address even if the first and last name cannot be found in the email. If disabled, it ignores all email that does not contain contacts' first and last names. This setting has no effect if {ccfe} is disabled.", array('{ccfe}' => '"' . Yii::t('admin', 'Create contacts from emails') . '"')));
106: echo '</div>';
107: echo CHtml::activeCheckBox($this,'zapLineBreaks',$this->htmlOptions('zapLineBreaks',$htmlOptions));
108: echo CHtml::activeLabel($this,'zapLineBreaks',$this->labelOptions('zapLineBreaks',$htmlOptions));
109: echo X2Html::hint(Yii::t('admin', 'If enabled, the mail parser will (when extracting the body of an email) attempt to clear the text of artificial line breaks induced by RFC email format specifications (which limit lines to 78 characters). If disabled, the email parser will not do this.'));
110: echo '<br />';
111: echo CHtml::activeCheckBox($this,'logging',$this->htmlOptions('logging',$htmlOptions));
112: echo CHtml::activeLabel($this,'logging',$this->labelOptions('logging',$htmlOptions));
113: echo X2Html::hint(Yii::t('admin', 'If enabled, the email dropbox will record email capture events in a log file in protected/runtime. This option is useful for troubleshooting but will take up some extra disk space on a system that captures a high volume of emails.'));
114: echo '<br />';
115: echo CHtml::activeCheckBox($this,'ignoreEmptyName',$this->htmlOptions('ignoreEmptyName',$htmlOptions));
116: echo CHtml::activeLabel($this,'ignoreEmptyName',$this->labelOptions('ignoreEmptyName',$htmlOptions));
117: echo X2Html::hint(Yii::t('admin', "If disabled, the import will exit and send an error message email if the forwarded message header does not contain the sender's full name."));
118: echo '<br />';
119: echo CHtml::activeLabel($this, 'caseFlag', $this->labelOptions('caseFlag', $htmlOptions));
120: echo CHtml::activeTextField($this, 'caseFlag', $this->htmlOptions('caseFlag', $htmlOptions));
121: echo X2Html::hint(Yii::t('admin', 'When sending an email, you can specify a case to attach the email to by putting this code, followed immediately by the case ID, into the email body before the forwarded message, or without any case ID to create a new case from the email.'));
122: echo '<br />';
123: echo CHtml::activeLabel($this,'alias',$this->labelOptions('alias',$htmlOptions));
124: echo CHtml::activeTextField($this,'alias',$this->htmlOptions('alias',$htmlOptions));
125: echo X2Html::hint(Yii::t('admin', 'The address to use as the sender when sending error notification emails, if no default is set for system notifications. By default, if left blank, the email dropbox will use the first addresses in the {tohf} or {cchf} field that contains {dbat}.', array('{tohf}' => 'To:', '{cchf}' => 'CC:', '{dbat}' => '"dropbox@"')));
126: echo '<br />';
127: echo "<script type=\"text/javascript\">
128: (function($) {
129: $(\"[name='".$this->resolveName('createContact')."']\").change(function() {
130: if($(this).is(':checked'))
131: $('#empty-contact').fadeIn(300);
132: else
133: $('#empty-contact').fadeOut(300);
134: }).each(function(){
135: if(!$(this).is(':checked'))
136: $('#empty-contact').hide();
137: else
138: $('#empty-contact').show();
139: });
140: })(jQuery);
141: </script>";
142: }
143:
144: }
145:
146: ?>
147: