public function __construct($parent_obj, $parent_cmd, $role_id, $template_context = "")
 {
     parent::__construct($parent_obj, $parent_cmd, $template_context);
     global $lng, $ilCtrl, $ilTabs;
     /**
      * @var $ilCtrl ilCtrl
      * @var $ilTabs ilTabsGUI
      */
     $this->ctrl = $ilCtrl;
     $this->tabs = $ilTabs;
     $this->lng = $lng;
     $this->setPrefix("sr_other_role_" . $role_id);
     $this->setFormName('sr_other_role_' . $role_id);
     $this->setId("sr_other_role_" . $role_id);
     $this->setRoleId($role_id);
     $this->setTableHeaders();
     $this->setTopCommands(true);
     $this->setEnableHeader(true);
     $this->setShowRowsSelector(true);
     $this->setShowTemplates(false);
     $this->setEnableHeader(true);
     $this->setDefaultOrderField("role");
     $this->setEnableTitle(true);
     $this->setTitle(ilObjRole::_lookupTitle($role_id));
     $this->setRowTemplate("tpl.staff_row.html", "Modules/OrgUnit");
 }
Ejemplo n.º 2
0
 public function initDefaultRoles()
 {
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role = ilObjRole::createDefaultRole('il_xvit_admin_' . $this->getRefId(), "Admin of vitero obj_no." . $this->getId(), 'il_xvit_admin', $this->getRefId());
     $role = ilObjRole::createDefaultRole('il_xvit_member_' . $this->getRefId(), "Member of vitero obj_no." . $this->getId(), 'il_xvit_member', $this->getRefId());
     parent::initDefaultRoles();
 }
 /**
  * Parse Search entries
  *
  * @access public
  * @param array array of search entries
  * 
  */
 public function parse($entries)
 {
     global $rbacreview;
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     foreach ($entries as $entry) {
         $tmp_arr['id'] = $entry['obj_id'];
         $tmp_arr['title'] = ilObjRole::_getTranslation(ilObject::_lookupTitle($entry['obj_id']));
         $tmp_arr['description'] = ilObject::_lookupDescription($entry['obj_id']);
         $tmp_arr['context'] = ilObject::_lookupTitle($rbacreview->getObjectOfRole($entry['obj_id']));
         $records_arr[] = $tmp_arr;
     }
     $this->setData($records_arr ? $records_arr : array());
 }
 /**
  * Apply action
  */
 public function apply()
 {
     global $rbacreview, $rbacadmin;
     $source = $this->initSourceObject();
     // Check if role folder already exists
     // Create role
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role = new ilObjRole();
     $role->setTitle(ilObject::_lookupTitle($this->getRoleTemplateId()));
     $role->setDescription(ilObject::_lookupDescription($this->getRoleTemplateId()));
     $role->create();
     $rbacadmin->assignRoleToFolder($role->getId(), $source->getRefId(), "y");
     $GLOBALS['ilLog']->write(__METHOD__ . ': Using rolt: ' . $this->getRoleTemplateId() . ' with title "' . ilObject::_lookupTitle($this->getRoleTemplateId() . '". '));
     // Copy template permissions
     $rbacadmin->copyRoleTemplatePermissions($this->getRoleTemplateId(), ROLE_FOLDER_ID, $source->getRefId(), $role->getId(), true);
     // Set permissions
     $ops = $rbacreview->getOperationsOfRole($role->getId(), $source->getType(), $source->getRefId());
     $rbacadmin->grantPermission($role->getId(), $ops, $source->getRefId());
     return true;
 }
 function start()
 {
     global $rbacreview;
     if (!is_array($this->roles)) {
         return false;
     }
     $this->__buildHeader();
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
     foreach ($this->roles as $role) {
         // if role type is not empty and does not match, then continue;
         if (!empty($this->role_type) && strcasecmp($this->role_type, $role["role_type"]) != 0) {
             continue;
         }
         if ($rbacreview->isRoleDeleted($role["obj_id"])) {
             continue;
         }
         $attrs = array('role_type' => ucwords($role["role_type"]), 'id' => "il_" . IL_INST_ID . "_role_" . $role["obj_id"]);
         // open tag
         $this->xmlStartTag("Role", $attrs);
         $this->xmlElement('Title', null, $role["title"]);
         $this->xmlElement('Description', null, $role["description"]);
         $this->xmlElement('Translation', null, ilObjRole::_getTranslation($role["title"]));
         if ($ref_id = ilUtil::__extractRefId($role["title"])) {
             $ownerObj = IlObjectFactory::getInstanceByRefId($ref_id, false);
             if (is_object($ownerObj)) {
                 $attrs = array("obj_id" => "il_" . IL_INST_ID . "_" . $ownerObj->getType() . "_" . $ownerObj->getId(), "ref_id" => $ownerObj->getRefId(), "type" => $ownerObj->getType());
                 $this->xmlStartTag('AssignedObject', $attrs);
                 $this->xmlElement('Title', null, $ownerObj->getTitle());
                 $this->xmlElement('Description', null, $ownerObj->getDescription());
                 ilObjectXMLWriter::appendPathToObject($this, $ref_id);
                 $this->xmlEndTag('AssignedObject', $attrs);
             }
         }
         $this->xmlEndTag("Role");
     }
     $this->__buildFooter();
     return true;
 }
 /**
  * Constructor
  *
  * @access public
  * @param object parent gui object
  * @return void
  */
 public function __construct($a_parent_obj)
 {
     global $lng, $ilCtrl;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('crs');
     $this->ctrl = $ilCtrl;
     $this->container = $a_parent_obj;
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $this->privacy = ilPrivacySettings::_getInstance();
     $this->participants = ilCourseParticipants::_getInstanceByObjId($a_parent_obj->object->getId());
     parent::__construct($a_parent_obj, 'editMembers');
     $this->setFormName('participants');
     $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
     $this->addColumn($this->lng->txt('lastname'), 'lastname', '20%');
     $this->addColumn($this->lng->txt('login'), 'login', '25%');
     if ($this->privacy->enabledCourseAccessTimes()) {
         $this->addColumn($this->lng->txt('last_access'), 'access_time');
     }
     $this->addColumn($this->lng->txt('crs_passed'), 'passed');
     $this->addColumn($this->lng->txt('crs_blocked'), 'blocked');
     $this->addColumn($this->lng->txt('crs_notification'), 'notification');
     $this->addColumn($this->lng->txt('objs_role'), 'roles');
     $this->addCommandButton('updateMembers', $this->lng->txt('save'));
     $this->addCommandButton('members', $this->lng->txt('cancel'));
     $this->setRowTemplate("tpl.edit_participants_row.html", "Modules/Course");
     $this->disable('sort');
     $this->enable('header');
     $this->enable('numinfo');
     $this->disable('select_all');
     // Performance improvement: We read the local course roles
     // only once, instead of reading them for each row in method fillRow().
     $this->localCourseRoles = array();
     foreach ($this->container->object->getLocalCourseRoles(false) as $title => $role_id) {
         $this->localCourseRoles[ilObjRole::_getTranslation($title)] = array('role_id' => $role_id, 'title' => $title);
     }
 }
