/**
  * @return array<list_Item>
  */
 public final function getItems()
 {
     try {
         $request = Controller::getInstance()->getContext()->getRequest();
         $questionId = intval($request->getParameter('questionId', 0));
         $question = DocumentHelper::getDocumentInstance($questionId);
     } catch (Exception $e) {
         if (Framework::isDebugEnabled()) {
             Framework::debug(__METHOD__ . ' EXCEPTION: ' . $e->getMessage());
         }
         return array();
     }
     // Here we must use instanceof and not getDocumentModelName to work with injection.
     $results = array();
     if ($question instanceof form_persistentdocument_boolean) {
         $trueLabel = $question->getTruelabel();
         $falseLabel = $question->getFalselabel();
         $results[$trueLabel] = new list_Item($trueLabel, $trueLabel);
         $results[$falseLabel] = new list_Item($falseLabel, $falseLabel);
     } else {
         if ($question instanceof form_persistentdocument_list) {
             $results = $question->getDataSource()->getItems();
         }
     }
     return $results;
 }
 /**
  * @return array<list_Item>
  */
 public final function getItems()
 {
     $request = Controller::getInstance()->getContext()->getRequest();
     $form = null;
     $conditionOn = null;
     try {
         $conditionOnId = intval($request->getParameter('documentId', 0));
         if ($conditionOnId > 0) {
             $conditionOn = DocumentHelper::getDocumentInstance($conditionOnId);
             $form = $conditionOn->getForm();
         } else {
             $parent = DocumentHelper::getDocumentInstance(intval($request->getParameter('parentId', 0)));
             if ($parent instanceof form_persistentdocument_baseform) {
                 $form = $parent;
             } else {
                 if ($parent instanceof form_persistentdocument_group) {
                     $form = $parent->getForm();
                 }
             }
         }
     } catch (Exception $e) {
         Framework::exception($e);
     }
     if (!$form instanceof form_persistentdocument_baseform) {
         return array();
     }
     $results = array();
     $excludeIds = $this->getExcludeIds($conditionOn);
     foreach ($form->getDocumentService()->getValidActivationFields($form, $excludeIds) as $field) {
         $results[] = new list_Item($field->getLabel(), $field->getId());
     }
     return $results;
 }
 /**
  * @param block_BlockContext $context
  * @param block_BlockRequest $request
  * @return String the view name
  */
 public function execute($context, $request)
 {
     if (!$request->hasNonEmptyParameter('id')) {
         return block_BlockView::NONE;
     }
     $id = $request->getParameter('id');
     $form = DocumentHelper::getDocumentInstance($id);
     $user = $context->getGlobalContext()->getUser();
     $attr = 'form_success_parameters_' . $form->getId();
     $parameters = $user->getAttribute($attr);
     if ($parameters === null) {
         return block_BlockView::NONE;
     }
     $user->removeAttribute($attr);
     $message = $form->getConfirmMessage();
     foreach ($parameters as $k => $v) {
         $message = str_replace('{' . $k . '}', htmlspecialchars($v), $message);
     }
     $this->setParameter('message', $message);
     if ($form->getUseBackLink()) {
         $this->setParameter('back', array('url' => $parameters[form_FormConstants::BACK_URL_PARAMETER], 'label' => f_Locale::translate('&modules.form.frontoffice.Back;')));
     } else {
         $this->setParameter('back', false);
     }
     $this->setParameter('form', $form);
     return block_BlockView::SUCCESS;
 }
