ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilObjPortfolio.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  protected function initType(): void
26  {
27  $this->type = "prtf";
28  }
29 
30 
31  protected function deleteAllPages(): void
32  {
33  // delete pages
34  $pages = ilPortfolioPage::getAllPortfolioPages($this->id);
35  foreach ($pages as $page) {
36  try {
37  $page_obj = new ilPortfolioPage($page["id"]);
38  $page_obj->setPortfolioId($this->id);
39  $page_obj->delete();
40  } catch (Exception $e) {
41  }
42  }
43  }
44 
45 
46  //
47  // HELPER
48  //
49 
50 
55  public static function getPortfoliosOfUser(
56  int $a_user_id
57  ): array {
58  global $DIC;
59 
60  $ilDB = $DIC->database();
61 
62  $set = $ilDB->query("SELECT up.*,od.title,od.description" .
63  " FROM usr_portfolio up" .
64  " JOIN object_data od ON (up.id = od.obj_id)" .
65  " WHERE od.owner = " . $ilDB->quote($a_user_id, "integer") .
66  " AND od.type = " . $ilDB->quote("prtf", "text") .
67  " ORDER BY od.title");
68  $res = array();
69  while ($rec = $ilDB->fetchAssoc($set)) {
70  $res[] = $rec;
71  }
72  return $res;
73  }
74 
78  public static function getDefaultPortfolio(int $a_user_id): ?int
79  {
80  return null;
81  }
82 
86  public static function deleteUserPortfolios(int $a_user_id): void
87  {
88  $all = self::getPortfoliosOfUser($a_user_id);
89  if ($all) {
90  $access_handler = new ilPortfolioAccessHandler();
91 
92  foreach ($all as $item) {
93  $access_handler->removePermission($item["id"]);
94 
95  $portfolio = new self($item["id"], false);
96  $portfolio->delete();
97  }
98  }
99  }
100 
101  public static function getAvailablePortfolioLinksForUserIds(
102  array $a_owner_ids,
103  ?string $a_back_url = null
104  ): array {
105  $res = array();
106 
107  $access_handler = new ilPortfolioAccessHandler();
108 
109  $params = null;
110  if ($a_back_url) {
111  //$params = array("back_url" => rawurlencode($a_back_url));
112  }
113  $params = [];
114 
115  foreach ($access_handler->getShardObjectsDataForUserIds($a_owner_ids) as $owner_id => $items) {
116  foreach ($items as $id => $title) {
117  $url = ilLink::_getLink($id, 'prtf', $params);
118  $res[$owner_id][$url] = $title;
119  }
120  }
121 
122  return $res;
123  }
124 
128  public function isCommentsExportPossible(): bool
129  {
131  $privacy = ilPrivacySettings::getInstance();
132  if ($setting->get("disable_comments")) {
133  return false;
134  }
135  if (!$this->notes->domain()->commentsActive($this->id)) {
136  return false;
137  }
138  if (!$privacy->enabledCommentsExport()) {
139  return false;
140  }
141  return true;
142  }
143 
144  public static function getAdvMDSubItemTitle(int $a_obj_id, string $a_sub_type, int $a_sub_id): string
145  {
146  return \ilPortfolioPage::lookupTitle($a_sub_id);
147  }
148 }
string $title
static getAllPortfolioPages(int $a_portfolio_id)
Get pages of portfolio.
$res
Definition: ltiservices.php:66
get(string $a_keyword, ?string $a_default_value=null)
get setting
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static getDefaultPortfolio(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$url
Definition: shib_logout.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getAdvMDSubItemTitle(int $a_obj_id, string $a_sub_type, int $a_sub_id)
Interface for repository objects to use adv md with subitems.
static getPortfoliosOfUser(int $a_user_id)
Get portfolios of user.
global $DIC
Definition: shib_login.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deleteUserPortfolios(int $a_user_id)
Delete all portfolio data for user.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Access handler for portfolio NOTE: This file needs to stay in the classes directory, WAC will be confused otherwise.
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, ?string $a_back_url=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isCommentsExportPossible()
Is export possible.