add_system_message(_("Delete failed, no parent"), 'error'); forward(""); } else if (count($folder_ids)<=0) { $TeKe->add_system_message(_("Delete failed, nothing to delete"), 'error'); forward("library/view"); } else { $delete_failed = false; $psyhvel = new Psyhvel(); if ($parent == "Library") { $forward_to = "library/view"; foreach ($folder_ids as $id) { if (!$psyhvel->deleteType("Folder", $id)) { $delete_failed = true; } } if ($delete_failed) { $TeKe->add_system_message(_("At least one of the deletions failed."), 'error'); forward($forward_to); } } } } else if (get_input('delete', false)) { if (empty($parent)) { $TeKe->add_system_message(_("Delete failed, no parent"), 'error'); forward(""); } else if (count($ids)<=0) { $TeKe->add_system_message(_("Delete failed, nothing to delete"), 'error'); if ($parent=="Library") { forward("library/view"); } else if ($parent=="Folder") { forward("library/Folder/".$parent_id."/view"); } forward("tests/view"); } else { $delete_failed = false; $psyhvel = new Psyhvel(); if ($parent == "TestFolder") { foreach ($ids as $id) { if (!$psyhvel->deleteType("", $id)) { $delete_failed = true; } } if ($delete_failed) { $TeKe->add_system_message(_("At least one of the deletions failed."), 'error'); forward($forward_to); } } else if ($parent == "Library") { $forward_to = "library/view"; foreach ($ids as $id) { if (!$psyhvel->deleteType("TestFolder", $id)) { $delete_failed = true; } } if ($delete_failed) { $TeKe->add_system_message(_("At least one of the deletions failed."), 'error'); forward($forward_to); } } else if ($parent == "Folder") { $forward_to = "library/Folder/".$parent_id."/view"; foreach ($ids as $id) { if (!$psyhvel->deleteType("TestFolder", $id)) { $delete_failed = true; } } if ($delete_failed) { $TeKe->add_system_message(_("At least one of the deletions failed."), 'error'); forward($forward_to); } } else if ($parent == "Tests") { $forward_to = "tests/view"; foreach ($ids as $id) { if (!$psyhvel->deleteType("Test", $id)) { $delete_failed = true; } } if ($delete_failed) { $TeKe->add_system_message(_("At least one of the deletions failed."), 'error'); forward($forward_to); } } else if ($parent == "Test") { $forward_to = "tests/Test/{$parent_id}/contents"; foreach ($ids as $id) { if (!$psyhvel->deleteType("TestFolder", $id)) { $delete_failed = true; } } if ($delete_failed) { $TeKe->add_system_message(_("At least one of the deletions failed."), 'error'); forward($forward_to); } } } $TeKe->add_system_message(_("Deleted")); } else if (get_input('copy', false)) { if ($parent == "Library") { $forward_to = "library/view"; } else if ($parent == "Folder") { $forward_to = "library/Folder/".$parent_id."/view"; } if (count($ids)<=0) { $TeKe->add_system_message(_("Copy failed, nothing to copy"), 'error'); forward($forward_to); } $TeKe->to_clipboard($ids, 'copy'); $TeKe->add_system_message(_("Copy")); } else if (get_input('cut', false)) { if ($parent == "Library") { $forward_to = "library/view"; } else if ($parent == "Folder") { $forward_to = "library/Folder/".$parent_id."/view"; } if (count($ids)<=0) { $TeKe->add_system_message(_("Cut failed, nothing to cut"), 'error'); forward($forward_to); } $TeKe->to_clipboard($ids, 'cut'); $TeKe->add_system_message(_("Cut")); } else if (get_input('paste', false)) { $cb_ids = $TeKe->from_clipboard(); if (array_key_exists("action", $cb_ids)) { $cb_action = $cb_ids["action"]; $cb_ids = $cb_ids["ids"]; } if (empty($parent) && empty($ids)) { $TeKe->add_system_message(_("Paste failed"), 'error'); forward(""); } else { $paste_failed = false; $psyhvel = new Psyhvel(); if ($parent == "TestFolder") { foreach ($cb_ids as $id) { $type = $psyhvel->loadType("", $id); if (!$type) { $paste_failed = true; } else { if (in_array($type->getType(), array("ChoiceTask", "TMTTask", "Questionnaire", "TextStimulus", "KSTask", "KSImgTask", "SliderTask", "MultiPictureStimulus", "ChoiceObject", "PictureStimulus", "SoundTask", "SoundStimulus", "SoundTesting", "HedgehogTest", "FlowerTest", "DragTest", "DragTesting", "ImageDragTask", "WordStimulus"))) { $type->setFolder($parent_id); if ($cb_action=="copy") { if (!$type->copy()) $paste_failed = true; } else if ($cb_action=="cut") { if (!$type->cut()) $paste_failed = true; } } else { $paste_failed = true; } } } if ($paste_failed) { $TeKe->add_system_message(_("At least one of the copied items could not be created."), 'error'); forward($forward_to); } } else if ($parent == "Library") { $forward_to = "library/view"; foreach ($cb_ids as $id) { $type = $psyhvel->loadType("TestFolder", $id); if (!$type) { $paste_failed = true; } else { $type->setFolder($parent_id); if ($cb_action=="copy") { if (!$type->copy()) $paste_failed = true; } else if ($cb_action=="cut") { if (!$type->cut()) $paste_failed = true; } } } if ($paste_failed) { $TeKe->add_system_message(_("At least one of the copied items could not be created."), 'error'); forward($forward_to); } } else if ($parent == "Folder") { $forward_to = "library/Folder/".$parent_id."/view"; foreach ($cb_ids as $id) { $type = $psyhvel->loadType("TestFolder", $id); if (!$type) { $paste_failed = true; } else { $type->setFolder($parent_id); if ($cb_action=="copy") { if (!$type->copy()) $paste_failed = true; } else if ($cb_action=="cut") { if (!$type->cut()) $paste_failed = true; } } } if ($paste_failed) { $TeKe->add_system_message(_("At least one of the copied items could not be created."), 'error'); forward($forward_to); } } } $TeKe->clear_clipboard(); $TeKe->add_system_message(_("Paste")); } else if (get_input('test_to_put', false) && $parent_id != 0 && $parent == "Tests") { $forward_to = WWW_ROOT."library/view"; if (isset($_SESSION['test_to_put'])) unset($_SESSION['test_to_put']); $_SESSION['test_to_put'] = $parent_id; } else if (get_input('assign', false) && ($parent == "Library" || $parent == "Folder")) { $assign_failed = false; if (isset($_SESSION['test_to_put'])) { $forward_to = "tests/Test/".$_SESSION['test_to_put']; $psyhvel = new Psyhvel(); foreach ($ids as $id) { $type = $psyhvel->loadType("TestFolder", $id); if (!$type) { $assign_failed = true; } else { if (!$type->assign($_SESSION['test_to_put'])) $assign_failed = true; } } unset($_SESSION['test_to_put']); } if ($assign_failed) { $TeKe->add_system_message(_("Assigning test failed!"), 'error'); forward($forward_to); } $TeKe->add_system_message(_("Test assigned")); } else if (get_input('reposition', false) && $parent_id > 0 && $parent == "TestFolder") { $order = get_input('folder_item', false); $psyhvel = new Psyhvel(); if ($type = $psyhvel->loadType("TestFolder", $parent_id)) { if (!$type->repositionContents($order)) { $TeKe->add_system_message(_("Repositioning failed."), 'error'); } } $TeKe->add_system_message(_("Moved")); } else if (get_input('reposition', false) && $parent_id > 0 && $parent == "Questionnaire") { $order = get_input('q_area', false); $psyhvel = new Psyhvel(); if ($type = $psyhvel->loadType("Questionnaire", $parent_id)) { if (!$type->repositionContents($order)) { $TeKe->add_system_message(_("Repositioning failed."), 'error'); } } $TeKe->add_system_message(_("Moved")); } else if (get_input('reposition', false) && $parent_id > 0 && $parent == "Test") { $forward_to = "tests/Test/{$parent_id}/contents"; $order = get_input('test_item', false); $psyhvel = new Psyhvel(); if ($type = $psyhvel->loadType("Test", $parent_id)) { if (!$type->repositionContents($order)) { $TeKe->add_system_message(_("Repositioning failed."), 'error'); } } $TeKe->add_system_message(_("Moved")); } else if (get_input('download_screenshots', false) && $parent_id > 0 && ($parent == "Test" || $parent == "TestFolder")) { $psyhvel = new Psyhvel(); $obj = $psyhvel->loadType($parent, $parent_id); $obj->zipScreenshots(); $no_forward = true; } else { $TeKe->add_system_message(_("No action")); } if (!$no_forward) { forward($forward_to); } ?>