Ejemplo n.º 7
0
 /**
  * Add standard fields to form
  */
 function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
 {
     global $ilSetting, $lng, $rbacreview, $ilias;
     // custom registration settings
     if (self::$mode == self::MODE_REGISTRATION) {
         include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
         $registration_settings = new ilRegistrationSettings();
         self::$user_field["username"]["group"] = "login_data";
         self::$user_field["password"]["group"] = "login_data";
         self::$user_field["language"]["default"] = $lng->lang_key;
         // different position for role
         $roles = self::$user_field["roles"];
         unset(self::$user_field["roles"]);
         self::$user_field["roles"] = $roles;
         self::$user_field["roles"]["group"] = "settings";
     }
     $fields = $this->getStandardFields();
     $current_group = "";
     $custom_fields_done = false;
     foreach ($fields as $f => $p) {
         // next group? -> diplay subheader
         if ($p["group"] != $current_group && ilUserProfile::userSettingVisible($f)) {
             if (is_array($custom_fields) && !$custom_fields_done) {
                 // should be appended to "other" or at least before "settings"
                 if ($current_group == "other" || $p["group"] == "settings") {
                     // add "other" subheader
                     if ($current_group != "other") {
                         $sh = new ilFormSectionHeaderGUI();
                         $sh->setTitle($lng->txt("other"));
                         $a_form->addItem($sh);
                     }
                     foreach ($custom_fields as $custom_field) {
                         $a_form->addItem($custom_field);
                     }
                     $custom_fields_done = true;
                 }
             }
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt($p["group"]));
             $a_form->addItem($sh);
             $current_group = $p["group"];
         }
         $m = "";
         if (isset($p["method"])) {
             $m = $p["method"];
         }
         $lv = isset($p["lang_var"]) && $p["lang_var"] != "" ? $p["lang_var"] : $f;
         switch ($p["input"]) {
             case "login":
                 if ((int) $ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION) {
                     $val = new ilTextInputGUI($lng->txt('username'), 'username');
                     if ($a_user) {
                         $val->setValue($a_user->getLogin());
                     }
                     $val->setMaxLength(32);
                     $val->setSize(40);
                     $val->setRequired(true);
                 } else {
                     // user account name
                     $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
                     if ($a_user) {
                         $val->setValue($a_user->getLogin());
                     }
                 }
                 $a_form->addItem($val);
                 break;
             case "text":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ti->setValue($a_user->{$m}());
                     }
                     $ti->setMaxLength($p["maxlength"]);
                     $ti->setSize($p["size"]);
                     $ti->setRequired($ilSetting->get("require_" . $f));
                     if (!$ti->getRequired() || $ti->getValue()) {
                         $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ti);
                 }
                 break;
             case "sel_country":
                 if (ilUserProfile::userSettingVisible($f)) {
                     include_once "./Services/Form/classes/class.ilCountrySelectInputGUI.php";
                     $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ci->setValue($a_user->{$m}());
                     }
                     $ci->setRequired($ilSetting->get("require_" . $f));
                     if (!$ci->getRequired() || $ci->getValue()) {
                         $ci->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ci);
                 }
                 break;
             case "birthday":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_" . $f);
                     include_once "./Services/Calendar/classes/class.ilDateTime.php";
                     $date = null;
                     if ($a_user && strlen($a_user->{$m}())) {
                         $date = new ilDateTime($a_user->{$m}(), IL_CAL_DATE);
                         $bi->setDate($date);
                     }
                     $bi->setShowEmpty(true);
                     $bi->setStartYear(1900);
                     $bi->setRequired($ilSetting->get("require_" . $f));
                     if (!$bi->getRequired() || $date) {
                         $bi->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($bi);
                 }
                 break;
             case "radio":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $rg->setValue($a_user->{$m}());
                     }
                     foreach ($p["values"] as $k => $v) {
                         $op = new ilRadioOption($lng->txt($v), $k);
                         $rg->addOption($op);
                     }
                     $rg->setRequired($ilSetting->get("require_" . $f));
                     if (!$rg->getRequired() || $rg->getValue()) {
                         $rg->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($rg);
                 }
                 break;
             case "picture":
                 if (ilUserProfile::userSettingVisible("upload") && $a_user) {
                     $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
                     $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
                     $upload = $a_form->getFileUpload("userfile");
                     if ($upload["name"]) {
                         $ii->setPending($upload["name"]);
                     } else {
                         $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true, true);
                         if ($im != "") {
                             $ii->setImage($im);
                             $ii->setAlt($lng->txt("personal_picture"));
                         }
                     }
                     // ilinc link as info
                     if (ilUserProfile::userSettingVisible("upload") and $ilSetting->get("ilinc_active")) {
                         include_once './Modules/ILinc/classes/class.ilObjiLincUser.php';
                         $ilinc_user = new ilObjiLincUser($a_user);
                         if ($ilinc_user->id) {
                             include_once './Modules/ILinc/classes/class.ilnetucateXMLAPI.php';
                             $ilincAPI = new ilnetucateXMLAPI();
                             $ilincAPI->uploadPicture($ilinc_user);
                             $response = $ilincAPI->sendRequest("uploadPicture");
                             // return URL to user's personal page
                             $url = trim($response->data['url']['cdata']);
                             $desc = $lng->txt("ilinc_upload_pic_text") . " " . '<a href="' . $url . '">' . $lng->txt("ilinc_upload_pic_linktext") . '</a>';
                             $ii->setInfo($desc);
                         }
                     }
                     $a_form->addItem($ii);
                 }
                 break;
             case "roles":
                 if (self::$mode == self::MODE_DESKTOP) {
                     if (ilUserProfile::userSettingVisible("roles")) {
                         $global_roles = $rbacreview->getGlobalRoles();
                         foreach ($global_roles as $role_id) {
                             if (in_array($role_id, $rbacreview->assignedRoles($a_user->getId()))) {
                                 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
                                 $role_names .= $roleObj->getTitle() . ", ";
                                 unset($roleObj);
                             }
                         }
                         $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
                         $dr->setValue(substr($role_names, 0, -2));
                         $a_form->addItem($dr);
                     }
                 } else {
                     if (self::$mode == self::MODE_REGISTRATION) {
                         if ($registration_settings->roleSelectionEnabled()) {
                             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
                             $options = array();
                             foreach (ilObjRole::_lookupRegisterAllowed() as $role) {
                                 $options[$role["id"]] = $role["title"];
                             }
                             // registration form validation will take care of missing field / value
                             if ($options) {
                                 if (sizeof($options) > 1) {
                                     $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_" . $f);
                                     $ta->setOptions($options);
                                     $ta->setRequired($ilSetting->get("require_" . $f));
                                     if (!$ta->getRequired()) {
                                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                                     }
                                 } else {
                                     $ta = new ilHiddenInputGUI("usr_" . $f);
                                     $ta->setValue(array_shift(array_keys($options)));
                                 }
                                 $a_form->addItem($ta);
                             }
                         }
                     }
                 }
                 break;
             case "email":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $em = new ilEMailInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $em->setValue($a_user->{$m}());
                     }
                     $em->setRequired($ilSetting->get("require_" . $f));
                     if (!$em->getRequired() || $em->getValue()) {
                         $em->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     if (self::MODE_REGISTRATION == self::$mode) {
                         $em->setRetype(true);
                     }
                     $a_form->addItem($em);
                 }
                 break;
             case "textarea":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ta->setValue($a_user->{$m}());
                     }
                     $ta->setRows($p["rows"]);
                     $ta->setCols($p["cols"]);
                     $ta->setRequired($ilSetting->get("require_" . $f));
                     if (!$ta->getRequired() || $ta->getValue()) {
                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "messenger":
                 if (ilUserProfile::userSettingVisible("instant_messengers")) {
                     $im_arr = $p["types"];
                     foreach ($im_arr as $im_name) {
                         $im = new ilTextInputGUI($lng->txt("im_" . $im_name), "usr_im_" . $im_name);
                         if ($a_user) {
                             $im->setValue($a_user->getInstantMessengerId($im_name));
                         }
                         $im->setMaxLength($p["maxlength"]);
                         $im->setSize($p["size"]);
                         $im->setRequired($ilSetting->get("require_" . "instant_messengers"));
                         if (!$im->getRequired() || $im->getValue()) {
                             $im->setDisabled($ilSetting->get("usr_settings_disable_" . "instant_messengers"));
                         }
                         $a_form->addItem($im);
                     }
                 }
                 break;
             case "password":
                 if (self::$mode == self::MODE_REGISTRATION) {
                     if (!$registration_settings->passwordGenerationEnabled()) {
                         $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_" . $f);
                         $ta->setRequired(true);
                         // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
                     } else {
                         $ta = new ilNonEditableValueGUI($lng->txt($lv));
                         $ta->setValue($lng->txt("reg_passwd_via_mail"));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "language":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ta = new ilSelectInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ta->setValue($a_user->{$m}());
                     }
                     $options = array();
                     $lng->loadLanguageModule("meta");
                     foreach ($lng->getInstalledLanguages() as $lang_key) {
                         $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
                     }
                     asort($options);
                     // #9728
                     $ta->setOptions($options);
                     $ta->setRequired($ilSetting->get("require_" . $f));
                     if (!$ta->getRequired() || $ta->getValue()) {
                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "multitext":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     $ti->setMulti(true);
                     if ($a_user) {
                         $ti->setValue($a_user->{$m}());
                     }
                     $ti->setMaxLength($p["maxlength"]);
                     $ti->setSize($p["size"]);
                     $ti->setRequired($ilSetting->get("require_" . $f));
                     if (!$ti->getRequired() || $ti->getValue()) {
                         $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     if ($this->ajax_href) {
                         // add field to ajax call
                         $ti->setDataSource($this->ajax_href . "&f=" . $f);
                     }
                     $a_form->addItem($ti);
                 }
                 break;
         }
     }
     // append custom fields as "other"
     if (is_array($custom_fields) && !$custom_fields_done) {
         // add "other" subheader
         if ($current_group != "other") {
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt("other"));
             $a_form->addItem($sh);
         }
         foreach ($custom_fields as $custom_field) {
             $a_form->addItem($custom_field);
         }
     }
 }
 /**
  * Available Roles Table Data
  * @return array
  */
 function getAvailableRolesTableData()
 {
     global $tree;
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $path = array_reverse($tree->getPathId($this->object->getRefId()));
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $counter = 0;
     foreach ($this->valid_roles as $role) {
         $result_set[$counter]["img"] = in_array($role['obj_id'], $this->user_roles) ? self::IMG_OK : self::IMG_NOT_OK;
         $result_set[$counter]["role"] = str_replace(" ", "&nbsp;", ilObjRole::_getTranslation($role["title"]));
         if ($role['role_type'] != "linked") {
             $result_set[$counter]["effective_from"] = "";
         } else {
             $rolfs = $this->rbacreview->getFoldersAssignedToRole($role["obj_id"]);
             // ok, try to match the next rolf in path
             foreach ($path as $node) {
                 if ($node == 1) {
                     break;
                 }
                 if (in_array($node, $rolfs)) {
                     $nodedata = $tree->getNodeData($node);
                     $result_set[$counter]["effective_from"] = $nodedata["title"];
                     $result_set[$counter]["effective_from_ref_id"] = $node;
                     break;
                 }
             }
         }
         if (in_array($role['obj_id'], $this->global_roles)) {
             $result_set[$counter]["original_position"] = $this->lng->txt("global");
             $result_set[$counter]["original_position_ref_id"] = false;
         } else {
             $rolf = $this->rbacreview->getFoldersAssignedToRole($role["obj_id"], true);
             $parent_node = $tree->getNodeData($rolf[0]);
             $result_set[$counter]["original_position"] = $parent_node["title"];
             $result_set[$counter]["original_position_ref_id"] = $parent_node["ref_id"];
         }
         ++$counter;
     }
     return $result_set;
 }
 /**
  * Returns the parent object of the role folder object which contains the specified role.
  */
 function getRoleObject($a_role_id)
 {
     if (array_key_exists($a_role_id, $this->localRoleCache)) {
         return $this->localRoleCache[$a_role_id];
     } else {
         $role_obj = new ilObjRole($a_role_id, false);
         $role_obj->read();
         $this->localRoleCache[$a_role_id] = $role_obj;
         return $role_obj;
     }
 }
 public function initDefaultRoles()
 {
     /**
      * @var $rbacadmin  ilRbacAdmin
      * @var $rbacreview ilRbacReview
      */
     global $rbacadmin, $rbacreview;
     include_once 'class.ilObjAdobeConnectAccess.php';
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     ilObjAdobeConnectAccess::getLocalAdminRoleTemplateId();
     ilObjAdobeConnectAccess::getLocalMemberRoleTemplateId();
     $admin_role = ilObjRole::createDefaultRole('il_xavc_admin_' . $this->getRefId(), 'Admin of Adobe Connect object with obj_no.' . $this->getId(), 'il_xavc_admin', $this->getRefId());
     $member_role = ilObjRole::createDefaultRole('il_xavc_member_' . $this->getRefId(), 'Member of Adobe Connect object with obj_no.' . $this->getId(), 'il_xavc_member', $this->getRefId());
     $ops = $rbacreview->getOperationsOfRole($member_role->getId(), 'xavc', $this->getRefId());
     // Set view permission for users
     $rbacadmin->grantPermission(self::RBAC_DEFAULT_ROLE_ID, $ops, $this->getRefId());
     // Set view permission for guests
     $rbacadmin->grantPermission(self::RBAC_GUEST_ROLE_ID, array(2), $this->getRefId());
     $roles = array($admin_role->getId(), $member_role->getId());
     return $roles ? $roles : array();
 }
 /**
  * import users
  */
 function importUsersObject()
 {
     global $rbacreview, $ilUser;
     // Blind out tabs for local user import
     if ($_GET["baseClass"] == 'ilRepositoryGUI') {
         $this->tabs_gui->clearTargets();
     }
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     include_once './Services/User/classes/class.ilUserImportParser.php';
     global $rbacreview, $rbacsystem, $tree, $lng;
     switch ($_POST["conflict_handling_choice"]) {
         case "update_on_conflict":
             $rule = IL_UPDATE_ON_CONFLICT;
             break;
         case "ignore_on_conflict":
         default:
             $rule = IL_IGNORE_ON_CONFLICT;
             break;
     }
     $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule);
     $importParser->setFolderId($this->getUserOwnerId());
     $import_dir = $this->getImportDir();
     // Catch hack attempts
     // We check here again, if the role folders are in the tree, and if the
     // user has permission on the roles.
     if ($_POST["role_assign"]) {
         $global_roles = $rbacreview->getGlobalRoles();
         $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
         foreach ($_POST["role_assign"] as $role_id) {
             if ($role_id != "") {
                 if (in_array($role_id, $global_roles)) {
                     if (!in_array(SYSTEM_ROLE_ID, $roles_of_user)) {
                         if ($role_id == SYSTEM_ROLE_ID && !in_array(SYSTEM_ROLE_ID, $roles_of_user) || $this->object->getRefId() != USER_FOLDER_ID && !ilObjRole::_getAssignUsersStatus($role_id)) {
                             ilUtil::delDir($import_dir);
                             $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), $this->ilias->error_obj->MESSAGE);
                         }
                     }
                 } else {
                     $rolf = $rbacreview->getFoldersAssignedToRole($role_id, true);
                     if ($rbacreview->isDeleted($rolf[0]) || !$rbacsystem->checkAccess('write', $tree->getParentId($rolf[0]))) {
                         ilUtil::delDir($import_dir);
                         $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), $this->ilias->error_obj->MESSAGE);
                         return;
                     }
                 }
             }
         }
     }
     $importParser->setRoleAssignment($_POST["role_assign"]);
     $importParser->startParsing();
     // purge user import directory
     ilUtil::delDir($import_dir);
     switch ($importParser->getErrorLevel()) {
         case IL_IMPORT_SUCCESS:
             ilUtil::sendSuccess($this->lng->txt("user_imported"), true);
             break;
         case IL_IMPORT_WARNING:
             ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings") . $importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
             break;
         case IL_IMPORT_FAILURE:
             $this->ilias->raiseError($this->lng->txt("user_import_failed") . $importParser->getProtocolAsHTML($lng->txt("import_failure_log")), $this->ilias->error_obj->MESSAGE);
             break;
     }
     if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
         $this->ctrl->redirect($this, "view");
         //ilUtil::redirect($this->ctrl->getLinkTarget($this));
     } else {
         $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
     }
 }
 /**
  * creates a local role in current rolefolder (this object)
  * 
  * @access	public
  * @param	string	title
  * @param	string	description
  * @return	object	role object
  */
 function createRole($a_title, $a_desc, $a_import_id = 0)
 {
     global $rbacadmin, $rbacreview;
     include_once "./Services/AccessControl/classes/class.ilObjRole.php";
     $roleObj = new ilObjRole();
     $roleObj->setTitle($a_title);
     $roleObj->setDescription($a_desc);
     //echo "aaa-1-";
     if ($a_import_id != "") {
         //echo "aaa-2-".$a_import_id."-";
         $roleObj->setImportId($a_import_id);
     }
     $roleObj->create();
     // ...and put the role into local role folder...
     $rbacadmin->assignRoleToFolder($roleObj->getId(), $this->getRefId(), "y");
     return $roleObj;
 }
Ejemplo n.º 13
0
 protected function adoptPermObject()
 {
     global $rbacreview;
     $output = array();
     $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id, true);
     $ids = array();
     foreach ($parent_role_ids as $id => $tmp) {
         $ids[] = $id;
     }
     // Sort ids
     $sorted_ids = ilUtil::_sortIds($ids, 'object_data', 'type,title', 'obj_id');
     $key = 0;
     foreach ($sorted_ids as $id) {
         $par = $parent_role_ids[$id];
         if ($par["obj_id"] != SYSTEM_ROLE_ID && $this->object->getId() != $par["obj_id"]) {
             $radio = ilUtil::formRadioButton(0, "adopt", $par["obj_id"]);
             $output["adopt"][$key]["css_row_adopt"] = $key % 2 == 0 ? "tblrow1" : "tblrow2";
             $output["adopt"][$key]["check_adopt"] = $radio;
             $output["adopt"][$key]["role_id"] = $par["obj_id"];
             $output["adopt"][$key]["type"] = $par["type"] == 'role' ? $this->lng->txt('obj_role') : $this->lng->txt('obj_rolt');
             $output["adopt"][$key]["role_name"] = ilObjRole::_getTranslation($par["title"]);
             $output["adopt"][$key]["role_desc"] = $par["desc"];
             $key++;
         }
     }
     $output["formaction_adopt"] = $this->ctrl->getFormAction($this);
     $output["message_middle"] = $this->lng->txt("adopt_perm_from_template");
     $tpl = new ilTemplate("tpl.adm_copy_role.html", true, true, "Services/AccessControl");
     $tpl->setCurrentBlock("ADOPT_PERM_ROW");
     foreach ($output["adopt"] as $key => $value) {
         $tpl->setVariable("CSS_ROW_ADOPT", $value["css_row_adopt"]);
         $tpl->setVariable("CHECK_ADOPT", $value["check_adopt"]);
         $tpl->setVariable("LABEL_ID", $value["role_id"]);
         $tpl->setVariable("TYPE", $value["type"]);
         $tpl->setVariable("ROLE_NAME", $value["role_name"]);
         if (strlen($value['role_desc'])) {
             $tpl->setVariable('ROLE_DESC', $value['role_desc']);
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("TPLPATH", $this->tpl->tplPath);
     $tpl->setVariable("MESSAGE_MIDDLE", $output["message_middle"]);
     $tpl->setVariable("FORMACTION_ADOPT", $output["formaction_adopt"]);
     $tpl->setVariable("ADOPT", $this->lng->txt('copy'));
     $tpl->setVariable("CANCEL", $this->lng->txt('cancel'));
     $tpl->setVariable('HEAD_ROLE', $this->lng->txt('title'));
     $tpl->setVariable('HEAD_TYPE', $this->lng->txt('type'));
     $this->tpl->setContent($tpl->get());
 }
 /**
  * Create (linked) title
  * @param array $role
  * @return 
  */
 protected function createTitle($role)
 {
     global $ilCtrl;
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role['title'] = ilObjRole::_getTranslation($role['title']);
     // No local policies
     if ($role['parent'] != $this->getRefId()) {
         return $role['title'];
     }
     $ilCtrl->setParameterByClass('ilobjrolegui', 'obj_id', $role['obj_id']);
     return '<a class="tblheader" href="' . $ilCtrl->getLinkTargetByClass('ilobjrolegui', '') . '" >' . $role['title'] . '</a>';
 }
 /**
  * display permissions
  * 
  * @access	public
  */
 function permObject()
 {
     global $rbacadmin, $rbacreview, $rbacsystem, $objDefinition;
     if (!$rbacsystem->checkAccess('write', $this->rolf_ref_id)) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_perm"), $this->ilias->error_obj->WARNING);
         exit;
     }
     $to_filter = $objDefinition->getSubobjectsToFilter();
     $tpl_filter = array();
     $internal_tpl = false;
     if ($internal_tpl = $this->object->isInternalTemplate()) {
         $tpl_filter = $this->object->getFilterOfInternalTemplate();
     }
     $operation_info = $rbacreview->getOperationAssignment();
     foreach ($operation_info as $info) {
         if ($objDefinition->getDevMode($info['type'])) {
             continue;
         }
         // FILTER SUBOJECTS OF adm OBJECT
         if (in_array($info['type'], $to_filter)) {
             continue;
         }
         if ($internal_tpl and $tpl_filter and !in_array($info['type'], $tpl_filter)) {
             continue;
         }
         $rbac_objects[$info['typ_id']] = array("obj_id" => $info['typ_id'], "type" => $info['type']);
         $txt = $objDefinition->isPlugin($info['type']) ? ilPlugin::lookupTxt("rep_robj", $info['type'], $info['type'] . "_" . $info['operation']) : $this->lng->txt($info['type'] . "_" . $info['operation']);
         if (substr($info['operation'], 0, 7) == "create_" && $objDefinition->isPlugin(substr($info['operation'], 7))) {
             $txt = ilPlugin::lookupTxt("rep_robj", substr($info['operation'], 7), $info['type'] . "_" . $info['operation']);
         } elseif (substr($info['operation'], 0, 6) == 'create') {
             $txt = $this->lng->txt('rbac_' . $info['operation']);
         }
         $rbac_operations[$info['typ_id']][$info['ops_id']] = array("ops_id" => $info['ops_id'], "title" => $info['operation'], "name" => $txt);
     }
     foreach ($rbac_objects as $key => $obj_data) {
         if ($objDefinition->isPlugin($obj_data["type"])) {
             $rbac_objects[$key]["name"] = ilPlugin::lookupTxt("rep_robj", $obj_data["type"], "obj_" . $obj_data["type"]);
         } else {
             $rbac_objects[$key]["name"] = $this->lng->txt("obj_" . $obj_data["type"]);
         }
         $rbac_objects[$key]["ops"] = $rbac_operations[$key];
     }
     sort($rbac_objects);
     foreach ($rbac_objects as $key => $obj_data) {
         sort($rbac_objects[$key]["ops"]);
     }
     // sort by (translated) name of object type
     $rbac_objects = ilUtil::sortArray($rbac_objects, "name", "asc");
     // BEGIN CHECK_PERM
     foreach ($rbac_objects as $key => $obj_data) {
         $arr_selected = $rbacreview->getOperationsOfRole($this->object->getId(), $obj_data["type"], $this->rolf_ref_id);
         $arr_checked = array_intersect($arr_selected, array_keys($rbac_operations[$obj_data["obj_id"]]));
         foreach ($rbac_operations[$obj_data["obj_id"]] as $operation) {
             $checked = in_array($operation["ops_id"], $arr_checked);
             $disabled = false;
             // Es wird eine 2-dim Post Variable �bergeben: perm[rol_id][ops_id]
             $box = ilUtil::formCheckBox($checked, "template_perm[" . $obj_data["type"] . "][]", $operation["ops_id"], $disabled);
             $output["perm"][$obj_data["obj_id"]][$operation["ops_id"]] = $box;
         }
     }
     // END CHECK_PERM
     $output["col_anz"] = count($rbac_objects);
     $output["txt_save"] = $this->lng->txt("save");
     $output["check_protected"] = ilUtil::formCheckBox($rbacreview->isProtected($this->rolf_ref_id, $this->object->getId()), "protected", 1);
     $output["text_protected"] = $this->lng->txt("role_protect_permissions");
     /************************************/
     /*		adopt permissions form		*/
     /************************************/
     $output["message_middle"] = $this->lng->txt("adopt_perm_from_template");
     // send message for system role
     if ($this->object->getId() == SYSTEM_ROLE_ID) {
         $output["adopt"] = array();
         ilUtil::sendFailure($this->lng->txt("msg_sysrole_not_editable"));
     } else {
         // BEGIN ADOPT_PERMISSIONS
         $parent_role_ids = $rbacreview->getParentRoleIds($this->rolf_ref_id, true);
         // sort output for correct color changing
         ksort($parent_role_ids);
         foreach ($parent_role_ids as $key => $par) {
             if ($par["obj_id"] != SYSTEM_ROLE_ID) {
                 $radio = ilUtil::formRadioButton(0, "adopt", $par["obj_id"]);
                 $output["adopt"][$key]["css_row_adopt"] = ilUtil::switchColor($key, "tblrow1", "tblrow2");
                 $output["adopt"][$key]["check_adopt"] = $radio;
                 $output["adopt"][$key]["type"] = $par["type"] == 'role' ? 'Role' : 'Template';
                 $output["adopt"][$key]["role_name"] = $par["title"];
             }
         }
         $output["formaction_adopt"] = $this->ctrl->getFormAction($this);
         // END ADOPT_PERMISSIONS
     }
     $output["formaction"] = $this->ctrl->getFormAction($this);
     $this->data = $output;
     /************************************/
     /*			generate output			*/
     /************************************/
     $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
     $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.adm_perm_role.html", "Services/AccessControl");
     foreach ($rbac_objects as $obj_data) {
         // BEGIN object_operations
         $this->tpl->setCurrentBlock("object_operations");
         foreach ($obj_data["ops"] as $operation) {
             $ops_ids[] = $operation["ops_id"];
             $css_row = ilUtil::switchColor($key, "tblrow1", "tblrow2");
             $this->tpl->setVariable("CSS_ROW", $css_row);
             $this->tpl->setVariable("PERMISSION", $operation["name"]);
             $this->tpl->setVariable("CHECK_PERMISSION", $this->data["perm"][$obj_data["obj_id"]][$operation["ops_id"]]);
             $this->tpl->parseCurrentBlock();
         }
         // END object_operations
         // BEGIN object_type
         $this->tpl->setCurrentBlock("object_type");
         $this->tpl->setVariable("TXT_OBJ_TYPE", $obj_data["name"]);
         // TODO: move this if in a function and query all objects that may be disabled or inactive
         if ($this->objDefinition->getDevMode($obj_data["type"])) {
             $this->tpl->setVariable("TXT_NOT_IMPL", "(" . $this->lng->txt("not_implemented_yet") . ")");
         } else {
             if ($obj_data["type"] == "icrs" and !$this->ilias->getSetting("ilinc_active")) {
                 $this->tpl->setVariable("TXT_NOT_IMPL", "(" . $this->lng->txt("not_enabled_or_configured") . ")");
             }
         }
         // js checkbox toggles
         $this->tpl->setVariable("JS_VARNAME", "template_perm_" . $obj_data["type"]);
         $this->tpl->setVariable("JS_ONCLICK", ilUtil::array_php2js($ops_ids));
         $this->tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
         $this->tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
         $this->tpl->parseCurrentBlock();
         // END object_type
     }
     /* 
     // BEGIN ADOPT PERMISSIONS
     foreach ($this->data["adopt"] as $key => $value)
     {			
     	$this->tpl->setCurrentBlock("ADOPT_PERM_ROW");
     	$this->tpl->setVariable("CSS_ROW_ADOPT",$value["css_row_adopt"]);
     	$this->tpl->setVariable("CHECK_ADOPT",$value["check_adopt"]);
     	$this->tpl->setVariable("TYPE",$value["type"]);
     	$this->tpl->setVariable("ROLE_NAME",$value["role_name"]);
     	$this->tpl->parseCurrentBlock();
     }
     
     $this->tpl->setCurrentBlock("ADOPT_PERM_FORM");
     $this->tpl->setVariable("MESSAGE_MIDDLE",$this->data["message_middle"]);
     $this->tpl->setVariable("FORMACTION_ADOPT",$this->data["formaction_adopt"]);
     $this->tpl->setVariable("ADOPT",$this->lng->txt('copy'));
     $this->tpl->parseCurrentBlock();
     // END ADOPT PERMISSIONS 		
     */
     $this->tpl->setCurrentBlock("tblfooter_protected");
     $this->tpl->setVariable("COL_ANZ", 3);
     $this->tpl->setVariable("CHECK_BOTTOM", $this->data["check_protected"]);
     $this->tpl->setVariable("MESSAGE_TABLE", $this->data["text_protected"]);
     $this->tpl->parseCurrentBlock();
     $this->tpl->setVariable("COL_ANZ_PLUS", 4);
     $this->tpl->setVariable("TXT_SAVE", $this->data["txt_save"]);
     $this->tpl->setCurrentBlock("adm_content");
     $this->tpl->setVariable("TBL_TITLE_IMG", ilUtil::getImagePath("icon_" . $this->object->getType() . ".png"));
     $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->lng->txt($this->object->getType()));
     $this->tpl->setVariable("TBL_HELP_IMG", ilUtil::getImagePath("icon_help.png"));
     $this->tpl->setVariable("TBL_HELP_LINK", "tbl_help.php");
     $this->tpl->setVariable("TBL_HELP_IMG_ALT", $this->lng->txt("help"));
     // compute additional information in title
     if (substr($this->object->getTitle(), 0, 3) == "il_") {
         $desc = $this->lng->txt("predefined_template");
         //$this->lng->txt("obj_".$parent_node['type'])." (".$parent_node['obj_id'].") : ".$parent_node['title'];
     }
     $description = "<br/>&nbsp;<span class=\"small\">" . $desc . "</span>";
     // translation for autogenerated roles
     if (substr($this->object->getTitle(), 0, 3) == "il_") {
         include_once './Services/AccessControl/classes/class.ilObjRole.php';
         $title = ilObjRole::_getTranslation($this->object->getTitle()) . " (" . $this->object->getTitle() . ")";
     } else {
         $title = $this->object->getTitle();
     }
     $this->tpl->setVariable("TBL_TITLE", $title . $description);
     $this->tpl->setVariable("TXT_PERMISSION", $this->data["txt_permission"]);
     $this->tpl->setVariable("FORMACTION", $this->data["formaction"]);
     $this->tpl->parseCurrentBlock();
 }
Ejemplo n.º 16
0
 /**
  * Get formatted mail body text of user profile data.
  *
  * @param	object	  Language object (choose user language of recipient) or null to use language of current user
  */
 function getProfileAsString(&$a_language)
 {
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     include_once './Services/Utilities/classes/class.ilFormat.php';
     global $lng, $rbacreview;
     $language =& $a_language;
     $language->loadLanguageModule('registration');
     $language->loadLanguageModule('crs');
     $body = '';
     $body .= $language->txt("login") . ": " . $this->getLogin() . "\n";
     if (strlen($this->getUTitle())) {
         $body .= $language->txt("title") . ": " . $this->getUTitle() . "\n";
     }
     if (strlen($this->getGender())) {
         $gender = $this->getGender() == 'm' ? $language->txt('gender_m') : $language->txt('gender_f');
         $body .= $language->txt("gender") . ": " . $gender . "\n";
     }
     if (strlen($this->getFirstname())) {
         $body .= $language->txt("firstname") . ": " . $this->getFirstname() . "\n";
     }
     if (strlen($this->getLastname())) {
         $body .= $language->txt("lastname") . ": " . $this->getLastname() . "\n";
     }
     if (strlen($this->getInstitution())) {
         $body .= $language->txt("institution") . ": " . $this->getInstitution() . "\n";
     }
     if (strlen($this->getDepartment())) {
         $body .= $language->txt("department") . ": " . $this->getDepartment() . "\n";
     }
     if (strlen($this->getStreet())) {
         $body .= $language->txt("street") . ": " . $this->getStreet() . "\n";
     }
     if (strlen($this->getCity())) {
         $body .= $language->txt("city") . ": " . $this->getCity() . "\n";
     }
     if (strlen($this->getZipcode())) {
         $body .= $language->txt("zipcode") . ": " . $this->getZipcode() . "\n";
     }
     if (strlen($this->getCountry())) {
         $body .= $language->txt("country") . ": " . $this->getCountry() . "\n";
     }
     if (strlen($this->getSelectedCountry())) {
         $body .= $language->txt("sel_country") . ": " . $this->getSelectedCountry() . "\n";
     }
     if (strlen($this->getPhoneOffice())) {
         $body .= $language->txt("phone_office") . ": " . $this->getPhoneOffice() . "\n";
     }
     if (strlen($this->getPhoneHome())) {
         $body .= $language->txt("phone_home") . ": " . $this->getPhoneHome() . "\n";
     }
     if (strlen($this->getPhoneMobile())) {
         $body .= $language->txt("phone_mobile") . ": " . $this->getPhoneMobile() . "\n";
     }
     if (strlen($this->getFax())) {
         $body .= $language->txt("fax") . ": " . $this->getFax() . "\n";
     }
     if (strlen($this->getEmail())) {
         $body .= $language->txt("email") . ": " . $this->getEmail() . "\n";
     }
     if (strlen($this->getHobby())) {
         $body .= $language->txt("hobby") . ": " . $this->getHobby() . "\n";
     }
     if (strlen($this->getComment())) {
         $body .= $language->txt("referral_comment") . ": " . $this->getComment() . "\n";
     }
     if (strlen($this->getMatriculation())) {
         $body .= $language->txt("matriculation") . ": " . $this->getMatriculation() . "\n";
     }
     if (strlen($this->getCreateDate())) {
         ilDatePresentation::setUseRelativeDates(false);
         ilDatePresentation::setLanguage($language);
         $date = ilDatePresentation::formatDate(new ilDateTime($this->getCreateDate(), IL_CAL_DATETIME));
         ilDatePresentation::resetToDefaults();
         $body .= $language->txt("create_date") . ": " . $date . "\n";
     }
     foreach ($rbacreview->getGlobalRoles() as $role) {
         if ($rbacreview->isAssigned($this->getId(), $role)) {
             $gr[] = ilObjRole::_lookupTitle($role);
         }
     }
     if (count($gr)) {
         $body .= $language->txt('reg_role_info') . ': ' . implode(',', $gr) . "\n";
     }
     // Time limit
     if ($this->getTimeLimitUnlimited()) {
         $body .= $language->txt('time_limit') . ": " . $language->txt('crs_unlimited') . "\n";
     } else {
         ilDatePresentation::setUseRelativeDates(false);
         ilDatePresentation::setLanguage($language);
         $period = ilDatePresentation::formatPeriod(new ilDateTime($this->getTimeLimitFrom(), IL_CAL_UNIX), new ilDateTime($this->getTimeLimitUntil(), IL_CAL_UNIX));
         ilDatePresentation::resetToDefaults();
         $start = new ilDateTime($this->getTimeLimitFrom(), IL_CAL_UNIX);
         $end = new ilDateTime($this->getTimeLimitUntil(), IL_CAL_UNIX);
         $body .= $language->txt('time_limit') . ': ' . $start->get(IL_CAL_DATETIME);
         $body .= $language->txt('time_limit') . ': ' . $end->get(IL_CAL_DATETIME);
         #$body .= $language->txt('time_limit').': '.$period;
         /*
         $body .= ($language->txt('time_limit').": ".$language->txt('crs_from')." ".
         		  ilFormat::formatUnixTime($this->getTimeLimitFrom(), true)." ".
         		  $language->txt('crs_to')." ".
         		  ilFormat::formatUnixTime($this->getTimeLimitUntil(), true)."\n");
         */
     }
     return $body;
 }
Ejemplo n.º 17
0
 /**
  * return translated title for autogenerated roles
  * @return 
  */
 public function getPresentationTitle()
 {
     return ilObjRole::_getTranslation($this->getTitle());
 }
Ejemplo n.º 18
0
 /**
  * Shoew add role
  * @global type $rbacreview
  * @global type $objDefinition
  * @return ilPropertyFormGUI 
  */
 protected function initRoleForm()
 {
     global $rbacreview, $objDefinition;
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt('role_new'));
     $form->addCommandButton('addrole', $this->lng->txt('role_new'));
     $form->addCommandButton('perm', $this->lng->txt('cancel'));
     $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
     $title->setValidationRegexp('/^(?!il_).*$/');
     $title->setValidationFailureMessage($this->lng->txt('msg_role_reserved_prefix'));
     $title->setSize(40);
     $title->setMaxLength(70);
     $title->setRequired(true);
     $form->addItem($title);
     $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
     $desc->setCols(40);
     $desc->setRows(3);
     $form->addItem($desc);
     $pro = new ilCheckboxInputGUI($this->lng->txt('role_protect_permissions'), 'pro');
     $pro->setInfo($this->lng->txt('role_protect_permissions_desc'));
     $pro->setValue(1);
     $form->addItem($pro);
     $pd = new ilCheckboxInputGUI($this->lng->txt('rbac_role_add_to_desktop'), 'desktop');
     $pd->setInfo($this->lng->txt('rbac_role_add_to_desktop_info'));
     $pd->setValue(1);
     $form->addItem($pd);
     if (!$this->isInAdministration()) {
         $rights = new ilRadioGroupInputGUI($this->lng->txt("rbac_role_rights_copy"), 'rights');
         $option = new ilRadioOption($this->lng->txt("rbac_role_rights_copy_empty"), 0);
         $rights->addOption($option);
         $parent_role_ids = $rbacreview->getParentRoleIds($this->gui_obj->object->getRefId(), true);
         $ids = array();
         foreach ($parent_role_ids as $id => $tmp) {
             $ids[] = $id;
         }
         // Sort ids
         $sorted_ids = ilUtil::_sortIds($ids, 'object_data', 'type DESC,title', 'obj_id');
         // Sort roles by title
         $sorted_roles = ilUtil::sortArray(array_values($parent_role_ids), 'title', ASC);
         $key = 0;
         foreach ($sorted_ids as $id) {
             $par = $parent_role_ids[$id];
             if ($par["obj_id"] != SYSTEM_ROLE_ID) {
                 include_once './Services/AccessControl/classes/class.ilObjRole.php';
                 $option = new ilRadioOption(($par["type"] == 'role' ? $this->lng->txt('obj_role') : $this->lng->txt('obj_rolt')) . ": " . ilObjRole::_getTranslation($par["title"]), $par["obj_id"]);
                 $option->setInfo($par["desc"]);
                 $rights->addOption($option);
             }
             $key++;
         }
         $form->addItem($rights);
     }
     // Local policy only for containers
     if ($objDefinition->isContainer($this->getCurrentObject()->getType())) {
         $check = new ilCheckboxInputGui($this->lng->txt("rbac_role_rights_copy_change_existing"), 'existing');
         $check->setInfo($this->lng->txt('rbac_change_existing_objects_desc_new_role'));
         $form->addItem($check);
     }
     return $form;
 }
 public function saveForm()
 {
     global $lng, $ilSetting;
     $this->__initForm();
     $form_valid = $this->form->checkInput();
     require_once 'Services/User/classes/class.ilObjUser.php';
     // custom validation
     // validate email against restricted domains
     $email = $this->form->getInput("usr_email");
     if ($email) {
         // #10366
         $domains = array();
         foreach ($this->registration_settings->getAllowedDomains() as $item) {
             if (trim($item)) {
                 $domains[] = $item;
             }
         }
         if (sizeof($domains)) {
             $mail_valid = false;
             foreach ($domains as $domain) {
                 $domain = str_replace("*", "~~~", $domain);
                 $domain = preg_quote($domain);
                 $domain = str_replace("~~~", ".+", $domain);
                 if (preg_match("/^" . $domain . "\$/", $email, $hit)) {
                     $mail_valid = true;
                     break;
                 }
             }
             if (!$mail_valid) {
                 $mail_obj = $this->form->getItemByPostVar('usr_email');
                 $mail_obj->setAlert(sprintf($lng->txt("reg_email_domains"), implode(", ", $domains)));
                 $form_valid = false;
             }
         }
     }
     if (!$this->form->getInput("usr_agreement")) {
         $agr_obj = $this->form->getItemByPostVar('usr_agreement');
         $agr_obj->setAlert($lng->txt("force_accept_usr_agreement"));
         $form_valid = false;
     }
     $valid_role = false;
     // code
     if ($this->code_enabled) {
         $code = $this->form->getInput('usr_registration_code');
         // could be optional
         if ($code) {
             // code validation
             include_once './Services/Registration/classes/class.ilRegistrationCode.php';
             if (!ilRegistrationCode::isUnusedCode($code)) {
                 $code_obj = $this->form->getItemByPostVar('usr_registration_code');
                 $code_obj->setAlert($lng->txt('registration_code_not_valid'));
                 $form_valid = false;
             } else {
                 // get role from valid code
                 $valid_role = (int) ilRegistrationCode::getCodeRole($code);
             }
         }
     }
     // no need if role is attached to code
     if (!$valid_role) {
         // manual selection
         if ($this->registration_settings->roleSelectionEnabled()) {
             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
             $selected_role = $this->form->getInput("usr_roles");
             if ($selected_role && ilObjRole::_lookupAllowRegister($selected_role)) {
                 $valid_role = (int) $selected_role;
             }
         } else {
             include_once 'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
             $registration_role_assignments = new ilRegistrationRoleAssignments();
             $valid_role = (int) $registration_role_assignments->getRoleByEmail($this->form->getInput("usr_email"));
         }
     }
     // no valid role could be determined
     if (!$valid_role) {
         ilUtil::sendInfo($lng->txt("registration_no_valid_role"));
         $form_valid = false;
     }
     // validate username
     $login_obj = $this->form->getItemByPostVar('username');
     $login = $this->form->getInput("username");
     if (!ilUtil::isLogin($login)) {
         $login_obj->setAlert($lng->txt("login_invalid"));
         $form_valid = false;
     } else {
         if (ilObjUser::_loginExists($login)) {
             $login_obj->setAlert($lng->txt("login_exists"));
             $form_valid = false;
         } else {
             if ((int) $ilSetting->get('allow_change_loginname') && (int) $ilSetting->get('reuse_of_loginnames') == 0 && ilObjUser::_doesLoginnameExistInHistory($login)) {
                 $login_obj->setAlert($lng->txt('login_exists'));
                 $form_valid = false;
             }
         }
     }
     if (!$form_valid) {
         ilUtil::sendFailure($lng->txt('form_input_not_valid'));
     } else {
         $password = $this->__createUser($valid_role);
         $this->__distributeMails($password, $this->form->getInput("usr_language"));
         $this->login($password);
         return true;
     }
     $this->form->setValuesByPost();
     $this->displayForm();
     return false;
 }
