ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSoapRBACAdministration.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22  */
23 
24 
33 include_once './webservice/soap/classes/class.ilSoapAdministration.php';
34 
36 {
37 
38 
39  function deleteRole($sid,$role_id)
40  {
41  $this->initAuth($sid);
42  $this->initIlias();
43 
44  if(!$this->__checkSession($sid))
45  {
46  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
47  }
48 
49  global $rbacreview, $rbacsystem,$ilAccess;
50 
51  if(!$tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false) or $tmp_role->getType() != 'role')
52  {
53  return $this->__raiseError('No valid role id given. Please choose an existing id of an ILIAS role',
54  'Client');
55  }
56 
57 
58  $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
59  if(!$ilAccess->checkAccess('edit_permission','',$obj_ref))
60  {
61  return $this->__raiseError('Check access failed. No permission to delete role','Server');
62  }
63 
64  // if it's last role of an user
65  foreach($assigned_users = $rbacreview->assignedUsers($role_id) as $user_id)
66  {
67  if(count($rbacreview->assignedRoles($user_id)) == 1)
68  {
69  return $this->__raiseError('Cannot deassign last role of users',
70  'Client');
71  }
72  }
73 
74  // set parent id (role folder id) of role
75  $rolf_id = end($rolf_ids = $rbacreview->getFoldersAssignedToRole($role_id,true));
76  $tmp_role->setParent($rolf_id);
77  $tmp_role->delete();
78 
79  return true;
80  }
81 
82  function addUserRoleEntry($sid,$user_id,$role_id)
83  {
84  $this->initAuth($sid);
85  $this->initIlias();
86 
87  if(!$this->__checkSession($sid))
88  {
89  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
90  }
91 
92  global $rbacadmin,$rbacreview,$ilAccess;
93 
94  if($tmp_user =& ilObjectFactory::getInstanceByObjId($user_id) and $tmp_user->getType() != 'usr')
95  {
96  return $this->__raiseError('No valid user id given. Please choose an existing id of an ILIAS user',
97  'Client');
98  }
99  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id) and $tmp_role->getType() != 'role')
100  {
101  return $this->__raiseError('No valid role id given. Please choose an existing id of an ILIAS role',
102  'Client');
103  }
104 
105  $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
106  if(!$ilAccess->checkAccess('edit_permission','',$obj_ref))
107  {
108  return $this->__raiseError('Check access failed. No permission to assign users','Server');
109  }
110 
111  if(!$rbacadmin->assignUser($role_id,$user_id))
112  {
113  return $this->__raiseError('Error rbacadmin->assignUser()',
114  'Server');
115  }
116  return true;
117  }
118  function deleteUserRoleEntry($sid,$user_id,$role_id)
119  {
120  $this->initAuth($sid);
121  $this->initIlias();
122 
123  if(!$this->__checkSession($sid))
124  {
125  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
126  }
127 
128  global $rbacadmin,$ilAccess,$rbacreview;
129 
130  if($tmp_user =& ilObjectFactory::getInstanceByObjId($user_id,false) and $tmp_user->getType() != 'usr')
131  {
132  return $this->__raiseError('No valid user id given. Please choose an existing id of an ILIAS user',
133  'Client');
134  }
135  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false) and $tmp_role->getType() != 'role')
136  {
137  return $this->__raiseError('No valid role id given. Please choose an existing id of an ILIAS role',
138  'Client');
139  }
140 
141  $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
142  if(!$ilAccess->checkAccess('edit_permission','',$obj_ref))
143  {
144  return $this->__raiseError('Check access failed. No permission to deassign users','Server');
145  }
146 
147  if(!$rbacadmin->deassignUser($role_id,$user_id))
148  {
149  return $this->__raiseError('Error rbacadmin->deassignUser()',
150  'Server');
151  }
152  return true;
153  }
154 
155  function getOperations($sid)
156  {
157  $this->initAuth($sid);
158  $this->initIlias();
159 
160  if(!$this->__checkSession($sid))
161  {
162  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
163  }
164 
165  global $rbacreview;
166 
167  if(is_array($ops = $rbacreview->getOperations()))
168  {
169  return $ops;
170  }
171  else
172  {
173  return $this->__raiseError('Unknown error','Server');
174  }
175  }
176 
177  function revokePermissions($sid,$ref_id,$role_id)
178  {
179  $this->initAuth($sid);
180  $this->initIlias();
181 
182  if(!$this->__checkSession($sid))
183  {
184  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
185  }
186 
187  global $rbacadmin,$ilAccess;
188 
189  if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
190  {
191  return $this->__raiseError('No valid ref id given. Please choose an existing reference id of an ILIAS object',
192  'Client');
193  }
194  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false) and $tmp_role->getType() != 'role')
195  {
196  return $this->__raiseError('No valid role id given. Please choose an existing id of an ILIAS role',
197  'Client');
198  }
199  if ($role_id == SYSTEM_ROLE_ID)
200  {
201  return $this->__raiseError('Cannot revoke permissions of system role',
202  'Client');
203  }
204 
205  if(!$ilAccess->checkAccess('edit_permission','',$ref_id))
206  {
207  return $this->__raiseError('Check access failed. No permission to revoke permissions','Server');
208  }
209 
210  $rbacadmin->revokePermission($ref_id,$role_id);
211 
212  return true;
213  }
214  function grantPermissions($sid,$ref_id,$role_id,$permissions)
215  {
216  $this->initAuth($sid);
217  $this->initIlias();
218 
219  if(!$this->__checkSession($sid))
220  {
221  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
222  }
223 
224  global $rbacadmin,$ilAccess;
225 
226  if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
227  {
228  return $this->__raiseError('No valid ref id given. Please choose an existing reference id of an ILIAS object',
229  'Client');
230  }
231  if($tmp_role =& ilObjectFactory::getInstanceByObjId($role_id,false) and $tmp_role->getType() != 'role')
232  {
233  return $this->__raiseError('No valid role id given. Please choose an existing id of an ILIAS role',
234  'Client');
235  }
236 
237  if(!$ilAccess->checkAccess('edit_permission','',$ref_id))
238  {
239  return $this->__raiseError('Check access failed. No permission to grant permissions','Server');
240  }
241 
242 
243  // mjansen@databay.de: dirty fix
244  if(isset($permissions['item']))
245  {
246  $permissions = $permissions['item'];
247  }
248 
249  if(!is_array($permissions))
250  {
251  return $this->__raiseError('No valid permissions given.'.print_r($permissions),
252  'Client');
253  }
254 
255  $rbacadmin->revokePermission($ref_id,$role_id);
256  $rbacadmin->grantPermission($role_id,$permissions,$ref_id);
257 
258  return true;
259  }
260 
261  function getLocalRoles($sid,$ref_id)
262  {
263  $this->initAuth($sid);
264  $this->initIlias();
265 
266  if(!$this->__checkSession($sid))
267  {
268  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
269  }
270 
271  global $rbacreview,$ilAccess;
272 
273  if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
274  {
275  return $this->__raiseError('No valid ref id given. Please choose an existing reference id of an ILIAS object',
276  'Client');
277  }
278 
279  if(!$ilAccess->checkAccess('edit_permission','',$ref_id))
280  {
281  return $this->__raiseError('Check access failed. No permission to access role information','Server');
282  }
283 
284 
285  foreach($rbacreview->getRolesOfRoleFolder($ref_id,false) as $role_id)
286  {
287  if($tmp_obj = ilObjectFactory::getInstanceByObjId($role_id,false))
288  {
289  $objs[] = $tmp_obj;
290  }
291  }
292  if(count($objs))
293  {
294  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
295 
296  $xml_writer = new ilObjectXMLWriter();
297  $xml_writer->setObjects($objs);
298  if($xml_writer->start())
299  {
300  return $xml_writer->getXML();
301  }
302  }
303  return '';
304  }
305 
306  function getUserRoles($sid,$user_id)
307  {
308  $this->initAuth($sid);
309  $this->initIlias();
310 
311  if(!$this->__checkSession($sid))
312  {
313  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
314  }
315 
316  global $rbacreview;
317 
318  if(!$tmp_user =& ilObjectFactory::getInstanceByObjId($user_id,false))
319  {
320  return $this->__raiseError('No valid user id given. Please choose an existing id of an ILIAS user',
321  'Client');
322  }
323 
324  foreach($rbacreview->assignedRoles($user_id) as $role_id)
325  {
326  if($tmp_obj = ilObjectFactory::getInstanceByObjId($role_id,false))
327  {
328  $objs[] = $tmp_obj;
329  }
330  }
331  if(count($objs))
332  {
333  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
334 
335  $xml_writer = new ilObjectXMLWriter();
336  $xml_writer->setObjects($objs);
337  if($xml_writer->start())
338  {
339  return $xml_writer->getXML();
340  }
341  }
342  return '';
343  }
344 
345  function addRole($sid,$target_id,$role_xml)
346  {
347  $this->initAuth($sid);
348  $this->initIlias();
349 
350  if(!$this->__checkSession($sid))
351  {
352  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
353  }
354 
355  global $rbacreview, $objDefinition, $rbacsystem,$ilAccess;
356 
357  if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($target_id,false))
358  {
359  return $this->__raiseError('No valid ref id given. Please choose an existing reference id of an ILIAS object',
360  'Client');
361  }
362 
364  {
365  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
366  }
367 
368  if(!$ilAccess->checkAccess('edit_permission','',$target_id))
369  {
370  return $this->__raiseError('Check access failed. No permission to create roles','Server');
371  }
372 
373  include_once 'webservice/soap/classes/class.ilObjectXMLParser.php';
374 
375  $xml_parser = new ilObjectXMLParser($role_xml);
376  $xml_parser->startParsing();
377 
378  foreach($xml_parser->getObjectData() as $object_data)
379  {
380 
381  // check if role title has il_ prefix
382  if(substr($object_data['title'],0,3) == "il_")
383  {
384  return $this->__raiseError('Rolenames are not allowed to start with "il_" ',
385  'Client');
386  }
387 
388  include_once './Services/AccessControl/classes/class.ilObjRole.php';
389  $role = new ilObjRole();
390  $role->setTitle($object_data['title']);
391  $role->setDescription($object_data['description']);
392  $role->setImportId($object_data['import_id']);
393  $role->create();
394 
395  $GLOBALS['rbacadmin']->assignRoleToFolder($role->getId(),$target_id);
396  $new_roles[] = $role->getId();
397  }
398 
399  return $new_roles ? $new_roles : array();
400  }
401 
402  function addRoleFromTemplate($sid,$target_id,$role_xml,$template_id)
403  {
404  $this->initAuth($sid);
405  $this->initIlias();
406 
407  if(!$this->__checkSession($sid))
408  {
409  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
410  }
411 
412  global $rbacreview, $objDefinition, $rbacsystem, $rbacadmin,$ilAccess;
413 
414  if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($target_id,false))
415  {
416  return $this->__raiseError('No valid ref id given. Please choose an existing reference id of an ILIAS object',
417  'Client');
418  }
419  if(ilObject::_lookupType($template_id) != 'rolt')
420  {
421  return $this->__raiseError('No valid template id given. Please choose an existing object id of an ILIAS role template',
422  'Client');
423  }
424 
425 
427  {
428  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
429  }
430 
431  if(!$ilAccess->checkAccess('edit_permission','',$target_id))
432  {
433  return $this->__raiseError('Check access failed. No permission to create roles','Server');
434  }
435 
436 
437  include_once 'webservice/soap/classes/class.ilObjectXMLParser.php';
438 
439  $xml_parser = new ilObjectXMLParser($role_xml);
440  $xml_parser->startParsing();
441 
442  foreach($xml_parser->getObjectData() as $object_data)
443  {
444 
445  // check if role title has il_ prefix
446  if(substr($object_data['title'],0,3) == "il_")
447  {
448  return $this->__raiseError('Rolenames are not allowed to start with "il_" ',
449  'Client');
450  }
451 
452  include_once './Services/AccessControl/classes/class.ilObjRole.php';
453  $role = new ilObjRole();
454  $role->setTitle($object_data['title']);
455  $role->setDescription($object_data['description']);
456  $role->setImportId($object_data['import_id']);
457  $role->create();
458 
459  $GLOBALS['rbacadmin']->assignRoleToFolder($role->getId(),$target_id);
460 
461  // Copy permssions
462  $rbacadmin->copyRoleTemplatePermissions($template_id,ROLE_FOLDER_ID,$target_id,$role->getId());
463 
464  // Set object permissions according to role template
465  $ops = $rbacreview->getOperationsOfRole($role->getId(),$tmp_obj->getType(),$target_id);
466  $rbacadmin->grantPermission($role->getId(),$ops,$target_id);
467  $new_roles[] = $role->getId();
468  }
469 
470 
471  // CREATE ADMIN ROLE
472 
473 
474 
475 
476 
477  return $new_roles ? $new_roles : array();
478  }
479 
480  function getObjectTreeOperations($sid,$ref_id,$user_id)
481  {
482  $this->initAuth($sid);
483  $this->initIlias();
484 
485  if(!$this->__checkSession($sid))
486  {
487  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
488  }
489 
490  global $rbacsystem,$rbacreview,$ilAccess;
491 
492 
493  if(!$tmp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
494  {
495  return $this->__raiseError('No valid ref id given. Please choose an existing reference id of an ILIAS object',
496  'Client');
497  }
498 
499  if(!$tmp_user =& ilObjectFactory::getInstanceByObjId($user_id,false))
500  {
501  return $this->__raiseError('No valid user id given.',
502  'Client');
503  }
504 
506  {
507  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
508  }
509 
510 
511 
512  // check visible for all upper tree entries
513  if(!$ilAccess->checkAccessOfUser($tmp_user->getId(),'visible','',$tmp_obj->getRefId()))
514  {
515  return array();
516  }
517  $op_data = $rbacreview->getOperation(2);
518  $ops_data[] = $op_data;
519 
520  if(!$ilAccess->checkAccessOfUser($tmp_user->getId(),'read','',$tmp_obj->getRefId()))
521  {
522  return $ops_data;
523  }
524 
525 
526  $ops_data = array();
527  $ops = $rbacreview->getOperationsOnTypeString($tmp_obj->getType());
528  foreach($ops as $ops_id)
529  {
530  $op_data = $rbacreview->getOperation($ops_id);
531 
532  if($rbacsystem->checkAccessOfUser($user_id,$op_data['operation'],$tmp_obj->getRefId()))
533  {
534  $ops_data[$ops_id] = $op_data;
535  }
536 
537  }
538 
539  foreach($ops_data as $data)
540  {
541  $ret_data[] = $data;
542  }
543  return $ret_data ? $ret_data : array();
544  }
545 
554  function getRoles($sid, $role_type, $id)
555  {
556  $this->initAuth($sid);
557  $this->initIlias();
558 
559  if(!$this->__checkSession($sid))
560  {
561  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
562  }
563 
564  global $rbacsystem, $rbacreview, $ilUser, $ilDB;
565 
566  if (strcasecmp($role_type,"") != 0 &&
567  strcasecmp($role_type,"local") != 0 &&
568  strcasecmp($role_type,"global") != 0 &&
569  strcasecmp($role_type,"user") != 0 &&
570  strcasecmp($role_type,"user_login") != 0 &&
571  strcasecmp($role_type,"template") != 0)
572  {
573  return $this->__raiseError('Called service with wrong role_type parameter \''.$role_type.'\'','Client');
574  }
575 
576  $roles = array();
577 
578 
579  if (strcasecmp($role_type,"template") == 0)
580  // get templates
581  {
582  $roles = $rbacreview->getRolesByFilter(6, $ilUser->getId());
583  } elseif (strcasecmp($role_type,"user")==0 || strcasecmp($role_type,"user_login")==0)
584  // handle user roles
585  {
586  $user_id = $this->parseUserID($id, $role_type);
587  if ($user_id != $ilUser->getId())
588  // check access for user folder
589  {
590  $tmpUser = new ilObjUser($user_id);
591  $timelimitOwner = $tmpUser->getTimeLimitOwner();
592  if(!$rbacsystem->checkAccess('read',$timelimitOwner))
593  {
594  return $this->__raiseError('Check access for time limit owner failed.','Server');
595  }
596  }
597  $role_type = ""; // local and global roles for user
598 
599  $query = sprintf("SELECT object_data.title, rbac_fa.* FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.rol_id IN ('%s') AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id AND rbac_ua.usr_id=".$user_id,
600  join ("','", $rbacreview->assignedRoles($user_id))
601  );
602 
603  $rbacresult = $ilDB->query($query);
604  while ($rbacrow = $rbacresult->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
605  {
606  if ($rbacrow["assign"] != "y")
607  continue;
608 
609  $type = "";
610 
611  if ($rbacrow["parent"] == ROLE_FOLDER_ID)
612  {
613  $type = "Global";
614  }
615  else
616  {
617  $type = "Local";
618  }
619  if (strlen($type) && $tmp_obj = ilObjectFactory::getInstanceByObjId($rbacrow["rol_id"],false))
620  {
621  /* @var $tmp_obj IlObjRole */
622  $roles[] = array (
623  "obj_id" =>$rbacrow["rol_id"],
624  "title" => $tmp_obj->getTitle(),
625  "description" => $tmp_obj->getDescription(),
626  "role_type" => $type);
627  }
628  }
629  } elseif ($id == "-1")
630  // get all roles of system role folder
631  {
632  if(!$rbacsystem->checkAccess('read',ROLE_FOLDER_ID))
633  {
634  return $this->__raiseError('Check access failed.','Server');
635  }
636 
637  $roles = $rbacreview->getAssignableRoles(false, true);
638  }
639  else
640  // get local roles for a specific repository object
641  // needs permission to read permissions of this object
642  {
643  if(!$rbacsystem->checkAccess('edit_permission',$id))
644  {
645  return $this->__raiseError('Check access for local roles failed.','Server');
646  }
647 
648  if (!is_numeric($id)) {
649  return $this->__raiseError('Id must be numeric to process roles of a repository object.','Client');
650  }
651 
652  $role_type = "local";
653 
654  foreach($rbacreview->getRolesOfRoleFolder($id,false) as $role_id)
655  {
656  if($tmp_obj = ilObjectFactory::getInstanceByObjId($role_id,false))
657  {
658  $roles[] = array ("obj_id" => $role_id, "title" => $tmp_obj->getTitle(), "description" => $tmp_obj->getDescription(), "role_type" => $role_type);
659  }
660  }
661  }
662 
663 
664  include_once './webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
665 
666  $xml_writer = new ilSoapRoleObjectXMLWriter();
667  $xml_writer->setObjects($roles);
668  $xml_writer->setType ($role_type);
669  if($xml_writer->start())
670  {
671  return $xml_writer->getXML();
672  }
673  }
674 
685  function searchRoles ($sid, $key, $combination, $role_type)
686  {
687  $this->initAuth($sid);
688  $this->initIlias();
689 
690  if(!$this->__checkSession($sid))
691  {
692  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
693  }
694 
695  global $rbacsystem, $rbacreview, $ilUser, $ilDB;
696 
697 
698  if (strcasecmp($role_type,"") != 0 &&
699  strcasecmp($role_type,"local") != 0 &&
700  strcasecmp($role_type,"global") != 0 &&
701  strcasecmp($role_type,"template") != 0)
702  {
703  return $this->__raiseError('Called service with wrong role_type parameter \''.$role_type.'\'','Client');
704  }
705 
706  if($combination != 'and' and $combination != 'or')
707  {
708  return $this->__raiseError('No valid combination given. Must be "and" or "or".',
709  'Client');
710  }
711 
712  include_once './Services/Search/classes/class.ilQueryParser.php';
713 
714  $query_parser = new ilQueryParser($key);
715  $query_parser->setMinWordLength(3);
716  $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
717  $query_parser->parse();
718  if(!$query_parser->validate())
719  {
720  return $this->__raiseError($query_parser->getMessage(), 'Client');
721  }
722 
723  include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
724 
725  $object_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
726  $object_search->setFilter(array("role","rolt"));
727 
728  $res = $object_search->performSearch();
729  $res->filter(ROOT_FOLDER_ID, $combination == 'and' ? true : false);
730 
731  $obj_ids = array();
732  foreach($res->getUniqueResults() as $entry)
733  {
734  $obj_ids [] = $entry['obj_id'];
735  }
736 
737  $roles = array();
738  if (count($obj_ids)> 0 )
739  {
740  #print_r($obj_ids);
741  $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type == "template");
742  }
743  #print_r($roles);
744  include_once './webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
745  $xml_writer = new ilSoapRoleObjectXMLWriter();
746  $xml_writer->setObjects($roles);
747  $xml_writer->setType ($role_type);
748  if($xml_writer->start())
749  {
750  return $xml_writer->getXML();
751  }
752 
753 
754  }
755 
756 
757  private function parseUserID ($id, $role_type) {
758  if (strcasecmp($role_type,"user")==0)
759  // get user roles for user id, which can be numeric or ilias id
760  {
761  $user_id = !is_numeric($id) ? ilUtil::__extractId($id, IL_INST_ID) : $id;
762  if (!is_numeric($user_id))
763  {
764  return $this->__raiseError('ID must be either numeric or ILIAS conform id for type \'user\'','Client');
765  }
766  } elseif (strcasecmp($role_type, "user_login") == 0)
767  // check for login
768  {
769  $user_id = ilObjUser::_lookupId($id);
770  if (!$user_id)
771  // could not find a valid user
772  {
773  return $this->__raiseError('User with login \''.$id.'\' does not exist!','Client');
774  }
775  }
776  return $user_id;
777  }
778 }
779 ?>
Class ilObjRole.
$template_id
Definition: example_062.php:89
grantPermissions($sid, $ref_id, $role_id, $permissions)
addUserRoleEntry($sid, $user_id, $role_id)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _isInTrash($a_ref_id)
checks wether object is in trash
static _lookupId($a_user_str)
Lookup id by login.
$target_id
Definition: goto.php:51
searchRoles($sid, $key, $combination, $role_type)
search for roles.
addRole($sid, $target_id, $role_xml)
getRoles($sid, $role_type, $id)
get roles for a specific type and id
const QP_COMBINATION_OR
revokePermissions($sid, $ref_id, $role_id)
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
addRoleFromTemplate($sid, $target_id, $role_xml, $template_id)
$ref_id
Definition: sahs_server.php:39
static _getObjectSearchInstance($query_parser)
get reference of ilFulltext/LikeObjectSearch.
initAuth($sid)
Init authentication.
global $ilDB
deleteUserRoleEntry($sid, $user_id, $role_id)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
const QP_COMBINATION_AND
getObjectTreeOperations($sid, $ref_id, $user_id)
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.