ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Notes\NotesManager Class Reference
+ Collaboration diagram for ILIAS\Notes\NotesManager:

Public Member Functions

 __construct (InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain)
 
 setSortAscending (bool $asc)
 
 getSortAscending ()
 
 createNote (Note $note, array $observer, bool $use_provided_creation_date=false)
 
 deleteNote (Note $note, int $user_id, $public_deletion_enabled=false)
 
 updateNoteText (int $id, string $text, array $observer)
 
 getNotesForContext (Context $context, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0, bool $ascending=false, string $since="", string $search_text="")
 Get all notes related to a specific context. More...
 
 getNotesForRepositoryObjId (int $obj_id, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0, bool $ascending=false, string $since="")
 Get all notes related to a specific repository object. More...
 
 getNotesForRepositoryObjIds (array $obj_ids, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0, bool $ascending=false, string $since="", string $search_text="")
 Get all notes related to a specific repository object. More...
 
 getNrOfNotesForContext (Context $context, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0)
 
 getRelatedObjectsOfUser (int $type)
 Get all untrashed objects that have either notes/comments of the user attached, or are favourites of the user and have at least one comment (of any user) More...
 
 getById (int $id)
 
 commentsActive (int $obj_id)
 Are comments activated for object? More...
 
 commentsActiveMultiple (array $obj_ids)
 
 activateComments (int $obj_id, bool $a_activate=true)
 Activate notes feature. More...
 
 getUserCount (int $obj_id, int $sub_obj_id, string $obj_type)
 How many users have attached a note/comment to a given object? More...
 
 countNotesAndCommentsMultipleObjects (array $obj_ids, bool $no_sub_objs=false)
 Get all notes related to multiple repository objects (current user) More...
 

Protected Attributes

NotificationsManager $notification
 
AccessManager $note_access
 
NoteSettingsDBRepository $db_settings_repo
 
NoteDBRepository $db_repo
 
InternalDomainService $domain
 
InternalRepoService $repo
 
InternalDataService $data
 
NotesSessionRepository $sess_repo
 

Detailed Description

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

Definition at line 26 of file class.NotesManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Notes\NotesManager::__construct ( InternalDataService  $data,
InternalRepoService  $repo,
InternalDomainService  $domain 
)

Definition at line 37 of file class.NotesManager.php.

References ILIAS\Notes\NotesManager\$data, ILIAS\Notes\NotesManager\$domain, ILIAS\Notes\NotesManager\$repo, and ILIAS\UI\examples\Symbol\Glyph\Notification\notification().

41  {
42  $this->data = $data;
43  $this->repo = $repo;
44  $this->domain = $domain;
45  $this->sess_repo = $repo->notesSession();
46  $this->db_repo = $repo->note();
47  $this->db_settings_repo = $repo->settings();
48  $this->note_access = $domain->noteAccess();
49  $this->notification = $domain->notification();
50  }
notification()
description: > Example for rendring a notification glyph.
InternalDataService $data
InternalDomainService $domain
InternalRepoService $repo
+ Here is the call graph for this function:

Member Function Documentation

◆ activateComments()

ILIAS\Notes\NotesManager::activateComments ( int  $obj_id,
bool  $a_activate = true 
)

Activate notes feature.

Definition at line 261 of file class.NotesManager.php.

References ilObject\_lookupType().

264  : void {
265  $this->db_settings_repo->activateComments(
266  $obj_id,
267  0,
268  \ilObject::_lookupType($obj_id),
269  $a_activate
270  );
271  }
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ commentsActive()

ILIAS\Notes\NotesManager::commentsActive ( int  $obj_id)

Are comments activated for object?

Definition at line 246 of file class.NotesManager.php.

Referenced by ILIAS\Notes\NotesManager\getRelatedObjectsOfUser().

248  : bool {
249  return $this->db_settings_repo->commentsActive($obj_id);
250  }
+ Here is the caller graph for this function:

◆ commentsActiveMultiple()

ILIAS\Notes\NotesManager::commentsActiveMultiple ( array  $obj_ids)

Definition at line 252 of file class.NotesManager.php.

254  : array {
255  return $this->db_settings_repo->commentsActiveMultiple($obj_ids);
256  }

◆ countNotesAndCommentsMultipleObjects()

ILIAS\Notes\NotesManager::countNotesAndCommentsMultipleObjects ( array  $obj_ids,
bool  $no_sub_objs = false 
)

Get all notes related to multiple repository objects (current user)

Todo:
see comment in db repo class

Definition at line 288 of file class.NotesManager.php.