Ejemplo n.º 20
0
 /**
  * Read settings
  *
  * @access private
  * 
  */
 private function read()
 {
     $all_settings = $this->settings->getAll();
     $sets = array("radius_active" => "setActive", "radius_port" => "setPort", "radius_shared_secret" => "setSecret", "radius_name" => "setName", "radius_creation" => "enableCreation", "radius_migration" => "enableAccountMigration", "radius_charset" => "setCharset");
     foreach ($sets as $s => $m) {
         if (isset($all_settings[$s])) {
             $this->{$m}($all_settings[$s]);
         }
     }
     reset($all_settings);
     foreach ($all_settings as $k => $v) {
         if (substr($k, 0, 13) == "radius_server") {
             $this->servers[] = $v;
         }
     }
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $roles = ilObjRole::_getRolesByAuthMode('radius');
     $this->default_role = 0;
     if (isset($roles[0]) && $roles[0]) {
         $this->default_role = $roles[0];
     }
 }
Ejemplo n.º 21
0
 function getRolesWithContribute($a_node_id)
 {
     global $rbacreview;
     include_once "Services/AccessControl/classes/class.ilObjRole.php";
     $contr_op_id = ilRbacReview::_getOperationIdByName("contribute");
     $contr_role_id = $this->getLocalContributorRole($a_node_id);
     $res = array();
     foreach ($rbacreview->getParentRoleIds($a_node_id) as $role_id => $role) {
         if ($role_id != $contr_role_id && in_array($contr_op_id, $rbacreview->getActiveOperationsOfRole($a_node_id, $role_id))) {
             $res[$role_id] = ilObjRole::_getTranslation($role["title"]);
         }
     }
     return $res;
 }
