Commit d813b01e authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes stuff from sonarqube

parent 013268cd
......@@ -75,8 +75,10 @@ if (!function_exists("imagecreate")) {
}
/* Draw image in GD image stream */
$im = imagecreate ($x, $y)
or die ("Cannot Initialize new GD image stream");
$im = imagecreate ($x, $y);
if (!$im) {
die ('Cannot Initialize new GD image stream');
}
/* Set colors */
$bg_color = imagecolorallocate($im, 255, 255, 255);
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
......@@ -30,48 +29,6 @@
* files
*/
class xml {
/*!
* \brief Validate a xml file from a schema
*
* \param string $file XML Filename
*
* \param string $schema Schema of the XML file
*/
static function validate($file, $schema)
{
// Enable user error handling
libxml_use_internal_errors(TRUE);
$xml = new DOMDocument();
$xml->load($file);
if (!$xml->schemaValidate($schema)) {
$errors = libxml_get_errors();
foreach ($errors as $error) {
$str = "";
switch ($error->level) {
case LIBXML_ERR_WARNING:
$str = _("Warning")." ".$error->code.": ";
break;
case LIBXML_ERR_ERROR:
$str = _("Error")." ".$error->code.": ";
break;
case LIBXML_ERR_FATAL:
$str = _("Fatal error")." ".$error->code.": ";
break;
}
$str .= trim($error->message);
if ($error->file) {
$str .= " "._("in")." ".$error->file;
}
$str .= " "._("on line")." ".$error->line;
msg_dialog::display(_("XML error"), $str, ERROR_DIALOG);
}
libxml_clear_errors();
}
}
/*!
* \brief Transform a xml document to an array
*
......
......@@ -112,7 +112,9 @@ class Print_a_class {
*/
function print_a($array, $iteration = FALSE, $key_bg_color = FALSE)
{
$key_bg_color or $key_bg_color = $this->key_bg_color;
if (!$key_bg_color) {
$key_bg_color = $this->key_bg_color;
}
if (!$iteration && isset($this->export_flag)) {
$this->output .= '<form id="pa_form_'.$this->export_hash.'" action="'.$this->export_dumper_path.'?mode='.$this->export_flag.'" method="post" target="_blank"><input name="array" type="hidden" value="'.htmlspecialchars( serialize( $array ) ).'"></form>';
......@@ -123,8 +125,13 @@ class Print_a_class {
for ($i = 0; $i < 6; $i += 2) {
$c = substr( $key_bg_color, $i, 2 );
$c = hexdec( $c );
( $c += 15 ) > 255 and $c = 255;
isset($tmp_key_bg_color) or $tmp_key_bg_color = '';
$c += 15;
if ($c > 255) {
$c = 255;
}
if (!isset($tmp_key_bg_color)) {
$tmp_key_bg_color = '';
}
$tmp_key_bg_color .= sprintf( "%02X", $c );
}
$key_bg_color = $tmp_key_bg_color;
......@@ -221,7 +228,7 @@ class Print_a_class {
function print_a($array, $return_mode = FALSE, $show_object_vars = FALSE, $export_flag = FALSE )
{
$e = error_reporting(0);
if (is_array($array) or is_object($array)) {
if (is_array($array) || is_object($array)) {
$pa = new Print_a_class;
if ($show_object_vars) {
$pa->show_object_vars = TRUE;
......
......@@ -40,9 +40,15 @@ class fake_userinfo extends userinfo
class setup
{
var $i_steps; // Number of setup steps
var $i_current = 0; // Current step
var $i_previous = 0; // Previous setup step;
/* Number of setup steps */
var $i_steps;
/* Current step */
var $i_current = 0;
/* Previous setup step */
var $i_previous = 0;
var $i_config = 4;
var $o_steps = array();
var $captured_values = array();
......
......@@ -104,13 +104,11 @@ class setupStep extends simplePlugin
/* bypass LDAP loading */
protected function loadAttributes()
{
foreach ($this->attributesInfo as &$sectionInfo) {
foreach ($sectionInfo['attrs'] as $name => &$attr) {
foreach ($this->attributesInfo as $sectionInfo) {
foreach ($sectionInfo['attrs'] as $attr) {
$attr->setParent($this);
}
unset($attr);
}
unset($sectionInfo);
}
}
?>
......@@ -352,7 +352,8 @@ class Step_Migrate extends setupStep
/* Try to detect base class type, e.g. is it a dcObject */
$dep_types = departmentManagement::getDepartmentTypes();
$dep_type = "";
$attrs['objectClass'][] = 'gosaDepartment'; // This allow us to filter it as if it was already migrated
/* This allow us to filter it as if it was already migrated */
$attrs['objectClass'][] = 'gosaDepartment';
foreach ($dep_types as $type) {
if (objects::isOfType($attrs, $type)) {
$dep_type = $type;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment