Passed
Push — master ( 8f7a8e...7e4a07 )
by Alxarafe
20:11
created
dolibarr/htdocs/core/tpl/extrafields_list_search_input.tpl.php 3 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 // Protection to avoid direct call of template
4 4
 if (empty($conf) || ! is_object($conf))
5 5
 {
6
-	print "Error, template page can't be called as URL";
7
-	exit;
6
+    print "Error, template page can't be called as URL";
7
+    exit;
8 8
 }
9 9
 
10 10
 if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
@@ -12,37 +12,37 @@  discard block
 block discarded – undo
12 12
 // Loop to show all columns of extrafields for the search title line
13 13
 if (! empty($extrafieldsobjectkey))	// $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
14 14
 {
15
-	if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
16
-	{
17
-		foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
18
-		{
19
-			if (! empty($arrayfields["ef.".$key]['checked'])) {
20
-				$align=$extrafields->getAlignFlag($key);
21
-				$typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
22
-				print '<td class="liste_titre'.($align?' '.$align:'').'">';
23
-				if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]))
24
-				{
25
-					$crit=$val;
26
-					$tmpkey=preg_replace('/search_options_/','',$key);
27
-					$searchclass='';
28
-					if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
29
-					if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
30
-					print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
31
-				}
32
-				elseif (! in_array($typeofextrafield, array('datetime','timestamp')))
33
-				{
34
-					// for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid')
35
-					$morecss='';
36
-					if ($typeofextrafield == 'sellist') $morecss='maxwidth200';
37
-					echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss);
38
-				}
39
-				elseif (in_array($typeofextrafield, array('datetime','timestamp')))
40
-				{
41
-					// TODO
42
-					// Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes
43
-				}
44
-				print '</td>';
45
-			}
46
-		}
47
-	}
15
+    if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
16
+    {
17
+        foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
18
+        {
19
+            if (! empty($arrayfields["ef.".$key]['checked'])) {
20
+                $align=$extrafields->getAlignFlag($key);
21
+                $typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
22
+                print '<td class="liste_titre'.($align?' '.$align:'').'">';
23
+                if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]))
24
+                {
25
+                    $crit=$val;
26
+                    $tmpkey=preg_replace('/search_options_/','',$key);
27
+                    $searchclass='';
28
+                    if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
29
+                    if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
30
+                    print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
31
+                }
32
+                elseif (! in_array($typeofextrafield, array('datetime','timestamp')))
33
+                {
34
+                    // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid')
35
+                    $morecss='';
36
+                    if ($typeofextrafield == 'sellist') $morecss='maxwidth200';
37
+                    echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss);
38
+                }
39
+                elseif (in_array($typeofextrafield, array('datetime','timestamp')))
40
+                {
41
+                    // TODO
42
+                    // Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes
43
+                }
44
+                print '</td>';
45
+            }
46
+        }
47
+    }
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Protection to avoid direct call of template
4
-if (empty($conf) || ! is_object($conf))
4
+if (empty($conf) || !is_object($conf))
5 5
 {
6 6
 	print "Error, template page can't be called as URL";
7 7
 	exit;
8 8
 }
9 9
 
10
-if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
10
+if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element;
11 11
 
12 12
 // Loop to show all columns of extrafields for the search title line
13
-if (! empty($extrafieldsobjectkey))	// $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
13
+if (!empty($extrafieldsobjectkey))	// $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
14 14
 {
15 15
 	if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
16 16
 	{
17
-		foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
17
+		foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
18 18
 		{
19
-			if (! empty($arrayfields["ef.".$key]['checked'])) {
20
-				$align=$extrafields->getAlignFlag($key);
21
-				$typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
22
-				print '<td class="liste_titre'.($align?' '.$align:'').'">';
19
+			if (!empty($arrayfields["ef.".$key]['checked'])) {
20
+				$align = $extrafields->getAlignFlag($key);
21
+				$typeofextrafield = $extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
22
+				print '<td class="liste_titre'.($align ? ' '.$align : '').'">';
23 23
 				if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]))
24 24
 				{
25
-					$crit=$val;
26
-					$tmpkey=preg_replace('/search_options_/','',$key);
27
-					$searchclass='';
28
-					if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
29
-					if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
30
-					print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
25
+					$crit = $val;
26
+					$tmpkey = preg_replace('/search_options_/', '', $key);
27
+					$searchclass = '';
28
+					if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass = 'searchstring';
29
+					if (in_array($typeofextrafield, array('int', 'double'))) $searchclass = 'searchnum';
30
+					print '<input class="flat'.($searchclass ? ' '.$searchclass : '').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
31 31
 				}
32
-				elseif (! in_array($typeofextrafield, array('datetime','timestamp')))
32
+				elseif (!in_array($typeofextrafield, array('datetime', 'timestamp')))
33 33
 				{
34 34
 					// for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid')
35
-					$morecss='';
36
-					if ($typeofextrafield == 'sellist') $morecss='maxwidth200';
35
+					$morecss = '';
36
+					if ($typeofextrafield == 'sellist') $morecss = 'maxwidth200';
37 37
 					echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss);
38 38
 				}
39
-				elseif (in_array($typeofextrafield, array('datetime','timestamp')))
39
+				elseif (in_array($typeofextrafield, array('datetime', 'timestamp')))
40 40
 				{
41 41
 					// TODO
42 42
 					// Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes
Please login to merge, or discard this patch.
Braces   +17 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,10 +7,13 @@  discard block
 block discarded – undo
7 7
 	exit;
8 8
 }
9 9
 
10
-if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
10
+if (empty($extrafieldsobjectkey) && is_object($object)) {
11
+    $extrafieldsobjectkey=$object->table_element;
12
+}
11 13
 
12 14
 // Loop to show all columns of extrafields for the search title line
13
-if (! empty($extrafieldsobjectkey))	// $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
15
+if (! empty($extrafieldsobjectkey)) {
16
+    // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
14 17
 {
15 18
 	if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
16 19
 	{
@@ -18,6 +21,7 @@  discard block
 block discarded – undo
18 21
 		{
19 22
 			if (! empty($arrayfields["ef.".$key]['checked'])) {
20 23
 				$align=$extrafields->getAlignFlag($key);
24
+}
21 25
 				$typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
22 26
 				print '<td class="liste_titre'.($align?' '.$align:'').'">';
23 27
 				if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]))
@@ -25,18 +29,22 @@  discard block
 block discarded – undo
25 29
 					$crit=$val;
26 30
 					$tmpkey=preg_replace('/search_options_/','',$key);
27 31
 					$searchclass='';
28
-					if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
29
-					if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
32
+					if (in_array($typeofextrafield, array('varchar', 'select'))) {
33
+					    $searchclass='searchstring';
34
+					}
35
+					if (in_array($typeofextrafield, array('int', 'double'))) {
36
+					    $searchclass='searchnum';
37
+					}
30 38
 					print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
31
-				}
32
-				elseif (! in_array($typeofextrafield, array('datetime','timestamp')))
39
+				} elseif (! in_array($typeofextrafield, array('datetime','timestamp')))
33 40
 				{
34 41
 					// for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid')
35 42
 					$morecss='';
36
-					if ($typeofextrafield == 'sellist') $morecss='maxwidth200';
43
+					if ($typeofextrafield == 'sellist') {
44
+					    $morecss='maxwidth200';
45
+					}
37 46
 					echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss);
38
-				}
39
-				elseif (in_array($typeofextrafield, array('datetime','timestamp')))
47
+				} elseif (in_array($typeofextrafield, array('datetime','timestamp')))
40 48
 				{
41 49
 					// TODO
42 50
 					// Use showInputField in a particular manner to have input with a comparison operator, not input for a specific value date-hour-minutes
Please login to merge, or discard this patch.
dolibarr/htdocs/core/tpl/admin_extrafields_view.tpl.php 3 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 // Protection to avoid direct call of template
28 28
 if (empty($langs) || ! is_object($langs))
29 29
 {
30
-	print "Error, template page can't be called as URL";
31
-	exit;
30
+    print "Error, template page can't be called as URL";
31
+    exit;
32 32
 }
33 33
 
34 34
 
@@ -66,50 +66,50 @@  discard block
 block discarded – undo
66 66
 print '<td align="center">'.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).'</td>';
67 67
 print '<td align="center">'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).'</td>';
68 68
 if ($conf->multicompany->enabled)  {
69
-	print '<td align="center">'.$langs->trans("Entities").'</td>';
69
+    print '<td align="center">'.$langs->trans("Entities").'</td>';
70 70
 }
71 71
 print '<td width="80">&nbsp;</td>';
72 72
 print "</tr>\n";
73 73
 
74 74
 if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type']))
75 75
 {
76
-	foreach($extrafields->attributes[$elementtype]['type'] as $key => $value)
77
-	{
78
-		// Load language if required
79
-		if (! empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
80
-			$langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
81
-		}
76
+    foreach($extrafields->attributes[$elementtype]['type'] as $key => $value)
77
+    {
78
+        // Load language if required
79
+        if (! empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
80
+            $langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
81
+        }
82 82
 
83
-		print '<tr class="oddeven">';
84
-		print "<td>".$extrafields->attributes[$elementtype]['pos'][$key]."</td>\n";
85
-		print "<td>".$extrafields->attributes[$elementtype]['label'][$key]."</td>\n";	// We don't translate here, we want admin to know what is the key not translated value
86
-		print "<td>".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."</td>\n";
87
-		print "<td>".$key."</td>\n";
88
-		print "<td>".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."</td>\n";
89
-		print '<td align="right">'.$extrafields->attributes[$elementtype]['size'][$key]."</td>\n";
90
-		print '<td>'.dol_trunc($extrafields->attributes[$elementtype]['computed'][$key], 20)."</td>\n";
91
-		print '<td align="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
92
-		print '<td align="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
93
-		print '<td align="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
94
-		print '<td align="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
95
-		print '<td align="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
96
-		if (! empty($conf->multicompany->enabled))  {
97
-			print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>';
98
-		}
99
-		print '<td class="right nowraponall""><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'#formeditextrafield">'.img_edit().'</a>';
100
-		print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
101
-		print "</tr>";
102
-	}
83
+        print '<tr class="oddeven">';
84
+        print "<td>".$extrafields->attributes[$elementtype]['pos'][$key]."</td>\n";
85
+        print "<td>".$extrafields->attributes[$elementtype]['label'][$key]."</td>\n";	// We don't translate here, we want admin to know what is the key not translated value
86
+        print "<td>".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."</td>\n";
87
+        print "<td>".$key."</td>\n";
88
+        print "<td>".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."</td>\n";
89
+        print '<td align="right">'.$extrafields->attributes[$elementtype]['size'][$key]."</td>\n";
90
+        print '<td>'.dol_trunc($extrafields->attributes[$elementtype]['computed'][$key], 20)."</td>\n";
91
+        print '<td align="center">'.yn($extrafields->attributes[$elementtype]['unique'][$key])."</td>\n";
92
+        print '<td align="center">'.yn($extrafields->attributes[$elementtype]['required'][$key])."</td>\n";
93
+        print '<td align="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
94
+        print '<td align="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
95
+        print '<td align="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
96
+        if (! empty($conf->multicompany->enabled))  {
97
+            print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>';
98
+        }
99
+        print '<td class="right nowraponall""><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'#formeditextrafield">'.img_edit().'</a>';
100
+        print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
101
+        print "</tr>";
102
+    }
103 103
 }
104 104
 else
105 105
 {
106
-	$colspan=9;
106
+    $colspan=9;
107 107
 
108
-	print '<tr class="oddeven">';
109
-	print '<td class="opacitymedium" colspan="'.$colspan.'">';
110
-	print $langs->trans("None");
111
-	print '</td>';
112
-	print '</tr>';
108
+    print '<tr class="oddeven">';
109
+    print '<td class="opacitymedium" colspan="'.$colspan.'">';
110
+    print $langs->trans("None");
111
+    print '</td>';
112
+    print '</tr>';
113 113
 }
114 114
 
115 115
 print "</table>";
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 
27 27
 // Protection to avoid direct call of template
28
-if (empty($langs) || ! is_object($langs))
28
+if (empty($langs) || !is_object($langs))
29 29
 {
30 30
 	print "Error, template page can't be called as URL";
31 31
 	exit;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 <!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
40 40
 <?php
41 41
 
42
-print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
42
+print $langs->trans("DefineHereComplementaryAttributes", $textobject).'<br>'."\n";
43 43
 print '<br>';
44 44
 
45 45
 // Load attribute_label
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 print '<td align="center">'.$langs->trans("AlwaysEditable").'</td>';
66 66
 print '<td align="center">'.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).'</td>';
67 67
 print '<td align="center">'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).'</td>';
68
-if ($conf->multicompany->enabled)  {
68
+if ($conf->multicompany->enabled) {
69 69
 	print '<td align="center">'.$langs->trans("Entities").'</td>';
70 70
 }
71 71
 print '<td width="80">&nbsp;</td>';
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 
74 74
 if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafields->attributes[$elementtype]['type']))
75 75
 {
76
-	foreach($extrafields->attributes[$elementtype]['type'] as $key => $value)
76
+	foreach ($extrafields->attributes[$elementtype]['type'] as $key => $value)
77 77
 	{
78 78
 		// Load language if required
79
-		if (! empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
79
+		if (!empty($extrafields->attributes[$elementtype]['langfile'][$key])) {
80 80
 			$langs->load($extrafields->attributes[$elementtype]['langfile'][$key]);
81 81
 		}
82 82
 
83 83
 		print '<tr class="oddeven">';
84 84
 		print "<td>".$extrafields->attributes[$elementtype]['pos'][$key]."</td>\n";
85
-		print "<td>".$extrafields->attributes[$elementtype]['label'][$key]."</td>\n";	// We don't translate here, we want admin to know what is the key not translated value
85
+		print "<td>".$extrafields->attributes[$elementtype]['label'][$key]."</td>\n"; // We don't translate here, we want admin to know what is the key not translated value
86 86
 		print "<td>".$langs->trans($extrafields->attributes[$elementtype]['label'][$key])."</td>\n";
87 87
 		print "<td>".$key."</td>\n";
88 88
 		print "<td>".$type2label[$extrafields->attributes[$elementtype]['type'][$key]]."</td>\n";
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 		print '<td align="center">'.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."</td>\n";
94 94
 		print '<td align="center">'.$extrafields->attributes[$elementtype]['list'][$key]."</td>\n";
95 95
 		print '<td align="center">'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."</td>\n";
96
-		if (! empty($conf->multicompany->enabled))  {
97
-			print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>';
96
+		if (!empty($conf->multicompany->enabled)) {
97
+			print '<td align="center">'.($extrafields->attributes[$elementtype]['entityid'][$key] == 0 ? $langs->trans("All") : $extrafields->attributes[$elementtype]['entitylabel'][$key]).'</td>';
98 98
 		}
99 99
 		print '<td class="right nowraponall""><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'#formeditextrafield">'.img_edit().'</a>';
100 100
 		print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 }
104 104
 else
105 105
 {
106
-	$colspan=9;
106
+	$colspan = 9;
107 107
 
108 108
 	print '<tr class="oddeven">';
109 109
 	print '<td class="opacitymedium" colspan="'.$colspan.'">';
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,8 +100,7 @@
 block discarded – undo
100 100
 		print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
101 101
 		print "</tr>";
102 102
 	}
103
-}
104
-else
103
+} else
105 104
 {
106 105
 	$colspan=9;
107 106
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/commonfieldsinexport.inc.php 3 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -10,31 +10,31 @@  discard block
 block discarded – undo
10 10
 dol_include_once($keyforclassfile);
11 11
 if (class_exists($keyforclass))
12 12
 {
13
-	$tmpobject=new $keyforclass($this->db);
13
+    $tmpobject=new $keyforclass($this->db);
14 14
 
15
-	// Add common fields
16
-	foreach($tmpobject->fields as $keyfield => $valuefield)
17
-	{
18
-		$fieldname = 't' . '.' . $keyfield;
19
-		$fieldlabel = ucfirst($valuefield['label']);
20
-		$typeFilter = "Text";
21
-		$typefield=preg_replace('/\(.*$/', '', $valuefield['type']);	// double(24,8) -> double
22
-		switch ($typefield) {
23
-			case 'int':
24
-			case 'integer':
25
-			case 'double':
26
-			case 'price':
27
-				$typeFilter = "Numeric";
28
-				break;
29
-			case 'date':
30
-			case 'datetime':
31
-			case 'timestamp':
32
-				$typeFilter = "Date";
33
-				break;
34
-			case 'boolean':
35
-				$typeFilter = "Boolean";
36
-				break;
37
-			/*
15
+    // Add common fields
16
+    foreach($tmpobject->fields as $keyfield => $valuefield)
17
+    {
18
+        $fieldname = 't' . '.' . $keyfield;
19
+        $fieldlabel = ucfirst($valuefield['label']);
20
+        $typeFilter = "Text";
21
+        $typefield=preg_replace('/\(.*$/', '', $valuefield['type']);	// double(24,8) -> double
22
+        switch ($typefield) {
23
+            case 'int':
24
+            case 'integer':
25
+            case 'double':
26
+            case 'price':
27
+                $typeFilter = "Numeric";
28
+                break;
29
+            case 'date':
30
+            case 'datetime':
31
+            case 'timestamp':
32
+                $typeFilter = "Date";
33
+                break;
34
+            case 'boolean':
35
+                $typeFilter = "Boolean";
36
+                break;
37
+            /*
38 38
 			 * case 'sellist':
39 39
 			 * $tmp='';
40 40
 			 * $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 			 * if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
46 46
 			 * break;
47 47
 			 */
48
-		}
49
-		if ($valuefield['enabled']) {
50
-			$this->export_fields_array[$r][$fieldname] = $fieldlabel;
51
-			$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
52
-			$this->export_entities_array[$r][$fieldname] = $keyforelement;
53
-		}
54
-	}
48
+        }
49
+        if ($valuefield['enabled']) {
50
+            $this->export_fields_array[$r][$fieldname] = $fieldlabel;
51
+            $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
52
+            $this->export_entities_array[$r][$fieldname] = $keyforelement;
53
+        }
54
+    }
55 55
 }
56 56
 else
57 57
 {
58
-	dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
58
+    dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
59 59
 }
60 60
 // End add common fields
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 dol_include_once($keyforclassfile);
11 11
 if (class_exists($keyforclass))
12 12
 {
13
-	$tmpobject=new $keyforclass($this->db);
13
+	$tmpobject = new $keyforclass($this->db);
14 14
 
15 15
 	// Add common fields
16
-	foreach($tmpobject->fields as $keyfield => $valuefield)
16
+	foreach ($tmpobject->fields as $keyfield => $valuefield)
17 17
 	{
18
-		$fieldname = 't' . '.' . $keyfield;
18
+		$fieldname = 't'.'.'.$keyfield;
19 19
 		$fieldlabel = ucfirst($valuefield['label']);
20 20
 		$typeFilter = "Text";
21
-		$typefield=preg_replace('/\(.*$/', '', $valuefield['type']);	// double(24,8) -> double
21
+		$typefield = preg_replace('/\(.*$/', '', $valuefield['type']); // double(24,8) -> double
22 22
 		switch ($typefield) {
23 23
 			case 'int':
24 24
 			case 'integer':
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@
 block discarded – undo
52 52
 			$this->export_entities_array[$r][$fieldname] = $keyforelement;
53 53
 		}
54 54
 	}
55
-}
56
-else
55
+} else
57 56
 {
58 57
 	dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
59 58
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/triggers/interface_20_all_Logevents.class.php 3 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -31,41 +31,41 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class InterfaceLogevents extends DolibarrTriggers
33 33
 {
34
-	/**
35
-	 * @var string Image of the trigger
36
-	 */
37
-	public $picto = 'technic';
38
-
39
-	public $family = 'core';
40
-
41
-	public $description = "Triggers of this module allows to add security event records inside Dolibarr.";
42
-
43
-	/**
44
-	 * Version of the trigger
45
-	 * @var string
46
-	 */
47
-	public $version = self::VERSION_DOLIBARR;
48
-
49
-	/**
50
-	 * Function called when a Dolibarrr business event is done.
51
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
52
-	 *
53
-	 * @param string		$action		Event action code
54
-	 * @param Object		$object     Object
55
-	 * @param User			$user       Object user
56
-	 * @param Translate		$langs      Object langs
57
-	 * @param conf			$conf       Object conf
58
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
59
-	 */
60
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
34
+    /**
35
+     * @var string Image of the trigger
36
+     */
37
+    public $picto = 'technic';
38
+
39
+    public $family = 'core';
40
+
41
+    public $description = "Triggers of this module allows to add security event records inside Dolibarr.";
42
+
43
+    /**
44
+     * Version of the trigger
45
+     * @var string
46
+     */
47
+    public $version = self::VERSION_DOLIBARR;
48
+
49
+    /**
50
+     * Function called when a Dolibarrr business event is done.
51
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
52
+     *
53
+     * @param string		$action		Event action code
54
+     * @param Object		$object     Object
55
+     * @param User			$user       Object user
56
+     * @param Translate		$langs      Object langs
57
+     * @param conf			$conf       Object conf
58
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
59
+     */
60
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
61 61
     {
62
-    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
62
+        if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
63 63
 
64
-    	$key='MAIN_LOGEVENTS_'.$action;
65
-    	//dol_syslog("xxxxxxxxxxx".$key);
66
-    	if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
64
+        $key='MAIN_LOGEVENTS_'.$action;
65
+        //dol_syslog("xxxxxxxxxxx".$key);
66
+        if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
67 67
 
68
-    	if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
68
+        if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
69 69
 
70 70
         $date = dol_now();
71 71
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             // Initialisation donnees (date,duree,texte,desc)
107 107
             $text=$langs->transnoentities("NewUserCreated",$object->login);
108 108
             $desc=$langs->transnoentities("NewUserCreated",$object->login);
109
-		}
109
+        }
110 110
         elseif ($action == 'USER_MODIFY')
111 111
         {
112 112
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
131 131
             $langs->load("users");
132 132
             // Initialisation donnees (date,duree,texte,desc)
133
-			if ($object->statut == 0)
134
-			{
135
-				$text=$langs->transnoentities("UserEnabled",$object->login);
136
-				$desc=$langs->transnoentities("UserEnabled",$object->login);
137
-			}
138
-			if ($object->statut == 1)
139
-			{
140
-				$text=$langs->transnoentities("UserDisabled",$object->login);
141
-				$desc=$langs->transnoentities("UserDisabled",$object->login);
142
-			}
133
+            if ($object->statut == 0)
134
+            {
135
+                $text=$langs->transnoentities("UserEnabled",$object->login);
136
+                $desc=$langs->transnoentities("UserEnabled",$object->login);
137
+            }
138
+            if ($object->statut == 1)
139
+            {
140
+                $text=$langs->transnoentities("UserDisabled",$object->login);
141
+                $desc=$langs->transnoentities("UserDisabled",$object->login);
142
+            }
143 143
         }
144 144
         elseif ($action == 'USER_DELETE')
145 145
         {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             $desc=$langs->transnoentities("UserDeleted",$object->login);
151 151
         }
152 152
 
153
-		// Groupes
153
+        // Groupes
154 154
         elseif ($action == 'GROUP_CREATE')
155 155
         {
156 156
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             // Initialisation donnees (date,duree,texte,desc)
159 159
             $text=$langs->transnoentities("NewGroupCreated",$object->name);
160 160
             $desc=$langs->transnoentities("NewGroupCreated",$object->name);
161
-		}
161
+        }
162 162
         elseif ($action == 'GROUP_MODIFY')
163 163
         {
164 164
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             // Initialisation donnees (date,duree,texte,desc)
167 167
             $text=$langs->transnoentities("GroupModified",$object->name);
168 168
             $desc=$langs->transnoentities("GroupModified",$object->name);
169
-		}
169
+        }
170 170
         elseif ($action == 'GROUP_DELETE')
171 171
         {
172 172
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
             // Initialisation donnees (date,duree,texte,desc)
175 175
             $text=$langs->transnoentities("GroupDeleted",$object->name);
176 176
             $desc=$langs->transnoentities("GroupDeleted",$object->name);
177
-		}
177
+        }
178 178
 
179
-		// If not found
179
+        // If not found
180 180
 /*
181 181
         else
182 182
         {
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
         }
186 186
 */
187 187
 
188
-		// Add more information into desc from the context property
189
-		if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
188
+        // Add more information into desc from the context property
189
+        if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
190 190
 
191 191
         // Add entry in event table
192
-		include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
192
+        include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
193 193
 
194
-		$event=new Events($this->db);
194
+        $event=new Events($this->db);
195 195
         $event->type=$action;
196 196
         $event->dateevent=$date;
197 197
         $event->label=$text;
198 198
         $event->description=$desc;
199
-		$event->user_agent=$_SERVER["HTTP_USER_AGENT"];
199
+        $event->user_agent=$_SERVER["HTTP_USER_AGENT"];
200 200
 
201 201
         $result=$event->create($user);
202 202
         if ($result > 0)
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
61 61
     {
62
-    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
62
+    	if (!empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features)
63 63
 
64
-    	$key='MAIN_LOGEVENTS_'.$action;
64
+    	$key = 'MAIN_LOGEVENTS_'.$action;
65 65
     	//dol_syslog("xxxxxxxxxxx".$key);
66
-    	if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
66
+    	if (empty($conf->global->$key)) return 0; // Log events not enabled for this action
67 67
 
68
-    	if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
68
+    	if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form)
69 69
 
70 70
         $date = dol_now();
71 71
 
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 
77 77
             $langs->load("users");
78 78
             // Initialisation donnees (date,duree,texte,desc)
79
-            $text="(UserLogged,".$object->login.")";
80
-            $text.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
81
-            $desc="(UserLogged,".$object->login.")";
82
-            $desc.=(empty($object->trigger_mesg)?'':' - '.$object->trigger_mesg);
79
+            $text = "(UserLogged,".$object->login.")";
80
+            $text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
81
+            $desc = "(UserLogged,".$object->login.")";
82
+            $desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
83 83
         }
84 84
         if ($action == 'USER_LOGIN_FAILED')
85 85
         {
86 86
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
87 87
 
88 88
             // Initialisation donnees (date,duree,texte,desc)
89
-            $text=$object->trigger_mesg;	// Message direct
90
-            $desc=$object->trigger_mesg;	// Message direct
89
+            $text = $object->trigger_mesg; // Message direct
90
+            $desc = $object->trigger_mesg; // Message direct
91 91
         }
92 92
         if ($action == 'USER_LOGOUT')
93 93
         {
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 
96 96
             $langs->load("users");
97 97
             // Initialisation donnees (date,duree,texte,desc)
98
-            $text="(UserLogoff,".$object->login.")";
99
-            $desc="(UserLogoff,".$object->login.")";
98
+            $text = "(UserLogoff,".$object->login.")";
99
+            $desc = "(UserLogoff,".$object->login.")";
100 100
         }
101 101
         if ($action == 'USER_CREATE')
102 102
         {
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
             $langs->load("users");
105 105
 
106 106
             // Initialisation donnees (date,duree,texte,desc)
107
-            $text=$langs->transnoentities("NewUserCreated",$object->login);
108
-            $desc=$langs->transnoentities("NewUserCreated",$object->login);
107
+            $text = $langs->transnoentities("NewUserCreated", $object->login);
108
+            $desc = $langs->transnoentities("NewUserCreated", $object->login);
109 109
 		}
110 110
         elseif ($action == 'USER_MODIFY')
111 111
         {
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
             $langs->load("users");
114 114
 
115 115
             // Initialisation donnees (date,duree,texte,desc)
116
-            $text=$langs->transnoentities("EventUserModified",$object->login);
117
-            $desc=$langs->transnoentities("EventUserModified",$object->login);
116
+            $text = $langs->transnoentities("EventUserModified", $object->login);
117
+            $desc = $langs->transnoentities("EventUserModified", $object->login);
118 118
         }
119 119
         elseif ($action == 'USER_NEW_PASSWORD')
120 120
         {
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
             $langs->load("users");
123 123
 
124 124
             // Initialisation donnees (date,duree,texte,desc)
125
-            $text=$langs->transnoentities("NewUserPassword",$object->login);
126
-            $desc=$langs->transnoentities("NewUserPassword",$object->login);
125
+            $text = $langs->transnoentities("NewUserPassword", $object->login);
126
+            $desc = $langs->transnoentities("NewUserPassword", $object->login);
127 127
         }
128 128
         elseif ($action == 'USER_ENABLEDISABLE')
129 129
         {
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
             // Initialisation donnees (date,duree,texte,desc)
133 133
 			if ($object->statut == 0)
134 134
 			{
135
-				$text=$langs->transnoentities("UserEnabled",$object->login);
136
-				$desc=$langs->transnoentities("UserEnabled",$object->login);
135
+				$text = $langs->transnoentities("UserEnabled", $object->login);
136
+				$desc = $langs->transnoentities("UserEnabled", $object->login);
137 137
 			}
138 138
 			if ($object->statut == 1)
139 139
 			{
140
-				$text=$langs->transnoentities("UserDisabled",$object->login);
141
-				$desc=$langs->transnoentities("UserDisabled",$object->login);
140
+				$text = $langs->transnoentities("UserDisabled", $object->login);
141
+				$desc = $langs->transnoentities("UserDisabled", $object->login);
142 142
 			}
143 143
         }
144 144
         elseif ($action == 'USER_DELETE')
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
147 147
             $langs->load("users");
148 148
             // Initialisation donnees (date,duree,texte,desc)
149
-            $text=$langs->transnoentities("UserDeleted",$object->login);
150
-            $desc=$langs->transnoentities("UserDeleted",$object->login);
149
+            $text = $langs->transnoentities("UserDeleted", $object->login);
150
+            $desc = $langs->transnoentities("UserDeleted", $object->login);
151 151
         }
152 152
 
153 153
 		// Groupes
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
157 157
             $langs->load("users");
158 158
             // Initialisation donnees (date,duree,texte,desc)
159
-            $text=$langs->transnoentities("NewGroupCreated",$object->name);
160
-            $desc=$langs->transnoentities("NewGroupCreated",$object->name);
159
+            $text = $langs->transnoentities("NewGroupCreated", $object->name);
160
+            $desc = $langs->transnoentities("NewGroupCreated", $object->name);
161 161
 		}
162 162
         elseif ($action == 'GROUP_MODIFY')
163 163
         {
164 164
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
165 165
             $langs->load("users");
166 166
             // Initialisation donnees (date,duree,texte,desc)
167
-            $text=$langs->transnoentities("GroupModified",$object->name);
168
-            $desc=$langs->transnoentities("GroupModified",$object->name);
167
+            $text = $langs->transnoentities("GroupModified", $object->name);
168
+            $desc = $langs->transnoentities("GroupModified", $object->name);
169 169
 		}
170 170
         elseif ($action == 'GROUP_DELETE')
171 171
         {
172 172
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
173 173
             $langs->load("users");
174 174
             // Initialisation donnees (date,duree,texte,desc)
175
-            $text=$langs->transnoentities("GroupDeleted",$object->name);
176
-            $desc=$langs->transnoentities("GroupDeleted",$object->name);
175
+            $text = $langs->transnoentities("GroupDeleted", $object->name);
176
+            $desc = $langs->transnoentities("GroupDeleted", $object->name);
177 177
 		}
178 178
 
179 179
 		// If not found
@@ -186,27 +186,27 @@  discard block
 block discarded – undo
186 186
 */
187 187
 
188 188
 		// Add more information into desc from the context property
189
-		if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
189
+		if (!empty($desc) && !empty($object->context['audit'])) $desc .= ' - '.$object->context['audit'];
190 190
 
191 191
         // Add entry in event table
192 192
 		include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
193 193
 
194
-		$event=new Events($this->db);
195
-        $event->type=$action;
196
-        $event->dateevent=$date;
197
-        $event->label=$text;
198
-        $event->description=$desc;
199
-		$event->user_agent=$_SERVER["HTTP_USER_AGENT"];
194
+		$event = new Events($this->db);
195
+        $event->type = $action;
196
+        $event->dateevent = $date;
197
+        $event->label = $text;
198
+        $event->description = $desc;
199
+		$event->user_agent = $_SERVER["HTTP_USER_AGENT"];
200 200
 
201
-        $result=$event->create($user);
201
+        $result = $event->create($user);
202 202
         if ($result > 0)
203 203
         {
204 204
             return 1;
205 205
         }
206 206
         else
207 207
         {
208
-            $error ="Failed to insert security event: ".$event->error;
209
-            $this->error=$error;
208
+            $error = "Failed to insert security event: ".$event->error;
209
+            $this->error = $error;
210 210
 
211 211
             dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
212 212
             return -1;
Please login to merge, or discard this patch.
Braces   +22 added lines, -18 removed lines patch added patch discarded remove patch
@@ -59,13 +59,22 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
61 61
     {
62
-    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0;	// Log events is disabled (hidden features)
62
+    	if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) {
63
+    	    return 0;
64
+    	}
65
+    	// Log events is disabled (hidden features)
63 66
 
64 67
     	$key='MAIN_LOGEVENTS_'.$action;
65 68
     	//dol_syslog("xxxxxxxxxxx".$key);
66
-    	if (empty($conf->global->$key)) return 0;				// Log events not enabled for this action
69
+    	if (empty($conf->global->$key)) {
70
+    	    return 0;
71
+    	}
72
+    	// Log events not enabled for this action
67 73
 
68
-    	if (empty($conf->entity)) $conf->entity = $entity;  // forcing of the entity if it's not defined (ex: in login form)
74
+    	if (empty($conf->entity)) {
75
+    	    $conf->entity = $entity;
76
+    	}
77
+    	// forcing of the entity if it's not defined (ex: in login form)
69 78
 
70 79
         $date = dol_now();
71 80
 
@@ -106,8 +115,7 @@  discard block
 block discarded – undo
106 115
             // Initialisation donnees (date,duree,texte,desc)
107 116
             $text=$langs->transnoentities("NewUserCreated",$object->login);
108 117
             $desc=$langs->transnoentities("NewUserCreated",$object->login);
109
-		}
110
-        elseif ($action == 'USER_MODIFY')
118
+		} elseif ($action == 'USER_MODIFY')
111 119
         {
112 120
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
113 121
             $langs->load("users");
@@ -115,8 +123,7 @@  discard block
 block discarded – undo
115 123
             // Initialisation donnees (date,duree,texte,desc)
116 124
             $text=$langs->transnoentities("EventUserModified",$object->login);
117 125
             $desc=$langs->transnoentities("EventUserModified",$object->login);
118
-        }
119
-        elseif ($action == 'USER_NEW_PASSWORD')
126
+        } elseif ($action == 'USER_NEW_PASSWORD')
120 127
         {
121 128
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
122 129
             $langs->load("users");
@@ -124,8 +131,7 @@  discard block
 block discarded – undo
124 131
             // Initialisation donnees (date,duree,texte,desc)
125 132
             $text=$langs->transnoentities("NewUserPassword",$object->login);
126 133
             $desc=$langs->transnoentities("NewUserPassword",$object->login);
127
-        }
128
-        elseif ($action == 'USER_ENABLEDISABLE')
134
+        } elseif ($action == 'USER_ENABLEDISABLE')
129 135
         {
130 136
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
131 137
             $langs->load("users");
@@ -140,8 +146,7 @@  discard block
 block discarded – undo
140 146
 				$text=$langs->transnoentities("UserDisabled",$object->login);
141 147
 				$desc=$langs->transnoentities("UserDisabled",$object->login);
142 148
 			}
