public function setFormValues(ilPropertyFormGUI $form) { $form->getItemByPostVar('registration_type')->setValue($this->getCurrentObject()->getRegistrationType()); $form->getItemByPostVar('registration_membership_limited')->setChecked($this->getCurrentObject()->isRegistrationUserLimitEnabled()); $form->getItemByPostVar('registration_max_members')->setValue($this->getCurrentObject()->getRegistrationMaxUsers()); $form->getItemByPostVar('waiting_list')->setChecked($this->getCurrentObject()->isRegistrationWaitingListEnabled()); }
protected function initPluginSettings() { $n = new ilNonEditableValueGUI($this->getPluginHookObject()->txt('info_token_expires')); $n->setValue(date(DATE_ISO8601, $this->getPluginObject()->getValidThrough())); $this->form->addItem($n); $this->form->getItemByPostVar('root_folder')->setDisabled(true); }
/** * initialises a given form object's specific form properties * relating to this question type * * (overwrites the method from ilAssMultiOptionQuestionFeedback, because of individual setting) * * @access public * @param ilPropertyFormGUI $form */ public function initSpecificFormProperties(ilPropertyFormGUI $form) { if (!$this->questionOBJ->getSelfAssessmentEditingMode()) { $form->getItemByPostVar('feedback_setting')->setValue($this->questionOBJ->getSpecificFeedbackSetting()); foreach ($this->getAnswerOptionsByAnswerIndex() as $index => $answer) { if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) { $value = $this->getPageObjectNonEditableValueHTML($this->getSpecificAnswerFeedbackPageObjectType(), $this->getSpecificAnswerFeedbackPageObjectId($this->questionOBJ->getId(), $index)); } else { $value = $this->questionOBJ->prepareTextareaOutput($this->getSpecificAnswerFeedbackContent($this->questionOBJ->getId(), $index)); } $form->getItemByPostVar("feedback_answer_{$index}")->setValue($value); } } }
/** * Check input of form * * @param $a_mode 'create' | 'update' * * @return bool */ protected function checkInput($a_mode) { global $lng; $return = $this->form->checkInput(); // Additional check for text fields: The length property should be max 200 if the textarea option is not set if ($this->form->getInput('datatype') == ilDataCollectionDatatype::INPUTFORMAT_TEXT && (int) $this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_LENGTH) > 200 && !$this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_TEXTAREA)) { $inputObj = $this->form->getItemByPostVar('prop_' . ilDataCollectionField::PROPERTYID_LENGTH); $inputObj->setAlert($lng->txt("form_msg_value_too_high")); $return = false; } // Don't allow multiple fields with the same title in this table if ($a_mode == 'create') { if ($title = $this->form->getInput('title')) { if (ilDataCollectionTable::_hasFieldByTitle($title, $this->table_id)) { $inputObj = $this->form->getItemByPostVar('title'); $inputObj->setAlert($lng->txt("dcl_field_title_unique")); $return = false; } } } if (!$return) { ilUtil::sendFailure($lng->txt("form_input_not_valid")); } return $return; }
/** * Applies given values to field in given form. * @param ilPropertyFormGUI $form * @param array $values */ public static function applyValues(ilPropertyFormGUI $form, array $values) { foreach ($values as $key => $value) { $field = $form->getItemByPostVar($key); if (!$field) { continue; } switch (strtolower(get_class($field))) { case 'ilcheckboxinputgui': if ($value) { $field->setChecked(true); } break; default: $field->setValue($value); } } }
/** * */ protected function saveCategory() { if (!$this->isCRUDContext()) { $this->{$this->getDefaultCommand()}(); return; } $category = $this->getCategoryById((int) $_GET['category_id']); $this->initUnitCategoryForm($category); if ($this->unit_cat_form->checkInput()) { try { $category->setCategory($this->unit_cat_form->getInput('category_name')); $this->repository->saveCategory($category); ilUtil::sendSuccess($this->lng->txt('saved_successfully')); $this->{$this->getUnitCategoryOverviewCommand()}(); return; } catch (ilException $e) { $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage())); ilUtil::sendFailure($this->lng->txt('form_input_not_valid')); } } $this->unit_cat_form->setValuesByPost(); $this->tpl->setContent($this->unit_cat_form->getHtml()); }
/** * Save record */ public function save() { $this->initForm(); if ($this->form->checkInput()) { $record_obj = ilDataCollectionCache::getRecordCache($this->record_id); $date_obj = new ilDateTime(time(), IL_CAL_UNIX); $record_obj->setTableId($this->table_id); $record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME)); $record_obj->setLastEditBy($this->user->getId()); $create_mode = false; if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) { $all_fields = $this->table->getRecordFields(); } else { $all_fields = $this->table->getEditableFields(); } $fail = ""; //Check if we can create this record. foreach ($all_fields as $field) { try { $value = $this->form->getInput("field_" . $field->getId()); $field->checkValidity($value, $this->record_id); } catch (ilDataCollectionInputException $e) { $fail .= $field->getTitle() . ": " . $e . "<br>"; } } if ($fail) { $this->sendFailure($fail); return; } if (!isset($this->record_id)) { if (!$this->table->hasPermissionToAddRecord($this->parent_obj->ref_id)) { $this->accessDenied(); return; } $record_obj->setOwner($this->user->getId()); $record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME)); $record_obj->setTableId($this->table_id); $record_obj->doCreate(); $this->record_id = $record_obj->getId(); $create_mode = true; } else { if (!$record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) { $this->accessDenied(); return; } } //edit values, they are valid we already checked them above foreach ($all_fields as $field) { $value = $this->form->getInput("field_" . $field->getId()); //deletion flag on MOB inputs. if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB && $this->form->getItemByPostVar("field_" . $field->getId())->getDeletionFlag()) { $value = -1; } $record_obj->setRecordFieldValue($field->getId(), $value); } // Do we need to set a new owner for this record? if (!$create_mode) { $owner_id = ilObjUser::_lookupId($_POST['field_owner']); if (!$owner_id) { $this->sendFailure($this->lng->txt('user_not_known')); return; } $record_obj->setOwner($owner_id); } if ($create_mode) { ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId()); } $record_obj->doUpdate(); $this->ctrl->setParameter($this, "table_id", $this->table_id); $this->ctrl->setParameter($this, "record_id", $this->record_id); if (!$this->ctrl->isAsynch()) { ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); } $this->checkAndPerformRedirect(); if ($this->ctrl->isAsynch()) { // If ajax request, return the form in edit mode again $this->record_id = $record_obj->getId(); $this->initForm(); $this->setFormValues(); echo $this->tpl->getMessageHTML($this->lng->txt('msg_obj_modified'), 'success') . $this->form->getHTML(); exit; } else { $this->ctrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords"); } } else { // Form not valid... $this->form->setValuesByPost(); if ($this->ctrl->isAsynch()) { echo $this->form->getHTML(); exit; } else { $this->tpl->setContent($this->form->getHTML()); } } }
protected function formPropertyExists(ilPropertyFormGUI $form, $propertyId) { return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI; }
public function updateCustom(ilPropertyFormGUI $a_form) { $this->object->setOnline($a_form->getInput("online")); // activation if ($a_form->getInput("access_type") == ilObjectActivation::TIMINGS_ACTIVATION) { $this->object->setActivationLimited(true); $this->object->setActivationVisibility($a_form->getInput("access_visiblity")); $period = $a_form->getItemByPostVar("access_period"); $this->object->setActivationStartDate($period->getStart()->get(IL_CAL_UNIX)); $this->object->setActivationEndDate($period->getEnd()->get(IL_CAL_UNIX)); } else { $this->object->setActivationLimited(false); } parent::updateCustom($a_form); }
/** * Validate field form * * @param ilPropertyFormGUI $form * @param ilUserDefinedFields $user_field_definitions * @param array $access * @param array $a_field_permissions * @return bool */ protected function validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions = null) { global $lng; if ($form->checkInput()) { $valid = true; $incoming = (array) $form->getInput("access"); if ($a_field_permissions) { $perm_map = self::getAccessPermissions(); } $access = array(); foreach (array_keys($this->getAccessOptions()) as $id) { $access[$id] = in_array($id, $incoming); // disabled fields if ($a_field_permissions && !$a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) { $access[$id] = $this->field_definition[$id]; } } if ($access['required'] && !$access['visib_reg']) { $this->confirm_change = true; $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg')); $valid = false; } if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) { $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists')); $valid = false; } if ($form->getInput("field_type") == UDF_TYPE_SELECT && (!$a_field_permissions || $a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY][ilUDFPermissionHelper::SUBACTION_FIELD_PROPERTIES])) { $user_field_definitions->setFieldValues($form->getInput("selvalue")); if ($error = $user_field_definitions->validateValues()) { switch ($error) { case UDF_DUPLICATE_VALUES: $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries')); $valid = false; break; } } } if (!$valid) { ilUtil::sendFailure($lng->txt("form_input_not_valid")); } return $valid; } return false; }
/** * @param ilPropertyFormGUI $form */ public function writeAnswerSpecificPostData(ilPropertyFormGUI $form) { $answers = $form->getItemByPostVar('kprim_answers')->getValues(); $files = $form->getItemByPostVar('kprim_answers')->getFiles(); $this->object->handleFileUploads($answers, $files); $this->object->setAnswers($answers); }
protected function updateCustom(ilPropertyFormGUI $a_form) { $this->object->setViewResults($a_form->getInput("results")); $this->object->setOnline($a_form->getInput("online")); $this->object->setSortResultByVotes($a_form->getInput("sort")); $this->object->setShowComments($a_form->getInput("comment")); $this->object->setShowResultsAs($a_form->getInput("show_results_as")); include_once "Services/Object/classes/class.ilObjectActivation.php"; if ($a_form->getInput("access_type")) { $this->object->setAccessType(ilObjectActivation::TIMINGS_ACTIVATION); $period = $a_form->getItemByPostVar("access_period"); $this->object->setAccessBegin($period->getStart()->get(IL_CAL_UNIX)); $this->object->setAccessEnd($period->getEnd()->get(IL_CAL_UNIX)); } else { $this->object->setAccessType(ilObjectActivation::TIMINGS_DEACTIVATED); } if ($a_form->getInput("period")) { $this->object->setVotingPeriod(1); $period = $a_form->getItemByPostVar("voting_period"); $this->object->setVotingPeriodBegin($period->getStart()->get(IL_CAL_UNIX)); $this->object->setVotingPeriodEnd($period->getEnd()->get(IL_CAL_UNIX)); } else { $this->object->setVotingPeriod(0); } }
/** * Validate field form * * @param ilPropertyFormGUI $form * @param ilUserDefinedFields $user_field_definitions * @param array $access * @return bool */ protected function validateForm($form, $user_field_definitions, array &$access) { global $lng; if ($form->checkInput()) { $valid = true; $incoming = (array) $form->getInput("access"); $access = array(); foreach (array_keys($this->getAccessOptions()) as $id) { $access[$id] = in_array($id, $incoming); } if ($access['required'] && !$access['visib_reg']) { $this->confirm_change = true; $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg')); $valid = false; } if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) { $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists')); $valid = false; } if ($form->getInput("field_type") == UDF_TYPE_SELECT) { $user_field_definitions->setFieldValues($form->getInput("selvalue")); if ($error = $user_field_definitions->validateValues()) { switch ($error) { case UDF_DUPLICATE_VALUES: $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries')); $valid = false; break; } } } if (!$valid) { ilUtil::sendFailure($lng->txt("form_input_not_valid")); } return $valid; } return false; }
/** * for mode 1:1 terms count must not be less than definitions count * for mode n:n this limitation is cancelled * * @param ilPropertyFormGUI $form * @return bool */ private function isValidTermAndDefinitionAmount(ilPropertyFormGUI $form) { $matchingMode = $form->getItemByPostVar('matching_mode')->getValue(); if ($matchingMode == assMatchingQuestion::MATCHING_MODE_N_ON_N) { return true; } $numTerms = count($form->getItemByPostVar('terms')->getValues()); $numDefinitions = count($form->getItemByPostVar('definitions')->getValues()); if ($numTerms >= $numDefinitions) { return true; } return false; }
/** * {@inheritdoc} */ public function validateForm(ilPropertyFormGUI $form) { /** * @var $lng ilLanguage */ global $lng; if (!strlen(trim($this->getClientSalt())) || !preg_match('/^.{' . self::MIN_SALT_SIZE . ',}$/', $this->getClientSalt())) { $form->getItemByPostVar('bcrypt_salt')->setAlert($lng->txt('passwd_encoder_bcrypt_client_salt_invalid')); return false; } return true; }
private function hasScoringSettingsChanged(ilPropertyFormGUI $form) { $countSystem = $form->getItemByPostVar('count_system'); if (is_object($countSystem) && $countSystem->getValue() != $this->testOBJ->getCountSystem()) { return true; } $mcScoring = $form->getItemByPostVar('mc_scoring'); if (is_object($mcScoring) && $mcScoring != $this->testOBJ->getMCScoring()) { return true; } $scoreCutting = $form->getItemByPostVar('score_cutting'); if (is_object($scoreCutting) && $scoreCutting->getValue() != $this->testOBJ->getScoreCutting()) { return true; } $passScoring = $form->getItemByPostVar('pass_scoring'); if (is_object($passScoring) && $passScoring->getValue() != $this->testOBJ->getPassScoring()) { return true; } return false; }
public function prepareCustomDefinitionFormConfirmation(ilPropertyFormGUI $a_form) { global $lng, $objDefinition; $a_form->getItemByPostVar("opts")->setDisabled(true); if (sizeof($this->confirm_objects)) { $new_options = $a_form->getInput("opts"); $sec = new ilFormSectionHeaderGUI(); $sec->setTitle($lng->txt("md_adv_confirm_definition_select_section")); $a_form->addItem($sec); foreach ($this->confirm_objects as $old_option => $items) { $details = new ilRadioGroupInputGUI($lng->txt("md_adv_confirm_definition_select_option") . ': "' . $old_option . '"', "conf_det[" . $this->getFieldId() . "][" . $old_option . "]"); $details->setRequired(true); $details->setValue("sum"); $a_form->addItem($details); $sum = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_all"), "sum"); $details->addOption($sum); $sel = new ilSelectInputGUI($lng->txt("md_adv_confirm_definition_select_option_all_action"), "conf_det_act[" . $this->getFieldId() . "][" . $old_option . "]"); $options = array("" => $lng->txt("md_adv_confirm_definition_select_option_remove")); foreach ($new_options as $new_option) { $options[$new_option] = $lng->txt("md_adv_confirm_definition_select_option_overwrite") . ': "' . $new_option . '"'; } $sel->setOptions($options); $sum->addSubItem($sel); $single = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_single"), "sgl"); $details->addOption($single); foreach ($items as $item) { $obj_id = $item[0]; $sub_type = $item[1]; $sub_id = $item[2]; $item_id = $obj_id . "_" . $sub_type . "_" . $sub_id; $type = ilObject::_lookupType($obj_id); $type_title = $lng->txt("obj_" . $type); $title = ' "' . ilObject::_lookupTitle($obj_id) . '"'; if ($sub_id) { $class = "ilObj" . $objDefinition->getClassName($type); $class_path = $objDefinition->getLocation($type); include_once $class_path . "/class." . $class . ".php"; if (class_implements($class, ilAdvancedMetaDataSubItem)) { $sub_title = $class::getAdvMDSubItemTitle($obj_id, $sub_type, $sub_id); if ($sub_title) { $title .= ' (' . $sub_title . ')'; } } } $sel = new ilSelectInputGUI($type_title . ' ' . $title, "conf[" . $this->getFieldId() . "][" . $old_option . "][" . $item_id . "]"); $options = array("" => $lng->txt("md_adv_confirm_definition_select_option_remove")); foreach ($new_options as $new_option) { $options[$new_option] = $lng->txt("md_adv_confirm_definition_select_option_overwrite") . ': "' . $new_option . '"'; } $sel->setOptions($options); $single->addSubItem($sel); } } } }
public function addThreadObject($a_prevent_redirect = false) { /** * @var $ilUser ilObjUser * @var $ilAccess ilAccessHandler * @var $lng ilLanguage */ global $ilUser, $ilAccess, $lng; $frm = $this->object->Forum; $frm->setForumId($this->object->getId()); $frm->setForumRefId($this->object->getRefId()); if (!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId())) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId())); $topicData = $frm->getOneTopic(); $this->initTopicCreateForm(); if ($this->create_topic_form_gui->checkInput()) { require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php'; if ($ilUser->isAnonymous() && !$ilUser->isCaptchaVerified() && ilCaptchaUtil::isActiveForForum()) { $ilUser->setCaptchaVerified(true); } if ($this->objProperties->isAnonymized()) { if (!strlen($this->create_topic_form_gui->getInput('alias'))) { $user_alias = $this->lng->txt('forums_anonymous'); } else { $user_alias = $this->create_topic_form_gui->getInput('alias'); } } else { $user_alias = $ilUser->getLogin(); } $status = 1; if ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()) { $status = 0; } // build new thread $newPost = $frm->generateThread($topicData['top_pk'], $ilUser->getId(), $this->objProperties->isAnonymized() ? 0 : $ilUser->getId(), $this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false), ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0), $this->create_topic_form_gui->getItemByPostVar('notify') ? (int) $this->create_topic_form_gui->getInput('notify') : 0, $this->create_topic_form_gui->getItemByPostVar('notify_posts') ? (int) $this->create_topic_form_gui->getInput('notify_posts') : 0, $user_alias, '', $status); $file = $_FILES['userfile']; // file upload if (is_array($file) && !empty($file)) { $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost); $tmp_file_obj->storeUploadedFile($file); } // Visit-Counter $frm->setDbTable('frm_data'); $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk'])); $frm->updateVisits($topicData['top_pk']); $frm->setMDB2WhereCondition('thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ', array('integer', 'text'), array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject'))); // copy temporary media objects (frm~) include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; $mediaObjects = ilRTE::_getMediaObjects($this->create_topic_form_gui->getInput('message'), 0); foreach ($mediaObjects as $mob) { if (ilObjMediaObject::_exists($mob)) { ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId()); ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost); } } if ($this->ilias->getSetting('forum_notification') == 1) { // send notification about new topic $objPost = new ilForumPost((int) $newPost, $this->is_moderator); $post_data = array(); $post_data = $objPost->getDataAsArray(); $titles = $this->getTitlesByRefId(array($this->object->getRefId())); $post_data["top_name"] = $titles[0]; $post_data["ref_id"] = $this->object->getRefId(); $frm->sendForumNotifications($post_data); } if (!$a_prevent_redirect) { ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true); $this->ctrl->redirect($this); } else { return $newPost; } } else { $this->create_topic_form_gui->setValuesByPost(); if (!$this->objProperties->isAnonymized()) { $this->create_topic_form_gui->getItemByPostVar('alias')->setValue($ilUser->getLogin()); } return $this->tpl->setContent($this->create_topic_form_gui->getHTML()); } }
public static function setCourseDefinedFieldValues(ilPropertyFormGUI $form, $a_obj_id, $a_usr_id = 0) { global $ilUser; if (!$a_usr_id) { $a_usr_id = $ilUser->getId(); } $ud = ilCourseUserData::_getValuesByObjId($a_obj_id); foreach (ilCourseDefinedFieldDefinition::_getFields($a_obj_id) as $field_obj) { $current_value = $ud[$a_usr_id][$field_obj->getId()]; if (!$current_value) { continue; } switch ($field_obj->getType()) { case IL_CDF_TYPE_SELECT: $id = $field_obj->getIdByValue($current_value); if ($id >= 0) { $item = $form->getItemByPostVar('cdf_' . $field_obj->getId()); $item->setValue($field_obj->getId() . '_' . $id); } else { // open answer $open_answer_indexes = $field_obj->getValueOptions(); $open_answer_index = end($open_answer_indexes); $item = $form->getItemByPostVar('cdf_' . $field_obj->getId()); $item->setValue($field_obj->getId() . '_' . $open_answer_index); $item_txt = $form->getItemByPostVar('cdf_oa_' . $field_obj->getId() . '_' . $open_answer_index); if ($item_txt) { $item_txt->setValue($current_value); } } break; case IL_CDF_TYPE_TEXT: $item = $form->getItemByPostVar('cdf_' . $field_obj->getId()); $item->setValue($current_value); break; } } }
public function updateCustom(ilPropertyFormGUI $a_form) { $this->object->setPublicComments($a_form->getInput("comments")); $this->object->setProfilePicture($a_form->getInput("ppic")); /* $this->object->setBackgroundColor($a_form->getInput("bg_color")); $this->object->setFontcolor($a_form->getInput("font_color")); */ $prfa_set = new ilSetting("prfa"); if ($_FILES["banner"]["tmp_name"]) { $this->object->uploadImage($_FILES["banner"]); } else { if ($prfa_set->get('banner') and $a_form->getItemByPostVar("banner")->getDeletionFlag()) { $this->object->deleteImage(); } } }
protected function handleDisabledAssignmentFields(ilExAssignment $a_ass, ilPropertyFormGUI $a_form) { // potentially disabled elements are initialized here to re-use this // method after setValuesByPost() - see updateAssignmentObject() // if there are any submissions we cannot change type anymore if (sizeof(ilExAssignment::getAllDeliveredFiles($this->object->getId(), $a_ass->getId())) || $a_ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) { $a_form->getItemByPostVar("type")->setDisabled(true); } if ($a_ass->getDeadline() > 0) { $a_form->getItemByPostVar("deadline_cb")->setChecked(true); $edit_date = new ilDateTime($a_ass->getDeadline(), IL_CAL_UNIX); $ed_item = $a_form->getItemByPostVar("deadline"); $ed_item->setDate($edit_date); } // team assignments do not support peer review if ($a_ass->getType() == ilExAssignment::TYPE_UPLOAD_TEAM) { return; } $a_form->getItemByPostVar("peer")->setChecked($a_ass->getPeerReview()); $a_form->getItemByPostVar("peer_min")->setValue($a_ass->getPeerReviewMin()); $a_form->getItemByPostVar("peer_file")->setChecked($a_ass->hasPeerReviewFileUpload()); $a_form->getItemByPostVar("peer_prsl")->setChecked($a_ass->hasPeerReviewPersonalized()); // with no active peer review there is nothing to protect if (!$a_ass->getPeerReview()) { return; } // #14450 if ($a_ass->hasPeerReviewGroups()) { // deadline(s) are past and must not change $a_form->getItemByPostVar("deadline_cb")->setDisabled(true); $a_form->getItemByPostVar("deadline")->setDisabled(true); // JourFixe, 2015-05-11 - editable again // $a_form->getItemByPostVar("peer_dl")->setDisabled(true); $a_form->getItemByPostVar("peer")->setDisabled(true); $a_form->getItemByPostVar("peer_min")->setDisabled(true); $a_form->getItemByPostVar("peer_file")->setDisabled(true); $a_form->getItemByPostVar("peer_prsl")->setDisabled(true); } }
protected function suppressPostParticipationFormElements(\ilPropertyFormGUI $form, $postvars_to_suppress) { foreach ($postvars_to_suppress as $postvar) { /** @var $item ilFormPropertyGUI */ $item = $form->getItemByPostVar($postvar); $item->setDisabled(true); } return $form; }
/** * initialises a given form object's GENERIC form properties * relating to all question types * * @final * @access public * @param ilPropertyFormGUI $form */ public final function initGenericFormProperties(ilPropertyFormGUI $form) { if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) { $pageObjectType = $this->getGenericFeedbackPageObjectType(); $valueFeedbackSolutionComplete = $this->getPageObjectNonEditableValueHTML($pageObjectType, $this->getGenericFeedbackPageObjectId($this->questionOBJ->getId(), true)); $valueFeedbackSolutionIncomplete = $this->getPageObjectNonEditableValueHTML($pageObjectType, $this->getGenericFeedbackPageObjectId($this->questionOBJ->getId(), false)); } else { $valueFeedbackSolutionComplete = $this->questionOBJ->prepareTextareaOutput($this->getGenericFeedbackContent($this->questionOBJ->getId(), true)); $valueFeedbackSolutionIncomplete = $this->questionOBJ->prepareTextareaOutput($this->getGenericFeedbackContent($this->questionOBJ->getId(), false)); } $form->getItemByPostVar('feedback_complete')->setValue($valueFeedbackSolutionComplete); $form->getItemByPostVar('feedback_incomplete')->setValue($valueFeedbackSolutionIncomplete); }
protected function updateCustom(ilPropertyFormGUI $a_form) { if ($this->id_type == self::REPOSITORY_NODE_ID) { $this->object->setApproval($a_form->getInput("approval")); } $this->object->setNotesStatus($a_form->getInput("notes")); $this->object->setProfilePicture($a_form->getInput("ppic")); $this->object->setBackgroundColor($a_form->getInput("bg_color")); $this->object->setFontColor($a_form->getInput("font_color")); $this->object->setRSS($a_form->getInput("rss")); // banner field is optional $banner = $a_form->getItemByPostVar("banner"); if ($banner) { if ($_FILES["banner"]["tmp_name"]) { $this->object->uploadImage($_FILES["banner"]); } else { if ($banner->getDeletionFlag()) { $this->object->deleteImage(); } } } }
private function performSaveForm(ilPropertyFormGUI $form) { include_once 'Services/MetaData/classes/class.ilMD.php'; $md_obj =& new ilMD($this->testOBJ->getId(), 0, "tst"); $md_section = $md_obj->getGeneral(); // title $md_section->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue())); $md_section->update(); // Description $md_desc_ids = $md_section->getDescriptionIds(); if ($md_desc_ids) { $md_desc = $md_section->getDescription(array_pop($md_desc_ids)); $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue())); $md_desc->update(); } else { $md_desc = $md_section->addDescription(); $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue())); $md_desc->save(); } $this->testOBJ->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue())); $this->testOBJ->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue())); $this->testOBJ->update(); // pool usage setting if ($form->getItemByPostVar('use_pool') instanceof ilFormPropertyGUI) { $this->testOBJ->setPoolUsage($form->getItemByPostVar('use_pool')->getChecked()); } // Archiving $this->testOBJ->setEnableArchiving($form->getItemByPostVar('enable_archiving')->getChecked()); // Examview $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked()); $this->testOBJ->setShowExamviewHtml($form->getItemByPostVar('show_examview_html')->getChecked()); $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked()); // online status $this->testOBJ->setOnline($form->getItemByPostVar('online')->getChecked()); // activation if ($form->getItemByPostVar('activation_type')->getValue() == ilObjectActivation::TIMINGS_ACTIVATION) { $this->testOBJ->setActivationLimited(true); $this->testOBJ->setActivationVisibility($form->getItemByPostVar('activation_visibility')->getChecked()); $period = $form->getItemByPostVar("access_period"); $this->testOBJ->setActivationStartingTime($period->getStart()->get(IL_CAL_UNIX)); $this->testOBJ->setActivationEndingTime($period->getEnd()->get(IL_CAL_UNIX)); } else { $this->testOBJ->setActivationLimited(false); } include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $this->testOBJ->setIntroduction($form->getItemByPostVar('introduction')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->testOBJ->setShowInfo($form->getItemByPostVar('showinfo')->getChecked()); $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked()); if ($form->getItemByPostVar('chb_postpone') instanceof ilFormPropertyGUI) { $this->testOBJ->setSequenceSettings($form->getItemByPostVar('chb_postpone')->getChecked()); } $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked()); $this->testOBJ->setListOfQuestions($form->getItemByPostVar('list_of_questions')->getChecked()); $listOfQuestionsOptions = $form->getItemByPostVar('list_of_questions_options')->getValue(); if (is_array($listOfQuestionsOptions)) { $this->testOBJ->setListOfQuestionsStart(in_array('chb_list_of_questions_start', $listOfQuestionsOptions)); $this->testOBJ->setListOfQuestionsEnd(in_array('chb_list_of_questions_end', $listOfQuestionsOptions)); $this->testOBJ->setListOfQuestionsDescription(in_array('chb_list_of_questions_with_description', $listOfQuestionsOptions)); } else { $this->testOBJ->setListOfQuestionsStart(0); $this->testOBJ->setListOfQuestionsEnd(0); $this->testOBJ->setListOfQuestionsDescription(0); } if ($form->getItemByPostVar('mailnotification') instanceof ilFormPropertyGUI) { $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification')->getValue()); } if ($form->getItemByPostVar('mailnottype') instanceof ilFormPropertyGUI) { $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked()); } if ($form->getItemByPostVar('chb_show_marker') instanceof ilFormPropertyGUI) { $this->testOBJ->setShowMarker($form->getItemByPostVar('chb_show_marker')->getChecked()); } if ($form->getItemByPostVar('chb_show_cancel') instanceof ilFormPropertyGUI) { $this->testOBJ->setShowCancel($form->getItemByPostVar('chb_show_cancel')->getChecked()); } if ($form->getItemByPostVar('kiosk') instanceof ilFormPropertyGUI) { $this->testOBJ->setKioskMode($form->getItemByPostVar('kiosk')->getChecked()); $kioskOptions = $form->getItemByPostVar('kiosk_options')->getValue(); if (is_array($kioskOptions)) { $this->testOBJ->setShowKioskModeTitle(in_array('kiosk_title', $kioskOptions)); $this->testOBJ->setShowKioskModeParticipant(in_array('kiosk_participant', $kioskOptions)); $this->testOBJ->setExamidInKiosk(in_array('examid_in_kiosk', $_POST["kiosk_options"])); } } // redirect after test if ($form->getItemByPostVar('redirection_enabled')->getChecked()) { $this->testOBJ->setRedirectionMode($form->getItemByPostVar('redirection_mode')->getValue()); } else { $this->testOBJ->setRedirectionMode(REDIRECT_NONE); } if (strlen($form->getItemByPostVar('redirection_url')->getValue())) { $this->testOBJ->setRedirectionUrl($form->getItemByPostVar('redirection_url')->getValue()); } else { $this->testOBJ->setRedirectionUrl(null); } if ($form->getItemByPostVar('sign_submission')->getChecked()) { $this->testOBJ->setSignSubmission(true); } else { $this->testOBJ->setSignSubmission(false); } $this->testOBJ->setEnableProcessingTime($form->getItemByPostVar('chb_processing_time')->getChecked()); if ($this->testOBJ->getEnableProcessingTime()) { $processingTime = $form->getItemByPostVar('processing_time'); $this->testOBJ->setProcessingTime(sprintf("%02d:%02d:%02d", $processingTime->getHours(), $processingTime->getMinutes(), $processingTime->getSeconds())); } else { $this->testOBJ->setProcessingTime(''); } $this->testOBJ->setResetProcessingTime($form->getItemByPostVar('chb_reset_processing_time')->getChecked()); if ($form->getItemByPostVar('chb_starting_time')->getChecked()) { $startingTimeSetting = $form->getItemByPostVar('starting_time'); $this->testOBJ->setStartingTime(ilFormat::dateDB2timestamp($startingTimeSetting->getDate()->get(IL_CAL_DATETIME))); } else { $this->testOBJ->setStartingTime(''); } if ($form->getItemByPostVar('chb_ending_time')->getChecked()) { $endingTimeSetting = $form->getItemByPostVar('ending_time'); $this->testOBJ->setEndingTime(ilFormat::dateDB2timestamp($endingTimeSetting->getDate()->get(IL_CAL_DATETIME))); } else { $this->testOBJ->setEndingTime(''); } if ($form->getItemByPostVar('forcejs') instanceof ilFormPropertyGUI) { $this->testOBJ->setForceJS($form->getItemByPostVar('forcejs')->getChecked()); } if ($form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI) { $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue()); } if ($form->getItemByPostVar('password') instanceof ilFormPropertyGUI) { $this->testOBJ->setPassword($form->getItemByPostVar('password')->getValue()); } if ($form->getItemByPostVar('allowedUsers') instanceof ilFormPropertyGUI) { $this->testOBJ->setAllowedUsers($form->getItemByPostVar('allowedUsers')->getValue()); } if ($form->getItemByPostVar('allowedUsersTimeGap') instanceof ilFormPropertyGUI) { $this->testOBJ->setAllowedUsersTimeGap($form->getItemByPostVar('allowedUsersTimeGap')->getValue()); } // Selector for uicode characters global $ilSetting; if ($ilSetting->get('char_selector_availability') > 0) { require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); $char_selector->addFormProperties($form); $char_selector->getFormValues($form); $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability()); $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition()); } $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked()); $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000); $this->testOBJ->setUsePreviousAnswers($form->getItemByPostVar('chb_use_previous_answers')->getChecked()); // highscore settings $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked()); $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked()); $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked()); $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked()); $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked()); $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked()); $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked()); $this->testOBJ->setHighscoreOwnTable((bool) $form->getItemByPostVar('highscore_own_table')->getChecked()); $this->testOBJ->setHighscoreTopTable((bool) $form->getItemByPostVar('highscore_top_table')->getChecked()); $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue()); if (!$this->testOBJ->participantDataExist()) { // question set type if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI) { $this->testOBJ->setQuestionSetType($form->getItemByPostVar('question_set_type')->getValue()); } // anonymity setting $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue()); // nr of tries (max passes) $this->testOBJ->setNrOfTries($form->getItemByPostVar('nr_of_tries')->getValue()); // fixed participants setting if ($form->getItemByPostVar('fixedparticipants') instanceof ilFormPropertyGUI) { $this->testOBJ->setFixedParticipants($form->getItemByPostVar('fixedparticipants')->getChecked()); } } // store settings to db $this->testOBJ->saveToDb(true); // Update ecs export settings include_once 'Modules/Test/classes/class.ilECSTestSettings.php'; $ecs = new ilECSTestSettings($this->testOBJ); $ecs->handleSettingsUpdate(); }
public function saveCustomSettings(ilPropertyFormGUI $a_form) { global $ilSetting, $lng; $lng->loadLanguageModule("user"); $setting = implode(',', $_POST['cron_inactive_user_delete_include_roles']); if (!strlen($setting)) { $setting = null; } $valid = true; $delete_period = ilUtil::stripSlashes($_POST['cron_inactive_user_delete_period']); $reminder_period = ilUtil::stripSlashes($_POST['cron_inactive_user_reminder_period']); $cron_period = (int) ilUtil::stripSlashes($_POST['type']); $cron_period_custom = (int) ilUtil::stripSlashes($_POST['sdyi']); if ($this->isDecimal($delete_period)) { $valid = false; $a_form->getItemByPostVar('cron_inactive_user_delete_period')->setAlert($lng->txt('send_mail_to_inactive_users_numbers_only'), 'send_mail_to_inactive_users_numbers_only'); } if ($this->isDecimal($reminder_period)) { $valid = false; $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_to_inactive_users_numbers_only'), 'send_mail_to_inactive_users_numbers_only'); } if ($reminder_period >= $delete_period) { $valid = false; $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_to_inactive_users_must_be_smaller_than'), 'send_mail_to_inactive_users_must_be_smaller_than'); } if ($cron_period >= ilCronJob::SCHEDULE_TYPE_IN_DAYS && $cron_period <= ilCronJob::SCHEDULE_TYPE_YEARLY && $reminder_period > 0) { $logic = true; $check_window_logic = $delete_period - $reminder_period; if ($cron_period == ilCronJob::SCHEDULE_TYPE_IN_DAYS) { if ($check_window_logic < $cron_period_custom) { $logic = false; } } else { if ($cron_period == ilCronJob::SCHEDULE_TYPE_WEEKLY) { if ($check_window_logic <= 7) { $logic = false; } } else { if ($cron_period == ilCronJob::SCHEDULE_TYPE_MONTHLY) { if ($check_window_logic <= 31) { $logic = false; } } else { if ($cron_period == ilCronJob::SCHEDULE_TYPE_QUARTERLY) { if ($check_window_logic <= 92) { $logic = false; } } else { if ($cron_period == ilCronJob::SCHEDULE_TYPE_YEARLY) { if ($check_window_logic <= 366) { $logic = false; } } } } } } if (!$logic) { $valid = false; $a_form->getItemByPostVar('cron_inactive_user_reminder_period')->setAlert($lng->txt('send_mail_reminder_window_too_small'), 'send_mail_reminder_window_too_small'); } } if ($_POST['cron_inactive_user_delete_period']) { $ilSetting->set('cron_inactive_user_delete_include_roles', $setting); $ilSetting->set('cron_inactive_user_delete_period', $_POST['cron_inactive_user_delete_period']); } if ($this->reminderTimer > $reminder_period) { ilCronDeleteInactiveUserReminderMail::flushDataTable(); } $ilSetting->set('cron_inactive_user_reminder_period', $reminder_period); if (!$valid) { ilUtil::sendFailure($lng->txt("form_input_not_valid")); return false; } return true; }
protected function initNewItemGroupForm($a_grp_id = false) { $this->setModuleSubTabs("new_item_groups"); include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $this->lng->loadLanguageModule("meta"); $def_lng = $this->lng->getDefaultLanguage(); $title = new ilTextInputGUI($this->lng->txt("title"), "title_" . $def_lng); $title->setInfo($this->lng->txt("meta_l_" . $def_lng) . " (" . $this->lng->txt("default_language") . ")"); $title->setRequired(true); $form->addItem($title); foreach ($this->lng->getInstalledLanguages() as $lang_id) { if ($lang_id != $def_lng) { $title = new ilTextInputGUI($this->lng->txt("translation"), "title_" . $lang_id); $title->setInfo($this->lng->txt("meta_l_" . $lang_id)); $form->addItem($title); } } if (!$a_grp_id) { $form->setTitle($this->lng->txt("rep_new_item_group_add")); $form->setFormAction($this->ctrl->getFormAction($this, "saveNewItemGroup")); $form->addCommandButton("saveNewItemGroup", $this->lng->txt("save")); } else { $form->setTitle($this->lng->txt("rep_new_item_group_edit")); $form->setFormAction($this->ctrl->getFormAction($this, "updateNewItemGroup")); include_once "Services/Repository/classes/class.ilObjRepositorySettings.php"; $grp = ilObjRepositorySettings::getNewItemGroups(); $grp = $grp[$a_grp_id]; foreach ($grp["titles"] as $id => $value) { $field = $form->getItemByPostVar("title_" . $id); if ($field) { $field->setValue($value); } } $form->addCommandButton("updateNewItemGroup", $this->lng->txt("save")); } $form->addCommandButton("listNewItemGroups", $this->lng->txt("cancel")); return $form; }
protected function validateEditForm(ilPropertyFormGUI $a_form) { if ($a_form->getInput("use_min_answers")) { $cnt_answers = $a_form->getItemByPostVar("answers"); $cnt_answers = $cnt_answers->getCategoryCount(); $min_anwers = $a_form->getInput("nr_min_answers"); $max_anwers = $a_form->getInput("nr_max_answers"); if ($min_anwers && $min_anwers > $cnt_answers) { $a_form->getItemByPostVar("nr_min_answers")->setAlert($this->lng->txt('err_minvalueganswers')); $errors = true; } if ($max_anwers > 0 && ($max_anwers > $cnt_answers || $max_anwers < $min_anwers)) { $a_form->getItemByPostVar("nr_max_answers")->setAlert($this->lng->txt('err_maxvaluegeminvalue')); $errors = true; } } ilUtil::sendFailure($this->lng->txt('form_input_not_valid')); return !$errors; }
/** * Reload definition values from post data * * @param ilPropertyFormGUI $form */ protected function setDefinitionFromPost(ilPropertyFormGUI $form) { $days = $form->getInput("days"); if ($days) { $days_group = $form->getItemByPostVar("days"); foreach ($days_group->getOptions() as $option) { $days_fields[$option->getValue()] = $option; } foreach ($days as $day) { $slot = $form->getInput($day . "_slot"); $subs = $days_fields[$day]->getSubItems(); if ($slot[0]) { $subs[0]->setValue($slot[0]); } if ($slot[1]) { $subs[1]->setValue($slot[1]); } } } }
/** * @param ilPropertyFormGUI $form */ private function saveQuestionBehaviourProperties(ilPropertyFormGUI $form) { if ($form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI) { $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue()); } $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked()); $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000); $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked()); if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'offer_hints')) { $this->testOBJ->setOfferingQuestionHintsEnabled($form->getItemByPostVar('offer_hints')->getChecked()); } if ($this->formPropertyExists($form, 'instant_feedback')) { $this->testOBJ->setScoringFeedbackOptionsByArray($form->getItemByPostVar('instant_feedback')->getValue()); } if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'obligations_enabled')) { $this->testOBJ->setObligationsEnabled($form->getItemByPostVar('obligations_enabled')->getChecked()); } if ($this->isCharSelectorPropertyRequired()) { require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php'; $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST); $char_selector->addFormProperties($form); $char_selector->getFormValues($form); $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability()); $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition()); } }