Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-08-28 17:22:57 -04:00
commit 481616a0d6
7 changed files with 96 additions and 32 deletions

View File

@ -50,6 +50,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetMailServerEmailAddress($values["preferences_email_server"]["email"]);
Application_Model_Preference::SetMailServerPassword($values["preferences_email_server"]["ms_password"]);
Application_Model_Preference::SetMailServerPort($values["preferences_email_server"]["port"]);
Application_Model_Preference::SetMailServerRequiresAuth($values["preferences_email_server"]["msRequiresAuth"]);
}
Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]);

View File

@ -41,6 +41,15 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'viewHelper'
)
));
$this->addElement('checkbox', 'msRequiresAuth', array(
'label' => 'Requires Authentication',
'required' => false,
'value' => Application_Model_Preference::GetMailServerRequiresAuth(),
'decorators' => array(
'viewHelper'
)
));
$this->addElement('text', 'mailServer', array(
'class' => 'input_text',
@ -50,7 +59,9 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'decorators' => array('viewHelper'),
'allowEmpty' => false,
'validators' => array(
new ConditionalNotEmpty(array('configureMailServer'=>'1'))
new ConditionalNotEmpty(array(
'configureMailServer' => '1'
))
)
));
@ -62,7 +73,10 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'decorators' => array('viewHelper'),
'allowEmpty' => false,
'validators' => array(
new ConditionalNotEmpty(array('configureMailServer'=>'1'))
new ConditionalNotEmpty(array(
'configureMailServer' => '1',
'msRequiresAuth' => '1'
))
)
));
@ -74,7 +88,10 @@ class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
'decorators' => array('viewHelper'),
'allowEmpty' => false,
'validators' => array(
new ConditionalNotEmpty(array('configureMailServer'=>'1'))
new ConditionalNotEmpty(array(
'configureMailServer' => '1',
'msRequiresAuth' => '1'
))
),
'renderPassword' => true
));

View File

