CC-4736: Let non-admin users update their user info
-done but needs design
This commit is contained in:
parent
e6cc0c3417
commit
dd5882984e
6 changed files with 112 additions and 2 deletions
|
@ -88,6 +88,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
$view->headLink()->appendStylesheet($baseUrl.'/css/styles.css?'.$CC_CONFIG['airtime_version']);
|
$view->headLink()->appendStylesheet($baseUrl.'/css/styles.css?'.$CC_CONFIG['airtime_version']);
|
||||||
$view->headLink()->appendStylesheet($baseUrl.'/css/masterpanel.css?'.$CC_CONFIG['airtime_version']);
|
$view->headLink()->appendStylesheet($baseUrl.'/css/masterpanel.css?'.$CC_CONFIG['airtime_version']);
|
||||||
$view->headLink()->appendStylesheet($baseUrl.'/css/bootstrap.css?'.$CC_CONFIG['airtime_version']);
|
$view->headLink()->appendStylesheet($baseUrl.'/css/bootstrap.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
$view->headLink()->appendStylesheet($baseUrl.'/css/tipsy/jquery.tipsy.css?'.$CC_CONFIG['airtime_version']);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _initHeadScript()
|
protected function _initHeadScript()
|
||||||
|
@ -116,7 +117,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/dashboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/dashboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
$view->headScript()->appendFile($baseUrl.'/js/tipsy/jquery.tipsy.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/audioplaytest.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/audioplaytest.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
|
@ -33,6 +33,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
|
||||||
$ccAcl->allow('G', 'index')
|
$ccAcl->allow('G', 'index')
|
||||||
->allow('G', 'login')
|
->allow('G', 'login')
|
||||||
->allow('G', 'error')
|
->allow('G', 'error')
|
||||||
|
->allow('G', 'user', 'edit-user')
|
||||||
->allow('G', 'showbuilder')
|
->allow('G', 'showbuilder')
|
||||||
->allow('G', 'api')
|
->allow('G', 'api')
|
||||||
->allow('G', 'schedule')
|
->allow('G', 'schedule')
|
||||||
|
|
|
@ -10,6 +10,7 @@ class UserController extends Zend_Controller_Action
|
||||||
->addActionContext('get-user-data-table-info', 'json')
|
->addActionContext('get-user-data-table-info', 'json')
|
||||||
->addActionContext('get-user-data', 'json')
|
->addActionContext('get-user-data', 'json')
|
||||||
->addActionContext('remove-user', 'json')
|
->addActionContext('remove-user', 'json')
|
||||||
|
->addActionContext('edit-user', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +115,49 @@ class UserController extends Zend_Controller_Action
|
||||||
$id = $this->_getParam('id');
|
$id = $this->_getParam('id');
|
||||||
$this->view->entries = Application_Model_User::GetUserData($id);
|
$this->view->entries = Application_Model_User::GetUserData($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function editUserAction()
|
||||||
|
{
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$form = new Application_Form_EditUser();
|
||||||
|
if ($request->isPost()) {
|
||||||
|
$params = $request->getPost();
|
||||||
|
$postData = explode('&', $params['data']);
|
||||||
|
foreach($postData as $k=>$v) {
|
||||||
|
$v = explode('=', $v);
|
||||||
|
$formData[$v[0]] = urldecode($v[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1
|
||||||
|
&& $formData['cu_login'] == 'admin') {
|
||||||
|
$this->view->form = $form;
|
||||||
|
$this->view->successMessage = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>";
|
||||||
|
die(json_encode(array("html"=>$this->view->render('user/edit-user.phtml'))));
|
||||||
|
} else if ($form->isValid($formData) &&
|
||||||
|
$form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) {
|
||||||
|
$user = new Application_Model_User($formData['cu_user_id']);
|
||||||
|
$user->setFirstName($formData['cu_first_name']);
|
||||||
|
$user->setLastName($formData['cu_last_name']);
|
||||||
|
$user->setLogin($formData['cu_login']);
|
||||||
|
// We don't allow 6 x's as a password.
|
||||||
|
// The reason is because we use that as a password placeholder
|
||||||
|
// on the client side.
|
||||||
|
if ($formData['cu_password'] != "xxxxxx") {
|
||||||
|
$user->setPassword($formData['cu_password']);
|
||||||
|
}
|
||||||
|
$user->setEmail($formData['cu_email']);
|
||||||
|
$user->setCellPhone($formData['cu_cell_phone']);
|
||||||
|
$user->setSkype($formData['cu_skype']);
|
||||||
|
$user->setJabber($formData['cu_jabber']);
|
||||||
|
$user->save();
|
||||||
|
$this->view->successMessage = "<div class='success'>"._("User updated successfully!")."</div>";
|
||||||
|
}
|
||||||
|
$this->view->form = $form;
|
||||||
|
die(json_encode(array("html"=>$this->view->render('user/edit-user.phtml'))));
|
||||||
|
}
|
||||||
|
$this->view->form = $form;
|
||||||
|
$this->view->html = $this->view->render('user/edit-user.phtml');
|
||||||
|
}
|
||||||
|
|
||||||
public function removeUserAction()
|
public function removeUserAction()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
$this->navigation()->menu()->setPartial($partial); ?>
|
$this->navigation()->menu()->setPartial($partial); ?>
|
||||||
<div class="personal-block solo">
|
<div class="personal-block solo">
|
||||||
<ul>
|
<ul>
|
||||||
<li><span class="name"><?php echo $this->loggedInAs()?></span> | <a href=<?php echo $baseUrl . "/Login/logout"?>><?php echo _("Logout")?></a></li>
|
<li>
|
||||||
|
<a id="current-user" href="#"><span class="name"><?php echo $this->loggedInAs()?></span></a> | <a href=<?php echo $baseUrl . "/Login/logout"?>><?php echo _("Logout")?></a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,10 @@ select {
|
||||||
}
|
}
|
||||||
/* Version Notification Ends*/
|
/* Version Notification Ends*/
|
||||||
|
|
||||||
|
#current-user-container {
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.override_help_icon, .icecast_metadata_help_icon {
|
.override_help_icon, .icecast_metadata_help_icon {
|
||||||
cursor: help;
|
cursor: help;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -441,7 +441,65 @@ function init() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We never retrieve the user's password from the db
|
||||||
|
* and when we call isValid($params) the form values are cleared
|
||||||
|
* and repopulated with $params which does not have the password
|
||||||
|
* field. Therefore, we fill the password field with 6 x's
|
||||||
|
*/
|
||||||
|
function setCurrentUserPseudoPassword() {
|
||||||
|
$('#cu_password').val("xxxxxx");
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if ($('#master-panel').length > 0)
|
if ($('#master-panel').length > 0)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
var timer;
|
||||||
|
|
||||||
|
$('.tipsy').live('mouseover', function() {
|
||||||
|
clearTimeout(timer);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.tipsy').live('mouseout', function() {
|
||||||
|
timer = setTimeout("$('#current-user').tipsy('hide')", 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#current-user').bind('mouseover', function() {
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl+'/user/edit-user/format/json',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(json) {
|
||||||
|
$('#current-user').tipsy({
|
||||||
|
gravity: 'n',
|
||||||
|
html: true,
|
||||||
|
fade: true,
|
||||||
|
opacity: 0.9,
|
||||||
|
trigger: 'manual',
|
||||||
|
title: function() {
|
||||||
|
return json.html;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cache: false,
|
||||||
|
complete: function() {
|
||||||
|
$('#current-user').tipsy('show');
|
||||||
|
setCurrentUserPseudoPassword();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#current-user').bind('mouseout', function() {
|
||||||
|
timer = setTimeout("$('#current-user').tipsy('hide')", 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#cu_save_user').live('click', function() {
|
||||||
|
var data = $('#current-user-form').serialize();
|
||||||
|
$.post(baseUrl+'/user/edit-user', {format: 'json', data: data}, function(data) {
|
||||||
|
var json = $.parseJSON(data);
|
||||||
|
$('#current-user-container').empty().append(json.html);
|
||||||
|
setCurrentUserPseudoPassword();
|
||||||
|
setTimeout(removeSuccessMsg, 5000);
|
||||||
|
});
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue