ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilIniFile.php File Reference

Go to the source code of this file.

Data Structures

class  ilIniFile
 INIFile Parser. More...
 

Functions

 show ()
 returns the content of IniFile @access public More...
 
 getGroupCount ()
 returns number of groups @access public More...
 
 readGroups ()
 returns an array with the names of all the groups @access public More...
 
 groupExists ($a_group_name)
 checks if a group exists @access public More...
 
 readGroup ($a_group_name)
 returns an associative array of the variables in one group @access public More...
 
 addGroup ($a_group_name)
 adds a new group @access public More...
 
 removeGroup ($a_group_name)
 removes a group @access public More...
 
 variableExists ($a_group, $a_var_name)
 returns if a variable exists or not @access public More...
 
 readVariable ($a_group, $a_var_name)
 reads a single variable from a group @access public More...
 
 setVariable ($a_group_name, $a_var_name, $a_var_value)
 sets a variable in a group @access public More...
 
 error ($a_errmsg)
 set error message @access public More...
 
 getError ()
 returns error @access public More...
 

Function Documentation

◆ addGroup()

addGroup (   $a_group_name)

adds a new group @access public

Parameters
stringgroup name
Returns
boolean

Definition at line 313 of file class.ilIniFile.php.

314 {
315 if ($this->groupExists($a_group_name)) {
316 $this->error("Group '" . $a_group_name . "' exists");
317 return false;
318 }
319
320 $this->GROUPS[$a_group_name] = array();
321 return true;
322 }
groupExists($a_group_name)
checks if a group exists @access public
error($a_errmsg)
set error message @access public

References error(), and groupExists().

+ Here is the call graph for this function:

◆ error()

error (   $a_errmsg)

set error message @access public

Parameters
string

Definition at line 395 of file class.ilIniFile.php.

396 {
397 $this->ERROR = $a_errmsg;
398
399 return true;
400 }

Referenced by ilFileDataForum\__checkReadWrite(), ilFileDataForumDrafts\__checkReadWrite(), ilBookmark\__construct(), ilBookmarkFolder\__construct(), ilAdministrationCommandGUI\__construct(), ilObjSystemFolderGUI\__construct(), ilObjObjectFolderGUI\__construct(), ilObjTypeDefinitionGUI\__construct(), ilObjMediaCastGUI\__construct(), ilObjSCORM2004LearningModuleGUI\__construct(), ilObjWikiGUI\__construct(), ilObjCategoryGUI\__construct(), ilObjForumGUI\__construct(), ilObjLearningResourcesSettingsGUI\__construct(), ilObjMediaCastSettingsGUI\__construct(), ilObjAccessibilitySettingsGUI\__construct(), ilContainerGUI\__construct(), ilContainerReferenceGUI\__construct(), ilObjMediaObjectsSettingsGUI\__construct(), ilObjNewsSettingsGUI\__construct(), ilObjPersonalDesktopSettingsGUI\__construct(), ilObjRepositorySettingsGUI\__construct(), ilObjSkillManagementGUI\__construct(), ilObjTaggingSettingsGUI\__construct(), ilObjMediaObjectGUI\__construct(), ilObjFolderGUI\__construct(), ilObjContentObjectGUI\__construct(), ilObjGlossaryGUI\__construct(), ilObjFileBasedLMGUI\__construct(), ilObjCertificateSettingsGUI\__construct(), ilObjGlossary\__construct(), ilObjContentObject\__construct(), ilObjSCORM2004LearningModule\__construct(), ilObjItemGroupGUI\__construct(), ilObjMediaPoolGUI\__construct(), ilObjWikiSettingsGUI\__construct(), ilObjHelpSettingsGUI\__construct(), ilContainer\__construct(), ilObject\__construct(), ilIniFile\__construct(), ilFileDataForum\__construct(), ilObjectCopyGUI\__construct(), ilPageContentGUI\__construct(), ilObjectActivationGUI\__construct(), ilSCORM2004ScoGUI\__construct(), ilExplorer\__construct(), ilPasteIntoMultipleItemsExplorer\__construct(), ilCategoryXmlParser\__construct(), ilContainerReferenceXmlParser\__construct(), Slim\Http\UploadedFile\__construct(), ilFolderXmlParser\__construct(), ilFileDataForumDrafts\__construct(), php4DOMDocument\__construct(), ilMailSearchCoursesGUI\__construct(), ilMailSearchGroupsGUI\__construct(), ilStructureObjectGUI\__construct(), ilForum\__construct(), ilForumExportGUI\__construct(), ilForumModeratorsGUI\__construct(), ilGlossaryEditorGUI\__construct(), ilGlossaryPresentationGUI\__construct(), ilHTLMEditorGUI\__construct(), ilHTLMPresentationGUI\__construct(), ilLMEditorGUI\__construct(), ilLMPresentationGUI\__construct(), ilObjSurveyQuestionPoolGUI\__construct(), ilAdministrationGUI\__construct(), ilBookmarkAdministrationGUI\__construct(), ilEditClipboardGUI\__construct(), ilContactGUI\__construct(), ilMailingListsGUI\__construct(), ilObjectActivation\__construct(), ilPersonalDesktopGUI\__construct(), ilRepositoryGUI\__construct(), ilMailTemplateGUI\__construct(), ILIAS\Validation\Constraints\Custom\__construct(), Mail_RFC822\_hasUnclosedBrackets(), Mail_RFC822\_splitAddresses(), Mail_RFC822\_splitCheck(), Mail_RFC822\_validateAddress(), addGroup(), ilObjForumGUI\addThreadObject(), ilContactGUI\applyContactsTableFilter(), ilDBUpdate\applyCustomUpdates(), ilDBUpdate\applyHotfix(), ilDBUpdate\applyUpdate(), ilDBUpdate\applyUpdateNr(), ilObjForumGUI\askForPostActivationObject(), SMTP\authenticate(), ilContactGUI\changeContactsView(), ilSetup\checkDataDirSetup(), ilObjForumGUI\checkDraftAccess(), ilSetup\checkErrorLogSetup(), ilSetup\checkLogSetup(), ilSetup\checkPasswordSetup(), ilSetup\checkToolsSetup(), ilSetup\cloneFromSource(), ilMailTemplateGUI\confirmDeleteTemplate(), ilObjForumGUI\confirmDeleteThreads(), ilObjForumGUI\confirmMergeThreadsObject(), ilObjTermsOfServiceGUI\confirmReset(), SMTP\connect(), ilClient\connect(), ilClient\create(), ilSetup\createDatabase(), ilObjForumGUI\createThreadObject(), ilObjForumGUI\deleteSelectedDraft(), ilMailTemplateGUI\deleteTemplate(), ilObjForumGUI\deliverZipFileObject(), ilObjForumGUI\editThreadDraftObject(), ilObjForumGUI\editThreadObject(), ilForumExportGUI\ensureThreadBelongsToForum(), ilObjForumGUI\ensureThreadBelongsToForum(), ilDBUpdate\execQuery(), ilObjBibliographicAdminLibrariesGUI\executeCommand(), ilObjForumGUI\executeCommand(), ilObjCertificateSettingsGUI\executeCommand(), ilContactGUI\executeCommand(), ilMailingListsGUI\executeCommand(), ilMailSearchCoursesGUI\executeCommand(), ilMailSearchGroupsGUI\executeCommand(), ilForumExportGUI\exportHTML(), SimpleSAML\Logger\flush(), ilObjForumGUI\getContent(), ilClient\getError(), ilSetup\getError(), ILIAS\Validation\Constraints\Custom\getErrorMessage(), SimpleSAML\Metadata\Sources\MDQ\getParsedSet(), ilObjForumGUI\infoScreen(), ilClient\init(), ilSetup\init(), ilMailTemplateGUI\insertTemplate(), CAS_Client\isAuthenticated(), GuzzleHttp\Psr7\UploadedFile\isOk(), ilSetup\loginAsClient(), ilContactGUI\mailToUsers(), ilObjForumGUI\markAllReadObject(), ilObjForumGUI\markPostReadObject(), ilObjForumGUI\markPostUnreadObject(), ilObjForumGUI\mergeThreadsObject(), ilObjForumGUI\moveThreadsObject(), ilSetup\newClient(), ilIniFile\parse(), Mail_RFC822\parseAddressList(), ilMailingListsGUI\performDeleteMembers(), ilObjForumGUI\performDeleteThreadsObject(), ilObjForumGUI\performMergeThreadsObject(), ilObjForumGUI\performMoveThreadsObject(), ilObjForumGUI\performPostActivationObject(), ilObjForumGUI\performThreadsActionObject(), ilForumExportGUI\printPost(), ilForumExportGUI\printThread(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\publishThreadDraftObject(), SMTP\quit(), ilObjForumGUI\quotePostObject(), ilIniFile\read(), ilDBUpdate\readDBUpdateFile(), readGroup(), ilDBUpdate\readLastUpdateFile(), readVariable(), removeGroup(), ilObjTermsOfServiceGUI\reset(), ilContactGUI\resetContactsTableFilter(), ilMailingListsGUI\saveAssignmentForm(), ilMailingListsGUI\saveForm(), ilSetup\saveMasterSetup(), ilSetup\saveNewClient(), ilObjTermsOfServiceGUI\saveSettings(), ilObjForumGUI\saveThreadAsDraftObject(), ilObjForumGUI\saveThreadSortingObject(), IMSGlobal\LTI\HTTPMessage\send(), SMTP\sendCommand(), ilExternalFeed\setError(), GuzzleHttp\Psr7\UploadedFile\setError(), ilChatroomServerConnectorMock\setError(), ilClient\setError(), SMTP\setError(), ilForum\setForumId(), ilForum\setForumRefId(), ilSetup\setPassword(), ilObjTermsOfServiceGUI\settings(), setVariable(), ilObjTermsOfServiceGUI\showAcceptanceHistory(), ilObjTermsOfServiceGUI\showAgreementByLanguage(), ilMailingListsGUI\showAssignmentForm(), ilContactGUI\showContacts(), ilMailingListsGUI\showForm(), ilObjForumGUI\showStatisticsObject(), ilObjForumGUI\toggleStickinessObject(), ilObjForumGUI\toggleThreadNotificationObject(), SMTP\turn(), ilSetup\updateMasterSettings(), ilMailTemplateGUI\updateTemplate(), ilObjForumGUI\updateThreadDraftObject(), ilObjForumGUI\updateThreadObject(), and ilIniFile\write().

+ Here is the caller graph for this function:

◆ getError()

getError ( )

returns error @access public

Returns
string

Definition at line 407 of file class.ilIniFile.php.

408 {
409 return $this->ERROR;
410 }

References ilIniFile\$ERROR.

Referenced by trendClass\calculate().

+ Here is the caller graph for this function:

◆ getGroupCount()

getGroupCount ( )

returns number of groups @access public

Returns
integer

Definition at line 255 of file class.ilIniFile.php.

256 {
257 return count($this->GROUPS);
258 }

◆ groupExists()

groupExists (   $a_group_name)

checks if a group exists @access public

Parameters
stringgroup name
Returns
boolean

Definition at line 282 of file class.ilIniFile.php.

283 {
284 if (!isset($this->GROUPS[$a_group_name])) {
285 return false;
286 }
287
288 return true;
289 }

Referenced by addGroup(), readGroup(), removeGroup(), and setVariable().

+ Here is the caller graph for this function:

◆ readGroup()

readGroup (   $a_group_name)

returns an associative array of the variables in one group @access public

Parameters
stringgroup name
Returns
mixed return array of values or boolean 'false' on failure

Definition at line 297 of file class.ilIniFile.php.

298 {
299 if (!$this->groupExists($a_group_name)) {
300 $this->error("Group '" . $a_group_name . "' does not exist");
301 return false;
302 }
303
304 return $this->GROUPS[$a_group_name];
305 }

References error(), and groupExists().

Referenced by show(), and ilIniFile\write().

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

◆ readGroups()

readGroups ( )

returns an array with the names of all the groups @access public

Returns
array groups

Definition at line 265 of file class.ilIniFile.php.

266 {
267 $groups = array();
268
269 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS)) {
270 $groups[]=$key;
271 }
272
273 return $groups;
274 }
$key
Definition: croninfo.php:18

References $key.

Referenced by show(), and ilIniFile\write().

+ Here is the caller graph for this function:

◆ readVariable()

readVariable (   $a_group,
  $a_var_name 
)

reads a single variable from a group @access public

Parameters
stringgroup name
stringvalue
Returns
mixed return value string or boolean 'false' on failure

Definition at line 361 of file class.ilIniFile.php.

362 {
363 if (!isset($this->GROUPS[$a_group][$a_var_name])) {
364 $this->error("'" . $a_var_name . "' does not exist in '" . $a_group . "'");
365 return false;
366 }
367
368 return trim($this->GROUPS[$a_group][$a_var_name]);
369 }

References error().

Referenced by ilSoapInstallationInfoXMLWriter\__buildInstallationInfo(), ilMail\_getInstallationSignature(), ilUtil\deliverFile(), ilChatroomConfigFileHandler\getClientFileContent(), and ilDB\initFromIniFile().

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

◆ removeGroup()

removeGroup (   $a_group_name)

removes a group @access public

Parameters
stringgroup name
Returns
boolean

Definition at line 330 of file class.ilIniFile.php.

331 {
332 if (!$this->groupExists($a_group_name)) {
333 $this->error("Group '" . $a_group_name . "' does not exist");
334 return false;
335 }
336
337 unset($this->GROUPS[$a_group_name]);
338 return true;
339 }

