Commit 1e550ec2 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 d4af9097
......@@ -104,12 +104,8 @@ class config {
*/
function check_and_reload($force = FALSE)
{
global $ui;
/* Check if class_location.inc has changed, this is the case
if we have installed or removed plugins.
*/
$tmp = stat(CACHE_DIR."/".CLASS_CACHE);
if we have installed or removed plugins. */
if (session::global_is_set("class_location.inc:timestamp")) {
if ($tmp['mtime'] != session::global_get("class_location.inc:timestamp")) {
session::global_un_set("plist");
......@@ -208,7 +204,6 @@ class config {
/* Look through attributes */
switch ($this->tags[$this->level - 1]) {
/* Handle tab section */
case 'TAB':
$name = $this->tags[$this->level - 2];
......@@ -340,7 +335,6 @@ class config {
/* Check for connection */
if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)) {
$smarty = get_smarty();
msg_dialog::display(_("LDAP error"), _("Cannot bind to LDAP. Please contact the system administrator."), FATAL_ERROR_DIALOG);
exit();
}
......@@ -532,7 +526,6 @@ class config {
);
}
/* Get asterisk servers */
$ldap->cd($this->current['BASE']);
$ldap->search("(objectClass=goFonServer)");
......@@ -565,7 +558,6 @@ class config {
$this->data['SERVERS']['FON'][$attrs['dn']] = $entry;
}
/* Get logdb server */
$ldap->cd($this->current['BASE']);
$ldap->search("(objectClass=goLogDBServer)");
......@@ -609,7 +601,6 @@ class config {
$this->data['SERVERS']['TERMINAL'][] = "default";
$this->data['SERVERS']['TERMINAL_SESSION_TYPES'] = array();
while ($attrs = $ldap->fetch()) {
$this->data['SERVERS']['TERMINAL'][] = $attrs["cn"][0];
if (isset( $attrs["gotoSessionType"]['count'])) {
......@@ -733,8 +724,6 @@ class config {
*/
function get_departments($ignore_dn = "")
{
global $config;
/* Initialize result hash */
$result = array();
......@@ -777,7 +766,7 @@ class config {
continue;
}
$dn = $ldap->getDN();
$dn = $ldap->getDN();
$data = objects::infos($oc);
$this->department_info[$dn] = array("img" => $data['icon'],
"description" => isset($attrs['description'][0])?$attrs['description'][0]:"",
......@@ -799,12 +788,10 @@ class config {
function make_idepartments($max_size = 28)
{
global $config;
$base = $config->current['BASE'];
$base = $this->current['BASE'];
$qbase = preg_quote($base, '/');
$arr = array();
$ui = get_userinfo();
$this->idepartments = array();
......@@ -842,7 +829,6 @@ class config {
}
}
/* Add base entry */
$ret['/']['ENTRY'] = $base;
$ret['/']['SUB'] = $arr;
......@@ -951,10 +937,9 @@ class config {
*/
function getShareServerList()
{
global $config;
$return = array();
$ui = get_userinfo();
$base = $config->current['BASE'];
$base = $this->current['BASE'];
$res = get_sub_list("(&(objectClass=goShareServer)(goExportEntry=*))", "server",
get_ou("serverRDN"), $base, array("goExportEntry","cn"), GL_NONE | GL_NO_ACL_CHECK);
......@@ -977,6 +962,7 @@ class config {
$return[$entry['cn'][0]."|".$sharename] = $data;
}
}
return $return;
}
......
......@@ -52,52 +52,51 @@ class log {
*
* \sa log()
*/
function log($action,$objecttype,$object,$changes_array = array(),$result = "")
function log($action, $objecttype, $object, $changes_array = array(), $result = "")
{
if(!is_array($changes_array)){
if (!is_array($changes_array)) {
trigger_error("log(string,string,string,array(),bool). Forth parameter must be an array.");
$changes_array = array();
}
$entry = array();
if(!session::global_is_set('config')){
$entry['user']= "unkown";
}else{
$this->config = session::global_get('config');
$ui = get_userinfo();
$entry['user']= @$ui->dn;
if (!session::global_is_set('config')) {
$entry['user'] = "unkown";
} else {
$this->config = session::global_get('config');
$ui = get_userinfo();
$entry['user'] = @$ui->dn;
}
/* Create string out of changes */
$changes ="";
foreach($changes_array as $str ){
$changes = "";
foreach ($changes_array as $str) {
$changes .= $str.",";
}
$changes = preg_replace("/,$/","",$changes );
$changes = preg_replace("/,$/", "", $changes);
/* Create data object */
$entry['timestamp'] = time();
$entry['action'] = $action;
$entry['objecttype']= $objecttype;
$entry['object'] = $object;
$entry['changes'] = $changes;
$entry['result'] = $result;
if(!isset($this->config) && empty($entry['user'])){
$entry['timestamp'] = time();
$entry['action'] = $action;
$entry['objecttype'] = $objecttype;
$entry['object'] = $object;
$entry['changes'] = $changes;
$entry['result'] = $result;
if (!isset($this->config) && empty($entry['user'])) {
$entry['user'] = "unknown";
}
/* Check if all given values are valid */
global $config;
$msgs = @log::check($entry);
if(count($msgs)){
foreach($msgs as $msg){
if (count($msgs)) {
foreach ($msgs as $msg) {
trigger_error("Logging failed, reason was: ".$msg);
msg_dialog::display(_("Internal error"), sprintf(_("Logging failed: %s"), $msg), ERROR_DIALOG);
}
}else{
if(is_object($config) && preg_match("/true/i",$config->get_cfg_value("logging",""))){
} else {
if (is_object($config) && preg_match("/true/i", $config->get_cfg_value("logging", ""))) {
$this->log_into_syslog($entry);
}
}
......@@ -112,15 +111,15 @@ class log {
{
$msgs = array();
if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view","security","debug"))){
if (!isset($entry['action']) || !in_array($entry['action'], array("modify","create","remove","copy","snapshot","view","security","debug"))) {
$msgs[] = sprintf(_("Invalid option '%s' specified!"), $entry['action']);
}
if(!isset($entry['objecttype']) || empty($entry['objecttype'])){
if (!isset($entry['objecttype']) || empty($entry['objecttype'])) {
$msgs[] = _("Specified objectType is empty or invalid!");
}
return($msgs);
return $msgs;
}
......@@ -131,7 +130,7 @@ class log {
*/
function log_into_syslog($entry)
{
$str= "";
$str = "";
if (empty($entry['object']) && empty($entry['changes'])) {
$str = "(".$entry['action'].") ".$entry['objecttype'].": ".$entry['result'];
} else {
......@@ -139,8 +138,5 @@ class log {
}
fusiondirectory_log($str);
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
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