ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Survey\Code\CodeManager Class Reference

Code manager. More...

+ Collaboration diagram for ILIAS\Survey\Code\CodeManager:

Public Member Functions

 __construct (CodeDBRepo $code_repo, InternalDataService $data, \ilObjSurvey $survey, InternalDomainService $domain_service, int $user_id)
 
 deleteAll (bool $force=false)
 Delete all codes of survey. More...
 
 delete (string $code)
 Delete single code. More...
 
 exists (string $code)
 Does code exist in survey? More...
 
 add (Code $code)
 Saves a survey access code for a registered user to the database. More...
 
 addCodes (int $nr)
 Add multiple new codes. More...
 
 updateExternalData (int $code_id, string $email, string $last_name, string $first_name, int $sent)
 Update external data of a code. More...
 
 getAll ()
 Get all access keys of a survey. More...
 
 getAllData ()
 Get all codes of a survey. More...
 
 bindUser (string $code, int $user_id)
 Bind registered user to a code. More...
 
 getByUserId (int $user_id)
 Get access key for a registered user. More...
 
 getByCodeId (int $code_id)
 
 getByUserKey (string $user_key)
 Get code object for an access key. More...
 

Protected Member Functions

 checkPermission ()
 

Protected Attributes

int $survey_ref_id = 0
 
CodeDBRepo $code_repo
 
InternalDataService $data
 
int $survey_id
 
AccessManager $access
 
ilLanguage $lng
 

Detailed Description

Code manager.

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

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Survey\Code\CodeManager::__construct ( CodeDBRepo  $code_repo,
InternalDataService  $data,
\ilObjSurvey  $survey,
InternalDomainService  $domain_service,
int  $user_id 
)

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

References ILIAS\Survey\Code\CodeManager\$code_repo, ILIAS\Survey\Code\CodeManager\$data, $user_id, ILIAS\Repository\access(), ILIAS\Survey\InternalDomainService\access(), ilObject\getRefId(), ilObjSurvey\getSurveyId(), and ILIAS\Repository\lng().

46  {
47  $this->data = $data;
48  $this->code_repo = $code_repo;
49  $this->survey_id = $survey->getSurveyId();
50  $this->survey_ref_id = $survey->getRefId();
51  $this->access = $domain_service->access(
52  $survey->getRefId(),
53  $user_id
54  );
55  $this->lng = $domain_service->lng();
56  }
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ILIAS\Survey\Code\CodeManager::add ( Code  $code)

Saves a survey access code for a registered user to the database.

Exceptions

Definition at line 106 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\$code_repo, ILIAS\Survey\Code\CodeDBRepo\add(), ILIAS\Survey\Code\Code\getCode(), ILIAS\Survey\Code\Code\getEmail(), ILIAS\Survey\Code\Code\getFirstName(), ILIAS\Survey\Code\Code\getLastName(), ILIAS\Survey\Code\Code\getSent(), ILIAS\Survey\Code\Code\getTimestamp(), and ILIAS\Survey\Code\Code\getUserId().

108  : int {
109  //$this->checkPermission();
110  $repo = $this->code_repo;
111  return $repo->add(
112  $this->survey_id,
113  $code->getCode(),
114  $code->getUserId(),
115  $code->getEmail(),
116  $code->getLastName(),
117  $code->getFirstName(),
118  $code->getSent(),
119  $code->getTimestamp()
120  );
121  }
add(int $survey_id, string $code="", int $user_id=0, string $email="", string $last_name="", string $first_name="", int $sent=0, int $tstamp=0)
Saves a survey access code for a registered user to the database.
+ Here is the call graph for this function:

◆ addCodes()

ILIAS\Survey\Code\CodeManager::addCodes ( int  $nr)

Add multiple new codes.

Parameters
int$nrnumber of codes that should be generated/added
Returns
int[]
Exceptions

Definition at line 130 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\checkPermission().

130  : array
131  {
132  $this->checkPermission();
133  return $this->code_repo->addCodes($this->survey_id, $nr);
134  }
+ Here is the call graph for this function:

◆ bindUser()

ILIAS\Survey\Code\CodeManager::bindUser ( string  $code,
int  $user_id 
)

Bind registered user to a code.

Exceptions

Definition at line 183 of file class.CodeManager.php.

References ANONYMOUS_USER_ID.

186  : void {
187  if ($user_id === ANONYMOUS_USER_ID) {
188  return;
189  }
190  $this->code_repo->bindUser($this->survey_id, $code, $user_id);
191  }
const ANONYMOUS_USER_ID
Definition: constants.php:27

◆ checkPermission()

ILIAS\Survey\Code\CodeManager::checkPermission ( )
protected
Exceptions

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

References ILIAS\Repository\access(), and ILIAS\Repository\lng().

