public function __construct($collectionId) { if (is_null($collectionId)) { throw new Solrsearch_Model_Exception('Could not browse collection due to missing id parameter.'); } $collection = null; try { $collection = new Opus_Collection((int) $collectionId); } catch (Opus_Model_NotFoundException $e) { throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' does not exist."); } // check if an unvisible collection exists along the path to the root collection foreach ($collection->getParents() as $parent) { if (!$parent->isRoot() && $parent->getVisible() !== '1') { throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' is not visible."); } } $collectionRole = null; try { $collectionRole = new Opus_CollectionRole($collection->getRoleId()); } catch (Opus_Model_NotFoundException $e) { throw new Solrsearch_Model_Exception("Collection role with id '" . $collection->getRoleId() . "' does not exist."); } if (!($collectionRole->getVisible() === '1' && $collectionRole->getVisibleBrowsingStart() === '1')) { throw new Solrsearch_Model_Exception("Collection role with id '" . $collectionRole->getId() . "' is not visible."); } // additional root collection check $rootCollection = $collectionRole->getRootCollection(); if (!is_null($rootCollection)) { // check if at least one visible child exists or current collection has at least one associated document if (!$rootCollection->hasVisibleChildren() && count($rootCollection->getPublishedDocumentIds()) == 0) { throw new Solrsearch_Model_Exception("Collection role with id '" . $collectionRole->getId() . "' is not clickable and therefore not displayed."); } } $this->_collectionRole = $collectionRole; $this->_collection = $collection; }
public function testSetVisibilityFalse() { $model = new Admin_Model_CollectionRole($this->collectionRoleId); $collectionRole = $model->getObject(); $this->assertEquals(1, $collectionRole->getVisible()); $model->setVisibility(false); $collectionRole = new Opus_CollectionRole($this->collectionRoleId); $this->assertEquals(0, $collectionRole->getVisible()); }
public function testCreateActionForEdit() { $this->useEnglish(); $roles = Opus_CollectionRole::fetchAll(); $role = new Opus_CollectionRole(); $role->setName('EditTestName'); $role->setOaiName('EditTestOaiName'); $role->setDisplayBrowsing('Name'); $role->setDisplayFrontdoor('Number'); $role->setVisible(1); $role->setVisibleBrowsingStart(1); $role->setVisibleFrontdoor(0); $role->setVisibleOai(0); $role->setPosition(20); $roleId = $role->store(); $post = array('oid' => $roleId, 'Name' => 'ModifiedName', 'OaiName' => 'ModifiedOaiName', 'DisplayBrowsing' => 'Number,Name', 'DisplayFrontdoor' => 'Name,Number', 'Visible' => '0', 'VisibleBrowsingStart' => '0', 'VisibleFrontdoor' => '1', 'VisibleOai' => '1', 'Position' => '19', 'Save' => 'Speichern'); $this->getRequest()->setMethod('POST')->setPost($post); $this->dispatch('/admin/collectionroles/create'); $this->assertEquals(count($roles) + 1, count(Opus_CollectionRole::fetchAll())); // keine neue Collection $role = new Opus_CollectionRole($roleId); $role->delete(); $this->assertEquals('ModifiedName', $role->getName()); $this->assertEquals('ModifiedOaiName', $role->getOaiName()); $this->assertEquals('Number,Name', $role->getDisplayBrowsing()); $this->assertEquals('Name,Number', $role->getDisplayFrontdoor()); $this->assertEquals(0, $role->getVisible()); $this->assertEquals(0, $role->getVisibleBrowsingStart()); $this->assertEquals(1, $role->getVisibleFrontdoor()); $this->assertEquals(1, $role->getVisibleOai()); $this->assertEquals(19, $role->getPosition()); $this->assertRedirectTo('/admin/collectionroles'); $this->verifyFlashMessage('Collection role \'ModifiedName\' was edited successfully.', self::MESSAGE_LEVEL_NOTICE); }