refactoring
This commit is contained in:
parent
2ce96573c0
commit
57d5e1ce3f
|
@ -98,8 +98,12 @@ abstract class baseModule {
|
|||
$this->scope = $scope;
|
||||
// load configuration
|
||||
if ($this->can_manage() || ($scope == 'none')) {
|
||||
if (isset($_SESSION['config'])) $this->moduleSettings = $_SESSION['config']->get_moduleSettings();
|
||||
if (isset($_SESSION['selfServiceProfile'])) $this->selfServiceSettings = $_SESSION['selfServiceProfile'];
|
||||
if (isset($_SESSION['config'])) {
|
||||
$this->moduleSettings = $_SESSION['config']->get_moduleSettings();
|
||||
}
|
||||
if (isset($_SESSION['selfServiceProfile'])) {
|
||||
$this->selfServiceSettings = $_SESSION['selfServiceProfile'];
|
||||
}
|
||||
// initialize module
|
||||
$this->load_Messages();
|
||||
$this->meta = $this->get_metaData();
|
||||
|
@ -415,8 +419,7 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function is_base_module() {
|
||||
if (isset($this->meta['is_base']) && ($this->meta['is_base'] == true)) return true;
|
||||
else return false;
|
||||
return (isset($this->meta['is_base']) && ($this->meta['is_base']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -436,8 +439,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function get_ldap_filter($typeId) {
|
||||
if (isset($this->meta['ldap_filter'])) return $this->meta['ldap_filter'];
|
||||
else return "";
|
||||
if (isset($this->meta['ldap_filter'])) {
|
||||
return $this->meta['ldap_filter'];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -454,8 +459,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function get_alias() {
|
||||
if (isset($this->meta['alias'])) return $this->meta['alias'];
|
||||
else return get_class($this);
|
||||
if (isset($this->meta['alias'])) {
|
||||
return $this->meta['alias'];
|
||||
}
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -475,8 +482,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function get_RDNAttributes($typeId) {
|
||||
if (isset($this->meta['RDN'])) return $this->meta['RDN'];
|
||||
else return array();
|
||||
if (isset($this->meta['RDN'])) {
|
||||
return $this->meta['RDN'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,8 +507,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function get_dependencies() {
|
||||
if (isset($this->meta['dependencies'])) return $this->meta['dependencies'];
|
||||
else return array('depends' => array(), 'conflicts' => array());
|
||||
if (isset($this->meta['dependencies'])) {
|
||||
return $this->meta['dependencies'];
|
||||
}
|
||||
return array('depends' => array(), 'conflicts' => array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -519,8 +530,10 @@ abstract class baseModule {
|
|||
* @see htmlElement
|
||||
*/
|
||||
public function get_profileOptions($typeId) {
|
||||
if (isset($this->meta['profile_options'])) return $this->meta['profile_options'];
|
||||
else return array();
|
||||
if (isset($this->meta['profile_options'])) {
|
||||
return $this->meta['profile_options'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -557,7 +570,9 @@ abstract class baseModule {
|
|||
// check by regular expression (from account.inc)
|
||||
case "ext_preg":
|
||||
// ignore empty fileds
|
||||
if ($options[$identifiers[$i]][0] == '') continue;
|
||||
if ($options[$identifiers[$i]][0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (! get_preg($options[$identifiers[$i]][0], $this->meta['profile_checks'][$identifiers[$i]]['regex'])) {
|
||||
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||
}
|
||||
|
@ -565,7 +580,9 @@ abstract class baseModule {
|
|||
// check by regular expression (case insensitive)
|
||||
case 'regex_i':
|
||||
// ignore empty fileds
|
||||
if ($options[$identifiers[$i]][0] == '') continue;
|
||||
if ($options[$identifiers[$i]][0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (! preg_match('/' . $this->meta['profile_checks'][$identifiers[$i]]['regex'] . '/i', $options[$identifiers[$i]][0])) {
|
||||
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||
}
|
||||
|
@ -573,7 +590,9 @@ abstract class baseModule {
|
|||
// check by regular expression (case sensitive)
|
||||
case 'regex':
|
||||
// ignore empty fileds
|
||||
if ($options[$identifiers[$i]][0] == '') continue;
|
||||
if ($options[$identifiers[$i]][0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (! preg_match('/' . $this->meta['profile_checks'][$identifiers[$i]]['regex'] . '/', $options[$identifiers[$i]][0])) {
|
||||
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||
}
|
||||
|
@ -581,7 +600,9 @@ abstract class baseModule {
|
|||
// check by integer comparison (greater)
|
||||
case 'int_greater':
|
||||
// ignore if both fields are empty
|
||||
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
|
||||
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
continue;
|
||||
}
|
||||
// print error message if only one field is empty
|
||||
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||
|
@ -595,7 +616,9 @@ abstract class baseModule {
|
|||
// check by integer comparison (greater or equal)
|
||||
case 'int_greaterOrEqual':
|
||||
// ignore if both fields are empty
|
||||
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
|
||||
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
continue;
|
||||
}
|
||||
// print error message if only one field is empty
|
||||
if (($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['profile_checks'][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
$messages[] = $this->meta['profile_checks'][$identifiers[$i]]['error_message'];
|
||||
|
@ -714,7 +737,9 @@ abstract class baseModule {
|
|||
// check by regular expression (from account.inc)
|
||||
case "ext_preg":
|
||||
// ignore empty fileds
|
||||
if ($options[$identifiers[$i]][0] == '') continue;
|
||||
if ($options[$identifiers[$i]][0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (! get_preg($options[$identifiers[$i]][0], $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'])) {
|
||||
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
|
||||
}
|
||||
|
@ -722,7 +747,9 @@ abstract class baseModule {
|
|||
// check by regular expression (case insensitive)
|
||||
case "regex_i":
|
||||
// ignore empty fileds
|
||||
if ($options[$identifiers[$i]][0] == '') continue;
|
||||
if ($options[$identifiers[$i]][0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (! preg_match('/' . $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'] . '/i', $options[$identifiers[$i]][0])) {
|
||||
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
|
||||
}
|
||||
|
@ -730,7 +757,9 @@ abstract class baseModule {
|
|||
// check by regular expression (case sensitive)
|
||||
case "regex":
|
||||
// ignore empty fileds
|
||||
if ($options[$identifiers[$i]][0] == '') continue;
|
||||
if ($options[$identifiers[$i]][0] == '') {
|
||||
continue;
|
||||
}
|
||||
if (! preg_match('/' . $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['regex'] . '/', $options[$identifiers[$i]][0])) {
|
||||
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
|
||||
}
|
||||
|
@ -738,7 +767,9 @@ abstract class baseModule {
|
|||
// check by integer comparison (greater)
|
||||
case "int_greater":
|
||||
// ignore if both fields are empty
|
||||
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
|
||||
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
continue;
|
||||
}
|
||||
// print error message if only one field is empty
|
||||
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
|
||||
|
@ -752,7 +783,9 @@ abstract class baseModule {
|
|||
// check by integer comparison (greater or equal)
|
||||
case "int_greaterOrEqual":
|
||||
// ignore if both fields are empty
|
||||
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) continue;
|
||||
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') && ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
continue;
|
||||
}
|
||||
// print error message if only one field is empty
|
||||
if (($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name1']][0] == '') || ($options[$this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['cmp_name2']][0] == '')) {
|
||||
$messages[] = $this->meta['config_checks'][$scopes[$s]][$identifiers[$i]]['error_message'];
|
||||
|
@ -889,8 +922,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function get_uploadColumns($selectedModules, &$type) {
|
||||
if (isset($this->meta['upload_columns'])) return $this->meta['upload_columns'];
|
||||
else return array();
|
||||
if (isset($this->meta['upload_columns'])) {
|
||||
return $this->meta['upload_columns'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -905,8 +940,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function get_uploadPreDepends() {
|
||||
if (isset($this->meta['upload_preDepends'])) return $this->meta['upload_preDepends'];
|
||||
else return array();
|
||||
if (isset($this->meta['upload_preDepends'])) {
|
||||
return $this->meta['upload_preDepends'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1684,8 +1721,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getManagedObjectClasses($typeId) {
|
||||
if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) return $this->meta['objectClasses'];
|
||||
else return array();
|
||||
if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) {
|
||||
return $this->meta['objectClasses'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1701,8 +1740,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getLDAPAliases($typeId) {
|
||||
if (isset($this->meta['LDAPaliases']) && is_array($this->meta['LDAPaliases'])) return $this->meta['LDAPaliases'];
|
||||
else return array();
|
||||
if (isset($this->meta['LDAPaliases']) && is_array($this->meta['LDAPaliases'])) {
|
||||
return $this->meta['LDAPaliases'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1715,8 +1756,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getManagedAttributes($typeId) {
|
||||
if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) return $this->meta['attributes'];
|
||||
else return array();
|
||||
if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) {
|
||||
return $this->meta['attributes'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1728,8 +1771,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getManagedHiddenAttributes($typeId) {
|
||||
if (isset($this->meta['hiddenAttributes']) && is_array($this->meta['hiddenAttributes'])) return $this->meta['hiddenAttributes'];
|
||||
else return array();
|
||||
if (isset($this->meta['hiddenAttributes']) && is_array($this->meta['hiddenAttributes'])) {
|
||||
return $this->meta['hiddenAttributes'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1742,8 +1787,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getRequiredExtensions() {
|
||||
if (isset($this->meta['extensions']) && is_array($this->meta['extensions'])) return $this->meta['extensions'];
|
||||
else return array();
|
||||
if (isset($this->meta['extensions']) && is_array($this->meta['extensions'])) {
|
||||
return $this->meta['extensions'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1756,8 +1803,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getSelfServiceSearchAttributes() {
|
||||
if (isset($this->meta['selfServiceSearchAttributes']) && is_array($this->meta['selfServiceSearchAttributes'])) return $this->meta['selfServiceSearchAttributes'];
|
||||
else return array();
|
||||
if (isset($this->meta['selfServiceSearchAttributes']) && is_array($this->meta['selfServiceSearchAttributes'])) {
|
||||
return $this->meta['selfServiceSearchAttributes'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1772,8 +1821,10 @@ abstract class baseModule {
|
|||
* @see baseModule::get_metaData()
|
||||
*/
|
||||
public function getSelfServiceFields() {
|
||||
if (isset($this->meta['selfServiceFieldSettings']) && is_array($this->meta['selfServiceFieldSettings'])) return $this->meta['selfServiceFieldSettings'];
|
||||
else return array();
|
||||
if (isset($this->meta['selfServiceFieldSettings']) && is_array($this->meta['selfServiceFieldSettings'])) {
|
||||
return $this->meta['selfServiceFieldSettings'];
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -104,9 +104,15 @@ function checkChmod($right, $target, $chmod) {
|
|||
|
||||
$chmod_num = -1;
|
||||
// owner:
|
||||
if ($target == "owner") $chmod_num = 0;
|
||||
if ($target == "group") $chmod_num = 1;
|
||||
if ($target == "other") $chmod_num = 2;
|
||||
if ($target == "owner") {
|
||||
$chmod_num = 0;
|
||||
}
|
||||
if ($target == "group") {
|
||||
$chmod_num = 1;
|
||||
}
|
||||
if ($target == "other") {
|
||||
$chmod_num = 2;
|
||||
}
|
||||
|
||||
// Cut the number from the chmod:
|
||||
$chmod_num = $chmod{$chmod_num};
|
||||
|
@ -118,10 +124,12 @@ function checkChmod($right, $target, $chmod) {
|
|||
$write = array(2,3,6,7);
|
||||
// What numbers allow "execute"
|
||||
$execute = array(1,3,5,7);
|
||||
if (($right == "read") && in_array($chmod_num, $read)) return true;
|
||||
elseif (($right == "write") && in_array($chmod_num, $write)) return true;
|
||||
elseif (($right == "execute") && in_array($chmod_num, $execute)) return true;
|
||||
else return false;
|
||||
if ((($right == "read") && in_array($chmod_num, $read))
|
||||
|| (($right == "write") && in_array($chmod_num, $write))
|
||||
|| (($right == "execute") && in_array($chmod_num, $execute))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,13 +227,11 @@ function deleteConfigProfile($name) {
|
|||
if (is_dir($subDirs[$i])) {
|
||||
$dirHandle = @opendir($subDirs[$i]);
|
||||
while (false !== ($path = readdir($dirHandle))) {
|
||||
if ($path != '.' && $path != '..') {
|
||||
if (!@unlink($subDirs[$i] . '/' . $path)) {
|
||||
if (($path != '.') && ($path != '..') && !@unlink($subDirs[$i] . '/' . $path)) {
|
||||
logNewMessage(LOG_ERR, 'Unable to delete ' . $subDirs[$i] . '/' . $path);
|
||||
return _("Unable to delete profile!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($dirHandle);
|
||||
if (!@rmdir($subDirs[$i])) {
|
||||
logNewMessage(LOG_ERR, 'Unable to delete ' . $subDirs[$i]);
|
||||
|
@ -283,8 +289,12 @@ function extractConfigOptionsFromPOST($confTypes) {
|
|||
}
|
||||
// checkboxes
|
||||
elseif ($type == "checkbox") {
|
||||
if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = array('true');
|
||||
else $options[$element] = array('false');
|
||||
if (isset($_POST[$element]) && ($_POST[$element] == "on")) {
|
||||
$options[$element] = array('true');
|
||||
}
|
||||
else {
|
||||
$options[$element] = array('false');
|
||||
}
|
||||
}
|
||||
// dropdownbox
|
||||
elseif ($type == "select") {
|
||||
|
@ -340,7 +350,7 @@ function metaRefresh($page) {
|
|||
*/
|
||||
function isAccountTypeHidden($type) {
|
||||
$typeSettings = $_SESSION['config']->get_typeSettings();
|
||||
return isset($typeSettings['hidden_' . $type]) && ($typeSettings['hidden_' . $type] == true);
|
||||
return isset($typeSettings['hidden_' . $type]) && ($typeSettings['hidden_' . $type]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,11 +362,13 @@ function getLanguages() {
|
|||
$languages = array();
|
||||
// loading available languages from language.conf file
|
||||
$languagefile = dirname(__FILE__) . "/../config/language";
|
||||
if(is_file($languagefile) == true) {
|
||||
if(is_file($languagefile)) {
|
||||
$file = fopen($languagefile, "r");
|
||||
while(!feof($file)) {
|
||||
$line = fgets($file, 1024);
|
||||
if($line == "" || $line == "\n" || $line[0] == "#") continue; // ignore comment and empty lines
|
||||
if($line == "" || $line == "\n" || $line[0] == "#") {
|
||||
continue; // ignore comment and empty lines
|
||||
}
|
||||
$value = explode(":", $line);
|
||||
$languages[] = new LAMLanguage($value[0], $value[1], $value[2]);
|
||||
}
|
||||
|
@ -625,9 +637,11 @@ class LAMConfig {
|
|||
*/
|
||||
private function reload() {
|
||||
$conffile = $this->getPath();
|
||||
if (is_file($conffile) == True) {
|
||||
if (is_file($conffile)) {
|
||||
$file = @fopen($conffile, "r");
|
||||
if (!$file) return false; // abort if file is not readable
|
||||
if (!$file) {
|
||||
return false; // abort if file is not readable
|
||||
}
|
||||
while (!feof($file)) {
|
||||
$line = fgets($file, 1000000);
|
||||
$line = trim($line); // remove spaces at the beginning and end
|
||||
|
@ -712,7 +726,9 @@ class LAMConfig {
|
|||
// only return available modules
|
||||
$ret = array();
|
||||
for ($i = 0; $i < sizeof($modules); $i++) {
|
||||
if (in_array($modules[$i], $available)) $ret[] = $modules[$i];
|
||||
if (in_array($modules[$i], $available)) {
|
||||
$ret[] = $modules[$i];
|
||||
}
|
||||
}
|
||||
$this->typeSettings[$moduleVar] = implode(",", $ret);
|
||||
}
|
||||
|
@ -722,7 +738,7 @@ class LAMConfig {
|
|||
/** Saves preferences to config file */
|
||||
public function save() {
|
||||
$conffile = $this->getPath();
|
||||
if (is_file($conffile) == True) {
|
||||
if (is_file($conffile)) {
|
||||
$file = fopen($conffile, "r");
|
||||
$file_array = array();
|
||||
// read config file
|
||||
|
|
Loading…
Reference in New Issue