Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
cf860bfe3c
15 changed files with 184 additions and 41 deletions
|
@ -34,7 +34,13 @@ $front->registerPlugin(new RabbitMqPlugin());
|
|||
|
||||
//localization configuration
|
||||
$codeset = 'UTF-8';
|
||||
$lang = Application_Model_Preference::GetLocale().'.'.$codeset;
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if ($auth->hasIdentity()) {
|
||||
$id = $auth->getIdentity()->id;
|
||||
$lang = Application_Model_Preference::GetCurrentUserLocale($id).'.'.$codeset;
|
||||
} else {
|
||||
$lang = Application_Model_Preference::GetLocale().'.'.$codeset;
|
||||
}
|
||||
|
||||
putenv("LC_ALL=$lang");
|
||||
putenv("LANG=$lang");
|
||||
|
|
|
@ -72,6 +72,11 @@ class UserController extends Zend_Controller_Action
|
|||
$user->setJabber($formData['jabber']);
|
||||
$user->save();
|
||||
|
||||
// Language settings are saved on a per-user basis
|
||||
// By default, the general language setting on preferences
|
||||
// page is what gets assigned.
|
||||
Application_Model_Preference::SetUserLocale($user->getId());
|
||||
|
||||
$form->reset();
|
||||
$this->view->form = $form;
|
||||
|
||||
|
@ -150,6 +155,7 @@ class UserController extends Zend_Controller_Action
|
|||
$user->setSkype($formData['cu_skype']);
|
||||
$user->setJabber($formData['cu_jabber']);
|
||||
$user->save();
|
||||
Application_Model_Preference::SetUserLocale($user->getId(), $formData['cu_locale']);
|
||||
$this->view->successMessage = "<div class='success'>"._("User updated successfully!")."</div>";
|
||||
}
|
||||
$this->view->form = $form;
|
||||
|
|
|
@ -29,6 +29,7 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$login->setLabel(_('Username:'));
|
||||
$login->setValue($userData["login"]);
|
||||
$login->setAttrib('class', 'input_text');
|
||||
$login->setAttrib('readonly', 'readonly');
|
||||
$login->setRequired(true);
|
||||
$login->addValidator($notEmptyValidator);
|
||||
$login->addFilter('StringTrim');
|
||||
|
@ -96,6 +97,12 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$jabber->setDecorators(array('viewHelper'));
|
||||
$this->addElement($jabber);
|
||||
|
||||
$locale = new Zend_Form_Element_Select("cu_locale");
|
||||
$locale->setLabel(_("Language"));
|
||||
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
$locale->setValue(Application_Model_Preference::GetUserLocale($currentUser->getId()));
|
||||
$locale->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($locale);
|
||||
/*
|
||||
$saveBtn = new Zend_Form_Element_Button('cu_save_user');
|
||||
$saveBtn->setAttrib('class', 'btn btn-small right-floated');
|
||||
|
|
|
@ -190,6 +190,30 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
|||
}
|
||||
$user->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($user);
|
||||
|
||||
$adminUser = new Zend_Form_Element_Text('admin_user');
|
||||
$adminUser->setLabel(_("Admin User"))
|
||||
->setValue(Application_Model_StreamSetting::getAdminUser($prefix))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
if ($disable_all) {
|
||||
$adminUser->setAttrib("disabled", "disabled");
|
||||
}
|
||||
$adminUser->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($adminUser);
|
||||
|
||||
$adminPass = new Zend_Form_Element_Text('admin_pass');
|
||||
$adminPass->setLabel(_("Admin Password"))
|
||||
->setValue(Application_Model_StreamSetting::getAdminPass($prefix))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
if ($disable_all) {
|
||||
$adminPass->setAttrib("disabled", "disabled");
|
||||
}
|
||||
$adminPass->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($adminPass);
|
||||
|
||||
$liquidsopa_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
|
||||
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
class Application_Model_Preference
|
||||
{
|
||||
|
||||
private static function setValue($key, $value, $isUserValue = false)
|
||||
/**
|
||||
*
|
||||
* @param integer $userId is not null when we are setting a locale for a specific user
|
||||
* @param boolean $isUserValue is true when we are setting a value for the current user
|
||||
*/
|
||||
private static function setValue($key, $value, $isUserValue = false, $userId = null)
|
||||
{
|
||||
try {
|
||||
//called from a daemon process
|
||||
|
@ -22,9 +27,12 @@ class Application_Model_Preference
|
|||
$paramMap[':key'] = $key;
|
||||
|
||||
//For user specific preference, check if id matches as well
|
||||
if ($isUserValue) {
|
||||
if ($isUserValue && is_null($userId)) {
|
||||
$sql .= " AND subjid = :id";
|
||||
$paramMap[':id'] = $id;
|
||||
} else if (!is_null($userId)) {
|
||||
$sql .= " AND subjid= :id";
|
||||
$paramMap[':id'] = $userId;
|
||||
}
|
||||
|
||||
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
||||
|
@ -42,7 +50,11 @@ class Application_Model_Preference
|
|||
$sql = "UPDATE cc_pref"
|
||||
. " SET valstr = :value"
|
||||
. " WHERE keystr = :key AND subjid = :id";
|
||||
$paramMap[':id'] = $id;
|
||||
if (is_null($userId)) {
|
||||
$paramMap[':id'] = $id;
|
||||
} else {
|
||||
$paramMap[':id'] = $userId;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// result not found
|
||||
|
@ -54,7 +66,11 @@ class Application_Model_Preference
|
|||
// user pref
|
||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||
." VALUES (:id, :key, :value)";
|
||||
$paramMap[':id'] = $id;
|
||||
if (is_null($userId)) {
|
||||
$paramMap[':id'] = $id;
|
||||
} else {
|
||||
$paramMap[':id'] = $userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
$paramMap[':key'] = $key;
|
||||
|
@ -428,16 +444,37 @@ class Application_Model_Preference
|
|||
{
|
||||
return self::getValue("timezone");
|
||||
}
|
||||
|
||||
|
||||
// This is the language setting on preferences page
|
||||
public static function SetLocale($locale)
|
||||
{
|
||||
self::setValue("locale", $locale);
|
||||
}
|
||||
|
||||
|
||||
public static function GetLocale()
|
||||
{
|
||||
return self::getValue("locale");
|
||||
}
|
||||
|
||||
public static function GetCurrentUserLocale($id)
|
||||
{
|
||||
return self::getValue("user_".$id."_locale", true);
|
||||
}
|
||||
|
||||
public static function SetUserLocale($userId, $locale = null)
|
||||
{
|
||||
// When a new user is created they will get the default locale
|
||||
// setting which the admin sets on preferences page
|
||||
if (is_null($locale)) {
|
||||
$locale = self::GetLocale();
|
||||
}
|
||||
self::setValue("user_".$userId."_locale", $locale, true, $userId);
|
||||
}
|
||||
|
||||
public static function GetUserLocale($userId)
|
||||
{
|
||||
return self::getValue("user_".$userId."_locale");
|
||||
}
|
||||
|
||||
public static function SetStationLogo($imagePath)
|
||||
{
|
||||
|
|
|
@ -163,7 +163,7 @@ class Application_Model_StreamSetting
|
|||
$con = Propel::getConnection();
|
||||
$sql = "SELECT *"
|
||||
." FROM cc_stream_setting"
|
||||
." WHERE keyname not like '%_error'";
|
||||
." WHERE keyname not like '%_error' AND keyname not like '%_admin_%'";
|
||||
|
||||
$rows = $con->query($sql)->fetchAll();
|
||||
|
||||
|
@ -433,4 +433,20 @@ class Application_Model_StreamSetting
|
|||
{
|
||||
return self::getValue("dj_live_stream_mp");
|
||||
}
|
||||
|
||||
public static function getAdminUser($stream){
|
||||
return self::getValue($stream."_admin_user");
|
||||
}
|
||||
|
||||
public static function setAdminUser($stream, $v){
|
||||
self::setValue($stream."_admin_user", $v, "string");
|
||||
}
|
||||
|
||||
public static function getAdminPass($stream){
|
||||
return self::getValue($stream."_admin_pass");
|
||||
}
|
||||
|
||||
public static function setAdminPass($stream, $v){
|
||||
self::setValue($stream."_admin_pass", $v, "string");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,20 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="cu-locale-label">
|
||||
<label><?php echo $this->element->getElement('cu_locale')->getLabel() ?>
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="cu-locale-element">
|
||||
<?php echo $this->element->getElement('cu_locale') ?>
|
||||
<?php if($this->element->getElement('cu_locale')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('cu_locale')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<button id="cu_save_user" type="button" class="btn btn-small right-floated">Save</button>
|
||||
</dl>
|
||||
</form>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
$s_name = "s".$this->stream_number;
|
||||
?>
|
||||
<h3 class="collapsible-header <?php echo $this->stream_number == '1'?"closed":""?>"><span class="arrow-icon"></span><? echo _("Stream "); ?><?php echo $this->stream_number?></h3>
|
||||
|
@ -104,6 +104,34 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="adminUser-label">
|
||||
<label for="outputUser"><?php echo $this->element->getElement('admin_user')->getLabel()?> :
|
||||
<span class='admin_username_help_icon'></span>
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="adminUser-element">
|
||||
<?php echo $this->element->getElement('admin_user')?>
|
||||
<?php if($this->element->getElement('admin_user')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('admin_user')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="adminPassword-label">
|
||||
<label class="optional" for="outputPassword"><?php echo $this->element->getElement('admin_pass')->getLabel()?> :</label>
|
||||
</dt>
|
||||
<dd id="adminPassword-element" class="clearfix">
|
||||
<?php echo $this->element->getElement('admin_pass')?>
|
||||
<?php if($this->element->getElement('admin_pass')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('admin_pass')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt class="block-display info-block">
|
||||
<?php echo _("The following info will be displayed to listeners in their media player:")?>
|
||||
</dt>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<tr><td><? echo _("Isrc Number:"); ?></td><td><?php echo ($this->md["MDATA_KEY_ISRC"]);?></td></tr>
|
||||
<tr><td><? echo _("Website:"); ?></td><td><?php echo ($this->md["MDATA_KEY_URL"]);?></td></tr>
|
||||
<tr><td><? echo _("Language:"); ?></td><td><?php echo ($this->md["MDATA_KEY_LANGUAGE"]);?></td></tr>
|
||||
<tr><td><? echo _("File"); ?> <? echo _("Path:"); ?></td><td><?php echo ($this->md["MDATA_KEY_FILEPATH"]);?></td></tr>
|
||||
<tr><td class='file-md-qtip-nowrap'><? echo _("File Path:"); ?></td><td><?php echo ($this->md["MDATA_KEY_FILEPATH"]);?></td></tr>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue