ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 372 of file class.ilIniFile.php.

373 {
374 if ($this->groupExists($a_group_name))
375 {
376 $this->error("Group '".$a_group_name."' exists");
377 return false;
378 }
379
380 $this->GROUPS[$a_group_name] = array();
381 return true;
382 }
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 458 of file class.ilIniFile.php.

459 {
460 $this->ERROR = $a_errmsg;
461
462 return true;
463 }

Referenced by ilPurchaseBaseGUI\__construct(), Mail_RFC822\_hasUnclosedBrackets(), Mail_RFC822\_splitAddresses(), Mail_RFC822\_splitCheck(), Mail_RFC822\_validateAddress(), ilPaymentCouponGUI\addCoupon(), addGroup(), ilDBUpdate\applyCustomUpdates(), ilDBUpdate\applyHotfix(), ilDBUpdate\applyUpdate(), ilDBUpdate\applyUpdateNr(), SMTP\authenticate(), ilClient\checkDatabaseHost(), ilSetup\checkDataDirSetup(), ilSetup\checkLogSetup(), ilSetup\checkPasswordSetup(), ilSetup\checkToolsSetup(), ilSetup\cloneFromSource(), SMTP\connect(), ilClient\connect(), ilClient\create(), ilSetup\createDatabase(), ilObjPaymentSettingsGUI\editVendorObject(), ilDBUpdate\execQuery(), ilPurchaseBaseGUI\getBill(), ilPurchaseBMFGUI\getCreditCard(), ilPurchaseBMFGUI\getDebitEntry(), ilClient\getError(), ilSetup\getError(), ilPurchaseBMFGUI\getPaymentType(), ilPurchaseBaseGUI\getPersonalData(), ilPurchaseBMFGUI\getPersonalData(), ilIniFile\ilIniFile(), ilClient\init(), ilSetup\init(), ilObjPaymentSettingsGUI\InvoiceNumberObject(), ilSetup\loginAsClient(), ilSetup\newClient(), ilIniFile\parse(), Mail_RFC822\parseAddressList(), ilObjPaymentSettingsGUI\performEditVendorObject(), php4DOMDocument\php4DOMDocument(), SMTP\quit(), OLERead\read(), ilIniFile\read(), ilDBUpdate\readDBUpdateFile(), readGroup(), ilDBUpdate\readLastUpdateFile(), readVariable(), removeGroup(), ilPaymentCouponGUI\saveCouponForm(), ilObjPaymentSettingsGUI\saveInvoiceNumberObject(), ilSetup\saveMasterSetup(), ilSetup\saveNewClient(), ilObjPaymentSettingsGUI\savePaypalSettingsObject(), SMTP\sendCommand(), ilExternalFeed\setError(), SMTP\setError(), ilSetup\setPassword(), setVariable(), ilPurchaseBMFGUI\showCreditCard(), ilPurchaseBMFGUI\showDebitEntry(), ilPurchaseBMFGUI\showPaymentType(), ilPurchaseBaseGUI\showPersonalData(), ilPurchaseBMFGUI\showPersonalData(), SMTP\turn(), ilSetup\updateMasterSettings(), and ilIniFile\write().

+ Here is the caller graph for this function:

◆ getError()

getError ( )

returns error @access public

Returns
string

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

471 {
472 return $this->ERROR;
473 }

References ilIniFile\$ERROR.

◆ getGroupCount()

getGroupCount ( )

returns number of groups @access public

Returns
integer

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

312 {
313 return count($this->GROUPS);
314 }

◆ groupExists()

groupExists (   $a_group_name)

checks if a group exists @access public

Parameters
stringgroup name
Returns
boolean

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

340 {
341 if (!isset($this->GROUPS[$a_group_name]))
342 {
343 return false;
344 }
345
346 return true;
347 }

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 355 of file class.ilIniFile.php.

356 {
357 if (!$this->groupExists($a_group_name))
358 {
359 $this->error("Group '".$a_group_name."' does not exist");
360 return false;
361 }
362
363 return $this->GROUPS[$a_group_name];
364 }

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 321 of file class.ilIniFile.php.

322 {
323 $groups = array();
324
325 for (reset($this->GROUPS);$key=key($this->GROUPS);next($this->GROUPS))
326 {
327 $groups[]=$key;
328 }
329
330 return $groups;
331 }

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 422 of file class.ilIniFile.php.

423 {
424 if (!isset($this->GROUPS[$a_group][$a_var_name]))
425 {
426 $this->error("'".$a_var_name."' does not exist in '".$a_group."'");
427 return false;
428 }
429
430 return trim($this->GROUPS[$a_group][$a_var_name]);
431 }

References error().

Referenced by ilSoapInstallationInfoXMLWriter\__buildInstallationInfo(), 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 390 of file class.ilIniFile.php.

391 {
392 if (!$this->groupExists($a_group_name))
393 {
394 $this->error("Group '".$a_group_name."' does not exist");
395 return false;
396 }
397
398 unset($this->GROUPS[$a_group_name]);
399 return true;
400 }

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 441 of file class.ilIniFile.php.

442 {
443 if (!$this->groupExists($a_group_name))
444 {
445 $this->error("Group '".$a_group_name."' does not exist");
446 return false;
447 }
448
449 $this->GROUPS[$a_group_name][$a_var_name] = $a_var_value;
450 return true;
451 }

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 272 of file class.ilIniFile.php.

273 {
274 $groups = $this->readGroups();
275 $group_cnt = count($groups);
276
277 //clear content
278 $content = "";
279
280 // go through all groups
281 for ($i=0; $i<$group_cnt; $i++)
282 {
283 $group_name = $groups[$i];
284 //prevent empty line at beginning of ini-file
285 if ($i==0)
286 {
287 $content = sprintf("[%s]\n",$group_name);
288 }
289 else
290 {
291 $content .= sprintf("\n[%s]\n",$group_name);
292 }
293
294 $group = $this->readGroup($group_name);
295
296 //go through group an display all variables
297 for (reset($group); $key=key($group);next($group))
298 {
299 $content .= sprintf("%s = %s\n",$key,$group[$key]);
300 }
301 }
302
303 return $content;
304 }
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

References readGroup(), and readGroups().

Referenced by ilPersonalDesktopGUI\executeCommand(), ilPersonalDesktopGUI\removeMember(), 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 409 of file class.ilIniFile.php.

410 {
411 return isset($this->GROUPS[$a_group][$a_var_name]);
412 }