Referenced by ILIAS\Survey\Code\CodeManager\addCodes(), ILIAS\Survey\Code\CodeManager\delete(), ILIAS\Survey\Code\CodeManager\deleteAll(), ILIAS\Survey\Code\CodeManager\getAll(), ILIAS\Survey\Code\CodeManager\getAllData(), and ILIAS\Survey\Code\CodeManager\updateExternalData().

61  : void
62  {
63  if (!$this->access->canManageCodes()) {
64  throw new \ilPermissionException($this->lng->txt("permission_denied") .
65  " (" . $this->survey_ref_id . ")");
66  }
67  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ILIAS\Survey\Code\CodeManager::delete ( string  $code)

Delete single code.

Exceptions

Definition at line 86 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\$code_repo, ILIAS\Survey\Code\CodeManager\checkPermission(), and ILIAS\Survey\Code\CodeDBRepo\delete().

86  : void
87  {
88  $this->checkPermission();
89  $repo = $this->code_repo;
90  $repo->delete($this->survey_id, $code);
91  }
delete(int $survey_id, string $code)
Delete single code.
+ Here is the call graph for this function:

◆ deleteAll()

ILIAS\Survey\Code\CodeManager::deleteAll ( bool  $force = false)

Delete all codes of survey.

Exceptions

Definition at line 73 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\$code_repo, ILIAS\Survey\Code\CodeManager\checkPermission(), and ILIAS\Survey\Code\CodeDBRepo\deleteAll().

73  : void
74  {
75  if (!$force) {
76  $this->checkPermission();
77  }
78  $repo = $this->code_repo;
79  $repo->deleteAll($this->survey_id);
80  }
deleteAll(int $survey_id)
Delete all codes of a survey.
+ Here is the call graph for this function:

◆ exists()

ILIAS\Survey\Code\CodeManager::exists ( string  $code)

Does code exist in survey?

Definition at line 96 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\$code_repo, and ILIAS\Survey\Code\CodeDBRepo\exists().

96  : bool
97  {
98  $repo = $this->code_repo;
99  return $repo->exists($this->survey_id, $code);
100  }
exists(int $survey_id, string $code)
Does code exist in survey?
+ Here is the call graph for this function:

◆ getAll()

ILIAS\Survey\Code\CodeManager::getAll ( )

Get all access keys of a survey.

Returns
string[]
Exceptions

Definition at line 162 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\checkPermission().

162  : array
163  {
164  $this->checkPermission();
165  return $this->code_repo->getAll($this->survey_id);
166  }
+ Here is the call graph for this function:

◆ getAllData()

ILIAS\Survey\Code\CodeManager::getAllData ( )

Get all codes of a survey.

Returns
Code[]
Exceptions

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

References ILIAS\Survey\Code\CodeManager\checkPermission().

173  : array
174  {
175  $this->checkPermission();
176  return $this->code_repo->getAllData($this->survey_id);
177  }
+ Here is the call graph for this function:

◆ getByCodeId()

ILIAS\Survey\Code\CodeManager::getByCodeId ( int  $code_id)

Definition at line 202 of file class.CodeManager.php.

204  : string {
205  return $this->code_repo->getByCodeId($this->survey_id, $code_id);
206  }

◆ getByUserId()

ILIAS\Survey\Code\CodeManager::getByUserId ( int  $user_id)

Get access key for a registered user.

Definition at line 196 of file class.CodeManager.php.

198  : string {
199  return $this->code_repo->getByUserId($this->survey_id, $user_id);
200  }

◆ getByUserKey()

ILIAS\Survey\Code\CodeManager::getByUserKey ( string  $user_key)

Get code object for an access key.

Definition at line 211 of file class.CodeManager.php.

211  : ?Code
212  {
213  return $this->code_repo->getByUserKey($this->survey_id, $user_key);
214  }

◆ updateExternalData()

ILIAS\Survey\Code\CodeManager::updateExternalData ( int  $code_id,
string  $email,
string  $last_name,
string  $first_name,
int  $sent 
)

Update external data of a code.

Exceptions

Definition at line 140 of file class.CodeManager.php.

References ILIAS\Survey\Code\CodeManager\checkPermission().

146  : bool {
147  $this->checkPermission();
148  return $this->code_repo->updateExternalData(
149  $code_id,
150  $email,
151  $last_name,
152  $first_name,
153  $sent
154  );
155  }
+ Here is the call graph for this function:

Field Documentation

◆ $access

AccessManager ILIAS\Survey\Code\CodeManager::$access
protected

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

◆ $code_repo

◆ $data

InternalDataService ILIAS\Survey\Code\CodeManager::$data
protected

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

Referenced by ILIAS\Survey\Code\CodeManager\__construct().

◆ $lng

ilLanguage ILIAS\Survey\Code\CodeManager::$lng
protected

Definition at line 38 of file class.CodeManager.php.

◆ $survey_id

int ILIAS\Survey\Code\CodeManager::$survey_id
protected

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

◆ $survey_ref_id

int ILIAS\Survey\Code\CodeManager::$survey_ref_id = 0
protected

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


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