diff --git a/classes/Form/class.ilContainerMultiSelectInputGUI.php b/classes/Form/class.ilContainerMultiSelectInputGUI.php index c0d659f..fa9f760 100644 --- a/classes/Form/class.ilContainerMultiSelectInputGUI.php +++ b/classes/Form/class.ilContainerMultiSelectInputGUI.php @@ -15,7 +15,6 @@ class ilContainerMultiSelectInputGUI extends ilMultiSelectSearchInput2GUI { */ protected $container_type = 'crs'; - /** * @param string $container_type * @param string $title @@ -26,7 +25,6 @@ public function __construct($container_type, $title, $post_var) { parent::__construct($title, $post_var); } - /** * @return string */ @@ -37,13 +35,13 @@ protected function getValueAsJson() { $res = $ilDB->query($query); $result = array(); while ($row = $ilDB->fetchAssoc($res)) { + // If the value is blacklisted we don't return it. $result[] = array( "id" => $row['obj_id'], "text" => $row['title'] ); } return json_encode($result); } - /** * @return mixed */ @@ -51,7 +49,6 @@ public function getValues() { return $this->value; } - /** * @param string $container_type */ @@ -59,7 +56,6 @@ public function setContainerType($container_type) { $this->container_type = $container_type; } - /** * @return string */ diff --git a/classes/UDFCheck/class.ilUDFCheckTableGUI.php b/classes/UDFCheck/class.ilUDFCheckTableGUI.php index ac02c66..4ab129d 100644 --- a/classes/UDFCheck/class.ilUDFCheckTableGUI.php +++ b/classes/UDFCheck/class.ilUDFCheckTableGUI.php @@ -134,13 +134,12 @@ public function initFilter() { * @return array */ public function getSelectableColumns() { - $cols['field_name'] = array( + $cols['udf_definition_field_name'] = array( 'txt' => $this->pl->txt('check_name'), 'default' => true, 'width' => '40%', - 'sort_field' => 'field_name' + 'sort_field' => 'udf_definition_field_name' ); - // $cols['operator'] = array( 'txt' => $this->pl->txt('check_operator'), 'default' => true, 'width' => '20px', 'sort_field' => 'operator' ); $cols['check_value'] = array( 'txt' => $this->pl->txt('check_value'), 'default' => true, 'width' => 'auto', 'sort_field' => 'check_value' ); $cols['actions'] = array( 'txt' => $this->pl->txt('check_actions'), 'default' => true, 'width' => '150px', ); diff --git a/classes/UserSetting/class.ilUserSetting.php b/classes/UserSetting/class.ilUserSetting.php index 3c39822..cfdb524 100644 --- a/classes/UserSetting/class.ilUserSetting.php +++ b/classes/UserSetting/class.ilUserSetting.php @@ -14,6 +14,7 @@ require_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php'); require_once('./Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php'); require_once('./Services/Skill/classes/class.ilPersonalSkill.php'); +require_once('./Modules/OrgUnit/classes/class.ilObjOrgUnit.php'); /** * Class ilUserSetting @@ -166,6 +167,9 @@ public function doAssignements(ilObjUser $ilObjUser) { $this->assignCourses(); $this->assignGroups(); $this->assignToGlobalRole(); + $this->assignOrgunits(); + if(ilUserDefaultsPlugin::getInstance()->is51()) + $this->assignStudyprograms(); } } @@ -187,7 +191,7 @@ protected function assignCourses() { return false; } foreach ($this->getAssignedCourses() as $crs_obj_id) { - if (!ilObject2::_lookupType($crs_obj_id) == 'crs') { + if (ilObject2::_lookupType($crs_obj_id) != 'crs') { continue; } $part = ilCourseParticipants::_getInstanceByObjId($crs_obj_id); @@ -206,7 +210,7 @@ protected function assignGroups() { return false; } foreach ($this->getAssignedGroupes() as $grp_obj_id) { - if (!ilObject2::_lookupType($grp_obj_id) == 'grp') { + if (ilObject2::_lookupType($grp_obj_id) != 'grp') { continue; } $part = ilGroupParticipants::_getInstanceByObjId($grp_obj_id); @@ -445,6 +449,25 @@ protected function addSkills() { * @con_length 256 */ protected $portfolio_name = ''; + + /** + * @var array + * + * @con_has_field true + * @con_fieldtype text + * @con_length 256 + */ + protected $assigned_orgus = array(); + + /** + * @var array + * + * @con_has_field true + * @con_fieldtype text + * @con_length 256 + */ + protected $assigned_studyprograms = array(); + /** * @var ilUDFCheck[] */ @@ -461,6 +484,8 @@ public function sleep($field_name) { case 'assigned_courses': case 'assigned_groupes': case 'portfolio_assigned_to_groups': + case 'assigned_orgus': + case 'assigned_studyprograms': return json_encode($this->{$field_name}); break; case 'create_date': @@ -484,6 +509,8 @@ public function wakeUp($field_name, $field_value) { case 'assigned_courses': case 'assigned_groupes': case 'portfolio_assigned_to_groups': + case 'assigned_orgus': + case 'assigned_studyprograms': return json_decode($field_value); break; case 'create_date': @@ -750,6 +777,77 @@ public function getPortfolioName() { public function setPortfolioName($portfolio_name) { $this->portfolio_name = $portfolio_name; } + + /** + * @return array + */ + public function getAssignedOrgus() { + return $this->assigned_orgus; + } + + /** + * @param array $assigned_orgus + */ + public function setAssignedOrgus($assigned_orgus) { + $this->assigned_orgus = $assigned_orgus; + } + + /** + * @return array + */ + public function getAssignedStudyprograms() { + return $this->assigned_studyprograms; + } + + /** + * @param array $assigned_studyprogramms + */ + public function setAssignedStudyprograms($assigned_studyprogramms) { + $this->assigned_studyprograms = $assigned_studyprogramms; + } + + /** + * @return bool + */ + protected function assignOrgunits() { + if(!count($this->getAssignedOrgus())) + return false; + foreach ($this->getAssignedOrgus() as $orgu_obj_id) { + if (ilObject2::_lookupType($orgu_obj_id) != 'orgu') { + continue; + } + $usr_id = $this->getUsrObject()->getId(); + $orgu_ref_ids = ilObjOrgUnit::_getAllReferences($orgu_obj_id); + $orgu_ref_id = array_shift(array_values($orgu_ref_ids)); + if(!$orgu_ref_id) + continue; + $orgUnit = new ilObjOrgUnit($orgu_ref_id, true); + $orgUnit->assignUsersToEmployeeRole(array($usr_id)); + } + return true; + } + + protected function assignStudyprograms() { + if(!count($this->getAssignedStudyprograms())) + return false; + foreach($this->getAssignedStudyprograms() as $studyProgramObjId) { + if (ilObject2::_lookupType($studyProgramObjId) != 'prg') { + continue; + } + + $usr_id = $this->getUsrObject()->getId(); + + // require stuff here in order not to break it in ILIAS <= 5.0.x + require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php"); + $prg_ref_ids = ilObjStudyProgramme::_getAllReferences($studyProgramObjId); + $prg_ref_id = array_shift(array_values($prg_ref_ids)); + if(!$prg_ref_id) + continue; + $studyProgram = new ilObjStudyProgramme($prg_ref_id, true); + $studyProgram->assignUser($usr_id, 6); + } + return true; + } } ?> diff --git a/classes/UserSetting/class.ilUserSettingsFormGUI.php b/classes/UserSetting/class.ilUserSettingsFormGUI.php index 2d920d9..54b4101 100644 --- a/classes/UserSetting/class.ilUserSettingsFormGUI.php +++ b/classes/UserSetting/class.ilUserSettingsFormGUI.php @@ -17,6 +17,8 @@ class ilUserSettingsFormGUI extends ilPropertyFormGUI { const F_ASSIGNED_GROUPS = 'assigned_groupes'; const F_PORTFOLIO_TEMPLATE_ID = 'portfolio_template_id'; const F_PORTFOLIO_ASSIGNED_TO_GROUPS = 'portfolio_assigned_to_groups'; + const F_ASSIGNED_ORGUS = 'assigned_orgus'; + const F_ASSIGNED_STUDYPROGRAMS = 'assigned_studyprograms'; const F_DESCRIPTION = 'description'; const F_PORTFOLIO_NAME = 'portfolio_name'; const F_BLOG_NAME = 'blog_name'; @@ -107,6 +109,16 @@ protected function initForm() { $ilCourseMultiSelectInputGUI->setAjaxLink($this->ctrl->getLinkTarget($this->parent_gui, ilUserSettingsGUI::CMD_SEARCH_COURSES)); $this->addItem($ilCourseMultiSelectInputGUI); + $ilOrgUnitMultiSelectInputGUI = new ilContainerMultiSelectInputGUI('orgu', $this->txt(self::F_ASSIGNED_ORGUS), self::F_ASSIGNED_ORGUS); + $ilOrgUnitMultiSelectInputGUI->setAjaxLink($this->ctrl->getLinkTarget($this->parent_gui, ilUserSettingsGUI::CMD_SEARCH_COURSES)); + $this->addItem($ilOrgUnitMultiSelectInputGUI); + + if($this->pl->is51()) { + $ilStudyProgramMultiSelectInputGUI = new ilContainerMultiSelectInputGUI('prg', $this->txt(self::F_ASSIGNED_STUDYPROGRAMS), self::F_ASSIGNED_STUDYPROGRAMS); + $ilStudyProgramMultiSelectInputGUI->setAjaxLink($this->ctrl->getLinkTarget($this->parent_gui, ilUserSettingsGUI::CMD_SEARCH_COURSES)); + $this->addItem($ilStudyProgramMultiSelectInputGUI); + } + $this->addCommandButtons(); } @@ -145,9 +157,10 @@ public function fillForm() { self::F_PORTFOLIO_ASSIGNED_TO_GROUPS => implode(',', $this->object->getPortfolioAssignedToGroups()), self::F_BLOG_NAME => $this->object->getBlogName(), self::F_PORTFOLIO_NAME => $this->object->getPortfolioName(), + self::F_ASSIGNED_ORGUS=> implode(',',$this->object->getAssignedOrgus()), + self::F_ASSIGNED_STUDYPROGRAMS=> implode(',',$this->object->getAssignedStudyprograms()), ); - $this->setValuesByArray($array); } @@ -169,10 +182,14 @@ public function saveObject() { $this->object->setGlobalRole($this->getInput(self::F_GLOBAL_ROLE)); $portfolio_template_id = $this->getInput(self::F_PORTFOLIO_TEMPLATE_ID); $this->object->setPortfolioTemplateId($portfolio_template_id > 0 ? $portfolio_template_id : NULL); - $portf_assignt_to_groups = $this->getInput(self::F_PORTFOLIO_ASSIGNED_TO_GROUPS); - $this->object->setPortfolioAssignedToGroups(explode(',', $portf_assignt_to_groups[0])); + $portf_assigned_to_groups = $this->getInput(self::F_PORTFOLIO_ASSIGNED_TO_GROUPS); + $this->object->setPortfolioAssignedToGroups(explode(',', $portf_assigned_to_groups[0])); $this->object->setBlogName($this->getInput(self::F_BLOG_NAME)); $this->object->setPortfolioName($this->getInput(self::F_PORTFOLIO_NAME)); + $assigned_orgus = $this->getInput(self::F_ASSIGNED_ORGUS); + $this->object->setAssignedOrgus(explode(',', $assigned_orgus[0])); + $assigned_studyprograms = $this->getInput(self::F_ASSIGNED_STUDYPROGRAMS); + $this->object->setAssignedStudyprograms(explode(',', $assigned_studyprograms[0])); if ($this->object->getId() > 0) { $this->object->update(); diff --git a/classes/UserSetting/class.ilUserSettingsGUI.php b/classes/UserSetting/class.ilUserSettingsGUI.php index e2e3c01..519d0a6 100644 --- a/classes/UserSetting/class.ilUserSettingsGUI.php +++ b/classes/UserSetting/class.ilUserSettingsGUI.php @@ -173,7 +173,8 @@ protected function searchContainer() { $res = $ilDB->query($query); $result = array(); while ($row = $ilDB->fetchAssoc($res)) { - $result[] = array( "id" => $row['obj_id'], "text" => $row['title'] ); + if($row['title'] != "__OrgUnitAdministration") + $result[] = array( "id" => $row['obj_id'], "text" => $row['title'] ); } echo json_encode($result); exit; diff --git a/classes/UserSetting/class.ilUserSettingsTableGUI.php b/classes/UserSetting/class.ilUserSettingsTableGUI.php index 8a8a6be..8f766b1 100644 --- a/classes/UserSetting/class.ilUserSettingsTableGUI.php +++ b/classes/UserSetting/class.ilUserSettingsTableGUI.php @@ -77,7 +77,7 @@ protected function parseData() { $xdglRequestList->limit($this->getOffset(), $this->getOffset() + $this->getLimit()); $xdglRequestList->orderBy('title'); $a_data = $xdglRequestList->getArray(); - if(ilUserDefaultsPlugin::is55()) { + if(ilUserDefaultsPlugin::is50()) { $img_on = ilUtil::img(ilUtil::getImagePath('icon_ok.svg')); $img_off = ilUtil::img(ilUtil::getImagePath('icon_not_ok.svg')); }else { diff --git a/classes/class.ilUserDefaultsConfigGUI.php b/classes/class.ilUserDefaultsConfigGUI.php index 4a59ae8..15862ae 100644 --- a/classes/class.ilUserDefaultsConfigGUI.php +++ b/classes/class.ilUserDefaultsConfigGUI.php @@ -9,7 +9,7 @@ * @author Fabian Schmid * * @version 1.0.00 - * + * ilCtrl_IsCalledBy ilUserDefaultsConfigGUI : ilObjComponentSettingsGUI */ class ilUserDefaultsConfigGUI extends ilPluginConfigGUI { diff --git a/classes/class.ilUserDefaultsPlugin.php b/classes/class.ilUserDefaultsPlugin.php index 45630a3..da8c67d 100644 --- a/classes/class.ilUserDefaultsPlugin.php +++ b/classes/class.ilUserDefaultsPlugin.php @@ -80,8 +80,17 @@ public function getPluginName() { /** * @return bool */ - public static function is55() { - return ((int)str_ireplace('.', '', ILIAS_VERSION_NUMERIC)) >= 500; + public static function is50() { + $version = explode('.', ILIAS_VERSION_NUMERIC); + return $version[0] >= 5; + } + + /** + * @return bool + */ + public static function is51() { + $version = explode('.', ILIAS_VERSION_NUMERIC); + return $version[0] >= 5 && $version[1] >= 1; } diff --git a/doc/Documentation.pdf b/doc/Documentation.pdf new file mode 100644 index 0000000..7804a21 Binary files /dev/null and b/doc/Documentation.pdf differ diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 3b35864..b5109d4 100755 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -38,4 +38,8 @@ check_delete#:#Löschen check_back#:#<< Zurück crs_placeholder#:#Kurse wählen grp_placeholder#:#Gruppen wählen -check_cancel#:#Abbrechen \ No newline at end of file +check_cancel#:#Abbrechen +set_assigned_orgus#:#Einschreiben in Organisationseinheiten +set_assigned_studyprograms#:#Einschreiben in Studienprogramme +orgu_placeholder#:#Organisationseinheiten wählen +prg_placeholder#:#Studienprogramme wählen \ No newline at end of file diff --git a/plugin.php b/plugin.php index fad8257..eadb015 100644 --- a/plugin.php +++ b/plugin.php @@ -1,8 +1,8 @@ diff --git a/sql/dbupdate.php b/sql/dbupdate.php index 9fb7be5..1a6d777 100644 --- a/sql/dbupdate.php +++ b/sql/dbupdate.php @@ -9,4 +9,14 @@ +<#3> + +<#4> + \ No newline at end of file