ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Survey\Participants\InvitationsManager Class Reference

Survey invitations. More...

+ Collaboration diagram for ILIAS\Survey\Participants\InvitationsManager:

Public Member Functions

 __construct (InvitationsDBRepository $repo=null, Execution\RunDBRepository $run_repo=null, Settings\SettingsDBRepository $set_repo=null)
 Constructor. More...
 
 remove (int $survey_id, int $user_id)
 Remove invitation. More...
 
 add (int $survey_id, int $user_id)
 Add invitation. More...
 
 getAllForSurvey (int $survey_id)
 Get invitations for survey. More...
 
 getOpenInvitationsOfUser (int $user_id)
 Get all open invitations of a user. More...
 

Protected Attributes

 $repo
 
 $run_repo
 
 $set_repo
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Survey\Participants\InvitationsManager::__construct ( InvitationsDBRepository  $repo = null,
Execution\RunDBRepository  $run_repo = null,
Settings\SettingsDBRepository  $set_repo = null 
)

Constructor.

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

References ILIAS\Survey\Participants\InvitationsManager\$repo, ILIAS\Survey\Participants\InvitationsManager\$run_repo, and ILIAS\Survey\Participants\InvitationsManager\$set_repo.

39  {
40  $this->repo = (is_null($repo))
41  ? new InvitationsDBRepository()
42  : $repo;
43 
44  $this->run_repo = (is_null($run_repo))
45  ? new Execution\RunDBRepository()
46  : $run_repo;
47 
48  $this->set_repo = (is_null($set_repo))
49  ? new Settings\SettingsDBRepository()
50  : $set_repo;
51  }

Member Function Documentation

◆ add()

ILIAS\Survey\Participants\InvitationsManager::add ( int  $survey_id,
int  $user_id 
)

Add invitation.

Parameters
int$survey_idSurvey ID not object ID!
int$user_id

Definition at line 72 of file class.InvitationsManager.php.

73  {
74  $this->repo->add($survey_id, $user_id);
75  }

◆ getAllForSurvey()

ILIAS\Survey\Participants\InvitationsManager::getAllForSurvey ( int  $survey_id)

Get invitations for survey.

Parameters
int$survey_idSurvey ID not object ID!
Returns
int[]

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

83  : array
84  {
85  return $this->repo->getAllForSurvey($survey_id);
86  }

◆ getOpenInvitationsOfUser()

ILIAS\Survey\Participants\InvitationsManager::getOpenInvitationsOfUser ( int  $user_id)

Get all open invitations of a user.

Parameters

Definition at line 94 of file class.InvitationsManager.php.

References $i.

95  {
96  // get all invitations
97  $survey_ids = $this->repo->getAllForUser($user_id);
98 
99  // check if user started already
100  $finished_surveys = $this->run_repo->getFinishedSurveysOfUser($user_id);
101 
102  $open_surveys = array_filter($survey_ids, function ($i) use ($finished_surveys) {
103  return !in_array($i, $finished_surveys);
104  });
105 
106  // filter all surveys that have ended
107  $has_ended = $this->set_repo->hasEnded($open_surveys);
108  $open_surveys = array_filter($open_surveys, function ($i) use ($has_ended) {
109  return !$has_ended[$i];
110  });
111 
112  return $open_surveys;
113  }
$i
Definition: metadata.php:24

◆ remove()

ILIAS\Survey\Participants\InvitationsManager::remove ( int  $survey_id,
int  $user_id 
)

Remove invitation.

Parameters
int$survey_idSurvey ID not object ID!
int$user_id

Definition at line 60 of file class.InvitationsManager.php.

61  {
62  $this->repo->remove($survey_id, $user_id);
63  }

Field Documentation

◆ $repo

ILIAS\Survey\Participants\InvitationsManager::$repo
protected

◆ $run_repo

ILIAS\Survey\Participants\InvitationsManager::$run_repo
protected

◆ $set_repo

ILIAS\Survey\Participants\InvitationsManager::$set_repo
protected

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