@ -13,23 +13,31 @@ class Application_Model_Email
public static function send($subject, $message, $tos, $from = null)
{
$mailServerConfigured = Application_Model_Preference::GetMailServerConfigured() == true ? true : false;
$mailServerRequiresAuth = Application_Model_Preference::GetMailServerRequiresAuth() == true ? true : false;
$success = true;
if ($mailServerConfigured) {
$username = Application_Model_Preference::GetMailServerEmailAddress();
$password = Application_Model_Preference::GetMailServerPassword();
$mailServer = Application_Model_Preference::GetMailServer();
$mailServerPort = Application_Model_Preference::GetMailServerPort();
if (!empty($mailServerPort)) {
$port = Application_Model_Preference::GetMailServerPort();
}
$config = array(
'auth' => 'login',
'ssl' => 'ssl',
'username' => $username,
'password' => $password
);
if ($mailServerRequiresAuth) {
$username = Application_Model_Preference::GetMailServerEmailAddress();
$password = Application_Model_Preference::GetMailServerPassword();
$config = array(
'auth' => 'login',
'ssl' => 'ssl',
'username' => $username,
'password' => $password
);
} else {
$config = array(
'ssl' => 'ssl'
);
}
if (isset($port)) {
$config['port'] = $port;

View File

@ -1089,6 +1089,16 @@ class Application_Model_Preference
{
return self::getValue("mail_server_port");
}
public static function SetMailServerRequiresAuth($value)
{
self::setValue("mail_server_requires_auth", $value, false);
}
public static function GetMailServerRequiresAuth()
{
return self::getValue("mail_server_requires_auth");
}
/* User specific preferences end */
public static function ShouldShowPopUp()

View File

@ -44,7 +44,13 @@
<label class="required" for="mailServer"><?php echo $this->element->getElement('mailServer')->getLabel() ?>
<span class="info-text-small">(Required)</span>:
</label>
<label class="required" for="msRequiresAuth">
<?php echo $this->element->getElement('msRequiresAuth') ?>
<?php echo $this->element->getElement('msRequiresAuth')->getLabel() ?>
</label>
</dt>
<dd id="mailServer-element" class="block-display">
<?php echo $this->element->getElement('mailServer') ?>
<?php if($this->element->getElement('mailServer')->hasErrors()) : ?>
@ -56,6 +62,14 @@
<?php endif; ?>
</dd>
<dt id="port-label" class="block-display">
<label class="required" for="port"><?php echo $this->element->getElement('port')->getLabel() ?>:
</label>
</dt>
<dd id="port-element" class="block-display">
<?php echo $this->element->getElement('port') ?>
</dd>
<dt id="email-label" class="block-display">
<label class="required" for="email"><?php echo $this->element->getElement('email')->getLabel() ?>
<span class="info-text-small">(Required)</span>:
@ -88,14 +102,6 @@
<?php endif; ?>
</dd>
<dt id="port-label" class="block-display">
<label class="required" for="port"><?php echo $this->element->getElement('port')->getLabel() ?>:
</label>
</dt>
<dd id="port-element" class="block-display">
<?php echo $this->element->getElement('port') ?>
</dd>
<?php } ?>
</dl>

View File

@ -20,14 +20,19 @@ function setConfigureMailServerListener() {
var configMailServer = $("#configureMailServer");
configMailServer.click(function(event){
setMailServerInputReadonly();
})
});
var msRequiresAuth = $("#msRequiresAuth");
msRequiresAuth.click(function(event){
setMsAuthenticationFieldsReadonly($(this));
});
}
function setEnableSystemEmailsListener() {
var enableSystemEmails = $("#enableSystemEmail");
enableSystemEmails.click(function(event){
setSystemFromEmailReadonly();
})
});
}
function setSystemFromEmailReadonly() {
@ -43,19 +48,36 @@ function setSystemFromEmailReadonly() {
function setMailServerInputReadonly() {
var configMailServer = $("#configureMailServer");
var mailServer = $("#mailServer");
var email = $("#email");
var password = $("#ms_password");
var port = $("#port");
if ($(configMailServer).is(':checked')) {
var requiresAuthCB = $("#msRequiresAuth");
if (configMailServer.is(':checked')) {
mailServer.removeAttr("readonly");
email.removeAttr("readonly");
password.removeAttr("readonly");
port.removeAttr("readonly");
requiresAuthCB.parent().show();
} else {
mailServer.attr("readonly", "readonly");
port.attr("readonly", "readonly");
requiresAuthCB.parent().hide();
}
setMsAuthenticationFieldsReadonly(requiresAuthCB);
}
/*
* Enable/disable mail server authentication fields
*/
function setMsAuthenticationFieldsReadonly(ele) {
var email = $("#email");
var password = $("#ms_password");
var configureMailServer = $("#configureMailServer");
if (ele.is(':checked') && configureMailServer.is(':checked')) {
email.removeAttr("readonly");
password.removeAttr("readonly");
} else if (ele.not(':checked') || configureMailServer.not(':checked')) {
email.attr("readonly", "readonly");
password.attr("readonly", "readonly");
port.attr("readonly", "readonly");
}
}

View File

@ -51,15 +51,15 @@ class TestMMP(unittest.TestCase):
orga['MDATA_KEY_FTYPE'] = u'audioclip'
orig['MDATA_KEY_BITRATE'] = u'256000'
orga['MDATA_KEY_BITRATE'] = u'256000'
old_path = "/home/rudi/recorded/2012-08-21-11:29:00.ogg"
old_path = "/home/rudi/recorded/2012-08-21-11:29:00.ogg"
normalized = mmp.normalized_metadata(orig, old_path)
normalized['MDATA_KEY_BITRATE'] = u'256000'
self.assertEqual( orga, normalized )
organized_base_name = "2012-08-21-11-29-00-record-256kbps.ogg"
base = "/srv/airtime/stor/"
organized_path = mmp.organized_path(old_path,base, normalized)
base = "/srv/airtime/stor/"
organized_path = mmp.organized_path(old_path,base, normalized)
self.assertEqual(os.path.basename(organized_path), organized_base_name)
def test_normalized_metadata2(self):
@ -72,14 +72,14 @@ class TestMMP(unittest.TestCase):
'title' : [u'18-11-00-Untitled Show'],
'artist' : [u'Airtime Show Recorder']
})
old_path = "/home/rudi/recorded/doesnt_really_matter.ogg"
old_path = "/home/rudi/recorded/doesnt_really_matter.ogg"
normalized = mmp.normalized_metadata(orig, old_path)
normalized['MDATA_KEY_BITRATE'] = u'256000'
opath = mmp.organized_path(old_path, "/srv/airtime/stor/",
normalized)
# TODO : add a better test than this...
self.assertTrue( len(opath) > 0 )
def test_file_md5(self):
p = os.path.realpath(__file__)
m1 = mmp.file_md5(p)