Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/core/actions_changeselectedfields.inc.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@
 block discarded – undo
30 30
 // Save selection
31 31
 if (GETPOST('formfilteraction') == 'listafterchangingselectedfields')
32 32
 {
33
-    $tabparam=array();
33
+    $tabparam = array();
34 34
 
35
-    $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
35
+    $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
36 36
 
37
-    if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
38
-    else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
37
+    if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
38
+    else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
39 39
 
40 40
     include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 41
 
42
-    $result=dol_set_user_param($db, $conf, $user, $tabparam);
42
+    $result = dol_set_user_param($db, $conf, $user, $tabparam);
43 43
 
44 44
     //$action='list';
45 45
     //var_dump($tabparam);exit;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,11 @@
 block discarded – undo
34 34
 
35 35
     $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
36 36
 
37
-    if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
38
-    else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
37
+    if (GETPOST("selectedfields")) {
38
+        $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
39
+    } else {
40
+        $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
41
+    }
39 42
 
40 43
     include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 44
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_dellink.inc.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 // Delete link
41 41
 if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel','alpha') && $dellinkid > 0)
42 42
 {
43
-	$result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid);
44
-	if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
43
+    $result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid);
44
+    if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
45 45
 }
46 46
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,21 +26,21 @@
 block discarded – undo
26 26
 // $object must be defined
27 27
 // $permissiondellink must be defined
28 28
 
29
-$dellinkid = GETPOST('dellinkid','int');
30
-$addlinkid = GETPOST('idtolinkto','int');
29
+$dellinkid = GETPOST('dellinkid', 'int');
30
+$addlinkid = GETPOST('idtolinkto', 'int');
31 31
 
32 32
 // Link invoice to order
33
-if ($action == 'addlink' && ! empty($permissiondellink) && ! GETPOST('cancel','alpha') && $id > 0 && $addlinkid > 0)
33
+if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0)
34 34
 {
35 35
     $object->fetch($id);
36 36
     $object->fetch_thirdparty();
37
-    $result = $object->add_object_linked(GETPOST('addlink','alpha'), $addlinkid);
37
+    $result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid);
38 38
 }
39 39
 
40 40
 // Delete link
41
-if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel','alpha') && $dellinkid > 0)
41
+if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0)
42 42
 {
43
-	$result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid);
44
-	if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
43
+	$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
44
+	if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
45 45
 }
46 46
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,6 +41,8 @@
 block discarded – undo
41 41
 if ($action == 'dellink' && ! empty($permissiondellink) && ! GETPOST('cancel','alpha') && $dellinkid > 0)
42 42
 {
43 43
 	$result=$object->deleteObjectLinked(0, '', 0, '', $dellinkid);
44
-	if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
45
-}
44
+	if ($result < 0) {
45
+	    setEventMessages($object->error,$object->errors,'errors');
46
+	}
47
+	}
46 48
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_fetchobject.inc.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,25 +30,25 @@
 block discarded – undo
30 30
 
31 31
 if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
32 32
 {
33
-	if (($id > 0 && is_numeric($id)) || ! empty($ref))	// To discard case when id is list of ids like '1,2,3...'
34
-	{
35
-	    $ret = $object->fetch($id, $ref);
36
-	    if ($ret > 0)
37
-	    {
38
-	        $object->fetch_thirdparty();
39
-	        $id = $object->id;
40
-	    }
41
-	    else
42
-	    {
43
-	    	if (empty($object->error) && ! count($object->errors))
44
-	    	{
45
-	    		if ($ret < 0)	// if $ret == 0, it means not found.
46
-	    		{
47
-	    			setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
48
-	    		}
49
-	    	}
50
-	        else setEventMessages($object->error, $object->errors, 'errors');
51
-	        $action='';
52
-	    }
53
-	}
33
+    if (($id > 0 && is_numeric($id)) || ! empty($ref))	// To discard case when id is list of ids like '1,2,3...'
34
+    {
35
+        $ret = $object->fetch($id, $ref);
36
+        if ($ret > 0)
37
+        {
38
+            $object->fetch_thirdparty();
39
+            $id = $object->id;
40
+        }
41
+        else
42
+        {
43
+            if (empty($object->error) && ! count($object->errors))
44
+            {
45
+                if ($ret < 0)	// if $ret == 0, it means not found.
46
+                {
47
+                    setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
48
+                }
49
+            }
50
+            else setEventMessages($object->error, $object->errors, 'errors');
51
+            $action='';
52
+        }
53
+    }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 // $cancel must be defined
29 29
 // $id or $ref must be defined (object is loaded in this file with fetch)
30 30
 
31
-if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
31
+if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
32 32
 {
33
-	if (($id > 0 && is_numeric($id)) || ! empty($ref))	// To discard case when id is list of ids like '1,2,3...'
33
+	if (($id > 0 && is_numeric($id)) || !empty($ref))	// To discard case when id is list of ids like '1,2,3...'
34 34
 	{
35 35
 	    $ret = $object->fetch($id, $ref);
36 36
 	    if ($ret > 0)
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	    }
41 41
 	    else
42 42
 	    {
43
-	    	if (empty($object->error) && ! count($object->errors))
43
+	    	if (empty($object->error) && !count($object->errors))
44 44
 	    	{
45 45
 	    		if ($ret < 0)	// if $ret == 0, it means not found.
46 46
 	    		{
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	    		}
49 49
 	    	}
50 50
 	        else setEventMessages($object->error, $object->errors, 'errors');
51
-	        $action='';
51
+	        $action = '';
52 52
 	    }
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,24 +30,28 @@
 block discarded – undo
30 30
 
31 31
 if (($id > 0 || (! empty($ref) && ! in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
32 32
 {
33
-	if (($id > 0 && is_numeric($id)) || ! empty($ref))	// To discard case when id is list of ids like '1,2,3...'
33
+	if (($id > 0 && is_numeric($id)) || ! empty($ref)) {
34
+	    // To discard case when id is list of ids like '1,2,3...'
34 35
 	{
35 36
 	    $ret = $object->fetch($id, $ref);
37
+	}
36 38
 	    if ($ret > 0)
37 39
 	    {
38 40
 	        $object->fetch_thirdparty();
39 41
 	        $id = $object->id;
40
-	    }
41
-	    else
42
+	    } else
42 43
 	    {
43 44
 	    	if (empty($object->error) && ! count($object->errors))
44 45
 	    	{
45
-	    		if ($ret < 0)	// if $ret == 0, it means not found.
46
+	    		if ($ret < 0) {
47
+	    		    // if $ret == 0, it means not found.
46 48
 	    		{
47 49
 	    			setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
48 50
 	    		}
49
-	    	}
50
-	        else setEventMessages($object->error, $object->errors, 'errors');
51
+	    		}
52
+	    	} else {
53
+	            setEventMessages($object->error, $object->errors, 'errors');
54
+	        }
51 55
 	        $action='';
52 56
 	    }
53 57
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/selectobject.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,16 +62,16 @@
 block discarded – undo
62 62
 $classpath=$InfoFieldList[1];
63 63
 if (! empty($classpath))
64 64
 {
65
-	dol_include_once($classpath);
66
-	if ($classname && class_exists($classname))
67
-	{
68
-		$objecttmp = new $classname($db);
69
-	}
65
+    dol_include_once($classpath);
66
+    if ($classname && class_exists($classname))
67
+    {
68
+        $objecttmp = new $classname($db);
69
+    }
70 70
 }
71 71
 if (! is_object($objecttmp))
72 72
 {
73
-	dol_syslog('Error bad param objectdesc', LOG_WARNING);
74
-	print 'Error bad param objectdesc';
73
+    dol_syslog('Error bad param objectdesc', LOG_WARNING);
74
+    print 'Error bad param objectdesc';
75 75
 }
76 76
 
77 77
 // When used from jQuery, the search term is added as GET param "term".
Please login to merge, or discard this patch.
Braces   +25 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,12 +20,25 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to return Ajax response on a selection list request
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
26
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
27
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
28
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');
23
+if (! defined('NOTOKENRENEWAL')) {
24
+    define('NOTOKENRENEWAL',1);
25
+}
26
+// Disables token renewal
27
+if (! defined('NOREQUIREMENU')) {
28
+    define('NOREQUIREMENU','1');
29
+}
30
+if (! defined('NOREQUIREHTML')) {
31
+    define('NOREQUIREHTML','1');
32
+}
33
+if (! defined('NOREQUIREAJAX')) {
34
+    define('NOREQUIREAJAX','1');
35
+}
36
+if (! defined('NOREQUIRESOC')) {
37
+    define('NOREQUIRESOC','1');
38
+}
39
+if (! defined('NOCSRFCHECK')) {
40
+    define('NOCSRFCHECK','1');
41
+}
29 42
 
30 43
 
31 44
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
@@ -57,7 +70,9 @@  discard block
 block discarded – undo
57 70
 
58 71
 top_httphead();
59 72
 
60
-if (empty($htmlname)) return;
73
+if (empty($htmlname)) {
74
+    return;
75
+}
61 76
 
62 77
 
63 78
 $InfoFieldList = explode(":", $objectdesc);
@@ -86,4 +101,6 @@  discard block
 block discarded – undo
86 101
 
87 102
 $db->close();
88 103
 
89
-if ($outjson) print json_encode($arrayresult);
104
+if ($outjson) {
105
+    print json_encode($arrayresult);
106
+}
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,24 +20,24 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to return Ajax response on a selection list request
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
26
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
27
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
28
-if (! defined('NOCSRFCHECK'))    define('NOCSRFCHECK','1');
23
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
24
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
25
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
26
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
27
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
28
+if (!defined('NOCSRFCHECK'))    define('NOCSRFCHECK', '1');
29 29
 
30 30
 
31 31
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
32 32
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
33
-require DOL_BASE_PATH . '/main.inc.php';
33
+require DOL_BASE_PATH.'/main.inc.php';
34 34
 
35
-$objectdesc=GETPOST('objectdesc', 'alpha');
36
-$htmlname=GETPOST('htmlname', 'aZ09');
37
-$sqlfilter=GETPOST('sqlfilter', 'alpha');
38
-$outjson=(GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
39
-$action=GETPOST('action', 'alpha');
40
-$id=GETPOST('id', 'int');
35
+$objectdesc = GETPOST('objectdesc', 'alpha');
36
+$htmlname = GETPOST('htmlname', 'aZ09');
37
+$sqlfilter = GETPOST('sqlfilter', 'alpha');
38
+$outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
39
+$action = GETPOST('action', 'alpha');
40
+$id = GETPOST('id', 'int');
41 41
 
42 42
 
43 43
 /*
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
 
63 63
 $InfoFieldList = explode(":", $objectdesc);
64
-$classname=$InfoFieldList[0];
65
-$classpath=$InfoFieldList[1];
66
-if (! empty($classpath))
64
+$classname = $InfoFieldList[0];
65
+$classpath = $InfoFieldList[1];
66
+if (!empty($classpath))
67 67
 {
68 68
 	dol_include_once($classpath);
69 69
 	if ($classname && class_exists($classname))
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
 		$objecttmp = new $classname($db);
72 72
 	}
73 73
 }
74
-if (! is_object($objecttmp))
74
+if (!is_object($objecttmp))
75 75
 {
76 76
 	dol_syslog('Error bad param objectdesc', LOG_WARNING);
77 77
 	print 'Error bad param objectdesc';
78 78
 }
79 79
 
80 80
 // When used from jQuery, the search term is added as GET param "term".
81
-$searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):''));
81
+$searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : ''));
82 82
 
83 83
 // TODO Add a security test to avoid to get content of all tables
84 84
 
85
-$arrayresult=$form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1);
85
+$arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1);
86 86
 
87 87
 $db->close();
88 88
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/loadinplace.php 3 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -44,72 +44,72 @@
 block discarded – undo
44 44
 // Load original field value
45 45
 if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element))
46 46
 {
47
-	$ext_element	= GETPOST('ext_element','alpha');
48
-	$field			= substr($field, 8); // remove prefix val_
49
-	$type			= GETPOST('type','alpha');
50
-	$loadmethod		= (GETPOST('loadmethod','alpha') ? GETPOST('loadmethod','alpha') : 'getValueFrom');
47
+    $ext_element	= GETPOST('ext_element','alpha');
48
+    $field			= substr($field, 8); // remove prefix val_
49
+    $type			= GETPOST('type','alpha');
50
+    $loadmethod		= (GETPOST('loadmethod','alpha') ? GETPOST('loadmethod','alpha') : 'getValueFrom');
51 51
 
52
-	if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
53
-	{
54
-		$element = $regs[1];
55
-		$subelement = $regs[2];
56
-	}
52
+    if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
53
+    {
54
+        $element = $regs[1];
55
+        $subelement = $regs[2];
56
+    }
57 57
 
58
-	if ($element == 'propal') $element = 'propale';
59
-	else if ($element == 'fichinter') $element = 'ficheinter';
60
-	else if ($element == 'product') $element = 'produit';
61
-	else if ($element == 'member') $element = 'adherent';
62
-	else if ($element == 'order_supplier') {
63
-		$element = 'fournisseur';
64
-		$subelement = 'commande';
65
-	}
66
-	else if ($element == 'invoice_supplier') {
67
-		$element = 'fournisseur';
68
-		$subelement = 'facture';
69
-	}
58
+    if ($element == 'propal') $element = 'propale';
59
+    else if ($element == 'fichinter') $element = 'ficheinter';
60
+    else if ($element == 'product') $element = 'produit';
61
+    else if ($element == 'member') $element = 'adherent';
62
+    else if ($element == 'order_supplier') {
63
+        $element = 'fournisseur';
64
+        $subelement = 'commande';
65
+    }
66
+    else if ($element == 'invoice_supplier') {
67
+        $element = 'fournisseur';
68
+        $subelement = 'facture';
69
+    }
70 70
 
71
-	if ($user->rights->$element->lire || $user->rights->$element->read
72
-	|| (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read))
73
-	|| ($element == 'payment' && $user->rights->facture->lire)
74
-	|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire))
75
-	{
76
-		if ($type == 'select')
77
-		{
78
-			$methodname	= 'load_cache_'.$loadmethod;
79
-			$cachename = 'cache_'.GETPOST('loadmethod','alpha');
71
+    if ($user->rights->$element->lire || $user->rights->$element->read
72
+    || (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read))
73
+    || ($element == 'payment' && $user->rights->facture->lire)
74
+    || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire))
75
+    {
76
+        if ($type == 'select')
77
+        {
78
+            $methodname	= 'load_cache_'.$loadmethod;
79
+            $cachename = 'cache_'.GETPOST('loadmethod','alpha');
80 80
 
81
-			$form = new Form($db);
82
-			if (method_exists($form, $methodname))
83
-			{
84
-				$ret = $form->$methodname();
85
-				if ($ret > 0) echo json_encode($form->$cachename);
86
-			}
87
-			else if (! empty($ext_element))
88
-			{
89
-				$module = $subelement = $ext_element;
90
-				if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
91
-				{
92
-					$module = $regs[1];
93
-					$subelement = $regs[2];
94
-				}
81
+            $form = new Form($db);
82
+            if (method_exists($form, $methodname))
83
+            {
84
+                $ret = $form->$methodname();
85
+                if ($ret > 0) echo json_encode($form->$cachename);
86
+            }
87
+            else if (! empty($ext_element))
88
+            {
89
+                $module = $subelement = $ext_element;
90
+                if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
91
+                {
92
+                    $module = $regs[1];
93
+                    $subelement = $regs[2];
94
+                }
95 95
 
96
-				dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');
97
-				$classname = 'Actions'.ucfirst($subelement);
98
-				$object = new $classname($db);
99
-				$ret = $object->$methodname($fk_element);
100
-				if ($ret > 0) echo json_encode($object->$cachename);
101
-			}
102
-		}
103
-		else
104
-		{
105
-			$object = new GenericObject($db);
106
-			$value=$object->$loadmethod($table_element, $fk_element, $field);
107
-			echo $value;
108
-		}
109
-	}
110
-	else
111
-	{
112
-		echo $langs->transnoentities('NotEnoughPermissions');
113
-	}
96
+                dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php');
97
+                $classname = 'Actions'.ucfirst($subelement);
98
+                $object = new $classname($db);
99
+                $ret = $object->$methodname($fk_element);
100
+                if ($ret > 0) echo json_encode($object->$cachename);
101
+            }
102
+        }
103
+        else
104
+        {
105
+            $object = new GenericObject($db);
106
+            $value=$object->$loadmethod($table_element, $fk_element, $field);
107
+            echo $value;
108
+        }
109
+    }
110
+    else
111
+    {
112
+        echo $langs->transnoentities('NotEnoughPermissions');
113
+    }
114 114
 }
115 115
 
Please login to merge, or discard this patch.
Braces   +32 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,10 +20,19 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to load field value
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
26
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
23
+if (! defined('NOTOKENRENEWAL')) {
24
+    define('NOTOKENRENEWAL','1');
25
+}
26
+// Disables token renewal
27
+if (! defined('NOREQUIREMENU')) {
28
+    define('NOREQUIREMENU','1');
29
+}
30
+if (! defined('NOREQUIREAJAX')) {
31
+    define('NOREQUIREAJAX','1');
32
+}
33
+if (! defined('NOREQUIRESOC')) {
34
+    define('NOREQUIRESOC','1');
35
+}
27 36
 
28 37
 
29 38
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
@@ -58,15 +67,18 @@  discard block
 block discarded – undo
58 67
 		$subelement = $regs[2];
59 68
 	}
60 69
 
61
-	if ($element == 'propal') $element = 'propale';
62
-	else if ($element == 'fichinter') $element = 'ficheinter';
63
-	else if ($element == 'product') $element = 'produit';
64
-	else if ($element == 'member') $element = 'adherent';
65
-	else if ($element == 'order_supplier') {
70
+	if ($element == 'propal') {
71
+	    $element = 'propale';
72
+	} else if ($element == 'fichinter') {
73
+	    $element = 'ficheinter';
74
+	} else if ($element == 'product') {
75
+	    $element = 'produit';
76
+	} else if ($element == 'member') {
77
+	    $element = 'adherent';
78
+	} else if ($element == 'order_supplier') {
66 79
 		$element = 'fournisseur';
67 80
 		$subelement = 'commande';
68
-	}
69
-	else if ($element == 'invoice_supplier') {
81
+	} else if ($element == 'invoice_supplier') {
70 82
 		$element = 'fournisseur';
71 83
 		$subelement = 'facture';
72 84
 	}
@@ -85,9 +97,10 @@  discard block
 block discarded – undo
85 97
 			if (method_exists($form, $methodname))
86 98
 			{
87 99
 				$ret = $form->$methodname();
88
-				if ($ret > 0) echo json_encode($form->$cachename);
89
-			}
90
-			else if (! empty($ext_element))
100
+				if ($ret > 0) {
101
+				    echo json_encode($form->$cachename);
102
+				}
103
+			} else if (! empty($ext_element))
91 104
 			{
92 105
 				$module = $subelement = $ext_element;
93 106
 				if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
@@ -100,17 +113,17 @@  discard block
 block discarded – undo
100 113
 				$classname = 'Actions'.ucfirst($subelement);
101 114
 				$object = new $classname($db);
102 115
 				$ret = $object->$methodname($fk_element);
103
-				if ($ret > 0) echo json_encode($object->$cachename);
116
+				if ($ret > 0) {
117
+				    echo json_encode($object->$cachename);
118
+				}
104 119
 			}
105
-		}
106
-		else
120
+		} else
107 121
 		{
108 122
 			$object = new GenericObject($db);
109 123
 			$value=$object->$loadmethod($table_element, $fk_element, $field);
110 124
 			echo $value;
111 125
 		}
112
-	}
113
-	else
126
+	} else
114 127
 	{
115 128
 		echo $langs->transnoentities('NotEnoughPermissions');
116 129
 	}
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to load field value
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
26
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
23
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
24
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
25
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
26
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
27 27
 
28 28
 
29 29
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
30 30
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
31
-require DOL_BASE_PATH . '/main.inc.php';
31
+require DOL_BASE_PATH.'/main.inc.php';
32 32
 require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
33 33
 
34
-$field			= GETPOST('field','alpha');
35
-$element		= GETPOST('element','alpha');
36
-$table_element	= GETPOST('table_element','alpha');
37
-$fk_element		= GETPOST('fk_element','alpha');
34
+$field = GETPOST('field', 'alpha');
35
+$element = GETPOST('element', 'alpha');
36
+$table_element = GETPOST('table_element', 'alpha');
37
+$fk_element = GETPOST('fk_element', 'alpha');
38 38
 
39 39
 /*
40 40
  * View
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
46 46
 
47 47
 // Load original field value
48
-if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element))
48
+if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element))
49 49
 {
50
-	$ext_element	= GETPOST('ext_element','alpha');
51
-	$field			= substr($field, 8); // remove prefix val_
52
-	$type			= GETPOST('type','alpha');
53
-	$loadmethod		= (GETPOST('loadmethod','alpha') ? GETPOST('loadmethod','alpha') : 'getValueFrom');
50
+	$ext_element	= GETPOST('ext_element', 'alpha');
51
+	$field = substr($field, 8); // remove prefix val_
52
+	$type = GETPOST('type', 'alpha');
53
+	$loadmethod		= (GETPOST('loadmethod', 'alpha') ? GETPOST('loadmethod', 'alpha') : 'getValueFrom');
54 54
 
55
-	if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
55
+	if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i', $element, $regs))
56 56
 	{
57 57
 		$element = $regs[1];
58 58
 		$subelement = $regs[2];
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	{
79 79
 		if ($type == 'select')
80 80
 		{
81
-			$methodname	= 'load_cache_'.$loadmethod;
82
-			$cachename = 'cache_'.GETPOST('loadmethod','alpha');
81
+			$methodname = 'load_cache_'.$loadmethod;
82
+			$cachename = 'cache_'.GETPOST('loadmethod', 'alpha');
83 83
 
84 84
 			$form = new Form($db);
85 85
 			if (method_exists($form, $methodname))
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 				$ret = $form->$methodname();
88 88
 				if ($ret > 0) echo json_encode($form->$cachename);
89 89
 			}
90
-			else if (! empty($ext_element))
90
+			else if (!empty($ext_element))
91 91
 			{
92 92
 				$module = $subelement = $ext_element;
93
-				if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs))
93
+				if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs))
94 94
 				{
95 95
 					$module = $regs[1];
96 96
 					$subelement = $regs[2];
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		else
107 107
 		{
108 108
 			$object = new GenericObject($db);
109
-			$value=$object->$loadmethod($table_element, $fk_element, $field);
109
+			$value = $object->$loadmethod($table_element, $fk_element, $field);
110 110
 			echo $value;
111 111
 		}
112 112
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/getaccountcurrency.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@
 block discarded – undo
39 39
 // Load original field value
40 40
 if (! empty($id))
41 41
 {
42
-	require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
43
-	$account=new Account($db);
44
-	$result = $account->fetch($id);
45
-	if ($result<0) {
46
-		$return['value']	= '';
47
-		$return['num']		= $result;
48
-		$return['error']	= $account->errors[0];
49
-	} else {
50
-		$return['value']	= $account->currency_code;
51
-		$return['num']		= $result;
52
-		$return['error']	= '';
53
-	}
54
-
55
-	echo json_encode($return);
42
+    require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
43
+    $account=new Account($db);
44
+    $result = $account->fetch($id);
45
+    if ($result<0) {
46
+        $return['value']	= '';
47
+        $return['num']		= $result;
48
+        $return['error']	= $account->errors[0];
49
+    } else {
50
+        $return['value']	= $account->currency_code;
51
+        $return['num']		= $result;
52
+        $return['error']	= '';
53
+    }
54
+
55
+    echo json_encode($return);
56 56
 }
57 57
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,16 @@
 block discarded – undo
20 20
  *       \brief      File to load vat rates combobox
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
23
+if (! defined('NOTOKENRENEWAL')) {
24
+    define('NOTOKENRENEWAL','1');
25
+}
26
+// Disables token renewal
27
+if (! defined('NOREQUIREMENU')) {
28
+    define('NOREQUIREMENU','1');
29
+}
30
+if (! defined('NOREQUIREAJAX')) {
31
+    define('NOREQUIREAJAX','1');
32
+}
26 33
 
27 34
 
28 35
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to load vat rates combobox
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
23
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
24
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
25
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
26 26
 
27 27
 
28 28
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
29 29
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
30
-require DOL_BASE_PATH . '/main.inc.php';
30
+require DOL_BASE_PATH.'/main.inc.php';
31 31
 
32
-$id			= GETPOST('id','int');
32
+$id = GETPOST('id', 'int');
33 33
 
34 34
 /*
35 35
  * View
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
41 41
 
42 42
 // Load original field value
43
-if (! empty($id))
43
+if (!empty($id))
44 44
 {
45 45
 	require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
46
-	$account=new Account($db);
46
+	$account = new Account($db);
47 47
 	$result = $account->fetch($id);
48
-	if ($result<0) {
48
+	if ($result < 0) {
49 49
 		$return['value']	= '';
50
-		$return['num']		= $result;
50
+		$return['num'] = $result;
51 51
 		$return['error']	= $account->errors[0];
52 52
 	} else {
53 53
 		$return['value']	= $account->currency_code;
54
-		$return['num']		= $result;
54
+		$return['num'] = $result;
55 55
 		$return['error']	= '';
56 56
 	}
57 57
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/ajaxdirtree.php 3 patches
Indentation   +339 added lines, -339 removed lines patch added patch discarded remove patch
@@ -34,35 +34,35 @@  discard block
 block discarded – undo
34 34
 
35 35
 if (! isset($mode) || $mode != 'noajax')    // For ajax call
36 36
 {
37
-	$res=@include '../../main.inc.php';
38
-	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39
-	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40
-	include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
41
-	include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
42
-	include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
37
+    $res=@include '../../main.inc.php';
38
+    include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39
+    include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40
+    include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
41
+    include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
42
+    include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
43 43
 
44
-	//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; }
44
+    //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; }
45 45
 
46
-	$openeddir = GETPOST('openeddir');
47
-	$modulepart= GETPOST('modulepart');
48
-	$selecteddir = jsUnEscape(GETPOST('dir'));        // relative path. We must decode using same encoding function used by javascript: escape()
46
+    $openeddir = GETPOST('openeddir');
47
+    $modulepart= GETPOST('modulepart');
48
+    $selecteddir = jsUnEscape(GETPOST('dir'));        // relative path. We must decode using same encoding function used by javascript: escape()
49 49
 
50
-	$preopened = GETPOST('preopened');
50
+    $preopened = GETPOST('preopened');
51 51
 
52
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
52
+    if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
53 53
 }
54 54
 else    // For no ajax call
55 55
 {
56
-	//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
56
+    //if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
57 57
 
58
-	$openeddir = GETPOST('openeddir');
59
-	$modulepart= GETPOST('modulepart');
60
-	$selecteddir = GETPOST('dir');
58
+    $openeddir = GETPOST('openeddir');
59
+    $modulepart= GETPOST('modulepart');
60
+    $selecteddir = GETPOST('dir');
61 61
 
62
-	$preopened = GETPOST('preopened');
62
+    $preopened = GETPOST('preopened');
63 63
 
64
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
65
-	if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
64
+    if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
65
+    if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
66 66
 }
67 67
 
68 68
 // Load translation files required by the page
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 $fullpathselecteddir='<none>';
73 73
 if ($modulepart == 'ecm')
74 74
 {
75
-	$fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
76
-	$fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
75
+    $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
76
+    $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
77 77
 }
78 78
 elseif ($modulepart == 'medias')
79 79
 {
80
-	$fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
81
-	$fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
80
+    $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
81
+    $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
82 82
 }
83 83
 
84 84
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 // Check permissions
96 96
 if ($modulepart == 'ecm')
97 97
 {
98
-	if (! $user->rights->ecm->read) accessforbidden();
98
+    if (! $user->rights->ecm->read) accessforbidden();
99 99
 }
100 100
 elseif ($modulepart == 'medias')
101 101
 {
102
-	// Always allowed
102
+    // Always allowed
103 103
 }
104 104
 
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
 if (! isset($mode) || $mode != 'noajax')	// if ajax mode
111 111
 {
112
-	top_httphead();
112
+    top_httphead();
113 113
 }
114 114
 
115 115
 //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n";
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 
134 134
 if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
135 135
 {
136
-	treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
136
+    treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
137 137
 
138
-	// TODO Find a solution to not output this code for each leaf we open
139
-	// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
140
-	// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
141
-	print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
142
-	print '<script type="text/javascript">
138
+    // TODO Find a solution to not output this code for each leaf we open
139
+    // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
140
+    // Because the content is reloaded by ajax call, we must also reenable some jquery hooks
141
+    print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
142
+    print '<script type="text/javascript">
143 143
 	            	jQuery(document).ready(function () {
144 144
 	            		jQuery(".classfortooltip").tooltip({
145 145
 							show: { collision: "flipfit", effect:\'toggle\', delay:50 },
@@ -152,170 +152,170 @@  discard block
 block discarded – undo
152 152
 	            	});
153 153
 	            	</script>';
154 154
 
155
-	// This ajax service is called only when a directory $selecteddir is opened but not when closed.
156
-	//print '<script language="javascript">';
157
-	//print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
158
-	//print '</script>';
155
+    // This ajax service is called only when a directory $selecteddir is opened but not when closed.
156
+    //print '<script language="javascript">';
157
+    //print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
158
+    //print '</script>';
159 159
 }
160 160
 
161 161
 
162 162
 if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS))
163 163
 {
164
-	print '<ul class="ecmjqft">';
165
-
166
-	// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
167
-	if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);    // Slow
168
-
169
-	// ----- This section will show a tree from a fulltree array -----
170
-	// $section must also be defined
171
-	// ----------------------------------------------------------------
172
-
173
-	// Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree)
174
-	$fullpathselected='';
175
-	foreach($sqltree as $key => $val)
176
-	{
177
-		//print $val['id']."-".$section."<br>";
178
-		if ($val['id'] == $section)
179
-		{
180
-			$fullpathselected=$val['fullpath'];
181
-			break;
182
-		}
183
-	}
184
-	//print "fullpathselected=".$fullpathselected."<br>";
185
-
186
-	// Update expandedsectionarray in session
187
-	$expandedsectionarray=array();
188
-	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
189
-
190
-	if ($section && GETPOST('sectionexpand') == 'true')
191
-	{
192
-		// We add all sections that are parent of opened section
193
-		$pathtosection=explode('_',$fullpathselected);
194
-		foreach($pathtosection as $idcursor)
195
-		{
196
-			if ($idcursor && ! in_array($idcursor,$expandedsectionarray))	// Not already in array
197
-			{
198
-				$expandedsectionarray[]=$idcursor;
199
-			}
200
-		}
201
-		$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
202
-	}
203
-	if ($section && GETPOST('sectionexpand') == 'false')
204
-	{
205
-		// We removed all expanded sections that are child of the closed section
206
-		$oldexpandedsectionarray=$expandedsectionarray;
207
-		$expandedsectionarray=array();	// Reset
208
-		foreach($oldexpandedsectionarray as $sectioncursor)
209
-		{
210
-			// TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this...
211
-			//if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
212
-		}
213
-		$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
214
-	}
215
-	//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
216
-
217
-	$nbofentries=0;
218
-	$oldvallevel=0;
219
-	foreach($sqltree as $key => $val)
220
-	{
221
-
222
-		$ecmdirstatic->id=$val['id'];
223
-		$ecmdirstatic->ref=$val['label'];
224
-
225
-		// Refresh cache
226
-		if (preg_match('/refresh/i',$action))
227
-		{
228
-			$result=$ecmdirstatic->fetch($val['id']);
229
-			$ecmdirstatic->ref=$ecmdirstatic->label;
230
-
231
-			$result=$ecmdirstatic->refreshcachenboffile(0);
232
-			$val['cachenbofdoc']=$result;
233
-		}
234
-
235
-		//$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
236
-
237
-		// Define showline
238
-		$showline=0;
239
-
240
-		// If directory is son of expanded directory, we show line
241
-		if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
242
-		// If directory is brother of selected directory, we show line
243
-		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
244
-		// If directory is parent of selected directory or is selected directory, we show line
245
-		elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
246
-		// If we are level one we show line
247
-		elseif ($val['level'] < 2) $showline=1;
248
-
249
-		if ($showline)
250
-		{
251
-			if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
252
-			else $option='indexnotexpanded';
253
-			//print $option;
254
-
255
-			print '<li class="directory collapsed">';
256
-
257
-			// Show tree graph pictos
258
-			$cpt=1;
259
-			while ($cpt < $sqltree[$key]['level'])
260
-			{
261
-				print ' &nbsp; &nbsp;';
262
-				$cpt++;
263
-			}
264
-			$resarray=tree_showpad($sqltree,$key,1);
265
-			$a=$resarray[0];
266
-			$nbofsubdir=$resarray[1];
267
-			$nboffilesinsubdir=$resarray[2];
268
-
269
-			// Show link
270
-			print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"');
271
-
272
-			print '<div class="ecmjqft">';
273
-
274
-			// Nb of docs
275
-			print '<table class="nobordernopadding"><tr><td>';
276
-			print $val['cachenbofdoc'];
277
-			print '</td>';
278
-			print '<td align="left">';
279
-			if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
280
-			print '</td>';
281
-
282
-			// Info
283
-			print '<td align="center">';
284
-			$userstatic->id=$val['fk_user_c'];
285
-			$userstatic->lastname=$val['login_c'];
286
-			$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
287
-			$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
288
-			$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
289
-			$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
290
-			$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
291
-			$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
292
-			if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
293
-			else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
294
-			print $form->textwithpicto('', $htmltooltip, 1, 'info');
295
-			print "</td>";
296
-
297
-			print '</tr></table>';
298
-
299
-			print '</div>';
300
-
301
-			print "</li>\n";
302
-		}
303
-
304
-		$oldvallevel=$val['level'];
305
-		$nbofentries++;
306
-	}
307
-
308
-	// If nothing to show
309
-	if ($nbofentries == 0)
310
-	{
311
-		print '<li class="directory collapsed">';
312
-		print '<div class="ecmjqft">';
313
-		print $langs->trans("ECMNoDirectoryYet");
314
-		print '</div>';
315
-		print "</li>\n";
316
-	}
317
-
318
-	print '</ul>';
164
+    print '<ul class="ecmjqft">';
165
+
166
+    // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
167
+    if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);    // Slow
168
+
169
+    // ----- This section will show a tree from a fulltree array -----
170
+    // $section must also be defined
171
+    // ----------------------------------------------------------------
172
+
173
+    // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree)
174
+    $fullpathselected='';
175
+    foreach($sqltree as $key => $val)
176
+    {
177
+        //print $val['id']."-".$section."<br>";
178
+        if ($val['id'] == $section)
179
+        {
180
+            $fullpathselected=$val['fullpath'];
181
+            break;
182
+        }
183
+    }
184
+    //print "fullpathselected=".$fullpathselected."<br>";
185
+
186
+    // Update expandedsectionarray in session
187
+    $expandedsectionarray=array();
188
+    if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
189
+
190
+    if ($section && GETPOST('sectionexpand') == 'true')
191
+    {
192
+        // We add all sections that are parent of opened section
193
+        $pathtosection=explode('_',$fullpathselected);
194
+        foreach($pathtosection as $idcursor)
195
+        {
196
+            if ($idcursor && ! in_array($idcursor,$expandedsectionarray))	// Not already in array
197
+            {
198
+                $expandedsectionarray[]=$idcursor;
199
+            }
200
+        }
201
+        $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
202
+    }
203
+    if ($section && GETPOST('sectionexpand') == 'false')
204
+    {
205
+        // We removed all expanded sections that are child of the closed section
206
+        $oldexpandedsectionarray=$expandedsectionarray;
207
+        $expandedsectionarray=array();	// Reset
208
+        foreach($oldexpandedsectionarray as $sectioncursor)
209
+        {
210
+            // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this...
211
+            //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
212
+        }
213
+        $_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
214
+    }
215
+    //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
216
+
217
+    $nbofentries=0;
218
+    $oldvallevel=0;
219
+    foreach($sqltree as $key => $val)
220
+    {
221
+
222
+        $ecmdirstatic->id=$val['id'];
223
+        $ecmdirstatic->ref=$val['label'];
224
+
225
+        // Refresh cache
226
+        if (preg_match('/refresh/i',$action))
227
+        {
228
+            $result=$ecmdirstatic->fetch($val['id']);
229
+            $ecmdirstatic->ref=$ecmdirstatic->label;
230
+
231
+            $result=$ecmdirstatic->refreshcachenboffile(0);
232
+            $val['cachenbofdoc']=$result;
233
+        }
234
+
235
+        //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
236
+
237
+        // Define showline
238
+        $showline=0;
239
+
240
+        // If directory is son of expanded directory, we show line
241
+        if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
242
+        // If directory is brother of selected directory, we show line
243
+        elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
244
+        // If directory is parent of selected directory or is selected directory, we show line
245
+        elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
246
+        // If we are level one we show line
247
+        elseif ($val['level'] < 2) $showline=1;
248
+
249
+        if ($showline)
250
+        {
251
+            if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
252
+            else $option='indexnotexpanded';
253
+            //print $option;
254
+
255
+            print '<li class="directory collapsed">';
256
+
257
+            // Show tree graph pictos
258
+            $cpt=1;
259
+            while ($cpt < $sqltree[$key]['level'])
260
+            {
261
+                print ' &nbsp; &nbsp;';
262
+                $cpt++;
263
+            }
264
+            $resarray=tree_showpad($sqltree,$key,1);
265
+            $a=$resarray[0];
266
+            $nbofsubdir=$resarray[1];
267
+            $nboffilesinsubdir=$resarray[2];
268
+
269
+            // Show link
270
+            print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"');
271
+
272
+            print '<div class="ecmjqft">';
273
+
274
+            // Nb of docs
275
+            print '<table class="nobordernopadding"><tr><td>';
276
+            print $val['cachenbofdoc'];
277
+            print '</td>';
278
+            print '<td align="left">';
279
+            if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
280
+            print '</td>';
281
+
282
+            // Info
283
+            print '<td align="center">';
284
+            $userstatic->id=$val['fk_user_c'];
285
+            $userstatic->lastname=$val['login_c'];
286
+            $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
287
+            $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
288
+            $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
289
+            $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
290
+            $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
291
+            $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
292
+            if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
293
+            else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
294
+            print $form->textwithpicto('', $htmltooltip, 1, 'info');
295
+            print "</td>";
296
+
297
+            print '</tr></table>';
298
+
299
+            print '</div>';
300
+
301
+            print "</li>\n";
302
+        }
303
+
304
+        $oldvallevel=$val['level'];
305
+        $nbofentries++;
306
+    }
307
+
308
+    // If nothing to show
309
+    if ($nbofentries == 0)
310
+    {
311
+        print '<li class="directory collapsed">';
312
+        print '<div class="ecmjqft">';
313
+        print $langs->trans("ECMNoDirectoryYet");
314
+        print '</div>';
315
+        print "</li>\n";
316
+    }
317
+
318
+    print '</ul>';
319 319
 }
320 320
 
321 321
 
@@ -340,156 +340,156 @@  discard block
 block discarded – undo
340 340
  */
341 341
 function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0)
342 342
 {
343
-	global $conf, $db, $langs, $form;
344
-	global $dolibarr_main_data_root;
345
-
346
-	$ecmdirstatic = new EcmDirectory($db);
347
-	$userstatic = new User($db);
348
-
349
-	if (file_exists($fullpathselecteddir))
350
-	{
351
-		$files = @scandir($fullpathselecteddir);
352
-
353
-		if (! empty($files))
354
-		{
355
-			natcasesort($files);
356
-			if (count($files) > 2)    /* The 2 accounts for . and .. */
357
-			{
358
-				echo '<ul class="ecmjqft" style="display: none;">'."\n";
359
-
360
-				// All dirs
361
-				foreach ($files as $file)    // $file can be '.', '..', or 'My dir' or 'My file'
362
-				{
363
-					if ($file == 'temp') continue;
364
-
365
-					$nbofsubdir=0;
366
-					$nboffilesinsubdir=0;
367
-
368
-					$val=array();
369
-
370
-					// Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
371
-					foreach($sqltree as $key => $tmpval)
372
-					{
373
-						//print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
374
-						if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))		// We found equivalent record into database
375
-						{
376
-							$val=$tmpval;
377
-							$resarray=tree_showpad($sqltree,$key,1);
378
-
379
-							// Refresh cache for this subdir
380
-							if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0)	// Cache is not up to date, so we update it for this directory t
381
-							{
382
-								$result=$ecmdirstatic->fetch($val['id']);
383
-								$ecmdirstatic->ref=$ecmdirstatic->label;
384
-
385
-								$result=$ecmdirstatic->refreshcachenboffile(0);
386
-								$val['cachenbofdoc']=$result;
387
-							}
388
-
389
-							$a=$resarray[0];
390
-							$nbofsubdir=$resarray[1];
391
-							$nboffilesinsubdir=$resarray[2];
392
-							break;
393
-						}
394
-					}
395
-
396
-					//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
397
-					if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
398
-					{
399
-						if (empty($val['fullrelativename']))	// If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
400
-						{
401
-							$val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
402
-							$val['id']=0;
403
-							$val['label']=$file;
404
-							$val['description']='';
405
-							$nboffilesinsubdir=$langs->trans("Unknown");
406
-						}
407
-
408
-						$collapsedorexpanded='collapsed';
409
-						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded';
410
-						print '<li class="directory '.$collapsedorexpanded.'">';	// collapsed is opposite if expanded
411
-
412
-						print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
413
-						print "#";
414
-						print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\"";
415
-						print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")";
416
-						print "\">";
417
-						print dol_escape_htmltag($file);
418
-						print "</a>";
419
-
420
-						print '<div class="ecmjqft">';
421
-
422
-						print '<table class="nobordernopadding"><tr>';
423
-
424
-						/*print '<td align="left">';
343
+    global $conf, $db, $langs, $form;
344
+    global $dolibarr_main_data_root;
345
+
346
+    $ecmdirstatic = new EcmDirectory($db);
347
+    $userstatic = new User($db);
348
+
349
+    if (file_exists($fullpathselecteddir))
350
+    {
351
+        $files = @scandir($fullpathselecteddir);
352
+
353
+        if (! empty($files))
354
+        {
355
+            natcasesort($files);
356
+            if (count($files) > 2)    /* The 2 accounts for . and .. */
357
+            {
358
+                echo '<ul class="ecmjqft" style="display: none;">'."\n";
359
+
360
+                // All dirs
361
+                foreach ($files as $file)    // $file can be '.', '..', or 'My dir' or 'My file'
362
+                {
363
+                    if ($file == 'temp') continue;
364
+
365
+                    $nbofsubdir=0;
366
+                    $nboffilesinsubdir=0;
367
+
368
+                    $val=array();
369
+
370
+                    // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
371
+                    foreach($sqltree as $key => $tmpval)
372
+                    {
373
+                        //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
374
+                        if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))		// We found equivalent record into database
375
+                        {
376
+                            $val=$tmpval;
377
+                            $resarray=tree_showpad($sqltree,$key,1);
378
+
379
+                            // Refresh cache for this subdir
380
+                            if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0)	// Cache is not up to date, so we update it for this directory t
381
+                            {
382
+                                $result=$ecmdirstatic->fetch($val['id']);
383
+                                $ecmdirstatic->ref=$ecmdirstatic->label;
384
+
385
+                                $result=$ecmdirstatic->refreshcachenboffile(0);
386
+                                $val['cachenbofdoc']=$result;
387
+                            }
388
+
389
+                            $a=$resarray[0];
390
+                            $nbofsubdir=$resarray[1];
391
+                            $nboffilesinsubdir=$resarray[2];
392
+                            break;
393
+                        }
394
+                    }
395
+
396
+                    //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
397
+                    if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
398
+                    {
399
+                        if (empty($val['fullrelativename']))	// If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
400
+                        {
401
+                            $val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
402
+                            $val['id']=0;
403
+                            $val['label']=$file;
404
+                            $val['description']='';
405
+                            $nboffilesinsubdir=$langs->trans("Unknown");
406
+                        }
407
+
408
+                        $collapsedorexpanded='collapsed';
409
+                        if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded';
410
+                        print '<li class="directory '.$collapsedorexpanded.'">';	// collapsed is opposite if expanded
411
+
412
+                        print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
413
+                        print "#";
414
+                        print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\"";
415
+                        print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")";
416
+                        print "\">";
417
+                        print dol_escape_htmltag($file);
418
+                        print "</a>";
419
+
420
+                        print '<div class="ecmjqft">';
421
+
422
+                        print '<table class="nobordernopadding"><tr>';
423
+
424
+                        /*print '<td align="left">';
425 425
 						 print dol_escape_htmltag($file);
426 426
 						 print '</td>';*/
427 427
 
428
-						// Nb of docs
429
-						print '<td align="right">';
430
-						print (isset($val['cachenbofdoc']) && $val['cachenbofdoc']  >= 0)?$val['cachenbofdoc']:'&nbsp;';
431
-						print '</td>';
432
-						print '<td align="left">';
433
-						if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
434
-						print '</td>';
435
-
436
-						// Edit link
437
-						print '<td align="right" width="18"><a href="';
438
-						print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'&section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
439
-						print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
440
-						print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>';
441
-
442
-						// Add link
443
-						//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
444
-						//print '<td align="right" width="14">&nbsp;</td>';
445
-
446
-						// Info
447
-						if ($modulepart == 'ecm')
448
-						{
449
-							print '<td align="right" width="18">';
450
-							$userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
451
-							$userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
452
-							$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
453
-							$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
454
-							$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
455
-							$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
456
-							$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
457
-							$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
458
-							if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
459
-							else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
460
-							print $form->textwithpicto('',$htmltooltip,1,"info");
461
-							print "</td>";
462
-						}
463
-
464
-						print "</tr></table>\n";
465
-						print '</div>';
466
-
467
-						//print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n";
468
-						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened))
469
-						{
470
-							//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
471
-							$newselecteddir = $val['fullrelativename'];
472
-							$newfullpathselecteddir='';
473
-							if ($modulepart == 'ecm')
474
-							{
475
-								$newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
476
-							}
477
-							elseif ($modulepart == 'medias')
478
-							{
479
-								$newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
480
-							}
481
-
482
-							if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
483
-						}
484
-
485
-						print "</li>\n";
486
-					}
487
-				}
488
-
489
-				echo "</ul>\n";
490
-			}
491
-		}
492
-		else print "PermissionDenied";
493
-	}
428
+                        // Nb of docs
429
+                        print '<td align="right">';
430
+                        print (isset($val['cachenbofdoc']) && $val['cachenbofdoc']  >= 0)?$val['cachenbofdoc']:'&nbsp;';
431
+                        print '</td>';
432
+                        print '<td align="left">';
433
+                        if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
434
+                        print '</td>';
435
+
436
+                        // Edit link
437
+                        print '<td align="right" width="18"><a href="';
438
+                        print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'&section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
439
+                        print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
440
+                        print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>';
441
+
442
+                        // Add link
443
+                        //print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
444
+                        //print '<td align="right" width="14">&nbsp;</td>';
445
+
446
+                        // Info
447
+                        if ($modulepart == 'ecm')
448
+                        {
449
+                            print '<td align="right" width="18">';
450
+                            $userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
451
+                            $userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
452
+                            $htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
453
+                            $htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
454
+                            $htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
455
+                            $htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
456
+                            $htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
457
+                            $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
458
+                            if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
459
+                            else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
460
+                            print $form->textwithpicto('',$htmltooltip,1,"info");
461
+                            print "</td>";
462
+                        }
463
+
464
+                        print "</tr></table>\n";
465
+                        print '</div>';
466
+
467
+                        //print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n";
468
+                        if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened))
469
+                        {
470
+                            //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
471
+                            $newselecteddir = $val['fullrelativename'];
472
+                            $newfullpathselecteddir='';
473
+                            if ($modulepart == 'ecm')
474
+                            {
475
+                                $newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
476
+                            }
477
+                            elseif ($modulepart == 'medias')
478
+                            {
479
+                                $newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
480
+                            }
481
+
482
+                            if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
483
+                        }
484
+
485
+                        print "</li>\n";
486
+                    }
487
+                }
488
+
489
+                echo "</ul>\n";
490
+            }
491
+        }
492
+        else print "PermissionDenied";
493
+    }
494 494
 }
495 495
 
Please login to merge, or discard this patch.
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 // This script is called with a POST method.
27 27
 // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax
28 28
 
29
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
30
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
31
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
32
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
29
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
30
+if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
31
+if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
32
+if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
33 33
 
34 34
 
35
-if (! isset($mode) || $mode != 'noajax')    // For ajax call
35
+if (!isset($mode) || $mode != 'noajax')    // For ajax call
36 36
 {
37
-	$res=@include '../../main.inc.php';
37
+	$res = @include '../../main.inc.php';
38 38
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 39
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40 40
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
@@ -44,58 +44,58 @@  discard block
 block discarded – undo
44 44
 	//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = '/bbb/'; }
45 45
 
46 46
 	$openeddir = GETPOST('openeddir');
47
-	$modulepart= GETPOST('modulepart');
48
-	$selecteddir = jsUnEscape(GETPOST('dir'));        // relative path. We must decode using same encoding function used by javascript: escape()
47
+	$modulepart = GETPOST('modulepart');
48
+	$selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape()
49 49
 
50 50
 	$preopened = GETPOST('preopened');
51 51
 
52
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
52
+	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
53 53
 }
54 54
 else    // For no ajax call
55 55
 {
56 56
 	//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
57 57
 
58 58
 	$openeddir = GETPOST('openeddir');
59
-	$modulepart= GETPOST('modulepart');
59
+	$modulepart = GETPOST('modulepart');
60 60
 	$selecteddir = GETPOST('dir');
61 61
 
62 62
 	$preopened = GETPOST('preopened');
63 63
 
64
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
65
-	if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
64
+	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
65
+	if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php';
66 66
 }
