ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\News\Dashboard\DashboardNewsManager Class Reference
+ Collaboration diagram for ILIAS\News\Dashboard\DashboardNewsManager:

Public Member Functions

 __construct (InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain)
 
 getDashboardNewsPeriod ()
 
 getDashboardSelectedRefId ()
 
 saveFilterData (?array $data)
 
 getPeriodOptions ()
 
 getContextOptions ()
 

Protected Member Functions

 getUserNewsObjectRefIds ()
 User news on the daashboard/news overview are presented for all favourites and all memberships of the user. More...
 
 getNewsForOverview (int $ref_id, int $period, bool $include_auto_entries, int $items_per_load)
 

Protected Attributes

DashboardSessionRepository $session_repo
 
InternalRepoService $repo
 
InternalDataService $data
 
InternalDomainService $domain
 
ilFavouritesManager $fav_manager
 

Static Protected Attributes

static array $user_object_ref_ids = null
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 30 of file class.DashboardNewsManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\News\Dashboard\DashboardNewsManager::__construct ( InternalDataService  $data,
InternalRepoService  $repo,
InternalDomainService  $domain 
)

Definition at line 42 of file class.DashboardNewsManager.php.

References ILIAS\News\Dashboard\DashboardNewsManager\$data, ILIAS\News\Dashboard\DashboardNewsManager\$domain, and ILIAS\News\InternalRepoService\dashboard().

