/** * @covers ilRoomSharingFileUtils::isTXTType */ public function testIsTXTType() { self::assertTrue(UTILS::isTXTType("text/plain")); self::assertTrue(UTILS::isTXTType("text/richtext")); self::assertTrue(UTILS::isTXTType("text/rtf")); // Negative cases self::assertFalse(UTILS::isTXTType("file/podf")); self::assertFalse(UTILS::isTXTType("")); self::assertFalse(UTILS::isTXTType(12)); self::assertFalse(UTILS::isTXTType(NULL)); self::assertFalse(UTILS::isTXTType(1)); }
/** * Returns true if the given mime type is allowed for the room agreement file. * * @param string $a_mimeType * * @return boolean */ private function isAllowedFileType($a_mimeType) { $isImage = ilRoomSharingFileUtils::isImageType($a_mimeType); $isPDF = ilRoomSharingFileUtils::isPDFType($a_mimeType); $isTXT = ilRoomSharingFileUtils::isTXTType($a_mimeType); return $isImage || $isPDF || $isTXT; }
/** * Creates a new floor plan by using the ILIAS MediaObject Service * and leaves a database entry. * * @param string $a_title the title of the floor plan * @param string $a_desc the floor plan description * @param array $a_newfile an array containing the input values of the form * * @return boolean success or failure */ public function addFloorPlan($a_title, $a_desc, $a_newfile) { if (!$this->permission->checkPrivilege(PRIVC::ADD_FLOORPLANS)) { ilUtil::sendFailure($this->lng->txt("rep_robj_xrs_no_permission_for_action"), true); $this->ctrl->redirectByClass('ilinfoscreengui', 'showSummary', 'showSummary'); return false; } if ($this->isTitleAlreadyTaken($a_title)) { throw new ilRoomSharingFloorplanException("rep_robj_xrs_floor_plan_title_is_already_taken"); } $mediaObj = $this->createMediaObject($a_title, $a_desc, NULL); $fileinfo = $this->configureFile($mediaObj, $a_newfile); if (!ilRoomSharingFileUtils::isImageType($fileinfo["format"])) { throw new ilRoomSharingFloorplanException("rep_robj_xrs_floor_plans_upload_error"); } if (!ilRoomSharingNumericUtils::isPositiveNumber($a_newfile['size'])) { throw new ilRoomSharingFloorplanException("rep_robj_xrs_floor_plans_upload_error"); } $this->updateMediaObject($mediaObj, $fileinfo); $this->fileToDatabase($mediaObj->getId()); }