Exemplo n.º 1
0
 /**
  * Test member agreement
  * @group IL_Init
  */
 public function testMemberAgreement()
 {
     include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
     global $ilDB;
     $agree = new ilMemberAgreement(9999, 8888);
     $agree->read();
     $agree->setAccepted(true);
     $agree->save();
     $agree = new ilMemberAgreement(9999, 8888);
     $agree->read();
     $sta = $agree->isAccepted();
     $this->assertEquals($sta, true);
     $agree->delete();
     $agree = new ilMemberAgreement(9999, 8888);
     $agree->read();
     $sta = $agree->isAccepted();
     $this->assertEquals($sta, false);
     $sta = ilMemberAgreement::_hasAccepted(9999, 8888);
     $this->assertEquals($sta, false);
     $agree = new ilMemberAgreement(9999, 8888);
     $agree->read();
     $agree->setAccepted(true);
     $agree->save();
     $sta = ilMemberAgreement::_hasAgreementsByObjId(8888);
     $this->assertEquals($sta, true);
     $sta = ilMemberAgreement::_hasAgreements();
     $this->assertEquals($sta, true);
     ilMemberAgreement::_deleteByUser(9999);
 }
 /**
  * Init acceptance
  * @return 
  */
 protected function initSettings()
 {
     if (self::$accepted_ids !== NULL) {
         return true;
     }
     self::$export_allowed = ilPrivacySettings::_getInstance()->checkExportAccess($this->getParentObject()->object->getRefId());
     self::$confirmation_required = ilPrivacySettings::_getInstance()->groupConfirmationRequired();
     include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
     self::$accepted_ids = ilMemberAgreement::lookupAcceptedAgreements($this->getParentObject()->object->getId());
     include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     self::$has_odf_definitions = ilCourseDefinedFieldDefinition::_hasFields($this->getParentObject()->object->getId());
 }
 /**
  * Constructor
  *
  * @access public
  * 
  */
 public function __construct($a_ref_id, $a_type = self::EXPORT_CSV)
 {
     global $ilObjDataCache, $lng;
     $this->lng = $lng;
     $this->export_type = $a_type;
     $this->ref_id = $a_ref_id;
     $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
     $this->type = ilObject::_lookupType($this->obj_id);
     $this->initMembers();
     $this->agreement = ilMemberAgreement::_readByObjId($this->obj_id);
     $this->settings = new ilUserFormSettings('memexp');
     $this->privacy = ilPrivacySettings::_getInstance();
 }
 function saveGlobalUserSettingsObject($action = "")
 {
     include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
     include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     global $ilias, $ilSetting;
     // see ilUserFieldSettingsTableGUI
     include_once "./Services/User/classes/class.ilUserProfile.php";
     $up = new ilUserProfile();
     $up->skipField("username");
     $field_properties = $up->getStandardFields();
     $profile_fields = array_keys($field_properties);
     $valid = true;
     foreach ($profile_fields as $field) {
         if ($_POST["chb"]["required_" . $field] && !(int) $_POST['chb']['visib_reg_' . $field]) {
             $valid = false;
             break;
         }
     }
     if (!$valid) {
         global $lng;
         ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
         $this->confirm_change = 1;
         $this->settingsObject();
         return;
     }
     // For the following fields, the required state can not be changed
     $fixed_required_fields = array("firstname" => 1, "lastname" => 1, "upload" => 0, "password" => 0, "language" => 0, "skin_style" => 0, "hits_per_page" => 0, "show_users_online" => 0, "hide_own_online_status" => 0);
     // check if a course export state of any field has been added
     $privacy = ilPrivacySettings::_getInstance();
     if ($privacy->enabledCourseExport() == true && $privacy->courseConfirmationRequired() == true && $action != "save") {
         foreach ($profile_fields as $field) {
             if (!$ilias->getSetting("usr_settings_course_export_" . $field) && $_POST["chb"]["course_export_" . $field] == "1") {
                 #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export'));
                 #$this->confirm_change = 1;
                 #$this->settingsObject();
                 #return;
             }
         }
     }
     // Reset user confirmation
     if ($action == 'save') {
         include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
         ilMemberAgreement::_reset();
     }
     foreach ($profile_fields as $field) {
         // Enable disable searchable
         if (ilUserSearchOptions::_isSearchable($field)) {
             ilUserSearchOptions::_saveStatus($field, (bool) $_POST['chb']['searchable_' . $field]);
         }
         if (!$_POST["chb"]["visible_" . $field] && !$field_properties[$field]["visible_hide"]) {
             $ilias->setSetting("usr_settings_hide_" . $field, "1");
         } else {
             $ilias->deleteSetting("usr_settings_hide_" . $field);
         }
         if (!$_POST["chb"]["changeable_" . $field] && !$field_properties[$field]["changeable_hide"]) {
             $ilias->setSetting("usr_settings_disable_" . $field, "1");
         } else {
             $ilias->deleteSetting("usr_settings_disable_" . $field);
         }
         // registration visible
         if ((int) $_POST['chb']['visib_reg_' . $field] && !$field_properties[$field]["visib_reg_hide"]) {
             $ilSetting->set('usr_settings_visib_reg_' . $field, '1');
         } else {
             $ilSetting->set('usr_settings_visib_reg_' . $field, '0');
         }
         if ((int) $_POST['chb']['visib_lua_' . $field]) {
             $ilSetting->set('usr_settings_visib_lua_' . $field, '1');
         } else {
             $ilSetting->set('usr_settings_visib_lua_' . $field, '0');
         }
         if ((int) $_POST['chb']['changeable_lua_' . $field]) {
             $ilSetting->set('usr_settings_changeable_lua_' . $field, '1');
         } else {
             $ilSetting->set('usr_settings_changeable_lua_' . $field, '0');
         }
         if ($_POST["chb"]["export_" . $field] && !$field_properties[$field]["export_hide"]) {
             $ilias->setSetting("usr_settings_export_" . $field, "1");
         } else {
             $ilias->deleteSetting("usr_settings_export_" . $field);
         }
         // Course export/visibility
         if ($_POST["chb"]["course_export_" . $field] && !$field_properties[$field]["course_export_hide"]) {
             $ilias->setSetting("usr_settings_course_export_" . $field, "1");
         } else {
             $ilias->deleteSetting("usr_settings_course_export_" . $field);
         }
         // Group export/visibility
         if ($_POST["chb"]["group_export_" . $field] && !$field_properties[$field]["group_export_hide"]) {
             $ilias->setSetting("usr_settings_group_export_" . $field, "1");
         } else {
             $ilias->deleteSetting("usr_settings_group_export_" . $field);
         }
         $is_fixed = array_key_exists($field, $fixed_required_fields);
         if ($is_fixed && $fixed_required_fields[$field] || !$is_fixed && $_POST["chb"]["required_" . $field]) {
             $ilias->setSetting("require_" . $field, "1");
         } else {
             $ilias->deleteSetting("require_" . $field);
         }
     }
     if ($_POST["select"]["default_hits_per_page"]) {
         $ilias->setSetting("hits_per_page", $_POST["select"]["default_hits_per_page"]);
     }
     if ($_POST["select"]["default_show_users_online"]) {
         $ilias->setSetting("show_users_online", $_POST["select"]["default_show_users_online"]);
     }
     if ($_POST["chb"]["export_preferences"]) {
         $ilias->setSetting("usr_settings_export_preferences", $_POST["chb"]["export_preferences"]);
     } else {
         $ilias->deleteSetting("usr_settings_export_preferences");
     }
     $ilias->setSetting('mail_incoming_mail', (int) $_POST['select']['default_mail_incoming_mail']);
     ilUtil::sendSuccess($this->lng->txt("usr_settings_saved"));
     $this->settingsObject();
 }
 /**
  * Update field definition
  * @return 
  */
 protected function updateField()
 {
     $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($_POST, true));
     $this->initFieldForm(self::MODE_UPDATE);
     if ($this->form->checkInput()) {
         $udf = new ilCourseDefinedFieldDefinition($this->getObjId(), (int) $_REQUEST['field_id']);
         $udf->setName($this->form->getInput('na'));
         $udf->setType($this->form->getInput('ty'));
         $udf->setValues($udf->prepareValues($this->form->getInput('va')));
         $udf->setValueOptions($this->form->getItemByPostVar('va')->getOpenAnswerIndexes());
         $udf->enableRequired($this->form->getInput('re'));
         $udf->update();
         // Finally reset member agreements
         ilMemberAgreement::_deleteByObjId($this->getObjId());
         ilUtil::sendSuccess($this->lng->txt('settings_saved'));
         $this->listFields();
         return true;
     }
     ilUtil::sendFailure($this->lng->txt('err_check_input'));
     $this->form->setValuesByPost();
     $this->tpl->setContent($this->form->getHTML());
     return false;
 }
 /**
  * Get all user-based tracking data for object
  *
  * @param	int		$a_ref_id
  * @param	string	$a_order_field
  * @param	string	$a_order_dir
  * @param	int		$a_offset
  * @param	int		$a_limit
  * @param	array	$a_filters
  * @param	array	$a_additional_fields
  * @param	int  	$check_agreement (obj id of parent course)
  * @param	arry	$privacy_fields
  * @return	array	cnt, set
  */
 static function getUserDataForObject($a_ref_id, $a_order_field = "", $a_order_dir = "", $a_offset = 0, $a_limit = 9999, array $a_filters = NULL, array $a_additional_fields = NULL, $check_agreement = false, $privacy_fields = NULL)
 {
     global $ilDB;
     $fields = array("usr_data.usr_id", "login", "active");
     $udf = self::buildColumns($fields, $a_additional_fields);
     $where = array();
     $where[] = "usr_data.usr_id <> " . $ilDB->quote(ANONYMOUS_USER_ID, "integer");
     // users
     $left = "";
     $a_users = self::getParticipantsForObject($a_ref_id);
     $obj_id = ilObject::_lookupObjectId($a_ref_id);
     self::refreshObjectsStatus(array($obj_id), $a_users);
     if (is_array($a_users)) {
         $left = "LEFT";
         $where[] = $ilDB->in("usr_data.usr_id", $a_users, false, "integer");
     }
     $query = " FROM usr_data " . $left . " JOIN read_event ON (read_event.usr_id = usr_data.usr_id" . " AND read_event.obj_id = " . $ilDB->quote($obj_id, "integer") . ")" . " LEFT JOIN ut_lp_marks ON (ut_lp_marks.usr_id = usr_data.usr_id " . " AND ut_lp_marks.obj_id = " . $ilDB->quote($obj_id, "integer") . ")" . " LEFT JOIN usr_pref ON (usr_pref.usr_id = usr_data.usr_id AND keyword = " . $ilDB->quote("language", "text") . ")" . self::buildFilters($where, $a_filters);
     $queries = array(array("fields" => $fields, "query" => $query));
     // #9598 - if language is not in fields alias is missing
     if ($a_order_field == "language") {
         $a_order_field = "usr_pref.value";
     }
     // udf data is added later on, not in this query
     $udf_order = null;
     if (!$a_order_field) {
         $a_order_field = "login";
     } else {
         if (substr($a_order_field, 0, 4) == "udf_") {
             $udf_order = $a_order_field;
             $a_order_field = null;
         }
     }
     $result = self::executeQueries($queries, $a_order_field, $a_order_dir, $a_offset, $a_limit);
     if ($result["cnt"]) {
         if (sizeof($udf)) {
             $query = "SELECT usr_id, field_id, value FROM udf_text WHERE " . $ilDB->in("field_id", $udf, false, "integer");
             $set = $ilDB->query($query);
             $udf = array();
             while ($row = $ilDB->fetchAssoc($set)) {
                 $udf[$row["usr_id"]]["udf_" . $row["field_id"]] = $row["value"];
             }
         }
         // (course) user agreement
         if ($check_agreement) {
             // admins/tutors (write-access) will never have agreement ?!
             include_once "Services/Membership/classes/class.ilMemberAgreement.php";
             $agreements = ilMemberAgreement::lookupAcceptedAgreements($check_agreement);
             // public information for users
             $query = "SELECT usr_id FROM usr_pref WHERE keyword = " . $ilDB->quote("public_profile", "text") . " AND value = " . $ilDB->quote("y", "text") . " OR value = " . $ilDB->quote("g", "text");
             $set = $ilDB->query($query);
             $all_public = array();
             while ($row = $ilDB->fetchAssoc($set)) {
                 $all_public[] = $row["usr_id"];
             }
             $query = "SELECT usr_id,keyword FROM usr_pref WHERE " . $ilDB->like("keyword", "text", "public_%", false) . " AND value = " . $ilDB->quote("y", "text") . " AND " . $ilDB->in("usr_id", $all_public, "", "integer");
             $set = $ilDB->query($query);
             $public = array();
             while ($row = $ilDB->fetchAssoc($set)) {
                 $public[$row["usr_id"]][] = substr($row["keyword"], 7);
             }
             unset($all_public);
         }
         foreach ($result["set"] as $idx => $row) {
             // add udf data
             if (isset($udf[$row["usr_id"]])) {
                 $result["set"][$idx] = $row = array_merge($row, $udf[$row["usr_id"]]);
             }
             // remove all private data - if active agreement and agreement not given by user
             if (sizeof($privacy_fields) && $check_agreement && !in_array($row["usr_id"], $agreements)) {
                 foreach ($privacy_fields as $field) {
                     // check against public profile
                     if (isset($row[$field]) && (!isset($public[$row["usr_id"]]) || !in_array($field, $public[$row["usr_id"]]))) {
                         // remove complete entry - offending field was filtered
                         if (isset($a_filters[$field])) {
                             unset($result["set"][$idx]);
                             break;
                         } else {
                             $result["set"][$idx][$field] = false;
                         }
                     }
                 }
             }
         }
         // as we cannot do this in the query, sort by custom field here
         if ($udf_order) {
             include_once "Services/Utilities/classes/class.ilStr.php";
             $result["set"] = ilUtil::stableSortArray($result["set"], $udf_order, $a_order_dir);
         }
     }
     return $result;
 }
 /**
  * Init acceptance
  * @return 
  */
 public function initAcceptedAgreements()
 {
     if (self::$accepted_ids !== NULL) {
         return true;
     }
     self::$export_allowed = ilPrivacySettings::_getInstance()->checkExportAccess($this->getParentObject()->object->getRefId());
     self::$confirmation_required = ilPrivacySettings::_getInstance()->courseConfirmationRequired();
     include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
     self::$accepted_ids = ilMemberAgreement::lookupAcceptedAgreements($this->getParentObject()->object->getId());
 }
 /**
  * Save privacy settings
  *
  * @access public
  *
  */
 public function save_privacy()
 {
     global $ilErr, $ilAccess, $ilSetting;
     if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
     }
     if ((int) $_POST['rbac_log_age'] > 24) {
         $_POST['rbac_log_age'] = 24;
     } else {
         if ((int) $_POST['rbac_log_age'] < 1) {
             $_POST['rbac_log_age'] = 1;
         }
     }
     $_POST['profile_protection'] = isset($_POST['profile_protection']) ? $_POST['profile_protection'] : array();
     $privacy = ilPrivacySettings::_getInstance();
     $privacy->enableCourseExport((int) in_array('export_course', $_POST['profile_protection']));
     $privacy->enableGroupExport((int) in_array('export_group', $_POST['profile_protection']));
     $privacy->setCourseConfirmationRequired((int) in_array('export_confirm_course', $_POST['profile_protection']));
     $privacy->setGroupConfirmationRequired((int) in_array('export_confirm_group', $_POST['profile_protection']));
     $privacy->showGroupAccessTimes((int) in_array('grp_access_times', $_POST['profile_protection']));
     $privacy->showCourseAccessTimes((int) in_array('crs_access_times', $_POST['profile_protection']));
     $privacy->enableForaStatistics((int) $_POST['fora_statistics']);
     $privacy->enableAnonymousFora((int) $_POST['anonymous_fora']);
     $privacy->enableRbacLog((int) $_POST['rbac_log']);
     $privacy->setRbacLogAge((int) $_POST['rbac_log_age']);
     $privacy->enableSahsProtocolData((int) $_POST['enable_sahs_pd']);
     // validate settings
     $code = $privacy->validate();
     // if error code != 0, display error and do not save
     if ($code != 0) {
         $msg = $this->getErrorMessage($code);
         ilUtil::sendFailure($msg);
     } else {
         $privacy->save();
         include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
         ilMemberAgreement::_reset();
         ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     }
     $this->showPrivacy();
 }
Exemplo n.º 9
0
 /**
  * Check agreement and redirect if it is not accepted
  *
  * @access private
  * 
  */
 private function checkAgreement()
 {
     global $ilUser, $ilAccess;
     if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         return true;
     }
     // Disable aggrement if is not member of course
     if (!$this->object->getMemberObject()->isAssigned()) {
         return true;
     }
     include_once './Services/Container/classes/class.ilMemberViewSettings.php';
     if (ilMemberViewSettings::getInstance()->isActive()) {
         return true;
     }
     include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
     $privacy = ilPrivacySettings::_getInstance();
     // Check agreement
     if (($privacy->courseConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId())) and !ilMemberAgreement::_hasAccepted($ilUser->getId(), $this->object->getId())) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Missing course confirmation.');
         return false;
     }
     // Check required fields
     include_once 'Modules/Course/classes/Export/class.ilCourseUserData.php';
     if (!ilCourseUserData::_checkRequired($ilUser->getId(), $this->object->getId())) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Missing required fields');
         return false;
     }
     return true;
 }
 function update()
 {
     global $lng, $ilCtrl;
     $user_field_definitions = ilUserDefinedFields::_getInstance();
     $user_field_definitions->setFieldType($this->field_definition["field_type"]);
     $access = array();
     $form = $this->initForm("edit");
     if ($this->validateForm($form, $user_field_definitions, $access) && $this->field_id) {
         // field values are set in validateForm()...
         $user_field_definitions->setFieldName($form->getInput("name"));
         $user_field_definitions->enableVisible($access['visible']);
         $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
         $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
         $user_field_definitions->enableCourseExport($access['course_export']);
         $user_field_definitions->enableGroupExport($access['group_export']);
         $user_field_definitions->enableChangeable($access['changeable']);
         $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
         $user_field_definitions->enableRequired($access['required']);
         $user_field_definitions->enableExport($access['export']);
         $user_field_definitions->enableSearchable($access['searchable']);
         $user_field_definitions->enableCertificate($access['certificate']);
         $user_field_definitions->update($this->field_id);
         if ($access['course_export']) {
             include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
             ilMemberAgreement::_reset();
         }
         ilUtil::sendSuccess($lng->txt('udf_added_field'), true);
         $ilCtrl->redirect($this);
     }
     $form->setValuesByPost();
     $this->edit($form);
 }
 function update()
 {
     global $lng, $ilCtrl;
     $user_field_definitions = ilUserDefinedFields::_getInstance();
     $user_field_definitions->setFieldType($this->field_definition["field_type"]);
     // gather old select options
     $old_options = null;
     if ($this->field_id) {
         $old_values = $user_field_definitions->getDefinition($this->field_id);
         if ($old_values["field_type"] == UDF_TYPE_SELECT) {
             $old_options = $old_values["field_values"];
         }
         $perms = $this->permissions->hasPermissions(ilUDFPermissionHelper::CONTEXT_FIELD, $this->field_id, array(array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY, ilUDFPermissionHelper::SUBACTION_FIELD_TITLE), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY, ilUDFPermissionHelper::SUBACTION_FIELD_PROPERTIES), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_COURSES), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_REQUIRED), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_EXPORT), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_SEARCHABLE), array(ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper::SUBACTION_FIELD_ACCESS_CERTIFICATE)));
     }
     $access = array();
     $form = $this->initForm("edit");
     if ($this->validateForm($form, $user_field_definitions, $access, $perms) && $this->field_id) {
         // field values are set in validateForm()...
         if (!$perms || $perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY][ilUDFPermissionHelper::SUBACTION_FIELD_PROPERTIES]) {
             // diff old select options against new to handle deleted values properly
             if (is_array($old_options)) {
                 foreach ($old_options as $old_option) {
                     if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
                         ilUserDefinedData::deleteFieldValue($this->field_id, $old_option);
                     }
                 }
             }
         } else {
             if (is_array($old_options)) {
                 $user_field_definitions->setFieldValues($old_options);
             }
         }
         if (!$perms || $perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_PROPERTY][ilUDFPermissionHelper::SUBACTION_FIELD_TITLE]) {
             $user_field_definitions->setFieldName($form->getInput("name"));
         } else {
             $user_field_definitions->setFieldName($this->field_definition["field_name"]);
         }
         $user_field_definitions->enableVisible($access['visible']);
         $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
         $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
         $user_field_definitions->enableCourseExport($access['course_export']);
         $user_field_definitions->enableGroupExport($access['group_export']);
         $user_field_definitions->enableChangeable($access['changeable']);
         $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
         $user_field_definitions->enableRequired($access['required']);
         $user_field_definitions->enableExport($access['export']);
         $user_field_definitions->enableSearchable($access['searchable']);
         $user_field_definitions->enableCertificate($access['certificate']);
         $user_field_definitions->update($this->field_id);
         if ($access['course_export']) {
             include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
             ilMemberAgreement::_reset();
         }
         ilUtil::sendSuccess($lng->txt('udf_added_field'), true);
         $ilCtrl->redirect($this);
     }
     $form->setValuesByPost();
     $this->edit($form);
 }
 /**
  * Save privacy settings
  *
  * @access public
  *
  */
 public function save_privacy()
 {
     global $ilErr, $ilAccess, $ilSetting;
     if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $ilErr->raiseError($this->lng->txt('no_permission'), $ilErr->WARNING);
     }
     if ((int) $_POST['rbac_log_age'] > 24) {
         $_POST['rbac_log_age'] = 24;
     } else {
         if ((int) $_POST['rbac_log_age'] < 1) {
             $_POST['rbac_log_age'] = 1;
         }
     }
     $_POST['profile_protection'] = isset($_POST['profile_protection']) ? $_POST['profile_protection'] : array();
     $privacy = ilPrivacySettings::_getInstance();
     // to determine if agreements need to be reset - see below
     $old_settings = array('export_course' => $privacy->enabledCourseExport(), 'export_group' => $privacy->enabledGroupExport(), 'export_confirm_course' => $privacy->courseConfirmationRequired(), 'export_confirm_group' => $privacy->groupConfirmationRequired(), 'crs_access_times' => $privacy->enabledCourseAccessTimes(), 'grp_access_times' => $privacy->enabledGroupAccessTimes());
     $privacy->enableCourseExport((int) in_array('export_course', $_POST['profile_protection']));
     $privacy->enableGroupExport((int) in_array('export_group', $_POST['profile_protection']));
     $privacy->setCourseConfirmationRequired((int) in_array('export_confirm_course', $_POST['profile_protection']));
     $privacy->setGroupConfirmationRequired((int) in_array('export_confirm_group', $_POST['profile_protection']));
     $privacy->showGroupAccessTimes((int) in_array('grp_access_times', $_POST['profile_protection']));
     $privacy->showCourseAccessTimes((int) in_array('crs_access_times', $_POST['profile_protection']));
     // validate settings
     $code = $privacy->validate();
     // if error code != 0, display error and do not save
     if ($code != 0) {
         $msg = $this->getErrorMessage($code);
         ilUtil::sendFailure($msg);
     } else {
         $privacy->save();
         // reset agreements?
         $do_reset = false;
         if (!$old_settings['export_course'] && $privacy->enabledCourseExport()) {
             $do_reset = true;
         }
         if (!$do_reset && !$old_settings['export_group'] && $privacy->enabledGroupExport()) {
             $do_reset = true;
         }
         if (!$do_reset && !$old_settings['export_confirm_course'] && $privacy->courseConfirmationRequired()) {
             $do_reset = true;
         }
         if (!$do_reset && !$old_settings['export_confirm_group'] && $privacy->groupConfirmationRequired()) {
             $do_reset = true;
         }
         if (!$do_reset && !$old_settings['crs_access_times'] && $privacy->enabledCourseAccessTimes()) {
             $do_reset = true;
         }
         if (!$do_reset && !$old_settings['grp_access_times'] && $privacy->enabledGroupAccessTimes()) {
             $do_reset = true;
         }
         if ($do_reset) {
             include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
             ilMemberAgreement::_reset();
         }
         ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     }
     $this->showPrivacy();
 }
