/** * 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); }
/** * 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; }