143
-        }
144
-        elseif ($action == 'USER_DELETE')
149
+        } elseif ($action == 'USER_DELETE')
145 150
         {
146 151
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
147 152
             $langs->load("users");
@@ -158,16 +163,14 @@  discard block
 block discarded – undo
158 163
             // Initialisation donnees (date,duree,texte,desc)
159 164
             $text=$langs->transnoentities("NewGroupCreated",$object->name);
160 165
             $desc=$langs->transnoentities("NewGroupCreated",$object->name);
161
-		}
162
-        elseif ($action == 'GROUP_MODIFY')
166
+		} elseif ($action == 'GROUP_MODIFY')
163 167
         {
164 168
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
165 169
             $langs->load("users");
166 170
             // Initialisation donnees (date,duree,texte,desc)
167 171
             $text=$langs->transnoentities("GroupModified",$object->name);
168 172
             $desc=$langs->transnoentities("GroupModified",$object->name);
169
-		}
170
-        elseif ($action == 'GROUP_DELETE')
173
+		} elseif ($action == 'GROUP_DELETE')
171 174
         {
172 175
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
173 176
             $langs->load("users");
@@ -186,7 +189,9 @@  discard block
 block discarded – undo
186 189
 */
187 190
 
188 191
 		// Add more information into desc from the context property
189
-		if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
192
+		if (! empty($desc) && ! empty($object->context['audit'])) {
193
+		    $desc.=' - '.$object->context['audit'];
194
+		}
190 195
 
191 196
         // Add entry in event table
192 197
 		include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
@@ -202,8 +207,7 @@  discard block
 block discarded – undo
202 207
         if ($result > 0)
203 208
         {
204 209
             return 1;
205
-        }
206
-        else
210
+        } else
207 211
         {
208 212
             $error ="Failed to insert security event: ".$event->error;
209 213
             $this->error=$error;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php 3 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -50,221 +50,221 @@
 block discarded – undo
50 50
         $this->db = $db;
51 51
 
52 52
         $this->name = preg_replace('/^Interface/i', '', get_class($this));
53
-	    $this->family = 'stripe';
53
+        $this->family = 'stripe';
54 54
         $this->description = "Triggers of the module Stripe";
55 55
         $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
56 56
         $this->picto = 'stripe@stripe';
57 57
     }
58 58
 
59
-	/**
60
-	 * Trigger name
61
-	 *
62
-	 * @return string Name of trigger file
63
-	 */
64
-	public function getName()
65
-	{
66
-		return $this->name;
67
-	}
68
-
69
-
70
-	/**
71
-	 * Trigger description
72
-	 *
73
-	 * @return string Description of trigger file
74
-	 */
75
-	public function getDesc()
76
-	{
77
-		return $this->description;
78
-	}
79
-
80
-	/**
81
-	 * Trigger version
82
-	 *
83
-	 * @return string Version of trigger file
84
-	 */
85
-	public function getVersion()
86
-	{
87
-		global $langs;
88
-		$langs->load("admin");
89
-
90
-		if ($this->version == 'development') {
91
-			return $langs->trans("Development");
92
-		} elseif ($this->version == 'experimental') {
93
-			return $langs->trans("Experimental");
94
-		} elseif ($this->version == 'dolibarr') {
95
-			return DOL_VERSION;
96
-		} elseif ($this->version) {
97
-			return $this->version;
98
-		} else {
99
-			return $langs->trans("Unknown");
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * Function called when a Dolibarrr business event is done.
105
-	 * All functions "runTrigger" are triggered if file
106
-	 * is inside directory core/triggers
107
-	 *
108
-	 * @param 	string 			$action 	Event action code
109
-	 * @param 	CommonObject 	$object 	Object
110
-	 * @param 	User 			$user 		Object user
111
-	 * @param 	Translate 		$langs 		Object langs
112
-	 * @param 	Conf 			$conf 		Object conf
113
-	 * @return 	int              			<0 if KO, 0 if no triggered ran, >0 if OK
114
-	 */
115
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
116
-	{
117
-		// Put here code you want to execute when a Dolibarr business event occurs.
118
-		// Data and type of action are stored into $object and $action
119
-		global $langs, $db, $conf;
120
-
121
-		// Load translation files required by the page
59
+    /**
60
+     * Trigger name
61
+     *
62
+     * @return string Name of trigger file
63
+     */
64
+    public function getName()
65
+    {
66
+        return $this->name;
67
+    }
68
+
69
+
70
+    /**
71
+     * Trigger description
72
+     *
73
+     * @return string Description of trigger file
74
+     */
75
+    public function getDesc()
76
+    {
77
+        return $this->description;
78
+    }
79
+
80
+    /**
81
+     * Trigger version
82
+     *
83
+     * @return string Version of trigger file
84
+     */
85
+    public function getVersion()
86
+    {
87
+        global $langs;
88
+        $langs->load("admin");
89
+
90
+        if ($this->version == 'development') {
91
+            return $langs->trans("Development");
92
+        } elseif ($this->version == 'experimental') {
93
+            return $langs->trans("Experimental");
94
+        } elseif ($this->version == 'dolibarr') {
95
+            return DOL_VERSION;
96
+        } elseif ($this->version) {
97
+            return $this->version;
98
+        } else {
99
+            return $langs->trans("Unknown");
100
+        }
101
+    }
102
+
103
+    /**
104
+     * Function called when a Dolibarrr business event is done.
105
+     * All functions "runTrigger" are triggered if file
106
+     * is inside directory core/triggers
107
+     *
108
+     * @param 	string 			$action 	Event action code
109
+     * @param 	CommonObject 	$object 	Object
110
+     * @param 	User 			$user 		Object user
111
+     * @param 	Translate 		$langs 		Object langs
112
+     * @param 	Conf 			$conf 		Object conf
113
+     * @return 	int              			<0 if KO, 0 if no triggered ran, >0 if OK
114
+     */
115
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
116
+    {
117
+        // Put here code you want to execute when a Dolibarr business event occurs.
118
+        // Data and type of action are stored into $object and $action
119
+        global $langs, $db, $conf;
120
+
121
+        // Load translation files required by the page
122 122
         $langs->loadLangs(array("members","other","users","mails"));
123 123
 
124
-		require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
125
-		$stripe = new Stripe($db);
126
-
127
-		if (empty($conf->stripe->enabled)) return 0;
128
-
129
-		$ok = 1;
130
-
131
-		$service = 'StripeTest';
132
-		$servicestatus = 0;
133
-		if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha'))
134
-		{
135
-			$service = 'StripeLive';
136
-			$servicestatus = 1;
137
-		}
138
-
139
-		// If customer is linked to Stripe, we update/delete Stripe too
140
-		if ($action == 'COMPANY_MODIFY') {
141
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
142
-
143
-			$stripeacc = $stripe->getStripeAccount($service);	// No need of network access for this. May return '' if no Oauth defined.
144
-
145
-			if ($object->client != 0) {
146
-				$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);	// This make a network request
147
-				if ($customer)
148
-				{
149
-					$namecleaned = $object->name ? $object->name : null;
150
-					$vatcleaned = $object->tva_intra ? $object->tva_intra : null;
151
-
152
-					$taxinfo = array('type'=>'vat');
153
-					if ($vatcleaned)
154
-					{
155
-						$taxinfo["tax_id"] = $vatcleaned;
156
-					}
157
-					// We force data to "null" if not defined as expected by Stripe
158
-					if (empty($vatcleaned)) $taxinfo=null;
159
-
160
-					// Detect if we change a Stripe info (email, description, vat id)
161
-					$changerequested = 0;
162
-					if (! empty($object->email) && $object->email != $customer->email) $changerequested++;
163
-					if ($namecleaned != $customer->description) $changerequested++;
164
-					if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++;
165
-					elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++;
166
-					elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned))
167
-					{
168
-						if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++;
169
-					}
170
-
171
-					if ($changerequested)
172
-					{
173
-						if (! empty($object->email)) $customer->email = $object->email;
174
-						$customer->description = $namecleaned;
175
-						if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
176
-						else $customer->tax_info = $taxinfo;
177
-
178
-						$customer->save();
179
-					}
180
-				}
181
-			}
182
-		}
183
-		if ($action == 'COMPANY_DELETE') {
184
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
185
-
186
-			$stripeacc = $stripe->getStripeAccount($service);	// No need of network access for this. May return '' if no Oauth defined.
187
-
188
-			$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);
189
-			if ($customer)
190
-			{
191
-				$customer->delete();
192
-			}
193
-
194
-			$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account";
195
-			$sql.= " WHERE site='stripe' AND fk_soc = " . $object->id;
196
-			$this->db->query($sql);
197
-		}
198
-
199
-		// If payment mode is linked to Stripee, we update/delete Stripe too
200
-		if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
201
-
202
-			// For creation of credit card, we do not create in Stripe automatically
203
-		}
204
-		if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
205
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
206
-
207
-			if (! empty($object->stripe_card_ref))
208
-			{
209
-				$stripeacc = $stripe->getStripeAccount($service);				// No need of network access for this. May return '' if no Oauth defined.
210
-				$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc);	// No need of network access for this
211
-
212
-				if ($stripecu)
213
-				{
214
-					// Get customer (required to get a card)
215
-					if (empty($stripeacc)) {				// If the Stripe connect account not set, we use common API usage
216
-						$customer = \Stripe\Customer::retrieve($stripecu);
217
-					} else {
218
-						$customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
219
-					}
220
-
221
-					if ($customer)
222
-					{
223
-						$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
224
-						if ($card) {
225
-							$card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
226
-							try {
227
-								$card->save($dataforcard);
228
-							}
229
-							catch(Exception $e)
230
-							{
231
-								$ok = -1;
232
-								$this->error = $e->getMessages();
233
-							}
234
-						}
235
-					}
236
-				}
237
-			}
238
-		}
239
-		if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
240
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
241
-
242
-			if (! empty($object->stripe_card_ref))
243
-			{
244
-				$stripeacc = $stripe->getStripeAccount($service);				// No need of network access for this. May return '' if no Oauth defined.
245
-				$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc);	// No need of network access for this
246
-
247
-				if ($stripecu)
248
-				{
249
-					// Get customer (required to get a card)
250
-					if (empty($stripeacc)) {				// If the Stripe connect account not set, we use common API usage
251
-						$customer = \Stripe\Customer::retrieve($stripecu);
252
-					} else {
253
-						$customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
254
-					}
255
-
256
-					if ($customer)
257
-					{
258
-						$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
259
-						if ($card) {
260
-							if (method_exists($card, 'detach')) $card->detach();
261
-							else $card->delete();
262
-						}
263
-					}
264
-				}
265
-			}
266
-		}
267
-
268
-		return $ok;
269
-	}
124
+        require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
125
+        $stripe = new Stripe($db);
126
+
127
+        if (empty($conf->stripe->enabled)) return 0;
128
+
129
+        $ok = 1;
130
+
131
+        $service = 'StripeTest';
132
+        $servicestatus = 0;
133
+        if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha'))
134
+        {
135
+            $service = 'StripeLive';
136
+            $servicestatus = 1;
137
+        }
138
+
139
+        // If customer is linked to Stripe, we update/delete Stripe too
140
+        if ($action == 'COMPANY_MODIFY') {
141
+            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
142
+
143
+            $stripeacc = $stripe->getStripeAccount($service);	// No need of network access for this. May return '' if no Oauth defined.
144
+
145
+            if ($object->client != 0) {
146
+                $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);	// This make a network request
147
+                if ($customer)
148
+                {
149
+                    $namecleaned = $object->name ? $object->name : null;
150
+                    $vatcleaned = $object->tva_intra ? $object->tva_intra : null;
151
+
152
+                    $taxinfo = array('type'=>'vat');
153
+                    if ($vatcleaned)
154
+                    {
155
+                        $taxinfo["tax_id"] = $vatcleaned;
156
+                    }
157
+                    // We force data to "null" if not defined as expected by Stripe
158
+                    if (empty($vatcleaned)) $taxinfo=null;
159
+
160
+                    // Detect if we change a Stripe info (email, description, vat id)
161
+                    $changerequested = 0;
162
+                    if (! empty($object->email) && $object->email != $customer->email) $changerequested++;
163
+                    if ($namecleaned != $customer->description) $changerequested++;
164
+                    if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++;
165
+                    elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++;
166
+                    elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned))
167
+                    {
168
+                        if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++;
169
+                    }
170
+
171
+                    if ($changerequested)
172
+                    {
173
+                        if (! empty($object->email)) $customer->email = $object->email;
174
+                        $customer->description = $namecleaned;
175
+                        if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
176
+                        else $customer->tax_info = $taxinfo;
177
+
178
+                        $customer->save();
179
+                    }
180
+                }
181
+            }
182
+        }
183
+        if ($action == 'COMPANY_DELETE') {
184
+            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
185
+
186
+            $stripeacc = $stripe->getStripeAccount($service);	// No need of network access for this. May return '' if no Oauth defined.
187
+
188
+            $customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);
189
+            if ($customer)
190
+            {
191
+                $customer->delete();
192
+            }
193
+
194
+            $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account";
195
+            $sql.= " WHERE site='stripe' AND fk_soc = " . $object->id;
196
+            $this->db->query($sql);
197
+        }
198
+
199
+        // If payment mode is linked to Stripee, we update/delete Stripe too
200
+        if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
201
+
202
+            // For creation of credit card, we do not create in Stripe automatically
203
+        }
204
+        if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
205
+            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
206
+
207
+            if (! empty($object->stripe_card_ref))
208
+            {
209
+                $stripeacc = $stripe->getStripeAccount($service);				// No need of network access for this. May return '' if no Oauth defined.
210
+                $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc);	// No need of network access for this
211
+
212
+                if ($stripecu)
213
+                {
214
+                    // Get customer (required to get a card)
215
+                    if (empty($stripeacc)) {				// If the Stripe connect account not set, we use common API usage
216
+                        $customer = \Stripe\Customer::retrieve($stripecu);
217
+                    } else {
218
+                        $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
219
+                    }
220
+
221
+                    if ($customer)
222
+                    {
223
+                        $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
224
+                        if ($card) {
225
+                            $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
226
+                            try {
227
+                                $card->save($dataforcard);
228
+                            }
229
+                            catch(Exception $e)
230
+                            {
231
+                                $ok = -1;
232
+                                $this->error = $e->getMessages();
233
+                            }
234
+                        }
235
+                    }
236
+                }
237
+            }
238
+        }
239
+        if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
240
+            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
241
+
242
+            if (! empty($object->stripe_card_ref))
243
+            {
244
+                $stripeacc = $stripe->getStripeAccount($service);				// No need of network access for this. May return '' if no Oauth defined.
245
+                $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc);	// No need of network access for this
246
+
247
+                if ($stripecu)
248
+                {
249
+                    // Get customer (required to get a card)
250
+                    if (empty($stripeacc)) {				// If the Stripe connect account not set, we use common API usage
251
+                        $customer = \Stripe\Customer::retrieve($stripecu);
252
+                    } else {
253
+                        $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
254
+                    }
255
+
256
+                    if ($customer)
257
+                    {
258
+                        $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
259
+                        if ($card) {
260
+                            if (method_exists($card, 'detach')) $card->detach();
261
+                            else $card->delete();
262
+                        }
263
+                    }
264
+                }
265
+            }
266
+        }
267
+
268
+        return $ok;
269
+    }
270 270
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		global $langs, $db, $conf;
120 120
 
121 121
 		// Load translation files required by the page
122
-        $langs->loadLangs(array("members","other","users","mails"));
122
+        $langs->loadLangs(array("members", "other", "users", "mails"));
123 123
 
124 124
 		require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
125 125
 		$stripe = new Stripe($db);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 		$service = 'StripeTest';
132 132
 		$servicestatus = 0;
133
-		if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha'))
133
+		if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha'))
134 134
 		{
135 135
 			$service = 'StripeLive';
136 136
 			$servicestatus = 1;
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 
139 139
 		// If customer is linked to Stripe, we update/delete Stripe too
140 140
 		if ($action == 'COMPANY_MODIFY') {
141
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
141
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
142 142
 
143
-			$stripeacc = $stripe->getStripeAccount($service);	// No need of network access for this. May return '' if no Oauth defined.
143
+			$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
144 144
 
145 145
 			if ($object->client != 0) {
146
-				$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);	// This make a network request
146
+				$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request
147 147
 				if ($customer)
148 148
 				{
149 149
 					$namecleaned = $object->name ? $object->name : null;
@@ -155,22 +155,22 @@  discard block
 block discarded – undo
155 155
 						$taxinfo["tax_id"] = $vatcleaned;
156 156
 					}
157 157
 					// We force data to "null" if not defined as expected by Stripe
158
-					if (empty($vatcleaned)) $taxinfo=null;
158
+					if (empty($vatcleaned)) $taxinfo = null;
159 159
 
160 160
 					// Detect if we change a Stripe info (email, description, vat id)
161 161
 					$changerequested = 0;
162
-					if (! empty($object->email) && $object->email != $customer->email) $changerequested++;
162
+					if (!empty($object->email) && $object->email != $customer->email) $changerequested++;
163 163
 					if ($namecleaned != $customer->description) $changerequested++;
164
-					if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++;
164
+					if (!isset($customer->tax_info['tax_id']) && !is_null($vatcleaned)) $changerequested++;
165 165
 					elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++;
166
-					elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned))
166
+					elseif (isset($customer->tax_info['tax_id']) && !is_null($vatcleaned))
167 167
 					{
168 168
 						if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++;
169 169
 					}
170 170
 
171 171
 					if ($changerequested)
172 172
 					{
173
-						if (! empty($object->email)) $customer->email = $object->email;
173
+						if (!empty($object->email)) $customer->email = $object->email;
174 174
 						$customer->description = $namecleaned;
175 175
 						if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
176 176
 						else $customer->tax_info = $taxinfo;
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 			}
182 182
 		}
183 183
 		if ($action == 'COMPANY_DELETE') {
184
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
184
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
185 185
 
186
-			$stripeacc = $stripe->getStripeAccount($service);	// No need of network access for this. May return '' if no Oauth defined.
186
+			$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
187 187
 
188 188
 			$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);
189 189
 			if ($customer)
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 			}
193 193
 
194 194
 			$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account";
195
-			$sql.= " WHERE site='stripe' AND fk_soc = " . $object->id;
195
+			$sql .= " WHERE site='stripe' AND fk_soc = ".$object->id;
196 196
 			$this->db->query($sql);
197 197
 		}
198 198
 
@@ -202,12 +202,12 @@  discard block
 block discarded – undo
202 202
 			// For creation of credit card, we do not create in Stripe automatically
203 203
 		}
204 204
 		if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
205
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
205
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
206 206
 
207
-			if (! empty($object->stripe_card_ref))
207
+			if (!empty($object->stripe_card_ref))
208 208
 			{
209
-				$stripeacc = $stripe->getStripeAccount($service);				// No need of network access for this. May return '' if no Oauth defined.
210
-				$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc);	// No need of network access for this
209
+				$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
210
+				$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
211 211
 
212 212
 				if ($stripecu)
213 213
 				{
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 					{
223 223
 						$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
224 224
 						if ($card) {
225
-							$card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
225
+							$card->metadata = array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']));
226 226
 							try {
227 227
 								$card->save($dataforcard);
228 228
 							}
229
-							catch(Exception $e)
229
+							catch (Exception $e)
230 230
 							{
231 231
 								$ok = -1;
232 232
 								$this->error = $e->getMessages();
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 			}
238 238
 		}
239 239
 		if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
240
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
240
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
241 241
 
242
-			if (! empty($object->stripe_card_ref))
242
+			if (!empty($object->stripe_card_ref))
243 243
 			{
244
-				$stripeacc = $stripe->getStripeAccount($service);				// No need of network access for this. May return '' if no Oauth defined.
245
-				$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc);	// No need of network access for this
244
+				$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
245
+				$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
246 246
 
247 247
 				if ($stripecu)
248 248
 				{
Please login to merge, or discard this patch.
Braces   +34 added lines, -15 removed lines patch added patch discarded remove patch
@@ -124,7 +124,9 @@  discard block
 block discarded – undo
124 124
 		require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
125 125
 		$stripe = new Stripe($db);
126 126
 
127
-		if (empty($conf->stripe->enabled)) return 0;
127
+		if (empty($conf->stripe->enabled)) {
128
+		    return 0;
129
+		}
128 130
 
129 131
 		$ok = 1;
130 132
 
@@ -155,25 +157,40 @@  discard block
 block discarded – undo
155 157
 						$taxinfo["tax_id"] = $vatcleaned;
156 158
 					}
157 159
 					// We force data to "null" if not defined as expected by Stripe
158
-					if (empty($vatcleaned)) $taxinfo=null;
160
+					if (empty($vatcleaned)) {
161
+					    $taxinfo=null;
162
+					}
159 163
 
160 164
 					// Detect if we change a Stripe info (email, description, vat id)
161 165
 					$changerequested = 0;
162
-					if (! empty($object->email) && $object->email != $customer->email) $changerequested++;
163
-					if ($namecleaned != $customer->description) $changerequested++;
164
-					if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) $changerequested++;
165
-					elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) $changerequested++;
166
-					elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned))
166
+					if (! empty($object->email) && $object->email != $customer->email) {
167
+					    $changerequested++;
168
+					}
169
+					if ($namecleaned != $customer->description) {
170
+					    $changerequested++;
171
+					}
172
+					if (! isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned)) {
173
+					    $changerequested++;
174
+					} elseif (isset($customer->tax_info['tax_id']) && is_null($vatcleaned)) {
175
+					    $changerequested++;
176
+					} elseif (isset($customer->tax_info['tax_id']) && ! is_null($vatcleaned))
167 177
 					{
168
-						if ($vatcleaned != $customer->tax_info['tax_id']) $changerequested++;
178
+						if ($vatcleaned != $customer->tax_info['tax_id']) {
179
+						    $changerequested++;
180
+						}
169 181
 					}
170 182
 
171 183
 					if ($changerequested)
172 184
 					{
173
-						if (! empty($object->email)) $customer->email = $object->email;
185
+						if (! empty($object->email)) {
186
+						    $customer->email = $object->email;
187
+						}
174 188
 						$customer->description = $namecleaned;
175
-						if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
176
-						else $customer->tax_info = $taxinfo;
189
+						if (empty($taxinfo)) {
190
+						    $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
191
+						} else {
192
+						    $customer->tax_info = $taxinfo;
193
+						}
177 194
 
178 195
 						$customer->save();
179 196
 					}
@@ -225,8 +242,7 @@  discard block
 block discarded – undo
225 242
 							$card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']));
226 243
 							try {
227 244
 								$card->save($dataforcard);
228
-							}
229
-							catch(Exception $e)
245
+							} catch(Exception $e)
230 246
 							{
231 247
 								$ok = -1;
232 248
 								$this->error = $e->getMessages();
@@ -257,8 +273,11 @@  discard block
 block discarded – undo
257 273
 					{
258 274
 						$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
259 275
 						if ($card) {
260
-							if (method_exists($card, 'detach')) $card->detach();
261
-							else $card->delete();
276
+							if (method_exists($card, 'detach')) {
277
+							    $card->detach();
278
+							} else {
279
+							    $card->delete();
280
+							}
262 281
 						}
263 282
 					}
264 283
 				}
Please login to merge, or discard this patch.
htdocs/core/triggers/interface_50_modNotification_Notification.class.php 3 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -30,119 +30,119 @@
 block discarded – undo
30 30
  */
31 31
 class InterfaceNotification extends DolibarrTriggers
32 32
 {
33
-	public $family = 'notification';
34
-	public $description = "Triggers of this module send email notifications according to Notification module setup.";
35
-
36
-	/**
37
-	 * Version of the trigger
38
-	 * @var string
39
-	 */
40
-	public $version = self::VERSION_DOLIBARR;
41
-
42
-	/**
43
-	 * @var string Image of the trigger
44
-	 */
45
-	public $picto = 'email';
46
-
47
-	// @TODO Defined also into notify.class.php)
48
-	public $listofmanagedevents=array(
49
-		'BILL_VALIDATE',
50
-		'BILL_PAYED',
51
-		'ORDER_VALIDATE',
52
-		'PROPAL_VALIDATE',
53
-		'PROPAL_CLOSE_SIGNED',
54
-		'FICHINTER_VALIDATE',
55
-		'FICHINTER_ADD_CONTACT',
56
-		'ORDER_SUPPLIER_VALIDATE',
57
-		'ORDER_SUPPLIER_APPROVE',
58
-		'ORDER_SUPPLIER_REFUSE',
59
-		'SHIPPING_VALIDATE',
60
-		'EXPENSE_REPORT_VALIDATE',
61
-		'EXPENSE_REPORT_APPROVE',
62
-		'HOLIDAY_VALIDATE',
63
-		'HOLIDAY_APPROVE'
64
-	);
65
-
66
-	/**
67
-	 * Function called when a Dolibarrr business event is done.
68
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
69
-	 *
70
-	 * @param string		$action		Event action code
71
-	 * @param Object		$object     Object
72
-	 * @param User		    $user       Object user
73
-	 * @param Translate 	$langs      Object langs
74
-	 * @param conf		    $conf       Object conf
75
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
76
-	 */
77
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
78
-	{
79
-		if (empty($conf->notification->enabled)) return 0;     // Module not active, we do nothing
80
-
81
-		require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
82
-		$notify = new Notify($this->db);
83
-
84
-		if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
85
-
86
-		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
87
-
88
-		$notify->send($action, $object);
89
-
90
-		return 1;
91
-	}
92
-
93
-
94
-	/**
95
-	 * Return list of events managed by notification module
96
-	 *
97
-	 * @return      array       Array of events managed by notification module
98
-	 */
99
-	function getListOfManagedEvents()
100
-	{
101
-		global $conf;
102
-
103
-		$ret=array();
104
-
105
-		$sql = "SELECT rowid, code, label, description, elementtype";
106
-		$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
107
-		$sql.= $this->db->order("rang, elementtype, code");
108
-		dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
109
-		$resql=$this->db->query($sql);
110
-		if ($resql)
111
-		{
112
-			$num=$this->db->num_rows($resql);
113
-			$i=0;
114
-			while ($i < $num)
115
-			{
116
-				$obj=$this->db->fetch_object($resql);
117
-
118
-				$qualified=0;
119
-				// Check is this event is supported by notification module
120
-				if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1;
121
-				// Check if module for this event is active
122
-				if ($qualified)
123
-				{
124
-					//print 'xx'.$obj->code;
125
-					$element=$obj->elementtype;
126
-
127
-					// Exclude events if related module is disabled
128
-					if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
129
-					elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
130
-					elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
131
-					elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
132
-					elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
133
-					elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
134
-				}
135
-
136
-				if ($qualified)
137
-				{
138
-					$ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
139
-				}
140
-
141
-				$i++;
142
-			}
143
-		}
144
-		else dol_print_error($this->db);
145
-
146
-		return $ret;
147
-	}
33
+    public $family = 'notification';
34
+    public $description = "Triggers of this module send email notifications according to Notification module setup.";
35
+
36
+    /**
37
+     * Version of the trigger
38
+     * @var string
39
+     */
40
+    public $version = self::VERSION_DOLIBARR;
41
+
42
+    /**
43
+     * @var string Image of the trigger
44
+     */
45
+    public $picto = 'email';
46
+
47
+    // @TODO Defined also into notify.class.php)
48
+    public $listofmanagedevents=array(
49
+        'BILL_VALIDATE',
50
+        'BILL_PAYED',
51
+        'ORDER_VALIDATE',
52
+        'PROPAL_VALIDATE',
53
+        'PROPAL_CLOSE_SIGNED',
54
+        'FICHINTER_VALIDATE',
55
+        'FICHINTER_ADD_CONTACT',
56
+        'ORDER_SUPPLIER_VALIDATE',
57
+        'ORDER_SUPPLIER_APPROVE',
58
+        'ORDER_SUPPLIER_REFUSE',
59
+        'SHIPPING_VALIDATE',
60
+        'EXPENSE_REPORT_VALIDATE',
61
+        'EXPENSE_REPORT_APPROVE',
62
+        'HOLIDAY_VALIDATE',
63
+        'HOLIDAY_APPROVE'
64
+    );
65
+
66
+    /**
67
+     * Function called when a Dolibarrr business event is done.
68
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
69
+     *
70
+     * @param string		$action		Event action code
71
+     * @param Object		$object     Object
72
+     * @param User		    $user       Object user
73
+     * @param Translate 	$langs      Object langs
74
+     * @param conf		    $conf       Object conf
75
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
76
+     */
77
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
78
+    {
79
+        if (empty($conf->notification->enabled)) return 0;     // Module not active, we do nothing
80
+
81
+        require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
82
+        $notify = new Notify($this->db);
83
+
84
+        if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
85
+
86
+        dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
87
+
88
+        $notify->send($action, $object);
89
+
90
+        return 1;
91
+    }
92
+
93
+
94
+    /**
95
+     * Return list of events managed by notification module
96
+     *
97
+     * @return      array       Array of events managed by notification module
98
+     */
99
+    function getListOfManagedEvents()
100
+    {
101
+        global $conf;
102
+
103
+        $ret=array();
104
+
105
+        $sql = "SELECT rowid, code, label, description, elementtype";
106
+        $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
107
+        $sql.= $this->db->order("rang, elementtype, code");
108
+        dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
109
+        $resql=$this->db->query($sql);
110
+        if ($resql)
111
+        {
112
+            $num=$this->db->num_rows($resql);
113
+            $i=0;
114
+            while ($i < $num)
115
+            {
116
+                $obj=$this->db->fetch_object($resql);
117
+
118
+                $qualified=0;
119
+                // Check is this event is supported by notification module
120
+                if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1;
121
+                // Check if module for this event is active
122
+                if ($qualified)
123
+                {
124
+                    //print 'xx'.$obj->code;
125
+                    $element=$obj->elementtype;
126
+
127
+                    // Exclude events if related module is disabled
128
+                    if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
129
+                    elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
130
+                    elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
131
+                    elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
132
+                    elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
133
+                    elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
134
+                }
135
+
136
+                if ($qualified)
137
+                {
138
+                    $ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
139
+                }
140
+
141
+                $i++;
142
+            }
143
+        }
144
+        else dol_print_error($this->db);
145
+
146
+        return $ret;
147
+    }
148 148
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	public $picto = 'email';
46 46
 
47 47
 	// @TODO Defined also into notify.class.php)
48
-	public $listofmanagedevents=array(
48
+	public $listofmanagedevents = array(
49 49
 		'BILL_VALIDATE',
50 50
 		'BILL_PAYED',
51 51
 		'ORDER_VALIDATE',
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
78 78
 	{
79
-		if (empty($conf->notification->enabled)) return 0;     // Module not active, we do nothing
79
+		if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing
80 80
 
81
-		require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
81
+		require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
82 82
 		$notify = new Notify($this->db);
83 83
 
84
-		if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
84
+		if (!in_array($action, $notify->arrayofnotifsupported)) return 0;
85 85
 
86 86
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
87 87
 
@@ -100,42 +100,42 @@  discard block
 block discarded – undo
100 100
 	{
101 101
 		global $conf;
102 102
 
103
-		$ret=array();
103
+		$ret = array();
104 104
 
105 105
 		$sql = "SELECT rowid, code, label, description, elementtype";
106
-		$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
107
-		$sql.= $this->db->order("rang, elementtype, code");
106
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
107
+		$sql .= $this->db->order("rang, elementtype, code");
108 108
 		dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
109
-		$resql=$this->db->query($sql);
109
+		$resql = $this->db->query($sql);
110 110
 		if ($resql)
111 111
 		{
112
-			$num=$this->db->num_rows($resql);
113
-			$i=0;
112
+			$num = $this->db->num_rows($resql);
113
+			$i = 0;
114 114
 			while ($i < $num)
115 115
 			{
116
-				$obj=$this->db->fetch_object($resql);
116
+				$obj = $this->db->fetch_object($resql);
117 117
 
118
-				$qualified=0;
118
+				$qualified = 0;
119 119
 				// Check is this event is supported by notification module
120
-				if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1;
120
+				if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1;
121 121
 				// Check if module for this event is active
122 122
 				if ($qualified)
123 123
 				{
124 124
 					//print 'xx'.$obj->code;
125
-					$element=$obj->elementtype;
125
+					$element = $obj->elementtype;
126 126
 
127 127
 					// Exclude events if related module is disabled
128
-					if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
129
-					elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
130
-					elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
131
-					elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
132
-					elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
133
-					elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
128
+					if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0;
129
+					elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified = 0;
130
+					elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified = 0;
131
+					elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified = 0;
132
+					elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified = 0;
133
+					elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member', 'expensereport')) && empty($conf->$element->enabled)) $qualified = 0;
134 134
 				}
135 135
 
136 136
 				if ($qualified)
137 137
 				{
138
-					$ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
138
+					$ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype);
139 139
 				}
140 140
 
141 141
 				$i++;
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,12 +76,17 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
78 78
 	{
79
-		if (empty($conf->notification->enabled)) return 0;     // Module not active, we do nothing
79
+		if (empty($conf->notification->enabled)) {
80
+		    return 0;
81
+		}
82
+		// Module not active, we do nothing
80 83
 
81 84
 		require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
82 85
 		$notify = new Notify($this->db);
83 86
 
84
-		if (! in_array($action, $notify->arrayofnotifsupported)) return 0;
87
+		if (! in_array($action, $notify->arrayofnotifsupported)) {
88
+		    return 0;
89
+		}
85 90
 
86 91
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
87 92
 
@@ -117,7 +122,9 @@  discard block
 block discarded – undo
117 122
 
118 123
 				$qualified=0;
119 124
 				// Check is this event is supported by notification module
120
-				if (in_array($obj->code, $this->listofmanagedevents)) $qualified=1;
125
+				if (in_array($obj->code, $this->listofmanagedevents)) {
126
+				    $qualified=1;
127
+				}
121 128
 				// Check if module for this event is active
122 129
 				if ($qualified)
123 130
 				{
@@ -125,12 +132,19 @@  discard block
 block discarded – undo
125 132
 					$element=$obj->elementtype;
126 133
 
127 134
 					// Exclude events if related module is disabled
128
-					if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
129
-					elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
130
-					elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
131
-					elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
132
-					elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
133
-					elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) $qualified=0;
135
+					if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) {
136
+					    $qualified=0;
137
+					} elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) {
138
+					    $qualified=0;
139
+					} elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) {
140
+					    $qualified=0;
141
+					} elseif ($element == 'shipping' && empty($conf->expedition->enabled)) {
142
+					    $qualified=0;
143
+					} elseif ($element == 'member' && empty($conf->adherent->enabled)) {
144
+					    $qualified=0;
145
+					} elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member','expensereport')) && empty($conf->$element->enabled)) {
146
+					    $qualified=0;
147
+					}
134 148
 				}
135 149
 
136 150
 				if ($qualified)
@@ -140,8 +154,9 @@  discard block
 block discarded – undo
140 154
 
141 155
 				$i++;
142 156
 			}
157
+		} else {
158
+		    dol_print_error($this->db);
143 159
 		}
