ILIAS  trunk Revision v12.0_alpha-454-g178fcb218fa
ILIAS\News\Dashboard\DashboardNewsManager Class Reference
+ Collaboration diagram for ILIAS\News\Dashboard\DashboardNewsManager:

Public Member Functions

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

Protected Attributes

DashboardSessionRepository $session_repo
 
ilFavouritesManager $fav_manager
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

40 {
41 $this->session_repo = $repo->dashboard();
42 $this->fav_manager = new \ilFavouritesManager();
43 }

References ILIAS\News\InternalRepoService\dashboard().

+ Here is the call graph for this function:

Member Function Documentation

◆ getContextOptions()

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

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

111 : array
112 {
113 $context_count = $this->repo->news()->countByContextsBatch(
114 $this->domain->resolver()->getAccessibleContexts(
115 $this->domain->user(),
116 new NewsCriteria(period: $this->getDashboardNewsPeriod(), only_public: false)
117 )
118 );
119
120 $options = [];
121 foreach ($context_count as [$context, $count]) {
122 $options[$context->getRefId()] = \ilObject::_lookupTitle($context->getObjId()) . " ({$count})";
123 }
124 asort($options);
125
126 return [0 => $this->domain->lng()->txt('news_all_items')] + $options;
127 }
static _lookupTitle(int $obj_id)
$context
Definition: webdav.php:31

References $context, ILIAS\UI\Implementation\Component\Input\Field\$options, ilObject\_lookupTitle(), and ILIAS\News\Dashboard\DashboardNewsManager\getDashboardNewsPeriod().

+ Here is the call graph for this function:

◆ getDashboardNewsPeriod()

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

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

45 : int
46 {
47 $user = $this->domain->user();
48 $period = $this->session_repo->getDashboardNewsPeriod();
49 if ($period === 0) {
50 $period = \ilNewsItem::_lookupUserPDPeriod($user->getId());
51 }
52 return $period;
53 }
static _lookupUserPDPeriod(int $a_user_id)

References ilNewsItem\_lookupUserPDPeriod().

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

+ 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 55 of file class.DashboardNewsManager.php.

55 : int
56 {
57 $user = $this->domain->user();
58 return (int) $user->getPref("news_sel_ref_id");
59 }

◆ getPeriodOptions()

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

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

75 : array
76 {
77 $lng = $this->domain->lng();
78 $news_set = new \ilSetting("news");
79 $allow_shorter_periods = $news_set->get("allow_shorter_periods");
80 $allow_longer_periods = $news_set->get("allow_longer_periods");
82
83 $options = [
84 "7" => $lng->txt("news_period_1_week"),
85 "30" => $lng->txt("news_period_1_month"),
86 "366" => $lng->txt("news_period_1_year")
87 ];
88
89 return $options;
90
91 /*
92 $unset = [];
93 foreach ($options as $k => $opt) {
94 if (!$allow_shorter_periods && ($k < $default_per)) {
95 $unset[$k] = $k;
96 }
97 if (!$allow_longer_periods && ($k > $default_per)) {
98 $unset[$k] = $k;
99 }
100 }
101 foreach ($unset as $k) {
102 unset($options[$k]);
103 }
104
105 return $options;*/
106 }
static _lookupDefaultPDPeriod()
global $lng
Definition: privfeed.php:31

References $lng, ILIAS\UI\Implementation\Component\Input\Field\$options, and ilNewsItem\_lookupDefaultPDPeriod().

+ Here is the call graph for this function:

◆ saveFilterData()

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

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

61 : void
62 {
63 $user = $this->domain->user();
64 if (!is_null($data) && !is_null($data["news_ref_id"])) {
65 $user->writePref("news_sel_ref_id", (string) (int) $data["news_ref_id"]);
66 } else {
67 $user->writePref("news_sel_ref_id", "0");
68 }
69 $this->session_repo->setDashboardNewsPeriod((int) ($data["news_per"] ?? 0));
70 }

References $data.

Field Documentation

◆ $fav_manager

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

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

◆ $session_repo

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

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


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