67 67
 
68 68
 // Load translation files required by the page
69 69
 $langs->load("ecm");
70 70
 
71 71
 // Define fullpathselecteddir.
72
-$fullpathselecteddir='<none>';
72
+$fullpathselecteddir = '<none>';
73 73
 if ($modulepart == 'ecm')
74 74
 {
75
-	$fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
76
-	$fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
75
+	$fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
76
+	$fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
77 77
 }
78 78
 elseif ($modulepart == 'medias')
79 79
 {
80
-	$fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
81
-	$fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
80
+	$fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
81
+	$fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
82 82
 }
83 83
 
84 84
 
85 85
 // Security:
86 86
 // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
87
-if (preg_match('/\.\./',$fullpathselecteddir) || preg_match('/[<>|]/',$fullpathselecteddir))
87
+if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir))
88 88
 {
89 89
     dol_syslog("Refused to deliver file ".$original_file);
90 90
     // Do no show plain path in shown error message
91
-    dol_print_error(0,$langs->trans("ErrorFileNameInvalid",GETPOST("file")));
91
+    dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file")));
92 92
     exit;
93 93
 }
94 94
 
95 95
 // Check permissions
96 96
 if ($modulepart == 'ecm')
97 97
 {
98
-	if (! $user->rights->ecm->read) accessforbidden();
98
+	if (!$user->rights->ecm->read) accessforbidden();
99 99
 }
100 100
 elseif ($modulepart == 'medias')
101 101
 {
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
  * View
108 108
  */
109 109
 
110
-if (! isset($mode) || $mode != 'noajax')	// if ajax mode
110
+if (!isset($mode) || $mode != 'noajax')	// if ajax mode
111 111
 {
112 112
 	top_httphead();
113 113
 }
114 114
 
115 115
 //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n";
116
-$userstatic=new User($db);
117
-$form=new Form($db);
116
+$userstatic = new User($db);
117
+$form = new Form($db);
118 118
 $ecmdirstatic = new EcmDirectory($db);
119 119
 
120 120
 // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir
121
-if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
121
+if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0);
122 122
 
123 123
 // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id
124
-$current_ecmdir_id=-1;
125
-foreach($sqltree as $keycursor => $val)
124
+$current_ecmdir_id = -1;
125
+foreach ($sqltree as $keycursor => $val)
126 126
 {
127 127
     //print $val['fullrelativename']." == ".$selecteddir;
128 128
     if ($val['fullrelativename'] == $selecteddir)
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     }
132 132
 }
133 133
 
134
-if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
134
+if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
135 135
 {
136 136
 	treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
137 137
 
@@ -159,115 +159,115 @@  discard block
 block discarded – undo
159 159
 }
160 160
 
161 161
 
162
-if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE_JS))
162
+if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS))
163 163
 {
164 164
 	print '<ul class="ecmjqft">';
165 165
 
166 166
 	// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
167
-	if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);    // Slow
167
+	if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow
168 168
 
169 169
 	// ----- This section will show a tree from a fulltree array -----
170 170
 	// $section must also be defined
171 171
 	// ----------------------------------------------------------------
172 172
 
173 173
 	// Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree)
174
-	$fullpathselected='';
175
-	foreach($sqltree as $key => $val)
174
+	$fullpathselected = '';
175
+	foreach ($sqltree as $key => $val)
176 176
 	{
177 177
 		//print $val['id']."-".$section."<br>";
178 178
 		if ($val['id'] == $section)
179 179
 		{
180
-			$fullpathselected=$val['fullpath'];
180
+			$fullpathselected = $val['fullpath'];
181 181
 			break;
182 182
 		}
183 183
 	}
184 184
 	//print "fullpathselected=".$fullpathselected."<br>";
185 185
 
186 186
 	// Update expandedsectionarray in session
187
-	$expandedsectionarray=array();
188
-	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
187
+	$expandedsectionarray = array();
188
+	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']);
189 189
 
190 190
 	if ($section && GETPOST('sectionexpand') == 'true')
191 191
 	{
192 192
 		// We add all sections that are parent of opened section
193
-		$pathtosection=explode('_',$fullpathselected);
194
-		foreach($pathtosection as $idcursor)
193
+		$pathtosection = explode('_', $fullpathselected);
194
+		foreach ($pathtosection as $idcursor)
195 195
 		{
196
-			if ($idcursor && ! in_array($idcursor,$expandedsectionarray))	// Not already in array
196
+			if ($idcursor && !in_array($idcursor, $expandedsectionarray))	// Not already in array
197 197
 			{
198
-				$expandedsectionarray[]=$idcursor;
198
+				$expandedsectionarray[] = $idcursor;
199 199
 			}
200 200
 		}
201
-		$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
201
+		$_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray);
202 202
 	}
203 203
 	if ($section && GETPOST('sectionexpand') == 'false')
204 204
 	{
205 205
 		// We removed all expanded sections that are child of the closed section
206
-		$oldexpandedsectionarray=$expandedsectionarray;
207
-		$expandedsectionarray=array();	// Reset
208
-		foreach($oldexpandedsectionarray as $sectioncursor)
206
+		$oldexpandedsectionarray = $expandedsectionarray;
207
+		$expandedsectionarray = array(); // Reset
208
+		foreach ($oldexpandedsectionarray as $sectioncursor)
209 209
 		{
210 210
 			// TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this...
211 211
 			//if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
212 212
 		}
213
-		$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
213
+		$_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray);
214 214
 	}
215 215
 	//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
216 216
 
217
-	$nbofentries=0;
218
-	$oldvallevel=0;
219
-	foreach($sqltree as $key => $val)
217
+	$nbofentries = 0;
218
+	$oldvallevel = 0;
219
+	foreach ($sqltree as $key => $val)
220 220
 	{
221 221
 
222
-		$ecmdirstatic->id=$val['id'];
223
-		$ecmdirstatic->ref=$val['label'];
222
+		$ecmdirstatic->id = $val['id'];
223
+		$ecmdirstatic->ref = $val['label'];
224 224
 
225 225
 		// Refresh cache
226
-		if (preg_match('/refresh/i',$action))
226
+		if (preg_match('/refresh/i', $action))
227 227
 		{
228
-			$result=$ecmdirstatic->fetch($val['id']);
229
-			$ecmdirstatic->ref=$ecmdirstatic->label;
228
+			$result = $ecmdirstatic->fetch($val['id']);
229
+			$ecmdirstatic->ref = $ecmdirstatic->label;
230 230
 
231
-			$result=$ecmdirstatic->refreshcachenboffile(0);
232
-			$val['cachenbofdoc']=$result;
231
+			$result = $ecmdirstatic->refreshcachenboffile(0);
232
+			$val['cachenbofdoc'] = $result;
233 233
 		}
234 234
 
235 235
 		//$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
236 236
 
237 237
 		// Define showline
238
-		$showline=0;
238
+		$showline = 0;
239 239
 
240 240
 		// If directory is son of expanded directory, we show line
241
-		if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
241
+		if (in_array($val['id_mere'], $expandedsectionarray)) $showline = 4;
242 242
 		// If directory is brother of selected directory, we show line
243
-		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
243
+		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3;
244 244
 		// If directory is parent of selected directory or is selected directory, we show line
245
-		elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
245
+		elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2;
246 246
 		// If we are level one we show line
247
-		elseif ($val['level'] < 2) $showline=1;
247
+		elseif ($val['level'] < 2) $showline = 1;
248 248
 
249 249
 		if ($showline)
250 250
 		{
251
-			if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
252
-			else $option='indexnotexpanded';
251
+			if (in_array($val['id'], $expandedsectionarray)) $option = 'indexexpanded';
252
+			else $option = 'indexnotexpanded';
253 253
 			//print $option;
254 254
 
255 255
 			print '<li class="directory collapsed">';
256 256
 
257 257
 			// Show tree graph pictos
258
-			$cpt=1;
258
+			$cpt = 1;
259 259
 			while ($cpt < $sqltree[$key]['level'])
260 260
 			{
261 261
 				print ' &nbsp; &nbsp;';
262 262
 				$cpt++;
263 263
 			}
264
-			$resarray=tree_showpad($sqltree,$key,1);
265
-			$a=$resarray[0];
266
-			$nbofsubdir=$resarray[1];
267
-			$nboffilesinsubdir=$resarray[2];
264
+			$resarray = tree_showpad($sqltree, $key, 1);
265
+			$a = $resarray[0];
266
+			$nbofsubdir = $resarray[1];
267
+			$nboffilesinsubdir = $resarray[2];
268 268
 
269 269
 			// Show link
270
-			print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"');
270
+			print $ecmdirstatic->getNomUrl(0, $option, 32, 'class="fmdirlia jqft ecmjqft"');
271 271
 
272 272
 			print '<div class="ecmjqft">';
273 273
 
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 
282 282
 			// Info
283 283
 			print '<td align="center">';
284
-			$userstatic->id=$val['fk_user_c'];
285
-			$userstatic->lastname=$val['login_c'];
286
-			$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
287
-			$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
288
-			$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
289
-			$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
290
-			$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
291
-			$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
292
-			if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
293
-			else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
284
+			$userstatic->id = $val['fk_user_c'];
285
+			$userstatic->lastname = $val['login_c'];
286
+			$htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
287
+			$htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
288
+			$htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
289
+			$htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'], "dayhour").'<br>';
290
+			$htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
291
+			$htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
292
+			if ($nbofsubdir) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
293
+			else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
294 294
 			print $form->textwithpicto('', $htmltooltip, 1, 'info');
295 295
 			print "</td>";
296 296
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 			print "</li>\n";
302 302
 		}
303 303
 
304
-		$oldvallevel=$val['level'];
304
+		$oldvallevel = $val['level'];
305 305
 		$nbofentries++;
306 306
 	}