144
-		else dol_print_error($this->db);
145 160
 
146 161
 		return $ret;
147 162
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php 3 patches
Indentation   +771 added lines, -771 removed lines patch added patch discarded remove patch
@@ -31,781 +31,781 @@
 block discarded – undo
31 31
  */
32 32
 class InterfaceLdapsynchro extends DolibarrTriggers
33 33
 {
34
-	public $family = 'ldap';
35
-	public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
36
-
37
-	/**
38
-	 * Version of the trigger
39
-	 * @var string
40
-	 */
41
-	public $version = self::VERSION_DOLIBARR;
42
-
43
-	/**
44
-	 * @var string Image of the trigger
45
-	 */
46
-	public $picto = 'technic';
47
-
48
-	/**
49
-	 * Function called when a Dolibarrr business event is done.
50
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
51
-	 *
52
-	 * @param string		$action		Event action code
53
-	 * @param Object		$object     Object
54
-	 * @param User		    $user       Object user
55
-	 * @param Translate 	$langs      Object langs
56
-	 * @param conf		    $conf       Object conf
57
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
58
-	 */
59
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60
-	{
61
-		if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
-		if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
63
-
64
-		if (! function_exists('ldap_connect'))
65
-		{
66
-			dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
67
-			return 0;
68
-		}
69
-
70
-		require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
71
-		require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
72
-
73
-		$result=0;
74
-
75
-		// Users
76
-		if ($action == 'USER_CREATE')
77
-		{
78
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
79
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
80
-			{
81
-				$ldap=new Ldap();
82
-				$result=$ldap->connect_bind();
83
-
84
-				if ($result > 0)
85
-				{
86
-					$info=$object->_load_ldap_info();
87
-					$dn=$object->_load_ldap_dn($info);
88
-
89
-					$result=$ldap->add($dn,$info,$user);
90
-				}
91
-
92
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
93
-			}
94
-		}
95
-		elseif ($action == 'USER_MODIFY')
96
-		{
97
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
99
-			{
100
-				$ldap=new Ldap();
101
-				$result=$ldap->connect_bind();
102
-
103
-				if ($result > 0)
104
-				{
105
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
106
-					{
107
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
108
-						$object->oldcopy = clone $object;
109
-					}
110
-
111
-					$oldinfo=$object->oldcopy->_load_ldap_info();
112
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
113
-
114
-					// Verify if entry exist
115
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
116
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
117
-					$records=$ldap->search($container,$search);
118
-					if (count($records) && $records['count'] == 0)
119
-					{
120
-						$olddn = '';
121
-					}
122
-
123
-					$info=$object->_load_ldap_info();
124
-					$dn=$object->_load_ldap_dn($info);
125
-					$newrdn=$object->_load_ldap_dn($info,2);
126
-					$newparent=$object->_load_ldap_dn($info,1);
127
-
128
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
129
-				}
130
-
131
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
132
-			}
133
-		}
134
-		elseif ($action == 'USER_NEW_PASSWORD')
135
-		{
136
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
138
-			{
139
-				$ldap=new Ldap();
140
-				$result=$ldap->connect_bind();
141
-
142
-				if ($result > 0)
143
-				{
144
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
145
-					{
146
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
147
-						$object->oldcopy = clone $object;
148
-					}
149
-
150
-					$oldinfo=$object->oldcopy->_load_ldap_info();
151
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
152
-
153
-					// Verify if entry exist
154
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
155
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
156
-					$records=$ldap->search($container,$search);
157
-					if (count($records) && $records['count'] == 0)
158
-					{
159
-						$olddn = '';
160
-					}
161
-
162
-					$info=$object->_load_ldap_info();
163
-					$dn=$object->_load_ldap_dn($info);
164
-
165
-					$result=$ldap->update($dn,$info,$user,$olddn);
166
-				}
167
-
168
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
169
-			}
170
-		}
171
-		elseif ($action == 'USER_ENABLEDISABLE')
172
-		{
173
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
174
-		}
175
-		elseif ($action == 'USER_DELETE')
176
-		{
177
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
179
-			{
180
-				$ldap=new Ldap();
181
-				$result=$ldap->connect_bind();
182
-
183
-				if ($result > 0)
184
-				{
185
-					$info=$object->_load_ldap_info();
186
-					$dn=$object->_load_ldap_dn($info);
187
-
188
-					$result=$ldap->delete($dn);
189
-				}
190
-
191
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
192
-			}
193
-		}
194
-		elseif ($action == 'USER_SETINGROUP')
195
-		{
196
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
198
-			{
199
-				$ldap=new Ldap();
200
-				$result=$ldap->connect_bind();
201
-
202
-				if ($result > 0)
203
-				{
204
-					// Must edit $object->newgroupid
205
-					$usergroup=new UserGroup($this->db);
206
-					if ($object->newgroupid > 0)
207
-					{
208
-						$usergroup->fetch($object->newgroupid);
209
-
210
-						$oldinfo=$usergroup->_load_ldap_info();
211
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
212
-
213
-						// Verify if entry exist
214
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
215
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
216
-						$records=$ldap->search($container,$search);
217
-						if (count($records) && $records['count'] == 0)
218
-						{
219
-							$olddn = '';
220
-						}
221
-
222
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
223
-						$dn=$usergroup->_load_ldap_dn($info);
224
-
225
-						$result=$ldap->update($dn,$info,$user,$olddn);
226
-					}
227
-				}
228
-
229
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
230
-			}
231
-		}
232
-		elseif ($action == 'USER_REMOVEFROMGROUP')
233
-		{
234
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
236
-			{
237
-				$ldap=new Ldap();
238
-				$result=$ldap->connect_bind();
239
-
240
-				if ($result > 0)
241
-				{
242
-					// Must edit $object->newgroupid
243
-					$usergroup=new UserGroup($this->db);
244
-					if ($object->oldgroupid > 0)
245
-					{
246
-						$usergroup->fetch($object->oldgroupid);
247
-
248
-						$oldinfo=$usergroup->_load_ldap_info();
249
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
250
-
251
-						// Verify if entry exist
252
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
253
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
254
-						$records=$ldap->search($container,$search);
255
-						if (count($records) && $records['count'] == 0)
256
-						{
257
-							$olddn = '';
258
-						}
259
-
260
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
261
-						$dn=$usergroup->_load_ldap_dn($info);
262
-
263
-						$result=$ldap->update($dn,$info,$user,$olddn);
264
-					}
265
-				}
266
-
267
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
268
-			}
269
-		}
270
-
271
-		// Groupes
272
-		elseif ($action == 'GROUP_CREATE')
273
-		{
274
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
275
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
276
-			{
277
-				$ldap=new Ldap();
278
-				$result=$ldap->connect_bind();
279
-
280
-				if ($result > 0)
281
-				{
282
-					$info=$object->_load_ldap_info();
283
-					$dn=$object->_load_ldap_dn($info);
284
-
285
-					// Get a gid number for objectclass PosixGroup
286
-					if (in_array('posixGroup',$info['objectclass'])) {
287
-						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
288
-					}
289
-
290
-					$result=$ldap->add($dn,$info,$user);
291
-				}
292
-
293
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
294
-			}
295
-		}
296
-		elseif ($action == 'GROUP_MODIFY')
297
-		{
298
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
300
-			{
301
-				$ldap=new Ldap();
302
-				$result=$ldap->connect_bind();
303
-
304
-				if ($result > 0)
305
-				{
306
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
307
-					{
308
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
309
-						$object->oldcopy = clone $object;
310
-					}
311
-
312
-					$oldinfo=$object->oldcopy->_load_ldap_info();
313
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
314
-
315
-					// Verify if entry exist
316
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
317
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
318
-					$records=$ldap->search($container,$search);
319
-					if (count($records) && $records['count'] == 0)
320
-					{
321
-						$olddn = '';
322
-					}
323
-
324
-					$info=$object->_load_ldap_info();
325
-					$dn=$object->_load_ldap_dn($info);
326
-
327
-					$result=$ldap->update($dn,$info,$user,$olddn);
328
-				}
329
-
330
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
331
-			}
332
-		}
333
-		elseif ($action == 'GROUP_DELETE')
334
-		{
335
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
337
-			{
338
-				$ldap=new Ldap();
339
-				$result=$ldap->connect_bind();
340
-
341
-				if ($result > 0)
342
-				{
343
-					$info=$object->_load_ldap_info();
344
-					$dn=$object->_load_ldap_dn($info);
345
-
346
-					$result=$ldap->delete($dn);
347
-				}
348
-
349
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
350
-			}
351
-		}
352
-
353
-		// Contacts
354
-		elseif ($action == 'CONTACT_CREATE')
355
-		{
356
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
357
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
358
-			{
359
-				$ldap=new Ldap();
360
-				$result=$ldap->connect_bind();
361
-
362
-				if ($result > 0)
363
-				{
364
-					$info=$object->_load_ldap_info();
365
-					$dn=$object->_load_ldap_dn($info);
366
-
367
-					$result=$ldap->add($dn,$info,$user);
368
-				}
369
-
370
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
371
-			}
372
-		}
373
-		elseif ($action == 'CONTACT_MODIFY')
374
-		{
375
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
377
-			{
378
-				$ldap=new Ldap();
379
-				$result=$ldap->connect_bind();
380
-
381
-				if ($result > 0)
382
-				{
383
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
384
-					{
385
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
386
-						$object->oldcopy = clone $object;
387
-					}
388
-
389
-					$oldinfo=$object->oldcopy->_load_ldap_info();
390
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
391
-
392
-					// Verify if entry exist
393
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
394
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
395
-					$records=$ldap->search($container,$search);
396
-					if (count($records) && $records['count'] == 0)
397
-					{
398
-						$olddn = '';
399
-					}
400
-
401
-					$info=$object->_load_ldap_info();
402
-					$dn=$object->_load_ldap_dn($info);
403
-
404
-					$result=$ldap->update($dn,$info,$user,$olddn);
405
-				}
406
-
407
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
408
-			}
409
-		}
410
-		elseif ($action == 'CONTACT_DELETE')
411
-		{
412
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
414
-			{
415
-				$ldap=new Ldap();
416
-				$result=$ldap->connect_bind();
417
-
418
-				if ($result > 0)
419
-				{
420
-					$info=$object->_load_ldap_info();
421
-					$dn=$object->_load_ldap_dn($info);
422
-
423
-					$result=$ldap->delete($dn);
424
-				}
425
-
426
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
427
-			}
428
-		}
429
-
430
-		// Members
431
-		elseif ($action == 'MEMBER_CREATE')
432
-		{
433
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
434
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
435
-			{
436
-				$ldap=new Ldap();
437
-				$result=$ldap->connect_bind();
438
-
439
-				if ($result > 0)
440
-				{
441
-					$info=$object->_load_ldap_info();
442
-					$dn=$object->_load_ldap_dn($info);
443
-
444
-					$result=$ldap->add($dn,$info,$user);
445
-
446
-					// For member type
447
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
448
-					{
449
-						$membertype=new AdherentType($this->db);
450
-						if ($object->typeid > 0)
451
-						{
452
-							$membertype->fetch($object->typeid);
453
-							$membertype->listMembersForMemberType('', 1);
454
-
455
-							$oldinfo=$membertype->_load_ldap_info();
456
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
457
-
458
-							// Verify if entry exist
459
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
460
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
461
-							$records=$ldap->search($container,$search);
462
-							if (count($records) && $records['count'] == 0)
463
-							{
464
-								$olddn = '';
465
-							}
466
-
467
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
468
-							$dn=$membertype->_load_ldap_dn($info);
469
-
470
-							$result=$ldap->update($dn,$info,$user,$olddn);
471
-						}
472
-					}
473
-				}
474
-
475
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
476
-			}
477
-		}
478
-		elseif ($action == 'MEMBER_VALIDATE')
479
-		{
480
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
482
-			{
483
-				// If status field is setup to be synchronized
484
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
485
-				{
486
-					$ldap=new Ldap();
487
-					$result=$ldap->connect_bind();
488
-
489
-					if ($result > 0)
490
-					{
491
-						$info=$object->_load_ldap_info();
492
-						$dn=$object->_load_ldap_dn($info);
493
-						$olddn=$dn;	// We know olddn=dn as we change only status
494
-
495
-						$result=$ldap->update($dn,$info,$user,$olddn);
496
-					}
497
-
498
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
499
-				}
500
-			}
501
-		}
502
-		elseif ($action == 'MEMBER_SUBSCRIPTION')
503
-		{
504
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
506
-			{
507
-				// If subscriptions fields are setup to be synchronized
508
-				if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
509
-					|| $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
510
-					|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE
511
-					|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
512
-					|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
513
-				{
514
-					$ldap=new Ldap();
515
-					$result=$ldap->connect_bind();
516
-
517
-					if ($result > 0)
518
-					{
519
-						$info=$object->_load_ldap_info();
520
-						$dn=$object->_load_ldap_dn($info);
521
-						$olddn=$dn;	// We know olddn=dn as we change only subscriptions
522
-
523
-						$result=$ldap->update($dn,$info,$user,$olddn);
524
-					}
525
-
526
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
527
-				}
528
-			}
529
-		}
530
-		elseif ($action == 'MEMBER_MODIFY')
531
-		{
532
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
534
-			{
535
-				$ldap=new Ldap();
536
-				$result=$ldap->connect_bind();
537
-
538
-				if ($result > 0)
539
-				{
540
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
541
-					{
542
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
543
-						$object->oldcopy = clone $object;
544
-					}
545
-
546
-					$oldinfo=$object->oldcopy->_load_ldap_info();
547
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
548
-
549
-					// Verify if entry exist
550
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
551
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
552
-					$records=$ldap->search($container,$search);
553
-					if (count($records) && $records['count'] == 0)
554
-					{
555
-						$olddn = '';
556
-					}
557
-
558
-					$info=$object->_load_ldap_info();
559
-					$dn=$object->_load_ldap_dn($info);
560
-					$newrdn=$object->_load_ldap_dn($info,2);
561
-					$newparent=$object->_load_ldap_dn($info,1);
562
-
563
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
564
-
565
-					// For member type
566
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
567
-					{
568
-						/*
34
+    public $family = 'ldap';
35
+    public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
36
+
37
+    /**
38
+     * Version of the trigger
39
+     * @var string
40
+     */
41
+    public $version = self::VERSION_DOLIBARR;
42
+
43
+    /**
44
+     * @var string Image of the trigger
45
+     */
46
+    public $picto = 'technic';
47
+
48
+    /**
49
+     * Function called when a Dolibarrr business event is done.
50
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
51
+     *
52
+     * @param string		$action		Event action code
53
+     * @param Object		$object     Object
54
+     * @param User		    $user       Object user
55
+     * @param Translate 	$langs      Object langs
56
+     * @param conf		    $conf       Object conf
57
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
58
+     */
59
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60
+    {
61
+        if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
+        if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
63
+
64
+        if (! function_exists('ldap_connect'))
65
+        {
66
+            dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
67
+            return 0;
68
+        }
69
+
70
+        require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
71
+        require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
72
+
73
+        $result=0;
74
+
75
+        // Users
76
+        if ($action == 'USER_CREATE')
77
+        {
78
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
79
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
80
+            {
81
+                $ldap=new Ldap();
82
+                $result=$ldap->connect_bind();
83
+
84
+                if ($result > 0)
85
+                {
86
+                    $info=$object->_load_ldap_info();
87
+                    $dn=$object->_load_ldap_dn($info);
88
+
89
+                    $result=$ldap->add($dn,$info,$user);
90
+                }
91
+
92
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
93
+            }
94
+        }
95
+        elseif ($action == 'USER_MODIFY')
96
+        {
97
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
99
+            {
100
+                $ldap=new Ldap();
101
+                $result=$ldap->connect_bind();
102
+
103
+                if ($result > 0)
104
+                {
105
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
106
+                    {
107
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
108
+                        $object->oldcopy = clone $object;
109
+                    }
110
+
111
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
112
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
113
+
114
+                    // Verify if entry exist
115
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
116
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
117
+                    $records=$ldap->search($container,$search);
118
+                    if (count($records) && $records['count'] == 0)
119
+                    {
120
+                        $olddn = '';
121
+                    }
122
+
123
+                    $info=$object->_load_ldap_info();
124
+                    $dn=$object->_load_ldap_dn($info);
125
+                    $newrdn=$object->_load_ldap_dn($info,2);
126
+                    $newparent=$object->_load_ldap_dn($info,1);
127
+
128
+                    $result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
129
+                }
130
+
131
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
132
+            }
133
+        }
134
+        elseif ($action == 'USER_NEW_PASSWORD')
135
+        {
136
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
138
+            {
139
+                $ldap=new Ldap();
140
+                $result=$ldap->connect_bind();
141
+
142
+                if ($result > 0)
143
+                {
144
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
145
+                    {
146
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
147
+                        $object->oldcopy = clone $object;
148
+                    }
149
+
150
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
151
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
152
+
153
+                    // Verify if entry exist
154
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
155
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
156
+                    $records=$ldap->search($container,$search);
157
+                    if (count($records) && $records['count'] == 0)
158
+                    {
159
+                        $olddn = '';
160
+                    }
161
+
162
+                    $info=$object->_load_ldap_info();
163
+                    $dn=$object->_load_ldap_dn($info);
164
+
165
+                    $result=$ldap->update($dn,$info,$user,$olddn);
166
+                }
167
+
168
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
169
+            }
170
+        }
171
+        elseif ($action == 'USER_ENABLEDISABLE')
172
+        {
173
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
174
+        }
175
+        elseif ($action == 'USER_DELETE')
176
+        {
177
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
179
+            {
180
+                $ldap=new Ldap();
181
+                $result=$ldap->connect_bind();
182
+
183
+                if ($result > 0)
184
+                {
185
+                    $info=$object->_load_ldap_info();
186
+                    $dn=$object->_load_ldap_dn($info);
187
+
188
+                    $result=$ldap->delete($dn);
189
+                }
190
+
191
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
192
+            }
193
+        }
194
+        elseif ($action == 'USER_SETINGROUP')
195
+        {
196
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
198
+            {
199
+                $ldap=new Ldap();
200
+                $result=$ldap->connect_bind();
201
+
202
+                if ($result > 0)
203
+                {
204
+                    // Must edit $object->newgroupid
205
+                    $usergroup=new UserGroup($this->db);
206
+                    if ($object->newgroupid > 0)
207
+                    {
208
+                        $usergroup->fetch($object->newgroupid);
209
+
210
+                        $oldinfo=$usergroup->_load_ldap_info();
211
+                        $olddn=$usergroup->_load_ldap_dn($oldinfo);
212
+
213
+                        // Verify if entry exist
214
+                        $container=$usergroup->_load_ldap_dn($oldinfo,1);
215
+                        $search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
216
+                        $records=$ldap->search($container,$search);
217
+                        if (count($records) && $records['count'] == 0)
218
+                        {
219
+                            $olddn = '';
220
+                        }
221
+
222
+                        $info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
223
+                        $dn=$usergroup->_load_ldap_dn($info);
224
+
225
+                        $result=$ldap->update($dn,$info,$user,$olddn);
226
+                    }
227
+                }
228
+
229
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
230
+            }
231
+        }
232
+        elseif ($action == 'USER_REMOVEFROMGROUP')
233
+        {
234
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
236
+            {
237
+                $ldap=new Ldap();
238
+                $result=$ldap->connect_bind();
239
+
240
+                if ($result > 0)
241
+                {
242
+                    // Must edit $object->newgroupid
243
+                    $usergroup=new UserGroup($this->db);
244
+                    if ($object->oldgroupid > 0)
245
+                    {
246
+                        $usergroup->fetch($object->oldgroupid);
247
+
248
+                        $oldinfo=$usergroup->_load_ldap_info();
249
+                        $olddn=$usergroup->_load_ldap_dn($oldinfo);
250
+
251
+                        // Verify if entry exist
252
+                        $container=$usergroup->_load_ldap_dn($oldinfo,1);
253
+                        $search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
254
+                        $records=$ldap->search($container,$search);
255
+                        if (count($records) && $records['count'] == 0)
256
+                        {
257
+                            $olddn = '';
258
+                        }
259
+
260
+                        $info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
261
+                        $dn=$usergroup->_load_ldap_dn($info);
262
+
263
+                        $result=$ldap->update($dn,$info,$user,$olddn);
264
+                    }
265
+                }
266
+
267
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
268
+            }
269
+        }
270
+
271
+        // Groupes
272
+        elseif ($action == 'GROUP_CREATE')
273
+        {
274
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
275
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
276
+            {
277
+                $ldap=new Ldap();
278
+                $result=$ldap->connect_bind();
279
+
280
+                if ($result > 0)
281
+                {
282
+                    $info=$object->_load_ldap_info();
283
+                    $dn=$object->_load_ldap_dn($info);
284
+
285
+                    // Get a gid number for objectclass PosixGroup
286
+                    if (in_array('posixGroup',$info['objectclass'])) {
287
+                        $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
288
+                    }
289
+
290
+                    $result=$ldap->add($dn,$info,$user);
291
+                }
292
+
293
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
294
+            }
295
+        }
296
+        elseif ($action == 'GROUP_MODIFY')
297
+        {
298
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
300
+            {
301
+                $ldap=new Ldap();
302
+                $result=$ldap->connect_bind();
303
+
304
+                if ($result > 0)
305
+                {
306
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
307
+                    {
308
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
309
+                        $object->oldcopy = clone $object;
310
+                    }
311
+
312
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
313
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
314
+
315
+                    // Verify if entry exist
316
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
317
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
318
+                    $records=$ldap->search($container,$search);
319
+                    if (count($records) && $records['count'] == 0)
320
+                    {
321
+                        $olddn = '';
322
+                    }
323
+
324
+                    $info=$object->_load_ldap_info();
325
+                    $dn=$object->_load_ldap_dn($info);
326
+
327
+                    $result=$ldap->update($dn,$info,$user,$olddn);
328
+                }
329
+
330
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
331
+            }
332
+        }
333
+        elseif ($action == 'GROUP_DELETE')
334
+        {
335
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
337
+            {
338
+                $ldap=new Ldap();
339
+                $result=$ldap->connect_bind();
340
+
341
+                if ($result > 0)
342
+                {
343
+                    $info=$object->_load_ldap_info();
344
+                    $dn=$object->_load_ldap_dn($info);
345
+
346
+                    $result=$ldap->delete($dn);
347
+                }
348
+
349
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
350
+            }
351
+        }
352
+
353
+        // Contacts
354
+        elseif ($action == 'CONTACT_CREATE')
355
+        {
356
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
357
+            if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
358
+            {
359
+                $ldap=new Ldap();
360
+                $result=$ldap->connect_bind();
361
+
362
+                if ($result > 0)
363
+                {
364
+                    $info=$object->_load_ldap_info();
365
+                    $dn=$object->_load_ldap_dn($info);
366
+
367
+                    $result=$ldap->add($dn,$info,$user);
368
+                }
369
+
370
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
371
+            }
372
+        }
373
+        elseif ($action == 'CONTACT_MODIFY')
374
+        {
375
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376
+            if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
377
+            {
378
+                $ldap=new Ldap();
379
+                $result=$ldap->connect_bind();
380
+
381
+                if ($result > 0)
382
+                {
383
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
384
+                    {
385
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
386
+                        $object->oldcopy = clone $object;
387
+                    }
388
+
389
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
390
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
391
+
392
+                    // Verify if entry exist
393
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
394
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
395
+                    $records=$ldap->search($container,$search);
396
+                    if (count($records) && $records['count'] == 0)
397
+                    {
398
+                        $olddn = '';
399
+                    }
400
+
401
+                    $info=$object->_load_ldap_info();
402
+                    $dn=$object->_load_ldap_dn($info);
403
+
404
+                    $result=$ldap->update($dn,$info,$user,$olddn);
405
+                }
406
+
407
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
408
+            }
409
+        }
410
+        elseif ($action == 'CONTACT_DELETE')
411
+        {
412
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413
+            if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
414
+            {
415
+                $ldap=new Ldap();
416
+                $result=$ldap->connect_bind();
417
+
418
+                if ($result > 0)
419
+                {
420
+                    $info=$object->_load_ldap_info();
421
+                    $dn=$object->_load_ldap_dn($info);
422
+
423
+                    $result=$ldap->delete($dn);
424
+                }
425
+
426
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
427
+            }
428
+        }
429
+
430
+        // Members
431
+        elseif ($action == 'MEMBER_CREATE')
432
+        {
433
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
434
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
435
+            {
436
+                $ldap=new Ldap();
437
+                $result=$ldap->connect_bind();
438
+
439
+                if ($result > 0)
440
+                {
441
+                    $info=$object->_load_ldap_info();
442
+                    $dn=$object->_load_ldap_dn($info);
443
+
444
+                    $result=$ldap->add($dn,$info,$user);
445
+
446
+                    // For member type
447
+                    if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
448
+                    {
449
+                        $membertype=new AdherentType($this->db);
450
+                        if ($object->typeid > 0)
451
+                        {
452
+                            $membertype->fetch($object->typeid);
453
+                            $membertype->listMembersForMemberType('', 1);
454
+
455
+                            $oldinfo=$membertype->_load_ldap_info();
456
+                            $olddn=$membertype->_load_ldap_dn($oldinfo);
457
+
458
+                            // Verify if entry exist
459
+                            $container=$membertype->_load_ldap_dn($oldinfo,1);
460
+                            $search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
461
+                            $records=$ldap->search($container,$search);
462
+                            if (count($records) && $records['count'] == 0)
463
+                            {
464
+                                $olddn = '';
465
+                            }
466
+
467
+                            $info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
468
+                            $dn=$membertype->_load_ldap_dn($info);
469
+
470
+                            $result=$ldap->update($dn,$info,$user,$olddn);
471
+                        }
472
+                    }
473
+                }
474
+
475
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
476
+            }
477
+        }
478
+        elseif ($action == 'MEMBER_VALIDATE')
479
+        {
480
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
482
+            {
483
+                // If status field is setup to be synchronized
484
+                if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
485
+                {
486
+                    $ldap=new Ldap();
487
+                    $result=$ldap->connect_bind();
488
+
489
+                    if ($result > 0)
490
+                    {
491
+                        $info=$object->_load_ldap_info();
492
+                        $dn=$object->_load_ldap_dn($info);
493
+                        $olddn=$dn;	// We know olddn=dn as we change only status
494
+
495
+                        $result=$ldap->update($dn,$info,$user,$olddn);
496
+                    }
497
+
498
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
499
+                }
500
+            }
501
+        }
502
+        elseif ($action == 'MEMBER_SUBSCRIPTION')
503
+        {
504
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
506
+            {
507
+                // If subscriptions fields are setup to be synchronized
508
+                if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
509
+                    || $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
510
+                    || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE
511
+                    || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
512
+                    || $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
513
+                {
514
+                    $ldap=new Ldap();
515
+                    $result=$ldap->connect_bind();
516
+
517
+                    if ($result > 0)
518
+                    {
519
+                        $info=$object->_load_ldap_info();
520
+                        $dn=$object->_load_ldap_dn($info);
521
+                        $olddn=$dn;	// We know olddn=dn as we change only subscriptions
522
+
523
+                        $result=$ldap->update($dn,$info,$user,$olddn);
524
+                    }
525
+
526
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
527
+                }
528
+            }
529
+        }
530
+        elseif ($action == 'MEMBER_MODIFY')
531
+        {
532
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
534
+            {
535
+                $ldap=new Ldap();
536
+                $result=$ldap->connect_bind();
537
+
538
+                if ($result > 0)
539
+                {
540
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
541
+                    {
542
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
543
+                        $object->oldcopy = clone $object;
544
+                    }
545
+
546
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
547
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
548
+
549
+                    // Verify if entry exist
550
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
551
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
552
+                    $records=$ldap->search($container,$search);
553
+                    if (count($records) && $records['count'] == 0)
554
+                    {
555
+                        $olddn = '';
556
+                    }
557
+
558
+                    $info=$object->_load_ldap_info();
559
+                    $dn=$object->_load_ldap_dn($info);
560
+                    $newrdn=$object->_load_ldap_dn($info,2);
561
+                    $newparent=$object->_load_ldap_dn($info,1);
562
+
563
+                    $result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
564
+
565
+                    // For member type
566
+                    if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
567
+                    {
568
+                        /*
569 569
 						 * Change member info
570 570
 						 */
571
-						$newmembertype=new AdherentType($this->db);
572
-						$newmembertype->fetch($object->typeid);
573
-						$newmembertype->listMembersForMemberType('', 1);
574
-
575
-						$oldinfo=$newmembertype->_load_ldap_info();
576
-						$olddn=$newmembertype->_load_ldap_dn($oldinfo);
577
-
578
-						// Verify if entry exist
579
-						$container=$newmembertype->_load_ldap_dn($oldinfo,1);
580
-						$search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
581
-						$records=$ldap->search($container,$search);
582
-						if (count($records) && $records['count'] == 0)
583
-						{
584
-							$olddn = '';
585
-						}
586
-
587
-						$info=$newmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
588
-						$dn=$newmembertype->_load_ldap_dn($info);
589
-
590
-						$result=$ldap->update($dn,$info,$user,$olddn);
591
-
592
-						if ($object->oldcopy->typeid != $object->typeid)
593
-						{
594
-							/*
571
+                        $newmembertype=new AdherentType($this->db);
572
+                        $newmembertype->fetch($object->typeid);
573
+                        $newmembertype->listMembersForMemberType('', 1);
574
+
575
+                        $oldinfo=$newmembertype->_load_ldap_info();
576
+                        $olddn=$newmembertype->_load_ldap_dn($oldinfo);
577
+
578
+                        // Verify if entry exist
579
+                        $container=$newmembertype->_load_ldap_dn($oldinfo,1);
580
+                        $search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
581
+                        $records=$ldap->search($container,$search);
582
+                        if (count($records) && $records['count'] == 0)
583
+                        {
584
+                            $olddn = '';
585
+                        }
586
+
587
+                        $info=$newmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
588
+                        $dn=$newmembertype->_load_ldap_dn($info);
589
+
590
+                        $result=$ldap->update($dn,$info,$user,$olddn);
591
+
592
+                        if ($object->oldcopy->typeid != $object->typeid)
593
+                        {
594
+                            /*
595 595
 							 * Remove member in old member type
596 596
 							 */
597
-							$oldmembertype=new AdherentType($this->db);
598
-							$oldmembertype->fetch($object->oldcopy->typeid);
599
-							$oldmembertype->listMembersForMemberType('', 1);
600
-
601
-							$oldinfo=$oldmembertype->_load_ldap_info();
602
-							$olddn=$oldmembertype->_load_ldap_dn($oldinfo);
603
-
604
-							// Verify if entry exist
605
-							$container=$oldmembertype->_load_ldap_dn($oldinfo,1);
606
-							$search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
607
-							$records=$ldap->search($container,$search);
608
-							if (count($records) && $records['count'] == 0)
609
-							{
610
-								$olddn = '';
611
-							}
612
-
613
-							$info=$oldmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
614
-							$dn=$oldmembertype->_load_ldap_dn($info);
615
-
616
-							$result=$ldap->update($dn,$info,$user,$olddn);
617
-						}
618
-					}
619
-				}
620
-
621
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
622
-			}
623
-		}
624
-		elseif ($action == 'MEMBER_NEW_PASSWORD')
625
-		{
626
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
628
-			{
629
-				// If password field is setup to be synchronized
630
-				if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
631
-				{
632
-					$ldap=new Ldap();
633
-					$result=$ldap->connect_bind();
634
-
635
-					if ($result > 0)
636
-					{
637
-						$info=$object->_load_ldap_info();
638
-						$dn=$object->_load_ldap_dn($info);
639
-						$olddn=$dn;	// We know olddn=dn as we change only password
640
-
641
-						$result=$ldap->update($dn,$info,$user,$olddn);
642
-					}
643
-
644
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
645
-				}
646
-			}
647
-		}
648
-		elseif ($action == 'MEMBER_RESILIATE')
649
-		{
650
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
652
-			{
653
-				// If status field is setup to be synchronized
654
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
655
-				{
656
-					$ldap=new Ldap();
657
-					$result=$ldap->connect_bind();
658
-
659
-					if ($result > 0)
660
-					{
661
-						$info=$object->_load_ldap_info();
662
-						$dn=$object->_load_ldap_dn($info);
663
-						$olddn=$dn;	// We know olddn=dn as we change only status
664
-
665
-						$result=$ldap->update($dn,$info,$user,$olddn);
666
-					}
667
-
668
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
669
-				}
670
-			}
671
-		}
672
-		elseif ($action == 'MEMBER_DELETE')
673
-		{
674
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
676
-			{
677
-				$ldap=new Ldap();
678
-				$result=$ldap->connect_bind();
679
-
680
-				if ($result > 0)
681
-				{
682
-					$info=$object->_load_ldap_info();
683
-					$dn=$object->_load_ldap_dn($info);
684
-
685
-					$result=$ldap->delete($dn);
686
-
687
-					// For member type
688
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
689
-					{
690
-						if ($object->typeid > 0)
691
-						{
692
-							/*
597
+                            $oldmembertype=new AdherentType($this->db);
598
+                            $oldmembertype->fetch($object->oldcopy->typeid);
599
+                            $oldmembertype->listMembersForMemberType('', 1);
600
+
601
+                            $oldinfo=$oldmembertype->_load_ldap_info();
602
+                            $olddn=$oldmembertype->_load_ldap_dn($oldinfo);
603
+
604
+                            // Verify if entry exist
605
+                            $container=$oldmembertype->_load_ldap_dn($oldinfo,1);
606
+                            $search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
607
+                            $records=$ldap->search($container,$search);
608
+                            if (count($records) && $records['count'] == 0)
609
+                            {
610
+                                $olddn = '';
611
+                            }
612
+
613
+                            $info=$oldmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
614
+                            $dn=$oldmembertype->_load_ldap_dn($info);
615
+
616
+                            $result=$ldap->update($dn,$info,$user,$olddn);
617
+                        }
618
+                    }
619
+                }
620
+
621
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
622
+            }
623
+        }
624
+        elseif ($action == 'MEMBER_NEW_PASSWORD')
625
+        {
626
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
628
+            {
629
+                // If password field is setup to be synchronized
630
+                if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
631
+                {
632
+                    $ldap=new Ldap();
633
+                    $result=$ldap->connect_bind();
634
+
635
+                    if ($result > 0)
636
+                    {
637
+                        $info=$object->_load_ldap_info();
638
+                        $dn=$object->_load_ldap_dn($info);
639
+                        $olddn=$dn;	// We know olddn=dn as we change only password
640
+
641
+                        $result=$ldap->update($dn,$info,$user,$olddn);
642
+                    }
643
+
644
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
645
+                }
646
+            }
647
+        }
648
+        elseif ($action == 'MEMBER_RESILIATE')
649
+        {
650
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
652
+            {
653
+                // If status field is setup to be synchronized
654
+                if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
655
+                {
656
+                    $ldap=new Ldap();
657
+                    $result=$ldap->connect_bind();
658
+
659
+                    if ($result > 0)
660
+                    {
661
+                        $info=$object->_load_ldap_info();
662
+                        $dn=$object->_load_ldap_dn($info);
663
+                        $olddn=$dn;	// We know olddn=dn as we change only status
664
+
665
+                        $result=$ldap->update($dn,$info,$user,$olddn);
666
+                    }
667
+
668
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
669
+                }
670
+            }
671
+        }
672
+        elseif ($action == 'MEMBER_DELETE')
673
+        {
674
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
676
+            {
677
+                $ldap=new Ldap();
678
+                $result=$ldap->connect_bind();
679
+
680
+                if ($result > 0)
681
+                {
682
+                    $info=$object->_load_ldap_info();
683
+                    $dn=$object->_load_ldap_dn($info);
684
+
685
+                    $result=$ldap->delete($dn);
686
+
687
+                    // For member type
688
+                    if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
689
+                    {
690
+                        if ($object->typeid > 0)
691
+                        {
692
+                            /*
693 693
 							 * Remove member in member type
694 694
 							 */
695
-							$membertype=new AdherentType($this->db);
696
-							$membertype->fetch($object->typeid);
697
-							$membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list
698
-
699
-							$oldinfo=$membertype->_load_ldap_info();
700
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
701
-
702
-							// Verify if entry exist
703
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
704
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
705
-							$records=$ldap->search($container,$search);
706
-							if (count($records) && $records['count'] == 0)
707
-							{
708
-								$olddn = '';
709
-							}
710
-
711
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
712
-							$dn=$membertype->_load_ldap_dn($info);
713
-
714
-							$result=$ldap->update($dn,$info,$user,$olddn);
715
-						}
716
-					}
717
-				}
718
-
719
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
720
-			}
721
-		}
722
-
723
-		// Members types
724
-		elseif ($action == 'MEMBER_TYPE_CREATE')
725
-		{
726
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
727
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
728
-			{
729
-				$ldap=new Ldap();
730
-				$result=$ldap->connect_bind();
731
-
732
-				if ($result > 0)
733
-				{
734
-					$info=$object->_load_ldap_info();
735
-					$dn=$object->_load_ldap_dn($info);
736
-
737
-					// Get a gid number for objectclass PosixGroup
738
-					if (in_array('posixGroup',$info['objectclass'])) {
739
-						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
740
-					}
741
-
742
-					$result=$ldap->add($dn,$info,$user);
743
-				}
744
-
745
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
746
-			}
747
-		}
748
-		elseif ($action == 'MEMBER_TYPE_MODIFY')
749
-		{
750
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
752
-			{
753
-				$ldap=new Ldap();
754
-				$result=$ldap->connect_bind();
755
-
756
-				if ($result > 0)
757
-				{
758
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
759
-					{
760
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
761
-						$object->oldcopy = clone $object;
762
-					}
763
-
764
-					$object->oldcopy->listMembersForMemberType('', 1);
765
-
766
-					$oldinfo=$object->oldcopy->_load_ldap_info();
767
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
768
-
769
-					// Verify if entry exist
770
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
771
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
772
-					$records=$ldap->search($container,$search);
773
-					if (count($records) && $records['count'] == 0)
774
-					{
775
-						$olddn = '';
776
-					}
777
-
778
-					$object->listMembersForMemberType('', 1);
779
-
780
-					$info=$object->_load_ldap_info();
781
-					$dn=$object->_load_ldap_dn($info);
782
-
783
-					$result=$ldap->update($dn,$info,$user,$olddn);
784
-				}
785
-
786
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
787
-			}
788
-		}
789
-		elseif ($action == 'MEMBER_TYPE_DELETE')
790
-		{
791
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
793
-			{
794
-				$ldap=new Ldap();
795
-				$result=$ldap->connect_bind();
796
-
797
-				if ($result > 0)
798
-				{
799
-					$info=$object->_load_ldap_info();
800
-					$dn=$object->_load_ldap_dn($info);
801
-
802
-					$result=$ldap->delete($dn);
803
-				}
804
-
805
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
806
-			}
807
-		}
808
-
809
-		return $result;
810
-	}
695
+                            $membertype=new AdherentType($this->db);
696
+                            $membertype->fetch($object->typeid);
697
+                            $membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list
698
+
699
+                            $oldinfo=$membertype->_load_ldap_info();
700
+                            $olddn=$membertype->_load_ldap_dn($oldinfo);
701
+
702
+                            // Verify if entry exist
703
+                            $container=$membertype->_load_ldap_dn($oldinfo,1);
704
+                            $search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
705
+                            $records=$ldap->search($container,$search);
706
+                            if (count($records) && $records['count'] == 0)
707
+                            {
708
+                                $olddn = '';
709
+                            }
710
+
711
+                            $info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
712
+                            $dn=$membertype->_load_ldap_dn($info);
713
+
714
+                            $result=$ldap->update($dn,$info,$user,$olddn);
715
+                        }
716
+                    }
717
+                }
718
+
719
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
720
+            }
721
+        }
722
+
723
+        // Members types
724
+        elseif ($action == 'MEMBER_TYPE_CREATE')
725
+        {
726
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
727
+            if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
728
+            {
729
+                $ldap=new Ldap();
730
+                $result=$ldap->connect_bind();
731
+
732
+                if ($result > 0)
733
+                {
734
+                    $info=$object->_load_ldap_info();
735
+                    $dn=$object->_load_ldap_dn($info);
736
+
737
+                    // Get a gid number for objectclass PosixGroup
738
+                    if (in_array('posixGroup',$info['objectclass'])) {
739
+                        $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
740
+                    }
741
+
742
+                    $result=$ldap->add($dn,$info,$user);
743
+                }
744
+
745
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
746
+            }
747
+        }
748
+        elseif ($action == 'MEMBER_TYPE_MODIFY')
749
+        {
750
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751
+            if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
752
+            {
753
+                $ldap=new Ldap();
754
+                $result=$ldap->connect_bind();
755
+
756
+                if ($result > 0)
757
+                {
758
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
759
+                    {
760
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
761
+                        $object->oldcopy = clone $object;
762
+                    }
763
+
764
+                    $object->oldcopy->listMembersForMemberType('', 1);
765
+
766
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
767
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
768
+
769
+                    // Verify if entry exist
770
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
771
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
772
+                    $records=$ldap->search($container,$search);
773
+                    if (count($records) && $records['count'] == 0)
774
+                    {
775
+                        $olddn = '';
776
+                    }
777
+
778
+                    $object->listMembersForMemberType('', 1);
779
+
780
+                    $info=$object->_load_ldap_info();
781
+                    $dn=$object->_load_ldap_dn($info);
782
+
783
+                    $result=$ldap->update($dn,$info,$user,$olddn);
784
+                }
785
+
786
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
787
+            }
788
+        }
789
+        elseif ($action == 'MEMBER_TYPE_DELETE')
790
+        {
791
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792
+            if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
793
+            {
794
+                $ldap=new Ldap();
795
+                $result=$ldap->connect_bind();
796
+
797
+                if ($result > 0)
798
+                {
799
+                    $info=$object->_load_ldap_info();
800
+                    $dn=$object->_load_ldap_dn($info);
801
+
802
+                    $result=$ldap->delete($dn);
803
+                }
804
+
805
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
806
+            }
807
+        }
808
+
809
+        return $result;
810
+    }
811 811
 }
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60 60
 	{
61
-		if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
-		if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
61
+		if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing
62
+		if (defined('DISABLE_LDAP_SYNCHRO')) return 0; // If constant defined, we do nothing
63 63
 
64
-		if (! function_exists('ldap_connect'))
64
+		if (!function_exists('ldap_connect'))
65 65
 		{
66 66
 			dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
67 67
 			return 0;
@@ -70,102 +70,102 @@  discard block
 block discarded – undo
70 70
 		require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
71 71
 		require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
72 72
 
73
-		$result=0;
73
+		$result = 0;
74 74
 
75 75
 		// Users
76 76
 		if ($action == 'USER_CREATE')
77 77
 		{
78 78
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
79
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
79
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
80 80
 			{
81
-				$ldap=new Ldap();
82
-				$result=$ldap->connect_bind();
81
+				$ldap = new Ldap();
82
+				$result = $ldap->connect_bind();
83 83
 
84 84
 				if ($result > 0)
85 85
 				{
86
-					$info=$object->_load_ldap_info();
87
-					$dn=$object->_load_ldap_dn($info);
86
+					$info = $object->_load_ldap_info();
87
+					$dn = $object->_load_ldap_dn($info);
88 88
 
89
-					$result=$ldap->add($dn,$info,$user);
89
+					$result = $ldap->add($dn, $info, $user);
90 90
 				}
91 91
 
92
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
92
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
93 93
 			}
94 94
 		}
95 95
 		elseif ($action == 'USER_MODIFY')
96 96
 		{
97 97
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
98
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
99 99
 			{
100
-				$ldap=new Ldap();
101
-				$result=$ldap->connect_bind();
100
+				$ldap = new Ldap();
101
+				$result = $ldap->connect_bind();
102 102
 
103 103
 				if ($result > 0)
104 104
 				{
105
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
105
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
106 106
 					{
107 107
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
108 108
 						$object->oldcopy = clone $object;
109 109
 					}
110 110
 
111
-					$oldinfo=$object->oldcopy->_load_ldap_info();
112
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
111
+					$oldinfo = $object->oldcopy->_load_ldap_info();
112
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
113 113
 
114 114
 					// Verify if entry exist
115
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
116
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
117
-					$records=$ldap->search($container,$search);
115
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
116
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
117
+					$records = $ldap->search($container, $search);
118 118
 					if (count($records) && $records['count'] == 0)
119 119
 					{
120 120
 						$olddn = '';
121 121
 					}
122 122
 
123
-					$info=$object->_load_ldap_info();
124
-					$dn=$object->_load_ldap_dn($info);
125
-					$newrdn=$object->_load_ldap_dn($info,2);
126
-					$newparent=$object->_load_ldap_dn($info,1);
123
+					$info = $object->_load_ldap_info();
124
+					$dn = $object->_load_ldap_dn($info);
125
+					$newrdn = $object->_load_ldap_dn($info, 2);
126
+					$newparent = $object->_load_ldap_dn($info, 1);
127 127
 
128
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
128
+					$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
129 129
 				}
130 130
 
131
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
131
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
132 132
 			}
133 133
 		}
134 134
 		elseif ($action == 'USER_NEW_PASSWORD')
135 135
 		{
136 136
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
137
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
138 138
 			{
139
-				$ldap=new Ldap();
140
-				$result=$ldap->connect_bind();
139
+				$ldap = new Ldap();
140
+				$result = $ldap->connect_bind();
141 141
 
142 142
 				if ($result > 0)
143 143
 				{
144
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
144
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
145 145
 					{
146 146
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
147 147
 						$object->oldcopy = clone $object;
148 148
 					}
149 149
 
150
-					$oldinfo=$object->oldcopy->_load_ldap_info();
151
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
150
+					$oldinfo = $object->oldcopy->_load_ldap_info();
151
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
152 152
 
153 153
 					// Verify if entry exist
154
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
155
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
156
-					$records=$ldap->search($container,$search);
154
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
155
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
156
+					$records = $ldap->search($container, $search);
157 157
 					if (count($records) && $records['count'] == 0)
158 158
 					{
159 159
 						$olddn = '';
160 160
 					}
161 161
 
162
-					$info=$object->_load_ldap_info();
163
-					$dn=$object->_load_ldap_dn($info);
162
+					$info = $object->_load_ldap_info();
163
+					$dn = $object->_load_ldap_dn($info);
164 164
 
165
-					$result=$ldap->update($dn,$info,$user,$olddn);
165
+					$result = $ldap->update($dn, $info, $user, $olddn);
166 166
 				}
167 167
 
168
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
168
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
169 169
 			}
170 170
 		}
171 171
 		elseif ($action == 'USER_ENABLEDISABLE')
@@ -175,96 +175,96 @@  discard block
 block discarded – undo
175 175
 		elseif ($action == 'USER_DELETE')
176 176
 		{
177 177
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
178
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
179 179
 			{
180
-				$ldap=new Ldap();
181
-				$result=$ldap->connect_bind();
180
+				$ldap = new Ldap();
181
+				$result = $ldap->connect_bind();
182 182
 
183 183
 				if ($result > 0)
184 184
 				{
185
-					$info=$object->_load_ldap_info();
186
-					$dn=$object->_load_ldap_dn($info);
185
+					$info = $object->_load_ldap_info();
186
+					$dn = $object->_load_ldap_dn($info);
187 187
 
188
-					$result=$ldap->delete($dn);
188
+					$result = $ldap->delete($dn);
189 189
 				}
190 190
 
191
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
191
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
192 192
 			}
193 193
 		}
194 194
 		elseif ($action == 'USER_SETINGROUP')
195 195
 		{
196 196
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
197
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
198 198
 			{
199
-				$ldap=new Ldap();
200
-				$result=$ldap->connect_bind();
199
+				$ldap = new Ldap();
200
+				$result = $ldap->connect_bind();
201 201
 
202 202
 				if ($result > 0)
203 203
 				{
204 204
 					// Must edit $object->newgroupid
205
-					$usergroup=new UserGroup($this->db);
205
+					$usergroup = new UserGroup($this->db);
206 206
 					if ($object->newgroupid > 0)
207 207
 					{
208 208
 						$usergroup->fetch($object->newgroupid);
209 209
 
210
-						$oldinfo=$usergroup->_load_ldap_info();
211
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
210
+						$oldinfo = $usergroup->_load_ldap_info();
211
+						$olddn = $usergroup->_load_ldap_dn($oldinfo);
212 212
 
213 213
 						// Verify if entry exist
214
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
215
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
216
-						$records=$ldap->search($container,$search);
214
+						$container = $usergroup->_load_ldap_dn($oldinfo, 1);
215
+						$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
216
+						$records = $ldap->search($container, $search);
217 217
 						if (count($records) && $records['count'] == 0)
218 218
 						{
219 219
 							$olddn = '';
220 220
 						}
221 221
 
222
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
223
-						$dn=$usergroup->_load_ldap_dn($info);
222
+						$info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
223
+						$dn = $usergroup->_load_ldap_dn($info);
224 224
 
225
-						$result=$ldap->update($dn,$info,$user,$olddn);
225
+						$result = $ldap->update($dn, $info, $user, $olddn);
226 226
 					}
227 227
 				}
228 228
 
229
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
229
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
230 230
 			}
231 231
 		}
232 232
 		elseif ($action == 'USER_REMOVEFROMGROUP')
233 233
 		{
234 234
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
235
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
236 236
 			{
237
-				$ldap=new Ldap();
238
-				$result=$ldap->connect_bind();
237
+				$ldap = new Ldap();
238
+				$result = $ldap->connect_bind();
239 239
 
240 240
 				if ($result > 0)
241 241
 				{
242 242
 					// Must edit $object->newgroupid
243
-					$usergroup=new UserGroup($this->db);
243
+					$usergroup = new UserGroup($this->db);
244 244
 					if ($object->oldgroupid > 0)
245 245
 					{
246 246
 						$usergroup->fetch($object->oldgroupid);
247 247
 
248
-						$oldinfo=$usergroup->_load_ldap_info();
249
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
248
+						$oldinfo = $usergroup->_load_ldap_info();
249
+						$olddn = $usergroup->_load_ldap_dn($oldinfo);
250 250
 
251 251
 						// Verify if entry exist
252
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
253
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
254
-						$records=$ldap->search($container,$search);
252
+						$container = $usergroup->_load_ldap_dn($oldinfo, 1);
253
+						$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
254
+						$records = $ldap->search($container, $search);
255 255
 						if (count($records) && $records['count'] == 0)
256 256
 						{
257 257
 							$olddn = '';
258 258
 						}
259 259
 
260
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
261
-						$dn=$usergroup->_load_ldap_dn($info);
260
+						$info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
261
+						$dn = $usergroup->_load_ldap_dn($info);
262 262
 
263
-						$result=$ldap->update($dn,$info,$user,$olddn);
263
+						$result = $ldap->update($dn, $info, $user, $olddn);
264 264
 					}
265 265
 				}
266 266
 
267
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
267
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
268 268
 			}
269 269
 		}
270 270
 
@@ -272,81 +272,81 @@  discard block
 block discarded – undo
272 272
 		elseif ($action == 'GROUP_CREATE')
273 273
 		{
274 274
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
275
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
275
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
276 276
 			{
277
-				$ldap=new Ldap();
278
-				$result=$ldap->connect_bind();
277
+				$ldap = new Ldap();
278
+				$result = $ldap->connect_bind();
279 279
 
280 280
 				if ($result > 0)
281 281
 				{
282
-					$info=$object->_load_ldap_info();
283
-					$dn=$object->_load_ldap_dn($info);
282
+					$info = $object->_load_ldap_info();
283
+					$dn = $object->_load_ldap_dn($info);
284 284
 
285 285
 					// Get a gid number for objectclass PosixGroup
286
-					if (in_array('posixGroup',$info['objectclass'])) {
286
+					if (in_array('posixGroup', $info['objectclass'])) {
287 287
 						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
288 288
 					}
289 289
 
290
-					$result=$ldap->add($dn,$info,$user);
290
+					$result = $ldap->add($dn, $info, $user);
291 291
 				}
292 292
 
293
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
293
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
294 294
 			}
295 295
 		}
296 296
 		elseif ($action == 'GROUP_MODIFY')
297 297
 		{
298 298
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
299
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
300 300
 			{
301
-				$ldap=new Ldap();
302
-				$result=$ldap->connect_bind();
301
+				$ldap = new Ldap();
302
+				$result = $ldap->connect_bind();
303 303
 
304 304
 				if ($result > 0)
305 305
 				{
306
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
306
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
307 307
 					{
308 308
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
309 309
 						$object->oldcopy = clone $object;
310 310
 					}
311 311
 
312
-					$oldinfo=$object->oldcopy->_load_ldap_info();
313
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
312
+					$oldinfo = $object->oldcopy->_load_ldap_info();
313
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
314 314
 
315 315
 					// Verify if entry exist
316
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
317
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
318
-					$records=$ldap->search($container,$search);
316
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
317
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
318
+					$records = $ldap->search($container, $search);
319 319
 					if (count($records) && $records['count'] == 0)
320 320
 					{
321 321
 						$olddn = '';
322 322
 					}
323 323
 
324
-					$info=$object->_load_ldap_info();
325
-					$dn=$object->_load_ldap_dn($info);
324
+					$info = $object->_load_ldap_info();
325
+					$dn = $object->_load_ldap_dn($info);
326 326
 
327
-					$result=$ldap->update($dn,$info,$user,$olddn);
327
+					$result = $ldap->update($dn, $info, $user, $olddn);
328 328
 				}
329 329
 
330
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
330
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
331 331
 			}
332 332
 		}
333 333
 		elseif ($action == 'GROUP_DELETE')
334 334
 		{
335 335
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
336
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
337 337
 			{
338
-				$ldap=new Ldap();
339
-				$result=$ldap->connect_bind();
338
+				$ldap = new Ldap();
339
+				$result = $ldap->connect_bind();
340 340
 
341 341
 				if ($result > 0)
342 342
 				{
343
-					$info=$object->_load_ldap_info();
344
-					$dn=$object->_load_ldap_dn($info);
343
+					$info = $object->_load_ldap_info();
344
+					$dn = $object->_load_ldap_dn($info);
345 345
 
346
-					$result=$ldap->delete($dn);
346
+					$result = $ldap->delete($dn);
347 347
 				}
348 348
 
349
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
349
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
350 350
 			}
351 351
 		}
352 352
 
@@ -354,76 +354,76 @@  discard block
 block discarded – undo
354 354
 		elseif ($action == 'CONTACT_CREATE')
355 355
 		{
356 356
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
357
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
357
+			if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
358 358
 			{
359
-				$ldap=new Ldap();
360
-				$result=$ldap->connect_bind();
359
+				$ldap = new Ldap();
360
+				$result = $ldap->connect_bind();
361 361
 
362 362
 				if ($result > 0)
363 363
 				{
364
-					$info=$object->_load_ldap_info();
365
-					$dn=$object->_load_ldap_dn($info);
364
+					$info = $object->_load_ldap_info();
365
+					$dn = $object->_load_ldap_dn($info);
366 366
 
367
-					$result=$ldap->add($dn,$info,$user);
367
+					$result = $ldap->add($dn, $info, $user);
368 368
 				}
369 369
 
370
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
370
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
371 371
 			}
372 372
 		}
373 373
 		elseif ($action == 'CONTACT_MODIFY')
374 374
 		{
375 375
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
376
+			if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
377 377
 			{
378
-				$ldap=new Ldap();
379
-				$result=$ldap->connect_bind();
378
+				$ldap = new Ldap();
379
+				$result = $ldap->connect_bind();
380 380
 
381 381
 				if ($result > 0)
382 382
 				{
383
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
383
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
384 384
 					{
385 385
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
386 386
 						$object->oldcopy = clone $object;
387 387
 					}
388 388
 
389
-					$oldinfo=$object->oldcopy->_load_ldap_info();
390
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
389
+					$oldinfo = $object->oldcopy->_load_ldap_info();
390
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
391 391
 
392 392
 					// Verify if entry exist
393
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
394
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
395
-					$records=$ldap->search($container,$search);
393
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
394
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
395
+					$records = $ldap->search($container, $search);
396 396
 					if (count($records) && $records['count'] == 0)
397 397
 					{
398 398
 						$olddn = '';
399 399
 					}
400 400
 
401
-					$info=$object->_load_ldap_info();
402
-					$dn=$object->_load_ldap_dn($info);
401
+					$info = $object->_load_ldap_info();
402
+					$dn = $object->_load_ldap_dn($info);
403 403
 
404
-					$result=$ldap->update($dn,$info,$user,$olddn);
404
+					$result = $ldap->update($dn, $info, $user, $olddn);
405 405
 				}
406 406
 
407
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
407
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
408 408
 			}
409 409
 		}
410 410
 		elseif ($action == 'CONTACT_DELETE')
411 411
 		{
412 412
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
413
+			if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
414 414
 			{
415
-				$ldap=new Ldap();
416
-				$result=$ldap->connect_bind();
415
+				$ldap = new Ldap();
416
+				$result = $ldap->connect_bind();
417 417
 
418 418
 				if ($result > 0)
419 419
 				{
420
-					$info=$object->_load_ldap_info();
421
-					$dn=$object->_load_ldap_dn($info);
420
+					$info = $object->_load_ldap_info();
421
+					$dn = $object->_load_ldap_dn($info);
422 422
 
423
-					$result=$ldap->delete($dn);
423
+					$result = $ldap->delete($dn);
424 424
 				}
425 425
 
426
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
426
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
427 427
 			}
428 428
 		}
429 429
 
@@ -431,78 +431,78 @@  discard block
 block discarded – undo
431 431
 		elseif ($action == 'MEMBER_CREATE')
432 432
 		{
433 433
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
434
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
434
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
435 435
 			{
436
-				$ldap=new Ldap();
437
-				$result=$ldap->connect_bind();
436
+				$ldap = new Ldap();
437
+				$result = $ldap->connect_bind();
438 438
 
439 439
 				if ($result > 0)
440 440
 				{
441
-					$info=$object->_load_ldap_info();
442
-					$dn=$object->_load_ldap_dn($info);
441
+					$info = $object->_load_ldap_info();
442
+					$dn = $object->_load_ldap_dn($info);
443 443
 
444
-					$result=$ldap->add($dn,$info,$user);
444
+					$result = $ldap->add($dn, $info, $user);
445 445
 
446 446
 					// For member type
447
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
447
+					if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
448 448
 					{
449
-						$membertype=new AdherentType($this->db);
449
+						$membertype = new AdherentType($this->db);
450 450
 						if ($object->typeid > 0)
451 451
 						{
452 452
 							$membertype->fetch($object->typeid);
453 453
 							$membertype->listMembersForMemberType('', 1);
454 454
 
455
-							$oldinfo=$membertype->_load_ldap_info();
456
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
455
+							$oldinfo = $membertype->_load_ldap_info();
456
+							$olddn = $membertype->_load_ldap_dn($oldinfo);
457 457
 
458 458
 							// Verify if entry exist
459
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
460
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
461
-							$records=$ldap->search($container,$search);
459
+							$container = $membertype->_load_ldap_dn($oldinfo, 1);
460
+							$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
461
+							$records = $ldap->search($container, $search);
462 462
 							if (count($records) && $records['count'] == 0)
463 463
 							{
464 464
 								$olddn = '';
465 465
 							}
466 466
 
467
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
468
-							$dn=$membertype->_load_ldap_dn($info);
467
+							$info = $membertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
468
+							$dn = $membertype->_load_ldap_dn($info);
469 469
 
470
-							$result=$ldap->update($dn,$info,$user,$olddn);
470
+							$result = $ldap->update($dn, $info, $user, $olddn);
471 471
 						}
472 472
 					}
473 473
 				}
474 474
 
475
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
475
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
476 476
 			}
477 477
 		}
478 478
 		elseif ($action == 'MEMBER_VALIDATE')
479 479
 		{
480 480
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
481
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
482 482
 			{
483 483
 				// If status field is setup to be synchronized
484
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
484
+				if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
485 485
 				{
486
-					$ldap=new Ldap();
487
-					$result=$ldap->connect_bind();
486
+					$ldap = new Ldap();
487
+					$result = $ldap->connect_bind();
488 488
 
489 489
 					if ($result > 0)
490 490
 					{
491
-						$info=$object->_load_ldap_info();
492
-						$dn=$object->_load_ldap_dn($info);
493
-						$olddn=$dn;	// We know olddn=dn as we change only status
491
+						$info = $object->_load_ldap_info();
492
+						$dn = $object->_load_ldap_dn($info);
493
+						$olddn = $dn; // We know olddn=dn as we change only status
494 494
 
495
-						$result=$ldap->update($dn,$info,$user,$olddn);
495
+						$result = $ldap->update($dn, $info, $user, $olddn);
496 496
 					}
497 497
 
498
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
498
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
499 499
 				}
500 500
 			}
501 501
 		}
502 502
 		elseif ($action == 'MEMBER_SUBSCRIPTION')
503 503
 		{
504 504
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
505
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
506 506
 			{
507 507
 				// If subscriptions fields are setup to be synchronized
508 508
 				if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
@@ -511,212 +511,212 @@  discard block
 block discarded – undo
511 511
 					|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
512 512
 					|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
513 513
 				{
514
-					$ldap=new Ldap();
515
-					$result=$ldap->connect_bind();
514
+					$ldap = new Ldap();
515
+					$result = $ldap->connect_bind();
516 516
 
517 517
 					if ($result > 0)
518 518
 					{
519
-						$info=$object->_load_ldap_info();
520
-						$dn=$object->_load_ldap_dn($info);
521
-						$olddn=$dn;	// We know olddn=dn as we change only subscriptions
519
+						$info = $object->_load_ldap_info();
520
+						$dn = $object->_load_ldap_dn($info);
521
+						$olddn = $dn; // We know olddn=dn as we change only subscriptions
522 522
 
523
-						$result=$ldap->update($dn,$info,$user,$olddn);
523
+						$result = $ldap->update($dn, $info, $user, $olddn);
524 524
 					}
525 525
 
526
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
526
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
527 527
 				}
528 528
 			}
529 529
 		}
530 530
 		elseif ($action == 'MEMBER_MODIFY')
531 531
 		{
532 532
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
533
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
534 534
 			{
535
-				$ldap=new Ldap();
536
-				$result=$ldap->connect_bind();
535
+				$ldap = new Ldap();
536
+				$result = $ldap->connect_bind();
537 537
 
538 538
 				if ($result > 0)
539 539
 				{
540
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
540
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
541 541
 					{
542 542
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
543 543
 						$object->oldcopy = clone $object;
544 544
 					}
545 545
 
546
-					$oldinfo=$object->oldcopy->_load_ldap_info();
547
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
546
+					$oldinfo = $object->oldcopy->_load_ldap_info();
547
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
548 548
 
549 549
 					// Verify if entry exist
550
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
551
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
552
-					$records=$ldap->search($container,$search);
550
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
551
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
552
+					$records = $ldap->search($container, $search);
553 553
 					if (count($records) && $records['count'] == 0)
554 554
 					{
555 555
 						$olddn = '';
556 556
 					}
557 557
 
558
-					$info=$object->_load_ldap_info();
559
-					$dn=$object->_load_ldap_dn($info);
560
-					$newrdn=$object->_load_ldap_dn($info,2);
561
-					$newparent=$object->_load_ldap_dn($info,1);
558
+					$info = $object->_load_ldap_info();
559
+					$dn = $object->_load_ldap_dn($info);
560
+					$newrdn = $object->_load_ldap_dn($info, 2);
561
+					$newparent = $object->_load_ldap_dn($info, 1);
562 562
 
563
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
563
+					$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
564 564
 
565 565
 					// For member type
566
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
566
+					if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
567 567
 					{
568 568
 						/*
569 569
 						 * Change member info
570 570
 						 */
571
-						$newmembertype=new AdherentType($this->db);
571
+						$newmembertype = new AdherentType($this->db);
572 572
 						$newmembertype->fetch($object->typeid);
573 573
 						$newmembertype->listMembersForMemberType('', 1);
574 574
 
575
-						$oldinfo=$newmembertype->_load_ldap_info();
576
-						$olddn=$newmembertype->_load_ldap_dn($oldinfo);
575
+						$oldinfo = $newmembertype->_load_ldap_info();
576
+						$olddn = $newmembertype->_load_ldap_dn($oldinfo);
577 577
 
578 578
 						// Verify if entry exist
579
-						$container=$newmembertype->_load_ldap_dn($oldinfo,1);
580
-						$search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
581
-						$records=$ldap->search($container,$search);
579
+						$container = $newmembertype->_load_ldap_dn($oldinfo, 1);
580
+						$search = "(".$newmembertype->_load_ldap_dn($oldinfo, 2).")";
581
+						$records = $ldap->search($container, $search);
582 582
 						if (count($records) && $records['count'] == 0)
583 583
 						{
584 584
 							$olddn = '';
585 585
 						}
586 586
 
587
-						$info=$newmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
588
-						$dn=$newmembertype->_load_ldap_dn($info);
587
+						$info = $newmembertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
588
+						$dn = $newmembertype->_load_ldap_dn($info);
589 589
 
590
-						$result=$ldap->update($dn,$info,$user,$olddn);
590
+						$result = $ldap->update($dn, $info, $user, $olddn);
591 591
 
592 592
 						if ($object->oldcopy->typeid != $object->typeid)
593 593
 						{
594 594
 							/*
595 595
 							 * Remove member in old member type
596 596
 							 */
597
-							$oldmembertype=new AdherentType($this->db);
597
+							$oldmembertype = new AdherentType($this->db);
598 598
 							$oldmembertype->fetch($object->oldcopy->typeid);
599 599
 							$oldmembertype->listMembersForMemberType('', 1);
600 600
 
601
-							$oldinfo=$oldmembertype->_load_ldap_info();
602
-							$olddn=$oldmembertype->_load_ldap_dn($oldinfo);
601
+							$oldinfo = $oldmembertype->_load_ldap_info();
602
+							$olddn = $oldmembertype->_load_ldap_dn($oldinfo);
603 603
 
604 604
 							// Verify if entry exist
605
-							$container=$oldmembertype->_load_ldap_dn($oldinfo,1);
606
-							$search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
607
-							$records=$ldap->search($container,$search);
605
+							$container = $oldmembertype->_load_ldap_dn($oldinfo, 1);
606
+							$search = "(".$oldmembertype->_load_ldap_dn($oldinfo, 2).")";
607
+							$records = $ldap->search($container, $search);
608 608
 							if (count($records) && $records['count'] == 0)
609 609
 							{
610 610
 								$olddn = '';
611 611
 							}
612 612
 
613
-							$info=$oldmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
614
-							$dn=$oldmembertype->_load_ldap_dn($info);
613
+							$info = $oldmembertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
614
+							$dn = $oldmembertype->_load_ldap_dn($info);
615 615
 
616
-							$result=$ldap->update($dn,$info,$user,$olddn);
616
+							$result = $ldap->update($dn, $info, $user, $olddn);
617 617
 						}
618 618
 					}
619 619
 				}
620 620
 
621
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
621
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
622 622
 			}
623 623
 		}
624 624
 		elseif ($action == 'MEMBER_NEW_PASSWORD')
625 625
 		{
626 626
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
627
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
628 628
 			{
629 629
 				// If password field is setup to be synchronized
630 630
 				if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
631 631
 				{
632
-					$ldap=new Ldap();
633
-					$result=$ldap->connect_bind();
632
+					$ldap = new Ldap();
633
+					$result = $ldap->connect_bind();
634 634
 
635 635
 					if ($result > 0)
636 636
 					{
637
-						$info=$object->_load_ldap_info();
638
-						$dn=$object->_load_ldap_dn($info);
639
-						$olddn=$dn;	// We know olddn=dn as we change only password
637
+						$info = $object->_load_ldap_info();
638
+						$dn = $object->_load_ldap_dn($info);
639
+						$olddn = $dn; // We know olddn=dn as we change only password
640 640
 
641
-						$result=$ldap->update($dn,$info,$user,$olddn);
641
+						$result = $ldap->update($dn, $info, $user, $olddn);
642 642
 					}
643 643
 
644
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
644
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
645 645
 				}
646 646
 			}
647 647
 		}
648 648
 		elseif ($action == 'MEMBER_RESILIATE')
649 649
 		{
650 650
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
651
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
652 652
 			{
653 653
 				// If status field is setup to be synchronized
654
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
654
+				if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
655 655
 				{
656
-					$ldap=new Ldap();
657
-					$result=$ldap->connect_bind();
656
+					$ldap = new Ldap();
657
+					$result = $ldap->connect_bind();
658 658
 
659 659
 					if ($result > 0)
660 660
 					{
661
-						$info=$object->_load_ldap_info();
662
-						$dn=$object->_load_ldap_dn($info);
663
-						$olddn=$dn;	// We know olddn=dn as we change only status
661
+						$info = $object->_load_ldap_info();
662
+						$dn = $object->_load_ldap_dn($info);
663
+						$olddn = $dn; // We know olddn=dn as we change only status
664 664
 
665
-						$result=$ldap->update($dn,$info,$user,$olddn);
665
+						$result = $ldap->update($dn, $info, $user, $olddn);
666 666
 					}
667 667
 
668
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
668
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
669 669
 				}
670 670
 			}
671 671
 		}
672 672
 		elseif ($action == 'MEMBER_DELETE')
673 673
 		{
674 674
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
675
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
676 676
 			{
677
-				$ldap=new Ldap();
678
-				$result=$ldap->connect_bind();
677
+				$ldap = new Ldap();
678
+				$result = $ldap->connect_bind();
679 679
 
680 680
 				if ($result > 0)
681 681
 				{
682
-					$info=$object->_load_ldap_info();
683
-					$dn=$object->_load_ldap_dn($info);
682
+					$info = $object->_load_ldap_info();
683
+					$dn = $object->_load_ldap_dn($info);
684 684
 
685
-					$result=$ldap->delete($dn);
685
+					$result = $ldap->delete($dn);
686 686
 
687 687
 					// For member type
688
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
688
+					if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
689 689
 					{
690 690
 						if ($object->typeid > 0)
691 691
 						{
692 692
 							/*
693 693
 							 * Remove member in member type
694 694
 							 */
695
-							$membertype=new AdherentType($this->db);
695
+							$membertype = new AdherentType($this->db);
696 696
 							$membertype->fetch($object->typeid);
697
-							$membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list
697
+							$membertype->listMembersForMemberType('a.rowid != '.$object->id, 1); // remove deleted member from the list
698 698
 
699
-							$oldinfo=$membertype->_load_ldap_info();
700
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
699
+							$oldinfo = $membertype->_load_ldap_info();
700
+							$olddn = $membertype->_load_ldap_dn($oldinfo);
701 701
 
702 702
 							// Verify if entry exist
703
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
704
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
705
-							$records=$ldap->search($container,$search);
703
+							$container = $membertype->_load_ldap_dn($oldinfo, 1);
704
+							$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
705
+							$records = $ldap->search($container, $search);
706 706
 							if (count($records) && $records['count'] == 0)
707 707
 							{
708 708
 								$olddn = '';
709 709
 							}
710 710
 
711
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
712
-							$dn=$membertype->_load_ldap_dn($info);
711
+							$info = $membertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
712
+							$dn = $membertype->_load_ldap_dn($info);
713 713
 
714
-							$result=$ldap->update($dn,$info,$user,$olddn);
714
+							$result = $ldap->update($dn, $info, $user, $olddn);
715 715
 						}
716 716
 					}
717 717
 				}
718 718
 
719
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
719
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
720 720
 			}
721 721
 		}
722 722
 
@@ -724,38 +724,38 @@  discard block
 block discarded – undo
724 724
 		elseif ($action == 'MEMBER_TYPE_CREATE')
725 725
 		{
726 726
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
727
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
727
+			if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
728 728
 			{
729
-				$ldap=new Ldap();
730
-				$result=$ldap->connect_bind();
729
+				$ldap = new Ldap();
730
+				$result = $ldap->connect_bind();
731 731
 
732 732
 				if ($result > 0)
733 733
 				{
734
-					$info=$object->_load_ldap_info();
735
-					$dn=$object->_load_ldap_dn($info);
734
+					$info = $object->_load_ldap_info();
735
+					$dn = $object->_load_ldap_dn($info);
736 736
 
737 737
 					// Get a gid number for objectclass PosixGroup
738
-					if (in_array('posixGroup',$info['objectclass'])) {
738
+					if (in_array('posixGroup', $info['objectclass'])) {
739 739
 						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
740 740
 					}
741 741
 
742
-					$result=$ldap->add($dn,$info,$user);
742
+					$result = $ldap->add($dn, $info, $user);
743 743
 				}
744 744
 
745
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
745
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
746 746
 			}
747 747
 		}
748 748
 		elseif ($action == 'MEMBER_TYPE_MODIFY')
749 749
 		{
750 750
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
751
+			if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
752 752
 			{
753
-				$ldap=new Ldap();
754
-				$result=$ldap->connect_bind();
753
+				$ldap = new Ldap();
754
+				$result = $ldap->connect_bind();
755 755
 
756 756
 				if ($result > 0)
757 757
 				{
758
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
758
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
759 759
 					{
760 760
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
761 761
 						$object->oldcopy = clone $object;
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 
764 764
 					$object->oldcopy->listMembersForMemberType('', 1);
765 765
 
766
-					$oldinfo=$object->oldcopy->_load_ldap_info();
767
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
766
+					$oldinfo = $object->oldcopy->_load_ldap_info();
767
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
768 768
 
769 769
 					// Verify if entry exist
770
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
771
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
772
-					$records=$ldap->search($container,$search);
770
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
771
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
772
+					$records = $ldap->search($container, $search);
773 773
 					if (count($records) && $records['count'] == 0)
774 774
 					{
775 775
 						$olddn = '';
@@ -777,32 +777,32 @@  discard block
 block discarded – undo
777 777
 
778 778
 					$object->listMembersForMemberType('', 1);
779 779
 
780
-					$info=$object->_load_ldap_info();
781
-					$dn=$object->_load_ldap_dn($info);
780
+					$info = $object->_load_ldap_info();
781
+					$dn = $object->_load_ldap_dn($info);
782 782
 
783
-					$result=$ldap->update($dn,$info,$user,$olddn);
783
+					$result = $ldap->update($dn, $info, $user, $olddn);
784 784
 				}
785 785
 
786
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
786
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
787 787
 			}
788 788
 		}
789 789
 		elseif ($action == 'MEMBER_TYPE_DELETE')
790 790
 		{
791 791
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
792
+			if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
793 793
 			{
794
-				$ldap=new Ldap();
795
-				$result=$ldap->connect_bind();
794
+				$ldap = new Ldap();
795
+				$result = $ldap->connect_bind();
796 796
 
797 797
 				if ($result > 0)
798 798
 				{
799
-					$info=$object->_load_ldap_info();
800
-					$dn=$object->_load_ldap_dn($info);
799
+					$info = $object->_load_ldap_info();
800
+					$dn = $object->_load_ldap_dn($info);
801 801
 
802
-					$result=$ldap->delete($dn);
802
+					$result = $ldap->delete($dn);
803 803
 				}
804 804
 
805
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
805
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
806 806
 			}
807 807
 		}
808 808
 
Please login to merge, or discard this patch.
Braces   +92 added lines, -60 removed lines patch added patch discarded remove patch
@@ -58,8 +58,14 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60 60
 	{
61
-		if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
-		if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
61
+		if (empty($conf->ldap->enabled)) {
62
+		    return 0;
63
+		}
64
+		// Module not active, we do nothing
65
+		if (defined('DISABLE_LDAP_SYNCHRO')) {
66
+		    return 0;
67
+		}
68
+		// If constant defined, we do nothing
63 69
 
64 70
 		if (! function_exists('ldap_connect'))
65 71
 		{
@@ -89,10 +95,11 @@  discard block
 block discarded – undo
89 95
 					$result=$ldap->add($dn,$info,$user);
90 96
 				}
91 97
 
92
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
98
+				if ($result < 0) {
99
+				    $this->error="ErrorLDAP ".$ldap->error;
100
+				}
93 101
 			}
94
-		}
95
-		elseif ($action == 'USER_MODIFY')
102
+		} elseif ($action == 'USER_MODIFY')
96 103
 		{
97 104
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98 105
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -128,10 +135,11 @@  discard block
 block discarded – undo
128 135
 					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
129 136
 				}
130 137
 
131
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
138
+				if ($result < 0) {
139
+				    $this->error="ErrorLDAP ".$ldap->error;
140
+				}
132 141
 			}
133
-		}
134
-		elseif ($action == 'USER_NEW_PASSWORD')
142
+		} elseif ($action == 'USER_NEW_PASSWORD')
135 143
 		{
136 144
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137 145
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -165,14 +173,14 @@  discard block
 block discarded – undo
165 173
 					$result=$ldap->update($dn,$info,$user,$olddn);
166 174
 				}
167 175
 
168
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
176
+				if ($result < 0) {
177
+				    $this->error="ErrorLDAP ".$ldap->error;
178
+				}
169 179
 			}
