ILIAS  release_8 Revision v8.24
class.PortfolioRoleAssignmentManager.php
Go to the documentation of this file.
1<?php
2
20
26{
27 protected \ilRbacReview $rbacreview;
29
30 public function __construct()
31 {
32 global $DIC;
33
34 $this->rbacreview = $DIC->rbac()->review();
35 $this->repo = new PortfolioRoleAssignmentDBRepository();
36 }
37
38 public function add(
39 int $template_ref_id,
40 int $role_id
41 ): void {
42 $this->repo->add(
43 $template_ref_id,
44 $role_id
45 );
46 }
47
48 public function delete(
49 int $template_ref_id,
50 int $role_id
51 ): void {
52 $this->repo->delete(
53 $template_ref_id,
54 $role_id
55 );
56 }
57
58 public function getTemplatesForRoles(
59 array $role_ids
60 ): array {
61 return $this->repo->getTemplatesForRoles($role_ids);
62 }
63
64 public function getAllAssignmentData(): array
65 {
66 return $this->repo->getAllAssignmentData();
67 }
68
72 public function getAvailableRoles(): array
73 {
74 $rbacreview = $this->rbacreview;
75 $global_roles = $rbacreview->getGlobalRoles();
76 $roles = array();
77 foreach ($global_roles as $roleid) {
78 $role_obj = new \ilObjRole($roleid);
79 $roles[$role_obj->getId()] = $role_obj->getTitle();
80 }
81 return $roles;
82 }
83
84 public function assignPortfoliosOnLogin(int $user_id): void
85 {
86 $rbacreview = $this->rbacreview;
87 // get roles of user
88 $role_ids = $rbacreview->assignedRoles($user_id);
89 // get portfolio templates
90 $template_ref_ids = $this->getTemplatesForRoles($role_ids);
91 // create portfolios
92 foreach ($template_ref_ids as $template_ref_id) {
93 if (\ilObject::_lookupType($template_ref_id, true) === "prtt") {
94 $source = new \ilObjPortfolioTemplate($template_ref_id, true);
95 // create portfolio
96 $target = new \ilObjPortfolio();
97 $target->setTitle($source->getTitle());
98 $target->setOwner($user_id);
99 $target->create();
100 $target_id = $target->getId();
102 }
103 }
104 }
105}
static clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, ?array $a_recipe=null, bool $copy_all=false)
Build template from portfolio and vice versa.
static _lookupType(int $id, bool $reference=false)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$target_id
Definition: goto.php:52
$source
Definition: metadata.php:93
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...