Commit 6177ad6b authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes: #2595 The code should follow code guidelines

parent bb225de3
This diff is collapsed.
......@@ -49,12 +49,12 @@ class filterLDAP {
*
* \param array $objectStorage
*/
static function query($parent,$base, $scope, $filter, $attributes, $category, $objectStorage= array(""))
static function query($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = array(""))
{
$config= session::global_get('config');
$ldap= $config->get_ldap_link(TRUE);
$flag= ($scope == "sub")?GL_SUBSEARCH:0;
$result= filterLDAP::get_list($parent,$base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
$config = session::global_get('config');
$ldap = $config->get_ldap_link(TRUE);
$flag = ($scope == "sub"?GL_SUBSEARCH:0);
$result = filterLDAP::get_list($parent, $base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
return $result;
}
......@@ -86,7 +86,7 @@ class filterLDAP {
}
// Store in base - i.e. is a rdn value empty?
$storeOnBase = in_array("",$objectStorage);
$storeOnBase = in_array("", $objectStorage);
$default_method = ($storeOnBase && !($flags & GL_SUBSEARCH))?"ls":"search";
......@@ -99,7 +99,7 @@ class filterLDAP {
} else {
foreach ($objectStorage as $oc) {
$oc = preg_replace('/,$/', '', $oc);
if (!strpos($oc,',')) {
if (!strpos($oc, ',')) {
preg_match('/([^=]+)=(.*)$/', $oc, $m);
if ($flags & GL_SUBSEARCH) {
$bases[$base][] = $m[1].":dn:=".$m[2];
......@@ -162,21 +162,21 @@ class filterLDAP {
}
// Check for size limit exceeded messages for GUI feedback
if (preg_match("/size limit/i", $ldap->get_error())){
if (preg_match("/size limit/i", $ldap->get_error())) {
session::set('limit_exceeded', TRUE);
$limit_exceeded = TRUE;
}
/* Crawl through result entries and perform the migration to the
result array */
while($attrs = $ldap->fetch()) {
$dn= $ldap->getDN();
while ($attrs = $ldap->fetch()) {
$dn = $ldap->getDN();
/* Convert dn into a printable format */
if ($flags & GL_CONVERT){
$attrs["dn"]= convert_department_dn($dn);
if ($flags & GL_CONVERT) {
$attrs["dn"] = convert_department_dn($dn);
} else {
$attrs["dn"]= $dn;
$attrs["dn"] = $dn;
}
/* Skip ACL checks if we are forced to skip those checks */
......
......@@ -41,12 +41,13 @@ class ldapMultiplexer {
*
* \param $object Object LDAP
*/
public function __construct(&$object) {
public function __construct(&$object)
{
/* Store object */
$this->object= $object;
$this->object = $object;
/* Set result resource */
$this->sr= $this->object->getSearchResource();
$this->sr = $this->object->getSearchResource();
}
/*!
......@@ -56,14 +57,15 @@ class ldapMultiplexer {
*
* \param $parameters Parameters for the method
*/
public function __call($methodName, $parameters) {
public function __call($methodName, $parameters)
{
/* Add resource pointer if the mentioned methods are used */
if (preg_match('/^(search|ls|cat|fetch|clearResult|resetResult|count|getDN|recursive_remove|rmdir_recursive|create_missing_trees|import_single_entry|import_complete_ldif)$/', $methodName)){
if (preg_match('/^(search|ls|cat|fetch|clearResult|resetResult|count|getDN|recursive_remove|rmdir_recursive|create_missing_trees|import_single_entry|import_complete_ldif)$/', $methodName)) {
array_unshift($parameters, $this->sr);
}
$class= new ReflectionClass($this->object);
$method= $class->getMethod($methodName);
$class = new ReflectionClass($this->object);
$method = $class->getMethod($methodName);
return $method->invokeArgs($this->object, $parameters);
}
......@@ -73,7 +75,8 @@ class ldapMultiplexer {
*
* \param string $memberName
*/
public function __get($memberName) {
public function __get($memberName)
{
return $this->object->$memberName;
}
......
......@@ -101,7 +101,7 @@ class listing {
$this->registerElementFilter("actions", "listing::filterActions");
// Load exporters
foreach ($class_mapping as $class => $dummy) {
foreach (array_keys($class_mapping) as $class) {
if (preg_match('/Exporter$/', $class)) {
$info = call_user_func(array($class, "getInfo"));
if ($info != NULL) {
......@@ -208,7 +208,7 @@ class listing {
// Fill objectTypes from departments and xml definition
$types = departmentManagement::get_support_departments();
foreach ($types as $class => $data) {
foreach ($types as $data) {
$this->objectTypes[$data['OC']] = array("label" => $data['TITLE'],
"objectClass" => $data['OC'],
"image" => $data['IMG']);
......@@ -509,7 +509,6 @@ class listing {
*/
function update()
{
global $config;
$ui = get_userinfo();
// Take care of base selector
......@@ -529,7 +528,6 @@ class listing {
$refresh = TRUE;
}
// Reset object counter / DN mapping
$this->objectTypeCount = array();
$this->objectDnMapping = array();
......@@ -591,7 +589,7 @@ class listing {
// Override base if we got signals from the navigation elements
$action = "";
foreach ($_POST as $key => $value) {
foreach (array_keys($_POST) as $key) {
if (preg_match('/^(ROOT|BACK|HOME)_x$/', $key, $match)) {
$action = $match[1];
break;
......@@ -970,7 +968,6 @@ class listing {
}
}
// If there's an objectclass definition and we don't have it
// add an empty picture here.
if (isset($action['objectclass'])) {
......@@ -1093,8 +1090,6 @@ class listing {
$enableRoot = FALSE;
}
$listhead = "";
/* Check if we are in users home department */
if (!count($deps) || $this->filter->base == get_base_from_people($ui->dn)) {
$enableHome = FALSE;
......@@ -1165,7 +1160,7 @@ class listing {
}
// Filter POST with "listing_" attributes
foreach ($_POST as $key => $prop) {
foreach (array_keys($_POST) as $key) {
// Capture selections
if (preg_match('/^listing_selected_[0-9]+$/', $key)) {
......@@ -1418,7 +1413,6 @@ class listing {
$ids = $config->idepartments;
$d = $ui->get_module_departments($this->categories);
$k_ids = array_keys($ids);
$deps = array_intersect($d, $k_ids);
// Fill internal bases list
$this->bases = array();
......@@ -1451,7 +1445,7 @@ class listing {
// of current base
$filter = "(&(objectClass=gosaDepartment)(|";
$attrs = array("description", "objectClass");
foreach ($types as $name => $data) {
foreach ($types as $data) {
$filter .= "(objectClass=".$data['OC'].")";
$attrs[] = $data['ATTR'];
}
......@@ -1502,7 +1496,6 @@ class listing {
$paste = $paste || $ui->is_pasteable($this->base, $category) == 1;
}
// Draw entries that allow copy and cut
if ($read) {
// Copy entry
......
This diff is collapsed.
......@@ -31,7 +31,7 @@ class setup
var $o_steps = array();
var $captured_values = array();
function setup()
function __construct()
{
$i = 1;
$this->o_steps[$i++] = new Step_Welcome();
......
......@@ -22,12 +22,12 @@
class Step_Checks extends setup_step
{
var $basic_checks = array();
var $config_checks= array();
var $is_writeable = array();
var $header_image = "images/setup/system.png";
var $basic_checks = array();
var $config_checks = array();
var $is_writeable = array();
var $header_image = "images/setup/system.png";
function Step_Checks()
function __construct()
{
$this->update_strings();
}
......@@ -46,10 +46,10 @@ class Step_Checks extends setup_step
{
$this->run_checks();
$smarty = get_smarty();
$smarty->assign("basic" ,$this->basic_checks);
$smarty->assign("config" ,$this->config_checks);
$smarty->assign("is_writeable",$this->is_writeable);
return($smarty->fetch(get_template_path("setup_checks.tpl",TRUE,dirname(__FILE__))));
$smarty->assign("basic", $this->basic_checks);
$smarty->assign("config", $this->config_checks);
$smarty->assign("is_writeable", $this->is_writeable);
return $smarty->fetch(get_template_path("setup_checks.tpl", TRUE, dirname(__FILE__)));
}
......@@ -142,9 +142,8 @@ class Step_Checks extends setup_step
$IMGVER = phpversion('imagick');
if ($IMGVER > 1.0) {
$R = method_exists('imagick','getImageBlob');
}
else {
$R = method_exists('imagick', 'getImageBlob');
} else {
$R = is_callable("imagick_blob2image") || !empty($output);
}
......@@ -208,7 +207,7 @@ class Step_Checks extends setup_step
$N = "max_execution_time &gt;= <b>30</b>";
$D = _("The Execution time should be at least 30 seconds.");
$S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher.");
$R = ini_get("max_execution_time") >= 30 ;
$R = ini_get("max_execution_time") >= 30;
$M = TRUE;
$this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M );
......@@ -235,10 +234,10 @@ class Step_Checks extends setup_step
/* Check if we can create a config file.*/
$N = _("Configuration writeable");
$D = _("The configuration file can't be written");
$S = sprintf(_("FusionDirectory reads its configuration from a file located in (%s/%s). The setup can write the configuration directly if it is writeable."),CONFIG_DIR,CONFIG_FILE);
$S = sprintf(_("FusionDirectory reads its configuration from a file located in (%s/%s). The setup can write the configuration directly if it is writeable."), CONFIG_DIR, CONFIG_FILE);
/* is there a config file ? or There is none, but can we create a file there ?*/
$R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE))
|| (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR));
$R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE))
|| (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR));
$M = FALSE;
$this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M );
......@@ -248,14 +247,12 @@ class Step_Checks extends setup_step
function save_object()
{
/* If everything is fine, set this step to completed
* and allow switching to next setup step
*/
$failed = false;
foreach(array("basic_checks","config_checks","is_writeable") as $type){
foreach($this->$type as $obj){
if($obj['MUST'] && !$obj['RESULT']){
$failed = true;
* and allow switching to next setup step */
$failed = FALSE;
foreach (array("basic_checks","config_checks","is_writeable") as $type) {
foreach ($this->$type as $obj) {
if ($obj['MUST'] && !$obj['RESULT']) {
$failed = TRUE;
break;
}
}
......@@ -268,9 +265,8 @@ class Step_Checks extends setup_step
with the current version of FusionDirectory */
function check_php_version()
{
return(version_compare(phpversion(),"5.2.0",">="));
return version_compare(phpversion(), "5.2.0", ">=");
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
......@@ -60,7 +60,7 @@ class Step_Config1 extends setup_step
"base_hook","base_hook_active","account_expiration","strict","include_personal_title",
"cngen_active","cngen");
function Step_Config1()
function __construct()
{
$this->update_strings();
......@@ -214,14 +214,7 @@ class Step_Config1 extends setup_step
}
/* base hook settings */
/* if (isset($_POST['base_hook_active'])) {
$this->pwd_rules['base_hook_active'] = TRUE;
if (isset($_POST['base_hook'])) {
$this->pwd_rules['base_hook'] = get_post('base_hook');
}
} else {*/
$this->pwd_rules['base_hook_active'] = FALSE;
/* }*/
$this->pwd_rules['base_hook_active'] = FALSE;
if (isset($_POST['cngen_active'])) {
$this->cngen_active = TRUE;
......
......@@ -39,7 +39,7 @@ class Step_Config2 extends setup_step
var $attributes = array("timezone");
var $called = FALSE;
function Step_Config2()
function __construct()
{
$this->update_strings();
......
......@@ -62,7 +62,7 @@ class Step_Config3 extends setup_step
var $attributes = array("errorlvl");
function Step_Config3()
function __construct()
{
$this->update_strings();
}
......@@ -201,9 +201,6 @@ class Step_Config3 extends setup_step
if ($cv['id_settings']['minid_active']) {
$attrs['fdMinId'] = $cv['id_settings']['minid'];
}
//~ $attrs['fdGosaSharedPrefix'] = "";
//~ $attrs['fdLdapTLS'] = ($cv['tls']?"TRUE":"FALSE");
//~ $attrs['fdHonourIvbbAttributes'] = ($cv['governmentmode']?"TRUE":"FALSE");
$attrs['fdHandleExpiredAccounts'] = ($cv['account_expiration']?"TRUE":"FALSE");
$attrs['fdEnableSnapshots'] = ($cv['generic_settings']['snapshot_active']?"TRUE":"FALSE");
$attrs['fdSnapshotBase'] = $cv['generic_settings']['snapshot_base'];
......
......@@ -23,9 +23,9 @@
class Step_Finish extends setup_step
{
var $cfg_file_written = FALSE;
var $header_image = "images/setup/server.png";
var $header_image = "images/setup/server.png";
function Step_Finish()
function __construct()
{
$this->update_strings();
}
......@@ -42,20 +42,19 @@ class Step_Finish extends setup_step
function get_conf_data()
{
$smarty = get_smarty();
$smarty->assign("cv",xmlentities($this->parent->captured_values));
$smarty->assign("config_checksum", md5(file_get_contents(CONFIG_TEMPLATE_DIR.CONFIG_FILE)));
$str = $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE);
return($str);
$smarty->assign("cv", xmlentities($this->parent->captured_values));
$smarty->assign("config_checksum", md5(file_get_contents(CONFIG_TEMPLATE_DIR.CONFIG_FILE)));
return $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE);
}
function execute()
{
global $BASE_DIR;
if(!function_exists("posix_getgrgid")){
if (!function_exists("posix_getgrgid")) {
$webgroup = "";
} else {
$info= posix_getgrgid(posix_getgid());
$info = posix_getgrgid(posix_getgid());
$webgroup = $info['name'];
}
......@@ -67,14 +66,14 @@ class Step_Finish extends setup_step
* - fusiondirectory.conf exists
* - Permisssion are set correctly
*/
if(isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){
if (isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
session::destroy();
header("Location: index.php");
exit();
}
/* Download config */
if(isset($_POST['getconf'])){
if (isset($_POST['getconf'])) {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
......@@ -84,33 +83,32 @@ class Step_Finish extends setup_step
header("Content-type: text/plain");
if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) ||
preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){
preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: filename="'.CONFIG_FILE.'"');
} else {
header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"');
}
$str = $this->get_conf_data();
$str = preg_replace("/\n[ ]*\n/","",$str);
$str = preg_replace("/\n[ ]*\n/", "", $str);
echo $this->get_conf_data();
exit();
}
$err_msg= "";
$err_msg = "";
if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){
if ($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
$err_msg = _("Your configuration file is currently world readable. Please update the file permissions!");
}elseif(!$exists){
} elseif(!$exists) {
$err_msg = _("The configuration is currently not readable or it does not exists.");
}
$smarty = get_smarty();
$smarty->assign("err_msg",$err_msg);
$smarty->assign("err_msg", $err_msg);
$smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't."),CONFIG_DIR,CONFIG_FILE));
$smarty->assign("cv", $this->parent->captured_values);
$smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't."),CONFIG_DIR,CONFIG_FILE));
$smarty->assign("cv",$this->parent->captured_values);
return $smarty->fetch("$BASE_DIR/setup/setup_finish.tpl");
}
......@@ -120,18 +118,16 @@ class Step_Finish extends setup_step
{
clearstatcache();
$p = fileperms($file);
$w_r = (decbin($p & 4) == TRUE);
return($w_r);
return (decbin($p & 4) == TRUE);
}
function save_object()
{
if(isset($_POST['step8_posted'])){
if (isset($_POST['step8_posted'])) {
/* Get attributes */
foreach($this->attributes as $attr){
if(isset($_POST[$attr])){
foreach ($this->attributes as $attr) {
if (isset($_POST[$attr])) {
$this->$attr = validate($_POST[$attr]);
}
}
......@@ -139,5 +135,4 @@ class Step_Finish extends setup_step
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
......@@ -29,7 +29,7 @@ class Step_Language extends setup_step
var $attributes = array("lang","lang_selected");
var $header_image = "images/setup/locale.png";
function Step_Language()
function __construct()
{
$this->lang = get_browser_language();
$this->lang_selected = "";
......@@ -47,29 +47,28 @@ class Step_Language extends setup_step
{
$this->languages = get_languages(TRUE);
asort($this->languages);
$this->languages = array_merge(array("" => _("Automatic")),$this->languages);
$this->languages = array_merge(array("" => _("Automatic")), $this->languages);
$smarty = get_smarty();
$smarty->assign("languages", $this->languages);
$smarty->assign("lang", $this->lang);
$smarty->assign("rtl", language_is_rtl($this->lang));
$smarty->assign("lang_selected",$this->lang_selected);
return($smarty->fetch(get_template_path("setup_language.tpl",TRUE,dirname(__FILE__))));
$smarty->assign("languages", $this->languages);
$smarty->assign("lang", $this->lang);
$smarty->assign("rtl", language_is_rtl($this->lang));
$smarty->assign("lang_selected", $this->lang_selected);
return $smarty->fetch(get_template_path("setup_language.tpl", TRUE, dirname(__FILE__)));
}
function save_object()
{
if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) {
$this->lang_selected = $_POST['lang_selected'];
$this->is_completed = TRUE;
if ((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) {
$this->lang_selected = $_POST['lang_selected'];
$this->is_completed = TRUE;
if($this->lang_selected != ""){
session::set('lang',$this->lang_selected);
}else{
session::set('lang',$this->lang);
if ($this->lang_selected != "") {
session::set('lang', $this->lang_selected);
} else {
session::set('lang', $this->lang);
}
}
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
......@@ -44,7 +44,7 @@ class Step_Ldap extends setup_step
var $header_image = "images/setup/ldap.png";
function Step_Ldap()
function __construct()
{
$this->update_strings();
}
......
......@@ -111,7 +111,7 @@ class Step_Migrate extends setup_step
var $rootOC_migrate_dialog = FALSE;
var $rootOC_details = array();
function Step_Migrate()
function __construct()
{
$this->update_strings();
}
......
......@@ -22,16 +22,16 @@
class Step_Schema extends setup_step
{
var $checked = array();
var $not_checked = array();
var $schema_readable = FALSE;
var $attributes = array("enable_schema_check","samba_version");
var $enable_schema_check = TRUE;
var $samba_version = 3;
var $checked = array();
var $not_checked = array();
var $schema_readable = FALSE;
var $attributes = array("enable_schema_check","samba_version");
var $enable_schema_check = TRUE;
var $samba_version = 3;
var $found_ocs = 0;
function Step_Schema()
function __construct()
{
$this->update_strings();
}
......@@ -49,16 +49,16 @@ class Step_Schema extends setup_step
{
global $BASE_DIR;
$this->check_schema();
$failed_checks = 0 ;
foreach($this->checked as $val) {
if(!$val['STATUS']){
$failed_checks = 0;
foreach ($this->checked as $val) {
if (!$val['STATUS']) {
$failed_checks ++;
}
}
if($failed_checks == 0){
if ($failed_checks == 0) {
$this->is_completed = TRUE;
}else{
} else {
$this->is_completed = TRUE;
}
......@@ -84,24 +84,24 @@ class Step_Schema extends setup_step
$ldap->set_size_limit(0);
$smarty = get_smarty();