170
-		}
171
-		elseif ($action == 'USER_ENABLEDISABLE')
180
+		} elseif ($action == 'USER_ENABLEDISABLE')
172 181
 		{
173 182
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
174
-		}
175
-		elseif ($action == 'USER_DELETE')
183
+		} elseif ($action == 'USER_DELETE')
176 184
 		{
177 185
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178 186
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -188,10 +196,11 @@  discard block
 block discarded – undo
188 196
 					$result=$ldap->delete($dn);
189 197
 				}
190 198
 
191
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
199
+				if ($result < 0) {
200
+				    $this->error="ErrorLDAP ".$ldap->error;
201
+				}
192 202
 			}
193
-		}
194
-		elseif ($action == 'USER_SETINGROUP')
203
+		} elseif ($action == 'USER_SETINGROUP')
195 204
 		{
196 205
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197 206
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -226,10 +235,11 @@  discard block
 block discarded – undo
226 235
 					}
227 236
 				}
228 237
 
229
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
238
+				if ($result < 0) {
239
+				    $this->error="ErrorLDAP ".$ldap->error;
240
+				}
230 241
 			}
231
-		}
232
-		elseif ($action == 'USER_REMOVEFROMGROUP')
242
+		} elseif ($action == 'USER_REMOVEFROMGROUP')
233 243
 		{
234 244
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235 245
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -264,7 +274,9 @@  discard block
 block discarded – undo
264 274
 					}
265 275
 				}
266 276
 
267
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
277
+				if ($result < 0) {
278
+				    $this->error="ErrorLDAP ".$ldap->error;
279
+				}
268 280
 			}
269 281
 		}
270 282
 
@@ -290,10 +302,11 @@  discard block
 block discarded – undo
290 302
 					$result=$ldap->add($dn,$info,$user);
291 303
 				}
292 304
 
293
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
305
+				if ($result < 0) {
306
+				    $this->error="ErrorLDAP ".$ldap->error;
307
+				}
294 308
 			}
295
-		}
296
-		elseif ($action == 'GROUP_MODIFY')
309
+		} elseif ($action == 'GROUP_MODIFY')
297 310
 		{
298 311
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299 312
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -327,10 +340,11 @@  discard block
 block discarded – undo
327 340
 					$result=$ldap->update($dn,$info,$user,$olddn);
328 341
 				}
329 342
 
330
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
343
+				if ($result < 0) {
344
+				    $this->error="ErrorLDAP ".$ldap->error;
345
+				}
331 346
 			}
332
-		}
333
-		elseif ($action == 'GROUP_DELETE')
347
+		} elseif ($action == 'GROUP_DELETE')
334 348
 		{
335 349
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336 350
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -346,7 +360,9 @@  discard block
 block discarded – undo
346 360
 					$result=$ldap->delete($dn);
347 361
 				}
348 362
 
349
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
363
+				if ($result < 0) {
364
+				    $this->error="ErrorLDAP ".$ldap->error;
365
+				}
350 366
 			}
351 367
 		}
352 368
 
@@ -367,10 +383,11 @@  discard block
 block discarded – undo
367 383
 					$result=$ldap->add($dn,$info,$user);
368 384
 				}
369 385
 
370
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
386
+				if ($result < 0) {
387
+				    $this->error="ErrorLDAP ".$ldap->error;
388
+				}
371 389
 			}
372
-		}
373
-		elseif ($action == 'CONTACT_MODIFY')
390
+		} elseif ($action == 'CONTACT_MODIFY')
374 391
 		{
375 392
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376 393
 			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
@@ -404,10 +421,11 @@  discard block
 block discarded – undo
404 421
 					$result=$ldap->update($dn,$info,$user,$olddn);
405 422
 				}
406 423
 
407
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
424
+				if ($result < 0) {
425
+				    $this->error="ErrorLDAP ".$ldap->error;
426
+				}
408 427
 			}
409
-		}
410
-		elseif ($action == 'CONTACT_DELETE')
428
+		} elseif ($action == 'CONTACT_DELETE')
411 429
 		{
412 430
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413 431
 			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
@@ -423,7 +441,9 @@  discard block
 block discarded – undo
423 441
 					$result=$ldap->delete($dn);
424 442
 				}
425 443
 
426
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
444
+				if ($result < 0) {
445
+				    $this->error="ErrorLDAP ".$ldap->error;
446
+				}
427 447
 			}
428 448
 		}
429 449
 
@@ -472,10 +492,11 @@  discard block
 block discarded – undo
472 492
 					}
473 493
 				}
474 494
 
475
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
495
+				if ($result < 0) {
496
+				    $this->error="ErrorLDAP ".$ldap->error;
497
+				}
476 498
 			}
477
-		}
478
-		elseif ($action == 'MEMBER_VALIDATE')
499
+		} elseif ($action == 'MEMBER_VALIDATE')
479 500
 		{
480 501
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481 502
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -495,11 +516,12 @@  discard block
 block discarded – undo
495 516
 						$result=$ldap->update($dn,$info,$user,$olddn);
496 517
 					}
497 518
 
498
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
519
+					if ($result < 0) {
520
+					    $this->error="ErrorLDAP ".$ldap->error;
521
+					}
499 522
 				}
500 523
 			}
501
-		}
502
-		elseif ($action == 'MEMBER_SUBSCRIPTION')
524
+		} elseif ($action == 'MEMBER_SUBSCRIPTION')
503 525
 		{
504 526
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505 527
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -523,11 +545,12 @@  discard block
 block discarded – undo
523 545
 						$result=$ldap->update($dn,$info,$user,$olddn);
524 546
 					}
525 547
 
526
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
548
+					if ($result < 0) {
549
+					    $this->error="ErrorLDAP ".$ldap->error;
550
+					}
527 551
 				}
528 552
 			}
529
-		}
530
-		elseif ($action == 'MEMBER_MODIFY')
553
+		} elseif ($action == 'MEMBER_MODIFY')
531 554
 		{
532 555
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533 556
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -618,10 +641,11 @@  discard block
 block discarded – undo
618 641
 					}
619 642
 				}
620 643
 
621
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
644
+				if ($result < 0) {
645
+				    $this->error="ErrorLDAP ".$ldap->error;
646
+				}
622 647
 			}
623
-		}
624
-		elseif ($action == 'MEMBER_NEW_PASSWORD')
648
+		} elseif ($action == 'MEMBER_NEW_PASSWORD')
625 649
 		{
626 650
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627 651
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -641,11 +665,12 @@  discard block
 block discarded – undo
641 665
 						$result=$ldap->update($dn,$info,$user,$olddn);
642 666
 					}
643 667
 
644
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
668
+					if ($result < 0) {
669
+					    $this->error="ErrorLDAP ".$ldap->error;
670
+					}
645 671
 				}
646 672
 			}
647
-		}
648
-		elseif ($action == 'MEMBER_RESILIATE')
673
+		} elseif ($action == 'MEMBER_RESILIATE')
649 674
 		{
650 675
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651 676
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -665,11 +690,12 @@  discard block
 block discarded – undo
665 690
 						$result=$ldap->update($dn,$info,$user,$olddn);
666 691
 					}
667 692
 
668
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
693
+					if ($result < 0) {
694
+					    $this->error="ErrorLDAP ".$ldap->error;
695
+					}
669 696
 				}
670 697
 			}
671
-		}
672
-		elseif ($action == 'MEMBER_DELETE')
698
+		} elseif ($action == 'MEMBER_DELETE')
673 699
 		{
674 700
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675 701
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -716,7 +742,9 @@  discard block
 block discarded – undo
716 742
 					}
717 743
 				}
718 744
 
719
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
745
+				if ($result < 0) {
746
+				    $this->error="ErrorLDAP ".$ldap->error;
747
+				}
720 748
 			}
721 749
 		}
722 750
 
@@ -742,10 +770,11 @@  discard block
 block discarded – undo
742 770
 					$result=$ldap->add($dn,$info,$user);
743 771
 				}
744 772
 
745
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
773
+				if ($result < 0) {
774
+				    $this->error="ErrorLDAP ".$ldap->error;
775
+				}
746 776
 			}
747
-		}
748
-		elseif ($action == 'MEMBER_TYPE_MODIFY')
777
+		} elseif ($action == 'MEMBER_TYPE_MODIFY')
749 778
 		{
750 779
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751 780
 			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
@@ -783,10 +812,11 @@  discard block
 block discarded – undo
783 812
 					$result=$ldap->update($dn,$info,$user,$olddn);
784 813
 				}
785 814
 
786
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
815
+				if ($result < 0) {
816
+				    $this->error="ErrorLDAP ".$ldap->error;
817
+				}
787 818
 			}
788
-		}
789
-		elseif ($action == 'MEMBER_TYPE_DELETE')
819
+		} elseif ($action == 'MEMBER_TYPE_DELETE')
790 820
 		{
791 821
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792 822
 			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
@@ -802,7 +832,9 @@  discard block
 block discarded – undo
802 832
 					$result=$ldap->delete($dn);
803 833
 				}
804 834
 
805
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
835
+				if ($result < 0) {
836
+				    $this->error="ErrorLDAP ".$ldap->error;
837
+				}
806 838
 			}
807 839
 		}
808 840
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php 3 patches
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -34,58 +34,58 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class InterfaceActionsAuto extends DolibarrTriggers
36 36
 {
37
-	public $family = 'agenda';
38
-	public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
39
-
40
-	/**
41
-	 * Version of the trigger
42
-	 * @var string
43
-	 */
44
-	public $version = self::VERSION_DOLIBARR;
45
-
46
-	/**
47
-	 * @var string Image of the trigger
48
-	 */
49
-	public $picto = 'action';
50
-
51
-	/**
52
-	 * Function called when a Dolibarrr business event is done.
53
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
54
-	 *
55
-	 * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
56
-	 *      $object->actiontypecode (translation action code: AC_OTH, ...)
57
-	 *      $object->actionmsg (note, long text)
58
-	 *      $object->actionmsg2 (label, short text)
59
-	 *      $object->sendtoid (id of contact or array of ids)
60
-	 *      $object->socid (id of thirdparty)
61
-	 *      $object->fk_project
62
-	 *      $object->fk_element
63
-	 *      $object->elementtype
64
-	 *
65
-	 * @param string		$action		Event action code
66
-	 * @param Object		$object     Object
67
-	 * @param User		    $user       Object user
68
-	 * @param Translate 	$langs      Object langs
69
-	 * @param conf		    $conf       Object conf
70
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
71
-	 */
72
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
73
-	{
37
+    public $family = 'agenda';
38
+    public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
39
+
40
+    /**
41
+     * Version of the trigger
42
+     * @var string
43
+     */
44
+    public $version = self::VERSION_DOLIBARR;
45
+
46
+    /**
47
+     * @var string Image of the trigger
48
+     */
49
+    public $picto = 'action';
50
+
51
+    /**
52
+     * Function called when a Dolibarrr business event is done.
53
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
54
+     *
55
+     * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
56
+     *      $object->actiontypecode (translation action code: AC_OTH, ...)
57
+     *      $object->actionmsg (note, long text)
58
+     *      $object->actionmsg2 (label, short text)
59
+     *      $object->sendtoid (id of contact or array of ids)
60
+     *      $object->socid (id of thirdparty)
61
+     *      $object->fk_project
62
+     *      $object->fk_element
63
+     *      $object->elementtype
64
+     *
65
+     * @param string		$action		Event action code
66
+     * @param Object		$object     Object
67
+     * @param User		    $user       Object user
68
+     * @param Translate 	$langs      Object langs
69
+     * @param conf		    $conf       Object conf
70
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
71
+     */
72
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
73
+    {
74 74
         if (empty($conf->agenda->enabled)) return 0;     // Module not active, we do nothing
75 75
 
76
-		$key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
76
+        $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
77 77
 
78
-		// Do not log events not enabled for this action
79
-		if (empty($conf->global->$key)) {
80
-			return 0;
81
-		}
78
+        // Do not log events not enabled for this action
79
+        if (empty($conf->global->$key)) {
80
+            return 0;
81
+        }
82 82
 
83
-		$langs->load("agenda");
83
+        $langs->load("agenda");
84 84
 
85
-		if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
85
+        if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
86 86
 
87
-		// Actions
88
-		if ($action == 'COMPANY_CREATE')
87
+        // Actions
88
+        if ($action == 'COMPANY_CREATE')
89 89
         {
90 90
             // Load translation files required by the page
91 91
             $langs->loadLangs(array("agenda","other","companies"));
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
             $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
95 95
             if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
96 96
 
97
-			$object->sendtoid=0;
98
-			$object->socid=$object->id;
97
+            $object->sendtoid=0;
98
+            $object->socid=$object->id;
99 99
         }
100 100
         elseif ($action == 'COMPANY_SENTBYMAIL')
101 101
         {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
             // Parameters $object->sendtoid defined by caller
108 108
             //$object->sendtoid=0;
109
-		}
109
+        }
110 110
         elseif ($action == 'CONTRACT_VALIDATE')
111 111
         {
112 112
             // Load translation files required by the page
@@ -116,22 +116,22 @@  discard block
 block discarded – undo
116 116
             $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
117 117
 
118 118
             $object->sendtoid=0;
119
-		}
120
-		elseif ($action == 'CONTRACT_SENTBYMAIL')
121
-		{
122
-			// Load translation files required by the page
119
+        }
120
+        elseif ($action == 'CONTRACT_SENTBYMAIL')
121
+        {
122
+            // Load translation files required by the page
123 123
             $langs->loadLangs(array("agenda","other","contracts"));
124 124
 
125
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
126
-			if (empty($object->actionmsg))
127
-			{
128
-				$object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
129
-			}
125
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
126
+            if (empty($object->actionmsg))
127
+            {
128
+                $object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
129
+            }
130 130
 
131
-			// Parameters $object->sendtoid defined by caller
132
-			//$object->sendtoid=0;
133
-		}
134
-		elseif ($action == 'PROPAL_VALIDATE')
131
+            // Parameters $object->sendtoid defined by caller
132
+            //$object->sendtoid=0;
133
+        }
134
+        elseif ($action == 'PROPAL_VALIDATE')
135 135
         {
136 136
             // Load translation files required by the page
137 137
             $langs->loadLangs(array("agenda","other","propal"));
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
140 140
             $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
141 141
 
142
-			$object->sendtoid=0;
143
-		}
142
+            $object->sendtoid=0;
143
+        }
144 144
         elseif ($action == 'PROPAL_SENTBYMAIL')
145 145
         {
146 146
             // Load translation files required by the page
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
             // Parameters $object->sendtoid defined by caller
156 156
             //$object->sendtoid=0;
157
-		}
158
-		elseif ($action == 'PROPAL_CLOSE_SIGNED')
157
+        }
158
+        elseif ($action == 'PROPAL_CLOSE_SIGNED')
159 159
         {
160 160
             // Load translation files required by the page
161 161
             $langs->loadLangs(array("agenda","other","propal"));
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
164 164
             $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
165 165
 
166
-			$object->sendtoid=0;
167
-		}
168
-		elseif ($action == 'PROPAL_CLASSIFY_BILLED')
166
+            $object->sendtoid=0;
167
+        }
168
+        elseif ($action == 'PROPAL_CLASSIFY_BILLED')
169 169
         {
170 170
             // Load translation files required by the page
171 171
             $langs->loadLangs(array("agenda","other","propal"));
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
174 174
             $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
175 175
 
176
-			$object->sendtoid=0;
177
-		}
178
-		elseif ($action == 'PROPAL_CLOSE_REFUSED')
176
+            $object->sendtoid=0;
177
+        }
178
+        elseif ($action == 'PROPAL_CLOSE_REFUSED')
179 179
         {
180 180
             // Load translation files required by the page
181 181
             $langs->loadLangs(array("agenda","other","propal"));
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
184 184
             $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
185 185
 
186
-			$object->sendtoid=0;
187
-		}
188
-		elseif ($action == 'ORDER_VALIDATE')
186
+            $object->sendtoid=0;
187
+        }
188
+        elseif ($action == 'ORDER_VALIDATE')
189 189
         {
190 190
             // Load translation files required by the page
191 191
             $langs->loadLangs(array("agenda","orders"));
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
194 194
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
195 195
 
196
-			$object->sendtoid=0;
197
-		}
198
-		elseif ($action == 'ORDER_CLOSE')
196
+            $object->sendtoid=0;
197
+        }
198
+        elseif ($action == 'ORDER_CLOSE')
199 199
         {
200 200
             // Load translation files required by the page
201 201
             $langs->loadLangs(array("agenda","other","orders"));
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
204 204
             $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
205 205
 
206
-			$object->sendtoid=0;
207
-		}
208
-		elseif ($action == 'ORDER_CLASSIFY_BILLED')
206
+            $object->sendtoid=0;
207
+        }
208
+        elseif ($action == 'ORDER_CLASSIFY_BILLED')
209 209
         {
210 210
             // Load translation files required by the page
211 211
             $langs->loadLangs(array("agenda","other","orders"));
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
214 214
             $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
215 215
 
216
-			$object->sendtoid=0;
217
-		}
218
-		elseif ($action == 'ORDER_CANCEL')
216
+            $object->sendtoid=0;
217
+        }
218
+        elseif ($action == 'ORDER_CANCEL')
219 219
         {
220 220
             // Load translation files required by the page
221 221
             $langs->loadLangs(array("agenda","other","orders"));
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
224 224
             $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
225 225
 
226
-			$object->sendtoid=0;
227
-		}
228
-		elseif ($action == 'ORDER_SENTBYMAIL')
226
+            $object->sendtoid=0;
227
+        }
228
+        elseif ($action == 'ORDER_SENTBYMAIL')
229 229
         {
230 230
             // Load translation files required by the page
231 231
             $langs->loadLangs(array("agenda","other","orders"));
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 
239 239
             // Parameters $object->sendtoid defined by caller
240 240
             //$object->sendtoid=0;
241
-		}
242
-		elseif ($action == 'BILL_VALIDATE')
241
+        }
242
+        elseif ($action == 'BILL_VALIDATE')
243 243
         {
244 244
             // Load translation files required by the page
245 245
             $langs->loadLangs(array("agenda","other","bills"));
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
248 248
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
249 249
 
250
-			$object->sendtoid=0;
251
-		}
252
-		elseif ($action == 'BILL_UNVALIDATE')
250
+            $object->sendtoid=0;
251
+        }
252
+        elseif ($action == 'BILL_UNVALIDATE')
253 253
         {
254
-           // Load translation files required by the page
254
+            // Load translation files required by the page
255 255
             $langs->loadLangs(array("agenda","other","bills"));
256 256
 
257 257
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
258 258
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
259 259
 
260
-			$object->sendtoid=0;
261
-		}
260
+            $object->sendtoid=0;
261
+        }
262 262
         elseif ($action == 'BILL_SENTBYMAIL')
263 263
         {
264 264
             // Load translation files required by the page
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
 
273 273
             // Parameters $object->sendtoid defined by caller
274 274
             //$object->sendtoid=0;
275
-		}
276
-		elseif ($action == 'BILL_PAYED')
275
+        }
276
+        elseif ($action == 'BILL_PAYED')
277 277
         {
278 278
             // Load translation files required by the page
279 279
             $langs->loadLangs(array("agenda","other","bills"));
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
284 284
 
285 285
             $object->sendtoid=0;
286
-		}
287
-		elseif ($action == 'BILL_CANCEL')
286
+        }
287
+        elseif ($action == 'BILL_CANCEL')
288 288
         {
289 289
             // Load translation files required by the page
290 290
             $langs->loadLangs(array("agenda","other","bills"));
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
294 294
 
295 295
             $object->sendtoid=0;
296
-		}
297
-		elseif ($action == 'FICHINTER_CREATE')
296
+        }
297
+        elseif ($action == 'FICHINTER_CREATE')
298 298
         {
299 299
             // Load translation files required by the page
300 300
             $langs->loadLangs(array("agenda","other","interventions"));
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
             $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
304 304
 
305 305
             $object->sendtoid=0;
306
-			$object->fk_element=0;
307
-			$object->elementtype='';
308
-		}
309
-		elseif ($action == 'FICHINTER_VALIDATE')
306
+            $object->fk_element=0;
307
+            $object->elementtype='';
308
+        }
309
+        elseif ($action == 'FICHINTER_VALIDATE')
310 310
         {
311 311
             // Load translation files required by the page
312 312
             $langs->loadLangs(array("agenda","other","interventions"));
@@ -315,10 +315,10 @@  discard block
 block discarded – undo
315 315
             $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
316 316
 
317 317
             $object->sendtoid=0;
318
-			$object->fk_element=0;
319
-			$object->elementtype='';
320
-		}
321
-		elseif ($action == 'FICHINTER_MODIFY')
318
+            $object->fk_element=0;
319
+            $object->elementtype='';
320
+        }
321
+        elseif ($action == 'FICHINTER_MODIFY')
322 322
         {
323 323
             // Load translation files required by the page
324 324
             $langs->loadLangs(array("agenda","other","interventions"));
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
             $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
328 328
 
329 329
             $object->sendtoid=0;
330
-			$object->fk_element=0;
331
-			$object->elementtype='';
332
-		}
333
-		elseif ($action == 'FICHINTER_SENTBYMAIL')
330
+            $object->fk_element=0;
331
+            $object->elementtype='';
332
+        }
333
+        elseif ($action == 'FICHINTER_SENTBYMAIL')
334 334
         {
335 335
             // Load translation files required by the page
336 336
             $langs->loadLangs(array("agenda","other","interventions"));
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
339 339
             if (empty($object->actionmsg))
340 340
             {
341
-            	$object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
341
+                $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
342 342
             }
343 343
 
344 344
             // Parameters $object->sendtoid defined by caller
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
             // Load translation files required by the page
350 350
             $langs->loadLangs(array("agenda","other","interventions"));
351 351
 
352
-           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
353
-           	$object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
352
+                if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
353
+                $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
354 354
 
355 355
             $object->sendtoid=0;
356 356
         }
357
-	    elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED')
357
+        elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED')
358 358
         {
359 359
             // Load translation files required by the page
360 360
             $langs->loadLangs(array("agenda","other","interventions"));
361 361
 
362
-           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
363
-           	$object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
362
+                if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
363
+                $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
364 364
 
365 365
             $object->sendtoid=0;
366 366
         }
@@ -373,24 +373,24 @@  discard block
 block discarded – undo
373 373
             $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
374 374
 
375 375
             $object->sendtoid=0;
376
-			$object->fk_element=0;
377
-			$object->elementtype='';
378
-		}
376
+            $object->fk_element=0;
377
+            $object->elementtype='';
378
+        }
379 379
         elseif ($action == 'SHIPPING_VALIDATE')
380 380
         {
381 381
             // Load translation files required by the page
382 382
             $langs->loadLangs(array("agenda","other","sendings"));
383 383
 
384
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
385
-        	if (empty($object->actionmsg))
386
-        	{
387
-        		$object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
388
-        	}
384
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
385
+            if (empty($object->actionmsg))
386
+            {
387
+                $object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
388
+            }
389 389
 
390
-        	// Parameters $object->sendtoid defined by caller
391
-        	//$object->sendtoid=0;
390
+            // Parameters $object->sendtoid defined by caller
391
+            //$object->sendtoid=0;
392 392
         }
393
-		elseif ($action == 'SHIPPING_SENTBYMAIL')
393
+        elseif ($action == 'SHIPPING_SENTBYMAIL')
394 394
         {
395 395
             // Load translation files required by the page
396 396
             $langs->loadLangs(array("agenda","other","sendings"));
@@ -403,22 +403,22 @@  discard block
 block discarded – undo
403 403
 
404 404
             // Parameters $object->sendtoid defined by caller
405 405
             //$object->sendtoid=0;
406
-		} elseif ($action == 'RECEPTION_VALIDATE')
406
+        } elseif ($action == 'RECEPTION_VALIDATE')
407 407
         {
408 408
             $langs->load("agenda");
409 409
             $langs->load("other");
410
-        	$langs->load("receptions");
410
+            $langs->load("receptions");
411 411
 
412
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
413
-        	if (empty($object->actionmsg))
414
-        	{
415
-        		$object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
416
-        	}
412
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
413
+            if (empty($object->actionmsg))
414
+            {
415
+                $object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
416
+            }
417 417
 
418
-        	// Parameters $object->sendtoid defined by caller
419
-        	//$object->sendtoid=0;
418
+            // Parameters $object->sendtoid defined by caller
419
+            //$object->sendtoid=0;
420 420
         }
421
-		elseif ($action == 'RECEPTION_SENTBYMAIL')
421
+        elseif ($action == 'RECEPTION_SENTBYMAIL')
422 422
         {
423 423
             $langs->load("agenda");
424 424
             $langs->load("other");
@@ -432,52 +432,52 @@  discard block
 block discarded – undo
432 432
 
433 433
             // Parameters $object->sendtoid defined by caller
434 434
             //$object->sendtoid=0;
435
-		}
436
-		elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE')
437
-		{
438
-			// Load translation files required by the page
435
+        }
436
+        elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE')
437
+        {
438
+            // Load translation files required by the page
439 439
             $langs->loadLangs(array("agenda","other","propal"));
440 440
 
441
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
442
-			$object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
441
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
442
+            $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
443 443
 
444
-			$object->sendtoid=0;
445
-		}
446
-		elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL')
447
-		{
448
-			// Load translation files required by the page
444
+            $object->sendtoid=0;
445
+        }
446
+        elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL')
447
+        {
448
+            // Load translation files required by the page
449 449
             $langs->loadLangs(array("agenda","other","propal"));
450 450
 
451
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
452
-			if (empty($object->actionmsg))
453
-			{
454
-				$object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
455
-			}
456
-
457
-			// Parameters $object->sendtoid defined by caller
458
-			//$object->sendtoid=0;
459
-		}
460
-		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED')
461
-		{
462
-			// Load translation files required by the page
451
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
452
+            if (empty($object->actionmsg))
453
+            {
454
+                $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
455
+            }
456
+
457
+            // Parameters $object->sendtoid defined by caller
458
+            //$object->sendtoid=0;
459
+        }
460
+        elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED')
461
+        {
462
+            // Load translation files required by the page
463 463
             $langs->loadLangs(array("agenda","other","propal"));
464 464
 
465
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
466
-			$object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
465
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
466
+            $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
467 467
 
468
-			$object->sendtoid=0;
469
-		}
470
-		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED')
471
-		{
472
-			// Load translation files required by the page
468
+            $object->sendtoid=0;
469
+        }
470
+        elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED')
471
+        {
472
+            // Load translation files required by the page
473 473
             $langs->loadLangs(array("agenda","other","propal"));
474 474
 
475
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
476
-			$object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
475
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
476
+            $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
477 477
 
478
-			$object->sendtoid=0;
479
-		}
480
-		elseif ($action == 'ORDER_SUPPLIER_CREATE')
478
+            $object->sendtoid=0;
479
+        }
480
+        elseif ($action == 'ORDER_SUPPLIER_CREATE')
481 481
         {
482 482
             // Load translation files required by the page
483 483
             $langs->loadLangs(array("agenda","other","orders"));
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
             $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
487 487
 
488 488
             $object->sendtoid=0;
489
-		}
490
-		elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
489
+        }
490
+        elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
491 491
         {
492 492
             // Load translation files required by the page
493 493
             $langs->loadLangs(array("agenda","other","orders"));
@@ -496,28 +496,28 @@  discard block
 block discarded – undo
496 496
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
497 497
 
498 498
             $object->sendtoid=0;
499
-		}
500
-		elseif ($action == 'ORDER_SUPPLIER_APPROVE')
501
-		{
499
+        }
500
+        elseif ($action == 'ORDER_SUPPLIER_APPROVE')
501
+        {
502 502
             // Load translation files required by the page
503 503
             $langs->loadLangs(array("agenda","other","orders"));
504 504
 
505
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
506
-			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
505
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
506
+            $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
507 507
 
508
-			$object->sendtoid=0;
509
-		}
510
-		elseif ($action == 'ORDER_SUPPLIER_REFUSE')
511
-		{
508
+            $object->sendtoid=0;
509
+        }
510
+        elseif ($action == 'ORDER_SUPPLIER_REFUSE')
511
+        {
512 512
             // Load translation files required by the page
513 513
             $langs->loadLangs(array("agenda","other","orders"));
514 514
 
515
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
516
-			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
515
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
516
+            $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
517 517
 
518
-			$object->sendtoid=0;
519
-		}
520
-		elseif ($action == 'ORDER_SUPPLIER_SUBMIT')
518
+            $object->sendtoid=0;
519
+        }
520
+        elseif ($action == 'ORDER_SUPPLIER_SUBMIT')
521 521
         {
522 522
             // Load translation files required by the page
523 523
             $langs->loadLangs(array("agenda","other","orders"));
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
             $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
527 527
 
528 528
             $object->sendtoid=0;
529
-		}
530
-		elseif ($action == 'ORDER_SUPPLIER_RECEIVE')
529
+        }
530
+        elseif ($action == 'ORDER_SUPPLIER_RECEIVE')
531 531
         {
532 532
             // Load translation files required by the page
533 533
             $langs->loadLangs(array("agenda","other","orders"));
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
             $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
537 537
 
538 538
             $object->sendtoid=0;
539
-		}
540
-		elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
539
+        }
540
+        elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
541 541
         {
542 542
             // Load translation files required by the page
543 543
             $langs->loadLangs(array("agenda","other","bills","orders"));
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
             // Parameters $object->sendtoid defined by caller
552 552
             //$object->sendtoid=0;
553 553
         }
554
-		elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED')
554
+        elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED')
555 555
         {
556 556
             // Load translation files required by the page
557 557
             $langs->loadLangs(array("agenda","other","bills","orders"));
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 
565 565
             $object->sendtoid=0;
566 566
         }
567
-		elseif ($action == 'BILL_SUPPLIER_VALIDATE')
567
+        elseif ($action == 'BILL_SUPPLIER_VALIDATE')
568 568
         {
569 569
             // Load translation files required by the page
570 570
             $langs->loadLangs(array("agenda","other","bills"));
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
574 574
 
575 575
             $object->sendtoid=0;
576
-		}
577
-		elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
576
+        }
577
+        elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
578 578
         {
579 579
             // Load translation files required by the page
580 580
             $langs->loadLangs(array("agenda","other","bills"));
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
584 584
 
585 585
             $object->sendtoid=0;
586
-		}
586
+        }
587 587
         elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
588 588
         {
589 589
             // Load translation files required by the page
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
             // Parameters $object->sendtoid defined by caller
599 599
             //$object->sendtoid=0;
600 600
         }
601
-		elseif ($action == 'BILL_SUPPLIER_PAYED')
601
+        elseif ($action == 'BILL_SUPPLIER_PAYED')
602 602
         {
603 603
             // Load translation files required by the page
604 604
             $langs->loadLangs(array("agenda","other","bills"));
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
607 607
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
608 608
 
609
-			$object->sendtoid=0;
610
-		}
611
-		elseif ($action == 'BILL_SUPPLIER_CANCELED')
609
+            $object->sendtoid=0;
610
+        }
611
+        elseif ($action == 'BILL_SUPPLIER_CANCELED')
612 612
         {
613 613
             // Load translation files required by the page
614 614
             $langs->loadLangs(array("agenda","other","bills"));
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
617 617
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
618 618
 
619
-			$object->sendtoid=0;
620
-		}
619
+            $object->sendtoid=0;
620
+        }
621 621
 
622 622
         // Members
623 623
         elseif ($action == 'MEMBER_VALIDATE')
@@ -630,9 +630,9 @@  discard block
 block discarded – undo
630 630
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
631 631
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
632 632
 
633
-			$object->sendtoid=0;
633
+            $object->sendtoid=0;
634 634
         }
635
-		elseif ($action == 'MEMBER_MODIFY')
635
+        elseif ($action == 'MEMBER_MODIFY')
636 636
         {
637 637
             // Load translation files required by the page
638 638
             $langs->loadLangs(array("agenda","other","members"));
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
644 644
 
645 645
             $object->sendtoid=0;
646
-		}
646
+        }
647 647
         elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE')
648 648
         {
649 649
             // Load translation files required by the page
@@ -656,38 +656,38 @@  discard block
 block discarded – undo
656 656
             $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
657 657
             $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
658 658
 
659
-			$object->sendtoid=0;
660
-			if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
659
+            $object->sendtoid=0;
660
+            if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
661 661
         }
662 662
         elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY')
663 663
         {
664
-        	// Load translation files required by the page
664
+            // Load translation files required by the page
665 665
             $langs->loadLangs(array("agenda","other","members"));
666 666
 
667
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
668
-        	$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
669
-        	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
670
-        	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
671
-        	$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
672
-        	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
667
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
668
+            $object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
669
+            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
670
+            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
671
+            $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
672
+            $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
673 673
 
674
-        	$object->sendtoid=0;
675
-        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
674
+            $object->sendtoid=0;
675
+            if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
676 676
         }
677 677
         elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE')
678 678
         {
679
-        	// Load translation files required by the page
679
+            // Load translation files required by the page
680 680
             $langs->loadLangs(array("agenda","other","members"));
681 681
 
682
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
683
-        	$object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
684
-        	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
685
-        	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
686
-        	$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
687
-        	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
682
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
683
+            $object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
684
+            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
685
+            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
686
+            $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
687
+            $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
688 688
 
689
-        	$object->sendtoid=0;
690
-        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
689
+            $object->sendtoid=0;
690
+            if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
691 691
         }
692 692
         elseif ($action == 'MEMBER_RESILIATE')
693 693
         {
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
700 700
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
701 701
 
702
-			$object->sendtoid=0;
702
+            $object->sendtoid=0;
703 703
         }
704 704
         elseif ($action == 'MEMBER_DELETE')
705 705
         {
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
712 712
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
713 713
 
714
-			$object->sendtoid=0;
714
+            $object->sendtoid=0;
715 715
         }
716 716
 
717 717
         // Projects
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
             // Load translation files required by the page
721 721
             $langs->loadLangs(array("agenda","other","projects"));
722 722
 
723
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
724
-        	$object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
725
-        	$object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
723
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
724
+            $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
725
+            $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
726 726
 
727
-        	$object->sendtoid=0;
727
+            $object->sendtoid=0;
728 728
         }
729 729
         elseif($action == 'PROJECT_VALIDATE')
730 730
         {
@@ -749,74 +749,74 @@  discard block
 block discarded – undo
749 749
             $object->sendtoid=0;
750 750
         }
751 751
 
752
-		// Project tasks
753
-		elseif($action == 'TASK_CREATE')
754
-		{
752
+        // Project tasks
753
+        elseif($action == 'TASK_CREATE')
754
+        {
755 755
             // Load translation files required by the page
756 756
             $langs->loadLangs(array("agenda","other","projects"));
757 757
 
758
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
759
-			$object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
760
-			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
758
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
759
+            $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
760
+            $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
761 761
 
762
-			$object->sendtoid=0;
763
-		}
762
+            $object->sendtoid=0;
763
+        }
764 764
 
765
-		elseif($action == 'TASK_MODIFY')
766
-		{
765
+        elseif($action == 'TASK_MODIFY')
766
+        {
767 767
             // Load translation files required by the page
768 768
             $langs->loadLangs(array("agenda","other","projects"));
769 769
 
770
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
771
-			$object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
772
-			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
770
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
771
+            $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
772
+            $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
773 773
 
774
-			$object->sendtoid=0;
775
-		}
774
+            $object->sendtoid=0;
775
+        }
776 776
 
777
-		elseif($action == 'TASK_DELETE')
778
-		{
777
+        elseif($action == 'TASK_DELETE')
778
+        {
779 779
             // Load translation files required by the page
780 780
             $langs->loadLangs(array("agenda","other","projects"));
781 781
 
782
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
783
-			$object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
784
-			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
785
-
786
-			$object->sendtoid=0;
787
-		}
788
-		// TODO Merge all previous cases into this generic one
789
-		else	// $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ...
790
-		{
791
-		    // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function)
792
-		    // Load translation files required by the page
782
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
783
+            $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
784
+            $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
785
+
786
+            $object->sendtoid=0;
787
+        }
788
+        // TODO Merge all previous cases into this generic one
789
+        else	// $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ...
790
+        {
791
+            // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function)
792
+            // Load translation files required by the page
793 793
             $langs->loadLangs(array("agenda","other"));
794 794
 
795
-		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
796
-		    if (empty($object->actionmsg))  $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
795
+            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
796
+            if (empty($object->actionmsg))  $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
797 797
 
798
-		    $object->sendtoid=0;
799
-		}
798
+            $object->sendtoid=0;
799
+        }
800 800
 
801
-		$object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
801
+        $object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
802 802
 
803
-		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
803
+        dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
804 804
 
805 805
         // Add entry in event table
806
-		$now=dol_now();
806
+        $now=dol_now();
807 807
 
808
-		if (isset($_SESSION['listofnames-'.$object->trackid]))
809
-		{
810
-			$attachs=$_SESSION['listofnames-'.$object->trackid];
811
-			if ($attachs && strpos($action,'SENTBYMAIL'))
812
-			{
808
+        if (isset($_SESSION['listofnames-'.$object->trackid]))
809
+        {
810
+            $attachs=$_SESSION['listofnames-'.$object->trackid];
811
+            if ($attachs && strpos($action,'SENTBYMAIL'))
812
+            {
813 813
                 $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
814
-			}
815
-		}
814
+            }
815
+        }
816 816
 
817 817
         require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
818 818
         require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
819
-		$contactforaction=new Contact($this->db);
819
+        $contactforaction=new Contact($this->db);
820 820
         $societeforaction=new Societe($this->db);
821 821
         // Set contactforaction if there is only 1 contact.
822 822
         if (is_array($object->sendtoid))
@@ -838,87 +838,87 @@  discard block
 block discarded – undo
838 838
         $elementtype = $object->element;
839 839
         if ($object->element == 'subscription')
840 840
         {
841
-        	$elementid = $object->fk_adherent;
842
-        	$elementtype = 'member';
841
+            $elementid = $object->fk_adherent;
842
+            $elementtype = 'member';
843 843
         }
844 844
         //var_dump($societeforaction);var_dump($contactforaction);exit;
845 845
 
846
-		// Insertion action
847
-		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
848
-		$actioncomm = new ActionComm($this->db);
849
-		$actioncomm->type_code   = $object->actiontypecode;		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
850
-		$actioncomm->code        = 'AC_'.$action;
851
-		$actioncomm->label       = $object->actionmsg2;
852
-		$actioncomm->note        = $object->actionmsg;          // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg)
853
-		$actioncomm->fk_project  = $projectid;
854
-		$actioncomm->datep       = $now;
855
-		$actioncomm->datef       = $now;
856
-		$actioncomm->durationp   = 0;
857
-		$actioncomm->punctual    = 1;
858
-		$actioncomm->percentage  = -1;   // Not applicable
859
-		$actioncomm->societe     = $societeforaction;
860
-		$actioncomm->contact     = $contactforaction;
861
-		$actioncomm->socid       = $societeforaction->id;
862
-		$actioncomm->contactid   = $contactforaction->id;
863
-		$actioncomm->authorid    = $user->id;   // User saving action
864
-		$actioncomm->userownerid = $user->id;	// Owner of action
846
+        // Insertion action
847
+        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
848
+        $actioncomm = new ActionComm($this->db);
849
+        $actioncomm->type_code   = $object->actiontypecode;		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
850
+        $actioncomm->code        = 'AC_'.$action;
851
+        $actioncomm->label       = $object->actionmsg2;
852
+        $actioncomm->note        = $object->actionmsg;          // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg)
853
+        $actioncomm->fk_project  = $projectid;
854
+        $actioncomm->datep       = $now;
855
+        $actioncomm->datef       = $now;
856
+        $actioncomm->durationp   = 0;
857
+        $actioncomm->punctual    = 1;
858
+        $actioncomm->percentage  = -1;   // Not applicable
859
+        $actioncomm->societe     = $societeforaction;
860
+        $actioncomm->contact     = $contactforaction;
861
+        $actioncomm->socid       = $societeforaction->id;
862
+        $actioncomm->contactid   = $contactforaction->id;
863
+        $actioncomm->authorid    = $user->id;   // User saving action
864
+        $actioncomm->userownerid = $user->id;	// Owner of action
865 865
         // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label)
866
-		$actioncomm->email_msgid   = $object->email_msgid;
867
-		$actioncomm->email_from    = $object->email_from;
868
-		$actioncomm->email_sender  = $object->email_sender;
869
-		$actioncomm->email_to      = $object->email_to;
870
-		$actioncomm->email_tocc    = $object->email_tocc;
871
-		$actioncomm->email_tobcc   = $object->email_tobcc;
872
-		$actioncomm->email_subject = $object->email_subject;
873
-		$actioncomm->errors_to     = $object->errors_to;
874
-
875
-		// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
876
-		// for such objects because there is already a dedicated field into table llx_actioncomm.
877
-		if (! in_array($elementtype, array('societe','contact','project')))
878
-		{
879
-			$actioncomm->fk_element  = $elementid;
880
-			$actioncomm->elementtype = $elementtype;
881
-		}
882
-
883
-		if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
884
-			$actioncomm->attachedfiles=$object->attachedfiles;
885
-		}
886
-		if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
887
-			$actioncomm->userassigned=$object->sendtouserid;
888
-		}
889
-
890
-		$ret=$actioncomm->create($user);       // User creating action
891
-
892
-		if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO)
893
-		{
894
-			if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
895
-				foreach($object->attachedfiles['paths'] as $key=>$filespath) {
896
-					$srcfile = $filespath;
897
-					$destdir = $conf->agenda->dir_output . '/' . $ret;
898
-					$destfile = $destdir . '/' . $object->attachedfiles['names'][$key];
899
-					if (dol_mkdir($destdir) >= 0) {
900
-						require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
901
-						dol_copy($srcfile, $destfile);
902
-					}
903
-				}
904
-			}
905
-		}
906
-
907
-		unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode);	// When several action are called on same object, we must be sure to not reuse value of first action.
908
-
909
-		if ($ret > 0)
910
-		{
911
-			$_SESSION['LAST_ACTION_CREATED'] = $ret;
912
-			return 1;
913
-		}
914
-		else
915
-		{
866
+        $actioncomm->email_msgid   = $object->email_msgid;
867
+        $actioncomm->email_from    = $object->email_from;
868
+        $actioncomm->email_sender  = $object->email_sender;
869
+        $actioncomm->email_to      = $object->email_to;
870
+        $actioncomm->email_tocc    = $object->email_tocc;
871
+        $actioncomm->email_tobcc   = $object->email_tobcc;
872
+        $actioncomm->email_subject = $object->email_subject;
873
+        $actioncomm->errors_to     = $object->errors_to;
874
+
875
+        // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
876
+        // for such objects because there is already a dedicated field into table llx_actioncomm.
877
+        if (! in_array($elementtype, array('societe','contact','project')))
878
+        {
879
+            $actioncomm->fk_element  = $elementid;
880
+            $actioncomm->elementtype = $elementtype;
881
+        }
882
+
883
+        if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
884
+            $actioncomm->attachedfiles=$object->attachedfiles;
885
+        }
886
+        if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
887
+            $actioncomm->userassigned=$object->sendtouserid;
888
+        }
889
+
890
+        $ret=$actioncomm->create($user);       // User creating action
891
+
892
+        if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO)
893
+        {
894
+            if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
895
+                foreach($object->attachedfiles['paths'] as $key=>$filespath) {
896
+                    $srcfile = $filespath;
897
+                    $destdir = $conf->agenda->dir_output . '/' . $ret;
898
+                    $destfile = $destdir . '/' . $object->attachedfiles['names'][$key];
899
+                    if (dol_mkdir($destdir) >= 0) {
900
+                        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
901
+                        dol_copy($srcfile, $destfile);
902
+                    }
903
+                }
904
+            }
905
+        }
906
+
907
+        unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode);	// When several action are called on same object, we must be sure to not reuse value of first action.
908
+
909
+        if ($ret > 0)
910
+        {
911
+            $_SESSION['LAST_ACTION_CREATED'] = $ret;
912
+            return 1;
913
+        }
914
+        else
915
+        {
916 916
             $error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
917 917
             $this->error=$error;
918 918
             $this->errors=$actioncomm->errors;
919 919
 
920 920
             dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
921 921
             return -1;
922
-		}
922
+        }
923 923
     }
924 924
 }
Please login to merge, or discard this patch.
Spacing   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
73 73
 	{
74
-        if (empty($conf->agenda->enabled)) return 0;     // Module not active, we do nothing
74
+        if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing
75 75
 
76 76
 		$key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
77 77
 
@@ -82,25 +82,25 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$langs->load("agenda");
84 84
 
85
-		if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
85
+		if (empty($object->actiontypecode)) $object->actiontypecode = 'AC_OTH_AUTO';
86 86
 
87 87
 		// Actions
88 88
 		if ($action == 'COMPANY_CREATE')
89 89
         {
90 90
             // Load translation files required by the page
91
-            $langs->loadLangs(array("agenda","other","companies"));
91
+            $langs->loadLangs(array("agenda", "other", "companies"));
92 92
 
93
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
94
-            $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
95
-            if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
93
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
94
+            $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->name);
95
+            if (!empty($object->prefix)) $object->actionmsg .= " (".$object->prefix.")";
96 96
 
97
-			$object->sendtoid=0;
98
-			$object->socid=$object->id;
97
+			$object->sendtoid = 0;
98
+			$object->socid = $object->id;
99 99
         }
100 100
         elseif ($action == 'COMPANY_SENTBYMAIL')
101 101
         {
102 102
             // Load translation files required by the page
103
-            $langs->loadLangs(array("agenda","other","orders"));
103
+            $langs->loadLangs(array("agenda", "other", "orders"));
104 104
 
105 105
             if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
106 106
 
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
         elseif ($action == 'CONTRACT_VALIDATE')
111 111
         {
112 112
             // Load translation files required by the page
113
-            $langs->loadLangs(array("agenda","other","contracts"));
113
+            $langs->loadLangs(array("agenda", "other", "contracts"));
114 114
 
115
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
116
-            $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
115
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
116
+            $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
117 117
 
118
-            $object->sendtoid=0;
118
+            $object->sendtoid = 0;
119 119
 		}
120 120
 		elseif ($action == 'CONTRACT_SENTBYMAIL')
121 121
 		{
122 122
 			// Load translation files required by the page
123
-            $langs->loadLangs(array("agenda","other","contracts"));
123
+            $langs->loadLangs(array("agenda", "other", "contracts"));
124 124
 
125
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
125
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ContractSentByEMail", $object->ref);
126 126
 			if (empty($object->actionmsg))
127 127
 			{
128
-				$object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
128
+				$object->actionmsg = $langs->transnoentities("ContractSentByEMail", $object->ref);
129 129
 			}
130 130
 
131 131
 			// Parameters $object->sendtoid defined by caller
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 		elseif ($action == 'PROPAL_VALIDATE')
135 135
         {
136 136
             // Load translation files required by the page
137
-            $langs->loadLangs(array("agenda","other","propal"));
137
+            $langs->loadLangs(array("agenda", "other", "propal"));
138 138
 
139
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
140
-            $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
139
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
140
+            $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
141 141
 
142
-			$object->sendtoid=0;
142
+			$object->sendtoid = 0;
143 143
 		}
144 144
         elseif ($action == 'PROPAL_SENTBYMAIL')
145 145
         {
146 146
             // Load translation files required by the page
147
-            $langs->loadLangs(array("agenda","other","propal"));
147
+            $langs->loadLangs(array("agenda", "other", "propal"));
148 148
 
149
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
149
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
150 150
             if (empty($object->actionmsg))
151 151
             {
152
-                $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
152
+                $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
153 153
             }
154 154
 
155 155
             // Parameters $object->sendtoid defined by caller
@@ -158,82 +158,82 @@  discard block
 block discarded – undo
158 158
 		elseif ($action == 'PROPAL_CLOSE_SIGNED')
159 159
         {
160 160
             // Load translation files required by the page
161
-            $langs->loadLangs(array("agenda","other","propal"));
161
+            $langs->loadLangs(array("agenda", "other", "propal"));
162 162
 
163
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
164
-            $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
163
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
164
+            $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
165 165
 
166
-			$object->sendtoid=0;
166
+			$object->sendtoid = 0;
167 167
 		}
168 168
 		elseif ($action == 'PROPAL_CLASSIFY_BILLED')
169 169
         {
170 170
             // Load translation files required by the page
171
-            $langs->loadLangs(array("agenda","other","propal"));
171
+            $langs->loadLangs(array("agenda", "other", "propal"));
172 172
 
173
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
174
-            $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
173
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
174
+            $object->actionmsg = $langs->transnoentities("PropalClassifiedBilledInDolibarr", $object->ref);
175 175
 
176
-			$object->sendtoid=0;
176
+			$object->sendtoid = 0;
177 177
 		}
178 178
 		elseif ($action == 'PROPAL_CLOSE_REFUSED')
179 179
         {
180 180
             // Load translation files required by the page
181
-            $langs->loadLangs(array("agenda","other","propal"));
181
+            $langs->loadLangs(array("agenda", "other", "propal"));
182 182
 
183
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
184
-            $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
183
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
184
+            $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
185 185
 
186
-			$object->sendtoid=0;
186
+			$object->sendtoid = 0;
187 187
 		}
188 188
 		elseif ($action == 'ORDER_VALIDATE')
189 189
         {
190 190
             // Load translation files required by the page
191
-            $langs->loadLangs(array("agenda","orders"));
191
+            $langs->loadLangs(array("agenda", "orders"));
192 192
 
193
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
194
-            $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
193
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
194
+            $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
195 195
 
196
-			$object->sendtoid=0;
196
+			$object->sendtoid = 0;
197 197
 		}
198 198
 		elseif ($action == 'ORDER_CLOSE')
199 199
         {
200 200
             // Load translation files required by the page
201
-            $langs->loadLangs(array("agenda","other","orders"));
201
+            $langs->loadLangs(array("agenda", "other", "orders"));
202 202
 
203
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
204
-            $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
203
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
204
+            $object->actionmsg = $langs->transnoentities("OrderDeliveredInDolibarr", $object->ref);
205 205
 
206
-			$object->sendtoid=0;
206
+			$object->sendtoid = 0;
207 207
 		}
208 208
 		elseif ($action == 'ORDER_CLASSIFY_BILLED')
209 209
         {
210 210
             // Load translation files required by the page
211
-            $langs->loadLangs(array("agenda","other","orders"));
211
+            $langs->loadLangs(array("agenda", "other", "orders"));
212 212
 
213
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
214
-            $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
213
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
214
+            $object->actionmsg = $langs->transnoentities("OrderBilledInDolibarr", $object->ref);
215 215
 
216
-			$object->sendtoid=0;
216
+			$object->sendtoid = 0;
217 217
 		}
218 218
 		elseif ($action == 'ORDER_CANCEL')
219 219
         {
220 220
             // Load translation files required by the page
221
-            $langs->loadLangs(array("agenda","other","orders"));
221
+            $langs->loadLangs(array("agenda", "other", "orders"));
222 222
 
223
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
224
-            $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
223
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
224
+            $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref);
225 225
 
226
-			$object->sendtoid=0;
226
+			$object->sendtoid = 0;
227 227
 		}
228 228
 		elseif ($action == 'ORDER_SENTBYMAIL')
229 229
         {
230 230
             // Load translation files required by the page
231
-            $langs->loadLangs(array("agenda","other","orders"));
231
+            $langs->loadLangs(array("agenda", "other", "orders"));
232 232
 
233
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
233
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref);
234 234
             if (empty($object->actionmsg))
235 235
             {
236
-                $object->actionmsg=$langs->transnoentities("OrderSentByEMail",$object->ref);
236
+                $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref);
237 237
             }
238 238
 
239 239
             // Parameters $object->sendtoid defined by caller
@@ -242,32 +242,32 @@  discard block
 block discarded – undo
242 242
 		elseif ($action == 'BILL_VALIDATE')
243 243
         {
244 244
             // Load translation files required by the page
245
-            $langs->loadLangs(array("agenda","other","bills"));
245
+            $langs->loadLangs(array("agenda", "other", "bills"));
246 246
 
247
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
248
-            $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
247
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
248
+            $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
249 249
 
250
-			$object->sendtoid=0;
250
+			$object->sendtoid = 0;
251 251
 		}
252 252
 		elseif ($action == 'BILL_UNVALIDATE')
253 253
         {
254 254
            // Load translation files required by the page
255
-            $langs->loadLangs(array("agenda","other","bills"));
255
+            $langs->loadLangs(array("agenda", "other", "bills"));
256 256
 
257
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
258
-            $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
257
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
258
+            $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
259 259
 
260
-			$object->sendtoid=0;
260
+			$object->sendtoid = 0;
261 261
 		}
262 262
         elseif ($action == 'BILL_SENTBYMAIL')
263 263
         {
264 264
             // Load translation files required by the page
265
-            $langs->loadLangs(array("agenda","other","bills"));
265
+            $langs->loadLangs(array("agenda", "other", "bills"));
266 266
 
267
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
267
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
268 268
             if (empty($object->actionmsg))
269 269
             {
270
-                $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
270
+                $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref);
271 271
             }
272 272
 
273 273
             // Parameters $object->sendtoid defined by caller
@@ -276,69 +276,69 @@  discard block
 block discarded – undo
276 276
 		elseif ($action == 'BILL_PAYED')
277 277
         {
278 278
             // Load translation files required by the page
279
-            $langs->loadLangs(array("agenda","other","bills"));
279
+            $langs->loadLangs(array("agenda", "other", "bills"));
280 280
 
281 281
             // Values for this action can't be defined by caller.
282
-            $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
283
-            $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
282
+            $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
283
+            $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
284 284
 
285
-            $object->sendtoid=0;
285
+            $object->sendtoid = 0;
286 286
 		}
287 287
 		elseif ($action == 'BILL_CANCEL')
288 288
         {
289 289
             // Load translation files required by the page
290
-            $langs->loadLangs(array("agenda","other","bills"));
290
+            $langs->loadLangs(array("agenda", "other", "bills"));
291 291
 
292
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
293
-            $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
292
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
293
+            $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
294 294
 
295
-            $object->sendtoid=0;
295
+            $object->sendtoid = 0;
296 296
 		}
297 297
 		elseif ($action == 'FICHINTER_CREATE')
298 298
         {
299 299
             // Load translation files required by the page
300
-            $langs->loadLangs(array("agenda","other","interventions"));
300
+            $langs->loadLangs(array("agenda", "other", "interventions"));
301 301
 
302
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
303
-            $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
302
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
303
+            $object->actionmsg = $langs->transnoentities("InterventionCreatedInDolibarr", $object->ref);
304 304
 
305
-            $object->sendtoid=0;
306
-			$object->fk_element=0;
307
-			$object->elementtype='';
305
+            $object->sendtoid = 0;
306
+			$object->fk_element = 0;
307
+			$object->elementtype = '';
308 308
 		}
309 309
 		elseif ($action == 'FICHINTER_VALIDATE')
310 310
         {
311 311
             // Load translation files required by the page
312
-            $langs->loadLangs(array("agenda","other","interventions"));
312
+            $langs->loadLangs(array("agenda", "other", "interventions"));
313 313
 
314
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
315
-            $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
314
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
315
+            $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
316 316
 
317
-            $object->sendtoid=0;
318
-			$object->fk_element=0;
319
-			$object->elementtype='';
317
+            $object->sendtoid = 0;
318
+			$object->fk_element = 0;
319
+			$object->elementtype = '';
320 320
 		}
321 321
 		elseif ($action == 'FICHINTER_MODIFY')
322 322
         {
323 323
             // Load translation files required by the page
324
-            $langs->loadLangs(array("agenda","other","interventions"));
324
+            $langs->loadLangs(array("agenda", "other", "interventions"));
325 325
 
326
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
327
-            $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
326
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
327
+            $object->actionmsg = $langs->transnoentities("InterventionModifiedInDolibarr", $object->ref);
328 328
 
329
-            $object->sendtoid=0;
330
-			$object->fk_element=0;
331
-			$object->elementtype='';
329
+            $object->sendtoid = 0;
330
+			$object->fk_element = 0;
331
+			$object->elementtype = '';
332 332
 		}
333 333
 		elseif ($action == 'FICHINTER_SENTBYMAIL')
334 334
         {
335 335
             // Load translation files required by the page
336
-            $langs->loadLangs(array("agenda","other","interventions"));
336
+            $langs->loadLangs(array("agenda", "other", "interventions"));
337 337
 
338
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
338
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref);
339 339
             if (empty($object->actionmsg))
340 340
             {
341
-            	$object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
341
+            	$object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref);
342 342
             }
343 343
 
344 344
             // Parameters $object->sendtoid defined by caller
@@ -347,44 +347,44 @@  discard block
 block discarded – undo
347 347
         elseif ($action == 'FICHINTER_CLASSIFY_BILLED')
348 348
         {
349 349
             // Load translation files required by the page
350
-            $langs->loadLangs(array("agenda","other","interventions"));
350
+            $langs->loadLangs(array("agenda", "other", "interventions"));
351 351
 
352
-           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
353
-           	$object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
352
+           	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
353
+           	$object->actionmsg = $langs->transnoentities("InterventionClassifiedBilledInDolibarr", $object->ref);
354 354
 
355
-            $object->sendtoid=0;
355
+            $object->sendtoid = 0;
356 356
         }
357 357
 	    elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED')
358 358
         {
359 359
             // Load translation files required by the page
360
-            $langs->loadLangs(array("agenda","other","interventions"));
360
+            $langs->loadLangs(array("agenda", "other", "interventions"));
361 361
 
362
-           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
363
-           	$object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
362
+           	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
363
+           	$object->actionmsg = $langs->transnoentities("InterventionClassifiedUnbilledInDolibarr", $object->ref);
364 364
 
365
-            $object->sendtoid=0;
365
+            $object->sendtoid = 0;
366 366
         }
367 367
         elseif ($action == 'FICHINTER_DELETE')
368 368
         {
369 369
             // Load translation files required by the page
370
-            $langs->loadLangs(array("agenda","other","interventions"));
370
+            $langs->loadLangs(array("agenda", "other", "interventions"));
371 371
 
372
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
373
-            $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
372
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
373
+            $object->actionmsg = $langs->transnoentities("InterventionDeletedInDolibarr", $object->ref);
374 374
 
375
-            $object->sendtoid=0;
376
-			$object->fk_element=0;
377
-			$object->elementtype='';
375
+            $object->sendtoid = 0;
376
+			$object->fk_element = 0;
377
+			$object->elementtype = '';
378 378
 		}
379 379
         elseif ($action == 'SHIPPING_VALIDATE')
380 380
         {
381 381
             // Load translation files required by the page
382
-            $langs->loadLangs(array("agenda","other","sendings"));
382
+            $langs->loadLangs(array("agenda", "other", "sendings"));
383 383
 
384
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
384
+        	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
385 385
         	if (empty($object->actionmsg))
386 386
         	{
387
-        		$object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
387
+        		$object->actionmsg = $langs->transnoentities("ShippingValidated", ($object->newref ? $object->newref : $object->ref));
388 388
         	}
389 389
 
390 390
         	// Parameters $object->sendtoid defined by caller
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
 		elseif ($action == 'SHIPPING_SENTBYMAIL')
394 394
         {
395 395
             // Load translation files required by the page
396
-            $langs->loadLangs(array("agenda","other","sendings"));
396
+            $langs->loadLangs(array("agenda", "other", "sendings"));
397 397
 
398
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
398
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref);
399 399
             if (empty($object->actionmsg))
400 400
             {
401
-                $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref);
401
+                $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref);
402 402
             }
403 403
 
404 404
             // Parameters $object->sendtoid defined by caller
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
             $langs->load("other");
410 410
         	$langs->load("receptions");
411 411
 
412
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
412
+        	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
413 413
         	if (empty($object->actionmsg))
414 414
         	{
415
-        		$object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
415
+        		$object->actionmsg = $langs->transnoentities("ReceptionValidated", ($object->newref ? $object->newref : $object->ref));
416 416
         	}
417 417
 
418 418
         	// Parameters $object->sendtoid defined by caller
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
             $langs->load("other");
425 425
             $langs->load("receptions");
426 426
 
427
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
427
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
428 428
             if (empty($object->actionmsg))
429 429
             {
430
-                $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
430
+                $object->actionmsg = $langs->transnoentities("ReceptionSentByEMail", $object->ref);
431 431
             }
432 432
 
433 433
             // Parameters $object->sendtoid defined by caller
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 		elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE')
437 437
 		{
438 438
 			// Load translation files required by the page
439
-            $langs->loadLangs(array("agenda","other","propal"));
439
+            $langs->loadLangs(array("agenda", "other", "propal"));
440 440
 
441
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
442
-			$object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
441
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
442
+			$object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
443 443
 
444
-			$object->sendtoid=0;
444
+			$object->sendtoid = 0;
445 445
 		}
446 446
 		elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL')
447 447
 		{
448 448
 			// Load translation files required by the page
449
-            $langs->loadLangs(array("agenda","other","propal"));
449
+            $langs->loadLangs(array("agenda", "other", "propal"));
450 450
 
451
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
451
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref);
452 452
 			if (empty($object->actionmsg))
453 453
 			{
454
-				$object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
454
+				$object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref);
455 455
 			}
456 456
 
457 457
 			// Parameters $object->sendtoid defined by caller
@@ -460,92 +460,92 @@  discard block
 block discarded – undo
460 460
 		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED')
461 461
 		{
462 462
 			// Load translation files required by the page
463
-            $langs->loadLangs(array("agenda","other","propal"));
463
+            $langs->loadLangs(array("agenda", "other", "propal"));
464 464
 
465
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
466
-			$object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
465
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
466
+			$object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref);
467 467
 
468
-			$object->sendtoid=0;
468
+			$object->sendtoid = 0;
469 469
 		}
470 470
 		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED')
471 471
 		{
472 472
 			// Load translation files required by the page
473
-            $langs->loadLangs(array("agenda","other","propal"));
473
+            $langs->loadLangs(array("agenda", "other", "propal"));
474 474
 
475
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
476
-			$object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
475
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
476
+			$object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref);
477 477
 
478
-			$object->sendtoid=0;
478
+			$object->sendtoid = 0;
479 479
 		}
480 480
 		elseif ($action == 'ORDER_SUPPLIER_CREATE')