References error(), and groupExists().

+ Here is the call graph for this function:

◆ setVariable()

setVariable (   $a_group_name,
  $a_var_name,
  $a_var_value 
)

sets a variable in a group @access public

Parameters
string
string
string
Returns
boolean

Definition at line 379 of file class.ilIniFile.php.

380 {
381 if (!$this->groupExists($a_group_name)) {
382 $this->error("Group '" . $a_group_name . "' does not exist");
383 return false;
384 }
385
386 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
387 return true;
388 }

References error(), and groupExists().

+ Here is the call graph for this function:

◆ show()

show ( )

returns the content of IniFile @access public

Returns
string content

Definition at line 221 of file class.ilIniFile.php.

222 {
223 $groups = $this->readGroups();
224 $group_cnt = count($groups);
225
226 //clear content
227 $content = "";
228
229 // go through all groups
230 for ($i=0; $i<$group_cnt; $i++) {
231 $group_name = $groups[$i];
232 //prevent empty line at beginning of ini-file
233 if ($i==0) {
234 $content = sprintf("[%s]\n", $group_name);
235 } else {
236 $content .= sprintf("\n[%s]\n", $group_name);
237 }
238
239 $group = $this->readGroup($group_name);
240
241 //go through group an display all variables
242 for (reset($group); $key=key($group);next($group)) {
243 $content .= sprintf("%s = %s\n", $key, $group[$key]);
244 }
245 }
246
247 return $content;
248 }
sprintf('%.4f', $callTime)
readGroups()
returns an array with the names of all the groups @access public
readGroup($a_group_name)
returns an associative array of the variables in one group @access public
$i
Definition: disco.tpl.php:19

References $i, $key, readGroup(), readGroups(), and sprintf.

Referenced by ilPersonalDesktopGUI\executeCommand(), ilCalendarMonthGUI\getHTML(), ilPersonalDesktopGUI\jumpToMemberships(), ilPersonalDesktopGUI\jumpToSelectedItems(), and ilTemplate\show().

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

◆ variableExists()

variableExists (   $a_group,
  $a_var_name 
)

returns if a variable exists or not @access public

Parameters
stringgroup name
stringvalue
Returns
mixed return true if value exists or false

Definition at line 348 of file class.ilIniFile.php.

349 {
350 return isset($this->GROUPS[$a_group][$a_var_name]);
351 }