Ejemplo n.º 4
0
 public static function configurePage(Template $t, $title, $bodyContent = null, $jsExtra = null)
 {
     $t->insertSlot("TITLE", $title);
     $currentPage = DocumentHelper::getCurrentPageName();
     if ($bodyContent !== null) {
         $t->insertSlot("BODY_CONTENT", $bodyContent);
     }
     if ($jsExtra !== null) {
         $t->insertBlock("JS_EXTRA", $jsExtra);
     }
     if (SessionHelper::isAdmin()) {
         // logged in as admin
         $t->insertSlot("LOGIN_TEXT", "LOG OUT " . SessionHelper::getName());
         $t->insertSlot("LOGIN_LINK", "logout.php");
     } else {
         $t->insertBlock("LOGIN", "");
     }
     // menu - highlight current page
     $t->insertSlot("CLASS_ABOUT", $currentPage == "about.php" ? "current" : "");
     $t->insertSlot("CLASS_BOOKINGS", $currentPage == "bookings.php" ? "current" : "");
     $t->insertSlot("CLASS_VALET_PARKING", $currentPage == "valet_parking.php" ? "current" : "");
     $t->insertSlot("CLASS_VEHICLE_STORAGE", $currentPage == "vehicle_storage.php" ? "current" : "");
     $t->insertSlot("CLASS_POOL_CAR", $currentPage == "pool_car.php" ? "current" : "");
     $t->insertSlot("CLASS_RATES", $currentPage == "rates.php" ? "current" : "");
     $t->insertSlot("CLASS_VIDEO", $currentPage == "video.php" ? "current" : "");
 }
 /**
  * @param form_persistentdocument_mail $document
  * @param Integer $parentNodeId Parent node ID where to save the document (optionnal => can be null !).
  * @throws form_ReplyToFieldAlreadyExistsException
  * @return void
  */
 protected function preSave($document, $parentNodeId = null)
 {
     if ($document->getMultiline()) {
         $document->setValidators('emails:true');
     } else {
         $document->setValidators('email:true');
     }
     if ($parentNodeId !== NULL) {
         $form = DocumentHelper::getDocumentInstance($parentNodeId);
     } else {
         $form = $this->getFormOf($document);
     }
     if ($form === null) {
         if (Framework::isWarnEnabled()) {
             Framework::warn(__METHOD__ . ' the mail field document (' . $document->__toString() . ')is not in a form');
         }
     } else {
         if ($document->getUseAsReply()) {
             $oldReplyField = form_BaseFormService::getInstance()->getReplyToField($form);
             if ($oldReplyField !== null && $oldReplyField !== $document) {
                 Framework::error(__METHOD__ . ' Old reply field :' . $oldReplyField->__toString());
                 throw new form_ReplyToFieldAlreadyExistsException(f_Locale::translate('&modules.form.bo.errors.Mail-field-for-replyto-exists'));
             }
         }
     }
     parent::preSave($document, $parentNodeId);
 }
 /**
  * @param form_persistentdocument_file $field
  * @param DOMElement $fieldElm
  * @param mixed $rawValue
  * @return string
  */
 public function buildXmlElementResponse($field, $fieldElm, $rawValue)
 {
     if (is_numeric($rawValue)) {
         try {
             $document = DocumentHelper::getDocumentInstance($rawValue);
             $fieldElm->setAttribute('mailValue', $document->getLabel());
         } catch (Exception $e) {
             Framework::exception($e);
         }
     }
     return $rawValue;
 }
 /**
  * @see website_BlockAction::execute()
  * @param f_mvc_Request $request
  * @param f_mvc_Response $response
  * @return String
  */
 public function execute($request, $response)
 {
     if ($this->isInBackoffice()) {
         return website_BlockView::NONE;
     }
     $form = $this->getDocumentParameter();
     if ($form === null || !$form->isPublished()) {
         return website_BlockView::NONE;
     }
     $request->setAttribute('form', $form);
     $request->setAttribute('moduleName', $this->getModuleName());
     if ($request->hasParameter('receiverIds')) {
         $receiverIds = explode(',', $request->getParameter('receiverIds'));
         $receiverLabels = array();
         foreach ($receiverIds as $receiverId) {
             if (is_numeric($receiverId)) {
                 try {
                     $receiver = DocumentHelper::getDocumentInstance($receiverId);
                     $receiverLabels[] = $receiver->getLabel();
                 } catch (Exception $e) {
                     Framework::exception($e);
                     $receiverLabels[] = $receiverId;
                 }
             } else {
                 if (f_util_StringUtils::isNotEmpty($receiverId)) {
                     $receiverLabels[] = $receiverId;
                 }
             }
         }
         $request->setAttributes('receiverLabels', $receiverLabels);
     }
     $agaviUser = $this->getContext()->getGlobalContext()->getUser();
     if ($agaviUser->hasAttribute('form_success_parameters_' . $form->getId())) {
         $view = $this->getSuccessView($form, $request);
     } else {
         if ($request->hasParameter('submit_' . $form->getId())) {
             try {
                 $form->getDocumentService()->saveFormData($form, $request);
                 $agaviUser->setAttribute('form_success_parameters_' . $form->getId(), $request->getParameters());
                 $view = $this->getSuccessView($form, $request);
             } catch (form_FormValidationException $e) {
                 $request->setAttribute('errors', $e->getErrorCollection());
                 $view = $this->getInputView($form, $request);
             }
         } else {
             $view = $this->getInputView($form, $request);
         }
     }
     return $view;
 }
 /**
  * @param form_persistentdocument_hidden $field
  * @param DOMElement $fieldElm
  * @param mixed $rawValue
  * @return string
  */
 public function buildXmlElementResponse($field, $fieldElm, $rawValue)
 {
     switch ($field->getIsRecommand()) {
         case 'site':
             return website_WebsiteModuleService::getInstance()->getCurrentWebsite()->getUrl();
             break;
         case 'page':
             try {
                 return LinkHelper::getUrl(DocumentHelper::getDocumentInstance($rawValue));
             } catch (Exception $e) {
                 Framework::exception($e);
             }
             return website_WebsiteModuleService::getInstance()->getCurrentWebsite()->getUrl();
     }
     return parent::buildXmlElementResponse($field, $fieldElm, $rawValue);
 }
