public function execute($request)
 {
     $this->resource = $this->getRoute()->resource;
     // Check that this isn't the root
     if (!isset($this->resource->parent)) {
         $this->forward404();
     }
     // Check user authorization
     if (!QubitAcl::check($this->resource, 'read')) {
         QubitAcl::forwardToSecureAction();
     }
     if ('print' == $request->getGetParameter('media', 'screen')) {
         $this->getResponse()->addStylesheet('print-preview', 'last');
     }
     // Only show link to view/download master copy of digital object if the
     // user has readMaster permissions OR it's a text object (to allow reading)
     $this->digitalObjectLink = null;
     if (0 < count($this->resource->digitalObjects) && (QubitAcl::check($this->resource, 'readMaster') || in_array($this->resource->digitalObjects[0]->mediaTypeId, array(QubitTerm::TEXT_ID, QubitTerm::AUDIO_ID)))) {
         if (QubitTerm::EXTERNAL_URI_ID == $this->resource->digitalObjects[0]->usageId) {
             $this->digitalObjectLink = $this->resource->digitalObjects[0]->path;
         } else {
             $this->digitalObjectLink = $request->getUriPrefix() . $request->getRelativeUrlRoot() . $this->resource->digitalObjects[0]->getFullPath();
         }
     }
     QubitImageFlow::addAssets($this->response);
     QubitTreeView::addAssets($this->response);
 }
 public function execute($request)
 {
     $this->resource = $this->getRoute()->resource;
     // Check user authorization
     if (!QubitAcl::check($this->resource, 'read')) {
         QubitAcl::forwardToSecureAction();
     }
     if (1 > strlen($title = $this->resource->__toString())) {
         $title = $this->context->i18n->__('Untitled');
     }
     $this->response->setTitle("{$title} - {$this->response->getTitle()}");
     if (QubitAcl::check($this->resource, 'update')) {
         $validatorSchema = new sfValidatorSchema();
         $values = array();
         $validatorSchema->date = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Acquisition date - This is a mandatory element.')));
         $values['date'] = $this->resource->date;
         $validatorSchema->sourceOfAcquisition = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Source of acquisition - This is a mandatory element.')));
         $values['sourceOfAcquisition'] = $this->resource->getSourceOfAcquisition(array('culltureFallback' => true));
         $validatorSchema->locationInformation = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('Location information - This is a mandatory element.')));
         $values['locationInformation'] = $this->resource->getLocationInformation(array('culltureFallback' => true));
         try {
             $validatorSchema->clean($values);
         } catch (sfValidatorErrorSchema $e) {
             $this->errorSchema = $e;
         }
     }
 }
 protected function earlyExecute()
 {
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
     $this->form->getValidatorSchema()->setPostValidator(new sfValidatorSchemaCompare('password', '==', 'confirmPassword', array(), array('invalid' => $this->context->i18n->__('Your password confirmation did not match you password.'))));
     $this->resource = new QubitUser();
     if (isset($this->getRoute()->resource)) {
         $this->resource = $this->getRoute()->resource;
     }
     // Except for administrators, only allow users to reset their own password
     if (!$this->context->user->hasCredential('administrator')) {
         if ($this->resource->id != $this->context->user->getAttribute('user_id')) {
             QubitAcl::forwardToSecureAction();
         }
     }
 }