307 307
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 
321 321
 
322 322
 // Close db if mode is not noajax
323
-if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
323
+if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
324 324
 
325 325
 
326 326
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
  * @param	int		$depth					Depth
339 339
  * @return	void
340 340
  */
341
-function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0)
341
+function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0)
342 342
 {
343 343
 	global $conf, $db, $langs, $form;
344 344
 	global $dolibarr_main_data_root;
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	{
351 351
 		$files = @scandir($fullpathselecteddir);
352 352
 
353
-		if (! empty($files))
353
+		if (!empty($files))
354 354
 		{
355 355
 			natcasesort($files);
356 356
 			if (count($files) > 2)    /* The 2 accounts for . and .. */
@@ -362,56 +362,56 @@  discard block
 block discarded – undo
362 362
 				{
363 363
 					if ($file == 'temp') continue;
364 364
 
365
-					$nbofsubdir=0;
366
-					$nboffilesinsubdir=0;
365
+					$nbofsubdir = 0;
366
+					$nboffilesinsubdir = 0;
367 367
 
368
-					$val=array();
368
+					$val = array();
369 369
 
370 370
 					// Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
371
-					foreach($sqltree as $key => $tmpval)
371
+					foreach ($sqltree as $key => $tmpval)
372 372
 					{
373 373
 						//print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
374
-						if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))		// We found equivalent record into database
374
+						if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file))		// We found equivalent record into database
375 375
 						{
376
-							$val=$tmpval;
377
-							$resarray=tree_showpad($sqltree,$key,1);
376
+							$val = $tmpval;
377
+							$resarray = tree_showpad($sqltree, $key, 1);
378 378
 
379 379
 							// Refresh cache for this subdir
380 380
 							if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0)	// Cache is not up to date, so we update it for this directory t
381 381
 							{
382
-								$result=$ecmdirstatic->fetch($val['id']);
383
-								$ecmdirstatic->ref=$ecmdirstatic->label;
382
+								$result = $ecmdirstatic->fetch($val['id']);
383
+								$ecmdirstatic->ref = $ecmdirstatic->label;
384 384
 
385
-								$result=$ecmdirstatic->refreshcachenboffile(0);
386
-								$val['cachenbofdoc']=$result;
385
+								$result = $ecmdirstatic->refreshcachenboffile(0);
386
+								$val['cachenbofdoc'] = $result;
387 387
 							}
388 388
 
389
-							$a=$resarray[0];
390
-							$nbofsubdir=$resarray[1];
391
-							$nboffilesinsubdir=$resarray[2];
389
+							$a = $resarray[0];
390
+							$nbofsubdir = $resarray[1];
391
+							$nboffilesinsubdir = $resarray[2];
392 392
 							break;
393 393
 						}
394 394
 					}
395 395
 
396 396
 					//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
397
-					if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
397
+					if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file)))
398 398
 					{
399 399
 						if (empty($val['fullrelativename']))	// If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
400 400
 						{
401
-							$val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
402
-							$val['id']=0;
403
-							$val['label']=$file;
404
-							$val['description']='';
405
-							$nboffilesinsubdir=$langs->trans("Unknown");
401
+							$val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file;
402
+							$val['id'] = 0;
403
+							$val['label'] = $file;
404
+							$val['description'] = '';
405
+							$nboffilesinsubdir = $langs->trans("Unknown");
406 406
 						}
407 407
 
408
-						$collapsedorexpanded='collapsed';
409
-						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded';
410
-						print '<li class="directory '.$collapsedorexpanded.'">';	// collapsed is opposite if expanded
408
+						$collapsedorexpanded = 'collapsed';
409
+						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded = 'expanded';
410
+						print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded
411 411
 
412 412
 						print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
413 413
 						print "#";
414
-						print "\" rel=\"" . dol_escape_htmltag($val['fullrelativename'].'/') . "\" id=\"fmdirlia_id_".$val['id']."\"";
414
+						print "\" rel=\"".dol_escape_htmltag($val['fullrelativename'].'/')."\" id=\"fmdirlia_id_".$val['id']."\"";
415 415
 						print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")";
416 416
 						print "\">";
417 417
 						print dol_escape_htmltag($file);
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 
428 428
 						// Nb of docs
429 429
 						print '<td align="right">';
430
-						print (isset($val['cachenbofdoc']) && $val['cachenbofdoc']  >= 0)?$val['cachenbofdoc']:'&nbsp;';
430
+						print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : '&nbsp;';
431 431
 						print '</td>';
432 432
 						print '<td align="left">';
433
-						if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
433
+						if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
434 434
 						print '</td>';
435 435
 
436 436
 						// Edit link
@@ -447,17 +447,17 @@  discard block
 block discarded – undo
447 447
 						if ($modulepart == 'ecm')
448 448
 						{
449 449
 							print '<td align="right" width="18">';
450
-							$userstatic->id=isset($val['fk_user_c'])?$val['fk_user_c']:0;
451
-							$userstatic->lastname=isset($val['login_c'])?$val['login_c']:0;
452
-							$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
453
-							$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
454
-							$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
455
-							$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
456
-							$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
457
-							$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
458
-							if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
459
-							else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
460
-							print $form->textwithpicto('',$htmltooltip,1,"info");
450
+							$userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0;
451
+							$userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0;
452
+							$htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
453
+							$htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
454
+							$htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
455
+							$htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'<br>';
456
+							$htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
457
+							$htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : $langs->trans("NeedRefresh")).'<br>';
458
+							if ($nboffilesinsubdir > 0) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
459
+							else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
460
+							print $form->textwithpicto('', $htmltooltip, 1, "info");
461 461
 							print "</td>";
462 462
 						}
463 463
 
@@ -469,17 +469,17 @@  discard block
 block discarded – undo
469 469
 						{
470 470
 							//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
471 471
 							$newselecteddir = $val['fullrelativename'];
472
-							$newfullpathselecteddir='';
472
+							$newfullpathselecteddir = '';
473 473
 							if ($modulepart == 'ecm')
474 474
 							{
475
-								$newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
475
+								$newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
476 476
 							}
477 477
 							elseif ($modulepart == 'medias')
478 478
 							{
479
-								$newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
479
+								$newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
480 480
 							}
481 481
 
482
-							if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
482
+							if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
483 483
 						}
484 484
 
485 485
 						print "</li>\n";
Please login to merge, or discard this patch.
Braces   +110 added lines, -44 removed lines patch added patch discarded remove patch
@@ -26,15 +26,26 @@  discard block
 block discarded – undo
26 26
 // This script is called with a POST method.
27 27
 // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax
28 28
 
29
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
30
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
31
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
32
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
29
+if (! defined('NOTOKENRENEWAL')) {
30
+    define('NOTOKENRENEWAL',1);
31
+}
32
+// Disables token renewal
33
+if (! defined('NOREQUIREMENU')) {
34
+    define('NOREQUIREMENU','1');
35
+}
36
+if (! defined('NOREQUIREHTML')) {
37
+    define('NOREQUIREHTML','1');
38
+}
39
+if (! defined('NOREQUIREAJAX')) {
40
+    define('NOREQUIREAJAX','1');
41
+}
33 42
 
34 43
 
35
-if (! isset($mode) || $mode != 'noajax')    // For ajax call
44
+if (! isset($mode) || $mode != 'noajax') {
45
+    // For ajax call
36 46
 {
37 47
 	$res=@include '../../main.inc.php';
48
+}
38 49
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 50
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40 51
 	include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
@@ -49,9 +60,11 @@  discard block
 block discarded – undo
49 60
 
50 61
 	$preopened = GETPOST('preopened');
51 62
 
52
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
53
-}
54
-else    // For no ajax call
63
+	if ($selecteddir != '/') {
64
+	    $selecteddir = preg_replace('/\/$/','',$selecteddir);
65
+	}
66
+	// We removed last '/' except if it is '/'
67
+} else    // For no ajax call
55 68
 {
56 69
 	//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
57 70
 
@@ -61,9 +74,14 @@  discard block
 block discarded – undo
61 74
 
62 75
 	$preopened = GETPOST('preopened');
63 76
 
64
-	if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/','',$selecteddir);    // We removed last '/' except if it is '/'
65
-	if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
66
-}
77
+	if ($selecteddir != '/') {
78
+	    $selecteddir = preg_replace('/\/$/','',$selecteddir);
79
+	}
80
+	// We removed last '/' except if it is '/'
81
+	if (empty($url)) {
82
+	    $url=DOL_URL_ROOT.'/ecm/index.php';
83
+	}
84
+	}
67 85
 
68 86
 // Load translation files required by the page
69 87
 $langs->load("ecm");
@@ -74,8 +92,7 @@  discard block
 block discarded – undo
74 92
 {
75 93
 	$fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
76 94
 	$fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
77
-}
78
-elseif ($modulepart == 'medias')
95
+} elseif ($modulepart == 'medias')
79 96
 {
80 97
 	$fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
81 98
 	$fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
@@ -95,9 +112,10 @@  discard block
 block discarded – undo
95 112
 // Check permissions
96 113
 if ($modulepart == 'ecm')
97 114
 {
98
-	if (! $user->rights->ecm->read) accessforbidden();
99
-}
100
-elseif ($modulepart == 'medias')
115
+	if (! $user->rights->ecm->read) {
116
+	    accessforbidden();
117
+	}
118
+	} elseif ($modulepart == 'medias')
101 119
 {
102 120
 	// Always allowed
103 121
 }
@@ -107,10 +125,12 @@  discard block
 block discarded – undo
107 125
  * View
108 126
  */
109 127
 
110
-if (! isset($mode) || $mode != 'noajax')	// if ajax mode
128
+if (! isset($mode) || $mode != 'noajax') {
129
+    // if ajax mode
111 130
 {
112 131
 	top_httphead();
113 132
 }
133
+}
114 134
 
115 135
 //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n";
116 136
 $userstatic=new User($db);
@@ -118,7 +138,9 @@  discard block
 block discarded – undo
118 138
 $ecmdirstatic = new EcmDirectory($db);
119 139
 
120 140
 // Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir
121
-if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);
141
+if (empty($sqltree)) {
142
+    $sqltree=$ecmdirstatic->get_full_arbo(0);
143
+}
122 144
 
123 145
 // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id
124 146
 $current_ecmdir_id=-1;
@@ -164,7 +186,10 @@  discard block
 block discarded – undo
164 186
 	print '<ul class="ecmjqft">';
165 187
 
166 188
 	// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
167
-	if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0);    // Slow
189
+	if (empty($sqltree)) {
190
+	    $sqltree=$ecmdirstatic->get_full_arbo(0);
191
+	}
192
+	// Slow
168 193
 
169 194
 	// ----- This section will show a tree from a fulltree array -----
170 195
 	// $section must also be defined
@@ -185,7 +210,9 @@  discard block
 block discarded – undo
185 210
 
186 211
 	// Update expandedsectionarray in session
187 212
 	$expandedsectionarray=array();
188
-	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
213
+	if (isset($_SESSION['dol_ecmexpandedsectionarray'])) {
214
+	    $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
215
+	}
189 216
 
190 217
 	if ($section && GETPOST('sectionexpand') == 'true')
191 218
 	{
@@ -193,10 +220,12 @@  discard block
 block discarded – undo
193 220
 		$pathtosection=explode('_',$fullpathselected);
194 221
 		foreach($pathtosection as $idcursor)
195 222
 		{
196
-			if ($idcursor && ! in_array($idcursor,$expandedsectionarray))	// Not already in array
223
+			if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) {
224
+			    // Not already in array
197 225
 			{
198 226
 				$expandedsectionarray[]=$idcursor;
199 227
 			}
228
+			}
200 229
 		}
201 230
 		$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
202 231
 	}
@@ -238,18 +267,29 @@  discard block
 block discarded – undo
238 267
 		$showline=0;
239 268
 
240 269
 		// If directory is son of expanded directory, we show line
241
-		if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
270
+		if (in_array($val['id_mere'],$expandedsectionarray)) {
271
+		    $showline=4;
272
+		}
242 273
 		// If directory is brother of selected directory, we show line
243
-		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
274
+		elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) {
275
+		    $showline=3;
276
+		}
244 277
 		// If directory is parent of selected directory or is selected directory, we show line
245
-		elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
278
+		elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) {
279
+		    $showline=2;
280
+		}
246 281
 		// If we are level one we show line
247
-		elseif ($val['level'] < 2) $showline=1;
282
+		elseif ($val['level'] < 2) {
283
+		    $showline=1;
284
+		}
248 285
 
249 286
 		if ($showline)
250 287
 		{
251
-			if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
252
-			else $option='indexnotexpanded';
288
+			if (in_array($val['id'],$expandedsectionarray)) {
289
+			    $option='indexexpanded';
290
+			} else {
291
+			    $option='indexnotexpanded';
292
+			}
253 293
 			//print $option;
254 294
 
255 295
 			print '<li class="directory collapsed">';
@@ -276,7 +316,9 @@  discard block
 block discarded – undo
276 316
 			print $val['cachenbofdoc'];
277 317
 			print '</td>';
278 318
 			print '<td align="left">';
279
-			if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
319
+			if ($nbofsubdir && $nboffilesinsubdir) {
320
+			    print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
321
+			}
280 322
 			print '</td>';
281 323
 
282 324
 			// Info
@@ -289,8 +331,11 @@  discard block
 block discarded – undo
289 331
 			$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
290 332
 			$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
291 333
 			$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
292
-			if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
293
-			else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
334
+			if ($nbofsubdir) {
335
+			    $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
336
+			} else {
337
+			    $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
338
+			}
294 339
 			print $form->textwithpicto('', $htmltooltip, 1, 'info');
295 340
 			print "</td>";
296 341
 
@@ -320,7 +365,9 @@  discard block
 block discarded – undo
320 365
 
321 366
 
322 367
 // Close db if mode is not noajax
323
-if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
368
+if ((! isset($mode) || $mode != 'noajax') && is_object($db)) {
369
+    $db->close();
370
+}
324 371
 
325 372
 
326 373
 
@@ -353,14 +400,18 @@  discard block
 block discarded – undo
353 400
 		if (! empty($files))
354 401
 		{
355 402
 			natcasesort($files);
356
-			if (count($files) > 2)    /* The 2 accounts for . and .. */
403
+			if (count($files) > 2) {
404
+			    /* The 2 accounts for . and .. */
357 405
 			{
358 406
 				echo '<ul class="ecmjqft" style="display: none;">'."\n";
407
+			}
359 408
 
360 409
 				// All dirs
361
-				foreach ($files as $file)    // $file can be '.', '..', or 'My dir' or 'My file'
410
+				foreach ($files as $file) {
411
+				    // $file can be '.', '..', or 'My dir' or 'My file'
362 412
 				{
363 413
 					if ($file == 'temp') continue;
414
+				}
364 415
 
365 416
 					$nbofsubdir=0;
366 417
 					$nboffilesinsubdir=0;
@@ -371,15 +422,19 @@  discard block
 block discarded – undo
371 422
 					foreach($sqltree as $key => $tmpval)
372 423
 					{
373 424
 						//print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
374
-						if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))		// We found equivalent record into database
425
+						if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file)) {
426
+						    // We found equivalent record into database
375 427
 						{
376 428
 							$val=$tmpval;
429
+						}
377 430
 							$resarray=tree_showpad($sqltree,$key,1);
378 431
 
379 432
 							// Refresh cache for this subdir
380
-							if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0)	// Cache is not up to date, so we update it for this directory t
433
+							if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) {
434
+							    // Cache is not up to date, so we update it for this directory t
381 435
 							{
382 436
 								$result=$ecmdirstatic->fetch($val['id']);
437
+							}
383 438
 								$ecmdirstatic->ref=$ecmdirstatic->label;
384 439
 
385 440
 								$result=$ecmdirstatic->refreshcachenboffile(0);
@@ -396,9 +451,11 @@  discard block
 block discarded – undo
396 451
 					//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
397 452
 					if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . (preg_match('/\/$/',$fullpathselecteddir)?'':'/') . $file)))