Ejemplo n.º 9
0
<?php

session_start();
$pageName = basename($_SERVER["PHP_SELF"]);
require_once "classes/sessionhelper.class.php";
if (!SessionHelper::isLoggedIn() && $pageName != "login.php") {
    require_once "classes/documenthelper.class.php";
    //	echo "NOT LOGGED IN ";
    //	exit;
    header("Location: login.php?from=" . $pageName . DocumentHelper::getQueryString(true, true));
    exit;
}
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date in the past
 /**
  * @param form_persistentdocument_field $field
  * @param integer $parentNodeId
  * @throws form_FormException When $field is not inside a form
  * @throws form_FieldAlreadyExistsException When the name of $field is not available
  */
 public function checkFieldNameAvailable($field, $parentNodeId)
 {
     $fieldName = $field->getFieldName();
     $parent = DocumentHelper::getDocumentInstance($parentNodeId);
     if ($parent instanceof form_persistentdocument_baseform) {
         $form = $parent;
     } else {
         $form = $this->getAncestorFormByDocument($parent);
         if ($form === null) {
             throw new form_FormException("Field \"" . $field->__toString() . "\" is not inside a form.");
         }
     }
     $query = $this->getPersistentProvider()->createQuery('modules_form/field');
     $query->add(Restrictions::descendentOf($form->getId()));
     $query->add(Restrictions::eq('fieldName', $fieldName));
     $result = $query->findUnique();
     if ($result !== null && $result->getId() != $field->getId()) {
         throw new form_FieldAlreadyExistsException(f_Locale::translate('&modules.form.bo.errors.Field-name-alreay-used;', array('fieldName' => $fieldName)));
     }
 }
 /**
  * @param string $receiverIdStr
  * @param mail_MessageRecipients $recipients
  */
 private function handleReceveirIds($receiverIdStr, &$recipients)
 {
     $emailAddressArray = array();
     // Let's check if $receiverIdStr contains a list of email addresses...
     $errors = new validation_Errors();
     $validate = new validation_EmailsValidator();
     $validate->validate(new validation_Property(null, $receiverIdStr), $errors);
     // Errors have been found: $receiverIdStr does not seem to contain
     // email addresses, maybe it contains contacts ID.
     if (!$errors->isEmpty()) {
         // try to get the component and get its emails
         $receiverIdArray = explode(',', $receiverIdStr);
         foreach ($receiverIdArray as $receiverId) {
             $receiverId = f_util_Convert::fixDataType($receiverId);
             if (is_integer($receiverId)) {
                 try {
                     // Merge the previously found email addresses with
                     // the one of the contact with ID $receiverId.
                     $emailAddressArray = array_merge($emailAddressArray, DocumentHelper::getDocumentInstance($receiverId)->getEmailAddresses());
                 } catch (Exception $e) {
                     Framework::exception($e);
                 }
             }
         }
     } else {
         $emailAddressArray = explode(',', $receiverIdStr);
         $emailAddressArray = array_map("trim", $emailAddressArray);
     }
     $recipients->setTo($emailAddressArray);
 }
Ejemplo n.º 12
0
" value="" name="document_name_search" />
    </li>
    <li>
        <div class="ajax_loader"></div>
    </li>
</ul>

<small>
    <span id="documents_matched"></span> <?php 
echo TextHelper::_('COBALT_DOCUMENT_MATCHES');
?>
. <?php 
echo TextHelper::_('COBALT_DOCUMENT_THERE_ARE');
?>
 <span id="documents_total"><?php 
echo DocumentHelper::getTotalDocuments();
?>
</span> <?php 
echo TextHelper::_('COBALT_DOCUMENT_IN_YOUR_ACCOUNT');
?>
.
</small>
<?php 
echo TemplateHelper::getListEditActions();
?>
<form method="post" id="list_form" action="<?php 
echo RouteHelper::_('index.php?view=documents');
?>
">
    <table class="table table-hover table-striped data-table table-bordered dataTable no-footer" id="documents">
        <?php 
Ejemplo n.º 13
0
 private function __downloadPaper($paperId, $attachment, $documentType, $docid)
 {
     global $Opt, $Me, $zlib_output_compression;
     $result = $this->document_result($paperId, $documentType, $docid);
     if (!$result) {
         $this->log("Download error: " . $this->dblink->error, $Me, $paperId);
         return set_error_html("Database error while downloading paper.");
     } else {
         if (edb_nrows($result) == 0) {
             return set_error_html("No such document.");
         }
     }
     // Check data
     $docs = array();
     while ($doc = $this->document_row($result, $documentType)) {
         if (!$doc->mimetype) {
             $doc->mimetype = MIMETYPEID_PDF;
         }
         $doc->filename = HotCRPDocument::filename($doc);
         $docs[] = $doc;
     }
     if (count($docs) == 1 && $docs[0]->paperStorageId <= 1) {
         return set_error_html("Paper #" . $docs[0]->paperId . " hasn’t been uploaded yet.");
     }
     $downloadname = false;
     if (count($docs) > 1) {
         $downloadname = $Opt["downloadPrefix"] . pluralx(2, HotCRPDocument::unparse_dtype($documentType)) . ".zip";
     }
     return DocumentHelper::download($docs, $downloadname, $attachment);
 }
