Skip to content

Commit

Permalink
Merge pull request #5 from studer-raimann/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
otruffer committed Dec 22, 2015
2 parents 0c641f6 + 16b92d0 commit baa2c69
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 21 deletions.
6 changes: 1 addition & 5 deletions classes/Form/class.ilContainerMultiSelectInputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ilContainerMultiSelectInputGUI extends ilMultiSelectSearchInput2GUI {
*/
protected $container_type = 'crs';


/**
* @param string $container_type
* @param string $title
Expand All @@ -26,7 +25,6 @@ public function __construct($container_type, $title, $post_var) {
parent::__construct($title, $post_var);
}


/**
* @return string
*/
Expand All @@ -37,29 +35,27 @@ 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
*/
public function getValues() {
return $this->value;
}


/**
* @param string $container_type
*/
public function setContainerType($container_type) {
$this->container_type = $container_type;
}


/**
* @return string
*/
Expand Down
5 changes: 2 additions & 3 deletions classes/UDFCheck/class.ilUDFCheckTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', );

Expand Down
102 changes: 100 additions & 2 deletions classes/UserSetting/class.ilUserSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -166,6 +167,9 @@ public function doAssignements(ilObjUser $ilObjUser) {
$this->assignCourses();
$this->assignGroups();
$this->assignToGlobalRole();
$this->assignOrgunits();
if(ilUserDefaultsPlugin::getInstance()->is51())
$this->assignStudyprograms();
}
}

Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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[]
*/
Expand All @@ -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':
Expand All @@ -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':
Expand Down Expand Up @@ -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;
}
}

?>
23 changes: 20 additions & 3 deletions classes/UserSetting/class.ilUserSettingsFormGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion classes/UserSetting/class.ilUserSettingsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion classes/UserSetting/class.ilUserSettingsTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion classes/class.ilUserDefaultsConfigGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Fabian Schmid <fs@studer-raimann.ch>
*
* @version 1.0.00
*
* ilCtrl_IsCalledBy ilUserDefaultsConfigGUI : ilObjComponentSettingsGUI
*/
class ilUserDefaultsConfigGUI extends ilPluginConfigGUI {

Expand Down
13 changes: 11 additions & 2 deletions classes/class.ilUserDefaultsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
Binary file added doc/Documentation.pdf
Binary file not shown.
6 changes: 5 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
$id = 'usrdef';
$version = '1.0.7';
$version = '1.1.0';
$ilias_min_version = '4.4';
$ilias_max_version = '5.0.999';
$ilias_max_version = '5.1.999';
$responsible = 'Fabian Schmid';
$responsible_mail = 'fs@studer-raimann.ch';
?>
10 changes: 10 additions & 0 deletions sql/dbupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@
<?php
require_once('./Customizing/global/plugins/Services/EventHandling/EventHook/UserDefaults/classes/UserSetting/class.ilUserSetting.php');
ilUserSetting::updateDB();
?>
<#3>
<?php
require_once('./Customizing/global/plugins/Services/EventHandling/EventHook/UserDefaults/classes/UserSetting/class.ilUserSetting.php');
ilUserSetting::updateDB();
?>
<#4>
<?php
require_once('./Customizing/global/plugins/Services/EventHandling/EventHook/UserDefaults/classes/UserSetting/class.ilUserSetting.php');
ilUserSetting::updateDB();
?>

0 comments on commit baa2c69

Please sign in to comment.