Ejemplo n.º 22
0
 /**
  * get only 'global' roles (with flag 'assign_users')
  * @access	public
  * @return	array		Array with rol_ids
  * @todo refactor rolf => DONE
  */
 public function getGlobalAssignableRoles()
 {
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     foreach ($this->getGlobalRoles() as $role_id) {
         if (ilObjRole::_getAssignUsersStatus($role_id)) {
             $ga[] = array('obj_id' => $role_id, 'role_type' => 'global');
         }
     }
     return $ga ? $ga : array();
 }
Ejemplo n.º 23
0
 function updateAuthRolesObject()
 {
     global $rbacsystem;
     if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
         $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
     }
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     ilObjRole::_updateAuthMode($_POST['Fobject']);
     ilUtil::sendSuccess($this->lng->txt("auth_mode_roles_changed"), true);
     $this->ctrl->redirect($this, 'authSettings');
 }
Ejemplo n.º 24
0
 public static function _createRandomUserAccount($keyarray)
 {
     global $ilDB, $ilUser, $ilSetting, $rbacadmin;
     if ($_SESSION['create_user_account'] != NULL) {
         $obj_user = new ilObjUser($_SESSION['create_user_account']);
         return $obj_user;
     } else {
         $userLogin = array();
         $res = $ilDB->query('SELECT sequence FROM object_data_seq');
         $row = $ilDB->fetchAssoc($res);
         $temp_user_id = (int) $row['sequence'] + 1;
         $userLogin['login'] = '******' . $temp_user_id;
         $userLogin['passwd'] = ilUtil::generatePasswords(1);
         require_once 'Services/User/classes/class.ilObjUser.php';
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         $obj_user = new ilObjUser();
         $obj_user->setId($temp_user_id);
         $obj_user->setLogin($userLogin['login']);
         $obj_user->setPasswd((string) $userLogin['passwd'][0], IL_PASSWD_PLAIN);
         $_SESSION['tmp_user_account']['login'] = $userLogin['login'];
         $_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
         $obj_user->setFirstname($keyarray['first_name']);
         $obj_user->setLastname($keyarray['last_name']);
         $obj_user->setEmail($keyarray['payer_email']);
         #	$obj_user->setEmail('*****@*****.**');
         $obj_user->setGender('f');
         $obj_user->setLanguage($ilSetting->get("language"));
         $obj_user->setActive(true);
         $obj_user->setTimeLimitUnlimited(true);
         $obj_user->setTitle($obj_user->getFullname());
         $obj_user->setDescription($obj_user->getEmail());
         $obj_user->setTimeLimitOwner(7);
         $obj_user->setTimeLimitUnlimited(1);
         $obj_user->setTimeLimitMessage(0);
         $obj_user->setApproveDate(date("Y-m-d H:i:s"));
         // Set default prefs
         $obj_user->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
         $obj_user->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
         $obj_user->writePrefs();
         // at the first login the user must complete profile
         $obj_user->setProfileIncomplete(true);
         $obj_user->create();
         $obj_user->saveAsNew();
         $user_role = ilObject::_exists(4, false);
         if (!$user_role) {
             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
             $reg_allowed = ilObjRole::_lookupRegisterAllowed();
             $user_role = $reg_allowed[0]['id'];
         } else {
             $user_role = 4;
         }
         $rbacadmin->assignUser((int) $user_role, $obj_user->getId(), true);
         include_once "Services/Mail/classes/class.ilMimeMail.php";
         global $ilias, $lng;
         $settings = $ilias->getAllSettings();
         $mmail = new ilMimeMail();
         $mmail->autoCheck(false);
         $mmail->From($settings["admin_email"]);
         $mmail->To($obj_user->getEmail());
         // mail subject
         $subject = $lng->txt("reg_mail_subject");
         // mail body
         $body = $lng->txt("reg_mail_body_salutation") . " " . $obj_user->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n";
         $body .= $lng->txt("login") . ": " . $obj_user->getLogin() . "\n";
         $body .= $lng->txt("passwd") . ": " . $userLogin['passwd'][0] . "\n";
         $body .= "\n";
         $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
         $body .= $obj_user->getProfileAsString($lng);
         $mmail->Subject($subject);
         $mmail->Body($body);
         $mmail->Send();
         $_SESSION['create_user_account'] = $obj_user->getId();
         return $obj_user;
     }
 }
 public function mailMembersObject()
 {
     global $rbacreview, $ilObjDataCache;
     include_once 'Services/AccessControl/classes/class.ilObjRole.php';
     $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_members.html', 'Services/Contact');
     $this->__setSubTabs('members');
     include_once "./Services/Link/classes/class.ilLink.php";
     $link_to_seminar = ilLink::_getLink($this->object->getRefId());
     include_once 'Services/Mail/classes/class.ilMail.php';
     require_once 'Services/Mail/classes/class.ilMailFormCall.php';
     $this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'mailMembers', array(), array('type' => 'role')));
     $this->tpl->setVariable('ADDITIONAL_MESSAGE_TEXT', $link_to_seminar);
     $this->tpl->setVariable('IMG_ARROW', ilUtil::getImagePath('arrow_downright.png'));
     $this->tpl->setVariable('OK', $this->lng->txt('ok'));
     $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
     $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
     foreach ($role_ids as $role_id) {
         $this->tpl->setCurrentBlock('mailbox_row');
         $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
         $this->tpl->setVariable('CHECK_MAILBOX', ilUtil::formCheckbox(1, 'roles[]', htmlspecialchars($role_addr)));
         if (ilMail::_usePearMail()) {
             // if pear mail is enabled, mailbox addresses are already localized in the language of the user
             $this->tpl->setVariable('MAILBOX', $role_addr);
         } else {
             // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
             $this->tpl->setVariable('MAILBOX', ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . ' (' . $role_addr . ')');
         }
         $this->tpl->parseCurrentBlock();
     }
 }