Ejemplo n.º 14
0
 /**
  * @param Integer $elementId
  * @return Boolean
  */
 public static function getActivationValue($elementId)
 {
     $element = DocumentHelper::getDocumentInstance($elementId);
     return $element->getActivationValue();
 }
 /**
  * @param Integer $fieldId
  * @return Boolean
  */
 public function hasCondition($fieldId)
 {
     $field = DocumentHelper::getDocumentInstance($fieldId);
     return $field->getActivationQuestion() !== null;
 }
 /**
  * Moves $field into the destination node identified by $destId.
  * @param form_persistentdocument_field $field The field to move.
  * @param integer $destId ID of the destination node.
  * @param integer $beforeId
  * @param integer $afterId
  */
 public function moveTo($field, $destId, $beforeId = null, $afterId = null)
 {
     $fbs = form_BaseformService::getInstance();
     $fieldForm = $fbs->getAncestorFormByDocument($field);
     $destDocument = DocumentHelper::getDocumentInstance($destId);
     if ($destDocument instanceof form_persistentdocument_baseform) {
         $destForm = $destDocument;
     } else {
         $destForm = $fbs->getAncestorFormByDocument($destDocument);
     }
     if (!DocumentHelper::isEquals($destForm, $fieldForm)) {
         throw new form_FormException(f_Locale::translate('&modules.form.bo.errors.Cannot-move-a-field-from-a-form-to-another-form;'));
     }
     return parent::moveTo($field, $destId, $beforeId, $afterId);
 }
 /**
  * @param block_BlockContext $context
  * @param block_BlockRequest $request
  * @return String the view name
  */
 public function execute($context, $request)
 {
     $id = $this->getFormId();
     if (empty($id)) {
         return block_BlockView::NONE;
     }
     $form = DocumentHelper::getDocumentInstance($id);
     if (!$form->isPublished()) {
         return block_BlockView::NONE;
     }
     $form->getDocumentNode()->getDescendents();
     $this->setParameter('form', $form);
     if ($context->inBackofficeMode()) {
         return block_BlockView::DUMMY;
     }
     if ($request->hasParameter("receiverIds")) {
         $receiverIds = explode(",", $request->getParameter("receiverIds"));
         $receiverLabels = array();
         foreach ($receiverIds as $receiverId) {
             if (is_numeric($receiverId)) {
                 try {
                     $receiver = DocumentHelper::getDocumentInstance($receiverId);
                     $receiverLabels[] = $receiver->getLabel();
                 } catch (Exception $e) {
                     Framework::exception($e);
                     $receiverLabels[] = $receiverId;
                 }
             } elseif (f_util_StringUtils::isNotEmpty($receiverId)) {
                 $receiverLabels[] = $receiverId;
             }
         }
         $this->setParameter("receiverLabels", $receiverLabels);
     }
     if ($this->isSuccess($context, $request)) {
         $view = block_BlockView::SUCCESS;
     } else {
         if ($this->isFormPosted($request)) {
             $fs = form_FormService::getInstance();
             try {
                 $fs->saveFormData($form, $request);
                 $user = $context->getGlobalContext()->getUser();
                 $user->setAttribute('form_success_parameters_' . $form->getId(), $request->getParameters());
                 $view = block_BlockView::SUCCESS;
             } catch (form_FormValidationException $e) {
                 $this->setParameter('errors', $e->getErrorCollection());
                 $view = block_BlockView::INPUT;
             }
         } else {
             $view = block_BlockView::INPUT;
         }
     }
     // Calls the BlockFormDecorator if present.
     $formId = $form->getFormid();
     $matches = null;
     if (preg_match('#^modules_([a-z]+)/([a-z]+)$#', $formId, $matches)) {
         $extendClassName = $matches[1] . '_BlockForm' . ucfirst($matches[2]) . 'Decorator';
         if (f_util_ClassUtils::classExists($extendClassName)) {
             $instance = new $extendClassName($this);
             if ($instance instanceof form_BlockFormDecorator) {
                 $instance->execute($context, $request);
             } else {
                 Framework::warn("\"{$extendClassName}\" is not an instance of \"block_BlockDecorator\": form \"{$formId}\" won't be decorated.");
             }
         }
     }
     return $view;
 }