ILIAS  release_8 Revision v8.24
ilForumDraftsDerivedTaskProvider Class Reference

Class ilForumDraftsDerivedTaskProvider. More...

+ Inheritance diagram for ilForumDraftsDerivedTaskProvider:
+ Collaboration diagram for ilForumDraftsDerivedTaskProvider:

Public Member Functions

 __construct (ilTaskService $taskService, ilAccessHandler $accessHandler, ilLanguage $lng, ilSetting $settings, ilCtrlInterface $ctrl)
 
 getTasks (int $user_id)
 Get providers. More...
 
 isActive ()
 Is provider active? More...
 
 getTasks (int $user_id)
 Get providers. More...
 
 isActive ()
 Is provider active? More...
 

Protected Member Functions

 getFirstRefIdWithPermission (string $operation, int $objId, int $userId)
 

Protected Attributes

ilTaskService $taskService
 
ilAccessHandler $accessHandler
 
ilLanguage $lng
 
ilSetting $settings
 
ilCtrlInterface $ctrl
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumDraftsDerivedTaskProvider::__construct ( ilTaskService  $taskService,
ilAccessHandler  $accessHandler,
ilLanguage  $lng,
ilSetting  $settings,
ilCtrlInterface  $ctrl 
)

Member Function Documentation

◆ getFirstRefIdWithPermission()

ilForumDraftsDerivedTaskProvider::getFirstRefIdWithPermission ( string  $operation,
int  $objId,
int  $userId 
)
protected

Definition at line 112 of file class.ilForumDraftsDerivedTaskProvider.php.

112 : int
113 {
115 if ($this->accessHandler->checkAccessOfUser($userId, $operation, '', $refId)) {
116 return $refId;
117 }
118 }
119
120 return 0;
121 }
static _getAllReferences(int $id)
get all reference ids for object ID
$objId
Definition: xapitoken.php:57
$refId
Definition: xapitoken.php:58

References $objId, $refId, and ilObject\_getAllReferences().

Referenced by getTasks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTasks()

ilForumDraftsDerivedTaskProvider::getTasks ( int  $user_id)

Get providers.

Returns
ilDerivedTask[]

Implements ilDerivedTaskProvider.

Definition at line 49 of file class.ilForumDraftsDerivedTaskProvider.php.

49 : array
50 {
51 $tasks = [];
52
54 foreach ($drafts as $draft) {
55 $objId = ilForum::_lookupObjIdForForumId($draft->getForumId());
56 $refId = $this->getFirstRefIdWithPermission('read', $objId, $user_id);
57
58 if (0 === $refId) {
59 continue;
60 }
61
62 $title = sprintf(
63 $this->lng->txt('frm_task_publishing_draft_title'),
64 $draft->getPostSubject()
65 );
66
67 $task = $this->taskService->derived()->factory()->task(
68 $title,
69 $refId,
70 0,
71 0
72 );
73
74 $isThread = false;
75 if (0 === $draft->getThreadId()) {
76 $isThread = true;
77 }
78
79 $anchor = '';
80 $params = ['ref_id' => $refId];
81 if ($isThread) {
82 $params['draft_id'] = $draft->getDraftId();
83 $cmd = 'editThreadDraft';
84 } else {
85 $params['thr_pk'] = $draft->getThreadId();
86 $params['pos_pk'] = $draft->getPostId();
87 $cmd = 'viewThread';
88 $anchor = 'draft_' . $draft->getDraftId();
89 }
90
91 foreach ($params as $name => $value) {
92 $this->ctrl->setParameterByClass(ilObjForumGUI::class, $name, $value);
93 }
94 $url = $this->ctrl->getLinkTargetByClass(
95 [
96 ilRepositoryGUI::class,
97 ilObjForumGUI::class
98 ],
99 $cmd,
100 $anchor
101 );
102 foreach (array_keys($params) as $name) {
103 $this->ctrl->setParameterByClass(ilObjForumGUI::class, $name, null);
104 }
105
106 $tasks[] = $task->withUrl($url);
107 }
108
109 return $tasks;
110 }
getFirstRefIdWithPermission(string $operation, int $objId, int $userId)
static getDraftInstancesByUserId(int $user_id)
static _lookupObjIdForForumId(int $a_for_id)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
if($format !==null) $name
Definition: metadata.php:247
$url

References $name, $objId, $params, $refId, $url, ilForum\_lookupObjIdForForumId(), ILIAS\Repository\ctrl(), ilForumPostDraft\getDraftInstancesByUserId(), getFirstRefIdWithPermission(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ isActive()

ilForumDraftsDerivedTaskProvider::isActive ( )

Is provider active?

Implements ilDerivedTaskProvider.

Definition at line 123 of file class.ilForumDraftsDerivedTaskProvider.php.

123 : bool
124 {
125 return (bool) $this->settings->get('save_post_drafts', '0');
126 }

References ILIAS\Repository\settings().

+ Here is the call graph for this function:

Field Documentation

◆ $accessHandler

ilAccessHandler ilForumDraftsDerivedTaskProvider::$accessHandler
protected

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

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilForumDraftsDerivedTaskProvider::$ctrl
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilForumDraftsDerivedTaskProvider::$lng
protected

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

Referenced by __construct().

◆ $settings

ilSetting ilForumDraftsDerivedTaskProvider::$settings
protected

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

Referenced by __construct().

◆ $taskService

ilTaskService ilForumDraftsDerivedTaskProvider::$taskService
protected

Definition at line 27 of file class.ilForumDraftsDerivedTaskProvider.php.

Referenced by __construct().


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