Exemplo n.º 13
0
 /**
  * Handle privacy and add udf data to (user) result data
  * 
  * @param array $a_result
  * @param array $a_udf
  * @param int $a_check_agreement
  * @param array $a_privacy_fields
  * @param array $a_filters
  */
 protected static function getUDFAndHandlePrivacy(array &$a_result, array $a_udf = null, $a_check_agreement = null, array $a_privacy_fields = null, array $a_filters = null)
 {
     global $ilDB;
     if (!$a_result["cnt"]) {
         return;
     }
     if (sizeof($a_udf)) {
         $query = "SELECT usr_id, field_id, value FROM udf_text WHERE " . $ilDB->in("field_id", $a_udf, false, "integer");
         $set = $ilDB->query($query);
         $udf = array();
         while ($row = $ilDB->fetchAssoc($set)) {
             $udf[$row["usr_id"]]["udf_" . $row["field_id"]] = $row["value"];
         }
     }
     // (course/group) user agreement
     if ($a_check_agreement) {
         // admins/tutors (write-access) will never have agreement ?!
         include_once "Services/Membership/classes/class.ilMemberAgreement.php";
         $agreements = ilMemberAgreement::lookupAcceptedAgreements($a_check_agreement);
         // public information for users
         $query = "SELECT usr_id FROM usr_pref WHERE keyword = " . $ilDB->quote("public_profile", "text") . " AND value = " . $ilDB->quote("y", "text") . " OR value = " . $ilDB->quote("g", "text");
         $set = $ilDB->query($query);
         $all_public = array();
         while ($row = $ilDB->fetchAssoc($set)) {
             $all_public[] = $row["usr_id"];
         }
         $query = "SELECT usr_id,keyword FROM usr_pref WHERE " . $ilDB->like("keyword", "text", "public_%", false) . " AND value = " . $ilDB->quote("y", "text") . " AND " . $ilDB->in("usr_id", $all_public, "", "integer");
         $set = $ilDB->query($query);
         $public = array();
         while ($row = $ilDB->fetchAssoc($set)) {
             $public[$row["usr_id"]][] = substr($row["keyword"], 7);
         }
         unset($all_public);
     }
     foreach ($a_result["set"] as $idx => $row) {
         // add udf data
         if (isset($udf[$row["usr_id"]])) {
             $a_result["set"][$idx] = $row = array_merge($row, $udf[$row["usr_id"]]);
         }
         // remove all private data - if active agreement and agreement not given by user
         if (sizeof($a_privacy_fields) && $a_check_agreement && !in_array($row["usr_id"], $agreements)) {
             foreach ($a_privacy_fields as $field) {
                 // check against public profile
                 if (isset($row[$field]) && (!isset($public[$row["usr_id"]]) || !in_array($field, $public[$row["usr_id"]]))) {
                     // remove complete entry - offending field was filtered
                     if (isset($a_filters[$field])) {
                         unset($a_result["set"][$idx]);
                         break;
                     } else {
                         $a_result["set"][$idx][$field] = false;
                     }
                 }
             }
         }
     }
     $a_result["cnt"] = sizeof($a_result["set"]);
 }
 function update()
 {
     global $lng, $ilCtrl;
     $user_field_definitions = ilUserDefinedFields::_getInstance();
     $user_field_definitions->setFieldType($this->field_definition["field_type"]);
     // gather old select options
     $old_options = null;
     if ($this->field_id) {
         $old_values = $user_field_definitions->getDefinition($this->field_id);
         if ($old_values["field_type"] == UDF_TYPE_SELECT) {
             $old_options = $old_values["field_values"];
         }
     }
     $access = array();
     $form = $this->initForm("edit");
     if ($this->validateForm($form, $user_field_definitions, $access) && $this->field_id) {
         // field values are set in validateForm()...
         // diff old select options against new to handle deleted values properly
         if (is_array($old_options)) {
             foreach ($old_options as $old_option) {
                 if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
                     ilUserDefinedData::deleteFieldValue($this->field_id, $old_option);
                 }
             }
         }
         $user_field_definitions->setFieldName($form->getInput("name"));
         $user_field_definitions->enableVisible($access['visible']);
         $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
         $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
         $user_field_definitions->enableCourseExport($access['course_export']);
         $user_field_definitions->enableGroupExport($access['group_export']);
         $user_field_definitions->enableChangeable($access['changeable']);
         $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
         $user_field_definitions->enableRequired($access['required']);
         $user_field_definitions->enableExport($access['export']);
         $user_field_definitions->enableSearchable($access['searchable']);
         $user_field_definitions->enableCertificate($access['certificate']);
         $user_field_definitions->update($this->field_id);
         if ($access['course_export']) {
             include_once 'Services/Membership/classes/class.ilMemberAgreement.php';
             ilMemberAgreement::_reset();
         }
         ilUtil::sendSuccess($lng->txt('udf_added_field'), true);
         $ilCtrl->redirect($this);
     }
     $form->setValuesByPost();
     $this->edit($form);
 }