Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
0ceb0167fe
8 changed files with 48 additions and 57 deletions
|
@ -24,9 +24,16 @@ class UserController extends Zend_Controller_Action
|
|||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/user/user.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$js_files = array(
|
||||
'/js/datatables/js/jquery.dataTables.js?',
|
||||
'/js/datatables/plugin/dataTables.pluginAPI.js?',
|
||||
'/js/airtime/user/user.js?'
|
||||
);
|
||||
|
||||
foreach ($js_files as $js) {
|
||||
$this->view->headScript()->appendFile(
|
||||
$baseUrl.$js.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
}
|
||||
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/css/users.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
||||
|
@ -97,14 +104,39 @@ class UserController extends Zend_Controller_Action
|
|||
// action body
|
||||
$delId = $this->_getParam('id');
|
||||
|
||||
$valid_actions = array("delete_cascade", "reassign_to");
|
||||
|
||||
$files_action = $this->_getParam('deleted_files');
|
||||
|
||||
# TODO : remove this. we only use default for now not to break the UI.
|
||||
if (!$files_action) { # set default action
|
||||
$files_action = "delete_cascade";
|
||||
}
|
||||
|
||||
# only delete when valid action is selected for the owned files
|
||||
if (! in_array($files_action, $valid_actions) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$userId = $userInfo->id;
|
||||
|
||||
if ($delId != $userId) {
|
||||
$user = new Application_Model_User($delId);
|
||||
$this->view->entries = $user->delete();
|
||||
# Don't let users delete themselves
|
||||
if ($delId == $userId) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
$user = new Application_Model_User($delId);
|
||||
|
||||
# Take care of the user's files by either assigning them to somebody
|
||||
# or deleting them all
|
||||
if ($files_action == "delete_cascade") {
|
||||
$user->deleteAllFiles();
|
||||
} elseif ($files_action == "reassign_to") {
|
||||
$new_owner = $this->_getParam("new_owner");
|
||||
$user->reassignTo( $new_owner );
|
||||
}
|
||||
# Finally delete the user
|
||||
$this->view->entries = $user->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,6 +249,9 @@ class Application_Model_User
|
|||
public function deleteAllFiles()
|
||||
{
|
||||
$my_files = $this->getOwnedFiles();
|
||||
foreach ($files as $file) {
|
||||
$file->delete();
|
||||
}
|
||||
}
|
||||
|
||||
private function createUser()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<div class="ui-widget ui-widget-content block-shadow clearfix padded-strong user-management">
|
||||
|
||||
<h2>Manage Users</h2>
|
||||
<div class="user-list-wrapper">
|
||||
<div id="users_wrapper" class="dataTables_wrapper">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue