protected function addField($name)
 {
     switch ($name) {
         case 'authorizedFormOfName':
             $this->form->setValidator('authorizedFormOfName', new sfValidatorString());
             $this->form->setWidget('authorizedFormOfName', new sfWidgetFormSelect(array('choices' => array())));
             break;
         case 'type':
             $this->form->setDefault('type', $this->context->routing->generate(null, array(QubitTerm::getById(QubitTerm::DONOR_ID), 'module' => 'term')));
             $this->form->setValidator('type', new sfValidatorString());
             $this->form->setWidget('type', new sfWidgetFormInputHidden());
             break;
         case 'countryCode':
             $this->form->setValidator('countryCode', new sfValidatorI18nChoiceCountry());
             $this->form->setWidget('countryCode', new sfWidgetFormI18nChoiceCountry(array('add_empty' => true, 'culture' => $this->context->user->getCulture())));
             break;
         case 'city':
         case 'contactPerson':
         case 'email':
         case 'postalCode':
         case 'region':
         case 'streetAddress':
         case 'telephone':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
         default:
             return parent::addField($name);
     }
 }
Пример #2
0
 public static function getTaxonomyTerms($taxonomyId, $options = array())
 {
     $criteria = new Criteria();
     $criteria->add(QubitTerm::TAXONOMY_ID, $taxonomyId);
     // Only include top-level terms if option is set
     if (isset($options['level']) && $options['level'] == 'top') {
         $criteria->add(QubitTerm::PARENT_ID, QubitTerm::ROOT_ID);
     }
     // Sort alphabetically
     $criteria->addAscendingOrderByColumn('name');
     // Do source culture fallback
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm');
     return QubitTerm::get($criteria);
 }
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $conn = $databaseManager->getDatabase('propel')->getConnection();
     $criteria = new Criteria();
     $criteria->add(QubitSlug::SLUG, $arguments['slug']);
     $criteria->addJoin(QubitSlug::OBJECT_ID, QubitObject::ID);
     $resource = QubitInformationObject::get($criteria)->__get(0);
     $publicationStatus = QubitTerm::getById($arguments['publicationStatusId']);
     // Check if the resource exists
     if (!isset($resource)) {
         throw new sfException('Resource not found');
     }
     // Check if the given status is correct and exists
     if (!isset($publicationStatus)) {
         throw new sfException('Publication status not found');
     }
     if (QubitTaxonomy::PUBLICATION_STATUS_ID != $publicationStatus->taxonomyId) {
         throw new sfException('Given term is not part of the publication status taxonomy');
     }
     // Final confirmation
     if (!$options['no-confirm']) {
         if (!$this->askConfirmation(array('Please, confirm that you want to change', 'the publication status of "' . $resource . '"', 'to "' . $publicationStatus . '" (y/N)'), 'QUESTION_LARGE', false)) {
             $this->logSection('tools', 'Bye!');
             return 1;
         }
     }
     // Start work
     $resource->setPublicationStatus($publicationStatus->id);
     $resource->save();
     echo '+';
     // Update pub status of descendants
     if (!$options['ignore-descendants']) {
         foreach ($resource->descendants as $descendant) {
             if (null === ($descendantPubStatus = $descendant->getPublicationStatus())) {
                 $descendantPubStatus = new QubitStatus();
                 $descendantPubStatus->typeId = QubitTerm::STATUS_TYPE_PUBLICATION_ID;
                 $descendantPubStatus->objectId = $descendant->id;
             }
             if ($options['force'] || $publicationStatus->id != $descendantPubStatus->statusId) {
                 $descendantPubStatus->statusId = $publicationStatus->id;
                 $descendantPubStatus->save();
                 echo '^';
             }
         }
     }
     echo "\n";
 }
 /**
  * Execute digitalobject list action
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     // Build funky join query to get a count of top level digital objects
     // for each media type (term)
     $criteria = new Criteria();
     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MEDIA_TYPE_ID);
     $criteria->addJoin(QubitTerm::ID, QubitDigitalObject::MEDIA_TYPE_ID, Criteria::LEFT_JOIN);
     $criteria->addAsColumn('hits', 'COUNT(' . QubitDigitalObject::ID . ')');
     $criteria->addGroupByColumn(QubitTerm::ID);
     // Add I18n fallback
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm');
     $criteria->addAscendingOrderByColumn('name');
     // Filter drafts
     $criteria->addJoin(QubitDigitalObject::INFORMATION_OBJECT_ID, QubitInformationObject::ID);
     $criteria = QubitAcl::addFilterDraftsCriteria($criteria);
     $this->terms = QubitTerm::get($criteria);
 }
 public function execute($request)
 {
     $resource = $this->getRoute()->resource;
     if (!isset($resource)) {
         $this->forward404();
     }
     if ('QubitTerm' == $resource->className) {
         $term = QubitTerm::getById($resource->id);
         $this->terms = $term->descendants->andSelf()->orderBy('lft');
         $this->taxonomy = $term->taxonomy;
         $this->topLevelTerms = array($term);
     } else {
         $this->terms = QubitTaxonomy::getTaxonomyTerms($resource->id);
         $this->taxonomy = QubitTaxonomy::getById($resource->id);
         $this->topLevelTerms = QubitTaxonomy::getTaxonomyTerms($resource->id, array('level' => 'top'));
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'location':
         case 'name':
             $this->form->setDefault($name, $this->resource[$name]);
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'type':
             $this->form->setDefault('type', $this->context->routing->generate(null, array($this->resource->type, 'module' => 'term')));
             $this->form->setValidator('type', new sfValidatorString());
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => QubitTerm::getIndentedChildTree(QubitTerm::CONTAINER_ID, ' ', array('returnObjectInstances' => true)))));
             break;
         default:
             return parent::addField($name);
     }
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'containers':
             $this->form->setValidator('containers', new sfValidatorPass());
             $this->form->setWidget('containers', new sfWidgetFormSelect(array('choices' => array(), 'multiple' => true)));
             break;
         case 'location':
         case 'name':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInput());
             break;
         case 'type':
             $this->form->setValidator('type', new sfValidatorString());
             $this->form->setWidget('type', new sfWidgetFormSelect(array('choices' => QubitTerm::getIndentedChildTree(QubitTerm::CONTAINER_ID, ' ', array('returnObjectInstances' => true)))));
             break;
         default:
             return parent::addField($name);
     }
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     $this->timer = new QubitTimer();
     $this->terms = array();
     $this->termsPerPage = intval(sfConfig::get('app_hits_per_page'));
     $this->taxonomy = null;
     $this->parent = QubitTerm::getById(QubitTerm::ROOT_ID);
     if (isset($this->getRoute()->resource)) {
         $resource = $this->getRoute()->resource;
         if ('QubitTaxonomy' == $resource->className) {
             $this->taxonomy = QubitTaxonomy::getById($resource->id);
         } else {
             $this->parent = QubitTerm::getById($resource->id);
             $this->taxonomy = $this->parent->taxonomy;
         }
     }
     if (!isset($this->taxonomy)) {
         $this->forward404();
     }
     // Check user authorization
     if (!QubitAcl::check($this->parent, 'create')) {
         QubitAcl::forwardUnauthorized();
     }
     $this->form->setWidget('file', new sfWidgetFormInputFile());
     $this->form->setValidator('file', new sfValidatorFile());
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters(), $request->getFiles());
         if ($this->form->isValid()) {
             if (null !== ($file = $this->form->getValue('file'))) {
                 $doc = new domDocument();
                 $doc->substituteEntities = true;
                 $doc->load($file->getTempName());
                 $this->skos = sfSkosPlugin::parse($doc, array('taxonomy' => $this->taxonomy, 'parent' => $this->parent));
             }
         }
     } else {
         $this->setTemplate('importSelect');
     }
 }
 public function execute($request)
 {
     if (!isset($request->limit)) {
         $request->limit = 25;
     }
     $this->mediaType = QubitTerm::getById($request->mediatype);
     if (!$this->mediaType instanceof QubitTerm) {
         $this->forward404();
     }
     $criteria = new Criteria();
     $criteria->add(QubitDigitalObject::MEDIA_TYPE_ID, $this->mediaType->id);
     $criteria->add(QubitDigitalObject::SEQUENCE);
     $criteria->addJoin(QubitDigitalObject::INFORMATION_OBJECT_ID, QubitInformationObject::ID);
     // Sort by name ascending
     $criteria->addAscendingOrderByColumn(QubitDigitalObject::NAME);
     // Filter draft descriptions
     $criteria = QubitAcl::addFilterDraftsCriteria($criteria);
     $this->pager = new QubitPager('QubitDigitalObject');
     $this->pager->setCriteria($criteria);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
 }
 protected function addField($name)
 {
     switch ($name) {
         case 'className':
             $choices = array('QubitInformationObject' => sfConfig::get('app_ui_label_informationobject'), 'QubitActor' => sfConfig::get('app_ui_label_actor'), 'QubitRepository' => sfConfig::get('app_ui_label_repository'), 'QubitTerm' => sfConfig::get('app_ui_label_term'), 'QubitFunction' => sfConfig::get('app_ui_label_function'));
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' => $choices)));
             break;
         case 'dateStart':
             $this->form->setValidator($name, new sfValidatorDate(array(), array('invalid' => $this->context->i18n->__('Invalid start date'))));
             $this->form->setWidget($name, new sfWidgetFormInput(array(), array('style' => 'width: auto')));
             break;
         case 'dateEnd':
             $this->form->setValidator($name, new sfValidatorDate(array(), array('invalid' => $this->context->i18n->__('Invalid end date'))));
             $this->form->setWidget($name, new sfWidgetFormInput(array(), array('style' => 'width: auto')));
             break;
         case 'dateOf':
             $choices = array('CREATED_AT' => 'Creation', 'UPDATED_AT' => 'Revision', 'both' => 'Both');
             $this->form->setValidator($name, new sfValidatorChoice(array('choices' => array_keys($choices))));
             $this->form->setWidget($name, new sfWidgetFormSelectRadio(array('choices' => $choices, 'class' => 'radio inline')));
             break;
         case 'publicationStatus':
             $choices = array(QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID => QubitTerm::getById(QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID)->name, QubitTerm::PUBLICATION_STATUS_DRAFT_ID => QubitTerm::getById(QubitTerm::PUBLICATION_STATUS_DRAFT_ID)->name, 'all' => 'All');
             $this->form->setValidator($name, new sfValidatorChoice(array('choices' => array_keys($choices))));
             $this->form->setWidget($name, new sfWidgetFormSelectRadio(array('choices' => $choices, 'class' => 'radio inline')));
             break;
         case 'limit':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInputHidden());
             break;
         case 'sort':
             $this->form->setValidator($name, new sfValidatorString());
             $this->form->setWidget($name, new sfWidgetFormInputHidden());
             break;
     }
 }
 public function execute($request)
 {
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     // For term module show only preferred term
     $params = $this->context->routing->parse(Qubit::pathInfo($request->getReferer()));
     if ('term' == $params['module']) {
         $criteria = new Criteria();
         // Exclude the calling object and it's descendants from the list (prevent
         // circular inheritance)
         if (isset($params['id'])) {
             // TODO Self join would be ideal
             $term = QubitTerm::getById($params['id']);
             if (isset($term)) {
                 $criteria->add($criteria->getNewCriterion(QubitTerm::LFT, $term->lft, Criteria::LESS_THAN)->addOr($criteria->getNewCriterion(QubitTerm::RGT, $term->rgt, Criteria::GREATER_THAN)));
             }
         }
         $params = $this->context->routing->parse(Qubit::pathInfo($request->taxonomy));
         $criteria->add(QubitTerm::TAXONOMY_ID, $params['_sf_route']->resource->id);
         $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
         $criteria->add(QubitTermI18n::CULTURE, $this->context->user->getCulture());
         // Narrow results by query
         if (isset($request->query)) {
             $criteria->add(QubitTermI18n::NAME, "{$request->query}%", Criteria::LIKE);
         }
         // Sort by name
         $criteria->addAscendingOrderByColumn(QubitTermI18n::NAME);
         $criteria->setLimit(10);
         $this->terms = QubitTerm::get($criteria);
     } else {
         $s1 = 'SELECT qt.id, null, qti.name
     FROM ' . QubitTerm::TABLE_NAME . ' qt
       LEFT JOIN ' . QubitTermI18n::TABLE_NAME . ' qti
         ON qt.id = qti.id
     WHERE taxonomy_id = :p1
       AND qti.culture = :p2';
         $s2 = 'SELECT qt.id, qon.id as altId, qoni.name
     FROM ' . QubitOtherName::TABLE_NAME . ' qon
       INNER JOIN ' . QubitOtherNameI18n::TABLE_NAME . ' qoni
         ON qon.id = qoni.id
       INNER JOIN ' . QubitTerm::TABLE_NAME . ' qt
         ON qon.object_id = qt.id
     WHERE qt.taxonomy_id = :p1
       AND qoni.culture = :p2';
         // Narrow results by query
         if (isset($request->query)) {
             $s1 .= ' AND qti.name LIKE :p3';
             $s2 .= ' AND qoni.name LIKE :p3';
         }
         $connection = Propel::getConnection();
         $statement = $connection->prepare("({$s1}) UNION ALL ({$s2}) ORDER BY name LIMIT 10");
         $params = $this->context->routing->parse(Qubit::pathInfo($request->taxonomy));
         $statement->bindValue(':p1', $params['_sf_route']->resource->id);
         $statement->bindValue(':p2', $this->context->user->getCulture());
         if (isset($request->query)) {
             $statement->bindValue(':p3', "{$request->query}%");
         }
         $statement->execute();
         $this->terms = array();
         $rows = $statement->fetchAll();
         foreach ($rows as $row) {
             if (isset($row[1])) {
                 // Alternative term
                 $this->terms[] = array(QubitTerm::getById($row[0]), $row[2]);
             } else {
                 // Preferred term
                 $this->terms[] = QubitTerm::getById($row[0]);
             }
         }
     }
 }
Пример #12
0
 private static function getFullTree($currentNode, $limit)
 {
     $tree = array();
     // Get direct ancestors
     $ancestors = $currentNode->getAncestors()->orderBy('lft');
     foreach ($ancestors as $ancestor) {
         $tree[$ancestor->id] = $ancestor;
     }
     // Get siblings (with limit) - but don't show sibling collection roots
     $totalSiblings = 0;
     $criteria = new Criteria();
     $criteria->add(QubitTerm::PARENT_ID, $currentNode->parentId);
     if (QubitTerm::ROOT_ID == $currentNode->parentId) {
         $criteria->add(QubitTerm::TAXONOMY_ID, $currentNode->taxonomyId);
     }
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm');
     $criteria->addAscendingOrderByColumn('name');
     if (0 < $limit) {
         $criteria->setLimit($limit);
     }
     foreach (QubitTerm::get($criteria) as $item) {
         // Keep track of position of $currentNode in array
         if ($item === $currentNode) {
             $curIndex = count($tree);
         }
         $tree[] = $item;
     }
     $totalSiblings = intval(BasePeer::doCount($criteria->setLimit(0))->fetchColumn(0));
     // Add current object to $tree if it wasn't added as a sibling
     if (!isset($curIndex)) {
         if ($totalSiblings >= $limit) {
             // replace last sibling with current object
             array_splice($tree, -1, 1, array($currentNode));
         } else {
             $tree[] = $currentNode;
         }
         $curIndex = count($tree) - 1;
     }
     if ($totalSiblings > $limit) {
         $tree[] = array('total' => $totalSiblings, 'limit' => $limit, 'parentId' => $currentNode->parentId);
     }
     // Get children (with limit)
     $totalChildren = 0;
     $criteria = new Criteria();
     $criteria->add(QubitTerm::PARENT_ID, $currentNode->id);
     $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitTerm');
     $criteria->addAscendingOrderByColumn('name');
     if (0 < $limit) {
         $criteria->setLimit($limit);
     }
     if (0 < count($children = QubitTerm::get($criteria))) {
         foreach ($children as $item) {
             $childs[] = $item;
         }
         $totalChildren = intval(BasePeer::doCount($criteria->setLimit(0))->fetchColumn(0));
         if ($totalChildren > $limit) {
             $childs[] = array('total' => $totalChildren, 'limit' => $limit, 'parentId' => $currentNode->id);
         }
         // Insert children right AFTER current info object in array
         if ($curIndex == count($tree) - 1) {
             $tree = array_merge($tree, $childs);
         } else {
             array_splice($tree, $curIndex + 1, 0, $childs);
         }
     }
     return $tree;
 }
 public function filterQuery($query)
 {
     // limit to a repository if selected
     if (!empty($this->request->repository)) {
         $query->addSubquery(QubitSearch::getInstance()->addTerm($this->request->repository, 'repositoryId'), true);
         $this->queryTerms[] = array('term' => $this->getContext()->i18n->__('Repository') . ': ' . QubitRepository::getById($this->request->repository)->__toString(), 'operator' => 'and');
     }
     // digital object filters
     if ('true' == $this->request->hasDigitalObject) {
         $query->addSubquery(QubitSearch::getInstance()->addTerm('true', 'hasDigitalObject'), true);
         $this->queryTerms[] = array('term' => $this->getContext()->i18n->__('Digital object is available'), 'operator' => 'and');
     } else {
         if ('false' == $this->request->hasDigitalObject) {
             $query->addSubquery(QubitSearch::getInstance()->addTerm('false', 'hasDigitalObject'), true);
             $this->queryTerms[] = array('term' => $this->getContext()->i18n->__('No digital object is available'), 'operator' => 'and');
         }
     }
     if (!empty($this->request->mediatype)) {
         $query->addSubquery(QubitSearch::getInstance()->addTerm($this->request->mediatype, 'do_mediaTypeId'), true);
         $this->queryTerms[] = array('term' => 'mediatype: ' . QubitTerm::getById($this->request->mediatyp)->__toString(), 'operator' => 'and');
     }
     $query = parent::filterQuery($query);
     return $query;
 }
Пример #14
0
 protected function addFormFields()
 {
     // Media type field
     $choices = array();
     $criteria = new Criteria();
     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MEDIA_TYPE_ID);
     foreach (QubitTerm::get($criteria) as $item) {
         $choices[$item->id] = $item->getName(array('cultureFallback' => true));
     }
     asort($choices);
     // Sort media types by name
     $this->form->setValidator('mediaType', new sfValidatorChoice(array('choices' => array_keys($choices))));
     $this->form->setWidget('mediaType', new sfWidgetFormSelect(array('choices' => $choices)));
     $this->form->setDefault('mediaType', $this->resource->mediaTypeId);
     // Only display "compound digital object" toggle if we have a child with a
     // digital object
     $this->showCompoundObjectToggle = false;
     foreach ($this->informationObject->getChildren() as $item) {
         if (null !== $item->getDigitalObject()) {
             $this->showCompoundObjectToggle = true;
             break;
         }
     }
     if ($this->showCompoundObjectToggle) {
         $this->form->setValidator('displayAsCompound', new sfValidatorBoolean());
         $this->form->setWidget('displayAsCompound', new sfWidgetFormSelectRadio(array('choices' => array('1' => $this->context->i18n->__('Yes'), '0' => $this->context->i18n->__('No')))));
         // Set "displayAsCompound" value from QubitProperty
         $criteria = new Criteria();
         $criteria->add(QubitProperty::OBJECT_ID, $this->resource->id);
         $criteria->add(QubitProperty::NAME, 'displayAsCompound');
         if (null != ($compoundProperty = QubitProperty::getOne($criteria))) {
             $this->form->setDefault('displayAsCompound', $compoundProperty->getValue(array('sourceCulture' => true)));
         }
     }
     // Add rights component
     $this->rightEditComponent = new RightEditComponent($this->context, 'right', 'edit');
     $this->rightEditComponent->resource = $this->resource;
     $this->rightEditComponent->execute($this->request);
     $maxUploadSize = QubitDigitalObject::getMaxUploadSize();
     ProjectConfiguration::getActive()->loadHelpers('Qubit');
     // If reference representation doesn't exist, include upload widget
     foreach ($this->representations as $usageId => $representation) {
         if (null === $representation) {
             $repName = "repFile_{$usageId}";
             $derName = "generateDerivative_{$usageId}";
             $this->form->setValidator($repName, new sfValidatorFile());
             $this->form->setWidget($repName, new sfWidgetFormInputFile());
             if (-1 < $maxUploadSize) {
                 $this->form->getWidgetSchema()->{$repName}->setHelp($this->context->i18n->__('Max. size ~%1%', array('%1%' => hr_filesize($maxUploadSize))));
             } else {
                 $this->form->getWidgetSchema()->{$repName}->setHelp('');
             }
             // Add "auto-generate" checkbox
             $this->form->setValidator($derName, new sfValidatorBoolean());
             $this->form->setWidget($derName, new sfWidgetFormInputCheckbox(array(), array('value' => 1)));
         } else {
             $this["rightEditComponent_{$usageId}"] = new RightEditComponent($this->context, 'right', 'edit');
             $this["rightEditComponent_{$usageId}"]->resource = $representation;
             $this["rightEditComponent_{$usageId}"]->nameFormat = 'editRight' . $usageId . '[%s]';
             $this["rightEditComponent_{$usageId}"]->execute($this->request);
         }
     }
 }
Пример #15
0
 public static function eventTypes()
 {
     return array(QubitTerm::getById(QubitTerm::CONTRIBUTION_ID), QubitTerm::getById(QubitTerm::CREATION_ID), QubitTerm::getById(QubitTerm::PUBLICATION_ID));
 }
 protected static function getTermBySourceNote($sourceNote)
 {
     $criteria = new Criteria();
     $criteria->addJoin(QubitTerm::ID, QubitNote::OBJECT_ID);
     $criteria->addJoin(QubitNote::ID, QubitNoteI18n::ID);
     $criteria->add(QubitNoteI18n::CONTENT, $sourceNote);
     return QubitTerm::getOne($criteria);
 }
 public static function eventTypes()
 {
     return array(QubitTerm::getById(QubitTerm::CREATION_ID), QubitTerm::getById(QubitTerm::ACCUMULATION_ID));
 }
Пример #18
0
 public static function isAllowed($role, $resource, $action, $options = array())
 {
     if (!$role instanceof myUser) {
         self::getInstance()->addRole($role);
     }
     // If attempting to read a draft information object, check viewDraft permission
     if ('read' == $action && $resource instanceof QubitInformationObject) {
         if (null === $resource->getPublicationStatus()) {
             throw new sfException('No publication status set for information object id: ' . $resource->id);
         }
         if (QubitTerm::PUBLICATION_STATUS_DRAFT_ID == $resource->getPublicationStatus()->statusId) {
             $instance = self::getInstance()->buildAcl($resource, $options);
             return $instance->acl->isAllowed($role, $resource, 'read') && $instance->acl->isAllowed($role, $resource, 'viewDraft');
         }
     }
     // If resource is a new object (no id yet) figure out if we should test
     // authorization against parent (e.g. creating a new resource)
     if (is_object($resource) && !isset($resource->id)) {
         if (!isset($resource->parentId)) {
             return false;
         }
         if ('create' == $action) {
             // For create action always check permissions against parent
             $resource = $resource->parent;
         } else {
             if ($resource instanceof QubitInformationObject) {
                 // Special rules for information object
                 $resource = QubitInformationObjectAcl::getParentForIsAllowed($resource, $action);
             }
         }
         // If we still don't have a valid resource id, then deny access
         if (!isset($resource) || !isset($resource->id)) {
             return false;
         }
     }
     // HACKS for limiting term permissions by taxonomy
     if ($resource instanceof QubitTaxonomy && 'createTerm' == $action) {
         $term = clone QubitTerm::getById(QubitTerm::ROOT_ID);
         $term->taxonomyId = $resource->id;
         $action = 'create';
         $resource = $term;
     } else {
         if ($resource instanceof QubitTerm && array_key_exists('taxonomyId', $options)) {
             // Create clone resource that we can assign to an arbitrary taxonomy
             $resource = clone $resource;
             $resource->taxonomyId = $options['taxonomyId'];
         }
     }
     self::getInstance()->buildAcl($resource, $options);
     return self::getInstance()->acl->isAllowed($role, $resource, $action);
 }
Пример #19
0
?>
        </th><th style="width: 60%">
          <?php 
echo __('Title');
?>
        </th>
      </tr>
    </thead><tbody>
      <tr>
        <td>
          <input type="text" name="updateChildLevels[0][identifier]"/>
        </td><td>
          <select name="updateChildLevels[0][levelOfDescription]" id="updateChildLevels_0_levelOfDescription">
            <option value="">&nbsp;</option>
            <?php 
foreach (QubitTerm::getLevelsOfDescription() as $item) {
    ?>
              <option value="<?php 
    echo $item->id;
    ?>
"><?php 
    echo $item->__toString();
    ?>
</option>
            <?php 
}
?>
          </select>
        </td><td>
          <input type="text" name="updateChildLevels[0][title]"/>
        </td>
Пример #20
0
 public static function gettermsById($id, array $options = array())
 {
     $criteria = new Criteria();
     self::addtermsCriteriaById($criteria, $id);
     return QubitTerm::get($criteria, $options);
 }
 public function setPhysicalObjectByName($physicalObjectName, $options)
 {
     // see if physical object already exists, otherwise create a new physical object
     $criteria = new Criteria();
     $criteria->addJoin(QubitPhysicalObject::ID, QubitPhysicalObjectI18n::ID);
     $criteria->add(QubitPhysicalObjectI18n::NAME, $physicalObjectName);
     if ($existingPhysicalObject = QubitPhysicalObject::getOne($criteria)) {
         $this->addPhysicalObject($existingPhysicalObject);
     } else {
         $newPhysicalObject = new QubitPhysicalObject();
         $newPhysicalObject->setName($physicalObjectName);
         // see if physical object type already exists, otherwise create a new one
         if ($options['type']) {
             $criteria = new Criteria();
             $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PHYSICAL_OBJECT_TYPE_ID);
             $criteria->add(QubitTermI18n::NAME, $options['type']);
             if ($physicalObjectType = QubitTerm::getOne($criteria)) {
                 $newPhysicalObject->setTypeId($physicalObjectType->id);
             } else {
                 $newTerm = new QubitTerm();
                 $newTerm->setTaxonomyId(QubitTaxonomy::PHYSICAL_OBJECT_TYPE_ID);
                 $newTerm->setName($options['type']);
                 $newTerm->parentId = QubitTerm::CONTAINER_ID;
                 $newTerm->save();
                 $newPhysicalObject->setTypeId($newTerm->id);
             }
         }
         if (isset($options['location'])) {
             $newPhysicalObject->setLocation($options['location']);
         }
         $newPhysicalObject->save();
         $this->addPhysicalObject($newPhysicalObject);
     }
 }
Пример #22
0
 public function setTypeByName($name)
 {
     // See if type term already exists
     $criteria = new Criteria();
     $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
     $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::REPOSITORY_TYPE_ID);
     $criteria->add(QubitTermI18n::NAME, $name);
     if (null === ($term = QubitTerm::getOne($criteria))) {
         $term = new QubitTerm();
         $term->setTaxonomyId(QubitTaxonomy::REPOSITORY_TYPE_ID);
         $term->setName($name);
         $term->setRoot();
         $term->save();
     }
     foreach (self::getTermRelations(QubitTaxonomy::REPOSITORY_TYPE_ID) as $item) {
         // Faster than $item->term == $term
         if ($item->termId == $term->id) {
             return;
         }
     }
     $relation = new QubitObjectTermRelation();
     $relation->term = $term;
     $this->objectTermRelationsRelatedByobjectId[] = $relation;
 }
Пример #23
0
      <?php 
echo $form->licenseIdentifier->help(__('Can be text value or URI (e.g. to Creative Commons, GNU or other online licenses). Used to identify the granting agreement uniquely within the repository system.'))->renderRow();
?>

      <?php 
echo $form->licenseTerms->help(__('Text describing the license or agreement by which permission was granted or link to full-text hosted online. This can contain the actual text of the license or agreement or a paraphrase or summary.'))->renderRow();
?>

      <?php 
echo $form->licenseNote->help(__('Additional information about the license, such as contact persons, action dates, or interpretations. The note may also indicated the location of the license, if it is available online or embedded in the object itself.'))->renderRow();
?>

    </fieldset>

    <fieldset route="<?php 
echo $sf_context->routing->generate(null, array(QubitTerm::getById(QubitTerm::RIGHT_BASIS_STATUTE_ID), 'module' => 'term'));
?>
">

      <legend><?php 
echo __('Statute information');
?>
</legend>

      <?php 
echo $form->statuteJurisdiction->help(__('The country or other political body that has enacted the statute.'))->renderRow();
?>

      <?php 
echo $form->statuteCitation->help(__('An identifying designation for the statute. Use standard citation form when applicable, e.g. bibliographic citation.'))->renderRow();
?>
Пример #24
0
 public function execute($request)
 {
     // Default items per page
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     $this->form = new sfForm();
     $this->resource = $this->getRoute()->resource;
     // Check that the object exists and that it is not the root
     if (!isset($this->resource) || !isset($this->resource->parent)) {
         $this->forward404();
     }
     // Check authorization
     if (!QubitAcl::check($this->resource, 'update')) {
         QubitAcl::forwardUnauthorized();
     }
     // "parent" form field
     $this->form->setValidator('parent', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('parent', new sfWidgetFormInputHidden());
     // Root is default parent
     if ($this->resource instanceof QubitInformationObject) {
         $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitInformationObject::getById(QubitInformationObject::ROOT_ID), 'module' => 'informationobject'))));
     } else {
         if ($this->resource instanceof QubitTerm) {
             $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitTerm::getById(QubitTerm::ROOT_ID), 'module' => 'term'))));
         }
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue()));
             // In term treeview, root node links (href) to taxonomy, but it represents the term root object
             if ($this->resource instanceof QubitTerm && QubitObject::getById($params['_sf_route']->resource->id) instanceof QubitTaxonomy) {
                 $this->resource->parentId = QubitTerm::ROOT_ID;
             } else {
                 $this->resource->parentId = $params['_sf_route']->resource->id;
             }
             $this->resource->save();
             if ($request->isXmlHttpRequest()) {
                 return $this->renderText('');
             } else {
                 if ($this->resource instanceof QubitInformationObject) {
                     $this->redirect(array($this->resource, 'module' => 'informationobject'));
                 } else {
                     if ($this->resource instanceof QubitTerm) {
                         $this->redirect(array($this->resource, 'module' => 'term'));
                     }
                 }
             }
         }
     }
     $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue()));
     $this->parent = QubitObject::getById($params['_sf_route']->resource->id);
     $query = QubitSearch::getInstance()->addTerm($this->parent->slug, 'parent');
     if (isset($request->query)) {
         $query = $request->query;
     }
     $this->pager = new QubitArrayPager();
     $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
     $ids = array();
     foreach ($this->pager->getResults() as $hit) {
         $ids[] = $hit->getDocument()->id;
     }
     $criteria = new Criteria();
     $criteria->add(QubitObject::ID, $ids, Criteria::IN);
     $this->results = QubitObject::get($criteria);
 }
Пример #25
0
 protected function updateChildLevels()
 {
     if (is_array($updateChildLevels = $this->request->updateChildLevels) && count($updateChildLevels)) {
         foreach ($updateChildLevels as $item) {
             $childLevel = new QubitInformationObject();
             $childLevel->identifier = $item['identifier'];
             $childLevel->title = $item['title'];
             if (null != ($pubStatus = $this->resource->getPublicationStatus())) {
                 $childLevel->setPublicationStatus($pubStatus->statusId);
             }
             if (0 < strlen($item['levelOfDescription']) && null !== QubitTerm::getById($item['levelOfDescription'])) {
                 $childLevel->levelOfDescriptionId = $item['levelOfDescription'];
             }
             if (0 < strlen($item['levelOfDescription']) || 0 < strlen($item['identifier']) || 0 < strlen($item['title'])) {
                 $this->resource->informationObjectsRelatedByparentId[] = $childLevel;
             }
         }
     }
 }
Пример #26
0
</li>
                        <li><input type="radio" name="acl[<?php 
                echo $item[$action]->id;
                ?>
]" value="<?php 
                echo QubitAcl::INHERIT;
                ?>
"><?php 
                echo __('Inherit');
                ?>
</li>
                      <?php 
            } else {
                ?>
                        <?php 
                $rootTermUrl = url_for(array(QubitTerm::getById(QubitTerm::ROOT_ID), 'module' => 'term'));
                ?>
                        <li><input type="radio" name="acl[<?php 
                echo $action . '_' . $rootTermUrl;
                ?>
]" value="<?php 
                echo QubitAcl::GRANT;
                ?>
"><?php 
                echo __('Grant');
                ?>
</li>
                        <li><input type="radio" name="acl[<?php 
                echo $action . '_' . $rootTermUrl;
                ?>
]" value="<?php 
Пример #27
0
    echo $item->id;
    ?>
]" value="delete" class="multiDelete"/>
              </td>
            </tr>
          <?php 
}
?>

          <tr valign="top">
            <td>
              <input name="rad_note"/>
            </td><td>
              <select name="rad_note_type" id="rad_title_note_type">
                <?php 
foreach (QubitTerm::getOptionsForSelectList(QubitTaxonomy::RAD_NOTE_ID) as $value => $label) {
    ?>
                  <option value="<?php 
    echo esc_entities($value);
    ?>
"><?php 
    echo esc_entities($label);
    ?>
</option>
                <?php 
}
?>
              </select>
            </td>
          </tr>
Пример #28
0
?>

    <?php 
echo get_partial('right/edit', $rightEditComponent->getVarHolder()->getAll());
?>

  </fieldset>

  <?php 
foreach ($representations as $usageId => $representation) {
    ?>

    <fieldset class="collapsible">

      <legend><?php 
    echo __('%1% representation', array('%1%' => QubitTerm::getById($usageId)));
    ?>
</legend>

      <?php 
    if (isset($representation)) {
        ?>

        <?php 
        echo get_component('digitalobject', 'editRepresentation', array('resource' => $resource, 'representation' => $representation));
        ?>

        <?php 
        $rightComponent = "rightEditComponent_{$usageId}";
        ?>
        <?php 
 protected function mapIsdiah($parameters)
 {
     // remove duplicate values
     if ($parameters['parallelName'] == $parameters['authorizedFormOfName']) {
         unset($parameters['parallelName']);
     }
     if ($parameters['otherName'] == $parameters['authorizedFormOfName']) {
         unset($parameters['otherName']);
     }
     // NB: this is hacky, but required for an inconsistency in repository property names
     if (!isset($this->descriptionDetailLevels)) {
         foreach (QubitTerm::getDescriptionDetailLevels() as $term) {
             $this->descriptionDetailLevels[] = $term;
         }
     }
     if (!in_array($parameters['descDetail'], $this->descriptionDetailLevels)) {
         unset($parameters['descDetail']);
     }
     if (!isset($this->descriptionStatuss)) {
         foreach (QubitTerm::getDescriptionStatuses() as $term) {
             $this->descriptionStatuss[] = $term;
         }
     }
     if (!in_array($parameters['descStatus'], $this->descriptionStatuss)) {
         unset($parameters['descStatus']);
     }
     return $parameters;
 }