Skip to content

Commit

Permalink
Added default position access settings for objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer-ilias committed Aug 23, 2017
1 parent 6912439 commit 373db0b
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 77 deletions.
6 changes: 4 additions & 2 deletions Modules/Course/classes/class.ilObjCourseGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,8 @@ public function updateObject()
ilObjectServiceSettingsGUI::AUTO_RATING_NEW_OBJECTS,
ilObjectServiceSettingsGUI::TAG_CLOUD,
ilObjectServiceSettingsGUI::CUSTOM_METADATA,
ilObjectServiceSettingsGUI::BADGES
ilObjectServiceSettingsGUI::BADGES,
ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS,
)
);

Expand Down Expand Up @@ -1402,7 +1403,8 @@ protected function initEditForm()
ilObjectServiceSettingsGUI::AUTO_RATING_NEW_OBJECTS,
ilObjectServiceSettingsGUI::TAG_CLOUD,
ilObjectServiceSettingsGUI::CUSTOM_METADATA,
ilObjectServiceSettingsGUI::BADGES
ilObjectServiceSettingsGUI::BADGES,
ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS
)
);

Expand Down
22 changes: 22 additions & 0 deletions Modules/OrgUnit/classes/Settings/class.ilOrgUnitGlobalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ public function isPositionAccessActiveForObject($a_obj_id)
return $this->object_position_cache[$a_obj_id];
}

/**
* Set and save the default activation status according to settings.
* @param int obj_id
*/
public function saveDefaultPositionActivationStatus($a_obj_id)
{
$type = ilObject::_lookupType($a_obj_id);
try {
$type_settings = $this->getObjectPositionSettingsByType($type);
}
catch (\InvalidArgumentException $ex) {
return;
}
if($type_settings->isActive())
{
$object_setting = new ilOrgUnitObjectPositionSetting($a_obj_id);
$object_setting->setActive($type_settings->getActivationDefault());
$object_setting->update();
}
return;
}

/**
* read settings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ public function isActive()
return $this->active;
}

/**
* Set active for object
* @param bool $a_status
*/
public function setActive($a_status)
{
$this->active = $a_status;
}

/**
* Update object entry
*/
Expand Down
9 changes: 5 additions & 4 deletions Services/Object/classes/class.ilObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,20 +629,21 @@ function create()

$ilDB->manipulate($q);

//$this->id = $ilDB->getLastInsertId();


// Save long form of description if is rbac object
if($objDefinition->isRBACObject($this->getType()))
{
$values = array(
'obj_id' => array('integer',$this->id),
'description' => array('clob', $this->getLongDescription()));
//var_dump($values);
$ilDB->insert('object_description',$values);
}


if($GLOBALS['DIC']['objDefinition']->isOrgUnitPermissionType($this->type))
{
ilOrgUnitGlobalSettings::getInstance()->saveDefaultPositionActivationStatus($this->id);
}

// the line ($this->read();) messes up meta data handling: meta data,
// that is not saved at this time, gets lost, so we query for the dates alone
//$this->read();
Expand Down
10 changes: 10 additions & 0 deletions Services/Object/classes/class.ilObjectDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,16 @@ public function getOrgUnitPermissionTypes()
}
return $types;
}

/**
* Check if object type offers orgunit position support
* @param string $obj_type
* @return bool
*/
public function isOrgUnitPermissionType($a_obj_type)
{
return in_array($a_obj_type, $this->getOrgUnitPermissionTypes());
}

