15 use Symfony\Component\HttpFoundation\JsonResponse;
16 use Symfony\Component\HttpFoundation\Request;
20 const NAME =
"foldercontents";
28 function __construct()
30 parent::__construct(self::NAME, array(
33 $this->folderDao = $this->
getObject(
'dao.folder');
36 public function handle(Request $request)
38 $folderId = intval($request->get(
'folder'));
39 $uploadName = $request->get(
'upload');
40 if (!empty($uploadName)) {
44 $childFolders = $this->folderDao->getFolderChildFolders($folderId);
45 foreach ($childFolders as $folder) {
46 $results[$folder[
'foldercontents_pk']] =
'/'.$folder[
'folder_name'];
48 $childUploads = $this->folderDao->getFolderChildUploads($folderId,
Auth::getGroupId());
49 foreach ($childUploads as $upload) {
51 $uploadDate = explode(
".", $upload[
'upload_ts'])[0];
52 $uploadStatus =
" (" . $uploadStatus->getTypeName($upload[
'status_fk']) .
")";
53 $results[$upload[
'foldercontents_pk']] = $upload[
'upload_filename'] . _(
" from ") .
Convert2BrowserTime($uploadDate) . $uploadStatus;
56 if (!$request->get(
'removable')) {
57 if ($request->get(
'fromRest')) {
58 return array_map(
function($key, $value) {
64 }, array_keys($results), $results);
66 return new JsonResponse($results);
69 $filterResults = array();
70 foreach ($this->folderDao->getRemovableContents($folderId) as $content) {
71 $filterResults[$content] = $results[$content];
74 if ($request->get(
'fromRest')) {
75 return array_map(
function ($key, $value) {
81 }, array_keys($filterResults), $filterResults);
84 if (empty($filterResults)) {
85 $filterResults[
"-1"] =
"No removable content found";
88 return new JsonResponse($filterResults);
102 private function uploadExists($groupId, $folderId, $uploadName)
104 $childUploads = $this->folderDao->getFolderChildUploads($folderId, $groupId);
107 foreach ($childUploads as $upload) {
108 if (strcasecmp($upload[
'upload_filename'], $uploadName) === 0) {
109 $found = $upload[
'upload_pk'];
119 $uploadDao = $this->
getObject(
'dao.upload');
120 $parent = $uploadDao->getUploadParent($found);
123 return new JsonResponse([
"upload" => $found,
"date" => $date]);
127 register_plugin(
new AjaxFolderContents());
Contains the constants and helpers for authentication of user.
static getGroupId()
Get the current user's group id.
tracebackTotalUri()
Get the total url without query.
Convert2BrowserTime($server_time)
Convert the server time to browser time.