/** * Edit settings. */ public function settings() { global $lng, $ilAccess; $this->tabs_gui->setTabActive('settings'); $form_settings = new ilSetting("certificate"); include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); $form->setTitle($this->lng->txt('certificate_settings')); $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active"); $active->setChecked($form_settings->get("active")); $form->addItem($active); $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info"); $info->setValue($this->lng->txt("certificate_usage")); $form->addItem($info); $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background"); $bgimage->setRequired(FALSE); if (count($_POST)) { // handle the background upload if (strlen($_FILES["background"]["tmp_name"])) { if ($bgimage->checkInput()) { $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]); if ($result == FALSE) { $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage")); } } } } if (strlen($this->object->hasBackgroundImage())) { $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb()); } $bgimage->setInfo($this->lng->txt("default_background_info")); $form->addItem($bgimage); $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat"); $defaultformats = array("a4" => $this->lng->txt("certificate_a4"), "a4landscape" => $this->lng->txt("certificate_a4_landscape"), "a5" => $this->lng->txt("certificate_a5"), "a5landscape" => $this->lng->txt("certificate_a5_landscape"), "letter" => $this->lng->txt("certificate_letter"), "letterlandscape" => $this->lng->txt("certificate_letter_landscape")); $format->setOptions($defaultformats); $format->setValue($form_settings->get("pageformat")); $format->setInfo($this->lng->txt("certificate_page_format_info")); $form->addItem($format); if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) { $form->addCommandButton('save', $this->lng->txt('save')); } $this->tpl->setContent($form->getHTML()); if (strcmp($this->ctrl->getCmd(), "save") == 0) { if ($_POST["background_delete"]) { $this->object->deleteBackgroundImage(); } } }
/** * Shows the certificate editor for ILIAS tests */ public function certificateEditor() { global $ilAccess; $form_fields = array(); if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) { $form_fields = $this->getFormFieldsFromPOST(); } else { $form_fields = $this->getFormFieldsFromFO(); } include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setPreventDoubleSubmission(false); $form->setFormAction($this->ctrl->getFormAction($this)); $form->setTitle($this->lng->txt("certificate_edit")); $form->setMultipart(TRUE); $form->setTableWidth("100%"); $form->setId("certificate"); $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active"); $active->setChecked($form_fields["active"]); $form->addItem($active); $import = new ilFileInputGUI($this->lng->txt("import"), "certificate_import"); $import->setRequired(FALSE); $import->setSuffixes(array("zip")); // handle the certificate import if (strlen($_FILES["certificate_import"]["tmp_name"])) { if ($import->checkInput()) { $result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]); if ($result == FALSE) { $import->setAlert($this->lng->txt("certificate_error_import")); } else { $this->ctrl->redirect($this, "certificateEditor"); } } } $form->addItem($import); $pageformat = new ilRadioGroupInputGUI($this->lng->txt("certificate_page_format"), "pageformat"); $pageformats = $this->object->getPageFormats(); $pageformat->setValue($form_fields["pageformat"]); foreach ($pageformats as $format) { $option = new ilRadioOption($format["name"], $format["value"]); if (strcmp($format["value"], "custom") == 0) { $pageheight = new ilTextInputGUI($this->lng->txt("certificate_pageheight"), "pageheight"); $pageheight->setValue($form_fields["pageheight"]); $pageheight->setSize(6); $pageheight->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is"); $pageheight->setInfo($this->lng->txt("certificate_unit_description")); $pageheight->setRequired(true); $option->addSubitem($pageheight); $pagewidth = new ilTextInputGUI($this->lng->txt("certificate_pagewidth"), "pagewidth"); $pagewidth->setValue($form_fields["pagewidth"]); $pagewidth->setSize(6); $pagewidth->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is"); $pagewidth->setInfo($this->lng->txt("certificate_unit_description")); $pagewidth->setRequired(true); $option->addSubitem($pagewidth); } $pageformat->addOption($option); } $pageformat->setRequired(true); if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) { $pageformat->checkInput(); } $form->addItem($pageformat); $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background"); $bgimage->setRequired(FALSE); $bgimage->setUseCache(false); if (count($_POST)) { // handle the background upload if (strlen($_FILES["background"]["tmp_name"])) { if ($bgimage->checkInput()) { $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]); if ($result == FALSE) { $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage")); } } } } if (!$this->object->hasBackgroundImage()) { include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php"; if (ilObjCertificateSettingsAccess::hasBackgroundImage()) { $bgimage->setImage(ilObjCertificateSettingsAccess::getBackgroundImageThumbPathWeb()); } } else { $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb()); } $form->addItem($bgimage); $padding_top = new ilTextInputGUI($this->lng->txt("certificate_padding_top"), "padding_top"); $padding_top->setRequired(TRUE); $padding_top->setValue($form_fields["padding_top"]); $padding_top->setSize(6); $padding_top->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is"); $padding_top->setInfo($this->lng->txt("certificate_unit_description")); if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) { $padding_top->checkInput(); } $form->addItem($padding_top); $rect = new ilCSSRectInputGUI($this->lng->txt("certificate_margin_body"), "margin_body"); $rect->setRequired(TRUE); $rect->setUseUnits(TRUE); $rect->setTop($form_fields["margin_body_top"]); $rect->setBottom($form_fields["margin_body_bottom"]); $rect->setLeft($form_fields["margin_body_left"]); $rect->setRight($form_fields["margin_body_right"]); $rect->setInfo($this->lng->txt("certificate_unit_description")); if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) { $rect->checkInput(); } $form->addItem($rect); $certificate = new ilTextAreaInputGUI($this->lng->txt("certificate_text"), "certificate_text"); $certificate->removePlugin('ilimgupload'); $certificate->setValue($form_fields["certificate_text"]); $certificate->setRequired(TRUE); $certificate->setRows(20); $certificate->setCols(80); // fraunhpatch start $common_desc_tpl = new ilTemplate("tpl.common_desc.html", true, true, "Services/Certificate"); foreach (ilCertificate::getCustomCertificateFields() as $f) { $common_desc_tpl->setCurrentBlock("cert_field"); $common_desc_tpl->setVariable("PH", $f["ph"]); $common_desc_tpl->setVariable("PH_TXT", $f["name"]); $common_desc_tpl->parseCurrentBlock(); } $common_desc = $common_desc_tpl->get(); // fraunhpatch start $certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription() . $common_desc); $certificate->setUseRte(TRUE, '3.4.7'); $tags = array("br", "em", "font", "li", "ol", "p", "span", "strong", "u", "ul"); $certificate->setRteTags($tags); if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) { $certificate->checkInput(); } $form->addItem($certificate); $this->object->getAdapter()->addAdditionalFormElements($form, $form_fields); if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { if ($this->object->isComplete() || $this->object->hasBackgroundImage()) { $form->addCommandButton("certificatePreview", $this->lng->txt("certificate_preview")); $form->addCommandButton("certificateExportFO", $this->lng->txt("certificate_export")); $form->addCommandButton("certificateDelete", $this->lng->txt("delete")); } $form->addCommandButton("certificateSave", $this->lng->txt("save")); } $this->tpl->setVariable("ADM_CONTENT", $form->getHTML()); if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) { if ($_POST["background_delete"]) { $this->object->deleteBackgroundImage(); } if ($form->checkInput()) { try { $xslfo = $this->object->processXHTML2FO($form_fields); $this->object->getAdapter()->saveFormFields($form_fields); $this->object->saveCertificate($xslfo); $this->object->writeActive($form_fields["active"]); ilUtil::sendSuccess($this->lng->txt("saved_successfully"), TRUE); $this->ctrl->redirect($this, "certificateEditor"); } catch (Exception $e) { ilUtil::sendFailure($e->getMessage()); } } } }
public function updateDetails() { if (!$_GET['pobject_id']) { ilUtil::sendInfo($this->lng->txt('paya_no_object_selected')); $this->showObjects(); return true; } $this->__initPaymentObject((int) $_GET['pobject_id']); $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']); // read old settings $old_status = $this->pobject->getStatus(); // check status changed from not_buyable if ($old_status == $this->pobject->STATUS_NOT_BUYABLE and (int) $_POST['status'] != $old_status) { // check pay_method edited switch ((int) $_POST['pay_method']) { case $this->pobject->PAY_METHOD_NOT_SPECIFIED: ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first')); $this->editDetails(); return false; default: } // check minimum one price include_once './Services/Payment/classes/class.ilPaymentPrices.php'; $prices_obj = new ilPaymentPrices((int) $_GET['pobject_id']); if (!count($prices_obj->getPrices())) { ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first')); $this->editDetails(); return false; } } if ((int) $_POST['status'] == 0) { // Status: not buyable -> delete depending shoppingcart entries include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php'; ilPaymentShoppingCart::_deleteShoppingCartEntries($this->pobject->getPobjectId()); } $this->pobject->setStatus((int) $_POST['status']); $this->pobject->setVendorId((int) $_POST['vendor']); $this->pobject->setPayMethod((int) $_POST['pay_method']); $this->pobject->setTopicId((int) $_POST['topic_id']); $this->pobject->setVatId((int) $_POST['vat_id']); $this->pobject->setSubtype((string) $_POST['exc_subtype']); $this->pobject->setSpecial((int) $_POST['is_special']); if ((int) $_POST['thumbnail_delete']) { $oFile = new ilFileDataShop($this->pobject->getPobjectId()); $oFile->deassignFileFromPaymentObject(); } else { if ($_FILES['thumbnail']['tmp_name'] != '') { $this->lng->loadLanguageModule('form'); include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail'); if ($oThumbnail->checkInput()) { $oFile = new ilFileDataShop($this->pobject->getPobjectId()); if ($oFile->storeUploadedFile($_FILES['thumbnail']) !== false) { $oFile->assignFileToPaymentObject(); } } else { ilUtil::sendInfo($oThumbnail->getAlert()); return $this->editDetails(); } } } $this->pobject->update(); ilUtil::sendInfo($this->lng->txt('paya_details_updated')); $this->showObjects(); return true; }