398 453
 					{
399
-						if (empty($val['fullrelativename']))	// If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
454
+						if (empty($val['fullrelativename'])) {
455
+						    // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
400 456
 						{
401 457
 							$val['fullrelativename']=(($selecteddir && $selecteddir != '/')?$selecteddir.'/':'').$file;
458
+						}
402 459
 							$val['id']=0;
403 460
 							$val['label']=$file;
404 461
 							$val['description']='';
@@ -406,7 +463,9 @@  discard block
 block discarded – undo
406 463
 						}
407 464
 
408 465
 						$collapsedorexpanded='collapsed';
409
-						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded='expanded';
466
+						if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) {
467
+						    $collapsedorexpanded='expanded';
468
+						}
410 469
 						print '<li class="directory '.$collapsedorexpanded.'">';	// collapsed is opposite if expanded
411 470
 
412 471
 						print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
@@ -430,7 +489,9 @@  discard block
 block discarded – undo
430 489
 						print (isset($val['cachenbofdoc']) && $val['cachenbofdoc']  >= 0)?$val['cachenbofdoc']:'&nbsp;';
431 490
 						print '</td>';
432 491
 						print '<td align="left">';
433
-						if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
492
+						if ($nbofsubdir > 0  && $nboffilesinsubdir > 0) {
493
+						    print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
494
+						}
434 495
 						print '</td>';
435 496
 
436 497
 						// Edit link
@@ -455,8 +516,11 @@  discard block
 block discarded – undo
455 516
 							$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c'])?dol_print_date($val['date_c'],"dayhour"):$langs->trans("NeedRefresh")).'<br>';
456 517
 							$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
457 518
 							$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0)?$val['cachenbofdoc']:$langs->trans("NeedRefresh")).'<br>';
458
-							if ($nboffilesinsubdir > 0) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
459
-							else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
519
+							if ($nboffilesinsubdir > 0) {
520
+							    $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
521
+							} else {
522
+							    $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
523
+							}
460 524
 							print $form->textwithpicto('',$htmltooltip,1,"info");
461 525
 							print "</td>";
462 526
 						}
@@ -473,13 +537,14 @@  discard block
 block discarded – undo
473 537
 							if ($modulepart == 'ecm')
474 538
 							{
475 539
 								$newfullpathselecteddir=$conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
476
-							}
477
-							elseif ($modulepart == 'medias')
540
+							} elseif ($modulepart == 'medias')
478 541
 							{
479 542
 								$newfullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
480 543
 							}
481 544
 
482
-							if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
545
+							if ($newfullpathselecteddir) {
546
+							    treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth+1);
547
+							}
483 548
 						}
484 549
 
485 550
 						print "</li>\n";
@@ -488,8 +553,9 @@  discard block
 block discarded – undo
488 553
 
489 554
 				echo "</ul>\n";
490 555
 			}
556
+		} else {
557
+		    print "PermissionDenied";
491 558
 		}
492
-		else print "PermissionDenied";
493 559
 	}
494 560
 }
495 561
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/ajaxdirpreview.php 3 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
     if (! $sortorder) $sortorder="ASC";
57 57
     if (! $sortfield) $sortfield="name";
58 58
 
59
-	$rootdirfordoc = $conf->ecm->dir_output;
59
+    $rootdirfordoc = $conf->ecm->dir_output;
60 60
 
61
-	$upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file));
61
+    $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file));
62 62
 
63 63
     $ecmdir = new EcmDirectory($db);
64 64
     $result=$ecmdir->fetch($section);
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 }
71 71
 else    // For no ajax call
72 72
 {
73
-	$rootdirfordoc = $conf->ecm->dir_output;
73
+    $rootdirfordoc = $conf->ecm->dir_output;
74 74
 
75
-	$ecmdir = new EcmDirectory($db);
75
+    $ecmdir = new EcmDirectory($db);
76 76
     $relativepath='';
77 77
     if ($section > 0)
78 78
     {
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 
86 86
         $relativepath=$ecmdir->getRelativePath();	// Example   'mydir/'
87 87
     }
88
-	elseif (GETPOST('section_dir'))
89
-	{
90
-		$relativepath=GETPOST('section_dir');
91
-	}
92
-	//var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
88
+    elseif (GETPOST('section_dir'))
89
+    {
90
+        $relativepath=GETPOST('section_dir');
91
+    }
92
+    //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
93 93
 
94
-	$upload_dir = $rootdirfordoc.'/'.$relativepath;
94
+    $upload_dir = $rootdirfordoc.'/'.$relativepath;
95 95
 }
96 96
 
97 97
 if (empty($url))
98 98
 {
99
-	if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php';
100
-	else $url=DOL_URL_ROOT.'/ecm/index.php';
99
+    if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php';
100
+    else $url=DOL_URL_ROOT.'/ecm/index.php';
101 101
 }
102 102
 
103 103
 // Load translation files required by the page
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 // Check permissions
122 122
 if ($modulepart == 'ecm')
123 123
 {
124
-	if (! $user->rights->ecm->read) accessforbidden();
124
+    if (! $user->rights->ecm->read) accessforbidden();
125 125
 }
126 126
 if ($modulepart == 'medias')
127 127
 {
128
-	// Always allowed
128
+    // Always allowed
129 129
 }
130 130
 
131 131
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 if (! isset($mode) || $mode != 'noajax')
145 145
 {
146
-	// Ajout directives pour resoudre bug IE
146
+    // Ajout directives pour resoudre bug IE
147 147
     header('Cache-Control: Public, must-revalidate');
148 148
     header('Pragma: public');
149 149
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     else if ($module == 'user') $upload_dir = $conf->user->dir_output;
211 211
     // Auto area for expense report
212 212
     else if ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
213
-	// Auto area for holiday
213
+    // Auto area for holiday
214 214
     else if ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
215 215
 
216 216
     // Automatic list
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
     // Manual list
234 234
     else
235 235
     {
236
-    	if ($module == 'medias')
237
-    	{
238
-    		/*
236
+        if ($module == 'medias')
237
+        {
238
+            /*
239 239
     		   $_POST is array like
240 240
     		  'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
241 241
 			  'action' => string 'file_manager' (length=12)
@@ -246,66 +246,66 @@  discard block
 block discarded – undo
246 246
 			  'max_file_size' => string '2097152' (length=7)
247 247
 			  'sendit' => string 'Envoyer fichier' (length=15)
248 248
     		 */
249
-    		$relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
250
-    		if ($relativepath && $relativepath!= '/') $relativepath.='/';
251
-    		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
252
-    		if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
253
-	    	{
254
-	    		$param.='&file_manager=1';
255
-	    		if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
256
-	    		if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
257
-	    		//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
258
-	    	}
259
-    	}
260
-    	else
261
-    	{
262
-        	$relativepath=$ecmdir->getRelativePath();
263
-        	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
264
-    	}
249
+            $relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
250
+            if ($relativepath && $relativepath!= '/') $relativepath.='/';
251
+            $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
252
+            if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
253
+            {
254
+                $param.='&file_manager=1';
255
+                if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
256
+                if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
257
+                //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
258
+            }
259
+        }
260
+        else
261
+        {
262
+            $relativepath=$ecmdir->getRelativePath();
263
+            $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
264
+        }
265 265
 
266 266
         // If $section defined with value 0
267
-		if (($section === '0' || empty($section)) && ($module != 'medias'))
267
+        if (($section === '0' || empty($section)) && ($module != 'medias'))
268 268
         {
269 269
             $filearray=array();
270 270
         }
271 271
         else
272 272
         {
273
-        	$filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1);
273
+            $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1);
274 274
         }
275 275
 
276 276
         if ($section)
277 277
         {
278 278
             $param.='&section='.$section;
279
-        	if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
279
+            if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
280 280
 
281 281
             $textifempty = $langs->trans('NoFileFound');
282 282
         }
283 283
         else if ($section === '0')
284 284
         {
285
-        	if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
286
-        	else $textifempty = $langs->trans('NoFileFound');
285
+            if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
286
+            else $textifempty = $langs->trans('NoFileFound');
287 287
         }
288 288
         else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
289 289
 
290
-    	if ($module == 'medias')
291
-    	{
292
-    		$useinecm = 2;
293
-    		$modulepart='medias';
294
-        	$perm=($user->rights->website->write || $user->rights->emailing->creer);
295
-        	$title='none';
296
-    	}
297
-    	else
298
-    	{
299
-    		$useinecm = 1;
300
-    		$modulepart='ecm';
301
-        	$perm=$user->rights->ecm->upload;
302
-        	$title='';	// Use default
303
-    	}
304
-
305
-    	// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
306
-    	// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
307
-    	//var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
308
-		$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
290
+        if ($module == 'medias')
291
+        {
292
+            $useinecm = 2;
293
+            $modulepart='medias';
294
+            $perm=($user->rights->website->write || $user->rights->emailing->creer);
295
+            $title='none';
296
+        }
297
+        else
298
+        {
299
+            $useinecm = 1;
300
+            $modulepart='ecm';
301
+            $perm=$user->rights->ecm->upload;
302
+            $title='';	// Use default
303
+        }
304
+
305
+        // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
306
+        // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
307
+        //var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
308
+        $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
309 309
     }
310 310
 }
311 311
 
@@ -321,37 +321,37 @@  discard block
 block discarded – undo
321 321
 
322 322
 if ($useajax || $action == 'delete')
323 323
 {
324
-	$urlfile='';
325
-	if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha');
326
-
327
-	if (empty($section_dir)) $section_dir=GETPOST("file","alpha");
328
-	$section_id=$section;
329
-
330
-	require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
331
-	$useglobalvars=1;
332
-	$form = new Form($db);
333
-	$formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile');				// We must always put field, even if empty because it is fille by javascript later
334
-	$formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section');				// We must always put field, even if empty because it is fille by javascript later
335
-	$formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id');		// We must always put field, even if empty because it is fille by javascript later
336
-	$formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir');	// We must always put field, even if empty because it is fille by javascript later
337
-	if (! empty($action) && $action == 'file_manager')	$formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
338
-	if (! empty($websitekey))							$formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
339
-	if (! empty($pageid) && $pageid > 0)				$formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
340
-
341
-	print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
324
+    $urlfile='';
325
+    if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha');
326
+
327
+    if (empty($section_dir)) $section_dir=GETPOST("file","alpha");
328
+    $section_id=$section;
329
+
330
+    require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
331
+    $useglobalvars=1;
332
+    $form = new Form($db);
333
+    $formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile');				// We must always put field, even if empty because it is fille by javascript later
334
+    $formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section');				// We must always put field, even if empty because it is fille by javascript later
335
+    $formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id');		// We must always put field, even if empty because it is fille by javascript later
336
+    $formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir');	// We must always put field, even if empty because it is fille by javascript later
337
+    if (! empty($action) && $action == 'file_manager')	$formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
338
+    if (! empty($websitekey))							$formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
339
+    if (! empty($pageid) && $pageid > 0)				$formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
340
+
341
+    print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
342 342
 }
343 343
 
344 344
 if ($useajax)
345 345
 {
346
-	print '<script type="text/javascript">';
347
-
348
-	// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
349
-	// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
350
-	// Wrapper to manage document_preview
351
-	if ($conf->browser->layout != 'phone')
352
-	{
353
-		print "\n/* JS CODE TO ENABLE document_preview */\n";
354
-		print '
346
+    print '<script type="text/javascript">';
347
+
348
+    // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
349
+    // Because the content is reloaded by ajax call, we must also reenable some jquery hooks
350
+    // Wrapper to manage document_preview
351
+    if ($conf->browser->layout != 'phone')
352
+    {
353
+        print "\n/* JS CODE TO ENABLE document_preview */\n";
354
+        print '
355 355
                 jQuery(document).ready(function () {
356 356
 			        jQuery(".documentpreview").click(function () {
357 357
             		    console.log("We click on preview for element with href="+$(this).attr(\'href\')+" mime="+$(this).attr(\'mime\'));
@@ -360,19 +360,19 @@  discard block
 block discarded – undo
360 360
         			});
361 361
         		});
362 362
            ' . "\n";
363
-	}
364
-
365
-	// Enable jquery handlers button to delete files
366
-	print 'jQuery(document).ready(function() {'."\n";
367
-	print '  jQuery(".deletefilelink").click(function(e) { '."\n";
368
-	print '    console.log("We click on button with class deletefilelink, param='.$param.', we set urlfile to "+jQuery(this).attr("rel"));'."\n";
369
-	print '    jQuery("#urlfile").val(jQuery(this).attr("rel"));'."\n";
370
-	//print '    jQuery("#section_dir").val(\'aaa\');'."\n";
371
-	print '    jQuery("#dialog-confirm-deletefile").dialog("open");'."\n";
372
-	print '    return false;'."\n";
373
-	print '  });'."\n";
374
-	print '});'."\n";
375
-	print '</script>'."\n";
363
+    }
364
+
365
+    // Enable jquery handlers button to delete files
366
+    print 'jQuery(document).ready(function() {'."\n";
367
+    print '  jQuery(".deletefilelink").click(function(e) { '."\n";
368
+    print '    console.log("We click on button with class deletefilelink, param='.$param.', we set urlfile to "+jQuery(this).attr("rel"));'."\n";
369
+    print '    jQuery("#urlfile").val(jQuery(this).attr("rel"));'."\n";
370
+    //print '    jQuery("#section_dir").val(\'aaa\');'."\n";
371
+    print '    jQuery("#dialog-confirm-deletefile").dialog("open");'."\n";
372
+    print '    return false;'."\n";
373
+    print '  });'."\n";
374
+    print '});'."\n";
375
+    print '</script>'."\n";
376 376
 }
377 377
 
378 378
 // Close db if mode is not noajax
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
  * 				ajaxdirpreview.php?mode=nojs&action=preview&module=ecm&section=0&file=xxx
28 28
  */
29 29
 
30
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
31
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
32
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
33
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
30
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
31
+if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
32
+if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
33
+if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
34 34
 
35
-if (! isset($mode) || $mode != 'noajax')    // For ajax call
35
+if (!isset($mode) || $mode != 'noajax')    // For ajax call
36 36
 {
37 37
     require_once '../../main.inc.php';
38 38
     require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 39
     require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40 40
     require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
41 41
 
42
-    $action=GETPOST('action','aZ09');
43
-    $file=urldecode(GETPOST('file','alpha'));
44
-    $section=GETPOST("section",'alpha');
45
-    $module=GETPOST("module",'alpha');
46
-    $urlsource=GETPOST("urlsource",'alpha');
47
-    $search_doc_ref=GETPOST('search_doc_ref','alpha');
42
+    $action = GETPOST('action', 'aZ09');
43
+    $file = urldecode(GETPOST('file', 'alpha'));
44
+    $section = GETPOST("section", 'alpha');
45
+    $module = GETPOST("module", 'alpha');
46
+    $urlsource = GETPOST("urlsource", 'alpha');
47
+    $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
48 48
 
49
-    $sortfield = GETPOST("sortfield",'alpha');
50
-    $sortorder = GETPOST("sortorder",'alpha');
51
-    $page = GETPOST("page",'int');
49
+    $sortfield = GETPOST("sortfield", 'alpha');
50
+    $sortorder = GETPOST("sortorder", 'alpha');
51
+    $page = GETPOST("page", 'int');
52 52
     if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
53 53
     $offset = $conf->liste_limit * $page;
54 54
     $pageprev = $page - 1;
55 55
     $pagenext = $page + 1;
56
-    if (! $sortorder) $sortorder="ASC";
57
-    if (! $sortfield) $sortfield="name";
56
+    if (!$sortorder) $sortorder = "ASC";
57
+    if (!$sortfield) $sortfield = "name";
58 58
 
59 59
 	$rootdirfordoc = $conf->ecm->dir_output;
60 60
 
61 61
 	$upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file));
62 62
 
63 63
     $ecmdir = new EcmDirectory($db);
64
-    $result=$ecmdir->fetch($section);
65
-    if (! $result > 0)
64
+    $result = $ecmdir->fetch($section);
65
+    if (!$result > 0)
66 66
     {
67 67
         //dol_print_error($db,$ecmdir->error);
68 68
         //exit;
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 	$rootdirfordoc = $conf->ecm->dir_output;
74 74
 
75 75
 	$ecmdir = new EcmDirectory($db);
76
-    $relativepath='';
76
+    $relativepath = '';
77 77
     if ($section > 0)
78 78
     {
79
-        $result=$ecmdir->fetch($section);
80
-        if (! $result > 0)
79
+        $result = $ecmdir->fetch($section);
80
+        if (!$result > 0)
81 81
         {
82
-            dol_print_error($db,$ecmdir->error);
82
+            dol_print_error($db, $ecmdir->error);
83 83
             exit;
84 84
         }
85 85
 
86
-        $relativepath=$ecmdir->getRelativePath();	// Example   'mydir/'
86
+        $relativepath = $ecmdir->getRelativePath(); // Example   'mydir/'
87 87
     }
88 88
 	elseif (GETPOST('section_dir'))
89 89
 	{
90
-		$relativepath=GETPOST('section_dir');
90
+		$relativepath = GETPOST('section_dir');
91 91
 	}
92 92
 	//var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
93 93
 
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 
97 97
 if (empty($url))
98 98
 {
99
-	if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php';
100
-	else $url=DOL_URL_ROOT.'/ecm/index.php';
99
+	if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php';
100
+	else $url = DOL_URL_ROOT.'/ecm/index.php';
101 101
 }
102 102
 
103 103
 // Load translation files required by the page
104
-$langs->loadLangs(array("ecm","companies","other"));
104
+$langs->loadLangs(array("ecm", "companies", "other"));
105 105
 
106 106
 // Security check
107 107
 if ($user->societe_id > 0) $socid = $user->societe_id;
@@ -110,18 +110,18 @@  discard block
 block discarded – undo
110 110
 
111 111
 // Security:
112 112
 // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
113
-if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir))
113
+if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir))
114 114
 {
115 115
     dol_syslog("Refused to deliver file ".$upload_dir);
116 116
     // Do no show plain path in shown error message
117
-    dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$upload_dir));
117
+    dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
118 118
     exit;
119 119
 }
120 120
 
121 121
 // Check permissions
122 122
 if ($modulepart == 'ecm')
123 123
 {
124
-	if (! $user->rights->ecm->read) accessforbidden();
124
+	if (!$user->rights->ecm->read) accessforbidden();
125 125
 }
126 126
 if ($modulepart == 'medias')
127 127
 {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  * View
142 142
  */
143 143
 
144
-if (! isset($mode) || $mode != 'noajax')
144
+if (!isset($mode) || $mode != 'noajax')
145 145
 {
146 146
 	// Ajout directives pour resoudre bug IE
147 147
     header('Cache-Control: Public, must-revalidate');
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
     top_httphead();
151 151
 }
152 152
 
153
-$type='directory';
153
+$type = 'directory';
154 154
 
155 155
 // This test if file exists should be useless. We keep it to find bug more easily
156
-if (! dol_is_dir($upload_dir))
156
+if (!dol_is_dir($upload_dir))
157 157
 {
158 158
 //	dol_mkdir($upload_dir);
159 159
 /*    $langs->load("install");
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 print '<!-- ajaxdirpreview type='.$type.' -->'."\n";
165 165
 //print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
166 166
 
167
-$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
168
-if (! empty($websitekey)) $param.='&website='.$websitekey;
169
-if (! empty($pageid))     $param.='&pageid='.$pageid;
167
+$param = ($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '');
168
+if (!empty($websitekey)) $param .= '&website='.$websitekey;
169
+if (!empty($pageid))     $param .= '&pageid='.$pageid;
170 170
 
171 171
 
172 172
 // Dir scan
173 173
 if ($type == 'directory')
174 174
 {
175
-    $formfile=new FormFile($db);
175
+    $formfile = new FormFile($db);
176 176
 
177
-    $maxlengthname=40;
178
-    $excludefiles = array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview.*\.png)$','^temp$','^payments$','^CVS$','^thumbs$');
179
-    $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC);
177
+    $maxlengthname = 40;
178
+    $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
179
+    $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC);
180 180
 
181 181
     // Right area. If module is defined here, we are in automatic ecm.
182 182
     $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday');
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
     // Automatic list
217 217
     if (in_array($module, $automodules))
218 218
     {
219
-        $param.='&module='.$module;
220
-        if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
219
+        $param .= '&module='.$module;
220
+        if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
221 221
 
222
-        $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
222
+        $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
223 223
 
224
-        if ($module == 'company') $excludefiles[]='^contact$';   // The subdir 'contact' contains files of contacts with no id of thirdparty.
224
+        if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
225 225
 
226
-        $filter=preg_quote($search_doc_ref, '/');
227
-        $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1);
226
+        $filter = preg_quote($search_doc_ref, '/');
227
+        $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
228 228
 
229
-        $perm=$user->rights->ecm->upload;
229
+        $perm = $user->rights->ecm->upload;
230 230
 
231
-        $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$perm,1,$textifempty,$maxlengthname,$url,1);
231
+        $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
232 232
     }
233 233
     // Manual list
234 234
     else
@@ -246,60 +246,60 @@  discard block
 block discarded – undo
246 246
 			  'max_file_size' => string '2097152' (length=7)
247 247
 			  'sendit' => string 'Envoyer fichier' (length=15)
248 248
     		 */
249
-    		$relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
250
-    		if ($relativepath && $relativepath!= '/') $relativepath.='/';
249
+    		$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
250
+    		if ($relativepath && $relativepath != '/') $relativepath .= '/';
251 251
     		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
252 252
     		if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
253 253
 	    	{
254
-	    		$param.='&file_manager=1';
255
-	    		if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
256
-	    		if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
254
+	    		$param .= '&file_manager=1';
255
+	    		if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
256
+	    		if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
257 257
 	    		//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
258 258
 	    	}
259 259
     	}
260 260
     	else
261 261
     	{
262
-        	$relativepath=$ecmdir->getRelativePath();
262
+        	$relativepath = $ecmdir->getRelativePath();
263 263
         	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
264 264
     	}
265 265
 
266 266
         // If $section defined with value 0
267 267
 		if (($section === '0' || empty($section)) && ($module != 'medias'))
268 268
         {
269
-            $filearray=array();
269
+            $filearray = array();
270 270
         }
271 271
         else
272 272
         {
273
-        	$filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1);
273
+        	$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
274 274
         }
275 275
 
276 276
         if ($section)
277 277
         {
278
-            $param.='&section='.$section;
279
-        	if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
278
+            $param .= '&section='.$section;
279
+        	if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
280 280
 
281 281
             $textifempty = $langs->trans('NoFileFound');
282 282
         }
283 283
         else if ($section === '0')
284 284
         {
285
-        	if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
285
+        	if ($module == 'ecm') $textifempty = '<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
286 286
         	else $textifempty = $langs->trans('NoFileFound');
287 287
         }
288
-        else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
288
+        else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
289 289
 
290 290
     	if ($module == 'medias')
291 291
     	{
292 292
     		$useinecm = 2;
293
-    		$modulepart='medias';
294
-        	$perm=($user->rights->website->write || $user->rights->emailing->creer);
295
-        	$title='none';
293
+    		$modulepart = 'medias';
294
+        	$perm = ($user->rights->website->write || $user->rights->emailing->creer);
295
+        	$title = 'none';
296 296
     	}
297 297
     	else
298 298
     	{
299 299
     		$useinecm = 1;
300
-    		$modulepart='ecm';
301
-        	$perm=$user->rights->ecm->upload;
302
-        	$title='';	// Use default
300
+    		$modulepart = 'ecm';
301
+        	$perm = $user->rights->ecm->upload;
302
+        	$title = ''; // Use default
303 303
     	}
304 304
 
305 305
     	// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
@@ -312,33 +312,33 @@  discard block
 block discarded – undo
312 312
 
313 313
 
314 314
 // Bottom of page
315
-$useajax=1;
316
-if (! empty($conf->dol_use_jmobile)) $useajax=0;
317
-if (empty($conf->use_javascript_ajax)) $useajax=0;
318
-if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
315
+$useajax = 1;
316
+if (!empty($conf->dol_use_jmobile)) $useajax = 0;
317
+if (empty($conf->use_javascript_ajax)) $useajax = 0;
318
+if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0;
319 319
 
320 320
 //$param.=($param?'?':'').(preg_replace('/^&/','',$param));
321 321
 
322 322
 if ($useajax || $action == 'delete')
323 323
 {
324
-	$urlfile='';
325
-	if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha');
324
+	$urlfile = '';
325
+	if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha');
326 326
 
327
-	if (empty($section_dir)) $section_dir=GETPOST("file","alpha");
328
-	$section_id=$section;
327
+	if (empty($section_dir)) $section_dir = GETPOST("file", "alpha");
328
+	$section_id = $section;
329 329
 
330 330
 	require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
331
-	$useglobalvars=1;
331
+	$useglobalvars = 1;
332 332
 	$form = new Form($db);
333
-	$formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile');				// We must always put field, even if empty because it is fille by javascript later
334
-	$formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section');				// We must always put field, even if empty because it is fille by javascript later
335
-	$formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id');		// We must always put field, even if empty because it is fille by javascript later
336
-	$formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir');	// We must always put field, even if empty because it is fille by javascript later
337
-	if (! empty($action) && $action == 'file_manager')	$formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
338
-	if (! empty($websitekey))							$formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
339
-	if (! empty($pageid) && $pageid > 0)				$formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
340
-
341
-	print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
333
+	$formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later
334
+	$formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later
335
+	$formquestion['section_id'] = array('type'=>'hidden', 'value'=>$section_id, 'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later
336
+	$formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later
337
+	if (!empty($action) && $action == 'file_manager')	$formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager');
338
+	if (!empty($websitekey))							$formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website');
339
+	if (!empty($pageid) && $pageid > 0)				$formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid');
340
+
341
+	print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0));
342 342
 }
343 343
 
344 344
 if ($useajax)
@@ -376,4 +376,4 @@  discard block
 block discarded – undo
376 376
 }
377 377
 
378 378
 // Close db if mode is not noajax
379
-if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
379
+if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
Please login to merge, or discard this patch.
Braces   +145 added lines, -60 removed lines patch added patch discarded remove patch
@@ -27,14 +27,25 @@  discard block
 block discarded – undo
27 27
  * 				ajaxdirpreview.php?mode=nojs&action=preview&module=ecm&section=0&file=xxx
28 28
  */
29 29
 
30
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
31
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
32
-if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
33
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
30
+if (! defined('NOTOKENRENEWAL')) {
31
+    define('NOTOKENRENEWAL',1);
32
+}
33
+// Disables token renewal
34
+if (! defined('NOREQUIREMENU')) {
35
+    define('NOREQUIREMENU','1');
36
+}
37
+if (! defined('NOREQUIREHTML')) {
38
+    define('NOREQUIREHTML','1');
39
+}
40
+if (! defined('NOREQUIREAJAX')) {
41
+    define('NOREQUIREAJAX','1');
42
+}
34 43
 
35
-if (! isset($mode) || $mode != 'noajax')    // For ajax call
44
+if (! isset($mode) || $mode != 'noajax') {
45
+    // For ajax call
36 46
 {
37 47
     require_once '../../main.inc.php';
48
+}
38 49
     require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 50
     require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40 51
     require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
@@ -53,8 +64,12 @@  discard block
 block discarded – undo
53 64
     $offset = $conf->liste_limit * $page;
54 65
     $pageprev = $page - 1;
55 66
     $pagenext = $page + 1;
56
-    if (! $sortorder) $sortorder="ASC";
57
-    if (! $sortfield) $sortfield="name";
67
+    if (! $sortorder) {
68
+        $sortorder="ASC";
69
+    }
70
+    if (! $sortfield) {
71
+        $sortfield="name";
72
+    }
58 73
 
59 74
 	$rootdirfordoc = $conf->ecm->dir_output;
60 75
 
@@ -67,8 +82,7 @@  discard block
 block discarded – undo
67 82
         //dol_print_error($db,$ecmdir->error);
68 83
         //exit;
69 84
     }
70
-}
71
-else    // For no ajax call
85
+} else    // For no ajax call
72 86
 {
73 87
 	$rootdirfordoc = $conf->ecm->dir_output;
74 88
 
@@ -84,8 +98,7 @@  discard block
 block discarded – undo
84 98
         }
85 99
 
86 100
         $relativepath=$ecmdir->getRelativePath();	// Example   'mydir/'
87
-    }
88
-	elseif (GETPOST('section_dir'))
101
+    } elseif (GETPOST('section_dir'))
89 102
 	{
90 103
 		$relativepath=GETPOST('section_dir');
91 104
 	}
@@ -96,15 +109,20 @@  discard block
 block discarded – undo
96 109
 
97 110
 if (empty($url))