46  {
47  $this->session_repo = $repo->dashboard();
48  $this->data = $data;
49  $this->domain = $domain;
50  $this->fav_manager = new \ilFavouritesManager();
51  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getContextOptions()

ILIAS\News\Dashboard\DashboardNewsManager::getContextOptions ( )
Returns
array<int,string>

Definition at line 119 of file class.DashboardNewsManager.php.

References $lng, $ref_id, ilNewsItem\_getNewsItemsOfUser(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\News\Dashboard\DashboardNewsManager\getDashboardNewsPeriod(), ILIAS\News\Dashboard\DashboardNewsManager\getUserNewsObjectRefIds(), and ILIAS\Repository\int().

119  : array
120  {
121  $lng = $this->domain->lng();
122  $user = $this->domain->user();
123  $period = $this->getDashboardNewsPeriod();
124 
125  $cnt = [];
127  $user->getId(),
128  false,
129  true,
130  $period,
131  $cnt
132  );
133 
134  $ref_ids = $this->getUserNewsObjectRefIds();
135 
136  // related objects (contexts) of news
137  $contexts[0] = $lng->txt("news_all_items");
138 
139  $conts = [];
140  foreach ($ref_ids as $ref_id) {
141  $obj_id = \ilObject::_lookupObjId($ref_id);
142  $title = \ilObject::_lookupTitle($obj_id);
143  $conts[$ref_id] = $title;
144  }
145 
146  asort($conts);
147  foreach ($conts as $ref_id => $title) {
148  $contexts[$ref_id] = $title . " (" . (int) ($cnt[$ref_id] ?? 0) . ")";
149  }
150 
151  return $contexts;
152  }
getUserNewsObjectRefIds()
User news on the daashboard/news overview are presented for all favourites and all memberships of the...
static _getNewsItemsOfUser(int $a_user_id, bool $a_only_public=false, bool $a_prevent_aggregation=false, int $a_per=0, array &$a_cnt=[], bool $no_auto_generated=false, array $excluded=[], int $a_limit=0)
Get all news items for a user.
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:

◆ getDashboardNewsPeriod()

ILIAS\News\Dashboard\DashboardNewsManager::getDashboardNewsPeriod ( )

Definition at line 53 of file class.DashboardNewsManager.php.

References ilNewsItem\_lookupUserPDPeriod().

Referenced by ILIAS\News\Dashboard\DashboardNewsManager\getContextOptions().

53  : int
54  {
55  $user = $this->domain->user();
56  $period = $this->session_repo->getDashboardNewsPeriod();
57  if ($period === 0) {
58  $period = \ilNewsItem::_lookupUserPDPeriod($user->getId());
59  }
60  return $period;
61  }
static _lookupUserPDPeriod(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDashboardSelectedRefId()

ILIAS\News\Dashboard\DashboardNewsManager::getDashboardSelectedRefId ( )

Definition at line 63 of file class.DashboardNewsManager.php.

63  : int
64  {
65  $user = $this->domain->user();
66  return (int) $user->getPref("news_sel_ref_id");
67  }

◆ getNewsForOverview()

ILIAS\News\Dashboard\DashboardNewsManager::getNewsForOverview ( int  $ref_id,
int  $period,
bool  $include_auto_entries,
int  $items_per_load 
)
protected

Definition at line 187 of file class.DashboardNewsManager.php.

References ilNewsItem\_getNewsItemsOfUser(), and null.

192  : array {
193  $user = $this->domain->user();
194  $news_item = new \ilNewsItem();
195  //$news_item->setContextObjId($this->ctrl->getContextObjId());
196  //$news_item->setContextObjType($this->ctrl->getContextObjType());
197 
198  if ($ref_id > 0) {
199  $news_data = $news_item->getNewsForRefId(
200  $ref_id,
201  false,
202  false,
203  $period,
204  true,
205  false,
206  !$include_auto_entries,
207  false,
208  null,
209  $items_per_load
210  );
211  } else {
212  $cnt = [];
214  $user->getId(),
215  false,
216  true,
217  $period,
218  $cnt,
219  !$include_auto_entries
220  );
221  }
222  return $news_data;
223  }
static _getNewsItemsOfUser(int $a_user_id, bool $a_only_public=false, bool $a_prevent_aggregation=false, int $a_per=0, array &$a_cnt=[], bool $no_auto_generated=false, array $excluded=[], int $a_limit=0)
Get all news items for a user.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

◆ getPeriodOptions()

ILIAS\News\Dashboard\DashboardNewsManager::getPeriodOptions ( )
Returns
array<int,string>

Definition at line 83 of file class.DashboardNewsManager.php.

References $lng, and ilNewsItem\_lookupDefaultPDPeriod().

83  : array
84  {
85  $lng = $this->domain->lng();
86  $news_set = new \ilSetting("news");
87  $allow_shorter_periods = $news_set->get("allow_shorter_periods");
88  $allow_longer_periods = $news_set->get("allow_longer_periods");
89  $default_per = \ilNewsItem::_lookupDefaultPDPeriod();
90 
91  $options = [
92  "7" => $lng->txt("news_period_1_week"),
93  "30" => $lng->txt("news_period_1_month"),
94  "366" => $lng->txt("news_period_1_year")
95  ];
96 
97  return $options;
98 
99  /*
100  $unset = [];
101  foreach ($options as $k => $opt) {
102  if (!$allow_shorter_periods && ($k < $default_per)) {
103  $unset[$k] = $k;
104  }
105  if (!$allow_longer_periods && ($k > $default_per)) {
106  $unset[$k] = $k;
107  }
108  }
109  foreach ($unset as $k) {
110  unset($options[$k]);
111  }
112 
113  return $options;*/
114  }
global $lng
Definition: privfeed.php:31
static _lookupDefaultPDPeriod()
+ Here is the call graph for this function:

◆ getUserNewsObjectRefIds()

ILIAS\News\Dashboard\DashboardNewsManager::getUserNewsObjectRefIds ( )
protected

User news on the daashboard/news overview are presented for all favourites and all memberships of the user.

Returns
int[]

Definition at line 159 of file class.DashboardNewsManager.php.

References $user_id, ilObject\_getAllReferences(), ilParticipants\_getMembershipByType(), and ILIAS\Repository\int().

Referenced by ILIAS\News\Dashboard\DashboardNewsManager\getContextOptions().

159  : array
160  {
161  if (is_null(self::$user_object_ref_ids)) {
162  $ref_ids = [];
163  $user = $this->domain->user();
164  $user_id = $user->getId();
165 
166  // get all items of the personal desktop
167  $fav_items = $this->fav_manager->getFavouritesOfUser($user_id);
168  foreach ($fav_items as $item) {
169  if (!in_array($item["ref_id"], $ref_ids)) {
170  $ref_ids[] = (int) $item["ref_id"];
171  }
172  }
173 
174  // get all memberships
175  $crs_mbs = \ilParticipants::_getMembershipByType($user_id, ['crs']);
176  $grp_mbs = \ilParticipants::_getMembershipByType($user_id, ['grp']);
177  $items = array_merge($crs_mbs, $grp_mbs);
178  foreach ($items as $i) {
179  $item_references = \ilObject::_getAllReferences($i);
180  $ref_ids = array_unique(array_merge($ref_ids, $item_references));
181  }
182  self::$user_object_ref_ids = $ref_ids;
183  }
184  return self::$user_object_ref_ids;
185  }
static _getAllReferences(int $id)
get all reference ids for object ID
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveFilterData()

ILIAS\News\Dashboard\DashboardNewsManager::saveFilterData ( ?array  $data)

Definition at line 69 of file class.DashboardNewsManager.php.

69  : void
70  {
71  $user = $this->domain->user();
72  if (!is_null($data) && !is_null($data["news_ref_id"])) {
73  $user->writePref("news_sel_ref_id", (string) (int) $data["news_ref_id"]);
74  } else {
75  $user->writePref("news_sel_ref_id", "0");
76  }
77  $this->session_repo->setDashboardNewsPeriod((int) ($data["news_per"] ?? 0));
78  }

Field Documentation

◆ $data

InternalDataService ILIAS\News\Dashboard\DashboardNewsManager::$data
protected

◆ $domain

InternalDomainService ILIAS\News\Dashboard\DashboardNewsManager::$domain
protected

◆ $fav_manager

ilFavouritesManager ILIAS\News\Dashboard\DashboardNewsManager::$fav_manager
protected

Definition at line 36 of file class.DashboardNewsManager.php.

◆ $repo

InternalRepoService ILIAS\News\Dashboard\DashboardNewsManager::$repo
protected

Definition at line 33 of file class.DashboardNewsManager.php.

◆ $session_repo

DashboardSessionRepository ILIAS\News\Dashboard\DashboardNewsManager::$session_repo
protected

Definition at line 32 of file class.DashboardNewsManager.php.

◆ $user_object_ref_ids

array ILIAS\News\Dashboard\DashboardNewsManager::$user_object_ref_ids = null
staticprotected

Definition at line 40 of file class.DashboardNewsManager.php.


The documentation for this class was generated from the following file: