/** * Backend area (only rightpane) with a * form to delete multiple files and directories * @return void */ public function deleteMultiple() { $iddirectories = $this->req->req('d', array()); $idfiles = $this->req->req('f', array()); if (count($iddirectories) <= 0 && count($idfiles) <= 0) { $this->_indexRedirect(); } $catched_messages = array('type' => 'delete_multiple'); $ok = $error = 0; foreach ($iddirectories as $iddirectory) { if (!$this->directory_sql_item->loadById($iddirectory)) { $this->_setSystemLogMessage('directory_is_not_loaded', array('multiple' => TRUE, 'id' => $iddirectory)); $catched_messages['directory'][$iddirectory] = 'error_directory_is_not_loaded'; ++$error; continue; } // check perm for action if ($this->directory_sql_item->hasPerm('delete') == FALSE) { $this->_setUserLogMessage('permission_denied', array('multiple' => TRUE, 'id' => $iddirectory, 'path' => $this->directory_sql_item->getRelativePath()), 'debug'); $catched_messages['directory'][$iddirectory] = 'error_permission_denied'; ++$error; continue; } try { if ($this->directory_sql_item->delete() == TRUE) { $this->_setUserLogMessage('delete_directory_success', array('multiple' => TRUE, 'id' => $iddirectory, 'path' => $this->directory_sql_item->getRelativePath())); $catched_messages['directory'][$iddirectory] = 'ok_delete_directory_success'; ++$ok; } } catch (Exception $e) { switch ($e->getCode()) { // 0 = fatal, 1 = error case 0: case 1: $code = 'error'; break; // 2 = warning // 2 = warning case 2: $code = 'warning'; break; } $catched_messages['directory'][$iddirectory] = $code . '_' . $e->getMessage(); $this->_setUserLogMessage($e->getMessage(), array('multiple' => TRUE, 'id' => $iddirectory, 'path' => $this->directory_sql_item->getRelativePath()), $code); ++$error; } } foreach ($idfiles as $idfile) { if (!$this->file_sql_item->loadById($idfile)) { $this->_setSystemLogMessage('file_is_not_loaded', array('multiple' => TRUE, 'id' => $idfile)); $catched_messages['file'][$idfile] = 'error_file_is_not_loaded'; ++$error; continue; } // check perm for action if ($this->file_sql_item->hasPerm('delete') == FALSE) { $this->_setUserLogMessage('permission_denied', array('multiple' => TRUE, 'id' => $idfile, 'path' => $this->file_sql_item->getRelativePath()), 'debug'); $catched_messages['file'][$idfile] = 'error_permission_denied'; ++$error; continue; } try { if ($this->file_sql_item->delete() == TRUE) { $this->_setUserLogMessage('delete_file_success', array('multiple' => TRUE, 'id' => $idfile, 'path' => $this->file_sql_item->getRelativePath())); $catched_messages['file'][$idfile] = 'ok_delete_file_success'; ++$ok; } } catch (Exception $e) { switch ($e->getCode()) { // 0 = fatal, 1 = error case 0: case 1: $code = 'error'; break; // 2 = warning // 2 = warning case 2: $code = 'warning'; break; } $catched_messages['file'][$idfile] = $code . '_' . $e->getMessage(); $this->_setUserLogMessage($e->getMessage(), array('multiple' => TRUE, 'id' => $idfile, 'path' => $this->file_sql_item->getRelativePath()), $code); ++$error; } } if ($error > 0) { // store catched messages to session $msghash = md5(time()); $this->_setVarToSession($msghash, $catched_messages, 'msg', TRUE); $msgcode = $ok > 0 ? 'warning_some_actions_failed' : 'error_all_actions_failed'; } else { $msghash = ''; $msgcode = 'ok_action_successful'; } $this->http_header->redirect($this->url->urlGet(array('area' => $this->config_area['area_name'] . '_index', 'msghash' => $msghash, 'msgcode' => $msgcode))); }