Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
barryo committed Apr 5, 2012
2 parents 1d035d7 + 94ffd50 commit c0876b20b271d58eab527cdce4ba9c290571db5d
View
@@ -1,3 +1,12 @@
+2.2.0 2012-04-05
+ - fix: access restrictions - previous implementation would have broken SMTP
+ auth if one was using it. Added access_restriction_type to
+ application.ini.dist.
+ See: https://github.com/opensolutions/ViMbAdmin/wiki/POP3-IMAP-Access-Restriction
+
+ - IMPORTANT: this update requires a database migration
+ See: https://github.com/opensolutions/ViMbAdmin/wiki/Update-Instructions
+
2.1.0 2012-04-03
IMPORTANT: this update requires a database migration
@@ -46,6 +46,11 @@ defaults.mailbox.gid = 2000
;
allow_access_restriction = false
+; specify the options which should be allowed for access restrictions
+access_restriction_type.smtp = "SMTP"
+access_restriction_type.imap = "IMAP"
+access_restriction_type.pop3 = "POP3"
+
; Set the homedir and maildir values in the mailbox table where the
; following substitutions apply:
;
@@ -269,7 +274,7 @@ resources.doctrine.extensions_path = APPLICATION_PATH "/../library/DoctrineExten
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Database schema migration version - DO NOT CHANGE
-migration_version = 1
+migration_version = 2
resources.namespace.checkip = 1
@@ -332,10 +332,10 @@ public function editAction()
$domainList = DomainTable::getDomains( $this->getAdmin() );
- if( isset( $this->_options['allow_access_restriction'] ) )
- $editForm = new ViMbAdmin_Form_Mailbox_Edit( null, $domainList, $this->_options['defaults']['mailbox']['min_password_length'], $this->_options['allow_access_restriction'] );
+ if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] )
+ $this->view->editForm = $editForm = new ViMbAdmin_Form_Mailbox_Edit( null, $domainList, $this->_options['defaults']['mailbox']['min_password_length'], $this->_options['allow_access_restriction'], $this->_options['access_restriction_type'] );
else
- $editForm = new ViMbAdmin_Form_Mailbox_Edit( null, $domainList, $this->_options['defaults']['mailbox']['min_password_length'] );
+ $this->view->editForm = $editForm = new ViMbAdmin_Form_Mailbox_Edit( null, $domainList, $this->_options['defaults']['mailbox']['min_password_length'] );
$editForm->setDefaults( $this->_mailbox->toArray() );
@@ -351,6 +351,28 @@ public function editAction()
{
if( $editForm->isValid( $_POST ) )
{
+ if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] )
+ {
+ if( $editForm->getValue( 'access_restr' ) && !isset( $_POST['type'] ) )
+ {
+ $editForm->getElement( 'access_restr' )->addError( "You must select type if you allowing access restrictions." );
+ if( $this->_mailbox['id'] )
+ $editForm->getElement( 'local_part' )->setValue( $this->_mailbox['local_part'] );
+ $this->view->restrictions = array();
+
+ if( $this->_domain )
+ {
+ $editForm->getElement( 'domain' )->setValue( $this->_domain['id'] );
+ $this->view->domain = $this->_domain;
+ }
+
+ if( !$this->_getParam( 'helper', true ) )
+ $this->view->modal = true;
+
+ return;
+ }
+ }
+
do
{
// do we have a domain
@@ -448,7 +470,8 @@ public function editAction()
{
$this->_mailbox['quota'] = $this->_domain['quota'];
$this->addMessage(
- _( "Mailbox quota set to " ) . $this->_domain['quota'],
+ _( "Mailbox qif( !$this->_getParam( 'helper', true ) )
+ $this->view->modal = trueuota set to " ) . $this->_domain['quota'],
ViMbAdmin_Message::ALERT
);
}
@@ -457,10 +480,12 @@ public function editAction()
if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] )
{
if( $editForm->getValue( 'access_restr' ) )
- $this->_mailbox['access_restriction'] = $editForm->getValue( 'access_restriction' );
+ $this->_mailbox['access_restriction'] = implode(",", $_POST['type']);
else
- $this->_mailbox['access_restriction'] = Mailbox::ACCESS_RESTR_BOTH;
+ $this->_mailbox['access_restriction'] = "ALL";
}
+ else
+ $this->_mailbox['access_restriction'] = "ALL";
$this->_mailbox->save();
@@ -498,10 +523,9 @@ public function editAction()
}
else
{
+ $this->view->restrictions = $_POST["type"];
if( !$this->_getParam( 'helper', true ) )
- {
$this->view->modal = true;
- }
}
}
@@ -512,10 +536,15 @@ public function editAction()
}
if( isset( $this->_options['allow_access_restriction'] ) && $this->_options['allow_access_restriction'] )
- if( $this->_mailbox['access_restriction'] != Mailbox::ACCESS_RESTR_BOTH )
+ if( $this->_mailbox && $this->_mailbox['access_restriction'] != "ALL" && $this->_mailbox['access_restriction'] != "BOTH" )
+ {
$editForm->getElement( 'access_restr' )->setAttrib( "checked", "checked" );
- $this->view->editForm = $editForm;
+ if( strpos( $this->_mailbox['access_restriction'], "," ) )
+ $this->view->restrictions = explode( ",", $this->_mailbox['access_restriction'] );
+ else
+ $this->view->restrictions = array( $this->_mailbox['access_restriction'] );
+ }
}
@@ -39,22 +39,6 @@
*/
class Mailbox extends BaseMailbox
{
- /**
- * Const values to defines access restriction options.
- */
- const ACCESS_RESTR_BOTH = 'BOTH';
- const ACCESS_RESTR_IMAP = 'IMAP';
- const ACCESS_RESTR_POP3 = 'POP3';
-
- /**
- * Array for define the names of const variables
- * which defining access restriction
- */
- public static $MAILBOX_ACCESS_RESTR_TEXT = array(
- Mailbox::ACCESS_RESTR_IMAP => 'IMAP ONLY',
- Mailbox::ACCESS_RESTR_POP3 => 'POP3 ONLY'
- );
-
/**
* Set the maildir
*
@@ -5,6 +5,7 @@
*
* This class has been auto-generated by the Doctrine ORM Framework
*
+ * @property integer $id
* @property integer $version
*
* @package ##PACKAGE##
@@ -17,15 +18,24 @@
public function setTableDefinition()
{
$this->setTableName('migration_version');
+ $this->hasColumn('id', 'integer', 8, array(
+ 'type' => 'integer',
+ 'autoincrement' => true,
+ 'primary' => true,
+ 'length' => '8',
+ ));
$this->hasColumn('version', 'integer', 4, array(
'type' => 'integer',
- 'length' => 4,
- 'fixed' => false,
+ 'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
+ 'length' => '4',
));
+
+ $this->option('collate', 'utf8_general_ci');
+ $this->option('charset', 'utf8');
}
public function setUp()
@@ -100,12 +100,26 @@
{include file='form/element-checkbox.phtml' ielement=$element->active}
{if isset( $element->access_restr ) }
{include file='form/element-checkbox.phtml' ielement=$element->access_restr}
- <div id="access_restriction_div" style="display:none; margin-top: -25px; margin-left: 20px;">
+ <div id="access_restriction_div" class="dontdisplay" style="margin-top: -30px;">
<fieldset class="control-group">
- <label class="control-label">&nbsp;</label>
- <div id="ar_controls" class="controls" style="position: fixed; z-index: 2;">
- {$element->access_restriction}
- </div>
+ <label class="control-label" style="margin-right: 40px;">&nbsp;</label>
+ <div class="row-fluid" >
+ <div class="offset2 span2">
+ {if isset( $group1 ) && count( $group1 ) > 0 }
+ {include file='mailbox/form/restriction-checkboxlist.phtml' ielements=$group1}
+ {/if}
+ </div>
+ <div class="offset2 span2">
+ {if isset( $group2 ) && count( $group2 ) > 0 }
+ {include file='mailbox/form/restriction-checkboxlist.phtml' ielements=$group2}
+ {/if}
+ </div>
+ <div class="offset2 span2">
+ {if isset( $group3 ) && count( $group3 ) > 0 }
+ {include file='mailbox/form/restriction-checkboxlist.phtml' ielements=$group3}
+ {/if}
+ </div>
+ </div>
</fieldset>
</div>
{/if}
@@ -129,11 +143,36 @@
$(document).ready(function()
{
+ {if isset( $restrictions ) && is_array( $restrictions ) }
+ {if isset( $group1 ) && count( $group1 ) > 0 }
+ {foreach from=$group1 item=g}
+ {if !in_array($g.id, $restrictions ) }
+ $( '#type_{$g.id}' ).removeAttr( "checked" );
+ {/if}
+ {/foreach}
+ {/if}
+ {if isset( $group2 ) && count( $group2 ) > 0 }
+ {foreach from=$group2 item=g}
+ {if !in_array($g.id, $restrictions ) }
+ $( '#type_{$g.id}' ).removeAttr( "checked" );
+ {/if}
+ {/foreach}
+ {/if}
+ {if isset( $group3 ) && count( $group3 ) > 0 }
+ {foreach from=$group3 item=g}
+ {if !in_array($g.id, $restrictions ) }
+ $( '#type_{$g.id}' ).removeAttr( "checked" );
+ {/if}
+ {/foreach}
+ {/if}
+ {/if}
$( '#domain' ).chosen();
- $( '#access_restriction' ).chosen();
if( $( "#access_restr" ).attr( "checked" ) == "checked" )
+ {
$( "#access_restriction_div" ).show();
+ $( "#allow_to").show();
+ }
if( $( '#domain_chzn' ).css( "width" ).length < 5 )
{
@@ -143,16 +182,12 @@
}
$('#welcome_email').bind( 'change', function() {
- $('#div_welcome_email').toggle('slow', function(){
- if( $( "#welcome_email" ).attr( "checked" ) )
- $( "#ar_controls" ).removeAttr( "style" );
- else
- $( "#ar_controls" ).attr( "style", "position: fixed; z-index: 2;" );
- });
+ $('#div_welcome_email').toggle('slow');
});
$( "#access_restr" ).change( function(){
$( "#access_restriction_div" ).toggle( "slow" );
+ $( "#allow_to").toggle( "fast" );
});
}); // document onready
@@ -0,0 +1,17 @@
+<fieldset>
+ <div class="action">
+ <dl class="inputs-list">
+ {foreach from=$ielements item=ielement}
+ <dt>
+ <label>
+ <input id="type_{$ielement.id}" type="checkbox"
+ checked="checked"
+ value="{$ielement.id}" name="type[{$ielement.id}]"
+ />
+ {$ielement.name}
+ </label>
+ </dt>
+ {/foreach}
+ </dl>
+ </div>
+</fieldset>
@@ -0,0 +1,22 @@
+<?php
+/**
+ * This class has been auto-generated by the Doctrine ORM Framework
+ */
+class Version2 extends Doctrine_Migration_Base
+{
+ public function up()
+ {
+ $this->changeColumn('mailbox', 'access_restriction', 'string', '100', array(
+ 'default' => 'ALL',
+ 'notnull' => '1',
+ ));
+
+ Doctrine_Query::create()->update('Mailbox')->set('access_restriction',"'ALL'")->where('access_restriction = ?', "BOTH" )->execute();
+ Doctrine_Query::create()->update('Mailbox')->set('access_restriction',"'imap'")->where('access_restriction = ?', "IMAP" )->execute();
+ Doctrine_Query::create()->update('Mailbox')->set('access_restriction',"'pop3'")->where('access_restriction = ?', "POP3" )->execute();
+ }
+
+ public function down()
+ {
+ }
+}
@@ -134,9 +134,8 @@ Mailbox:
type: string(255)
notnull: true
access_restriction:
- type: enum
- values: [BOTH, IMAP, POP3]
- default: BOTH
+ type: string(100)
+ default: ALL
notnull: true
active:
default: 1
@@ -269,18 +268,18 @@ Token:
Timestampable:
updated:
disabled: true
-MigrationVersion:
+MigrationVersion:
connection: 0
tableName: migration_version
columns:
id:
- type: integer(8)
+ type: integer(8)
autoincrement: true
primary: true
version:
- type: integer(4)
+ type: integer(4)
fixed: false
unsigned: false
- primary: false
- notnull: false
+ primary: false
+ notnull: false
autoincrement: false
Oops, something went wrong.

0 comments on commit c0876b2

Please sign in to comment.