Format code using php-cs-fixer

This commit is contained in:
jo 2021-10-11 16:10:47 +02:00
parent 43d7dc92cd
commit d52c6184b9
352 changed files with 17473 additions and 17041 deletions

View file

@ -2,16 +2,16 @@
class UserController extends Zend_Controller_Action
{
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('get-hosts', 'json')
->addActionContext('get-user-data-table-info', 'json')
->addActionContext('get-user-data', 'json')
->addActionContext('remove-user', 'json')
->addActionContext('edit-user', 'json')
->initContext();
->addActionContext('get-user-data-table-info', 'json')
->addActionContext('get-user-data', 'json')
->addActionContext('remove-user', 'json')
->addActionContext('edit-user', 'json')
->initContext()
;
}
public function addUserAction()
@ -27,34 +27,35 @@ class UserController extends Zend_Controller_Action
$baseUrl = Application_Common_OsPath::getBaseDir();
$js_files = array(
$js_files = [
'js/datatables/js/jquery.dataTables.js?',
'js/datatables/plugin/dataTables.pluginAPI.js?',
'js/airtime/user/user.js?'
);
'js/airtime/user/user.js?',
];
foreach ($js_files as $js) {
$this->view->headScript()->appendFile(
$baseUrl.$js.$CC_CONFIG['airtime_version'],'text/javascript');
$baseUrl . $js . $CC_CONFIG['airtime_version'],
'text/javascript'
);
}
$this->view->headLink()->appendStylesheet($baseUrl.'css/users.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl . 'css/users.css?' . $CC_CONFIG['airtime_version']);
$form = new Application_Form_AddUser();
$this->view->successMessage = "";
$this->view->successMessage = '';
if ($request->isPost()) {
$params = $request->getPost();
$postData = explode('&', $params['data']);
$formData = array();
foreach($postData as $k=>$v) {
$formData = [];
foreach ($postData as $k => $v) {
$v = explode('=', $v);
$formData[$v[0]] = urldecode($v[1]);
}
if ($form->isValid($formData)) {
if ($form->validateLogin($formData)) {
$user = new Application_Model_User($formData['user_id']);
if (empty($formData['user_id'])) {
@ -65,7 +66,7 @@ class UserController extends Zend_Controller_Action
// We don't allow 6 x's as a password.
// The reason is because we that as a password placeholder
// on the client side.
if ($formData['password'] != "xxxxxx") {
if ($formData['password'] != 'xxxxxx') {
$user->setPassword($formData['password']);
}
if (array_key_exists('type', $formData)) {
@ -83,19 +84,19 @@ class UserController extends Zend_Controller_Action
$this->view->form = $form;
if (strlen($formData['user_id']) == 0) {
$this->view->successMessage = "<div class='success'>"._("User added successfully!")."</div>";
$this->view->successMessage = "<div class='success'>" . _('User added successfully!') . '</div>';
} else {
$this->view->successMessage = "<div class='success'>"._("User updated successfully!")."</div>";
$this->view->successMessage = "<div class='success'>" . _('User updated successfully!') . '</div>';
}
$this->_helper->json->sendJson(array("valid"=>"true", "html"=>$this->view->render('user/add-user.phtml')));
$this->_helper->json->sendJson(['valid' => 'true', 'html' => $this->view->render('user/add-user.phtml')]);
} else {
$this->view->form = $form;
$this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')));
$this->_helper->json->sendJson(['valid' => 'false', 'html' => $this->view->render('user/add-user.phtml')]);
}
} else {
$this->view->form = $form;
$this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')));
$this->_helper->json->sendJson(['valid' => 'false', 'html' => $this->view->render('user/add-user.phtml')]);
}
}
@ -104,7 +105,7 @@ class UserController extends Zend_Controller_Action
public function getHostsAction()
{
$search = $this->_getParam('term');
$search = $this->_getParam('term');
$this->view->hosts = Application_Model_User::getHosts($search);
}
@ -121,7 +122,7 @@ class UserController extends Zend_Controller_Action
$id = $this->_getParam('id');
$this->view->entries = Application_Model_User::GetUserData($id);
}
public function editUserAction()
{
Zend_Layout::getMvcInstance()->assign('parent_page', 'Settings');
@ -132,16 +133,16 @@ class UserController extends Zend_Controller_Action
$form = new Application_Form_EditUser();
if ($request->isPost()) {
$formData = $request->getPost();
if ($form->isValid($formData) &&
$form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) {
if ($form->isValid($formData)
&& $form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) {
$user = new Application_Model_User($formData['cu_user_id']);
//Stupid hack because our schema enforces non-null first_name
//even though by default the admin user has no first name... (....)
if (Application_Model_User::getCurrentUser()->isSuperAdmin()) {
if (empty($formData['cu_first_name'])) {
$formData['cu_first_name'] = "admin";
$formData['cu_last_name'] = "admin"; //ditto, avoid non-null DB constraint
if (empty($formData['cu_first_name'])) {
$formData['cu_first_name'] = 'admin';
$formData['cu_last_name'] = 'admin'; //ditto, avoid non-null DB constraint
}
}
if (isset($formData['cu_first_name'])) {
@ -154,8 +155,8 @@ class UserController extends Zend_Controller_Action
// 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 (array_key_exists('cu_password', $formData) && ($formData['cu_password'] != "xxxxxx") &&
(!empty($formData['cu_password']))) {
if (array_key_exists('cu_password', $formData) && ($formData['cu_password'] != 'xxxxxx')
&& (!empty($formData['cu_password']))) {
$user->setPassword($formData['cu_password']);
}
@ -185,7 +186,7 @@ class UserController extends Zend_Controller_Action
//reinitialize form so language gets translated
$form = new Application_Form_EditUser();
$this->view->successMessage = "<div class='success'>"._("Settings updated successfully!")."</div>";
$this->view->successMessage = "<div class='success'>" . _('Settings updated successfully!') . '</div>';
}
$this->view->form = $form;
$this->view->html = $this->view->render('user/edit-user.phtml');
@ -198,49 +199,48 @@ class UserController extends Zend_Controller_Action
{
// action body
$delId = $this->_getParam('id');
$valid_actions = array("delete_cascade", "reassign_to");
$valid_actions = ['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 = "reassign_to";
$new_owner = Application_Model_User::getFirstAdmin($delId);
// TODO : remove this. we only use default for now not to break the UI.
if (!$files_action) { // set default action
$files_action = 'reassign_to';
$new_owner = Application_Model_User::getFirstAdmin($delId);
}
# only delete when valid action is selected for the owned files
if (! in_array($files_action, $valid_actions) ) {
// 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;
# Don't let users delete themselves
// Don't let users delete themselves
if ($delId == $userId) {
return;
}
$user = new Application_Model_User($delId);
// Don't allow super admins to be deleted.
if ($user->isSuperAdmin())
{
if ($user->isSuperAdmin()) {
return;
}
# Take care of the user's files by either assigning them to somebody
# or deleting them all
if ($files_action == "delete_cascade") {
// 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") {
} elseif ($files_action == 'reassign_to') {
// TODO : fix code to actually use the line below and pick a
// real owner instead of defaulting to the first found admin
//$new_owner_id = $this->_getParam("new_owner");
//$new_owner = new Application_Model_User($new_owner_id);
$user->donateFilesTo( $new_owner );
$user->donateFilesTo($new_owner);
Logging::info("Reassign to user {$new_owner->getDbId()}");
}
# Finally delete the user
// Finally delete the user
$this->view->entries = $user->delete();
}
}