481 481
         {
482 482
             // Load translation files required by the page
483
-            $langs->loadLangs(array("agenda","other","orders"));
483
+            $langs->loadLangs(array("agenda", "other", "orders"));
484 484
 
485
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
486
-            $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
485
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
486
+            $object->actionmsg = $langs->transnoentities("OrderCreatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
487 487
 
488
-            $object->sendtoid=0;
488
+            $object->sendtoid = 0;
489 489
 		}
490 490
 		elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
491 491
         {
492 492
             // Load translation files required by the page
493
-            $langs->loadLangs(array("agenda","other","orders"));
493
+            $langs->loadLangs(array("agenda", "other", "orders"));
494 494
 
495
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
496
-            $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
495
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
496
+            $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
497 497
 
498
-            $object->sendtoid=0;
498
+            $object->sendtoid = 0;
499 499
 		}
500 500
 		elseif ($action == 'ORDER_SUPPLIER_APPROVE')
501 501
 		{
502 502
             // Load translation files required by the page
503
-            $langs->loadLangs(array("agenda","other","orders"));
503
+            $langs->loadLangs(array("agenda", "other", "orders"));
504 504
 
505
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
506
-			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
505
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
506
+			$object->actionmsg = $langs->transnoentities("OrderApprovedInDolibarr", $object->ref);
507 507
 
508
-			$object->sendtoid=0;
508
+			$object->sendtoid = 0;
509 509
 		}
510 510
 		elseif ($action == 'ORDER_SUPPLIER_REFUSE')
511 511
 		{
512 512
             // Load translation files required by the page
513
-            $langs->loadLangs(array("agenda","other","orders"));
513
+            $langs->loadLangs(array("agenda", "other", "orders"));
514 514
 
515
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
516
-			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
515
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
516
+			$object->actionmsg = $langs->transnoentities("OrderRefusedInDolibarr", $object->ref);
517 517
 
518
-			$object->sendtoid=0;
518
+			$object->sendtoid = 0;
519 519
 		}
520 520
 		elseif ($action == 'ORDER_SUPPLIER_SUBMIT')
521 521
         {
522 522
             // Load translation files required by the page
523
-            $langs->loadLangs(array("agenda","other","orders"));
523
+            $langs->loadLangs(array("agenda", "other", "orders"));
524 524
 
525
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
526
-            $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
525
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
526
+            $object->actionmsg = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref));
527 527
 
528
-            $object->sendtoid=0;
528
+            $object->sendtoid = 0;
529 529
 		}
530 530
 		elseif ($action == 'ORDER_SUPPLIER_RECEIVE')
531 531
         {
532 532
             // Load translation files required by the page
533
-            $langs->loadLangs(array("agenda","other","orders"));
533
+            $langs->loadLangs(array("agenda", "other", "orders"));
534 534
 
535
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
536
-            $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
535
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
536
+            $object->actionmsg = $langs->transnoentities("SupplierOrderReceivedInDolibarr", ($object->newref ? $object->newref : $object->ref));
537 537
 
538
-            $object->sendtoid=0;
538
+            $object->sendtoid = 0;
539 539
 		}
540 540
 		elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
541 541
         {
542 542
             // Load translation files required by the page
543
-            $langs->loadLangs(array("agenda","other","bills","orders"));
543
+            $langs->loadLangs(array("agenda", "other", "bills", "orders"));
544 544
 
545
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
545
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
546 546
             if (empty($object->actionmsg))
547 547
             {
548
-                $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
548
+                $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref);
549 549
             }
550 550
 
551 551
             // Parameters $object->sendtoid defined by caller
@@ -554,45 +554,45 @@  discard block
 block discarded – undo
554 554
 		elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED')
555 555
         {
556 556
             // Load translation files required by the page
557
-            $langs->loadLangs(array("agenda","other","bills","orders"));
557
+            $langs->loadLangs(array("agenda", "other", "bills", "orders"));
558 558
 
559
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
559
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
560 560
             if (empty($object->actionmsg))
561 561
             {
562
-                $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
562
+                $object->actionmsg = $langs->transnoentities("SupplierOrderClassifiedBilled", $object->ref);
563 563
             }
564 564
 
565
-            $object->sendtoid=0;
565
+            $object->sendtoid = 0;
566 566
         }
567 567
 		elseif ($action == 'BILL_SUPPLIER_VALIDATE')
568 568
         {
569 569
             // Load translation files required by the page
570
-            $langs->loadLangs(array("agenda","other","bills"));
570
+            $langs->loadLangs(array("agenda", "other", "bills"));
571 571
 
572
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
573
-            $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
572
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
573
+            $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", ($object->newref ? $object->newref : $object->ref));
574 574
 
575
-            $object->sendtoid=0;
575
+            $object->sendtoid = 0;
576 576
 		}
577 577
 		elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
578 578
         {
579 579
             // Load translation files required by the page
580
-            $langs->loadLangs(array("agenda","other","bills"));
580
+            $langs->loadLangs(array("agenda", "other", "bills"));
581 581
 
582
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
583
-            $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
582
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
583
+            $object->actionmsg = $langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
584 584
 
585
-            $object->sendtoid=0;
585
+            $object->sendtoid = 0;
586 586
 		}
587 587
         elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
588 588
         {
589 589
             // Load translation files required by the page
590
-            $langs->loadLangs(array("agenda","other","bills","orders"));
590
+            $langs->loadLangs(array("agenda", "other", "bills", "orders"));
591 591
 
592
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
592
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
593 593
             if (empty($object->actionmsg))
594 594
             {
595
-                $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
595
+                $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref);
596 596
             }
597 597
 
598 598
             // Parameters $object->sendtoid defined by caller
@@ -601,201 +601,201 @@  discard block
 block discarded – undo
601 601
 		elseif ($action == 'BILL_SUPPLIER_PAYED')
602 602
         {
603 603
             // Load translation files required by the page
604
-            $langs->loadLangs(array("agenda","other","bills"));
604
+            $langs->loadLangs(array("agenda", "other", "bills"));
605 605
 
606
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
607
-            $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
606
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
607
+            $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref);
608 608
 
609
-			$object->sendtoid=0;
609
+			$object->sendtoid = 0;
610 610
 		}
611 611
 		elseif ($action == 'BILL_SUPPLIER_CANCELED')
612 612
         {
613 613
             // Load translation files required by the page
614
-            $langs->loadLangs(array("agenda","other","bills"));
614
+            $langs->loadLangs(array("agenda", "other", "bills"));
615 615
 
616
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
617
-            $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
616
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
617
+            $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref);
618 618
 
619
-			$object->sendtoid=0;
619
+			$object->sendtoid = 0;
620 620
 		}
621 621
 
622 622
         // Members
623 623
         elseif ($action == 'MEMBER_VALIDATE')
624 624
         {
625 625
             // Load translation files required by the page
626
-            $langs->loadLangs(array("agenda","other","members"));
626
+            $langs->loadLangs(array("agenda", "other", "members"));
627 627
 
628
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
629
-            $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
630
-            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
631
-            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
628
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
629
+            $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->getFullName($langs));
630
+            $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
631
+            $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
632 632
 
633
-			$object->sendtoid=0;
633
+			$object->sendtoid = 0;
634 634
         }
635 635
 		elseif ($action == 'MEMBER_MODIFY')
636 636
         {
637 637
             // Load translation files required by the page
638
-            $langs->loadLangs(array("agenda","other","members"));
638
+            $langs->loadLangs(array("agenda", "other", "members"));
639 639
 
640
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
641
-            $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
642
-            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
643
-            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
640
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
641
+            $object->actionmsg = $langs->transnoentities("MemberModifiedInDolibarr", $object->getFullName($langs));
642
+            $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
643
+            $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
644 644
 
645
-            $object->sendtoid=0;
645
+            $object->sendtoid = 0;
646 646
 		}
647 647
         elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE')
648 648
         {
649 649
             // Load translation files required by the page
650
-            $langs->loadLangs(array("agenda","other","members"));
650
+            $langs->loadLangs(array("agenda", "other", "members"));
651 651
 
652
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
653
-            $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
654
-            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
655
-            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
656
-            $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
657
-            $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
652
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs));
653
+            $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref, $object->getFullName($langs));
654
+            $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
655
+            $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
656
+            $object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
657
+            $object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
658 658
 
659
-			$object->sendtoid=0;
660
-			if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
659
+			$object->sendtoid = 0;
660
+			if ($object->fk_soc > 0) $object->socid = $object->fk_soc;
661 661
         }
662 662
         elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY')
663 663
         {
664 664
         	// Load translation files required by the page
665
-            $langs->loadLangs(array("agenda","other","members"));
665
+            $langs->loadLangs(array("agenda", "other", "members"));
666 666
 
667
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
668
-        	$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
669
-        	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
670
-        	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
671
-        	$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
672
-        	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
667
+        	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs));
668
+        	$object->actionmsg = $langs->transnoentities("MemberSubscriptionModifiedInDolibarr", $object->ref, $object->getFullName($langs));
669
+        	$object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
670
+        	$object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
671
+        	$object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
672
+        	$object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
673 673
 
674
-        	$object->sendtoid=0;
675
-        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
674
+        	$object->sendtoid = 0;
675
+        	if ($object->fk_soc > 0) $object->socid = $object->fk_soc;
676 676
         }
677 677
         elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE')
678 678
         {
679 679
         	// Load translation files required by the page
680
-            $langs->loadLangs(array("agenda","other","members"));
680
+            $langs->loadLangs(array("agenda", "other", "members"));
681 681
 
682
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
683
-        	$object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
684
-        	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
685
-        	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
686
-        	$object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
687
-        	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
682
+        	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs));
683
+        	$object->actionmsg = $langs->transnoentities("MemberSubscriptionDeletedInDolibarr", $object->ref, $object->getFullName($langs));
684
+        	$object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
685
+        	$object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
686
+        	$object->actionmsg .= "\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
687
+        	$object->actionmsg .= "\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start, 'day').' - '.dol_print_date($object->last_subscription_date_end, 'day');
688 688
 
689
-        	$object->sendtoid=0;
690
-        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
689
+        	$object->sendtoid = 0;
690
+        	if ($object->fk_soc > 0) $object->socid = $object->fk_soc;
691 691
         }
692 692
         elseif ($action == 'MEMBER_RESILIATE')
693 693
         {
694 694
             // Load translation files required by the page
695
-            $langs->loadLangs(array("agenda","other","members"));
695
+            $langs->loadLangs(array("agenda", "other", "members"));
696 696
 
697
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
698
-            $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
699
-            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
700
-            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
697
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
698
+            $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->getFullName($langs));
699
+            $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
700
+            $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
701 701
 
702
-			$object->sendtoid=0;
702
+			$object->sendtoid = 0;
703 703
         }
704 704
         elseif ($action == 'MEMBER_DELETE')
705 705
         {
706 706
             // Load translation files required by the page
707
-            $langs->loadLangs(array("agenda","other","members"));
707
+            $langs->loadLangs(array("agenda", "other", "members"));
708 708
 
709
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
710
-            $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
711
-            $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
712
-            $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
709
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
710
+            $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->getFullName($langs));
711
+            $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
712
+            $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
713 713
 
714
-			$object->sendtoid=0;
714
+			$object->sendtoid = 0;
715 715
         }
716 716
 
717 717
         // Projects
718 718
         elseif ($action == 'PROJECT_CREATE')
719 719
         {
720 720
             // Load translation files required by the page
721
-            $langs->loadLangs(array("agenda","other","projects"));
721
+            $langs->loadLangs(array("agenda", "other", "projects"));
722 722
 
723
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
724
-        	$object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
725
-        	$object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
723
+        	if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
724
+        	$object->actionmsg = $langs->transnoentities("ProjectCreatedInDolibarr", $object->ref);
725
+        	$object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
726 726
 
727
-        	$object->sendtoid=0;
727
+        	$object->sendtoid = 0;
728 728
         }
729
-        elseif($action == 'PROJECT_VALIDATE')
729
+        elseif ($action == 'PROJECT_VALIDATE')
730 730
         {
731 731
             // Load translation files required by the page
732
-            $langs->loadLangs(array("agenda","other","projects"));
732
+            $langs->loadLangs(array("agenda", "other", "projects"));
733 733
 
734
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
735
-            $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
736
-            $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
734
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
735
+            $object->actionmsg = $langs->transnoentities("ProjectValidatedInDolibarr", $object->ref);
736
+            $object->actionmsg .= "\n".$langs->transnoentities("Project").': '.$object->ref;
737 737
 
738
-            $object->sendtoid=0;
738
+            $object->sendtoid = 0;
739 739
         }
740
-        elseif($action == 'PROJECT_MODIFY')
740
+        elseif ($action == 'PROJECT_MODIFY')
741 741
         {
742 742
             // Load translation files required by the page
743
-            $langs->loadLangs(array("agenda","other","projects"));
743
+            $langs->loadLangs(array("agenda", "other", "projects"));
744 744
 
745
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
746
-            $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
747
-            $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
745
+            if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
746
+            $object->actionmsg = $langs->transnoentities("ProjectModifiedInDolibarr", $object->ref);
747
+            $object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
748 748
 
749
-            $object->sendtoid=0;
749
+            $object->sendtoid = 0;
750 750
         }
751 751
 
752 752
 		// Project tasks
753
-		elseif($action == 'TASK_CREATE')
753
+		elseif ($action == 'TASK_CREATE')
754 754
 		{
755 755
             // Load translation files required by the page
756
-            $langs->loadLangs(array("agenda","other","projects"));
756
+            $langs->loadLangs(array("agenda", "other", "projects"));
757 757
 
758
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
759
-			$object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
760
-			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
758
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
759
+			$object->actionmsg = $langs->transnoentities("TaskCreatedInDolibarr", $object->ref);
760
+			$object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
761 761
 
762
-			$object->sendtoid=0;
762
+			$object->sendtoid = 0;
763 763
 		}
764 764
 
765
-		elseif($action == 'TASK_MODIFY')
765
+		elseif ($action == 'TASK_MODIFY')
766 766
 		{
767 767
             // Load translation files required by the page
768
-            $langs->loadLangs(array("agenda","other","projects"));
768
+            $langs->loadLangs(array("agenda", "other", "projects"));
769 769
 
770
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
771
-			$object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
772
-			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
770
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskModifiedInDolibarr", $object->ref);
771
+			$object->actionmsg = $langs->transnoentities("TaskModifieddInDolibarr", $object->ref);
772
+			$object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
773 773
 
774
-			$object->sendtoid=0;
774
+			$object->sendtoid = 0;
775 775
 		}
776 776
 
777
-		elseif($action == 'TASK_DELETE')
777
+		elseif ($action == 'TASK_DELETE')
778 778
 		{
779 779
             // Load translation files required by the page
780
-            $langs->loadLangs(array("agenda","other","projects"));
780
+            $langs->loadLangs(array("agenda", "other", "projects"));
781 781
 
782
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
783
-			$object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
784
-			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
782
+			if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
783
+			$object->actionmsg = $langs->transnoentities("TaskDeletedInDolibarr", $object->ref);
784
+			$object->actionmsg .= "\n".$langs->transnoentities("Task").': '.$object->ref;
785 785
 
786
-			$object->sendtoid=0;
786
+			$object->sendtoid = 0;
787 787
 		}
788 788
 		// TODO Merge all previous cases into this generic one
789 789
 		else	// $action = TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, ...
790 790
 		{
791 791
 		    // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function)
792 792
 		    // Load translation files required by the page
793
-            $langs->loadLangs(array("agenda","other"));
793
+            $langs->loadLangs(array("agenda", "other"));
794 794
 
795
-		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
796
-		    if (empty($object->actionmsg))  $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
795
+		    if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", $object->ref);
796
+		    if (empty($object->actionmsg))  $object->actionmsg = $langs->transnoentities($action."InDolibarr", $object->ref);
797 797
 
798
-		    $object->sendtoid=0;
798
+		    $object->sendtoid = 0;
799 799
 		}
800 800
 
801 801
 		$object->actionmsg = $langs->transnoentities("Author").': '.$user->login."\n".$object->actionmsg;
@@ -803,21 +803,21 @@  discard block
 block discarded – undo
803 803
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
804 804
 
805 805
         // Add entry in event table
806
-		$now=dol_now();
806
+		$now = dol_now();
807 807
 
808 808
 		if (isset($_SESSION['listofnames-'.$object->trackid]))
809 809
 		{
810
-			$attachs=$_SESSION['listofnames-'.$object->trackid];
811
-			if ($attachs && strpos($action,'SENTBYMAIL'))
810
+			$attachs = $_SESSION['listofnames-'.$object->trackid];
811
+			if ($attachs && strpos($action, 'SENTBYMAIL'))
812 812
 			{
813
-                $object->actionmsg=dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
813
+                $object->actionmsg = dol_concatdesc($object->actionmsg, "\n".$langs->transnoentities("AttachedFiles").': '.$attachs);
814 814
 			}
815 815
 		}
816 816
 
817 817
         require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
818 818
         require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
819
-		$contactforaction=new Contact($this->db);
820
-        $societeforaction=new Societe($this->db);
819
+		$contactforaction = new Contact($this->db);
820
+        $societeforaction = new Societe($this->db);
821 821
         // Set contactforaction if there is only 1 contact.
822 822
         if (is_array($object->sendtoid))
823 823
         {
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
         if ($object->socid > 0)			$societeforaction->fetch($object->socid);
832 832
         elseif ($object->fk_soc > 0)	$societeforaction->fetch($object->fk_soc);
833 833
 
834
-        $projectid = isset($object->fk_project)?$object->fk_project:0;
834
+        $projectid = isset($object->fk_project) ? $object->fk_project : 0;
835 835
         if ($object->element == 'project') $projectid = $object->id;
836 836
 
837 837
         $elementid = $object->id;
@@ -846,22 +846,22 @@  discard block
 block discarded – undo
846 846
 		// Insertion action
847 847
 		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
848 848
 		$actioncomm = new ActionComm($this->db);
849
-		$actioncomm->type_code   = $object->actiontypecode;		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
849
+		$actioncomm->type_code   = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
850 850
 		$actioncomm->code        = 'AC_'.$action;
851 851
 		$actioncomm->label       = $object->actionmsg2;
852
-		$actioncomm->note        = $object->actionmsg;          // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg)
852
+		$actioncomm->note        = $object->actionmsg; // TODO Replace with ($actioncomm->email_msgid ? $object->email_content : $object->actionmsg)
853 853
 		$actioncomm->fk_project  = $projectid;
854 854
 		$actioncomm->datep       = $now;
855 855
 		$actioncomm->datef       = $now;
856 856
 		$actioncomm->durationp   = 0;
857 857
 		$actioncomm->punctual    = 1;
858
-		$actioncomm->percentage  = -1;   // Not applicable
858
+		$actioncomm->percentage  = -1; // Not applicable
859 859
 		$actioncomm->societe     = $societeforaction;
860 860
 		$actioncomm->contact     = $contactforaction;
861 861
 		$actioncomm->socid       = $societeforaction->id;
862 862
 		$actioncomm->contactid   = $contactforaction->id;
863
-		$actioncomm->authorid    = $user->id;   // User saving action
864
-		$actioncomm->userownerid = $user->id;	// Owner of action
863
+		$actioncomm->authorid    = $user->id; // User saving action
864
+		$actioncomm->userownerid = $user->id; // Owner of action
865 865
         // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label)
866 866
 		$actioncomm->email_msgid   = $object->email_msgid;
867 867
 		$actioncomm->email_from    = $object->email_from;
@@ -874,28 +874,28 @@  discard block
 block discarded – undo
874 874
 
875 875
 		// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
876 876
 		// for such objects because there is already a dedicated field into table llx_actioncomm.
877
-		if (! in_array($elementtype, array('societe','contact','project')))
877
+		if (!in_array($elementtype, array('societe', 'contact', 'project')))
878 878
 		{
879 879
 			$actioncomm->fk_element  = $elementid;
880 880
 			$actioncomm->elementtype = $elementtype;
881 881
 		}
882 882
 
883
-		if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
884
-			$actioncomm->attachedfiles=$object->attachedfiles;
883
+		if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) {
884
+			$actioncomm->attachedfiles = $object->attachedfiles;
885 885
 		}
886
-		if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) {
887
-			$actioncomm->userassigned=$object->sendtouserid;
886
+		if (property_exists($object, 'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid) > 0) {
887
+			$actioncomm->userassigned = $object->sendtouserid;
888 888
 		}
889 889
 
890
-		$ret=$actioncomm->create($user);       // User creating action
890
+		$ret = $actioncomm->create($user); // User creating action
891 891
 
892 892
 		if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO)
893 893
 		{
894
-			if (is_array($object->attachedfiles) && array_key_exists('paths',$object->attachedfiles) && count($object->attachedfiles['paths'])>0) {
895
-				foreach($object->attachedfiles['paths'] as $key=>$filespath) {
894
+			if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) {
895
+				foreach ($object->attachedfiles['paths'] as $key=>$filespath) {
896 896
 					$srcfile = $filespath;
897
-					$destdir = $conf->agenda->dir_output . '/' . $ret;
898
-					$destfile = $destdir . '/' . $object->attachedfiles['names'][$key];
897
+					$destdir = $conf->agenda->dir_output.'/'.$ret;
898
+					$destfile = $destdir.'/'.$object->attachedfiles['names'][$key];
899 899
 					if (dol_mkdir($destdir) >= 0) {
900 900
 						require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
901 901
 						dol_copy($srcfile, $destfile);
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 			}
905 905
 		}
906 906
 
907
-		unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode);	// When several action are called on same object, we must be sure to not reuse value of first action.
907
+		unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action.
908 908
 
909 909
 		if ($ret > 0)
910 910
 		{
@@ -913,9 +913,9 @@  discard block
 block discarded – undo
913 913
 		}
914 914
 		else
915 915
 		{
916
-            $error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
917
-            $this->error=$error;
918
-            $this->errors=$actioncomm->errors;
916
+            $error = "Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors);
917
+            $this->error = $error;
918
+            $this->errors = $actioncomm->errors;
919 919
 
920 920
             dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
921 921
             return -1;
Please login to merge, or discard this patch.
Braces   +273 added lines, -188 removed lines patch added patch discarded remove patch
@@ -71,7 +71,10 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
73 73
 	{
74
-        if (empty($conf->agenda->enabled)) return 0;     // Module not active, we do nothing
74
+        if (empty($conf->agenda->enabled)) {
75
+            return 0;
76
+        }
77
+        // Module not active, we do nothing
75 78
 
76 79
 		$key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
77 80
 
@@ -82,7 +85,9 @@  discard block
 block discarded – undo
82 85
 
83 86
 		$langs->load("agenda");
84 87
 
85
-		if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
88
+		if (empty($object->actiontypecode)) {
89
+		    $object->actiontypecode='AC_OTH_AUTO';
90
+		}
86 91
 
87 92
 		// Actions
88 93
 		if ($action == 'COMPANY_CREATE')
@@ -90,39 +95,46 @@  discard block
 block discarded – undo
90 95
             // Load translation files required by the page
91 96
             $langs->loadLangs(array("agenda","other","companies"));
92 97
 
93
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
98
+            if (empty($object->actionmsg2)) {
99
+                $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
100
+            }
94 101
             $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name);
95
-            if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
102
+            if (! empty($object->prefix)) {
103
+                $object->actionmsg.=" (".$object->prefix.")";
104
+            }
96 105
 
97 106
 			$object->sendtoid=0;
98 107
 			$object->socid=$object->id;
99
-        }
100
-        elseif ($action == 'COMPANY_SENTBYMAIL')
108
+        } elseif ($action == 'COMPANY_SENTBYMAIL')
101 109
         {
102 110
             // Load translation files required by the page
103 111
             $langs->loadLangs(array("agenda","other","orders"));
104 112
 
105
-            if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
113
+            if (empty($object->actionmsg2)) {
114
+                dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
115
+            }
106 116
 
107 117
             // Parameters $object->sendtoid defined by caller
108 118
             //$object->sendtoid=0;
109
-		}
110
-        elseif ($action == 'CONTRACT_VALIDATE')
119
+		} elseif ($action == 'CONTRACT_VALIDATE')
111 120
         {
112 121
             // Load translation files required by the page
113 122
             $langs->loadLangs(array("agenda","other","contracts"));
114 123
 
115
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
124
+            if (empty($object->actionmsg2)) {
125
+                $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
126
+            }
116 127
             $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
117 128
 
118 129
             $object->sendtoid=0;
119
-		}
120
-		elseif ($action == 'CONTRACT_SENTBYMAIL')
130
+		} elseif ($action == 'CONTRACT_SENTBYMAIL')
121 131
 		{
122 132
 			// Load translation files required by the page
123 133
             $langs->loadLangs(array("agenda","other","contracts"));
124 134
 
125
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
135
+			if (empty($object->actionmsg2)) {
136
+			    $object->actionmsg2=$langs->transnoentities("ContractSentByEMail",$object->ref);
137
+			}
126 138
 			if (empty($object->actionmsg))
127 139
 			{
128 140
 				$object->actionmsg=$langs->transnoentities("ContractSentByEMail",$object->ref);
@@ -130,23 +142,25 @@  discard block
 block discarded – undo
130 142
 
131 143
 			// Parameters $object->sendtoid defined by caller
132 144
 			//$object->sendtoid=0;
133
-		}
134
-		elseif ($action == 'PROPAL_VALIDATE')
145
+		} elseif ($action == 'PROPAL_VALIDATE')
135 146
         {
136 147
             // Load translation files required by the page
137 148
             $langs->loadLangs(array("agenda","other","propal"));
138 149
 
139
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
150
+            if (empty($object->actionmsg2)) {
151
+                $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
152
+            }
140 153
             $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
141 154
 
142 155
 			$object->sendtoid=0;
143
-		}
144
-        elseif ($action == 'PROPAL_SENTBYMAIL')
156
+		} elseif ($action == 'PROPAL_SENTBYMAIL')
145 157
         {
146 158
             // Load translation files required by the page
147 159
             $langs->loadLangs(array("agenda","other","propal"));
148 160
 
149
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
161
+            if (empty($object->actionmsg2)) {
162
+                $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
163
+            }
150 164
             if (empty($object->actionmsg))
151 165
             {
152 166
                 $object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
@@ -154,83 +168,91 @@  discard block
 block discarded – undo
154 168
 
155 169
             // Parameters $object->sendtoid defined by caller
156 170
             //$object->sendtoid=0;
157
-		}
158
-		elseif ($action == 'PROPAL_CLOSE_SIGNED')
171
+		} elseif ($action == 'PROPAL_CLOSE_SIGNED')
159 172
         {
160 173
             // Load translation files required by the page
161 174
             $langs->loadLangs(array("agenda","other","propal"));
162 175
 
163
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
176
+            if (empty($object->actionmsg2)) {
177
+                $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
178
+            }
164 179
             $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
165 180
 
166 181
 			$object->sendtoid=0;
167
-		}
168
-		elseif ($action == 'PROPAL_CLASSIFY_BILLED')
182
+		} elseif ($action == 'PROPAL_CLASSIFY_BILLED')
169 183
         {
170 184
             // Load translation files required by the page
171 185
             $langs->loadLangs(array("agenda","other","propal"));
172 186
 
173
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
187
+            if (empty($object->actionmsg2)) {
188
+                $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
189
+            }
174 190
             $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref);
175 191
 
176 192
 			$object->sendtoid=0;
177
-		}
178
-		elseif ($action == 'PROPAL_CLOSE_REFUSED')
193
+		} elseif ($action == 'PROPAL_CLOSE_REFUSED')
179 194
         {
180 195
             // Load translation files required by the page
181 196
             $langs->loadLangs(array("agenda","other","propal"));
182 197
 
183
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
198
+            if (empty($object->actionmsg2)) {
199
+                $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
200
+            }
184 201
             $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
185 202
 
186 203
 			$object->sendtoid=0;
187
-		}
188
-		elseif ($action == 'ORDER_VALIDATE')
204
+		} elseif ($action == 'ORDER_VALIDATE')
189 205
         {
190 206
             // Load translation files required by the page
191 207
             $langs->loadLangs(array("agenda","orders"));
192 208
 
193
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
209
+            if (empty($object->actionmsg2)) {
210
+                $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
211
+            }
194 212
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
195 213
 
196 214
 			$object->sendtoid=0;
197
-		}
198
-		elseif ($action == 'ORDER_CLOSE')
215
+		} elseif ($action == 'ORDER_CLOSE')
199 216
         {
200 217
             // Load translation files required by the page
201 218
             $langs->loadLangs(array("agenda","other","orders"));
202 219
 
203
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
220
+            if (empty($object->actionmsg2)) {
221
+                $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
222
+            }
204 223
             $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref);
205 224
 
206 225
 			$object->sendtoid=0;
207
-		}
208
-		elseif ($action == 'ORDER_CLASSIFY_BILLED')
226
+		} elseif ($action == 'ORDER_CLASSIFY_BILLED')
209 227
         {
210 228
             // Load translation files required by the page
211 229
             $langs->loadLangs(array("agenda","other","orders"));
212 230
 
213
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
231
+            if (empty($object->actionmsg2)) {
232
+                $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
233
+            }
214 234
             $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref);
215 235
 
216 236
 			$object->sendtoid=0;
217
-		}
218
-		elseif ($action == 'ORDER_CANCEL')
237
+		} elseif ($action == 'ORDER_CANCEL')
219 238
         {
220 239
             // Load translation files required by the page
221 240
             $langs->loadLangs(array("agenda","other","orders"));
222 241
 
223
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
242
+            if (empty($object->actionmsg2)) {
243
+                $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
244
+            }
224 245
             $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref);
225 246
 
226 247
 			$object->sendtoid=0;
227
-		}
228
-		elseif ($action == 'ORDER_SENTBYMAIL')
248
+		} elseif ($action == 'ORDER_SENTBYMAIL')
229 249
         {
230 250
             // Load translation files required by the page
231 251
             $langs->loadLangs(array("agenda","other","orders"));
232 252
 
233
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
253
+            if (empty($object->actionmsg2)) {
254
+                $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
255
+            }
234 256
             if (empty($object->actionmsg))
235 257
             {
236 258
                 $object->actionmsg=$langs->transnoentities("OrderSentByEMail",$object->ref);
@@ -238,33 +260,36 @@  discard block
 block discarded – undo
238 260
 
239 261
             // Parameters $object->sendtoid defined by caller
240 262
             //$object->sendtoid=0;
241
-		}
242
-		elseif ($action == 'BILL_VALIDATE')
263
+		} elseif ($action == 'BILL_VALIDATE')
243 264
         {
244 265
             // Load translation files required by the page
245 266
             $langs->loadLangs(array("agenda","other","bills"));
246 267
 
247
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
268
+            if (empty($object->actionmsg2)) {
269
+                $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
270
+            }
248 271
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
249 272
 
250 273
 			$object->sendtoid=0;
251
-		}
252
-		elseif ($action == 'BILL_UNVALIDATE')
274
+		} elseif ($action == 'BILL_UNVALIDATE')
253 275
         {
254 276
            // Load translation files required by the page
255 277
             $langs->loadLangs(array("agenda","other","bills"));
256 278
 
257
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
279
+            if (empty($object->actionmsg2)) {
280
+                $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
281
+            }
258 282
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
259 283
 
260 284
 			$object->sendtoid=0;
261
-		}
262
-        elseif ($action == 'BILL_SENTBYMAIL')
285
+		} elseif ($action == 'BILL_SENTBYMAIL')
263 286
         {
264 287
             // Load translation files required by the page
265 288
             $langs->loadLangs(array("agenda","other","bills"));
266 289
 
267
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
290
+            if (empty($object->actionmsg2)) {
291
+                $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
292
+            }
268 293
             if (empty($object->actionmsg))
269 294
             {
270 295
                 $object->actionmsg=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
@@ -272,8 +297,7 @@  discard block
 block discarded – undo
272 297
 
273 298
             // Parameters $object->sendtoid defined by caller
274 299
             //$object->sendtoid=0;
275
-		}
276
-		elseif ($action == 'BILL_PAYED')
300
+		} elseif ($action == 'BILL_PAYED')
277 301
         {
278 302
             // Load translation files required by the page
279 303
             $langs->loadLangs(array("agenda","other","bills"));
@@ -283,59 +307,64 @@  discard block
 block discarded – undo
283 307
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
284 308
 
285 309
             $object->sendtoid=0;
286
-		}
287
-		elseif ($action == 'BILL_CANCEL')
310
+		} elseif ($action == 'BILL_CANCEL')
288 311
         {
289 312
             // Load translation files required by the page
290 313
             $langs->loadLangs(array("agenda","other","bills"));
291 314
 
292
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
315
+            if (empty($object->actionmsg2)) {
316
+                $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
317
+            }
293 318
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
294 319
 
295 320
             $object->sendtoid=0;
296
-		}
297
-		elseif ($action == 'FICHINTER_CREATE')
321
+		} elseif ($action == 'FICHINTER_CREATE')
298 322
         {
299 323
             // Load translation files required by the page
300 324
             $langs->loadLangs(array("agenda","other","interventions"));
301 325
 
302
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
326
+            if (empty($object->actionmsg2)) {
327
+                $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
328
+            }
303 329
             $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref);
304 330
 
305 331
             $object->sendtoid=0;
306 332
 			$object->fk_element=0;
307 333
 			$object->elementtype='';
308
-		}
309
-		elseif ($action == 'FICHINTER_VALIDATE')
334
+		} elseif ($action == 'FICHINTER_VALIDATE')
310 335
         {
311 336
             // Load translation files required by the page
312 337
             $langs->loadLangs(array("agenda","other","interventions"));
313 338
 
314
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
339
+            if (empty($object->actionmsg2)) {
340
+                $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
341
+            }
315 342
             $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
316 343
 
317 344
             $object->sendtoid=0;
318 345
 			$object->fk_element=0;
319 346
 			$object->elementtype='';
320
-		}
321
-		elseif ($action == 'FICHINTER_MODIFY')
347
+		} elseif ($action == 'FICHINTER_MODIFY')
322 348
         {
323 349
             // Load translation files required by the page
324 350
             $langs->loadLangs(array("agenda","other","interventions"));
325 351
 
326
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
352
+            if (empty($object->actionmsg2)) {
353
+                $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
354
+            }
327 355
             $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref);
328 356
 
329 357
             $object->sendtoid=0;
330 358
 			$object->fk_element=0;
331 359
 			$object->elementtype='';
332
-		}
333
-		elseif ($action == 'FICHINTER_SENTBYMAIL')
360
+		} elseif ($action == 'FICHINTER_SENTBYMAIL')
334 361
         {
335 362
             // Load translation files required by the page
336 363
             $langs->loadLangs(array("agenda","other","interventions"));
337 364
 
338
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
365
+            if (empty($object->actionmsg2)) {
366
+                $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
367
+            }
339 368
             if (empty($object->actionmsg))
340 369
             {
341 370
             	$object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
@@ -343,45 +372,49 @@  discard block
 block discarded – undo
343 372
 
344 373
             // Parameters $object->sendtoid defined by caller
345 374
             //$object->sendtoid=0;
346
-        }
347
-        elseif ($action == 'FICHINTER_CLASSIFY_BILLED')
375
+        } elseif ($action == 'FICHINTER_CLASSIFY_BILLED')
348 376
         {
349 377
             // Load translation files required by the page
350 378
             $langs->loadLangs(array("agenda","other","interventions"));
351 379
 
352
-           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
380
+           	if (empty($object->actionmsg2)) {
381
+           	    $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
382
+           	}
353 383
            	$object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref);
354 384
 
355 385
             $object->sendtoid=0;
356
-        }
357
-	    elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED')
386
+        } elseif ($action == 'FICHINTER_CLASSIFY_UNBILLED')
358 387
         {
359 388
             // Load translation files required by the page
360 389
             $langs->loadLangs(array("agenda","other","interventions"));
361 390
 
362
-           	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
391
+           	if (empty($object->actionmsg2)) {
392
+           	    $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
393
+           	}
363 394
            	$object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref);
364 395
 
365 396
             $object->sendtoid=0;
366
-        }
367
-        elseif ($action == 'FICHINTER_DELETE')
397
+        } elseif ($action == 'FICHINTER_DELETE')
368 398
         {
369 399
             // Load translation files required by the page
370 400
             $langs->loadLangs(array("agenda","other","interventions"));
371 401
 
372
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
402
+            if (empty($object->actionmsg2)) {
403
+                $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
404
+            }
373 405
             $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref);
374 406
 
375 407
             $object->sendtoid=0;
376 408
 			$object->fk_element=0;
377 409
 			$object->elementtype='';
378
-		}
379
-        elseif ($action == 'SHIPPING_VALIDATE')
410
+		} elseif ($action == 'SHIPPING_VALIDATE')
380 411
         {
381 412
             // Load translation files required by the page
382 413
             $langs->loadLangs(array("agenda","other","sendings"));
383 414
 
384
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
415
+        	if (empty($object->actionmsg2)) {
416
+        	    $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
417
+        	}
385 418
         	if (empty($object->actionmsg))
386 419
         	{
387 420
         		$object->actionmsg=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref));
@@ -389,13 +422,14 @@  discard block
 block discarded – undo
389 422
 
390 423
         	// Parameters $object->sendtoid defined by caller
391 424
         	//$object->sendtoid=0;
392
-        }
393
-		elseif ($action == 'SHIPPING_SENTBYMAIL')
425
+        } elseif ($action == 'SHIPPING_SENTBYMAIL')
394 426
         {
395 427
             // Load translation files required by the page
396 428
             $langs->loadLangs(array("agenda","other","sendings"));
397 429
 
398
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
430
+            if (empty($object->actionmsg2)) {
431
+                $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
432
+            }
399 433
             if (empty($object->actionmsg))
400 434
             {
401 435
                 $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref);
@@ -409,7 +443,9 @@  discard block
 block discarded – undo
409 443
             $langs->load("other");
410 444
         	$langs->load("receptions");
411 445
 
412
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
446
+        	if (empty($object->actionmsg2)) {
447
+        	    $object->actionmsg2=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
448
+        	}
413 449
         	if (empty($object->actionmsg))
414 450
         	{
415 451
         		$object->actionmsg=$langs->transnoentities("ReceptionValidated",($object->newref?$object->newref:$object->ref));
@@ -417,14 +453,15 @@  discard block
 block discarded – undo
417 453
 
418 454
         	// Parameters $object->sendtoid defined by caller
419 455
         	//$object->sendtoid=0;
420
-        }
421
-		elseif ($action == 'RECEPTION_SENTBYMAIL')
456
+        } elseif ($action == 'RECEPTION_SENTBYMAIL')
422 457
         {
423 458
             $langs->load("agenda");
424 459
             $langs->load("other");
425 460
             $langs->load("receptions");
426 461
 
427
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
462
+            if (empty($object->actionmsg2)) {
463
+                $object->actionmsg2=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
464
+            }
428 465
             if (empty($object->actionmsg))
429 466
             {
430 467
                 $object->actionmsg=$langs->transnoentities("ReceptionSentByEMail",$object->ref);
@@ -432,23 +469,25 @@  discard block
 block discarded – undo
432 469
 
433 470
             // Parameters $object->sendtoid defined by caller
434 471
             //$object->sendtoid=0;
435
-		}
436
-		elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE')
472
+		} elseif ($action == 'PROPOSAL_SUPPLIER_VALIDATE')
437 473
 		{
438 474
 			// Load translation files required by the page
439 475
             $langs->loadLangs(array("agenda","other","propal"));
440 476
 
441
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
477
+			if (empty($object->actionmsg2)) {
478
+			    $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
479
+			}
442 480
 			$object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
443 481
 
444 482
 			$object->sendtoid=0;
445
-		}
446
-		elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL')
483
+		} elseif ($action == 'PROPOSAL_SUPPLIER_SENTBYMAIL')
447 484
 		{
448 485
 			// Load translation files required by the page
449 486
             $langs->loadLangs(array("agenda","other","propal"));
450 487
 
451
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
488
+			if (empty($object->actionmsg2)) {
489
+			    $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
490
+			}
452 491
 			if (empty($object->actionmsg))
453 492
 			{
454 493
 				$object->actionmsg=$langs->transnoentities("ProposalSentByEMail",$object->ref);
@@ -456,93 +495,102 @@  discard block
 block discarded – undo
456 495
 
457 496
 			// Parameters $object->sendtoid defined by caller
458 497
 			//$object->sendtoid=0;
459
-		}
460
-		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED')
498
+		} elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_SIGNED')
461 499
 		{
462 500
 			// Load translation files required by the page
463 501
             $langs->loadLangs(array("agenda","other","propal"));
464 502
 
465
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
503
+			if (empty($object->actionmsg2)) {
504
+			    $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
505
+			}
466 506
 			$object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
467 507
 
468 508
 			$object->sendtoid=0;
469
-		}
470
-		elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED')
509
+		} elseif ($action == 'PROPOSAL_SUPPLIER_CLOSE_REFUSED')
471 510
 		{
472 511
 			// Load translation files required by the page
473 512
             $langs->loadLangs(array("agenda","other","propal"));
474 513
 
475
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
514
+			if (empty($object->actionmsg2)) {
515
+			    $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
516
+			}
476 517
 			$object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
477 518
 
478 519
 			$object->sendtoid=0;
479
-		}
480
-		elseif ($action == 'ORDER_SUPPLIER_CREATE')
520
+		} elseif ($action == 'ORDER_SUPPLIER_CREATE')
481 521
         {
482 522
             // Load translation files required by the page
483 523
             $langs->loadLangs(array("agenda","other","orders"));
484 524
 
485
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
525
+            if (empty($object->actionmsg2)) {
526
+                $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
527
+            }
486 528
             $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref));
487 529
 
488 530
             $object->sendtoid=0;
489
-		}
490
-		elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
531
+		} elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
491 532
         {
492 533
             // Load translation files required by the page
493 534
             $langs->loadLangs(array("agenda","other","orders"));
494 535
 
495
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
536
+            if (empty($object->actionmsg2)) {
537
+                $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
538
+            }
496 539
             $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
497 540
 
498 541
             $object->sendtoid=0;
499
-		}
500
-		elseif ($action == 'ORDER_SUPPLIER_APPROVE')
542
+		} elseif ($action == 'ORDER_SUPPLIER_APPROVE')
501 543
 		{
502 544
             // Load translation files required by the page
503 545
             $langs->loadLangs(array("agenda","other","orders"));
504 546
 
505
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
547
+			if (empty($object->actionmsg2)) {
548
+			    $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
549
+			}
506 550
 			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
507 551
 
508 552
 			$object->sendtoid=0;
509
-		}
510
-		elseif ($action == 'ORDER_SUPPLIER_REFUSE')
553
+		} elseif ($action == 'ORDER_SUPPLIER_REFUSE')
511 554
 		{
512 555
             // Load translation files required by the page
513 556
             $langs->loadLangs(array("agenda","other","orders"));
514 557
 
515
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
558
+			if (empty($object->actionmsg2)) {
559
+			    $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
560
+			}
516 561
 			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
517 562
 
518 563
 			$object->sendtoid=0;
519
-		}
520
-		elseif ($action == 'ORDER_SUPPLIER_SUBMIT')
564
+		} elseif ($action == 'ORDER_SUPPLIER_SUBMIT')
521 565
         {
522 566
             // Load translation files required by the page
523 567
             $langs->loadLangs(array("agenda","other","orders"));
524 568
 
525
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
569
+            if (empty($object->actionmsg2)) {
570
+                $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
571
+            }
526 572
             $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref));
527 573
 
528 574
             $object->sendtoid=0;
529
-		}
530
-		elseif ($action == 'ORDER_SUPPLIER_RECEIVE')
575
+		} elseif ($action == 'ORDER_SUPPLIER_RECEIVE')
531 576
         {
532 577
             // Load translation files required by the page
533 578
             $langs->loadLangs(array("agenda","other","orders"));
534 579
 
535
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
580
+            if (empty($object->actionmsg2)) {
581
+                $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
582
+            }
536 583
             $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref));
537 584
 
538 585
             $object->sendtoid=0;
539
-		}
540
-		elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
586
+		} elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
541 587
         {
542 588
             // Load translation files required by the page
543 589
             $langs->loadLangs(array("agenda","other","bills","orders"));
544 590
 
545
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
591
+            if (empty($object->actionmsg2)) {
592
+                $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
593
+            }
546 594
             if (empty($object->actionmsg))
547 595
             {
548 596
                 $object->actionmsg=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
@@ -550,46 +598,50 @@  discard block
 block discarded – undo
550 598
 
551 599
             // Parameters $object->sendtoid defined by caller
552 600
             //$object->sendtoid=0;
553
-        }
554
-		elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED')
601
+        } elseif ($action == 'ORDER_SUPPLIER_CLASSIFY_BILLED')
555 602
         {
556 603
             // Load translation files required by the page
557 604
             $langs->loadLangs(array("agenda","other","bills","orders"));
558 605
 
559
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
606
+            if (empty($object->actionmsg2)) {
607
+                $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
608
+            }
560 609
             if (empty($object->actionmsg))
561 610
             {
562 611
                 $object->actionmsg=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref);
563 612
             }
564 613
 
565 614
             $object->sendtoid=0;
566
-        }
567
-		elseif ($action == 'BILL_SUPPLIER_VALIDATE')
615
+        } elseif ($action == 'BILL_SUPPLIER_VALIDATE')
568 616
         {
569 617
             // Load translation files required by the page
570 618
             $langs->loadLangs(array("agenda","other","bills"));
571 619
 
572
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
620
+            if (empty($object->actionmsg2)) {
621
+                $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
622
+            }
573 623
             $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
574 624
 
575 625
             $object->sendtoid=0;
576
-		}
577
-		elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
626
+		} elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
578 627
         {
579 628
             // Load translation files required by the page
580 629
             $langs->loadLangs(array("agenda","other","bills"));
581 630
 
582
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
631
+            if (empty($object->actionmsg2)) {
632
+                $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
633
+            }
583 634
             $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
584 635
 
585 636
             $object->sendtoid=0;
586
-		}
587
-        elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
637
+		} elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
588 638
         {
589 639
             // Load translation files required by the page
590 640
             $langs->loadLangs(array("agenda","other","bills","orders"));
591 641
 
592
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
642
+            if (empty($object->actionmsg2)) {
643
+                $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
644
+            }
593 645
             if (empty($object->actionmsg))
594 646
             {
595 647
                 $object->actionmsg=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
@@ -597,23 +649,25 @@  discard block
 block discarded – undo
597 649
 
598 650
             // Parameters $object->sendtoid defined by caller
599 651
             //$object->sendtoid=0;
600
-        }
601
-		elseif ($action == 'BILL_SUPPLIER_PAYED')
652
+        } elseif ($action == 'BILL_SUPPLIER_PAYED')
602 653
         {
603 654
             // Load translation files required by the page
604 655
             $langs->loadLangs(array("agenda","other","bills"));
605 656
 
606
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
657
+            if (empty($object->actionmsg2)) {
658
+                $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
659
+            }
607 660
             $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
608 661
 
609 662
 			$object->sendtoid=0;
610
-		}
611
-		elseif ($action == 'BILL_SUPPLIER_CANCELED')
663
+		} elseif ($action == 'BILL_SUPPLIER_CANCELED')
612 664
         {
613 665
             // Load translation files required by the page
614 666
             $langs->loadLangs(array("agenda","other","bills"));
615 667
 
616
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
668
+            if (empty($object->actionmsg2)) {
669
+                $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
670
+            }
617 671
             $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
618 672
 
619 673
 			$object->sendtoid=0;
@@ -625,31 +679,35 @@  discard block
 block discarded – undo
625 679
             // Load translation files required by the page
626 680
             $langs->loadLangs(array("agenda","other","members"));
627 681
 
628
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
682
+            if (empty($object->actionmsg2)) {
683
+                $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
684
+            }
629 685
             $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs));
630 686
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
631 687
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
632 688
 
633 689
 			$object->sendtoid=0;
634
-        }
635
-		elseif ($action == 'MEMBER_MODIFY')
690
+        } elseif ($action == 'MEMBER_MODIFY')
636 691
         {
637 692
             // Load translation files required by the page
638 693
             $langs->loadLangs(array("agenda","other","members"));
639 694
 
640
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
695
+            if (empty($object->actionmsg2)) {
696
+                $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
697
+            }
641 698
             $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs));
642 699
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
643 700
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
644 701
 
645 702
             $object->sendtoid=0;
646
-		}
647
-        elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE')
703
+		} elseif ($action == 'MEMBER_SUBSCRIPTION_CREATE')
648 704
         {
649 705
             // Load translation files required by the page
650 706
             $langs->loadLangs(array("agenda","other","members"));
651 707
 
652
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
708
+            if (empty($object->actionmsg2)) {
709
+                $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
710
+            }
653 711
             $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref,$object->getFullName($langs));
654 712
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
655 713
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
@@ -657,14 +715,17 @@  discard block
 block discarded – undo
657 715
             $object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
658 716
 
659 717
 			$object->sendtoid=0;
660
-			if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
661
-        }
662
-        elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY')
718
+			if ($object->fk_soc > 0) {
719
+			    $object->socid=$object->fk_soc;
720
+			}
721
+        } elseif ($action == 'MEMBER_SUBSCRIPTION_MODIFY')
663 722
         {
664 723
         	// Load translation files required by the page
665 724
             $langs->loadLangs(array("agenda","other","members"));
666 725
 
667
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
726
+        	if (empty($object->actionmsg2)) {
727
+        	    $object->actionmsg2=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
728
+        	}
668 729
         	$object->actionmsg=$langs->transnoentities("MemberSubscriptionModifiedInDolibarr",$object->ref,$object->getFullName($langs));
669 730
         	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
670 731
         	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
@@ -672,14 +733,17 @@  discard block
 block discarded – undo
672 733
         	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
673 734
 
674 735
         	$object->sendtoid=0;
675
-        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
676
-        }
677
-        elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE')
736
+        	if ($object->fk_soc > 0) {
737
+        	    $object->socid=$object->fk_soc;
738
+        	}
739
+        } elseif ($action == 'MEMBER_SUBSCRIPTION_DELETE')
678 740
         {
679 741
         	// Load translation files required by the page
680 742
             $langs->loadLangs(array("agenda","other","members"));
681 743
 
682
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
744
+        	if (empty($object->actionmsg2)) {
745
+        	    $object->actionmsg2=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
746
+        	}
683 747
         	$object->actionmsg=$langs->transnoentities("MemberSubscriptionDeletedInDolibarr",$object->ref,$object->getFullName($langs));
684 748
         	$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
685 749
         	$object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
@@ -687,26 +751,30 @@  discard block
 block discarded – undo
687 751
         	$object->actionmsg.="\n".$langs->transnoentities("Period").': '.dol_print_date($object->last_subscription_date_start,'day').' - '.dol_print_date($object->last_subscription_date_end,'day');
688 752
 
689 753
         	$object->sendtoid=0;
690
-        	if ($object->fk_soc > 0) $object->socid=$object->fk_soc;
691
-        }
692
-        elseif ($action == 'MEMBER_RESILIATE')
754
+        	if ($object->fk_soc > 0) {
755
+        	    $object->socid=$object->fk_soc;
756
+        	}
757
+        } elseif ($action == 'MEMBER_RESILIATE')
693 758
         {
694 759
             // Load translation files required by the page
695 760
             $langs->loadLangs(array("agenda","other","members"));
696 761
 
697
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
762
+            if (empty($object->actionmsg2)) {
763
+                $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
764
+            }
698 765
             $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs));
699 766
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
700 767
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
701 768
 
702 769
 			$object->sendtoid=0;
703
-        }
704
-        elseif ($action == 'MEMBER_DELETE')
770
+        } elseif ($action == 'MEMBER_DELETE')
705 771
         {
706 772
             // Load translation files required by the page
707 773
             $langs->loadLangs(array("agenda","other","members"));
708 774
 
709
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
775
+            if (empty($object->actionmsg2)) {
776
+                $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
777
+            }
710 778
             $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs));
711 779
             $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
712 780
             $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type;
@@ -720,29 +788,33 @@  discard block
 block discarded – undo
720 788
             // Load translation files required by the page
721 789
             $langs->loadLangs(array("agenda","other","projects"));
722 790
 
723
-        	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
791
+        	if (empty($object->actionmsg2)) {
792
+        	    $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
793
+        	}
724 794
         	$object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
725 795
         	$object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
726 796
 
727 797
         	$object->sendtoid=0;
728
-        }
729
-        elseif($action == 'PROJECT_VALIDATE')
798
+        } elseif($action == 'PROJECT_VALIDATE')
730 799
         {
731 800
             // Load translation files required by the page
732 801
             $langs->loadLangs(array("agenda","other","projects"));
733 802
 
734
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
803
+            if (empty($object->actionmsg2)) {
804
+                $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
805
+            }
735 806
             $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref);
736 807
             $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref;
737 808
 
738 809
             $object->sendtoid=0;
739
-        }
740
-        elseif($action == 'PROJECT_MODIFY')
810
+        } elseif($action == 'PROJECT_MODIFY')
741 811
         {
742 812
             // Load translation files required by the page
743 813
             $langs->loadLangs(array("agenda","other","projects"));
744 814
 
745
-            if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
815
+            if (empty($object->actionmsg2)) {
816
+                $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
817
+            }
746 818
             $object->actionmsg=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref);
747 819
             $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
748 820
 
@@ -755,31 +827,33 @@  discard block
 block discarded – undo
755 827
             // Load translation files required by the page
756 828
             $langs->loadLangs(array("agenda","other","projects"));
757 829
 
758
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
830
+			if (empty($object->actionmsg2)) {
831
+			    $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
832
+			}
759 833
 			$object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref);
760 834
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
761 835
 
762 836
 			$object->sendtoid=0;
763
-		}
764
-
765
-		elseif($action == 'TASK_MODIFY')
837
+		} elseif($action == 'TASK_MODIFY')
766 838
 		{
767 839
             // Load translation files required by the page
768 840
             $langs->loadLangs(array("agenda","other","projects"));
769 841
 
770
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
842
+			if (empty($object->actionmsg2)) {
843
+			    $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
844
+			}
771 845
 			$object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref);
772 846
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
773 847
 
774 848
 			$object->sendtoid=0;
775
-		}
776
-
777
-		elseif($action == 'TASK_DELETE')
849
+		} elseif($action == 'TASK_DELETE')
778 850
 		{
779 851
             // Load translation files required by the page
780 852
             $langs->loadLangs(array("agenda","other","projects"));
781 853
 
782
-			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
854
+			if (empty($object->actionmsg2)) {
855
+			    $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
856
+			}
783 857
 			$object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
784 858
 			$object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref;
785 859
 
@@ -792,8 +866,12 @@  discard block
 block discarded – undo
792 866
 		    // Load translation files required by the page
793 867
             $langs->loadLangs(array("agenda","other"));
794 868
 
795
-		    if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
796
-		    if (empty($object->actionmsg))  $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
869
+		    if (empty($object->actionmsg2)) {
870
+		        $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref);
871
+		    }
872
+		    if (empty($object->actionmsg)) {
873
+		        $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref);
874
+		    }
797 875
 
798 876
 		    $object->sendtoid=0;
799 877
 		}
@@ -821,18 +899,26 @@  discard block
 block discarded – undo
821 899
         // Set contactforaction if there is only 1 contact.
822 900
         if (is_array($object->sendtoid))
823 901
         {
824
-            if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid));
825
-        }
826
-        else
902
+            if (count($object->sendtoid) == 1) {
903
+                $contactforaction->fetch(reset($object->sendtoid));
904
+            }
905
+        } else
827 906
         {
828
-            if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid);
907
+            if ($object->sendtoid > 0) {
908
+                $contactforaction->fetch($object->sendtoid);
909
+            }
829 910
         }
830 911
         // Set societeforaction.
831
-        if ($object->socid > 0)			$societeforaction->fetch($object->socid);
832
-        elseif ($object->fk_soc > 0)	$societeforaction->fetch($object->fk_soc);
912
+        if ($object->socid > 0) {
913
+            $societeforaction->fetch($object->socid);
914
+        } elseif ($object->fk_soc > 0) {
915
+            $societeforaction->fetch($object->fk_soc);
916
+        }
833 917
 
834 918
         $projectid = isset($object->fk_project)?$object->fk_project:0;
835
-        if ($object->element == 'project') $projectid = $object->id;
919
+        if ($object->element == 'project') {
920
+            $projectid = $object->id;
921
+        }
836 922
 
837 923
         $elementid = $object->id;
838 924
         $elementtype = $object->element;
@@ -910,8 +996,7 @@  discard block
 block discarded – undo
910 996
 		{
911 997
 			$_SESSION['LAST_ACTION_CREATED'] = $ret;
912 998
 			return 1;
913
-		}
914
-		else
999
+		} else
915 1000
 		{
916 1001
             $error ="Failed to insert event : ".$actioncomm->error." ".join(',',$actioncomm->errors);
917 1002
             $this->error=$error;
Please login to merge, or discard this patch.
core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php 3 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -29,33 +29,33 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class InterfaceMailmanSpipsynchro extends DolibarrTriggers
31 31
 {
32
-	public $family = 'mailmanspip';
33
-	public $description = "Triggers of this module allows to synchronize Mailman an Spip.";
34
-
35
-	/**
36
-	 * Version of the trigger
37
-	 * @var string
38
-	 */
39
-	public $version = self::VERSION_DOLIBARR;
40
-
41
-	/**
42
-	 * @var string Image of the trigger
43
-	 */
44
-	public $picto = 'technic';
45
-
46
-	/**
47
-	 * Function called when a Dolibarrr business event is done.
48
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
49
-	 *
50
-	 * @param string		$action		Event action code
51
-	 * @param Object		$object     Object
52
-	 * @param User		    $user       Object user
53
-	 * @param Translate 	$langs      Object langs
54
-	 * @param conf		    $conf       Object conf
55
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
56
-	 */
57
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58
-	{
32
+    public $family = 'mailmanspip';
33
+    public $description = "Triggers of this module allows to synchronize Mailman an Spip.";
34
+
35
+    /**
36
+     * Version of the trigger
37
+     * @var string
38
+     */
39
+    public $version = self::VERSION_DOLIBARR;
40
+
41
+    /**
42
+     * @var string Image of the trigger
43
+     */
44
+    public $picto = 'technic';
45
+
46
+    /**
47
+     * Function called when a Dolibarrr business event is done.
48
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
49
+     *
50
+     * @param string		$action		Event action code
51
+     * @param Object		$object     Object
52
+     * @param User		    $user       Object user
53
+     * @param Translate 	$langs      Object langs
54
+     * @param conf		    $conf       Object conf
55
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
56
+     */
57
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58
+    {
59 59
         if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
60 60
 
61 61
         require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php";
@@ -63,39 +63,39 @@  discard block
 block discarded – undo
63 63
 
64 64
         if ($action == 'CATEGORY_LINK')
65 65
         {
66
-        	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
67
-
68
-        	// We add subscription if we change category (new category may means more mailing-list to subscribe)
69
-        	if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0)
70
-    		{
71
-    			$this->error=$object->context['linkto']->error;
72
-    			$this->errors=$object->context['linkto']->errors;
73
-    			$return=-1;
74
-    		}
75
-			else
76
-			{
77
-				$return=1;
78
-			}
79
-
80
-        	return $return;
66
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
67
+
68
+            // We add subscription if we change category (new category may means more mailing-list to subscribe)
69
+            if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0)
70
+            {
71
+                $this->error=$object->context['linkto']->error;
72
+                $this->errors=$object->context['linkto']->errors;
73
+                $return=-1;
74
+            }
75
+            else
76
+            {
77
+                $return=1;
78
+            }
79
+
80
+            return $return;
81 81
         }
82 82
         elseif ($action == 'CATEGORY_UNLINK')
83 83
         {
84
-        	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
85
-
86
-        	// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
87
-        	if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0)
88
-        	{
89
-        		$this->error=$object->context['unlinkoff']->error;
90
-        		$this->errors=$object->context['unlinkoff']->errors;
91
-        		$return=-1;
92
-        	}
93
-        	else
94
-        	{
95
-        		$return=1;
96
-        	}
97
-
98
-        	return $return;
84
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
85
+
86
+            // We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
87
+            if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0)
88
+            {
89
+                $this->error=$object->context['unlinkoff']->error;
90
+                $this->errors=$object->context['unlinkoff']->errors;
91
+                $return=-1;
92
+            }
93
+            else
94
+            {
95
+                $return=1;
96
+            }
97
+
98
+            return $return;
99 99
         }
100 100
 
101 101
         // Members
@@ -103,37 +103,37 @@  discard block
 block discarded – undo
103 103
         {
104 104
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
105 105
 
106
-			$return=0;
106
+            $return=0;
107 107
             // Add user into some linked tools (mailman, spip, etc...)
108
-			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
109
-			{
110
-				if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email))    // If email has changed we delete mailman subscription for old email
111
-				{
112
-					if ($object->oldcopy->del_to_abo() < 0)
113
-					{
114
-						if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
115
-						$this->errors=$object->oldcopy->errors;
116
-						$return=-1;
117
-					}
118
-					else
119
-					{
120
-						$return=1;
121
-					}
122
-				}
123
-    			// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
124
-    			if ($object->add_to_abo() < 0)
125
-    			{
126
-    				 if (! empty($object->error)) $this->error=$object->error;
127
-    				 $this->errors=$object->errors;
128
-    				 $return=-1;
129
-    			}
130
-				else
131
-				{
132
-					$return=1;
133
-				}
134
-			}
135
-
136
-			return $return;
108
+            if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
109
+            {
110
+                if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email))    // If email has changed we delete mailman subscription for old email
111
+                {
112
+                    if ($object->oldcopy->del_to_abo() < 0)
113
+                    {
114
+                        if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
115
+                        $this->errors=$object->oldcopy->errors;
116
+                        $return=-1;
117
+                    }
118
+                    else
119
+                    {
120
+                        $return=1;
121
+                    }
122
+                }
123
+                // We add subscription if new email or new type (new type may means more mailing-list to subscribe)
124
+                if ($object->add_to_abo() < 0)
125
+                {
126
+                        if (! empty($object->error)) $this->error=$object->error;
127
+                        $this->errors=$object->errors;
128
+                        $return=-1;
129
+                }
130
+                else
131
+                {
132
+                    $return=1;
133
+                }
134
+            }
135
+
136
+            return $return;
137 137
         }
138 138
         elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
139 139
         {
@@ -141,20 +141,20 @@  discard block
 block discarded – undo
141 141
 
142 142
             $return=0;
143 143
             // Remove from external tools (mailman, spip, etc...)
144
-        	if ($object->del_to_abo() < 0)
145
-			{
146
-				if (! empty($object->error)) $this->error=$object->error;
147
-				$this->errors=$object->errors;
148
-				$return=-1;
149
-			}
150
-			else
151
-			{
152
-				$return=1;
153
-			}
154
-
155
-	        return $return;
144
+            if ($object->del_to_abo() < 0)
145
+            {
146
+                if (! empty($object->error)) $this->error=$object->error;
147
+                $this->errors=$object->errors;
148
+                $return=-1;
149
+            }
150
+            else
151
+            {
152
+                $return=1;
153
+            }
154
+
155
+            return $return;
156 156
         }
157 157
 
158
-		return 0;
158
+        return 0;
159 159
     }
160 160
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58 58
 	{
59
-        if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
59
+        if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing
60 60
 
61 61
         require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php";
62 62
         require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
         	// We add subscription if we change category (new category may means more mailing-list to subscribe)
69 69
         	if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0)
70 70
     		{
71
-    			$this->error=$object->context['linkto']->error;
72
-    			$this->errors=$object->context['linkto']->errors;
73
-    			$return=-1;
71
+    			$this->error = $object->context['linkto']->error;
72
+    			$this->errors = $object->context['linkto']->errors;
73
+    			$return = -1;
74 74
     		}
75 75
 			else
76 76
 			{
77
-				$return=1;
77
+				$return = 1;
78 78
 			}
79 79
 
80 80
         	return $return;
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
         	// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
87 87
         	if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0)
88 88
         	{
89
-        		$this->error=$object->context['unlinkoff']->error;
90
-        		$this->errors=$object->context['unlinkoff']->errors;
91
-        		$return=-1;
89
+        		$this->error = $object->context['unlinkoff']->error;
90
+        		$this->errors = $object->context['unlinkoff']->errors;
91
+        		$return = -1;
92 92
         	}
93 93
         	else
94 94
         	{
95
-        		$return=1;
95
+        		$return = 1;
96 96
         	}
97 97
 
98 98
         	return $return;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         {
104 104
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
105 105
 
106
-			$return=0;
106
+			$return = 0;
107 107
             // Add user into some linked tools (mailman, spip, etc...)
108 108
 			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
109 109
 			{
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
 				{
112 112
 					if ($object->oldcopy->del_to_abo() < 0)
113 113
 					{
114
-						if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
115
-						$this->errors=$object->oldcopy->errors;
116
-						$return=-1;
114
+						if (!empty($object->oldcopy->error)) $this->error = $object->oldcopy->error;
115
+						$this->errors = $object->oldcopy->errors;
116
+						$return = -1;
117 117
 					}
118 118
 					else
119 119
 					{
120
-						$return=1;
120
+						$return = 1;
121 121
 					}
122 122
 				}
123 123
     			// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
124 124
     			if ($object->add_to_abo() < 0)
125 125
     			{
126
-    				 if (! empty($object->error)) $this->error=$object->error;
127
-    				 $this->errors=$object->errors;
128
-    				 $return=-1;
126
+    				 if (!empty($object->error)) $this->error = $object->error;
127
+    				 $this->errors = $object->errors;
128
+    				 $return = -1;
129 129
     			}
130 130
 				else
131 131
 				{
132
-					$return=1;
132
+					$return = 1;
133 133
 				}
134 134
 			}
135 135
 
@@ -139,17 +139,17 @@  discard block
 block discarded – undo
139 139
         {
140 140
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
141 141
 
142
-            $return=0;
142
+            $return = 0;
143 143
             // Remove from external tools (mailman, spip, etc...)
144 144
         	if ($object->del_to_abo() < 0)
145 145
 			{
146
-				if (! empty($object->error)) $this->error=$object->error;
147
-				$this->errors=$object->errors;
148
-				$return=-1;
146
+				if (!empty($object->error)) $this->error = $object->error;
147
+				$this->errors = $object->errors;
148
+				$return = -1;
149 149
 			}
150 150
 			else
151 151
 			{
152
-				$return=1;
152
+				$return = 1;
153 153
 			}
154 154
 
155 155
 	        return $return;
Please login to merge, or discard this patch.
Braces   +20 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,7 +56,10 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58 58
 	{
59
-        if (empty($conf->mailmanspip->enabled)) return 0;     // Module not active, we do nothing
59
+        if (empty($conf->mailmanspip->enabled)) {
60
+            return 0;
61
+        }
62
+        // Module not active, we do nothing
60 63
 
61 64
         require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php";
62 65
         require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
@@ -71,15 +74,13 @@  discard block
 block discarded – undo
71 74
     			$this->error=$object->context['linkto']->error;
72 75
     			$this->errors=$object->context['linkto']->errors;
73 76
     			$return=-1;
74
-    		}
75
-			else
77
+    		} else
76 78
 			{
77 79
 				$return=1;
78 80
 			}
79 81
 
80 82
         	return $return;
81
-        }
82
-        elseif ($action == 'CATEGORY_UNLINK')
83
+        } elseif ($action == 'CATEGORY_UNLINK')
83 84
         {
84 85
         	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
85 86
 
@@ -89,8 +90,7 @@  discard block
 block discarded – undo
89 90
         		$this->error=$object->context['unlinkoff']->error;
90 91
         		$this->errors=$object->context['unlinkoff']->errors;
91 92
         		$return=-1;
92
-        	}
93
-        	else
93
+        	} else
94 94
         	{
95 95
         		$return=1;
96 96
         	}
@@ -105,17 +105,18 @@  discard block
 block discarded – undo
105 105
 
106 106
 			$return=0;
107 107
             // Add user into some linked tools (mailman, spip, etc...)
108
-			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))	// TODO Do del/add also if type change
108
+			if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) {
109
+			    // TODO Do del/add also if type change
109 110
 			{
110 111
 				if (is_object($object->oldcopy) && ($object->oldcopy->email != $object->email))    // If email has changed we delete mailman subscription for old email
111 112
 				{
112 113
 					if ($object->oldcopy->del_to_abo() < 0)
113 114
 					{
114 115
 						if (! empty($object->oldcopy->error)) $this->error=$object->oldcopy->error;
116
+			}
115 117
 						$this->errors=$object->oldcopy->errors;
116 118
 						$return=-1;
117
-					}
118
-					else
119
+					} else
119 120
 					{
120 121
 						$return=1;
121 122
 					}
@@ -123,19 +124,19 @@  discard block
 block discarded – undo
123 124
     			// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
124 125
     			if ($object->add_to_abo() < 0)
125 126
     			{
126
-    				 if (! empty($object->error)) $this->error=$object->error;
127
+    				 if (! empty($object->error)) {
128
+    				     $this->error=$object->error;
129
+    				 }
127 130
     				 $this->errors=$object->errors;
128 131
     				 $return=-1;
129
-    			}
130
-				else
132
+    			} else
131 133
 				{
132 134
 					$return=1;
133 135
 				}
134 136
 			}
135 137
 
136 138
 			return $return;
137
-        }
138
-        elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
139
+        } elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
139 140
         {
140 141
             dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
141 142
 
@@ -143,11 +144,12 @@  discard block
 block discarded – undo
143 144
             // Remove from external tools (mailman, spip, etc...)
144 145
         	if ($object->del_to_abo() < 0)
145 146
 			{
146
-				if (! empty($object->error)) $this->error=$object->error;
147
+				if (! empty($object->error)) {
148
+				    $this->error=$object->error;
149
+				}
147 150
 				$this->errors=$object->errors;
148 151
 				$return=-1;
149
-			}
150
-			else
152
+			} else
151 153
 			{
152 154
 				$return=1;
153 155
 			}
Please login to merge, or discard this patch.