Ejemplo n.º 26
0
 public function initDefaultRoles()
 {
     global $rbacadmin, $rbacreview, $ilAppEventHandler;
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role = new ilObjRole();
     $role->setTitle("il_orgu_employee_" . $this->getRefId());
     $role->setDescription("Emplyee of org unit obj_no." . $this->getId());
     $role->create();
     $GLOBALS['rbacadmin']->assignRoleToFolder($role->getId(), $this->getRefId(), 'y');
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role_sup = ilObjRole::createDefaultRole('il_orgu_superior_' . $this->getRefId(), "Superior of org unit obj_no." . $this->getId(), 'il_orgu_superior', $this->getRefId());
     $ilAppEventHandler->raise('Modules/OrgUnit', 'initDefaultRoles', array('object' => $this, 'obj_id' => $this->getId(), 'ref_id' => $this->getRefId(), 'role_superior_id' => $role->getId(), 'role_employee_id' => $role_sup->getId()));
 }
Ejemplo n.º 27
0
 /**
  * Copy local roles
  * This method creates a copy of all local role.
  * Note: auto generated roles are excluded
  *
  * @access public
  * @param int source id of object (not role folder)
  * @param int target id of object
  * 
  */
 public function copyLocalRoles($a_source_id, $a_target_id)
 {
     global $rbacreview, $ilLog, $ilObjDataCache;
     $real_local = array();
     foreach ($rbacreview->getRolesOfRoleFolder($a_source_id, false) as $role_data) {
         $title = $ilObjDataCache->lookupTitle($role_data);
         if (substr($title, 0, 3) == 'il_') {
             continue;
         }
         $real_local[] = $role_data;
     }
     if (!count($real_local)) {
         return true;
     }
     // Create role folder
     foreach ($real_local as $role) {
         include_once "./Services/AccessControl/classes/class.ilObjRole.php";
         $orig = new ilObjRole($role);
         $orig->read();
         $ilLog->write(__METHOD__ . ': Start copying of role ' . $orig->getTitle());
         $roleObj = new ilObjRole();
         $roleObj->setTitle($orig->getTitle());
         $roleObj->setDescription($orig->getDescription());
         $roleObj->setImportId($orig->getImportId());
         $roleObj->create();
         $this->assignRoleToFolder($roleObj->getId(), $a_target_id, "y");
         $this->copyRolePermissions($role, $a_source_id, $a_target_id, $roleObj->getId(), true);
         $ilLog->write(__METHOD__ . ': Added new local role, id ' . $roleObj->getId());
     }
 }
 /**
  * Delete local policy
  *
  * @param int $a_role_id
  * @param ilObject $source
  */
 protected function deleteLocalPolicy($a_role_id, $source)
 {
     global $rbacreview, $rbacadmin;
     // Create role folder if it does not exist
     //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
     if ($rbacreview->getRoleFolderOfRole($a_role_id) == $source->getRefId()) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
         return false;
     }
     $rbacadmin->deleteLocalRole($a_role_id, $source->getRefId());
     // Change existing object
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     $role = new ilObjRole($a_role_id);
     $role->changeExistingObjects($source->getRefId(), ilObjRole::MODE_UNPROTECTED_DELETE_LOCAL_POLICIES, array('all'));
     return true;
 }
Ejemplo n.º 29
0
 /**
  * get ALL local roles of course, also those created and defined afterwards
  * only fetch data once from database. info is stored in object variable
  * @access	public
  * @return	return array [title|id] of roles...
  */
 public function getLocalCourseRoles($a_translate = false)
 {
     global $rbacadmin, $rbacreview;
     if (empty($this->local_roles)) {
         $this->local_roles = array();
         $role_arr = $rbacreview->getRolesOfRoleFolder($this->getRefId());
         foreach ($role_arr as $role_id) {
             if ($rbacreview->isAssignable($role_id, $this->getRefId()) == true) {
                 $role_Obj = $this->ilias->obj_factory->getInstanceByObjId($role_id);
                 if ($a_translate) {
                     $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
                 } else {
                     $role_name = $role_Obj->getTitle();
                 }
                 $this->local_roles[$role_name] = $role_Obj->getId();
             }
         }
     }
     return $this->local_roles;
 }
Ejemplo n.º 30
0
 /**
  * Parse role list
  * @param array $role_list
  */
 public function parse($role_folder_id)
 {
     global $rbacreview, $ilUser;
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     if ($this->getType() == self::TYPE_VIEW) {
         $filter_orig = $filter = $this->getFilterItemByPostVar('role_title')->getValue();
         $type = $this->getFilterItemByPostVar('role_type')->getValue();
     } else {
         $filter_orig = $filter = $this->getRoleTitleFilter();
         $type = ilRbacReview::FILTER_ALL;
     }
     // the translation must be filtered
     if ($type == ilRbacReview::FILTER_INTERNAL or $type == ilRbacReview::FILTER_ALL) {
         // roles like il_crs_... are filtered manually
         $filter = '';
     }
     $role_list = $rbacreview->getRolesByFilter($type, 0, $filter);
     $counter = 0;
     $rows = array();
     foreach ((array) $role_list as $role) {
         if ($role['parent'] and $GLOBALS['tree']->isDeleted($role['parent'])) {
             continue;
         }
         $title = ilObjRole::_getTranslation($role['title']);
         if ($type == ilRbacReview::FILTER_INTERNAL or $type == ilRbacReview::FILTER_ALL) {
             if (strlen($filter_orig)) {
                 if (stristr($title, $filter_orig) == FALSE) {
                     continue;
                 }
             }
         }
         $rows[$counter]['title_orig'] = $role['title'];
         $rows[$counter]['title'] = $title;
         $rows[$counter]['description'] = $role['description'];
         $rows[$counter]['obj_id'] = $role['obj_id'];
         $rows[$counter]['parent'] = $role['parent'];
         $rows[$counter]['type'] = $role['type'];
         $auto = substr($role['title'], 0, 3) == 'il_' ? true : false;
         // Role templates
         if ($role['type'] == 'rolt') {
             $rows[$counter]['rtype'] = $auto ? self::TYPE_ROLT_AU : self::TYPE_ROLT_UD;
         } else {
             // Roles
             if ($role['parent'] == ROLE_FOLDER_ID) {
                 if ($role['obj_id'] == ANONYMOUS_ROLE_ID or $role['obj_id'] == SYSTEM_ROLE_ID) {
                     $rows[$counter]['rtype'] = self::TYPE_GLOBAL_AU;
                 } else {
                     $rows[$counter]['rtype'] = self::TYPE_GLOBAL_UD;
                 }
             } else {
                 $rows[$counter]['rtype'] = $auto ? self::TYPE_LOCAL_AU : self::TYPE_LOCAL_UD;
             }
         }
         ++$counter;
     }
     $this->setMaxCount(count($rows));
     $this->setData($rows);
 }