291  : array {
292  return $this->db_repo->countNotesAndCommentsMultipleObjects(
293  $obj_ids,
294  $this->domain->user()->getId(),
295  $no_sub_objs
296  );
297  }

◆ createNote()

ILIAS\Notes\NotesManager::createNote ( Note  $note,
array  $observer,
bool  $use_provided_creation_date = false 
)

Definition at line 62 of file class.NotesManager.php.

References ILIAS\UI\examples\Symbol\Glyph\Notification\notification(), ilUtil\now(), and ILIAS\Notes\Note\withCreationDate().

66  : void {
67  if (!$use_provided_creation_date) {
68  $note = $note->withCreationDate(\ilUtil::now());
69  }
70  $note = $this->db_repo->createNote($note);
71  $this->notification->sendNotifications($note, false);
72  $this->notification->notifyObserver($observer, "new", $note);
73  }
static now()
Return current timestamp in Y-m-d H:i:s format.
notification()
description: > Example for rendring a notification glyph.
+ Here is the call graph for this function:

◆ deleteNote()

ILIAS\Notes\NotesManager::deleteNote ( Note  $note,
int  $user_id,
  $public_deletion_enabled = false 
)

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

References ILIAS\Notes\Note\getId().

75  : void
76  {
77  if ($this->note_access->canDelete($note, $user_id, $public_deletion_enabled)) {
78  $this->db_repo->deleteNote($note->getId());
79  }
80  }
+ Here is the call graph for this function:

◆ getById()

ILIAS\Notes\NotesManager::getById ( int  $id)
Exceptions
NoteNotFoundException

Definition at line 238 of file class.NotesManager.php.

238  : Note
239  {
240  return $this->db_repo->getById($id);
241  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getNotesForContext()

ILIAS\Notes\NotesManager::getNotesForContext ( Context  $context,
int  $type = Note::PRIVATE,
bool  $incl_sub = false,
int  $author = 0,
bool  $ascending = false,
string  $since = "",
string  $search_text = "" 
)

Get all notes related to a specific context.

Returns
Note[]

Definition at line 100 of file class.NotesManager.php.

108  : array {
109  return $this->db_repo->getNotesForContext(
110  $context,
111  $type,
112  $incl_sub,
113  $author,
114  $ascending,
115  $since,
116  $search_text
117  );
118  }
$context
Definition: webdav.php:31

◆ getNotesForRepositoryObjId()

ILIAS\Notes\NotesManager::getNotesForRepositoryObjId ( int  $obj_id,
int  $type = Note::PRIVATE,
bool  $incl_sub = false,
int  $author = 0,
bool  $ascending = false,
string  $since = "" 
)

Get all notes related to a specific repository object.

Returns
Note[]

Definition at line 124 of file class.NotesManager.php.

References $context.

131  : array {
132  $context = $this->data->context(
133  $obj_id,
134  0,
135  ""
136  );
137  return $this->db_repo->getNotesForContext(
138  $context,
139  $type,
140  $incl_sub,
141  $author,
142  $ascending,
143  $since
144  );
145  }
$context
Definition: webdav.php:31

◆ getNotesForRepositoryObjIds()

ILIAS\Notes\NotesManager::getNotesForRepositoryObjIds ( array  $obj_ids,
int  $type = Note::PRIVATE,
bool  $incl_sub = false,
int  $author = 0,
bool  $ascending = false,
string  $since = "",
string  $search_text = "" 
)

Get all notes related to a specific repository object.

Parameters
array$obj_ids
Returns
Note[]

Definition at line 152 of file class.NotesManager.php.

160  : array {
161  return $this->db_repo->getNotesForObjIds(
162  $obj_ids,
163  $type,
164  $incl_sub,
165  $author,
166  $ascending,
167  $since,
168  $search_text
169  );
170  }

◆ getNrOfNotesForContext()

ILIAS\Notes\NotesManager::getNrOfNotesForContext ( Context  $context,
int  $type = Note::PRIVATE,
bool  $incl_sub = false,
int  $author = 0 
)

Definition at line 173 of file class.NotesManager.php.

178  : int {
179  return $this->db_repo->getNrOfNotesForContext(
180  $context,
181  $type,
182  $incl_sub,
183  $author
184  );
185  }
$context
Definition: webdav.php:31

◆ getRelatedObjectsOfUser()

ILIAS\Notes\NotesManager::getRelatedObjectsOfUser ( int  $type)

Get all untrashed objects that have either notes/comments of the user attached, or are favourites of the user and have at least one comment (of any user)

Parameters
int$typeNote::PRIVATE | Note::PUBLIC
Returns
int[]

Definition at line 193 of file class.NotesManager.php.

References $id, $user_id, ilObject\_hasUntrashedReference(), ILIAS\Notes\NotesManager\commentsActive(), and ILIAS\Notes\Note\PUBLIC.

193  : array
194  {
195  $tree = $this->domain->repositoryTree();
196  $user_id = $this->domain->user()->getId();
197  $fav_rep = new \ilFavouritesDBRepository();
198 
199  $ids = $this->db_repo->getRelatedObjIdsOfUser($user_id, $type);
200  $ids = array_filter($ids, function ($id) {
201  return \ilObject::_exists($id);
202  });
203 
204  if ($type === Note::PUBLIC) {
205  // additionally all objects on the personal desktop of the user
206  // that have at least on comment
207  $fav_obj_ids = array_map(function ($i) {
208  return $i["obj_id"];
209  }, $fav_rep->getFavouritesOfUser($user_id));
210  if (count($fav_obj_ids) > 0) {
211  $fav_obj_ids = $this->db_repo->filterObjectsWithNotes($fav_obj_ids, Note::PUBLIC);
212  $ids = array_unique(array_merge($ids, $fav_obj_ids));
213  }
214 
215  $ids = array_filter($ids, function ($id) {
216  return $this->commentsActive($id);
217  });
218  }
219 
220  $wsp_tree = new \ilWorkspaceTree($user_id);
221 
222  $ids = array_filter($ids, function ($id) use ($wsp_tree) {
224  return true;
225  }
226  if ($wsp_tree->lookupNodeId($id) > 0) {
227  return true;
228  }
229  return false;
230  });
231 
232  return $ids;
233  }
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
commentsActive(int $obj_id)
Are comments activated for object?
+ Here is the call graph for this function:

◆ getSortAscending()

ILIAS\Notes\NotesManager::getSortAscending ( )

Definition at line 57 of file class.NotesManager.php.

57  : bool
58  {
59  return $this->sess_repo->getSortAscending();
60  }

◆ getUserCount()

ILIAS\Notes\NotesManager::getUserCount ( int  $obj_id,
int  $sub_obj_id,
string  $obj_type 
)

How many users have attached a note/comment to a given object?

Definition at line 276 of file class.NotesManager.php.

280  : int {
281  return $this->db_repo->getUserCount($obj_id, $sub_obj_id, $obj_type);
282  }

◆ setSortAscending()

ILIAS\Notes\NotesManager::setSortAscending ( bool  $asc)

Definition at line 52 of file class.NotesManager.php.

52  : void
53  {
54  $this->sess_repo->setSortAscending($asc);
55  }

◆ updateNoteText()

ILIAS\Notes\NotesManager::updateNoteText ( int  $id,
string  $text,
array  $observer 
)

Definition at line 82 of file class.NotesManager.php.

References ILIAS\UI\examples\Symbol\Glyph\Notification\notification().

86  : void {
87  $note = $this->db_repo->getById($id);
88  if ($this->note_access->canEdit($note)) {
89  $this->db_repo->updateNoteText($id, $text);
90  $note = $this->db_repo->getById($id);
91  $this->notification->sendNotifications($note, true);
92  $this->notification->notifyObserver($observer, "update", $note);
93  }
94  }
notification()
description: > Example for rendring a notification glyph.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Field Documentation

◆ $data

InternalDataService ILIAS\Notes\NotesManager::$data
protected

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

Referenced by ILIAS\Notes\NotesManager\__construct().

◆ $db_repo

NoteDBRepository ILIAS\Notes\NotesManager::$db_repo
protected

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

◆ $db_settings_repo

NoteSettingsDBRepository ILIAS\Notes\NotesManager::$db_settings_repo
protected

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

◆ $domain

InternalDomainService ILIAS\Notes\NotesManager::$domain
protected

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

Referenced by ILIAS\Notes\NotesManager\__construct().

◆ $note_access

AccessManager ILIAS\Notes\NotesManager::$note_access
protected

Definition at line 29 of file class.NotesManager.php.

◆ $notification

NotificationsManager ILIAS\Notes\NotesManager::$notification
protected

Definition at line 28 of file class.NotesManager.php.

◆ $repo

InternalRepoService ILIAS\Notes\NotesManager::$repo
protected

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

Referenced by ILIAS\Notes\NotesManager\__construct().

◆ $sess_repo

NotesSessionRepository ILIAS\Notes\NotesManager::$sess_repo
protected

Definition at line 35 of file class.NotesManager.php.


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