/**
* Get Position By Object Type
Expand Down
25 changes: 14 additions & 11 deletions Services/Object/classes/class.ilObjectServiceSettingsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ilObjectServiceSettingsGUI
const TAG_CLOUD = 'cont_tag_cloud';
const CUSTOM_METADATA = 'cont_custom_md';
const BADGES = 'cont_badges';
const EXTENDED_USER_ACCESS = 'obj_orgunit_positions';
const ORGU_POSITION_ACCESS = 'obj_orgunit_positions';


private $gui = null;
Expand Down Expand Up @@ -234,7 +234,7 @@ public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $for
$form->addItem($bdg);
}
}
if(in_array(self::EXTENDED_USER_ACCESS, $services))
if(in_array(self::ORGU_POSITION_ACCESS, $services))
{
$position_settings = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
ilObject::_lookupType($a_obj_id)
Expand All @@ -244,15 +244,15 @@ public static function initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $for
$position_settings->isChangeableForObject()
)
{
$lia = new ilCheckboxInputGUI($GLOBALS['DIC']->language()->txt('obj_orgunit_positions'), self::EXTENDED_USER_ACCESS);
$lia = new ilCheckboxInputGUI(
$GLOBALS['DIC']->language()->txt('obj_orgunit_positions'),
self::ORGU_POSITION_ACCESS
);
$lia->setInfo($GLOBALS['DIC']->language()->txt('obj_orgunit_positions_info'));
$lia->setValue(1);
$lia->setChecked(
ilContainer::_lookupContainerSetting(
$a_obj_id,
self::EXTENDED_USER_ACCESS,
false
));
(bool) ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($a_obj_id)
);
$form->addItem($lia);
}
}
Expand Down Expand Up @@ -345,12 +345,15 @@ public static function updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $f
}
}
// extended user access
if(in_array(self::EXTENDED_USER_ACCESS, $services))
if(in_array(self::ORGU_POSITION_ACCESS, $services))
{
ilContainer::_writeContainerSetting($a_obj_id,self::EXTENDED_USER_ACCESS,(int) $form->getInput(self::EXTENDED_USER_ACCESS));
$orgu_object_settings = new ilOrgUnitObjectPositionSetting($a_obj_id);
$orgu_object_settings->setActive(
(int) $form->getInput(self::ORGU_POSITION_ACCESS)
);
$orgu_object_settings->update();
}


return true;
}

Expand Down
4 changes: 3 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// to the corresponding mode!
// Language file names refer to ISO 639, see: http://www.oasis-open.org/cover/iso639a.html
<!-- language file start -->
obj#:#obj_orgunit_positions#:#Zugriffsregelungen nach Organisationseinheiten
obj#:#obj_orgunit_positions_info#:#Wenn aktiviert, können zusätzliche Zugriffsregelungen über Positionen in Organisationseinheiten vergeben werden.
orgu#:#orgu_global_set_form#:#Globale Einstellungen
orgu#:#orgu_global_set_positions#:#Anzeige von Benutzerdaten nach Positionen in Organisationseinheiten
orgu#:#orgu_global_set_positions_type_active#:#Aktiv für:
Expand Down Expand Up @@ -16148,4 +16150,4 @@ svy#:#svy_user_added_360_rater_reminder_mail#:#Bitte bewerten Sie noch die folge
prtf#:#prtf_add_new_blog#:#Neues Blog hinzufügen
prtf#:#prtf_add_new_blog_info#:#Das neue Blog wird Ihrem persönlichen Arbeitsraum hinzugefügt.
prtf#:#prtf_add_existing_blog#:#Vorhandenes Blog nutzen
blog#:#blog_draft_text#:#Unveröffentlichter Beitrag
blog#:#blog_draft_text#:#Unveröffentlichter Beitrag
4 changes: 3 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// to the corresponding mode!
// Language file names refer to ISO 639, see: http://www.oasis-open.org/cover/iso639a.html
<!-- language file start -->
obj#:#obj_orgunit_positions#:#Access Control by Organisation Unit Positions
obj#:#obj_orgunit_positions_info#:#If enabled, additional access control rules can be defined by positions in organisational units.
orgu#:#orgu_global_set_form#:#Global Organisational Unit Settings
orgu#:#orgu_global_set_positions#:#Show User Data according to Organisational Unit Positions
orgu#:#orgu_global_set_positions_type_active#:#Active for:
Expand Down Expand Up @@ -13687,4 +13689,4 @@ svy#:#svy_user_added_360_rater_reminder_mail#:#Please finish to rate the followi
prtf#:#prtf_add_new_blog#:#Add New Blog
prtf#:#prtf_add_new_blog_info#:#The new blog will be added to your personal workspace.
prtf#:#prtf_add_existing_blog#:#Use Existing Blog
blog#:#blog_draft_text#:#Unpublished Post
blog#:#blog_draft_text#:#Unpublished Post
Loading

0 comments on commit 373db0b

Please sign in to comment.