98 111
 {
99
-	if (GETPOSTISSET('website')) $url=DOL_URL_ROOT.'/website/index.php';
100
-	else $url=DOL_URL_ROOT.'/ecm/index.php';
101
-}
112
+	if (GETPOSTISSET('website')) {
113
+	    $url=DOL_URL_ROOT.'/website/index.php';
114
+	} else {
115
+	    $url=DOL_URL_ROOT.'/ecm/index.php';
116
+	}
117
+	}
102 118
 
103 119
 // Load translation files required by the page
104 120
 $langs->loadLangs(array("ecm","companies","other"));
105 121
 
106 122
 // Security check
107
-if ($user->societe_id > 0) $socid = $user->societe_id;
123
+if ($user->societe_id > 0) {
124
+    $socid = $user->societe_id;
125
+}
108 126
 
109 127
 //print 'xxx'.$upload_dir;
110 128
 
@@ -121,8 +139,10 @@  discard block
 block discarded – undo
121 139
 // Check permissions
122 140
 if ($modulepart == 'ecm')
123 141
 {
124
-	if (! $user->rights->ecm->read) accessforbidden();
125
-}
142
+	if (! $user->rights->ecm->read) {
143
+	    accessforbidden();
144
+	}
145
+	}
126 146
 if ($modulepart == 'medias')
127 147
 {
128 148
 	// Always allowed
@@ -165,8 +185,12 @@  discard block
 block discarded – undo
165 185
 //print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
166 186
 
167 187
 $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
168
-if (! empty($websitekey)) $param.='&website='.$websitekey;
169
-if (! empty($pageid))     $param.='&pageid='.$pageid;
188
+if (! empty($websitekey)) {
189
+    $param.='&website='.$websitekey;
190
+}
191
+if (! empty($pageid)) {
192
+    $param.='&pageid='.$pageid;
193
+}
170 194
 
171 195
 
172 196
 // Dir scan
@@ -183,45 +207,80 @@  discard block
 block discarded – undo
183 207
 
184 208
     // TODO change for multicompany sharing
185 209
     // Auto area for suppliers invoices
186
-    if ($module == 'company') $upload_dir = $conf->societe->dir_output;
210
+    if ($module == 'company') {
211
+        $upload_dir = $conf->societe->dir_output;
212
+    }
187 213
     // Auto area for suppliers invoices
188
-    else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
214
+    else if ($module == 'invoice') {
215
+        $upload_dir = $conf->facture->dir_output;
216
+    }
189 217
     // Auto area for suppliers invoices
190
-    else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
218
+    else if ($module == 'invoice_supplier') {
219
+        $upload_dir = $conf->fournisseur->facture->dir_output;
220
+    }
191 221
     // Auto area for customers proposal
192
-    else if ($module == 'propal') $upload_dir = $conf->propal->dir_output;
222
+    else if ($module == 'propal') {
223
+        $upload_dir = $conf->propal->dir_output;
224
+    }
193 225
     // Auto area for suppliers proposal
194
-    else if ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
226
+    else if ($module == 'supplier_proposal') {
227
+        $upload_dir = $conf->supplier_proposal->dir_output;
228
+    }
195 229
     // Auto area for customers orders
196
-    else if ($module == 'order') $upload_dir = $conf->commande->dir_output;
230
+    else if ($module == 'order') {
231
+        $upload_dir = $conf->commande->dir_output;
232
+    }
197 233
     // Auto area for suppliers orders
198
-    else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
234
+    else if ($module == 'order_supplier') {
235
+        $upload_dir = $conf->fournisseur->commande->dir_output;
236
+    }
199 237
     // Auto area for suppliers invoices
200
-    else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
238
+    else if ($module == 'contract') {
239
+        $upload_dir = $conf->contrat->dir_output;
240
+    }
201 241
     // Auto area for products
202
-    else if ($module == 'product') $upload_dir = $conf->product->dir_output;
242
+    else if ($module == 'product') {
243
+        $upload_dir = $conf->product->dir_output;
244
+    }
203 245
     // Auto area for suppliers invoices
204
-    else if ($module == 'tax') $upload_dir = $conf->tax->dir_output;
246
+    else if ($module == 'tax') {
247
+        $upload_dir = $conf->tax->dir_output;
248
+    }
205 249
     // Auto area for projects
206
-    else if ($module == 'project') $upload_dir = $conf->projet->dir_output;
250
+    else if ($module == 'project') {
251
+        $upload_dir = $conf->projet->dir_output;
252
+    }
207 253
     // Auto area for interventions
208
-    else if ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
254
+    else if ($module == 'fichinter') {
255
+        $upload_dir = $conf->ficheinter->dir_output;
256
+    }
209 257
     // Auto area for users
210
-    else if ($module == 'user') $upload_dir = $conf->user->dir_output;
258
+    else if ($module == 'user') {
259
+        $upload_dir = $conf->user->dir_output;
260
+    }
211 261
     // Auto area for expense report
212
-    else if ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
262
+    else if ($module == 'expensereport') {
263
+        $upload_dir = $conf->expensereport->dir_output;
264
+    }
213 265
 	// Auto area for holiday
214
-    else if ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
266
+    else if ($module == 'holiday') {
267
+        $upload_dir = $conf->holiday->dir_output;
268
+    }
215 269
 
216 270
     // Automatic list
217 271
     if (in_array($module, $automodules))
218 272
     {
219 273
         $param.='&module='.$module;
220
-        if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
274
+        if (isset($search_doc_ref) && $search_doc_ref != '') {
275
+            $param.='&search_doc_ref='.$search_doc_ref;
276
+        }
221 277
 
222 278
         $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
223 279
 
224
-        if ($module == 'company') $excludefiles[]='^contact$';   // The subdir 'contact' contains files of contacts with no id of thirdparty.
280
+        if ($module == 'company') {
281
+            $excludefiles[]='^contact$';
282
+        }
283
+        // The subdir 'contact' contains files of contacts with no id of thirdparty.
225 284
 
226 285
         $filter=preg_quote($search_doc_ref, '/');
227 286
         $filearray=dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting,1);
@@ -247,17 +306,22 @@  discard block
 block discarded – undo
247 306
 			  'sendit' => string 'Envoyer fichier' (length=15)
248 307
     		 */
249 308
     		$relativepath=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
250
-    		if ($relativepath && $relativepath!= '/') $relativepath.='/';
309
+    		if ($relativepath && $relativepath!= '/') {
310
+    		    $relativepath.='/';
311
+    		}
251 312
     		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
252 313
     		if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
253 314
 	    	{
254 315
 	    		$param.='&file_manager=1';
255
-	    		if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
256
-	    		if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
316
+	    		if (!preg_match('/website=/',$param)) {
317
+	    		    $param.='&website='.urlencode(GETPOST('website','alpha'));
318
+	    		}
319
+	    		if (!preg_match('/pageid=/',$param)) {
320
+	    		    $param.='&pageid='.urlencode(GETPOST('pageid','int'));
321
+	    		}
257 322
 	    		//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
258 323
 	    	}
259
-    	}
260
-    	else
324
+    	} else
261 325
     	{
262 326
         	$relativepath=$ecmdir->getRelativePath();
263 327
         	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
@@ -267,8 +331,7 @@  discard block
 block discarded – undo
267 331
 		if (($section === '0' || empty($section)) && ($module != 'medias'))
268 332
         {
269 333
             $filearray=array();
270
-        }
271
-        else
334
+        } else
272 335
         {
273 336
         	$filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','(\.meta|_preview.*\.png)$','^temp$','^CVS$'),$sortfield, $sorting,1);
274 337
         }
@@ -276,16 +339,21 @@  discard block
 block discarded – undo
276 339
         if ($section)
277 340
         {
278 341
             $param.='&section='.$section;
279
-        	if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref;
342
+        	if (isset($search_doc_ref) && $search_doc_ref != '') {
343
+        	    $param.='&search_doc_ref='.$search_doc_ref;
344
+        	}
280 345
 
281 346
             $textifempty = $langs->trans('NoFileFound');
282
-        }
283
-        else if ($section === '0')
347
+        } else if ($section === '0')
284 348
         {
285
-        	if ($module == 'ecm') $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
286
-        	else $textifempty = $langs->trans('NoFileFound');
349
+        	if ($module == 'ecm') {
350
+        	    $textifempty='<br><div align="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
351
+        	} else {
352
+        	    $textifempty = $langs->trans('NoFileFound');
353
+        	}
354
+        } else {
355
+            $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
287 356
         }
288
-        else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"));
289 357
 
290 358
     	if ($module == 'medias')
291 359
     	{
@@ -293,8 +361,7 @@  discard block
 block discarded – undo
293 361
     		$modulepart='medias';
294 362
         	$perm=($user->rights->website->write || $user->rights->emailing->creer);
295 363
         	$title='none';
296
-    	}
297
-    	else
364
+    	} else
298 365
     	{
299 366
     		$useinecm = 1;
300 367
     		$modulepart='ecm';
@@ -313,18 +380,28 @@  discard block
 block discarded – undo
313 380
 
314 381
 // Bottom of page
315 382
 $useajax=1;
316
-if (! empty($conf->dol_use_jmobile)) $useajax=0;
317
-if (empty($conf->use_javascript_ajax)) $useajax=0;
318
-if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
383
+if (! empty($conf->dol_use_jmobile)) {
384
+    $useajax=0;
385
+}
386
+if (empty($conf->use_javascript_ajax)) {
387
+    $useajax=0;
388
+}
389
+if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) {
390
+    $useajax=0;
391
+}
319 392
 
320 393
 //$param.=($param?'?':'').(preg_replace('/^&/','',$param));
321 394
 
322 395
 if ($useajax || $action == 'delete')
323 396
 {
324 397
 	$urlfile='';
325
-	if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha');
398
+	if ($action == 'delete') {
399
+	    $urlfile=GETPOST('urlfile','alpha');
400
+	}
326 401
 
327
-	if (empty($section_dir)) $section_dir=GETPOST("file","alpha");
402
+	if (empty($section_dir)) {
403
+	    $section_dir=GETPOST("file","alpha");
404
+	}
328 405
 	$section_id=$section;
329 406
 
330 407
 	require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@@ -334,9 +411,15 @@  discard block
 block discarded – undo
334 411
 	$formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section');				// We must always put field, even if empty because it is fille by javascript later
335 412
 	$formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id');		// We must always put field, even if empty because it is fille by javascript later
336 413
 	$formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir');	// We must always put field, even if empty because it is fille by javascript later
337
-	if (! empty($action) && $action == 'file_manager')	$formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
338
-	if (! empty($websitekey))							$formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
339
-	if (! empty($pageid) && $pageid > 0)				$formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
414
+	if (! empty($action) && $action == 'file_manager') {
415
+	    $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
416
+	}
417
+	if (! empty($websitekey)) {
418
+	    $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
419
+	}
420
+	if (! empty($pageid) && $pageid > 0) {
421
+	    $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
422
+	}
340 423
 
341 424
 	print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
342 425
 }
@@ -376,4 +459,6 @@  discard block
 block discarded – undo
376 459
 }
377 460
 
378 461
 // Close db if mode is not noajax
379
-if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
462
+if ((! isset($mode) || $mode != 'noajax') && is_object($db)) {
463
+    $db->close();
464
+}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/ajax/constantonoff.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,19 +49,19 @@
 block discarded – undo
49 49
 // Registering the location of boxes
50 50
 if (! empty($action) && ! empty($name))
51 51
 {
52
-	$entity = GETPOST('entity','int');
53
-	$value = (GETPOST('value')?GETPOST('value'):1);
52
+    $entity = GETPOST('entity','int');
53
+    $value = (GETPOST('value')?GETPOST('value'):1);
54 54
 
55
-	if ($user->admin)
56
-	{
57
-		if ($action == 'set')
58
-		{
59
-			dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
60
-		}
61
-		else if ($action == 'del')
62
-		{
63
-			dolibarr_del_const($db, $name, $entity);
64
-		}
65
-	}
55
+    if ($user->admin)
56
+    {
57
+        if ($action == 'set')
58
+        {
59
+            dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
60
+        }
61
+        else if ($action == 'del')
62
+        {
63
+            dolibarr_del_const($db, $name, $entity);
64
+        }
65
+    }
66 66
 }
67 67
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,12 +20,25 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to set or del an on/off constant
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
26
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
27
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
28
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
23
+if (! defined('NOTOKENRENEWAL')) {
24
+    define('NOTOKENRENEWAL','1');
25
+}
26
+// Disables token renewal
27
+if (! defined('NOREQUIREMENU')) {
28
+    define('NOREQUIREMENU','1');
29
+}
30
+if (! defined('NOREQUIREHTML')) {
31
+    define('NOREQUIREHTML','1');
32
+}
33
+if (! defined('NOREQUIREAJAX')) {
34
+    define('NOREQUIREAJAX','1');
35
+}
36
+if (! defined('NOREQUIRESOC')) {
37
+    define('NOREQUIRESOC','1');
38
+}
39
+if (! defined('NOREQUIRETRAN')) {
40
+    define('NOREQUIRETRAN','1');
41
+}
29 42
 
30 43
 
31 44
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
@@ -60,8 +73,7 @@  discard block
 block discarded – undo
60 73
 		if ($action == 'set')
61 74
 		{
62 75
 			dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
63
-		}
64
-		else if ($action == 'del')
76
+		} else if ($action == 'del')
65 77
 		{
66 78
 			dolibarr_del_const($db, $name, $entity);
67 79
 		}
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
  *       \brief      File to set or del an on/off constant
21 21
  */
22 22
 
23
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
24
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU','1');
25
-if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML','1');
26
-if (! defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX','1');
27
-if (! defined('NOREQUIRESOC'))   define('NOREQUIRESOC','1');
28
-if (! defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN','1');
23
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
24
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', '1');
25
+if (!defined('NOREQUIREHTML'))  define('NOREQUIREHTML', '1');
26
+if (!defined('NOREQUIREAJAX'))  define('NOREQUIREAJAX', '1');
27
+if (!defined('NOREQUIRESOC'))   define('NOREQUIRESOC', '1');
28
+if (!defined('NOREQUIRETRAN'))  define('NOREQUIRETRAN', '1');
29 29
 
30 30
 
31 31
 // Copyright (C) 2018 Alxarafe/Alixar  <[email protected]>
32 32
 defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
33
-require DOL_BASE_PATH . '/main.inc.php';
33
+require DOL_BASE_PATH.'/main.inc.php';
34 34
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
35 35
 
36
-$action=GETPOST('action','alpha');
37
-$name=GETPOST('name','alpha');
36
+$action = GETPOST('action', 'alpha');
37
+$name = GETPOST('name', 'alpha');
38 38
 
39 39
 /*
40 40
  * View
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
51 51
 
52 52
 // Registering the location of boxes
53
-if (! empty($action) && ! empty($name))
53
+if (!empty($action) && !empty($name))
54 54
 {
55
-	$entity = GETPOST('entity','int');
56
-	$value = (GETPOST('value')?GETPOST('value'):1);
55
+	$entity = GETPOST('entity', 'int');
56
+	$value = (GETPOST('value') ?GETPOST('value') : 1);
57 57
 
58 58
 	if ($user->admin)
59 59
 	{
Please login to merge, or discard this patch.