Passed
Push — master ( 8f7a8e...7e4a07 )
by Alxarafe
20:11
created
dolibarr/htdocs/core/lib/reception.lib.php 3 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function reception_prepare_head(Reception $object)
36 36
 {
37
-	global $db, $langs, $conf, $user;
37
+    global $db, $langs, $conf, $user;
38 38
 
39
-	$langs->load("sendings");
40
-	$langs->load("deliveries");
39
+    $langs->load("sendings");
40
+    $langs->load("deliveries");
41 41
 
42
-	$h = 0;
43
-	$head = array();
42
+    $h = 0;
43
+    $head = array();
44 44
 
45
-	$head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
46
-	$head[$h][1] = $langs->trans("ReceptionCard");
47
-	$head[$h][2] = 'reception';
48
-	$h++;
45
+    $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
46
+    $head[$h][1] = $langs->trans("ReceptionCard");
47
+    $head[$h][2] = 'reception';
48
+    $h++;
49 49
 
50 50
 	
51 51
 
52
-	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
53
-	{
54
-	    $objectsrc = $object;
55
-	    if ($object->origin == 'commande' && $object->origin_id > 0)
56
-	    {
57
-	        $objectsrc = new Commande($db);
58
-	        $objectsrc->fetch($object->origin_id);
59
-	    }
60
-	    $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
61
-	    $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
62
-    	$head[$h][1] = $langs->trans("ContactsAddresses");
63
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
64
-    	$head[$h][2] = 'contact';
65
-    	$h++;
66
-	}
52
+    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
53
+    {
54
+        $objectsrc = $object;
55
+        if ($object->origin == 'commande' && $object->origin_id > 0)
56
+        {
57
+            $objectsrc = new Commande($db);
58
+            $objectsrc->fetch($object->origin_id);
59
+        }
60
+        $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
61
+        $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
62
+        $head[$h][1] = $langs->trans("ContactsAddresses");
63
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
64
+        $head[$h][2] = 'contact';
65
+        $h++;
66
+    }
67 67
 	
68 68
     $nbNote = 0;
69 69
     if (!empty($object->note_private)) $nbNote++;
70 70
     if (!empty($object->note_public)) $nbNote++;
71
-	$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
72
-	$head[$h][1] = $langs->trans("Notes");
73
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
74
-	$head[$h][2] = 'note';
75
-	$h++;
71
+    $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
72
+    $head[$h][1] = $langs->trans("Notes");
73
+    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
74
+    $head[$h][2] = 'note';
75
+    $h++;
76 76
 	
77 77
 	
78 78
 	
@@ -91,39 +91,39 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function reception_admin_prepare_head()
93 93
 {
94
-	global $langs, $conf, $user;
95
-	$langs->load("receptions");
94
+    global $langs, $conf, $user;
95
+    $langs->load("receptions");
96 96
 
97
-	$h = 0;
98
-	$head = array();
97
+    $h = 0;
98
+    $head = array();
99 99
 	
100
-	$head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
101
-	$head[$h][1] = $langs->trans("Reception");
102
-	$head[$h][2] = 'reception';
103
-	$h++;
100
+    $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
101
+    $head[$h][1] = $langs->trans("Reception");
102
+    $head[$h][2] = 'reception';
103
+    $h++;
104 104
 
105 105
 	
106
-	if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
107
-	{
108
-	$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
109
-	$head[$h][1] = $langs->trans("ExtraFields");
110
-	$head[$h][2] = 'attributes_reception';
111
-	$h++;
112
-	}
106
+    if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
107
+    {
108
+    $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
109
+    $head[$h][1] = $langs->trans("ExtraFields");
110
+    $head[$h][2] = 'attributes_reception';
111
+    $h++;
112
+    }
113 113
 	
114
-	if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
115
-	{
116
-	$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
117
-	$head[$h][1] = $langs->trans("ExtraFieldsLines");
118
-	$head[$h][2] = 'attributeslines_reception';
119
-	$h++;
120
-	}
114
+    if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
115
+    {
116
+    $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
117
+    $head[$h][1] = $langs->trans("ExtraFieldsLines");
118
+    $head[$h][2] = 'attributeslines_reception';
119
+    $h++;
120
+    }
121 121
 	
122 122
 	
123 123
 	
124
-	complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove');
124
+    complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove');
125 125
 
126
-	return $head;
126
+    return $head;
127 127
 }
128 128
 
129 129
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 	        $objectsrc = new Commande($db);
58 58
 	        $objectsrc->fetch($object->origin_id);
59 59
 	    }
60
-	    $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
60
+	    $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
61 61
 	    $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
62 62
     	$head[$h][1] = $langs->trans("ContactsAddresses");
63
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
63
+		if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
64 64
     	$head[$h][2] = 'contact';
65 65
     	$h++;
66 66
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     if (!empty($object->note_public)) $nbNote++;
71 71
 	$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
72 72
 	$head[$h][1] = $langs->trans("Notes");
73
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
73
+	if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
74 74
 	$head[$h][2] = 'note';
75 75
 	$h++;
76 76
 	
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 	
81 81
 
82
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
82
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
83 83
 
84 84
     return $head;
85 85
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	$h++;
104 104
 
105 105
 	
106
-	if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
106
+	if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
107 107
 	{
108 108
 	$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
109 109
 	$head[$h][1] = $langs->trans("ExtraFields");
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	$h++;
112 112
 	}
113 113
 	
114
-	if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
114
+	if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
115 115
 	{
116 116
 	$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
117 117
 	$head[$h][1] = $langs->trans("ExtraFieldsLines");
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	
122 122
 	
123 123
 	
124
-	complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove');
124
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');
125 125
 
126 126
 	return $head;
127 127
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,17 +60,25 @@
 block discarded – undo
60 60
 	    $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
61 61
 	    $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
62 62
     	$head[$h][1] = $langs->trans("ContactsAddresses");
63
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
63
+		if ($nbContact > 0) {
64
+		    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
65
+		}
64 66
     	$head[$h][2] = 'contact';
65 67
     	$h++;
66 68
 	}
67 69
 	
68 70
     $nbNote = 0;
69
-    if (!empty($object->note_private)) $nbNote++;
70
-    if (!empty($object->note_public)) $nbNote++;
71
+    if (!empty($object->note_private)) {
72
+        $nbNote++;
73
+    }
74
+    if (!empty($object->note_public)) {
75
+        $nbNote++;
76
+    }
71 77
 	$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
72 78
 	$head[$h][1] = $langs->trans("Notes");
73
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
79
+	if ($nbNote > 0) {
80
+	    $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
81
+	}
74 82
 	$head[$h][2] = 'note';
75 83
 	$h++;
76 84
 	
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/expensereport.lib.php 3 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -29,53 +29,53 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function expensereport_prepare_head($object)
31 31
 {
32
-	global $db, $langs, $conf;
32
+    global $db, $langs, $conf;
33 33
 
34
-	$h = 0;
35
-	$head = array();
34
+    $h = 0;
35
+    $head = array();
36 36
 
37
-	$head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id;
38
-	$head[$h][1] = $langs->trans("Card");
39
-	$head[$h][2] = 'card';
40
-	$h++;
37
+    $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id;
38
+    $head[$h][1] = $langs->trans("Card");
39
+    $head[$h][2] = 'card';
40
+    $h++;
41 41
 
42
-	// Show more tabs from modules
43
-	// Entries must be declared in modules descriptor with line
42
+    // Show more tabs from modules
43
+    // Entries must be declared in modules descriptor with line
44 44
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
45 45
     // $this->tabs = array('entity:-tabname);   												to remove a tab
46
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
46
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
47 47
 
48
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
49 49
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
50
-	$upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
51
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
50
+    $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
51
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
52 52
     $nbLinks=Link::count($db, $object->element, $object->id);
53
-	$head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54
-	$head[$h][1] = $langs->trans('Documents');
55
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
56
-	$head[$h][2] = 'documents';
57
-	$h++;
58
-
59
-	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60
-	{
61
-	    $nbNote = 0;
62
-	    if(!empty($object->note_private)) $nbNote++;
63
-	    if(!empty($object->note_public)) $nbNote++;
64
-	    $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65
-	    $head[$h][1] = $langs->trans('Notes');
66
-	    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67
-	    $head[$h][2] = 'note';
68
-	    $h++;
69
-	}
70
-
71
-	$head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
72
-	$head[$h][1] = $langs->trans("Info");
73
-	$head[$h][2] = 'info';
74
-	$h++;
75
-
76
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
77
-
78
-	return $head;
53
+    $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54
+    $head[$h][1] = $langs->trans('Documents');
55
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
56
+    $head[$h][2] = 'documents';
57
+    $h++;
58
+
59
+    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60
+    {
61
+        $nbNote = 0;
62
+        if(!empty($object->note_private)) $nbNote++;
63
+        if(!empty($object->note_public)) $nbNote++;
64
+        $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65
+        $head[$h][1] = $langs->trans('Notes');
66
+        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67
+        $head[$h][2] = 'note';
68
+        $h++;
69
+    }
70
+
71
+    $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
72
+    $head[$h][1] = $langs->trans("Info");
73
+    $head[$h][2] = 'info';
74
+    $h++;
75
+
76
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
77
+
78
+    return $head;
79 79
 }
80 80
 
81 81
 /**
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 function payment_expensereport_prepare_head(PaymentExpenseReport $object)
89 89
 {
90 90
 
91
-	global $langs, $conf;
91
+    global $langs, $conf;
92 92
 
93
-	$h = 0;
94
-	$head = array();
93
+    $h = 0;
94
+    $head = array();
95 95
 
96
-	$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
97
-	$head[$h][1] = $langs->trans("Card");
98
-	$head[$h][2] = 'payment';
99
-	$h++;
96
+    $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
97
+    $head[$h][1] = $langs->trans("Card");
98
+    $head[$h][2] = 'payment';
99
+    $h++;
100 100
 
101 101
     // Show more tabs from modules
102 102
     // Entries must be declared in modules descriptor with line
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
     // $this->tabs = array('entity:-tabname);   												to remove a tab
105 105
     complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
106 106
 
107
-	$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
108
-	$head[$h][1] = $langs->trans("Info");
109
-	$head[$h][2] = 'info';
110
-	$h++;
107
+    $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
108
+    $head[$h][1] = $langs->trans("Info");
109
+    $head[$h][2] = 'info';
110
+    $h++;
111 111
 
112
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
112
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
113 113
 
114
-	return $head;
114
+    return $head;
115 115
 }
116 116
 
117 117
 /**
@@ -121,42 +121,42 @@  discard block
 block discarded – undo
121 121
  */
122 122
 function expensereport_admin_prepare_head()
123 123
 {
124
-	global $langs, $conf, $user;
125
-
126
-	$h = 0;
127
-	$head = array();
128
-
129
-	$h = 0;
130
-
131
-	$head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
132
-	$head[$h][1] = $langs->trans("ExpenseReports");
133
-	$head[$h][2] = 'expensereport';
134
-	$h++;
135
-
136
-	if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
137
-	{
138
-		$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
139
-		$head[$h][1] = $langs->trans("ExpenseReportsIk");
140
-		$head[$h][2] = 'expenseik';
141
-		$h++;
142
-	}
143
-
144
-	if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
145
-	{
146
-		$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
147
-		$head[$h][1] = $langs->trans("ExpenseReportsRules");
148
-		$head[$h][2] = 'expenserules';
149
-		$h++;
150
-	}
151
-
152
-	// Show more tabs from modules
153
-	// Entries must be declared in modules descriptor with line
154
-	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
155
-	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
156
-	complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
157
-
158
-	$head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
159
-	$head[$h][1] = $langs->trans("ExtraFields");
124
+    global $langs, $conf, $user;
125
+
126
+    $h = 0;
127
+    $head = array();
128
+
129
+    $h = 0;
130
+
131
+    $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
132
+    $head[$h][1] = $langs->trans("ExpenseReports");
133
+    $head[$h][2] = 'expensereport';
134
+    $h++;
135
+
136
+    if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
137
+    {
138
+        $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
139
+        $head[$h][1] = $langs->trans("ExpenseReportsIk");
140
+        $head[$h][2] = 'expenseik';
141
+        $h++;
142
+    }
143
+
144
+    if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
145
+    {
146
+        $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
147
+        $head[$h][1] = $langs->trans("ExpenseReportsRules");
148
+        $head[$h][2] = 'expenserules';
149
+        $h++;
150
+    }
151
+
152
+    // Show more tabs from modules
153
+    // Entries must be declared in modules descriptor with line
154
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
155
+    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
156
+    complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
157
+
158
+    $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
159
+    $head[$h][1] = $langs->trans("ExtraFields");
160 160
     $head[$h][2] = 'attributes';
161 161
     $h++;
162 162
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     $h++;
168 168
 	*/
169 169
 
170
-	complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
170
+    complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
171 171
 
172 172
     return $head;
173 173
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	$h = 0;
35 35
 	$head = array();
36 36
 
37
-	$head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id;
37
+	$head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id;
38 38
 	$head[$h][1] = $langs->trans("Card");
39 39
 	$head[$h][2] = 'card';
40 40
 	$h++;
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	// Entries must be declared in modules descriptor with line
44 44
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
45 45
     // $this->tabs = array('entity:-tabname);   												to remove a tab
46
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
46
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport');
47 47
 
48 48
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
49 49
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
50
-	$upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
51
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
52
-    $nbLinks=Link::count($db, $object->element, $object->id);
50
+	$upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref);
51
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
52
+    $nbLinks = Link::count($db, $object->element, $object->id);
53 53
 	$head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54 54
 	$head[$h][1] = $langs->trans('Documents');
55
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
55
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>';
56 56
 	$head[$h][2] = 'documents';
57 57
 	$h++;
58 58
 
59 59
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60 60
 	{
61 61
 	    $nbNote = 0;
62
-	    if(!empty($object->note_private)) $nbNote++;
63
-	    if(!empty($object->note_public)) $nbNote++;
62
+	    if (!empty($object->note_private)) $nbNote++;
63
+	    if (!empty($object->note_public)) $nbNote++;
64 64
 	    $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65 65
 	    $head[$h][1] = $langs->trans('Notes');
66
-	    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
66
+	    if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>';
67 67
 	    $head[$h][2] = 'note';
68 68
 	    $h++;
69 69
 	}
70 70
 
71
-	$head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
71
+	$head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id;
72 72
 	$head[$h][1] = $langs->trans("Info");
73 73
 	$head[$h][2] = 'info';
74 74
 	$h++;
75 75
 
76
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
76
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
77 77
 
78 78
 	return $head;
79 79
 }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     // Entries must be declared in modules descriptor with line
103 103
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
104 104
     // $this->tabs = array('entity:-tabname);   												to remove a tab
105
-    complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
105
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport');
106 106
 
107 107
 	$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
108 108
 	$head[$h][1] = $langs->trans("Info");
109 109
 	$head[$h][2] = 'info';
110 110
 	$h++;
111 111
 
112
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
112
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove');
113 113
 
114 114
 	return $head;
115 115
 }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	// Entries must be declared in modules descriptor with line
154 154
 	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
155 155
 	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
156
-	complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
156
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin');
157 157
 
158 158
 	$head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
159 159
 	$head[$h][1] = $langs->trans("ExtraFields");
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     $h++;
168 168
 	*/
169 169
 
170
-	complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
170
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove');
171 171
 
172 172
     return $head;
173 173
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,18 +52,26 @@
 block discarded – undo
52 52
     $nbLinks=Link::count($db, $object->element, $object->id);
53 53
 	$head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54 54
 	$head[$h][1] = $langs->trans('Documents');
55
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
55
+	if (($nbFiles+$nbLinks) > 0) {
56
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
57
+	}
56 58
 	$head[$h][2] = 'documents';
57 59
 	$h++;
58 60
 
59 61
 	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60 62
 	{
61 63
 	    $nbNote = 0;
62
-	    if(!empty($object->note_private)) $nbNote++;
63
-	    if(!empty($object->note_public)) $nbNote++;
64
+	    if(!empty($object->note_private)) {
65
+	        $nbNote++;
66
+	    }
67
+	    if(!empty($object->note_public)) {
68
+	        $nbNote++;
69
+	    }
64 70
 	    $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65 71
 	    $head[$h][1] = $langs->trans('Notes');
66
-	    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
72
+	    if ($nbNote > 0) {
73
+	        $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
74
+	    }
67 75
 	    $head[$h][2] = 'note';
68 76
 	    $h++;
69 77
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/treeview.lib.php 3 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -35,61 +35,61 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function tree_showpad(&$fulltree,$key,$silent=0)
37 37
 {
38
-	$pos=1;
39
-
40
-	// Loop on each pos, because we will output an img for each pos
41
-	while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0)
42
-	{
43
-		// Process for column $pos
44
-
45
-		$atleastoneofthislevelafter=0;
46
-		$nbofdirinsub=0;
47
-		$nbofdocinsub=0;
48
-		$found=0;
49
-		//print 'x'.$key;
50
-		foreach($fulltree as $key2 => $val2)
51
-		{
38
+    $pos=1;
39
+
40
+    // Loop on each pos, because we will output an img for each pos
41
+    while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0)
42
+    {
43
+        // Process for column $pos
44
+
45
+        $atleastoneofthislevelafter=0;
46
+        $nbofdirinsub=0;
47
+        $nbofdocinsub=0;
48
+        $found=0;
49
+        //print 'x'.$key;
50
+        foreach($fulltree as $key2 => $val2)
51
+        {
52 52
             //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level'];
53
-			if ($found == 1) // We are after the entry to show
54
-			{
55
-				if ($fulltree[$key2]['level'] > $pos)
56
-				{
57
-					$nbofdirinsub++;
58
-					if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
59
-				}
60
-				if ($fulltree[$key2]['level'] == $pos)
61
-				{
62
-					$atleastoneofthislevelafter=1;
63
-				}
64
-				if ($fulltree[$key2]['level'] <= $pos)
65
-				{
66
-					break;
67
-				}
68
-			}
69
-			if ($key2 == $key)    // We found ourself, so now every lower level will be counted
70
-			{
71
-				$found=1;
72
-			}
73
-		}
74
-		//print $atleastoneofthislevelafter;
75
-
76
-		if (! $silent)
77
-		{
78
-    		if ($atleastoneofthislevelafter)
79
-    		{
80
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
81
-    			else print img_picto_common('','treemenu/line.gif');
82
-    		}
83
-    		else
84
-    		{
85
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
86
-    			else print img_picto_common('','treemenu/linebottom.gif');
87
-    		}
88
-		}
89
-		$pos++;
90
-	}
91
-
92
-	return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub);
53
+            if ($found == 1) // We are after the entry to show
54
+            {
55
+                if ($fulltree[$key2]['level'] > $pos)
56
+                {
57
+                    $nbofdirinsub++;
58
+                    if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
59
+                }
60
+                if ($fulltree[$key2]['level'] == $pos)
61
+                {
62
+                    $atleastoneofthislevelafter=1;
63
+                }
64
+                if ($fulltree[$key2]['level'] <= $pos)
65
+                {
66
+                    break;
67
+                }
68
+            }
69
+            if ($key2 == $key)    // We found ourself, so now every lower level will be counted
70
+            {
71
+                $found=1;
72
+            }
73
+        }
74
+        //print $atleastoneofthislevelafter;
75
+
76
+        if (! $silent)
77
+        {
78
+            if ($atleastoneofthislevelafter)
79
+            {
80
+                if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
81
+                else print img_picto_common('','treemenu/line.gif');
82
+            }
83
+            else
84
+            {
85
+                if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
86
+                else print img_picto_common('','treemenu/linebottom.gif');
87
+            }
88
+        }
89
+        $pos++;
90
+    }
91
+
92
+    return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub);
93 93
 }
94 94
 
95 95
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
     if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
121 121
 
122 122
     if ($rang == 0)
123
-	{
124
-		// Test also done with jstree and dynatree (not able to have <a> inside label)
125
-		print '<script type="text/javascript" language="javascript">
123
+    {
124
+        // Test also done with jstree and dynatree (not able to have <a> inside label)
125
+        print '<script type="text/javascript" language="javascript">
126 126
 		$(document).ready(function(){
127 127
 			$("#'.$iddivjstree.'").treeview({
128 128
 				collapsed: true,
@@ -136,94 +136,94 @@  discard block
 block discarded – undo
136 136
 		})
137 137
 		</script>';
138 138
 
139
-		print '<ul id="'.$iddivjstree.'">';
140
-	}
141
-
142
-	if ($rang > 50)
143
-	{
144
-	    return;	// Protect against infinite loop. Max 50 depth
145
-	}
146
-
147
-	//ballayage du tableau
148
-	$sizeoftab=count($tab);
149
-	$ulprinted=0;
150
-	for ($x=0; $x < $sizeoftab; $x++)
151
-	{
152
-		//var_dump($tab[$x]);exit;
153
-		// If an element has $pere for parent
154
-		if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
155
-		{
156
-		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
157
-			if (empty($ulprinted) && ! empty($pere['rowid']))
158
-			{
159
-    		    if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
160
-    		    {
161
-    		          dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
162
-    		          continue;
163
-    		    }
139
+        print '<ul id="'.$iddivjstree.'">';
140
+    }
141
+
142
+    if ($rang > 50)
143
+    {
144
+        return;	// Protect against infinite loop. Max 50 depth
145
+    }
146
+
147
+    //ballayage du tableau
148
+    $sizeoftab=count($tab);
149
+    $ulprinted=0;
150
+    for ($x=0; $x < $sizeoftab; $x++)
151
+    {
152
+        //var_dump($tab[$x]);exit;
153
+        // If an element has $pere for parent
154
+        if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
155
+        {
156
+            //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
157
+            if (empty($ulprinted) && ! empty($pere['rowid']))
158
+            {
159
+                if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
160
+                {
161
+                        dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
162
+                        continue;
163
+                }
164 164
 
165 165
                 print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
166
-			}
167
-			print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
168
-			if ($showfk)
169
-			{
170
-			    print '<table class="nobordernopadding centpercent"><tr><td>';
171
-			    print '<strong> &nbsp; ';
172
-			    print $tab[$x]['title'];
173
-			    print '&nbsp; (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
174
-			    print '</td><td align="right">';
175
-			    print $tab[$x]['buttons'];
176
-			    print '</td></tr></table>';
177
-			}
178
-			else
179
-			{
180
-			    print $tab[$x]['entry'];
181
-			}
182
-			//print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
183
-		    $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
184
-			// And now we search all its sons of lower level
185
-			tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
186
-			print '</li>';
187
-		}
188
-		elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
189
-		{
190
-		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
191
-		    if (empty($ulprinted) && ! empty($pere['rowid']))
192
-		    {
193
-		        if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
194
-		        {
195
-		            dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
196
-		            //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.';
166
+            }
167
+            print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
168
+            if ($showfk)
169
+            {
170
+                print '<table class="nobordernopadding centpercent"><tr><td>';
171
+                print '<strong> &nbsp; ';
172
+                print $tab[$x]['title'];
173
+                print '&nbsp; (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
174
+                print '</td><td align="right">';
175
+                print $tab[$x]['buttons'];
176
+                print '</td></tr></table>';
177
+            }
178
+            else
179
+            {
180
+                print $tab[$x]['entry'];
181
+            }
182
+            //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
183
+            $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
184
+            // And now we search all its sons of lower level
185
+            tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
186
+            print '</li>';
187
+        }
188
+        elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
189
+        {
190
+            //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
191
+            if (empty($ulprinted) && ! empty($pere['rowid']))
192
+            {
193
+                if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
194
+                {
195
+                    dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
196
+                    //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.';
197 197
                     continue;
198
-		        }
199
-
200
-		        print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
201
-		    }
202
-			print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
203
-			if ($showfk)
204
-			{
205
-			    print '<table class="nobordernopadding centpercent"><tr><td>';
206
-			    print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
207
-			    print $tab[$x]['title'];
208
-			    print '</a></strong>';
209
-			    print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
210
-			    print '</td><td align="right">';
211
-			    print $tab[$x]['buttons'];
212
-			    print '</td></tr></table>';
213
-			}
214
-			else
215
-			{
216
-			    print $tab[$x]['entry'];
217
-			}
218
-			//print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
219
-			$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
220
-			// And now we search all its sons of lower level
221
-			//print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n";
222
-		    tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
223
-			print '</li>';
224
-		}
225
-	}
226
-	if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
198
+                }
199
+
200
+                print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
201
+            }
202
+            print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
203
+            if ($showfk)
204
+            {
205
+                print '<table class="nobordernopadding centpercent"><tr><td>';
206
+                print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
207
+                print $tab[$x]['title'];
208
+                print '</a></strong>';
209
+                print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
210
+                print '</td><td align="right">';
211
+                print $tab[$x]['buttons'];
212
+                print '</td></tr></table>';
213
+            }
214
+            else
215
+            {
216
+                print $tab[$x]['entry'];
217
+            }
218
+            //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
219
+            $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
220
+            // And now we search all its sons of lower level
221
+            //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n";
222
+            tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
223
+            print '</li>';
224
+        }
225
+    }
226
+    if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
227 227
 
228 228
     if ($rang == 0) print '</ul>';
229 229
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -33,21 +33,21 @@  discard block
 block discarded – undo
33 33
  * @param	int		$silent			Do not output indent and picto, returns only value
34 34
  * @return	integer[]					array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub)
35 35
  */
36
-function tree_showpad(&$fulltree,$key,$silent=0)
36
+function tree_showpad(&$fulltree, $key, $silent = 0)
37 37
 {
38
-	$pos=1;
38
+	$pos = 1;
39 39
 
40 40
 	// Loop on each pos, because we will output an img for each pos
41 41
 	while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0)
42 42
 	{
43 43
 		// Process for column $pos
44 44
 
45
-		$atleastoneofthislevelafter=0;
46
-		$nbofdirinsub=0;
47
-		$nbofdocinsub=0;
48
-		$found=0;
45
+		$atleastoneofthislevelafter = 0;
46
+		$nbofdirinsub = 0;
47
+		$nbofdocinsub = 0;
48
+		$found = 0;
49 49
 		//print 'x'.$key;
50
-		foreach($fulltree as $key2 => $val2)
50
+		foreach ($fulltree as $key2 => $val2)
51 51
 		{
52 52
             //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level'];
53 53
 			if ($found == 1) // We are after the entry to show
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 				if ($fulltree[$key2]['level'] > $pos)
56 56
 				{
57 57
 					$nbofdirinsub++;
58
-					if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
58
+					if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub += $fulltree[$key2]['cachenbofdoc'];
59 59
 				}
60 60
 				if ($fulltree[$key2]['level'] == $pos)
61 61
 				{
62
-					$atleastoneofthislevelafter=1;
62
+					$atleastoneofthislevelafter = 1;
63 63
 				}
64 64
 				if ($fulltree[$key2]['level'] <= $pos)
65 65
 				{
@@ -68,28 +68,28 @@  discard block
 block discarded – undo
68 68
 			}
69 69
 			if ($key2 == $key)    // We found ourself, so now every lower level will be counted
70 70
 			{
71
-				$found=1;
71
+				$found = 1;
72 72
 			}
73 73
 		}
74 74
 		//print $atleastoneofthislevelafter;
75 75
 
76
-		if (! $silent)
76
+		if (!$silent)
77 77
 		{
78 78
     		if ($atleastoneofthislevelafter)
79 79
     		{
80
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
81
-    			else print img_picto_common('','treemenu/line.gif');
80
+    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branch.gif');
81
+    			else print img_picto_common('', 'treemenu/line.gif');
82 82
     		}
83 83
     		else
84 84
     		{
85
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
86
-    			else print img_picto_common('','treemenu/linebottom.gif');
85
+    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branchbottom.gif');
86
+    			else print img_picto_common('', 'treemenu/linebottom.gif');
87 87
     		}
88 88
 		}
89 89
 		$pos++;
90 90
 	}
91 91
 
92
-	return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub);
92
+	return array($atleastoneofthislevelafter, $nbofdirinsub, $nbofdocinsub);
93 93
 }
94 94
 
95 95
 
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
  *  @param  int     $showfk         1=show fk_links to parent into label  (used by menu editor only)
114 114
  *  @return	void
115 115
  */
116
-function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0)
116
+function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoresetalreadyloaded = 0, $showfk = 0)
117 117
 {
118 118
     global $tree_recur_alreadyadded;
119 119
 
120
-    if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
120
+    if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded = array();
121 121
 
122 122
     if ($rang == 0)
123 123
 	{
@@ -141,30 +141,30 @@  discard block
 block discarded – undo
141 141
 
142 142
 	if ($rang > 50)
143 143
 	{
144
-	    return;	// Protect against infinite loop. Max 50 depth
144
+	    return; // Protect against infinite loop. Max 50 depth
145 145
 	}
146 146
 
147 147
 	//ballayage du tableau
148
-	$sizeoftab=count($tab);
149
-	$ulprinted=0;
150
-	for ($x=0; $x < $sizeoftab; $x++)
148
+	$sizeoftab = count($tab);
149
+	$ulprinted = 0;
150
+	for ($x = 0; $x < $sizeoftab; $x++)
151 151
 	{
152 152
 		//var_dump($tab[$x]);exit;
153 153
 		// If an element has $pere for parent
154 154
 		if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
155 155
 		{
156 156
 		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
157
-			if (empty($ulprinted) && ! empty($pere['rowid']))
157
+			if (empty($ulprinted) && !empty($pere['rowid']))
158 158
 			{
159
-    		    if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
159
+    		    if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
160 160
     		    {
161 161
     		          dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
162 162
     		          continue;
163 163
     		    }
164 164
 
165
-                print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
165
+                print '<ul'.(empty($pere['rowid']) ? ' id="treeData"' : '').'>'; $ulprinted++;
166 166
 			}
167
-			print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
167
+			print "\n".'<li '.($tab[$x]['statut'] ? ' class="liuseractive"' : 'class="liuserdisabled"').'>';
168 168
 			if ($showfk)
169 169
 			{
170 170
 			    print '<table class="nobordernopadding centpercent"><tr><td>';
@@ -180,26 +180,26 @@  discard block
 block discarded – undo
180 180
 			    print $tab[$x]['entry'];
181 181
 			}
182 182
 			//print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
183
-		    $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
183
+		    $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1);
184 184
 			// And now we search all its sons of lower level
185
-			tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
185
+			tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk);
186 186
 			print '</li>';
187 187
 		}
188
-		elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
188
+		elseif (!empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
189 189
 		{
190 190
 		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
191
-		    if (empty($ulprinted) && ! empty($pere['rowid']))
191
+		    if (empty($ulprinted) && !empty($pere['rowid']))
192 192
 		    {
193
-		        if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
193
+		        if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
194 194
 		        {
195 195
 		            dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
196 196
 		            //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.';
197 197
                     continue;
198 198
 		        }
199 199
 
200
-		        print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
200
+		        print '<ul'.(empty($pere['rowid']) ? ' id="treeData"' : '').'>'; $ulprinted++;
201 201
 		    }
202
-			print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
202
+			print "\n".'<li '.($tab[$x]['statut'] ? ' class="liuseractive"' : 'class="liuserdisabled"').'>';
203 203
 			if ($showfk)
204 204
 			{
205 205
 			    print '<table class="nobordernopadding centpercent"><tr><td>';
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
 			    print $tab[$x]['entry'];
217 217
 			}
218 218
 			//print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
219
-			$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
219
+			$tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1);
220 220
 			// And now we search all its sons of lower level
221 221
 			//print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n";
222
-		    tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
222
+		    tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk);
223 223
 			print '</li>';
224 224
 		}
225 225
 	}
226
-	if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
226
+	if (!empty($ulprinted) && !empty($pere['rowid'])) { print '</ul>'."\n"; }
227 227
 
228 228
     if ($rang == 0) print '</ul>';
229 229
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -18 removed lines patch added patch discarded remove patch
@@ -50,12 +50,16 @@  discard block
 block discarded – undo
50 50
 		foreach($fulltree as $key2 => $val2)
51 51
 		{
52 52
             //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level'];
53
-			if ($found == 1) // We are after the entry to show
53
+			if ($found == 1) {
54
+			    // We are after the entry to show
54 55
 			{
55 56
 				if ($fulltree[$key2]['level'] > $pos)
56 57
 				{
57 58
 					$nbofdirinsub++;
58
-					if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
59
+			}
60
+					if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) {
61
+					    $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
62
+					}
59 63
 				}
60 64
 				if ($fulltree[$key2]['level'] == $pos)
61 65
 				{
@@ -66,10 +70,12 @@  discard block
 block discarded – undo
66 70
 					break;
67 71
 				}
68 72
 			}
69
-			if ($key2 == $key)    // We found ourself, so now every lower level will be counted
73
+			if ($key2 == $key) {
74
+			    // We found ourself, so now every lower level will be counted
70 75
 			{
71 76
 				$found=1;
72 77
 			}
78
+			}
73 79
 		}
74 80
 		//print $atleastoneofthislevelafter;
75 81
 
@@ -77,13 +83,18 @@  discard block
 block discarded – undo
77 83
 		{
78 84
     		if ($atleastoneofthislevelafter)
79 85
     		{
80
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
81
-    			else print img_picto_common('','treemenu/line.gif');
82
-    		}
83
-    		else
86
+    			if ($fulltree[$key]['level'] == $pos) {
87
+    			    print img_picto_common('','treemenu/branch.gif');
88
+    			} else {
89
+    			    print img_picto_common('','treemenu/line.gif');
90
+    			}
91
+    		} else
84 92
     		{
85
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
86
-    			else print img_picto_common('','treemenu/linebottom.gif');
93
+    			if ($fulltree[$key]['level'] == $pos) {
94
+    			    print img_picto_common('','treemenu/branchbottom.gif');
95
+    			} else {
96
+    			    print img_picto_common('','treemenu/linebottom.gif');
97
+    			}
87 98
     		}
88 99
 		}
89 100
 		$pos++;
@@ -117,7 +128,9 @@  discard block
 block discarded – undo
117 128
 {
118 129
     global $tree_recur_alreadyadded;
119 130
 
120
-    if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
131
+    if ($rang == 0 && empty($donoresetalreadyloaded)) {
132
+        $tree_recur_alreadyadded=array();
133
+    }
121 134
 
122 135
     if ($rang == 0)
123 136
 	{
@@ -174,8 +187,7 @@  discard block
 block discarded – undo
174 187
 			    print '</td><td align="right">';
175 188
 			    print $tab[$x]['buttons'];
176 189
 			    print '</td></tr></table>';
177
-			}
178
-			else
190
+			} else
179 191
 			{
180 192
 			    print $tab[$x]['entry'];
181 193
 			}
@@ -184,8 +196,7 @@  discard block
 block discarded – undo
184 196
 			// And now we search all its sons of lower level
185 197
 			tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
186 198
 			print '</li>';
187
-		}
188
-		elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
199
+		} elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
189 200
 		{
190 201
 		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
191 202
 		    if (empty($ulprinted) && ! empty($pere['rowid']))
@@ -210,8 +221,7 @@  discard block
 block discarded – undo
210 221
 			    print '</td><td align="right">';
211 222
 			    print $tab[$x]['buttons'];
212 223
 			    print '</td></tr></table>';
213
-			}
214
-			else
224
+			} else
215 225
 			{
216 226
 			    print $tab[$x]['entry'];
217 227
 			}
@@ -225,6 +235,8 @@  discard block
 block discarded – undo
225 235
 	}
226 236
 	if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
227 237
 
228
-    if ($rang == 0) print '</ul>';
229
-}
238
+    if ($rang == 0) {
239
+        print '</ul>';
240
+    }
241
+    }
230 242
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/memory.lib.php 3 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 global $shmkeys,$shmoffset;
25 25
 
26 26
 $shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6,
27
-				'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12,
28
-				'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19,
29
-				'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24,
30
-				'donations'=>25,'contracts'=>26);
27
+                'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12,
28
+                'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19,
29
+                'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24,
30
+                'donations'=>25,'contracts'=>26);
31 31
 $shmoffset=1000;	// Max number of entries found into a language file. If too low, some entries will be overwritten.
32 32
 
33 33
 
@@ -41,64 +41,64 @@  discard block
 block discarded – undo
41 41
  */
42 42
 function dol_setcache($memoryid,$data)
43 43
 {
44
-	global $conf;
45
-	$result=0;
44
+    global $conf;
45
+    $result=0;
46 46
 
47
-	// Using a memcached server
48
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
49
-	{
50
-	    global $dolmemcache;
51
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
52
-    	{
53
-       	    $dolmemcache=new Memcached();
54
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
-       		if (! $result) return -1;
57
-       	}
47
+    // Using a memcached server
48
+    if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
49
+    {
50
+        global $dolmemcache;
51
+        if (empty($dolmemcache) || ! is_object($dolmemcache))
52
+        {
53
+                $dolmemcache=new Memcached();
54
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55
+                $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
+                if (! $result) return -1;
57
+            }
58 58
        	
59
-	    $memoryid=session_name().'_'.$memoryid;
60
-		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
61
-		$dolmemcache->add($memoryid,$data);    // This fails if key already exists
62
-		$rescode=$dolmemcache->getResultCode();
63
-		if ($rescode == 0)
64
-		{
65
-			return count($data);
66
-		}
67
-		else
68
-		{
69
-			return -$rescode;
70
-		}
71
-	}
72
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
73
-	{
74
-		global $dolmemcache;
75
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
76
-    	{
77
-       	    $dolmemcache=new Memcache();
78
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
-       		if (! $result) return -1;
81
-       	}
59
+        $memoryid=session_name().'_'.$memoryid;
60
+        //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
61
+        $dolmemcache->add($memoryid,$data);    // This fails if key already exists
62
+        $rescode=$dolmemcache->getResultCode();
63
+        if ($rescode == 0)
64
+        {
65
+            return count($data);
66
+        }
67
+        else
68
+        {
69
+            return -$rescode;
70
+        }
71
+    }
72
+    else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
73
+    {
74
+        global $dolmemcache;
75
+        if (empty($dolmemcache) || ! is_object($dolmemcache))
76
+        {
77
+                $dolmemcache=new Memcache();
78
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79
+                $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
+                if (! $result) return -1;
81
+            }
82 82
 	    
83
-       	$memoryid=session_name().'_'.$memoryid;
84
-		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
85
-		$result=$dolmemcache->add($memoryid,$data);    // This fails if key already exists
86
-		if ($result)
87
-		{
88
-			return count($data);
89
-		}
90
-		else
91
-		{
92
-			return -1;
93
-		}
94
-	}
95
-	// Using shmop
96
-	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
97
-	{
98
-		$result=dol_setshmop($memoryid,$data);
99
-	}
83
+            $memoryid=session_name().'_'.$memoryid;
84
+        //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
85
+        $result=$dolmemcache->add($memoryid,$data);    // This fails if key already exists
86
+        if ($result)
87
+        {
88
+            return count($data);
89
+        }
90
+        else
91
+        {
92
+            return -1;
93
+        }
94
+    }
95
+    // Using shmop
96
+    else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
97
+    {
98
+        $result=dol_setshmop($memoryid,$data);
99
+    }
100 100
 
101
-	return $result;
101
+    return $result;
102 102
 }
103 103
 
104 104
 /**
@@ -109,69 +109,69 @@  discard block
 block discarded – undo
109 109
  */
110 110
 function dol_getcache($memoryid)
111 111
 {
112
-	global $conf;
112
+    global $conf;
113 113
 
114
-	// Using a memcached server
115
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
116
-	{
117
-		global $m;
118
-		if (empty($m) || ! is_object($m))
119
-    	{
114
+    // Using a memcached server
115
+    if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
116
+    {
117
+        global $m;
118
+        if (empty($m) || ! is_object($m))
119
+        {
120 120
             $m=new Memcached();
121
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
-       		if (! $result) return -1;
124
-       	}
121
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122
+                $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
+                if (! $result) return -1;
124
+            }
125 125
 	    
126
-		$memoryid=session_name().'_'.$memoryid;
127
-		//$m->setOption(Memcached::OPT_COMPRESSION, false);
128
-		//print "Get memoryid=".$memoryid;
129
-		$data=$m->get($memoryid);
130
-		$rescode=$m->getResultCode();
131
-		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
132
-		//var_dump($data);
133
-		if ($rescode == 0)
134
-		{
135
-			return $data;
136
-		}
137
-		else
138
-		{
139
-			return -$rescode;
140
-		}
141
-	}
142
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
143
-	{
144
-		global $m;
145
-		if (empty($m) || ! is_object($m))
146
-    	{
147
-       	    $m=new Memcache();
148
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
-       		if (! $result) return -1;
151
-       	}
126
+        $memoryid=session_name().'_'.$memoryid;
127
+        //$m->setOption(Memcached::OPT_COMPRESSION, false);
128
+        //print "Get memoryid=".$memoryid;
129
+        $data=$m->get($memoryid);
130
+        $rescode=$m->getResultCode();
131
+        //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
132
+        //var_dump($data);
133
+        if ($rescode == 0)
134
+        {
135
+            return $data;
136
+        }
137
+        else
138
+        {
139
+            return -$rescode;
140
+        }
141
+    }
142
+    else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
143
+    {
144
+        global $m;
145
+        if (empty($m) || ! is_object($m))
146
+        {
147
+                $m=new Memcache();
148
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149
+                $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
+                if (! $result) return -1;
151
+            }
152 152
 	    
153
-       	$memoryid=session_name().'_'.$memoryid;
154
-		//$m->setOption(Memcached::OPT_COMPRESSION, false);
155
-		$data=$m->get($memoryid);
156
-		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
157
-		//var_dump($data);
158
-		if ($data)
159
-		{
160
-			return $data;
161
-		}
162
-		else
163
-		{
164
-			return -1;
165
-		}
166
-	}
167
-	// Using shmop
168
-	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
169
-	{
170
-		$data=dol_getshmop($memoryid);
171
-		return $data;
172
-	}
153
+            $memoryid=session_name().'_'.$memoryid;
154
+        //$m->setOption(Memcached::OPT_COMPRESSION, false);
155
+        $data=$m->get($memoryid);
156
+        //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
157
+        //var_dump($data);
158
+        if ($data)
159
+        {
160
+            return $data;
161
+        }
162
+        else
163
+        {
164
+            return -1;
165
+        }
166
+    }
167
+    // Using shmop
168
+    else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
169
+    {
170
+        $data=dol_getshmop($memoryid);
171
+        return $data;
172
+    }
173 173
 
174
-	return 0;
174
+    return 0;
175 175
 }
176 176
 
177 177
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function dol_getshmopaddress($memoryid)
186 186
 {
187
-	global $shmkeys,$shmoffset;
188
-	if (empty($shmkeys[$memoryid])) return 0;
189
-	return $shmkeys[$memoryid]+$shmoffset;
187
+    global $shmkeys,$shmoffset;
188
+    if (empty($shmkeys[$memoryid])) return 0;
189
+    return $shmkeys[$memoryid]+$shmoffset;
190 190
 }
191 191
 
192 192
 /**
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function dol_listshmop()
198 198
 {
199
-	global $shmkeys,$shmoffset;
199
+    global $shmkeys,$shmoffset;
200 200
 
201
-	$resarray=array();
202
-	foreach($shmkeys as $key => $val)
203
-	{
204
-		$result=dol_getshmop($key);
205
-		if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
206
-	}
207
-	return $resarray;
201
+    $resarray=array();
202
+    foreach($shmkeys as $key => $val)
203
+    {
204
+        $result=dol_getshmop($key);
205
+        if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
206
+    }
207
+    return $resarray;
208 208
 }
209 209
 
210 210
 /**
@@ -216,31 +216,31 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function dol_setshmop($memoryid,$data)
218 218
 {
219
-	global $shmkeys,$shmoffset;
219
+    global $shmkeys,$shmoffset;
220 220
 
221
-	//print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
223
-	$shmkey=dol_getshmopaddress($memoryid);
224
-	$newdata=serialize($data);
225
-	$size=strlen($newdata);
226
-	//print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
227
-	$handle=shmop_open($shmkey,'c',0644,6+$size);
228
-	if ($handle)
229
-	{
230
-		$shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
231
-		$shm_bytes_written2=shmop_write($handle,$newdata,6);
232
-		if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
233
-		{
234
-   			print "Couldn't write the entire length of data\n";
235
-		}
236
-		shmop_close($handle);
237
-		return ($shm_bytes_written1+$shm_bytes_written2);
238
-	}
239
-	else
240
-	{
241
-		print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size;
242
-		return -1;
243
-	}
221
+    //print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
+    if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
223
+    $shmkey=dol_getshmopaddress($memoryid);
224
+    $newdata=serialize($data);
225
+    $size=strlen($newdata);
226
+    //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
227
+    $handle=shmop_open($shmkey,'c',0644,6+$size);
228
+    if ($handle)
229
+    {
230
+        $shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
231
+        $shm_bytes_written2=shmop_write($handle,$newdata,6);
232
+        if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
233
+        {
234
+                print "Couldn't write the entire length of data\n";
235
+        }
236
+        shmop_close($handle);
237
+        return ($shm_bytes_written1+$shm_bytes_written2);
238
+    }
239
+    else
240
+    {
241
+        print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size;
242
+        return -1;
243
+    }
244 244
 }
245 245
 
246 246
 /**
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function dol_getshmop($memoryid)
253 253
 {
254
-	global $shmkeys,$shmoffset;
254
+    global $shmkeys,$shmoffset;
255 255
 
256
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
257
-	$shmkey=dol_getshmopaddress($memoryid);
258
-	//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259
-	$handle=@shmop_open($shmkey,'a',0,0);
260
-	if ($handle)
261
-	{
262
-		$size=trim(shmop_read($handle,0,6));
263
-		if ($size) $data=unserialize(shmop_read($handle,6,$size));
264
-		else return -1;
265
-		shmop_close($handle);
266
-	}
267
-	else
268
-	{
269
-		return -2;
270
-	}
271
-	return $data;
256
+    if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
257
+    $shmkey=dol_getshmopaddress($memoryid);
258
+    //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259
+    $handle=@shmop_open($shmkey,'a',0,0);
260
+    if ($handle)
261
+    {
262
+        $size=trim(shmop_read($handle,0,6));
263
+        if ($size) $data=unserialize(shmop_read($handle,6,$size));
264
+        else return -1;
265
+        shmop_close($handle);
266
+    }
267
+    else
268
+    {
269
+        return -2;
270
+    }
271
+    return $data;
272 272
 }
273 273
 
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *  \brief		Set of function for memory/cache management
22 22
  */
23 23
 
24
-global $shmkeys,$shmoffset;
24
+global $shmkeys, $shmoffset;
25 25
 
26
-$shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6,
27
-				'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12,
28
-				'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19,
29
-				'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24,
30
-				'donations'=>25,'contracts'=>26);
31
-$shmoffset=1000;	// Max number of entries found into a language file. If too low, some entries will be overwritten.
26
+$shmkeys = array('main'=>1, 'admin'=>2, 'dict'=>3, 'companies'=>4, 'suppliers'=>5, 'products'=>6,
27
+				'commercial'=>7, 'compta'=>8, 'projects'=>9, 'cashdesk'=>10, 'agenda'=>11, 'bills'=>12,
28
+				'propal'=>13, 'boxes'=>14, 'banks'=>15, 'other'=>16, 'errors'=>17, 'members'=>18, 'ecm'=>19,
29
+				'orders'=>20, 'users'=>21, 'help'=>22, 'stocks'=>23, 'interventions'=>24,
30
+				'donations'=>25, 'contracts'=>26);
31
+$shmoffset = 1000; // Max number of entries found into a language file. If too low, some entries will be overwritten.
32 32
 
33 33
 
34 34
 
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
  * 	@param	string		$data			Data to save
40 40
  * 	@return	int							<0 if KO, Nb of bytes written if OK
41 41
  */
42
-function dol_setcache($memoryid,$data)
42
+function dol_setcache($memoryid, $data)
43 43
 {
44 44
 	global $conf;
45
-	$result=0;
45
+	$result = 0;
46 46
 
47 47
 	// Using a memcached server
48
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
48
+	if (!empty($conf->memcached->enabled) && class_exists('Memcached'))
49 49
 	{
50 50
 	    global $dolmemcache;
51
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
51
+		if (empty($dolmemcache) || !is_object($dolmemcache))
52 52
     	{
53
-       	    $dolmemcache=new Memcached();
54
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
-       		if (! $result) return -1;
53
+       	    $dolmemcache = new Memcached();
54
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
55
+       		$result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
56
+       		if (!$result) return -1;
57 57
        	}
58 58
        	
59
-	    $memoryid=session_name().'_'.$memoryid;
59
+	    $memoryid = session_name().'_'.$memoryid;
60 60
 		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
61
-		$dolmemcache->add($memoryid,$data);    // This fails if key already exists
62
-		$rescode=$dolmemcache->getResultCode();
61
+		$dolmemcache->add($memoryid, $data); // This fails if key already exists
62
+		$rescode = $dolmemcache->getResultCode();
63 63
 		if ($rescode == 0)
64 64
 		{
65 65
 			return count($data);
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 			return -$rescode;
70 70
 		}
71 71
 	}
72
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
72
+	else if (!empty($conf->memcached->enabled) && class_exists('Memcache'))
73 73
 	{
74 74
 		global $dolmemcache;
75
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
75
+		if (empty($dolmemcache) || !is_object($dolmemcache))
76 76
     	{
77
-       	    $dolmemcache=new Memcache();
78
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
-       		if (! $result) return -1;
77
+       	    $dolmemcache = new Memcache();
78
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
79
+       		$result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
80
+       		if (!$result) return -1;
81 81
        	}
82 82
 	    
83
-       	$memoryid=session_name().'_'.$memoryid;
83
+       	$memoryid = session_name().'_'.$memoryid;
84 84
 		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
85
-		$result=$dolmemcache->add($memoryid,$data);    // This fails if key already exists
85
+		$result = $dolmemcache->add($memoryid, $data); // This fails if key already exists
86 86
 		if ($result)
87 87
 		{
88 88
 			return count($data);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	// Using shmop
96 96
 	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
97 97
 	{
98
-		$result=dol_setshmop($memoryid,$data);
98
+		$result = dol_setshmop($memoryid, $data);
99 99
 	}
100 100
 
101 101
 	return $result;
@@ -112,22 +112,22 @@  discard block
 block discarded – undo
112 112
 	global $conf;
113 113
 
114 114
 	// Using a memcached server
115
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
115
+	if (!empty($conf->memcached->enabled) && class_exists('Memcached'))
116 116
 	{
117 117
 		global $m;
118
-		if (empty($m) || ! is_object($m))
118
+		if (empty($m) || !is_object($m))
119 119
     	{
120
-            $m=new Memcached();
121
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
-       		if (! $result) return -1;
120
+            $m = new Memcached();
121
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
122
+       		$result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
123
+       		if (!$result) return -1;
124 124
        	}
125 125
 	    
126
-		$memoryid=session_name().'_'.$memoryid;
126
+		$memoryid = session_name().'_'.$memoryid;
127 127
 		//$m->setOption(Memcached::OPT_COMPRESSION, false);
128 128
 		//print "Get memoryid=".$memoryid;
129
-		$data=$m->get($memoryid);
130
-		$rescode=$m->getResultCode();
129
+		$data = $m->get($memoryid);
130
+		$rescode = $m->getResultCode();
131 131
 		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
132 132
 		//var_dump($data);
133 133
 		if ($rescode == 0)
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
 			return -$rescode;
140 140
 		}
141 141
 	}
142
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
142
+	else if (!empty($conf->memcached->enabled) && class_exists('Memcache'))
143 143
 	{
144 144
 		global $m;
145
-		if (empty($m) || ! is_object($m))
145
+		if (empty($m) || !is_object($m))
146 146
     	{
147
-       	    $m=new Memcache();
148
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
-       		if (! $result) return -1;
147
+       	    $m = new Memcache();
148
+       		$tmparray = explode(':', $conf->global->MEMCACHED_SERVER);
149
+       		$result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
150
+       		if (!$result) return -1;
151 151
        	}
152 152
 	    
153
-       	$memoryid=session_name().'_'.$memoryid;
153
+       	$memoryid = session_name().'_'.$memoryid;
154 154
 		//$m->setOption(Memcached::OPT_COMPRESSION, false);
155
-		$data=$m->get($memoryid);
155
+		$data = $m->get($memoryid);
156 156
 		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
157 157
 		//var_dump($data);
158 158
 		if ($data)
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	// Using shmop
168 168
 	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
169 169
 	{
170
-		$data=dol_getshmop($memoryid);
170
+		$data = dol_getshmop($memoryid);
171 171
 		return $data;
172 172
 	}
173 173
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function dol_getshmopaddress($memoryid)
186 186
 {
187
-	global $shmkeys,$shmoffset;
187
+	global $shmkeys, $shmoffset;
188 188
 	if (empty($shmkeys[$memoryid])) return 0;
189
-	return $shmkeys[$memoryid]+$shmoffset;
189
+	return $shmkeys[$memoryid] + $shmoffset;
190 190
 }
191 191
 
192 192
 /**
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function dol_listshmop()
198 198
 {
199
-	global $shmkeys,$shmoffset;
199
+	global $shmkeys, $shmoffset;
200 200
 
201
-	$resarray=array();
202
-	foreach($shmkeys as $key => $val)
201
+	$resarray = array();
202
+	foreach ($shmkeys as $key => $val)
203 203
 	{
204
-		$result=dol_getshmop($key);
205
-		if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
204
+		$result = dol_getshmop($key);
205
+		if (!is_numeric($result) || $result > 0) $resarray[$key] = $result;
206 206
 	}
207 207
 	return $resarray;
208 208
 }
@@ -214,27 +214,27 @@  discard block
 block discarded – undo
214 214
  * 	@param	string	$data			Data to save
215 215
  * 	@return	int						<0 if KO, Nb of bytes written if OK
216 216
  */
217
-function dol_setshmop($memoryid,$data)
217
+function dol_setshmop($memoryid, $data)
218 218
 {
219
-	global $shmkeys,$shmoffset;
219
+	global $shmkeys, $shmoffset;
220 220
 
221 221
 	//print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
223
-	$shmkey=dol_getshmopaddress($memoryid);
224
-	$newdata=serialize($data);
225
-	$size=strlen($newdata);
222
+	if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0;
223
+	$shmkey = dol_getshmopaddress($memoryid);
224
+	$newdata = serialize($data);
225
+	$size = strlen($newdata);
226 226
 	//print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
227
-	$handle=shmop_open($shmkey,'c',0644,6+$size);
227
+	$handle = shmop_open($shmkey, 'c', 0644, 6 + $size);
228 228
 	if ($handle)
229 229
 	{
230
-		$shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
231
-		$shm_bytes_written2=shmop_write($handle,$newdata,6);
232
-		if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
230
+		$shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0);
231
+		$shm_bytes_written2 = shmop_write($handle, $newdata, 6);
232
+		if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata)))
233 233
 		{
234 234
    			print "Couldn't write the entire length of data\n";
235 235
 		}
236 236
 		shmop_close($handle);
237
-		return ($shm_bytes_written1+$shm_bytes_written2);
237
+		return ($shm_bytes_written1 + $shm_bytes_written2);
238 238
 	}
239 239
 	else
240 240
 	{
@@ -251,16 +251,16 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function dol_getshmop($memoryid)
253 253
 {
254
-	global $shmkeys,$shmoffset;
254
+	global $shmkeys, $shmoffset;
255 255
 
256
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
257
-	$shmkey=dol_getshmopaddress($memoryid);
256
+	if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) return 0;
257
+	$shmkey = dol_getshmopaddress($memoryid);
258 258
 	//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259
-	$handle=@shmop_open($shmkey,'a',0,0);
259
+	$handle = @shmop_open($shmkey, 'a', 0, 0);
260 260
 	if ($handle)
261 261
 	{
262
-		$size=trim(shmop_read($handle,0,6));
263
-		if ($size) $data=unserialize(shmop_read($handle,6,$size));
262
+		$size = trim(shmop_read($handle, 0, 6));
263
+		if ($size) $data = unserialize(shmop_read($handle, 6, $size));
264 264
 		else return -1;
265 265
 		shmop_close($handle);
266 266
 	}
Please login to merge, or discard this patch.
Braces   +37 added lines, -26 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
        	    $dolmemcache=new Memcached();
54 54
        		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55 55
        		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
-       		if (! $result) return -1;
56
+       		if (! $result) {
57
+       		    return -1;
58
+       		}
57 59
        	}
58 60
        	
59 61
 	    $memoryid=session_name().'_'.$memoryid;
@@ -63,13 +65,11 @@  discard block
 block discarded – undo
63 65
 		if ($rescode == 0)
64 66
 		{
65 67
 			return count($data);
66
-		}
67
-		else
68
+		} else
68 69
 		{
69 70
 			return -$rescode;
70 71
 		}
71
-	}
72
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
72
+	} else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
73 73
 	{
74 74
 		global $dolmemcache;
75 75
 		if (empty($dolmemcache) || ! is_object($dolmemcache))
@@ -77,7 +77,9 @@  discard block
 block discarded – undo
77 77
        	    $dolmemcache=new Memcache();
78 78
        		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79 79
        		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
-       		if (! $result) return -1;
80
+       		if (! $result) {
81
+       		    return -1;
82
+       		}
81 83
        	}
82 84
 	    
83 85
        	$memoryid=session_name().'_'.$memoryid;
@@ -86,8 +88,7 @@  discard block
 block discarded – undo
86 88
 		if ($result)
87 89
 		{
88 90
 			return count($data);
89
-		}
90
-		else
91
+		} else
91 92
 		{
92 93
 			return -1;
93 94
 		}
@@ -120,7 +121,9 @@  discard block
 block discarded – undo
120 121
             $m=new Memcached();
121 122
        		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122 123
        		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
-       		if (! $result) return -1;
124
+       		if (! $result) {
125
+       		    return -1;
126
+       		}
124 127
        	}
125 128
 	    
126 129
 		$memoryid=session_name().'_'.$memoryid;
@@ -133,13 +136,11 @@  discard block
 block discarded – undo
133 136
 		if ($rescode == 0)
134 137
 		{
135 138
 			return $data;
136
-		}
137
-		else
139
+		} else
138 140
 		{
139 141
 			return -$rescode;
140 142
 		}
141
-	}
142
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
143
+	} else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
143 144
 	{
144 145
 		global $m;
145 146
 		if (empty($m) || ! is_object($m))
@@ -147,7 +148,9 @@  discard block
 block discarded – undo
147 148
        	    $m=new Memcache();
148 149
        		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149 150
        		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
-       		if (! $result) return -1;
151
+       		if (! $result) {
152
+       		    return -1;
153
+       		}
151 154
        	}
152 155
 	    
153 156
        	$memoryid=session_name().'_'.$memoryid;
@@ -158,8 +161,7 @@  discard block
 block discarded – undo
158 161
 		if ($data)
159 162
 		{
160 163
 			return $data;
161
-		}
162
-		else
164
+		} else
163 165
 		{
164 166
 			return -1;
165 167
 		}
@@ -185,7 +187,9 @@  discard block
 block discarded – undo
185 187
 function dol_getshmopaddress($memoryid)
186 188
 {
187 189
 	global $shmkeys,$shmoffset;
188
-	if (empty($shmkeys[$memoryid])) return 0;
190
+	if (empty($shmkeys[$memoryid])) {
191
+	    return 0;
192
+	}
189 193
 	return $shmkeys[$memoryid]+$shmoffset;
190 194
 }
191 195
 
@@ -202,7 +206,9 @@  discard block
 block discarded – undo
202 206
 	foreach($shmkeys as $key => $val)
203 207
 	{
204 208
 		$result=dol_getshmop($key);
205
-		if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
209
+		if (! is_numeric($result) || $result > 0) {
210
+		    $resarray[$key]=$result;
211
+		}
206 212
 	}
207 213
 	return $resarray;
208 214
 }
@@ -219,7 +225,9 @@  discard block
 block discarded – undo
219 225
 	global $shmkeys,$shmoffset;
220 226
 
221 227
 	//print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
228
+	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) {
229
+	    return 0;
230
+	}
223 231
 	$shmkey=dol_getshmopaddress($memoryid);
224 232
 	$newdata=serialize($data);
225 233
 	$size=strlen($newdata);
@@ -235,8 +243,7 @@  discard block
 block discarded – undo
235 243
 		}
236 244
 		shmop_close($handle);
237 245
 		return ($shm_bytes_written1+$shm_bytes_written2);
238
-	}
239
-	else
246
+	} else
240 247
 	{
241 248
 		print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size;
242 249
 		return -1;
@@ -253,18 +260,22 @@  discard block
 block discarded – undo
253 260
 {
254 261
 	global $shmkeys,$shmoffset;
255 262
 
256
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
263
+	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) {
264
+	    return 0;
265
+	}
257 266
 	$shmkey=dol_getshmopaddress($memoryid);
258 267
 	//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259 268
 	$handle=@shmop_open($shmkey,'a',0,0);
260 269
 	if ($handle)
261 270
 	{
262 271
 		$size=trim(shmop_read($handle,0,6));
263
-		if ($size) $data=unserialize(shmop_read($handle,6,$size));
264
-		else return -1;
272
+		if ($size) {
273
+		    $data=unserialize(shmop_read($handle,6,$size));
274
+		} else {
275
+		    return -1;
276
+		}
265 277
 		shmop_close($handle);
266
-	}
267
-	else
278
+	} else
268 279
 	{
269 280
 		return -2;
270 281
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/xcal.lib.php 3 patches
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -34,78 +34,78 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function build_calfile($format,$title,$desc,$events_array,$outputfile)
36 36
 {
37
-	global $conf,$langs;
37
+    global $conf,$langs;
38 38
 
39
-	dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
39
+    dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
40 40
 
41
-	if (empty($outputfile)) return -1;
41
+    if (empty($outputfile)) return -1;
42 42
 
43 43
     // Note: A cal file is an UTF8 encoded file
44
-	$calfileh=fopen($outputfile,'w');
45
-	if ($calfileh)
46
-	{
47
-	    include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48
-		$now=dol_now();
49
-
50
-		$encoding='';
51
-		if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
52
-
53
-		// Print header
54
-		fwrite($calfileh,"BEGIN:VCALENDAR\n");
55
-		fwrite($calfileh,"VERSION:2.0\n");
56
-		fwrite($calfileh,"METHOD:PUBLISH\n");
57
-		//fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
58
-		fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
-		fwrite($calfileh,"CALSCALE:GREGORIAN\n");
60
-		fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
44
+    $calfileh=fopen($outputfile,'w');
45
+    if ($calfileh)
46
+    {
47
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48
+        $now=dol_now();
49
+
50
+        $encoding='';
51
+        if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
52
+
53
+        // Print header
54
+        fwrite($calfileh,"BEGIN:VCALENDAR\n");
55
+        fwrite($calfileh,"VERSION:2.0\n");
56
+        fwrite($calfileh,"METHOD:PUBLISH\n");
57
+        //fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
58
+        fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
+        fwrite($calfileh,"CALSCALE:GREGORIAN\n");
60
+        fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
61 61
         fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n");
62 62
         //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
63 63
         if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
64 64
         && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){
65
-	        $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
66
-	        $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
67
-	        $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
68
-	        fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
65
+            $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
66
+            $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
67
+            $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
68
+            fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
69 69
         }
70 70
 
71
-		foreach ($events_array as $key => $event)
72
-		{
73
-			$eventqualified=true;
74
-			if ($eventqualified)
75
-			{
76
-				// See http://fr.wikipedia.org/wiki/ICalendar for format
77
-				// See http://www.ietf.org/rfc/rfc2445.txt for RFC
78
-				$uid 		  = $event['uid'];
79
-				$type         = $event['type'];
71
+        foreach ($events_array as $key => $event)
72
+        {
73
+            $eventqualified=true;
74
+            if ($eventqualified)
75
+            {
76
+                // See http://fr.wikipedia.org/wiki/ICalendar for format
77
+                // See http://www.ietf.org/rfc/rfc2445.txt for RFC
78
+                $uid 		  = $event['uid'];
79
+                $type         = $event['type'];
80 80
                 $startdate    = $event['startdate'];
81
-				$duration	  = $event['duration'];
82
-				$enddate	  = $event['enddate'];
83
-				$summary  	  = $event['summary'];
84
-				$category	  = $event['category'];
81
+                $duration	  = $event['duration'];
82
+                $enddate	  = $event['enddate'];
83
+                $summary  	  = $event['summary'];
84
+                $category	  = $event['category'];
85 85
                 $priority     = $event['priority'];
86 86
                 $fulldayevent = $event['fulldayevent'];
87
-				$location     = $event['location'];
88
-				$email 		  = $event['email'];
89
-				$url		  = $event['url'];
90
-				$transparency = $event['transparency'];		// OPAQUE (busy) or TRANSPARENT (not busy)
91
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
92
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
87
+                $location     = $event['location'];
88
+                $email 		  = $event['email'];
89
+                $url		  = $event['url'];
90
+                $transparency = $event['transparency'];		// OPAQUE (busy) or TRANSPARENT (not busy)
91
+                $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
92
+                    $description=dol_string_nohtmltag($description,0);	// Remove html tags
93 93
                 $created      = $event['created'];
94
- 				$modified     = $event['modified'];
94
+                    $modified     = $event['modified'];
95 95
 
96
-				// Uncomment for tests
97
-				//$summary="Resume";
98
-				//$description="Description";
99
-				//$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
96
+                // Uncomment for tests
97
+                //$summary="Resume";
98
+                //$description="Description";
99
+                //$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
100 100
 
101
-				// Format
102
-				$summary=format_cal($format,$summary);
103
-				$description=format_cal($format,$description);
104
-				$category=format_cal($format,$category);
105
-				$location=format_cal($format,$location);
101
+                // Format
102
+                $summary=format_cal($format,$summary);
103
+                $description=format_cal($format,$description);
104
+                $category=format_cal($format,$category);
105
+                $location=format_cal($format,$location);
106 106
 
107
-				// Output the vCard/iCal VEVENT object
108
-				/*
107
+                // Output the vCard/iCal VEVENT object
108
+                /*
109 109
 				Example from Google ical export for a 1 hour event:
110 110
                 BEGIN:VEVENT
111 111
                 DTSTART:20101103T120000Z
@@ -138,26 +138,26 @@  discard block
 block discarded – undo
138 138
                 TRANSP:TRANSPARENT
139 139
                 END:VEVENT
140 140
                 */
141
-				if ($type == 'event')
142
-				{
143
-					fwrite($calfileh,"BEGIN:VEVENT\n");
144
-					fwrite($calfileh,"UID:".$uid."\n");
145
-					if (! empty($email))
146
-					{
147
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
148
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
149
-					}
150
-					if (! empty($url))
151
-					{
152
-						fwrite($calfileh,"URL:".$url."\n");
153
-					};
141
+                if ($type == 'event')
142
+                {
143
+                    fwrite($calfileh,"BEGIN:VEVENT\n");
144
+                    fwrite($calfileh,"UID:".$uid."\n");
145
+                    if (! empty($email))
146
+                    {
147
+                        fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
148
+                        fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
149
+                    }
150
+                    if (! empty($url))
151
+                    {
152
+                        fwrite($calfileh,"URL:".$url."\n");
153
+                    };
154 154
 
155 155
                     if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
156 156
                     if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
157 157
                     fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
158
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
158
+                    fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
159 159
 
160
-					/* Other keys:
160
+                    /* Other keys:
161 161
 					// Status values for a "VEVENT"
162 162
 					statvalue  = "TENTATIVE"           ;Indicates event is
163 163
 				                                        ;tentative.
@@ -174,86 +174,86 @@  discard block
 block discarded – undo
174 174
 				                / "FINAL"               ;Indicates journal is final.
175 175
 				                / "CANCELLED"           ;Indicates journal is removed.
176 176
 					*/
177
-					//fwrite($calfileh,"CLASS:PUBLIC\n");				// PUBLIC, PRIVATE, CONFIDENTIAL
177
+                    //fwrite($calfileh,"CLASS:PUBLIC\n");				// PUBLIC, PRIVATE, CONFIDENTIAL
178 178
                     //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n");
179 179
                     //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected]
180 180
 
181 181
                     if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
182
-					if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
182
+                    if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
183 183
                     if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
184 184
 
185
-					// Date must be GMT dates
186
-					// Current date
187
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
188
-					// Start date
185
+                    // Date must be GMT dates
186
+                    // Current date
187
+                    fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
188
+                    // Start date
189 189
                     $prefix='';
190 190
                     $startdatef = dol_print_date($startdate,'dayhourxcard',true);
191 191
                     if ($fulldayevent)
192
-					{
192
+                    {
193 193
                         $prefix=';VALUE=DATE';
194
-					    $startdatef = dol_print_date($startdate,'dayxcard',false);     // Local time
195
-					}
196
-					fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
194
+                        $startdatef = dol_print_date($startdate,'dayxcard',false);     // Local time
195
+                    }
196
+                    fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
197 197
                     // End date
198
-					if ($fulldayevent)
199
-					{
200
-    					if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
201
-					}
202
-					else
203
-					{
198
+                    if ($fulldayevent)
199
+                    {
200
+                        if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
201
+                    }
202
+                    else
203
+                    {
204 204
                         if (empty($enddate)) $enddate=$startdate+$duration;
205
-					}
205
+                    }
206 206
                     $prefix='';
207
-					$enddatef = dol_print_date($enddate,'dayhourxcard',true);
208
-					if ($fulldayevent)
209
-					{
207
+                    $enddatef = dol_print_date($enddate,'dayhourxcard',true);
208
+                    if ($fulldayevent)
209
+                    {
210 210
                         $prefix=';VALUE=DATE';
211
-					    $enddatef = dol_print_date($enddate+1,'dayxcard',false);
212
-					    //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false);   // Local time
213
-					}
211
+                        $enddatef = dol_print_date($enddate+1,'dayxcard',false);
212
+                        //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false);   // Local time
213
+                    }
214 214
                     fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
215
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
-					if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
-					if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
218
-					fwrite($calfileh,"END:VEVENT\n");
219
-				}
220
-
221
-				// Output the vCard/iCal VTODO object
222
-				// ...
223
-				//PERCENT-COMPLETE:39
224
-
225
-				// Output the vCard/iCal VJOURNAL object
226
-				if ($type == 'journal')
227
-				{
228
-					fwrite($calfileh,"BEGIN:VJOURNAL\n");
229
-					fwrite($calfileh,"UID:".$uid."\n");
230
-					if (! empty($email))
231
-					{
232
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
233
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
234
-					}
235
-					if (! empty($url))
236
-					{
237
-						fwrite($calfileh,"URL:".$url."\n");
238
-					};
215
+                    fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
+                    if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
+                    if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
218
+                    fwrite($calfileh,"END:VEVENT\n");
219
+                }
220
+
221
+                // Output the vCard/iCal VTODO object
222
+                // ...
223
+                //PERCENT-COMPLETE:39
224
+
225
+                // Output the vCard/iCal VJOURNAL object
226
+                if ($type == 'journal')
227
+                {
228
+                    fwrite($calfileh,"BEGIN:VJOURNAL\n");
229
+                    fwrite($calfileh,"UID:".$uid."\n");
230
+                    if (! empty($email))
231
+                    {
232
+                        fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
233
+                        fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
234
+                    }
235
+                    if (! empty($url))
236
+                    {
237
+                        fwrite($calfileh,"URL:".$url."\n");
238
+                    };
239 239
 
240 240
                     if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
241 241
                     if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
242
-					fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
245
-					fwrite($calfileh,"CATEGORIES:".$category."\n");
246
-					fwrite($calfileh,"LOCATION:".$location."\n");
247
-					fwrite($calfileh,"TRANSP:OPAQUE\n");
248
-					fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
249
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
242
+                    fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243
+                    fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244
+                    fwrite($calfileh,'STATUS:CONFIRMED'."\n");
245
+                    fwrite($calfileh,"CATEGORIES:".$category."\n");
246
+                    fwrite($calfileh,"LOCATION:".$location."\n");
247
+                    fwrite($calfileh,"TRANSP:OPAQUE\n");
248
+                    fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
249
+                    fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
250 250
 
251
-					fwrite($calfileh,"END:VJOURNAL\n");
252
-				}
251
+                    fwrite($calfileh,"END:VJOURNAL\n");
252
+                }
253 253
 
254 254
 
255
-				// Put other info in comment
256
-				/*
255
+                // Put other info in comment
256
+                /*
257 257
 				$comment=array();
258 258
 				$comment ['eid']			= $eid;
259 259
 				$comment ['url']			= $linktoevent;
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
 				$comment ['enddate']		= $enddate;
264 264
 				fwrite($calfileh,"COMMENT:" . serialize ($comment) . "\n");
265 265
 				*/
266
-			}
267
-		}
268
-
269
-		// Footer
270
-		fwrite($calfileh,"END:VCALENDAR");
271
-
272
-		fclose($calfileh);
273
-		if (! empty($conf->global->MAIN_UMASK))
274
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275
-	}
276
-	else
277
-	{
278
-		dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
279
-		return -2;
280
-	}
266
+            }
267
+        }
268
+
269
+        // Footer
270
+        fwrite($calfileh,"END:VCALENDAR");
271
+
272
+        fclose($calfileh);
273
+        if (! empty($conf->global->MAIN_UMASK))
274
+            @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275
+    }
276
+    else
277
+    {
278
+        dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
279
+        return -2;
280
+    }
281 281
 }
282 282
 
283 283
 /**
@@ -294,97 +294,97 @@  discard block
 block discarded – undo
294 294
  */
295 295
 function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='')
296 296
 {
297
-	global $user,$conf,$langs;
298
-	global $dolibarr_main_url_root;
297
+    global $user,$conf,$langs;
298
+    global $dolibarr_main_url_root;
299 299
 
300
-	dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
300
+    dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
301 301
 
302
-	if (empty($outputfile)) return -1;
302
+    if (empty($outputfile)) return -1;
303 303
 
304
-	$fichier=fopen($outputfile,'w');
305
-	if ($fichier)
306
-	{
307
-		$date=date("r");
304
+    $fichier=fopen($outputfile,'w');
305
+    if ($fichier)
306
+    {
307
+        $date=date("r");
308 308
 
309
-		// Print header
310
-		$form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
311
-		fwrite($fichier, $form);
312
-		fwrite($fichier, "\n");
313
-		$form='<rss version="2.0">';
314
-		fwrite($fichier, $form);
315
-		fwrite($fichier, "\n");
309
+        // Print header
310
+        $form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
311
+        fwrite($fichier, $form);
312
+        fwrite($fichier, "\n");
313
+        $form='<rss version="2.0">';
314
+        fwrite($fichier, $form);
315
+        fwrite($fichier, "\n");
316 316
 
317
-		$form="<channel>\n<title>".$title."</title>\n";
318
-		fwrite($fichier, $form);
317
+        $form="<channel>\n<title>".$title."</title>\n";
318
+        fwrite($fichier, $form);
319 319
 
320
-		$form='<description><![CDATA['.$desc.'.]]></description>'."\n".
320
+        $form='<description><![CDATA['.$desc.'.]]></description>'."\n".
321 321
 //		'<language>fr</language>'."\n".
322
-		'<copyright>Dolibarr</copyright>'."\n".
323
-		'<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
324
-		'<generator>Dolibarr</generator>'."\n";
325
-
326
-		// Define $urlwithroot
327
-		$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
328
-		$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;			// This is to use external domain name found into config file
329
-		//$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
330
-  		$url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
-		$form.='<link><![CDATA['.$url.']]></link>'."\n";
332
-
333
-		//print $form;
334
-		fwrite($fichier, $form);
335
-
336
-
337
-		foreach ($events_array as $key => $event)
338
-		{
339
-			$eventqualified=true;
340
-			if ($filter)
341
-			{
342
-				// TODO Add a filter
343
-
344
-				$eventqualified=false;
345
-			}
346
-
347
-			if ($eventqualified)
348
-			{
349
-				$uid		  = $event['uid'];
350
-				$startdate	  = $event['startdate'];
351
-				$summary  	  = $event['summary'];
352
-				$url		  = $event['url'];
353
-				$author		  = $event['author'];
354
-				$category	  = $event['category'];
355
-				/* No place inside a RSS
322
+        '<copyright>Dolibarr</copyright>'."\n".
323
+        '<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
324
+        '<generator>Dolibarr</generator>'."\n";
325
+
326
+        // Define $urlwithroot
327
+        $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
328
+        $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;			// This is to use external domain name found into config file
329
+        //$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
330
+            $url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
+        $form.='<link><![CDATA['.$url.']]></link>'."\n";
332
+
333
+        //print $form;
334
+        fwrite($fichier, $form);
335
+
336
+
337
+        foreach ($events_array as $key => $event)
338
+        {
339
+            $eventqualified=true;
340
+            if ($filter)
341
+            {
342
+                // TODO Add a filter
343
+
344
+                $eventqualified=false;
345
+            }
346
+
347
+            if ($eventqualified)
348
+            {
349
+                $uid		  = $event['uid'];
350
+                $startdate	  = $event['startdate'];
351
+                $summary  	  = $event['summary'];
352
+                $url		  = $event['url'];
353
+                $author		  = $event['author'];
354
+                $category	  = $event['category'];
355
+                /* No place inside a RSS
356 356
                 $priority     = $event['priority'];
357 357
                 $fulldayevent = $event['fulldayevent'];
358 358
                 $location     = $event['location'];
359 359
                 $email        = $event['email'];
360 360
                 */
361
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
362
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
363
-
364
-				fwrite($fichier, "<item>\n");
365
-				fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
366
-				fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
367
-				fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
368
-				fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
369
-				fwrite($fichier, "<description><![CDATA[");
370
-				if ($description) fwrite($fichier, $description);
371
-				//else fwrite($fichier, 'NoDesc');
372
-				fwrite($fichier, "]]></description>\n");
373
-				fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
374
-				fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
375
-				fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
376
-				fwrite($fichier, "</item>\n");
377
-			}
378
-		}
379
-
380
-		fwrite($fichier, '</channel>');
381
-		fwrite($fichier, "\n");
382
-		fwrite($fichier, '</rss>');
383
-
384
-		fclose($fichier);
385
-		if (! empty($conf->global->MAIN_UMASK))
386
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
387
-	}
361
+                $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
362
+                    $description=dol_string_nohtmltag($description,0);	// Remove html tags
363
+
364
+                fwrite($fichier, "<item>\n");
365
+                fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
366
+                fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
367
+                fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
368
+                fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
369
+                fwrite($fichier, "<description><![CDATA[");
370
+                if ($description) fwrite($fichier, $description);
371
+                //else fwrite($fichier, 'NoDesc');
372
+                fwrite($fichier, "]]></description>\n");
373
+                fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
374
+                fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
375
+                fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
376
+                fwrite($fichier, "</item>\n");
377
+            }
378
+        }
379
+
380
+        fwrite($fichier, '</channel>');
381
+        fwrite($fichier, "\n");
382
+        fwrite($fichier, '</rss>');
383
+
384
+        fclose($fichier);
385
+        if (! empty($conf->global->MAIN_UMASK))
386
+            @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
387
+    }
388 388
 }
389 389
 
390 390
 
@@ -397,25 +397,25 @@  discard block
 block discarded – undo
397 397
  */
398 398
 function format_cal($format,$string)
399 399
 {
400
-	global $conf;
401
-
402
-	$newstring=$string;
403
-
404
-	if ($format == 'vcal')
405
-	{
406
-		$newstring=quotedPrintEncode($newstring);
407
-	}
408
-	if ($format == 'ical')
409
-	{
410
-		// Replace new lines chars by '\n'
411
-		$newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
412
-		$newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
413
-		$newstring=preg_replace('/'."\n".'/i','\n',$newstring);
414
-		// Must not exceed 75 char. Cut with "\r\n"+Space
415
-		$newstring=calEncode($newstring);
416
-	}
417
-
418
-	return $newstring;
400
+    global $conf;
401
+
402
+    $newstring=$string;
403
+
404
+    if ($format == 'vcal')
405
+    {
406
+        $newstring=quotedPrintEncode($newstring);
407
+    }
408
+    if ($format == 'ical')
409
+    {
410
+        // Replace new lines chars by '\n'
411
+        $newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
412
+        $newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
413
+        $newstring=preg_replace('/'."\n".'/i','\n',$newstring);
414
+        // Must not exceed 75 char. Cut with "\r\n"+Space
415
+        $newstring=calEncode($newstring);
416
+    }
417
+
418
+    return $newstring;
419 419
 }
420 420
 
421 421
 /**
@@ -427,45 +427,45 @@  discard block
 block discarded – undo
427 427
  */
428 428
 function calEncode($line)
429 429
 {
430
-	$out = '';
431
-
432
-	$newpara = '';
433
-
434
-	// If mb_ functions exists, it's better to use them
435
-	if (function_exists('mb_strlen'))
436
-	{
437
-	    $strlength=mb_strlen($line, 'UTF-8');
438
-		for ($j = 0; $j <= ($strlength - 1); $j++)
439
-		{
440
-			$char = mb_substr($line, $j, 1, 'UTF-8');	// Take char at position $j
441
-
442
-			if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
443
-			{
444
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
445
-				$newpara = '';
446
-			}
447
-			$newpara .= $char;
448
-		}
449
-		$out .= $newpara;
450
-	}
451
-	else
452
-	{
453
-	    $strlength=dol_strlen($line);
454
-		for ($j = 0; $j <= ($strlength - 1); $j++)
455
-		{
456
-			$char = substr($line, $j, 1);	// Take char at position $j
457
-
458
-			if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
459
-			{
460
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
461
-				$newpara = '';
462
-			}
463
-			$newpara .= $char;
464
-		}
465
-		$out .= $newpara;
466
-	}
467
-
468
-	return trim($out);
430
+    $out = '';
431
+
432
+    $newpara = '';
433
+
434
+    // If mb_ functions exists, it's better to use them
435
+    if (function_exists('mb_strlen'))
436
+    {
437
+        $strlength=mb_strlen($line, 'UTF-8');
438
+        for ($j = 0; $j <= ($strlength - 1); $j++)
439
+        {
440
+            $char = mb_substr($line, $j, 1, 'UTF-8');	// Take char at position $j
441
+
442
+            if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
443
+            {
444
+                $out .= $newpara . "\r\n ";	// CRLF + Space for cal
445
+                $newpara = '';
446
+            }
447
+            $newpara .= $char;
448
+        }
449
+        $out .= $newpara;
450
+    }
451
+    else
452
+    {
453
+        $strlength=dol_strlen($line);
454
+        for ($j = 0; $j <= ($strlength - 1); $j++)
455
+        {
456
+            $char = substr($line, $j, 1);	// Take char at position $j
457
+
458
+            if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
459
+            {
460
+                $out .= $newpara . "\r\n ";	// CRLF + Space for cal
461
+                $newpara = '';
462
+            }
463
+            $newpara .= $char;
464
+        }
465
+        $out .= $newpara;
466
+    }
467
+
468
+    return trim($out);
469 469
 }
470 470
 
471 471
 
@@ -478,33 +478,33 @@  discard block
 block discarded – undo
478 478
  */
479 479
 function quotedPrintEncode($str,$forcal=0)
480 480
 {
481
-	$lines = preg_split("/\r\n/", $str);
482
-	$out = '';
483
-
484
-	foreach ($lines as $line)
485
-	{
486
-		$newpara = '';
487
-
488
-		$strlength=strlen($line);	// Do not use dol_strlen here, we need number of bytes
489
-		for ($j = 0; $j <= ($strlength - 1); $j++)
490
-		{
491
-			$char = substr($line, $j, 1);
492
-			$ascii = ord($char);
493
-
494
-			if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
-			$char = '=' . strtoupper(sprintf("%02X", $ascii));
496
-
497
-			if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
498
-			{
499
-				$out .= $newpara . '=' . "\r\n";	// CRLF
500
-				if ($forcal) $out .= " ";		// + Space for cal
501
-				$newpara = '';
502
-			}
503
-			$newpara .= $char;
504
-		}
505
-		$out .= $newpara;
506
-	}
507
-	return trim($out);
481
+    $lines = preg_split("/\r\n/", $str);
482
+    $out = '';
483
+
484
+    foreach ($lines as $line)
485
+    {
486
+        $newpara = '';
487
+
488
+        $strlength=strlen($line);	// Do not use dol_strlen here, we need number of bytes
489
+        for ($j = 0; $j <= ($strlength - 1); $j++)
490
+        {
491
+            $char = substr($line, $j, 1);
492
+            $ascii = ord($char);
493
+
494
+            if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
+            $char = '=' . strtoupper(sprintf("%02X", $ascii));
496
+
497
+            if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
498
+            {
499
+                $out .= $newpara . '=' . "\r\n";	// CRLF
500
+                if ($forcal) $out .= " ";		// + Space for cal
501
+                $newpara = '';
502
+            }
503
+            $newpara .= $char;
504
+        }
505
+        $out .= $newpara;
506
+    }
507
+    return trim($out);
508 508
 }
509 509
 
510 510
 /**
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
  */
516 516
 function quotedPrintDecode($str)
517 517
 {
518
-	$out = preg_replace('/=\r?\n/', '', $str);
519
-	$out = quoted_printable_decode($out);	// Available with PHP 4+
520
-	return trim($out);
518
+    $out = preg_replace('/=\r?\n/', '', $str);
519
+    $out = quoted_printable_decode($out);	// Available with PHP 4+
520
+    return trim($out);
521 521
 }
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -32,66 +32,66 @@  discard block
 block discarded – undo
32 32
  *	@param		string	$outputfile			Output file
33 33
  *	@return		int							<0 if ko, Nb of events in file if ok
34 34
  */
35
-function build_calfile($format,$title,$desc,$events_array,$outputfile)
35
+function build_calfile($format, $title, $desc, $events_array, $outputfile)
36 36
 {
37
-	global $conf,$langs;
37
+	global $conf, $langs;
38 38
 
39 39
 	dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
40 40
 
41 41
 	if (empty($outputfile)) return -1;
42 42
 
43 43
     // Note: A cal file is an UTF8 encoded file
44
-	$calfileh=fopen($outputfile,'w');
44
+	$calfileh = fopen($outputfile, 'w');
45 45
 	if ($calfileh)
46 46
 	{
47 47
 	    include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48
-		$now=dol_now();
48
+		$now = dol_now();
49 49
 
50
-		$encoding='';
51
-		if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
50
+		$encoding = '';
51
+		if ($format == 'vcal') $encoding = 'ENCODING=QUOTED-PRINTABLE:';
52 52
 
53 53
 		// Print header
54
-		fwrite($calfileh,"BEGIN:VCALENDAR\n");
55
-		fwrite($calfileh,"VERSION:2.0\n");
56
-		fwrite($calfileh,"METHOD:PUBLISH\n");
54
+		fwrite($calfileh, "BEGIN:VCALENDAR\n");
55
+		fwrite($calfileh, "VERSION:2.0\n");
56
+		fwrite($calfileh, "METHOD:PUBLISH\n");
57 57
 		//fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
58
-		fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
-		fwrite($calfileh,"CALSCALE:GREGORIAN\n");
60
-		fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
61
-        fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n");
58
+		fwrite($calfileh, "PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
+		fwrite($calfileh, "CALSCALE:GREGORIAN\n");
60
+		fwrite($calfileh, "X-WR-CALNAME:".$encoding.format_cal($format, $title)."\n");
61
+        fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n");
62 62
         //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
63
-        if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
64
-        && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){
65
-	        $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
66
-	        $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
67
-	        $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
68
-	        fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
63
+        if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
64
+        && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60) {
65
+	        $hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'hour');
66
+	        $mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'min');
67
+	        $ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'sec');
68
+	        fwrite($calfileh, "X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
69 69
         }
70 70
 
71 71
 		foreach ($events_array as $key => $event)
72 72
 		{
73
-			$eventqualified=true;
73
+			$eventqualified = true;
74 74
 			if ($eventqualified)
75 75
 			{
76 76
 				// See http://fr.wikipedia.org/wiki/ICalendar for format
77 77
 				// See http://www.ietf.org/rfc/rfc2445.txt for RFC
78
-				$uid 		  = $event['uid'];
79
-				$type         = $event['type'];
80
-                $startdate    = $event['startdate'];
78
+				$uid = $event['uid'];
79
+				$type = $event['type'];
80
+                $startdate = $event['startdate'];
81 81
 				$duration	  = $event['duration'];
82
-				$enddate	  = $event['enddate'];
83
-				$summary  	  = $event['summary'];
82
+				$enddate = $event['enddate'];
83
+				$summary = $event['summary'];
84 84
 				$category	  = $event['category'];
85 85
                 $priority     = $event['priority'];
86 86
                 $fulldayevent = $event['fulldayevent'];
87 87
 				$location     = $event['location'];
88
-				$email 		  = $event['email'];
89
-				$url		  = $event['url'];
90
-				$transparency = $event['transparency'];		// OPAQUE (busy) or TRANSPARENT (not busy)
91
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
92
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
93
-                $created      = $event['created'];
94
- 				$modified     = $event['modified'];
88
+				$email = $event['email'];
89
+				$url = $event['url'];
90
+				$transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy)
91
+				$description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']);
92
+ 				$description = dol_string_nohtmltag($description, 0); // Remove html tags
93
+                $created = $event['created'];
94
+ 				$modified = $event['modified'];
95 95
 
96 96
 				// Uncomment for tests
97 97
 				//$summary="Resume";
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 				//$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
100 100
 
101 101
 				// Format
102
-				$summary=format_cal($format,$summary);
103
-				$description=format_cal($format,$description);
104
-				$category=format_cal($format,$category);
105
-				$location=format_cal($format,$location);
102
+				$summary = format_cal($format, $summary);
103
+				$description = format_cal($format, $description);
104
+				$category = format_cal($format, $category);
105
+				$location = format_cal($format, $location);
106 106
 
107 107
 				// Output the vCard/iCal VEVENT object
108 108
 				/*
@@ -140,22 +140,22 @@  discard block
 block discarded – undo
140 140
                 */
141 141
 				if ($type == 'event')
142 142
 				{
143
-					fwrite($calfileh,"BEGIN:VEVENT\n");
144
-					fwrite($calfileh,"UID:".$uid."\n");
145
-					if (! empty($email))
143
+					fwrite($calfileh, "BEGIN:VEVENT\n");
144
+					fwrite($calfileh, "UID:".$uid."\n");
145
+					if (!empty($email))
146 146
 					{
147
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
148
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
147
+						fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
148
+						fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
149 149
 					}
150
-					if (! empty($url))
150
+					if (!empty($url))
151 151
 					{
152
-						fwrite($calfileh,"URL:".$url."\n");
152
+						fwrite($calfileh, "URL:".$url."\n");
153 153
 					};
154 154
 
155
-                    if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
156
-                    if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
157
-                    fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
158
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
155
+                    if ($created)  fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n");
156
+                    if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n");
157
+                    fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
158
+					fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
159 159
 
160 160
 					/* Other keys:
161 161
 					// Status values for a "VEVENT"
@@ -178,44 +178,44 @@  discard block
 block discarded – undo
178 178
                     //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n");
179 179
                     //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected]
180 180
 
181
-                    if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
182
-					if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
183
-                    if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
181
+                    if (!empty($location)) fwrite($calfileh, "LOCATION:".$encoding.$location."\n");
182
+					if ($fulldayevent) fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n");
183
+                    if ($fulldayevent) fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
184 184
 
185 185
 					// Date must be GMT dates
186 186
 					// Current date
187
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
187
+					fwrite($calfileh, "DTSTAMP:".dol_print_date($now, 'dayhourxcard', true)."\n");
188 188
 					// Start date
189
-                    $prefix='';
190
-                    $startdatef = dol_print_date($startdate,'dayhourxcard',true);
189
+                    $prefix = '';
190
+                    $startdatef = dol_print_date($startdate, 'dayhourxcard', true);
191 191
                     if ($fulldayevent)
192 192
 					{
193
-                        $prefix=';VALUE=DATE';
194
-					    $startdatef = dol_print_date($startdate,'dayxcard',false);     // Local time
193
+                        $prefix = ';VALUE=DATE';
194
+					    $startdatef = dol_print_date($startdate, 'dayxcard', false); // Local time
195 195
 					}
196
-					fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
196
+					fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n");
197 197
                     // End date
198 198
 					if ($fulldayevent)
199 199
 					{
200
-    					if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
200
+    					if (empty($enddate)) $enddate = dol_time_plus_duree($startdate, 1, 'd');
201 201
 					}
202 202
 					else
203 203
 					{
204
-                        if (empty($enddate)) $enddate=$startdate+$duration;
204
+                        if (empty($enddate)) $enddate = $startdate + $duration;
205 205
 					}
206
-                    $prefix='';
207
-					$enddatef = dol_print_date($enddate,'dayhourxcard',true);
206
+                    $prefix = '';
207
+					$enddatef = dol_print_date($enddate, 'dayhourxcard', true);
208 208
 					if ($fulldayevent)
209 209
 					{
210
-                        $prefix=';VALUE=DATE';
211
-					    $enddatef = dol_print_date($enddate+1,'dayxcard',false);
210
+                        $prefix = ';VALUE=DATE';
211
+					    $enddatef = dol_print_date($enddate + 1, 'dayxcard', false);
212 212
 					    //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false);   // Local time
213 213
 					}
214
-                    fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
215
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
-					if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
-					if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
218
-					fwrite($calfileh,"END:VEVENT\n");
214
+                    fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n");
215
+					fwrite($calfileh, 'STATUS:CONFIRMED'."\n");
216
+					if (!empty($transparency)) fwrite($calfileh, "TRANSP:".$transparency."\n");
217
+					if (!empty($category)) fwrite($calfileh, "CATEGORIES:".$encoding.$category."\n");
218
+					fwrite($calfileh, "END:VEVENT\n");
219 219
 				}
220 220
 
221 221
 				// Output the vCard/iCal VTODO object
@@ -225,30 +225,30 @@  discard block
 block discarded – undo
225 225
 				// Output the vCard/iCal VJOURNAL object
226 226
 				if ($type == 'journal')
227 227
 				{
228
-					fwrite($calfileh,"BEGIN:VJOURNAL\n");
229
-					fwrite($calfileh,"UID:".$uid."\n");
230
-					if (! empty($email))
228
+					fwrite($calfileh, "BEGIN:VJOURNAL\n");
229
+					fwrite($calfileh, "UID:".$uid."\n");
230
+					if (!empty($email))
231 231
 					{
232
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
233
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
232
+						fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
233
+						fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
234 234
 					}
235
-					if (! empty($url))
235
+					if (!empty($url))
236 236
 					{
237
-						fwrite($calfileh,"URL:".$url."\n");
237
+						fwrite($calfileh, "URL:".$url."\n");
238 238
 					};
239 239
 
240
-                    if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
241
-                    if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
242
-					fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
245
-					fwrite($calfileh,"CATEGORIES:".$category."\n");
246
-					fwrite($calfileh,"LOCATION:".$location."\n");
247
-					fwrite($calfileh,"TRANSP:OPAQUE\n");
248
-					fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
249
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
250
-
251
-					fwrite($calfileh,"END:VJOURNAL\n");
240
+                    if ($created)  fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n");
241
+                    if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n");
242
+					fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
243
+					fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
244
+					fwrite($calfileh, 'STATUS:CONFIRMED'."\n");
245
+					fwrite($calfileh, "CATEGORIES:".$category."\n");
246
+					fwrite($calfileh, "LOCATION:".$location."\n");
247
+					fwrite($calfileh, "TRANSP:OPAQUE\n");
248
+					fwrite($calfileh, "CLASS:CONFIDENTIAL\n");
249
+					fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, 'dayhourxcard', true)."\n");
250
+
251
+					fwrite($calfileh, "END:VJOURNAL\n");
252 252
 				}
253 253
 
254 254
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 		}
268 268
 
269 269
 		// Footer
270
-		fwrite($calfileh,"END:VCALENDAR");
270
+		fwrite($calfileh, "END:VCALENDAR");
271 271
 
272 272
 		fclose($calfileh);
273
-		if (! empty($conf->global->MAIN_UMASK))
273
+		if (!empty($conf->global->MAIN_UMASK))
274 274
 			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275 275
 	}
276 276
 	else
@@ -292,43 +292,43 @@  discard block
 block discarded – undo
292 292
  *	@param		string	$filter				Filter
293 293
  *	@return		int							<0 if ko, Nb of events in file if ok
294 294
  */
295
-function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='')
295
+function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '')
296 296
 {
297
-	global $user,$conf,$langs;
297
+	global $user, $conf, $langs;
298 298
 	global $dolibarr_main_url_root;
299 299
 
300 300
 	dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
301 301
 
302 302
 	if (empty($outputfile)) return -1;
303 303
 
304
-	$fichier=fopen($outputfile,'w');
304
+	$fichier = fopen($outputfile, 'w');
305 305
 	if ($fichier)
306 306
 	{
307
-		$date=date("r");
307
+		$date = date("r");
308 308
 
309 309
 		// Print header
310
-		$form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
310
+		$form = '<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
311 311
 		fwrite($fichier, $form);
312 312
 		fwrite($fichier, "\n");
313
-		$form='<rss version="2.0">';
313
+		$form = '<rss version="2.0">';
314 314
 		fwrite($fichier, $form);
315 315
 		fwrite($fichier, "\n");
316 316
 
317
-		$form="<channel>\n<title>".$title."</title>\n";
317
+		$form = "<channel>\n<title>".$title."</title>\n";
318 318
 		fwrite($fichier, $form);
319 319
 
320
-		$form='<description><![CDATA['.$desc.'.]]></description>'."\n".
320
+		$form = '<description><![CDATA['.$desc.'.]]></description>'."\n".
321 321
 //		'<language>fr</language>'."\n".
322 322
 		'<copyright>Dolibarr</copyright>'."\n".
323 323
 		'<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
324 324
 		'<generator>Dolibarr</generator>'."\n";
325 325
 
326 326
 		// Define $urlwithroot
327
-		$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
328
-		$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;			// This is to use external domain name found into config file
327
+		$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
328
+		$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
329 329
 		//$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
330
-  		$url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
-		$form.='<link><![CDATA['.$url.']]></link>'."\n";
330
+  		$url = $urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
+		$form .= '<link><![CDATA['.$url.']]></link>'."\n";
332 332
 
333 333
 		//print $form;
334 334
 		fwrite($fichier, $form);
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 
337 337
 		foreach ($events_array as $key => $event)
338 338
 		{
339
-			$eventqualified=true;
339
+			$eventqualified = true;
340 340
 			if ($filter)
341 341
 			{
342 342
 				// TODO Add a filter
343 343
 
344
-				$eventqualified=false;
344
+				$eventqualified = false;
345 345
 			}
346 346
 
347 347
 			if ($eventqualified)
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 				$startdate	  = $event['startdate'];
351 351
 				$summary  	  = $event['summary'];
352 352
 				$url		  = $event['url'];
353
-				$author		  = $event['author'];
354
-				$category	  = $event['category'];
353
+				$author = $event['author'];
354
+				$category = $event['category'];
355 355
 				/* No place inside a RSS
356 356
                 $priority     = $event['priority'];
357 357
                 $fulldayevent = $event['fulldayevent'];
358 358
                 $location     = $event['location'];
359 359
                 $email        = $event['email'];
360 360
                 */
361
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
362
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
361
+				$description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']);
362
+ 				$description = dol_string_nohtmltag($description, 0); // Remove html tags
363 363
 
364 364
 				fwrite($fichier, "<item>\n");
365 365
 				fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		fwrite($fichier, '</rss>');
383 383
 
384 384
 		fclose($fichier);
385
-		if (! empty($conf->global->MAIN_UMASK))
385
+		if (!empty($conf->global->MAIN_UMASK))
386 386
 			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
387 387
 	}
388 388
 }
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
  * 	@param 		string	$string		string to encode
396 396
  * 	@return		string				string encoded
397 397
  */
398
-function format_cal($format,$string)
398
+function format_cal($format, $string)
399 399
 {
400 400
 	global $conf;
401 401
 
402
-	$newstring=$string;
402
+	$newstring = $string;
403 403
 
404 404
 	if ($format == 'vcal')
405 405
 	{
406
-		$newstring=quotedPrintEncode($newstring);
406
+		$newstring = quotedPrintEncode($newstring);
407 407
 	}
408 408
 	if ($format == 'ical')
409 409
 	{
410 410
 		// Replace new lines chars by '\n'
411
-		$newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
412
-		$newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
413
-		$newstring=preg_replace('/'."\n".'/i','\n',$newstring);
411
+		$newstring = preg_replace('/'."\r\n".'/i', "\n", $newstring);
412
+		$newstring = preg_replace('/'."\n\r".'/i', "\n", $newstring);
413
+		$newstring = preg_replace('/'."\n".'/i', '\n', $newstring);
414 414
 		// Must not exceed 75 char. Cut with "\r\n"+Space
415
-		$newstring=calEncode($newstring);
415
+		$newstring = calEncode($newstring);
416 416
 	}
417 417
 
418 418
 	return $newstring;
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 	// If mb_ functions exists, it's better to use them
435 435
 	if (function_exists('mb_strlen'))
436 436
 	{
437
-	    $strlength=mb_strlen($line, 'UTF-8');
437
+	    $strlength = mb_strlen($line, 'UTF-8');
438 438
 		for ($j = 0; $j <= ($strlength - 1); $j++)
439 439
 		{
440
-			$char = mb_substr($line, $j, 1, 'UTF-8');	// Take char at position $j
440
+			$char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j
441 441
 
442 442
 			if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
443 443
 			{
444
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
444
+				$out .= $newpara."\r\n "; // CRLF + Space for cal
445 445
 				$newpara = '';
446 446
 			}
447 447
 			$newpara .= $char;
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 	}
451 451
 	else
452 452
 	{
453
-	    $strlength=dol_strlen($line);
453
+	    $strlength = dol_strlen($line);
454 454
 		for ($j = 0; $j <= ($strlength - 1); $j++)
455 455
 		{
456
-			$char = substr($line, $j, 1);	// Take char at position $j
456
+			$char = substr($line, $j, 1); // Take char at position $j
457 457
 
458
-			if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
458
+			if ((dol_strlen($newpara) + dol_strlen($char)) >= 75)
459 459
 			{
460
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
460
+				$out .= $newpara."\r\n "; // CRLF + Space for cal
461 461
 				$newpara = '';
462 462
 			}
463 463
 			$newpara .= $char;
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
  *	@param		int		$forcal		1=For cal
477 477
  *	@return		string 				String converted
478 478
  */
479
-function quotedPrintEncode($str,$forcal=0)
479
+function quotedPrintEncode($str, $forcal = 0)
480 480
 {
481 481
 	$lines = preg_split("/\r\n/", $str);
482 482
 	$out = '';
@@ -485,19 +485,19 @@  discard block
 block discarded – undo
485 485
 	{
486 486
 		$newpara = '';
487 487
 
488
-		$strlength=strlen($line);	// Do not use dol_strlen here, we need number of bytes
488
+		$strlength = strlen($line); // Do not use dol_strlen here, we need number of bytes
489 489
 		for ($j = 0; $j <= ($strlength - 1); $j++)
490 490
 		{
491 491
 			$char = substr($line, $j, 1);
492 492
 			$ascii = ord($char);
493 493
 
494
-			if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
-			$char = '=' . strtoupper(sprintf("%02X", $ascii));
494
+			if ($ascii < 32 || $ascii == 61 || $ascii > 126)
495
+			$char = '='.strtoupper(sprintf("%02X", $ascii));
496 496
 
497
-			if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
497
+			if ((strlen($newpara) + strlen($char)) >= 76)	// Do not use dol_strlen here, we need number of bytes
498 498
 			{
499
-				$out .= $newpara . '=' . "\r\n";	// CRLF
500
-				if ($forcal) $out .= " ";		// + Space for cal
499
+				$out .= $newpara.'='."\r\n"; // CRLF
500
+				if ($forcal) $out .= " "; // + Space for cal
501 501
 				$newpara = '';
502 502
 			}
503 503
 			$newpara .= $char;
@@ -516,6 +516,6 @@  discard block
 block discarded – undo
516 516
 function quotedPrintDecode($str)
517 517
 {
518 518
 	$out = preg_replace('/=\r?\n/', '', $str);
519
-	$out = quoted_printable_decode($out);	// Available with PHP 4+
519
+	$out = quoted_printable_decode($out); // Available with PHP 4+
520 520
 	return trim($out);
521 521
 }
Please login to merge, or discard this patch.
Braces   +66 added lines, -30 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 39
 	dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
40 40
 
41
-	if (empty($outputfile)) return -1;
41
+	if (empty($outputfile)) {
42
+	    return -1;
43
+	}
42 44
 
43 45
     // Note: A cal file is an UTF8 encoded file
44 46
 	$calfileh=fopen($outputfile,'w');
@@ -48,7 +50,9 @@  discard block
 block discarded – undo
48 50
 		$now=dol_now();
49 51
 
50 52
 		$encoding='';
51
-		if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
53
+		if ($format == 'vcal') {
54
+		    $encoding='ENCODING=QUOTED-PRINTABLE:';
55
+		}
52 56
 
53 57
 		// Print header
54 58
 		fwrite($calfileh,"BEGIN:VCALENDAR\n");
@@ -152,8 +156,12 @@  discard block
 block discarded – undo
152 156
 						fwrite($calfileh,"URL:".$url."\n");
153 157
 					};
154 158
 
155
-                    if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
156
-                    if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
159
+                    if ($created) {
160
+                        fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
161
+                    }
162
+                    if ($modified) {
163
+                        fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
164
+                    }
157 165
                     fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
158 166
 					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
159 167
 
@@ -178,9 +186,15 @@  discard block
 block discarded – undo
178 186
                     //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n");
179 187
                     //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected]
180 188
 
181
-                    if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
182
-					if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
183
-                    if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
189
+                    if (! empty($location)) {
190
+                        fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
191
+                    }
192
+					if ($fulldayevent) {
193
+					    fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
194
+					}
195
+                    if ($fulldayevent) {
196
+                        fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
197
+                    }
184 198
 
185 199
 					// Date must be GMT dates
186 200
 					// Current date
@@ -197,11 +211,14 @@  discard block
 block discarded – undo
197 211
                     // End date
198 212
 					if ($fulldayevent)
199 213
 					{
200
-    					if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
201
-					}
202
-					else
214
+    					if (empty($enddate)) {
215
+    					    $enddate=dol_time_plus_duree($startdate,1,'d');
216
+    					}
217
+					} else
203 218
 					{
204
-                        if (empty($enddate)) $enddate=$startdate+$duration;
219
+                        if (empty($enddate)) {
220
+                            $enddate=$startdate+$duration;
221
+                        }
205 222
 					}
206 223
                     $prefix='';
207 224
 					$enddatef = dol_print_date($enddate,'dayhourxcard',true);
@@ -213,8 +230,12 @@  discard block
 block discarded – undo
213 230
 					}
214 231
                     fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
215 232
 					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
-					if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
-					if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
233
+					if (! empty($transparency)) {
234
+					    fwrite($calfileh,"TRANSP:".$transparency."\n");
235
+					}
236
+					if (! empty($category)) {
237
+					    fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
238
+					}
218 239
 					fwrite($calfileh,"END:VEVENT\n");
219 240
 				}
220 241
 
@@ -237,8 +258,12 @@  discard block
 block discarded – undo
237 258
 						fwrite($calfileh,"URL:".$url."\n");
238 259
 					};
239 260
 
240
-                    if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
241
-                    if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
261
+                    if ($created) {
262
+                        fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
263
+                    }
264
+                    if ($modified) {
265
+                        fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
266
+                    }
242 267
 					fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243 268
 					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244 269
 					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
@@ -270,10 +295,10 @@  discard block
 block discarded – undo
270 295
 		fwrite($calfileh,"END:VCALENDAR");
271 296
 
272 297
 		fclose($calfileh);
273
-		if (! empty($conf->global->MAIN_UMASK))
274
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275
-	}
276
-	else
298
+		if (! empty($conf->global->MAIN_UMASK)) {
299
+					@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
300
+		}
301
+	} else
277 302
 	{
278 303
 		dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
279 304
 		return -2;
@@ -299,7 +324,9 @@  discard block
 block discarded – undo
299 324
 
300 325
 	dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
301 326
 
302
-	if (empty($outputfile)) return -1;
327
+	if (empty($outputfile)) {
328
+	    return -1;
329
+	}
303 330
 
304 331
 	$fichier=fopen($outputfile,'w');
305 332
 	if ($fichier)
@@ -367,7 +394,9 @@  discard block
 block discarded – undo
367 394
 				fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
368 395
 				fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
369 396
 				fwrite($fichier, "<description><![CDATA[");
370
-				if ($description) fwrite($fichier, $description);
397
+				if ($description) {
398
+				    fwrite($fichier, $description);
399
+				}
371 400
 				//else fwrite($fichier, 'NoDesc');
372 401
 				fwrite($fichier, "]]></description>\n");
373 402
 				fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
@@ -382,8 +411,9 @@  discard block
 block discarded – undo
382 411
 		fwrite($fichier, '</rss>');
383 412
 
384 413
 		fclose($fichier);
385
-		if (! empty($conf->global->MAIN_UMASK))
386
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
414
+		if (! empty($conf->global->MAIN_UMASK)) {
415
+					@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
416
+		}
387 417
 	}
388 418
 }
389 419
 
@@ -447,8 +477,7 @@  discard block
 block discarded – undo
447 477
 			$newpara .= $char;
448 478
 		}
449 479
 		$out .= $newpara;
450
-	}
451
-	else
480
+	} else
452 481
 	{
453 482
 	    $strlength=dol_strlen($line);
454 483
 		for ($j = 0; $j <= ($strlength - 1); $j++)
@@ -491,13 +520,20 @@  discard block
 block discarded – undo
491 520
 			$char = substr($line, $j, 1);
492 521
 			$ascii = ord($char);
493 522
 
494
-			if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
-			$char = '=' . strtoupper(sprintf("%02X", $ascii));
523
+			if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) {
524
+						$char = '=' . strtoupper(sprintf("%02X", $ascii));
525
+			}
496 526
 
497
-			if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
527
+			if ((strlen($newpara) + strlen($char)) >= 76 ) {
528
+			    // Do not use dol_strlen here, we need number of bytes
498 529
 			{
499
-				$out .= $newpara . '=' . "\r\n";	// CRLF
500
-				if ($forcal) $out .= " ";		// + Space for cal
530
+				$out .= $newpara . '=' . "\r\n";
531
+			}
532
+			// CRLF
533
+				if ($forcal) {
534
+				    $out .= " ";
535
+				}
536
+				// + Space for cal
501 537
 				$newpara = '';
502 538
 			}
503 539
 			$newpara .= $char;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/ticket.lib.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,9 @@
 block discarded – undo
81 81
     	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
82 82
     	$head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
83 83
     	$head[$h][1] = $langs->trans('ContactsAddresses');
84
-    	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
84
+    	if ($nbContact > 0) {
85
+    	    $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
86
+    	}
85 87
     	$head[$h][2] = 'contact';
86 88
     	$h++;
87 89
     }
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 
79 79
     if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid))
80 80
     {
81
-    	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
82
-    	$head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
83
-    	$head[$h][1] = $langs->trans('ContactsAddresses');
84
-    	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
85
-    	$head[$h][2] = 'contact';
86
-    	$h++;
81
+        $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
82
+        $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
83
+        $head[$h][1] = $langs->trans('ContactsAddresses');
84
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
85
+        $head[$h][2] = 'contact';
86
+        $h++;
87 87
     }
88 88
 
89 89
     complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket');
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
     $head[$h][1] = $langs->trans('Events');
108 108
     if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
109 109
     {
110
-    	$head[$h][1].= '/';
111
-    	$head[$h][1].= $langs->trans("Agenda");
110
+        $head[$h][1].= '/';
111
+        $head[$h][1].= $langs->trans("Agenda");
112 112
     }
113 113
     $head[$h][2] = 'tabTicketLogs';
114 114
     $h++;
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
     print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">';
157 157
 
158 158
     if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) {
159
-    	// Print logo
160
-    	$urllogo = DOL_BASE_URI . '/theme/login_logo.png';
159
+        // Print logo
160
+        $urllogo = DOL_BASE_URI . '/theme/login_logo.png';
161 161
 
162 162
         if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
163
-    		$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file=' . urlencode('logos/thumbs/'.$mysoc->logo_small);
164
-    	} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
165
-    		$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file=' . urlencode('logos/'.$mysoc->logo);
166
-    		$width = 128;
167
-    	} elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) {
163
+            $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file=' . urlencode('logos/thumbs/'.$mysoc->logo_small);
164
+        } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
165
+            $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file=' . urlencode('logos/'.$mysoc->logo);
166
+            $width = 128;
167
+        } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) {
168 168
             $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png';
169 169
         }
170
-    	print '<center>';
171
-    	print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
172
-    	print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
173
-    	print '</center><br>';
170
+        print '<center>';
171
+        print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
172
+        print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
173
+        print '</center><br>';
174 174
     }
175 175
 
176 176
     print '<div style="margin-left: 50px; margin-right: 50px;">';
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     $h = 0;
72 72
     $head = array();
73
-    $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id;
73
+    $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id;
74 74
     $head[$h][1] = $langs->trans("Card");
75 75
     $head[$h][2] = 'tabTicket';
76 76
     $h++;
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 
79 79
     if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid))
80 80
     {
81
-    	$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
81
+    	$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
82 82
     	$head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
83 83
     	$head[$h][1] = $langs->trans('ContactsAddresses');
84
-    	if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
84
+    	if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>';
85 85
     	$head[$h][2] = 'contact';
86 86
     	$h++;
87 87
     }
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
     complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket');
90 90
 
91 91
     // Attached files
92
-    include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
93
-    $upload_dir = $conf->ticket->dir_output . "/" . $object->track_id;
92
+    include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
93
+    $upload_dir = $conf->ticket->dir_output."/".$object->track_id;
94 94
     $nbFiles = count(dol_dir_list($upload_dir, 'files'));
95
-    $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?track_id=' . $object->track_id;
95
+    $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?track_id='.$object->track_id;
96 96
     $head[$h][1] = $langs->trans("Documents");
97 97
     if ($nbFiles > 0) {
98
-        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
98
+        $head[$h][1] .= ' <span class="badge">'.$nbFiles.'</span>';
99 99
     }
100 100
 
101 101
     $head[$h][2] = 'tabTicketDocument';
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 
104 104
 
105 105
     // History
106
-    $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id;
106
+    $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
107 107
     $head[$h][1] = $langs->trans('Events');
108
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
108
+    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
109 109
     {
110
-    	$head[$h][1].= '/';
111
-    	$head[$h][1].= $langs->trans("Agenda");
110
+    	$head[$h][1] .= '/';
111
+    	$head[$h][1] .= $langs->trans("Agenda");
112 112
     }
113 113
     $head[$h][2] = 'tabTicketLogs';
114 114
     $h++;
115 115
 
116 116
 
117
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket','remove');
117
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove');
118 118
 
119 119
 
120 120
     return $head;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
  *    @param  string $car Char to generate key
127 127
  *     @return void
128 128
  */
129
-function generate_random_id($car=16)
129
+function generate_random_id($car = 16)
130 130
 {
131 131
     $string = "";
132 132
     $chaine = "abcdefghijklmnopqrstuvwxyz123456789";
@@ -155,21 +155,21 @@  discard block
 block discarded – undo
155 155
     top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
156 156
     print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">';
157 157
 
158
-    if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) {
158
+    if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) {
159 159
     	// Print logo
160
-    	$urllogo = DOL_BASE_URI . '/theme/login_logo.png';
160
+    	$urllogo = DOL_BASE_URI.'/theme/login_logo.png';
161 161
 
162
-        if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
163
-    		$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file=' . urlencode('logos/thumbs/'.$mysoc->logo_small);
164
-    	} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
165
-    		$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file=' . urlencode('logos/'.$mysoc->logo);
162
+        if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
163
+    		$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
164
+    	} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
165
+    		$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$mysoc->logo);
166 166
     		$width = 128;
167
-    	} elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) {
168
-            $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png';
167
+    	} elseif (is_readable(DOL_BASE_URI.'/theme/dolibarr_logo.png')) {
168
+            $urllogo = DOL_BASE_URI.'/theme/dolibarr_logo.png';
169 169
         }
170 170
     	print '<center>';
171
-    	print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
172
-    	print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
171
+    	print '<a href="'.($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)).'"><img alt="Logo" id="logosubscribe" title="" src="'.$urllogo.'" style="max-width: 440px" /></a><br>';
172
+    	print '<strong>'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).'</strong>';
173 173
     	print '</center><br>';
174 174
     }
175 175
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/cron.lib.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function cron_prepare_head(Cronjob $object)
57 57
 {
58
-	global $langs, $conf, $user;
59
-	$h = 0;
60
-	$head = array();
58
+    global $langs, $conf, $user;
59
+    $h = 0;
60
+    $head = array();
61 61
 
62
-	$head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id;
63
-	$head[$h][1] = $langs->trans("CronTask");
64
-	$head[$h][2] = 'card';
65
-	$h++;
62
+    $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id;
63
+    $head[$h][1] = $langs->trans("CronTask");
64
+    $head[$h][2] = 'card';
65
+    $h++;
66 66
 
67
-	$head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id;
68
-	$head[$h][1] = $langs->trans("Info");
69
-	$head[$h][2] = 'info';
70
-	$h++;
67
+    $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id;
68
+    $head[$h][1] = $langs->trans("Info");
69
+    $head[$h][2] = 'info';
70
+    $h++;
71 71
 
72
-	complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron');
72
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron');
73 73
 
74
-	complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove');
74
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove');
75 75
 
76
-	return $head;
76
+    return $head;
77 77
 }
78 78
 
79 79
 /**
@@ -83,54 +83,54 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function dol_print_cron_urls()
85 85
 {
86
-	global $conf, $langs, $user;
87
-	global $dolibarr_main_url_root;
88
-
89
-	// Define $urlwithroot
90
-	$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
91
-	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
92
-	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
93
-
94
-	// Cron launch
95
-	print '<div class="div-table-responsive-no-min">';
96
-	print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
97
-	$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
99
-	print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
100
-	$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
86
+    global $conf, $langs, $user;
87
+    global $dolibarr_main_url_root;
88
+
89
+    // Define $urlwithroot
90
+    $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
91
+    $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
92
+    //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
93
+
94
+    // Cron launch
95
+    print '<div class="div-table-responsive-no-min">';
96
+    print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
97
+    $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98
+    print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
99
+    print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
100
+    $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101
+    print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
102 102
     print '</div>';
103 103
     print '<br>';
104 104
     
105
-	$logintouse = 'firstadmin';
106
-	if ($user->admin) $logintouse = $user->login;
105
+    $logintouse = 'firstadmin';
106
+    if ($user->admin) $logintouse = $user->login;
107 107
 	
108
-	print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
109
-
110
-	$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
111
-	print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n";
112
-	print '<br>';
113
-
114
-	// Add note
115
-	if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
116
-	{
117
-    	$linuxlike=1;
118
-    	if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
119
-    	if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
120
-    	print $langs->trans("Note").': ';
121
-    	if ($linuxlike)
122
-    	{
123
-    		print $langs->trans("CronExplainHowToRunUnix");
124
-    		print '<br>';
125
-    		print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
126
-    	}
127
-    	else
128
-    	{
129
-    		print $langs->trans("CronExplainHowToRunWin");
130
-    	}
131
-	}
108
+    print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
109
+
110
+    $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
111
+    print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n";
112
+    print '<br>';
113
+
114
+    // Add note
115
+    if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
116
+    {
117
+        $linuxlike=1;
118
+        if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
119
+        if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
120
+        print $langs->trans("Note").': ';
121
+        if ($linuxlike)
122
+        {
123
+            print $langs->trans("CronExplainHowToRunUnix");
124
+            print '<br>';
125
+            print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
126
+        }
127
+        else
128
+        {
129
+            print $langs->trans("CronExplainHowToRunWin");
130
+        }
131
+    }
132 132
 	
133
-	return 0;
133
+    return 0;
134 134
 }
135 135
 
136 136
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
 	global $dolibarr_main_url_root;
88 88
 
89 89
 	// Define $urlwithroot
90
-	$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
91
-	$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
90
+	$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
91
+	$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
92 92
 	//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
93 93
 
94 94
 	// Cron launch
95 95
 	print '<div class="div-table-responsive-no-min">';
96 96
 	print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
97
-	$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
97
+	$url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
98
+	print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
99 99
 	print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
100
-	$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101
-	print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
100
+	$url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
101
+	print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
102 102
     print '</div>';
103 103
     print '<br>';
104 104
     
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
109 109
 
110
-	$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
110
+	$file = '/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
111 111
 	print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n";
112 112
 	print '<br>';
113 113
 
114 114
 	// Add note
115 115
 	if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
116 116
 	{
117
-    	$linuxlike=1;
118
-    	if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
119
-    	if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
117
+    	$linuxlike = 1;
118
+    	if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
119
+    	if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
120 120
     	print $langs->trans("Note").': ';
121 121
     	if ($linuxlike)
122 122
     	{
123 123
     		print $langs->trans("CronExplainHowToRunUnix");
124 124
     		print '<br>';
125
-    		print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
125
+    		print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
126 126
     	}
127 127
     	else
128 128
     	{
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -103,7 +103,9 @@  discard block
 block discarded – undo
103 103
     print '<br>';
104 104
     
105 105
 	$logintouse = 'firstadmin';
106
-	if ($user->admin) $logintouse = $user->login;
106
+	if ($user->admin) {
107
+	    $logintouse = $user->login;
108
+	}
107 109
 	
108 110
 	print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
109 111
 
@@ -115,16 +117,19 @@  discard block
 block discarded – undo
115 117
 	if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
116 118
 	{
117 119
     	$linuxlike=1;
118
-    	if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
119
-    	if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
120
+    	if (preg_match('/^win/i',PHP_OS)) {
121
+    	    $linuxlike=0;
122
+    	}
123
+    	if (preg_match('/^mac/i',PHP_OS)) {
124
+    	    $linuxlike=0;
125
+    	}
120 126
     	print $langs->trans("Note").': ';
121 127
     	if ($linuxlike)
122 128
     	{
123 129
     		print $langs->trans("CronExplainHowToRunUnix");
124 130
     		print '<br>';
125 131
     		print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' &gt; '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
126
-    	}
127
-    	else
132
+    	} else
128 133
     	{
129 134
     		print $langs->trans("CronExplainHowToRunWin");
130 135
     	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/report.lib.php 3 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -40,86 +40,86 @@
 block discarded – undo
40 40
  */
41 41
 function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
42 42
 {
43
-	global $langs;
44
-
45
-	if (empty($hselected)) $hselected='report';
46
-
47
-	print "\n\n<!-- start banner of report -->\n";
48
-
49
-	if(! empty($varlink)) $varlink = '?'.$varlink;
50
-
51
-	$h=0;
52
-	$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
53
-	$head[$h][1] = $langs->trans("Report");
54
-	$head[$h][2] = 'report';
55
-
56
-	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
57
-
58
-	dol_fiche_head($head, 'report');
59
-
60
-	foreach($moreparam as $key => $value)
61
-	{
62
-		 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
63
-	}
64
-	print '<table width="100%" class="border">';
65
-
66
-	$variante = ($periodlink || $exportlink);
67
-
68
-	// Ligne de titre
69
-	print '<tr>';
70
-	print '<td width="110">'.$langs->trans("ReportName").'</td>';
71
-	print '<td>';
72
-	print $reportname;
73
-	print '</td>';
74
-	if ($variante) print '<td></td>';
75
-	print '</tr>';
76
-
77
-	// Calculation mode
78
-	if ($calcmode)
79
-	{
80
-		print '<tr>';
81
-		print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
82
-		print '<td>';
83
-		print $calcmode;
84
-		if ($variante) print '<td></td>';
85
-		print '</td>';
86
-		print '</tr>';
87
-	}
88
-
89
-	// Ligne de la periode d'analyse du rapport
90
-	print '<tr>';
91
-	print '<td>'.$langs->trans("ReportPeriod").'</td>';
92
-	print '<td>';
93
-	if ($period) print $period;
94
-	if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>';
95
-	print '</td>';
96
-	print '</tr>';
97
-
98
-	// Ligne de description
99
-	print '<tr>';
100
-	print '<td>'.$langs->trans("ReportDescription").'</td>';
101
-	print '<td>'.$description.'</td>';
102
-	if ($variante) print '<td></td>';
103
-	print '</tr>';
104
-
105
-	// Ligne d'export
106
-	print '<tr>';
107
-	print '<td>'.$langs->trans("GeneratedOn").'</td>';
108
-	print '<td>';
109
-	print dol_print_date($builddate, 'dayhour');
110
-	print '</td>';
111
-	if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
112
-	print '</tr>';
113
-
114
-	print '</table>';
115
-
116
-	dol_fiche_end();
117
-
118
-	print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
119
-
120
-	print '</form>';
121
-	print '<br>';
122
-
123
-	print "\n<!-- end banner of report -->\n\n";
43
+    global $langs;
44
+
45
+    if (empty($hselected)) $hselected='report';
46
+
47
+    print "\n\n<!-- start banner of report -->\n";
48
+
49
+    if(! empty($varlink)) $varlink = '?'.$varlink;
50
+
51
+    $h=0;
52
+    $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
53
+    $head[$h][1] = $langs->trans("Report");
54
+    $head[$h][2] = 'report';
55
+
56
+    print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
57
+
58
+    dol_fiche_head($head, 'report');
59
+
60
+    foreach($moreparam as $key => $value)
61
+    {
62
+            print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
63
+    }
64
+    print '<table width="100%" class="border">';
65
+
66
+    $variante = ($periodlink || $exportlink);
67
+
68
+    // Ligne de titre
69
+    print '<tr>';
70
+    print '<td width="110">'.$langs->trans("ReportName").'</td>';
71
+    print '<td>';
72
+    print $reportname;
73
+    print '</td>';
74
+    if ($variante) print '<td></td>';
75
+    print '</tr>';
76
+
77
+    // Calculation mode
78
+    if ($calcmode)
79
+    {
80
+        print '<tr>';
81
+        print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
82
+        print '<td>';
83
+        print $calcmode;
84
+        if ($variante) print '<td></td>';
85
+        print '</td>';
86
+        print '</tr>';
87
+    }
88
+
89
+    // Ligne de la periode d'analyse du rapport
90
+    print '<tr>';
91
+    print '<td>'.$langs->trans("ReportPeriod").'</td>';
92
+    print '<td>';
93
+    if ($period) print $period;
94
+    if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>';
95
+    print '</td>';
96
+    print '</tr>';
97
+
98
+    // Ligne de description
99
+    print '<tr>';
100
+    print '<td>'.$langs->trans("ReportDescription").'</td>';
101
+    print '<td>'.$description.'</td>';
102
+    if ($variante) print '<td></td>';
103
+    print '</tr>';
104
+
105
+    // Ligne d'export
106
+    print '<tr>';
107
+    print '<td>'.$langs->trans("GeneratedOn").'</td>';
108
+    print '<td>';
109
+    print dol_print_date($builddate, 'dayhour');
110
+    print '</td>';
111
+    if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
112
+    print '</tr>';
113
+
114
+    print '</table>';
115
+
116
+    dol_fiche_end();
117
+
118
+    print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
119
+
120
+    print '</form>';
121
+    print '<br>';
122
+
123
+    print "\n<!-- end banner of report -->\n\n";
124 124
 }
125 125
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
  *  @param  string              $varlink        Add a variable into the address of the page
39 39
  *	@return	void
40 40
  */
41
-function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
41
+function report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
42 42
 {
43 43
 	global $langs;
44 44
 
45
-	if (empty($hselected)) $hselected='report';
45
+	if (empty($hselected)) $hselected = 'report';
46 46
 
47 47
 	print "\n\n<!-- start banner of report -->\n";
48 48
 
49
-	if(! empty($varlink)) $varlink = '?'.$varlink;
49
+	if (!empty($varlink)) $varlink = '?'.$varlink;
50 50
 
51
-	$h=0;
51
+	$h = 0;
52 52
 	$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
53 53
 	$head[$h][1] = $langs->trans("Report");
54 54
 	$head[$h][2] = 'report';
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	dol_fiche_head($head, 'report');
59 59
 
60
-	foreach($moreparam as $key => $value)
60
+	foreach ($moreparam as $key => $value)
61 61
 	{
62 62
 		 print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
63 63
 	}
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,11 +42,15 @@  discard block
 block discarded – undo
42 42
 {
43 43
 	global $langs;
44 44
 
45
-	if (empty($hselected)) $hselected='report';
45
+	if (empty($hselected)) {
46
+	    $hselected='report';
47
+	}
46 48
 
47 49
 	print "\n\n<!-- start banner of report -->\n";
48 50
 
49
-	if(! empty($varlink)) $varlink = '?'.$varlink;
51
+	if(! empty($varlink)) {
52
+	    $varlink = '?'.$varlink;
53
+	}
50 54
 
51 55
 	$h=0;
52 56
 	$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
@@ -71,7 +75,9 @@  discard block
 block discarded – undo
71 75
 	print '<td>';
72 76
 	print $reportname;
73 77
 	print '</td>';
74
-	if ($variante) print '<td></td>';
78
+	if ($variante) {
79
+	    print '<td></td>';
80
+	}
75 81
 	print '</tr>';
76 82
 
77 83
 	// Calculation mode
@@ -81,7 +87,9 @@  discard block
 block discarded – undo
81 87
 		print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
82 88
 		print '<td>';
83 89
 		print $calcmode;
84
-		if ($variante) print '<td></td>';
90
+		if ($variante) {
91
+		    print '<td></td>';
92
+		}
85 93
 		print '</td>';
86 94
 		print '</tr>';
87 95
 	}
@@ -90,8 +98,12 @@  discard block
 block discarded – undo
90 98
 	print '<tr>';
91 99
 	print '<td>'.$langs->trans("ReportPeriod").'</td>';
92 100
 	print '<td>';
93
-	if ($period) print $period;
94
-	if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>';
101
+	if ($period) {
102
+	    print $period;
103
+	}
104
+	if ($variante) {
105
+	    print '<td class="nowraponall">'.$periodlink.'</td>';
106
+	}
95 107
 	print '</td>';
96 108
 	print '</tr>';
97 109
 
@@ -99,7 +111,9 @@  discard block
 block discarded – undo
99 111
 	print '<tr>';
100 112
 	print '<td>'.$langs->trans("ReportDescription").'</td>';
101 113
 	print '<td>'.$description.'</td>';
102
-	if ($variante) print '<td></td>';
114
+	if ($variante) {
115
+	    print '<td></td>';
116
+	}
103 117
 	print '</tr>';
104 118
 
105 119
 	// Ligne d'export
@@ -108,7 +122,9 @@  discard block
 block discarded – undo
108 122
 	print '<td>';
109 123
 	print dol_print_date($builddate, 'dayhour');
110 124
 	print '</td>';
111
-	if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
125
+	if ($variante) {
126
+	    print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
127
+	}
112 128
 	print '</tr>';
113 129
 
114 130
 	print '</table>';
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_sendmails.inc.php 3 patches
Indentation   +394 added lines, -394 removed lines patch added patch discarded remove patch
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
  */
35 35
 if (GETPOST('addfile','alpha'))
36 36
 {
37
-	$trackid = GETPOST('trackid','aZ09');
37
+    $trackid = GETPOST('trackid','aZ09');
38 38
 
39
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
40 40
 
41
-	// Set tmp user directory
42
-	$vardir=$conf->user->dir_output."/".$user->id;
43
-	$upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
41
+    // Set tmp user directory
42
+    $vardir=$conf->user->dir_output."/".$user->id;
43
+    $upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
44 44
 
45
-	dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0);
46
-	$action='presend';
45
+    dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0);
46
+    $action='presend';
47 47
 }
48 48
 
49 49
 /*
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
  */
52 52
 if (! empty($_POST['removedfile']) && empty($_POST['removAll']))
53 53
 {
54
-	$trackid = GETPOST('trackid','aZ09');
54
+    $trackid = GETPOST('trackid','aZ09');
55 55
 
56
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
57 57
 
58
-	// Set tmp user directory
59
-	$vardir=$conf->user->dir_output."/".$user->id;
60
-	$upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
58
+    // Set tmp user directory
59
+    $vardir=$conf->user->dir_output."/".$user->id;
60
+    $upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
61 61
 
62
-	// TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
63
-	// GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
64
-	dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid);   // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
65
-	$action='presend';
62
+    // TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
63
+    // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
64
+    dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid);   // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
65
+    $action='presend';
66 66
 }
67 67
 
68 68
 /*
@@ -70,31 +70,31 @@  discard block
 block discarded – undo
70 70
  */
71 71
 if (GETPOST('removAll','alpha'))
72 72
 {
73
-	$trackid = GETPOST('trackid','aZ09');
74
-
75
-	$listofpaths=array();
76
-	$listofnames=array();
77
-	$listofmimes=array();
78
-	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
79
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
80
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
81
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
82
-
83
-	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
84
-	$formmail = new FormMail($db);
85
-	$formmail->trackid = $trackid;
86
-
87
-	foreach($listofpaths as $key => $value)
88
-	{
89
-		$pathtodelete = $value;
90
-		$filetodelete = $listofnames[$key];
91
-		$result = dol_delete_file($pathtodelete,1); // Delete uploded Files
92
-
93
-		$langs->load("other");
94
-		setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
95
-
96
-		$formmail->remove_attached_files($key); // Update Session
97
-	}
73
+    $trackid = GETPOST('trackid','aZ09');
74
+
75
+    $listofpaths=array();
76
+    $listofnames=array();
77
+    $listofmimes=array();
78
+    $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
79
+    if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
80
+    if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
81
+    if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
82
+
83
+    include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
84
+    $formmail = new FormMail($db);
85
+    $formmail->trackid = $trackid;
86
+
87
+    foreach($listofpaths as $key => $value)
88
+    {
89
+        $pathtodelete = $value;
90
+        $filetodelete = $listofnames[$key];
91
+        $result = dol_delete_file($pathtodelete,1); // Delete uploded Files
92
+
93
+        $langs->load("other");
94
+        setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
95
+
96
+        $formmail->remove_attached_files($key); // Update Session
97
+    }
98 98
 }
99 99
 
100 100
 /*
@@ -102,244 +102,244 @@  discard block
 block discarded – undo
102 102
  */
103 103
 if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
104 104
 {
105
-	if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
106
-
107
-	$subject='';$actionmsg='';$actionmsg2='';
108
-
109
-	$langs->load('mails');
110
-
111
-	if (is_object($object))
112
-	{
113
-		$result=$object->fetch($id);
114
-
115
-		$sendtosocid=0;    // Thirdparty on object
116
-		if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact')))
117
-		{
118
-			$result=$object->fetch_thirdparty();
119
-			if ($object->element == 'user' && $result == 0) $result=1;    // Even if not found, we consider ok
120
-			$thirdparty=$object->thirdparty;
121
-			$sendtosocid=$thirdparty->id;
122
-		}
123
-		else if ($object->element == 'member' || $object->element == 'user')
124
-		{
125
-			$thirdparty=$object;
126
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
127
-		}
128
-		else if ($object->element == 'societe')
129
-		{
130
-			$thirdparty=$object;
131
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
132
-		}
133
-		else if ($object->element == 'contact')
134
-		{
135
-			$contact=$object;
136
-			if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id;
137
-		}
138
-		else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
139
-
140
-		if (is_object($hookmanager))
141
-		{
142
-			$parameters=array();
143
-			$reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
144
-		}
145
-	}
146
-	else $thirdparty = $mysoc;
147
-
148
-	if ($result > 0)
149
-	{
150
-		$sendto='';
151
-		$sendtocc='';
152
-		$sendtobcc='';
153
-		$sendtoid = array();
154
-		$sendtouserid=array();
155
-		$sendtoccuserid=array();
156
-
157
-		// Define $sendto
158
-		$receiver=$_POST['receiver'];
159
-		if (! is_array($receiver))
160
-		{
161
-			if ($receiver == '-1') $receiver=array();
162
-			else $receiver=array($receiver);
163
-		}
164
-		$tmparray=array();
165
-		if (trim($_POST['sendto']))
166
-		{
167
-			// Recipients are provided into free text
168
-			$tmparray[] = trim($_POST['sendto']);
169
-		}
170
-		if (count($receiver)>0)
171
-		{
172
-			foreach($receiver as $key=>$val)
173
-			{
174
-				// Recipient was provided from combo list
175
-				if ($val == 'thirdparty') // Id of third party
176
-				{
177
-					$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
178
-				}
179
-				// Recipient was provided from combo list
180
-				elseif ($val == 'contact') // Id of contact
181
-				{
182
-					$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
183
-				}
184
-				elseif ($val)	// Id du contact
185
-				{
186
-					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
187
-					$sendtoid[] = $val;
188
-				}
189
-			}
190
-		}
191
-		if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
192
-		{
193
-			$receiveruser=$_POST['receiveruser'];
194
-			if (is_array($receiveruser) && count($receiveruser)>0)
195
-			{
196
-				$fuserdest = new User($db);
197
-				foreach($receiveruser as $key=>$val)
198
-				{
199
-					$tmparray[] = $fuserdest->user_get_property($val,'email');
200
-					$sendtouserid[] = $val;
201
-				}
202
-			}
203
-		}
204
-
205
-		$sendto=implode(',',$tmparray);
206
-
207
-		// Define $sendtocc
208
-		$receivercc=$_POST['receivercc'];
209
-		if (! is_array($receivercc))
210
-		{
211
-			if ($receivercc == '-1') $receivercc=array();
212
-			else $receivercc=array($receivercc);
213
-		}
214
-		$tmparray=array();
215
-		if (trim($_POST['sendtocc']))
216
-		{
217
-			$tmparray[] = trim($_POST['sendtocc']);
218
-		}
219
-		if (count($receivercc) > 0)
220
-		{
221
-			foreach($receivercc as $key=>$val)
222
-			{
223
-				// Recipient was provided from combo list
224
-				if ($val == 'thirdparty') // Id of third party
225
-				{
226
-					$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
227
-				}
228
-				// Recipient was provided from combo list
229
-				elseif ($val == 'contact') // Id of contact
230
-				{
231
-					$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
232
-				}
233
-				elseif ($val)	// Id du contact
234
-				{
235
-					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
236
-					//$sendtoid[] = $val;  TODO Add also id of contact in CC ?
237
-				}
238
-			}
239
-		}
240
-		if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
241
-			$receiverccuser=$_POST['receiverccuser'];
242
-
243
-			if (is_array($receiverccuser) && count($receiverccuser)>0)
244
-			{
245
-				$fuserdest = new User($db);
246
-				foreach($receiverccuser as $key=>$val)
247
-				{
248
-					$tmparray[] = $fuserdest->user_get_property($val,'email');
249
-					$sendtoccuserid[] = $val;
250
-				}
251
-			}
252
-		}
253
-		$sendtocc=implode(',',$tmparray);
254
-
255
-		if (dol_strlen($sendto))
256
-		{
105
+    if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
106
+
107
+    $subject='';$actionmsg='';$actionmsg2='';
108
+
109
+    $langs->load('mails');
110
+
111
+    if (is_object($object))
112
+    {
113
+        $result=$object->fetch($id);
114
+
115
+        $sendtosocid=0;    // Thirdparty on object
116
+        if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact')))
117
+        {
118
+            $result=$object->fetch_thirdparty();
119
+            if ($object->element == 'user' && $result == 0) $result=1;    // Even if not found, we consider ok
120
+            $thirdparty=$object->thirdparty;
121
+            $sendtosocid=$thirdparty->id;
122
+        }
123
+        else if ($object->element == 'member' || $object->element == 'user')
124
+        {
125
+            $thirdparty=$object;
126
+            if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
127
+        }
128
+        else if ($object->element == 'societe')
129
+        {
130
+            $thirdparty=$object;
131
+            if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
132
+        }
133
+        else if ($object->element == 'contact')
134
+        {
135
+            $contact=$object;
136
+            if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id;
137
+        }
138
+        else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
139
+
140
+        if (is_object($hookmanager))
141
+        {
142
+            $parameters=array();
143
+            $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
144
+        }
145
+    }
146
+    else $thirdparty = $mysoc;
147
+
148
+    if ($result > 0)
149
+    {
150
+        $sendto='';
151
+        $sendtocc='';
152
+        $sendtobcc='';
153
+        $sendtoid = array();
154
+        $sendtouserid=array();
155
+        $sendtoccuserid=array();
156
+
157
+        // Define $sendto
158
+        $receiver=$_POST['receiver'];
159
+        if (! is_array($receiver))
160
+        {
161
+            if ($receiver == '-1') $receiver=array();
162
+            else $receiver=array($receiver);
163
+        }
164
+        $tmparray=array();
165
+        if (trim($_POST['sendto']))
166
+        {
167
+            // Recipients are provided into free text
168
+            $tmparray[] = trim($_POST['sendto']);
169
+        }
170
+        if (count($receiver)>0)
171
+        {
172
+            foreach($receiver as $key=>$val)
173
+            {
174
+                // Recipient was provided from combo list
175
+                if ($val == 'thirdparty') // Id of third party
176
+                {
177
+                    $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
178
+                }
179
+                // Recipient was provided from combo list
180
+                elseif ($val == 'contact') // Id of contact
181
+                {
182
+                    $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
183
+                }
184
+                elseif ($val)	// Id du contact
185
+                {
186
+                    $tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
187
+                    $sendtoid[] = $val;
188
+                }
189
+            }
190
+        }
191
+        if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
192
+        {
193
+            $receiveruser=$_POST['receiveruser'];
194
+            if (is_array($receiveruser) && count($receiveruser)>0)
195
+            {
196
+                $fuserdest = new User($db);
197
+                foreach($receiveruser as $key=>$val)
198
+                {
199
+                    $tmparray[] = $fuserdest->user_get_property($val,'email');
200
+                    $sendtouserid[] = $val;
201
+                }
202
+            }
203
+        }
204
+
205
+        $sendto=implode(',',$tmparray);
206
+
207
+        // Define $sendtocc
208
+        $receivercc=$_POST['receivercc'];
209
+        if (! is_array($receivercc))
210
+        {
211
+            if ($receivercc == '-1') $receivercc=array();
212
+            else $receivercc=array($receivercc);
213
+        }
214
+        $tmparray=array();
215
+        if (trim($_POST['sendtocc']))
216
+        {
217
+            $tmparray[] = trim($_POST['sendtocc']);
218
+        }
219
+        if (count($receivercc) > 0)
220
+        {
221
+            foreach($receivercc as $key=>$val)
222
+            {
223
+                // Recipient was provided from combo list
224
+                if ($val == 'thirdparty') // Id of third party
225
+                {
226
+                    $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
227
+                }
228
+                // Recipient was provided from combo list
229
+                elseif ($val == 'contact') // Id of contact
230
+                {
231
+                    $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
232
+                }
233
+                elseif ($val)	// Id du contact
234
+                {
235
+                    $tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
236
+                    //$sendtoid[] = $val;  TODO Add also id of contact in CC ?
237
+                }
238
+            }
239
+        }
240
+        if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
241
+            $receiverccuser=$_POST['receiverccuser'];
242
+
243
+            if (is_array($receiverccuser) && count($receiverccuser)>0)
244
+            {
245
+                $fuserdest = new User($db);
246
+                foreach($receiverccuser as $key=>$val)
247
+                {
248
+                    $tmparray[] = $fuserdest->user_get_property($val,'email');
249
+                    $sendtoccuserid[] = $val;
250
+                }
251
+            }
252
+        }
253
+        $sendtocc=implode(',',$tmparray);
254
+
255
+        if (dol_strlen($sendto))
256
+        {
257 257
             // Define $urlwithroot
258 258
             $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
259 259
             $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
260 260
             //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
261 261
 
262
-		    require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
263
-
264
-			$langs->load("commercial");
265
-
266
-			$fromtype = GETPOST('fromtype','alpha');
267
-			if ($fromtype === 'robot') {
268
-				$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
269
-			}
270
-			elseif ($fromtype === 'user') {
271
-				$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
272
-			}
273
-			elseif ($fromtype === 'company') {
274
-				$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
275
-			}
276
-			elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
277
-				$tmp=explode(',', $user->email_aliases);
278
-				$from = trim($tmp[($reg[1] - 1)]);
279
-			}
280
-			elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
281
-				$tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
282
-				$from = trim($tmp[($reg[1] - 1)]);
283
-			}
284
-			elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
285
-				$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
286
-				$resql = $db->query($sql);
287
-				$obj = $db->fetch_object($resql);
288
-				if ($obj)
289
-				{
290
-					$from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
291
-				}
292
-			}
293
-			else {
294
-				$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
295
-			}
296
-
297
-			$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>';
298
-			$message = GETPOST('message','none');
299
-			$subject = GETPOST('subject','none');
300
-
301
-			// Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
302
-			// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
303
-			// become
304
-			// <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
305
-			$message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
306
-
307
-			$sendtobcc= GETPOST('sendtoccc');
308
-			// Autocomplete the $sendtobcc
309
-			// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
310
-			if (! empty($autocopy))
311
-			{
312
-				$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
313
-			}
314
-
315
-			$deliveryreceipt = $_POST['deliveryreceipt'];
316
-
317
-			if ($action == 'send' || $action == 'relance')
318
-			{
319
-				$actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1);
320
-				if ($message)
321
-				{
322
-					$actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323
-					$actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
-					if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
325
-					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
326
-					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
327
-					$actionmsg = dol_concatdesc($actionmsg, $message);
328
-				}
329
-			}
330
-
331
-			// Create form object
332
-			include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
333
-			$formmail = new FormMail($db);
334
-			$formmail->trackid = $trackid;      // $trackid must be defined
335
-
336
-			$attachedfiles=$formmail->get_attached_files();
337
-			$filepath = $attachedfiles['paths'];
338
-			$filename = $attachedfiles['names'];
339
-			$mimetype = $attachedfiles['mimes'];
340
-
341
-			// Feature to push mail sent into Sent folder
342
-			/* This code must be now included into the hook mail, method sendMailAfter
262
+            require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
263
+
264
+            $langs->load("commercial");
265
+
266
+            $fromtype = GETPOST('fromtype','alpha');
267
+            if ($fromtype === 'robot') {
268
+                $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
269
+            }
270
+            elseif ($fromtype === 'user') {
271
+                $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
272
+            }
273
+            elseif ($fromtype === 'company') {
274
+                $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
275
+            }
276
+            elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
277
+                $tmp=explode(',', $user->email_aliases);
278
+                $from = trim($tmp[($reg[1] - 1)]);
279
+            }
280
+            elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
281
+                $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
282
+                $from = trim($tmp[($reg[1] - 1)]);
283
+            }
284
+            elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
285
+                $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
286
+                $resql = $db->query($sql);
287
+                $obj = $db->fetch_object($resql);
288
+                if ($obj)
289
+                {
290
+                    $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
291
+                }
292
+            }
293
+            else {
294
+                $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
295
+            }
296
+
297
+            $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>';
298
+            $message = GETPOST('message','none');
299
+            $subject = GETPOST('subject','none');
300
+
301
+            // Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
302
+            // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
303
+            // become
304
+            // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
305
+            $message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
306
+
307
+            $sendtobcc= GETPOST('sendtoccc');
308
+            // Autocomplete the $sendtobcc
309
+            // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
310
+            if (! empty($autocopy))
311
+            {
312
+                $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
313
+            }
314
+
315
+            $deliveryreceipt = $_POST['deliveryreceipt'];
316
+
317
+            if ($action == 'send' || $action == 'relance')
318
+            {
319
+                $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1);
320
+                if ($message)
321
+                {
322
+                    $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323
+                    $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
+                    if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
325
+                    $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
326
+                    $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
327
+                    $actionmsg = dol_concatdesc($actionmsg, $message);
328
+                }
329
+            }
330
+
331
+            // Create form object
332
+            include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
333
+            $formmail = new FormMail($db);
334
+            $formmail->trackid = $trackid;      // $trackid must be defined
335
+
336
+            $attachedfiles=$formmail->get_attached_files();
337
+            $filepath = $attachedfiles['paths'];
338
+            $filename = $attachedfiles['names'];
339
+            $mimetype = $attachedfiles['mimes'];
340
+
341
+            // Feature to push mail sent into Sent folder
342
+            /* This code must be now included into the hook mail, method sendMailAfter
343 343
 			if (! empty($conf->dolimail->enabled))
344 344
 			{
345 345
 				$mailfromid = explode("#", $_POST['frommail'],3);	// $_POST['frommail'] = 'aaa#Sent# <[email protected]>'	// TODO Use a better way to define Sent dir.
@@ -382,39 +382,39 @@  discard block
 block discarded – undo
382 382
 			}
383 383
 			*/
384 384
 
385
-			// Make substitution in email content
386
-			$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
387
-			$substitutionarray['__EMAIL__'] = $sendto;
388
-			$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
389
-
390
-			$parameters=array('mode'=>'formemail');
391
-			complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
392
-
393
-			$subject=make_substitutions($subject, $substitutionarray);
394
-			$message=make_substitutions($message, $substitutionarray);
395
-
396
-			if (method_exists($object, 'makeSubstitution'))
397
-			{
398
-				$subject = $object->makeSubstitution($subject);
399
-				$message = $object->makeSubstitution($message);
400
-			}
401
-
402
-			// Send mail (substitutionarray must be done just before this)
403
-			if (empty($sendcontext)) $sendcontext = 'standard';
404
-			$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
405
-
406
-			if ($mailfile->error)
407
-			{
408
-				setEventMessages($mailfile->error, $mailfile->errors, 'errors');
409
-				$action='presend';
410
-			}
411
-			else
412
-			{
413
-				$result=$mailfile->sendfile();
414
-				if ($result)
415
-				{
416
-					// Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
417
-					/*
385
+            // Make substitution in email content
386
+            $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
387
+            $substitutionarray['__EMAIL__'] = $sendto;
388
+            $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
389
+
390
+            $parameters=array('mode'=>'formemail');
391
+            complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
392
+
393
+            $subject=make_substitutions($subject, $substitutionarray);
394
+            $message=make_substitutions($message, $substitutionarray);
395
+
396
+            if (method_exists($object, 'makeSubstitution'))
397
+            {
398
+                $subject = $object->makeSubstitution($subject);
399
+                $message = $object->makeSubstitution($message);
400
+            }
401
+
402
+            // Send mail (substitutionarray must be done just before this)
403
+            if (empty($sendcontext)) $sendcontext = 'standard';
404
+            $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
405
+
406
+            if ($mailfile->error)
407
+            {
408
+                setEventMessages($mailfile->error, $mailfile->errors, 'errors');
409
+                $action='presend';
410
+            }
411
+            else
412
+            {
413
+                $result=$mailfile->sendfile();
414
+                if ($result)
415
+                {
416
+                    // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
417
+                    /*
418 418
 					if (! empty($conf->dolimail->enabled))
419 419
 					{
420 420
 						$mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0);	// Original mail id is set ?
@@ -434,91 +434,91 @@  discard block
 block discarded – undo
434 434
 						}
435 435
 					}*/
436 436
 
437
-					// Initialisation of datas of object to call trigger
438
-					if (is_object($object))
439
-					{
440
-					    if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
441
-
442
-						$object->socid			= $sendtosocid;	   // To link to a company
443
-						$object->sendtoid		= $sendtoid;	   // To link to contact addresses. This is an array.
444
-						$object->actiontypecode	= $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
445
-						$object->actionmsg		= $actionmsg;      // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
446
-						$object->actionmsg2		= $actionmsg2;     // Short text ($langs->transnoentities('MailSentBy')...);
447
-
448
-						$object->trackid        = $trackid;
449
-						$object->fk_element		= $object->id;
450
-						$object->elementtype	= $object->element;
451
-						if (is_array($attachedfiles) && count($attachedfiles)>0) {
452
-							$object->attachedfiles	= $attachedfiles;
453
-						}
454
-						if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
455
-							$object->sendtouserid	= $sendtouserid;
456
-						}
457
-
458
-						$object->email_msgid = $mailfile->msgid;	// @TODO Set msgid into $mailfile after sending
459
-						$object->email_from = $from;
460
-						$object->email_subject = $subject;
461
-						$object->email_to = $sendto;
462
-						$object->email_tocc = $sendtocc;
463
-						$object->email_tobcc = $sendtobcc;
464
-						$object->email_subject = $subject;
465
-						$object->email_msgid = $mailfile->msgid;
466
-
467
-						// Call of triggers
468
-						if (! empty($trigger_name))
469
-						{
470
-    						include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
471
-    						$interface=new Interfaces($db);
472
-    						$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
473
-							if ($result < 0) {
474
-    							setEventMessages($interface->error, $interface->errors, 'errors');
475
-    						}
476
-						}
477
-					}
478
-
479
-					// Redirect here
480
-					// This avoid sending mail twice if going out and then back to page
481
-					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
482
-					setEventMessages($mesg, null, 'mesgs');
483
-
484
-  					$moreparam='';
485
-	  				if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
486
-		  			header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
487
-			  		exit;
488
-				}
489
-				else
490
-				{
491
-					$langs->load("other");
492
-					$mesg='<div class="error">';
493
-					if ($mailfile->error)
494
-					{
495
-						$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
496
-						$mesg.='<br>'.$mailfile->error;
497
-					}
498
-					else
499
-					{
500
-						$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
501
-					}
502
-					$mesg.='</div>';
503
-
504
-					setEventMessages($mesg, null, 'warnings');
505
-					$action = 'presend';
506
-				}
507
-			}
508
-		}
509
-		else
510
-		{
511
-			$langs->load("errors");
512
-			setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
513
-			dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
514
-			$action = 'presend';
515
-		}
516
-	}
517
-	else
518
-	{
519
-		$langs->load("other");
520
-		setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
521
-		dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
522
-		$action = 'presend';
523
-	}
437
+                    // Initialisation of datas of object to call trigger
438
+                    if (is_object($object))
439
+                    {
440
+                        if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
441
+
442
+                        $object->socid			= $sendtosocid;	   // To link to a company
443
+                        $object->sendtoid		= $sendtoid;	   // To link to contact addresses. This is an array.
444
+                        $object->actiontypecode	= $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
445
+                        $object->actionmsg		= $actionmsg;      // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
446
+                        $object->actionmsg2		= $actionmsg2;     // Short text ($langs->transnoentities('MailSentBy')...);
447
+
448
+                        $object->trackid        = $trackid;
449
+                        $object->fk_element		= $object->id;
450
+                        $object->elementtype	= $object->element;
451
+                        if (is_array($attachedfiles) && count($attachedfiles)>0) {
452
+                            $object->attachedfiles	= $attachedfiles;
453
+                        }
454
+                        if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
455
+                            $object->sendtouserid	= $sendtouserid;
456
+                        }
457
+
458
+                        $object->email_msgid = $mailfile->msgid;	// @TODO Set msgid into $mailfile after sending
459
+                        $object->email_from = $from;
460
+                        $object->email_subject = $subject;
461
+                        $object->email_to = $sendto;
462
+                        $object->email_tocc = $sendtocc;
463
+                        $object->email_tobcc = $sendtobcc;
464
+                        $object->email_subject = $subject;
465
+                        $object->email_msgid = $mailfile->msgid;
466
+
467
+                        // Call of triggers
468
+                        if (! empty($trigger_name))
469
+                        {
470
+                            include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
471
+                            $interface=new Interfaces($db);
472
+                            $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
473
+                            if ($result < 0) {
474
+                                setEventMessages($interface->error, $interface->errors, 'errors');
475
+                            }
476
+                        }
477
+                    }
478
+
479
+                    // Redirect here
480
+                    // This avoid sending mail twice if going out and then back to page
481
+                    $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
482
+                    setEventMessages($mesg, null, 'mesgs');
483
+
484
+                        $moreparam='';
485
+                        if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
486
+                        header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
487
+                        exit;
488
+                }
489
+                else
490
+                {
491
+                    $langs->load("other");
492
+                    $mesg='<div class="error">';
493
+                    if ($mailfile->error)
494
+                    {
495
+                        $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
496
+                        $mesg.='<br>'.$mailfile->error;
497
+                    }
498
+                    else
499
+                    {
500
+                        $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
501
+                    }
502
+                    $mesg.='</div>';
503
+
504
+                    setEventMessages($mesg, null, 'warnings');
505
+                    $action = 'presend';
506
+                }
507
+            }
508
+        }
509
+        else
510
+        {
511
+            $langs->load("errors");
512
+            setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
513
+            dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
514
+            $action = 'presend';
515
+        }
516
+    }
517
+    else
518
+    {
519
+        $langs->load("other");
520
+        setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
521
+        dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
522
+        $action = 'presend';
523
+    }
524 524
 }
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -32,66 +32,66 @@  discard block
 block discarded – undo
32 32
 /*
33 33
  * Add file in email form
34 34
  */
35
-if (GETPOST('addfile','alpha'))
35
+if (GETPOST('addfile', 'alpha'))
36 36
 {
37
-	$trackid = GETPOST('trackid','aZ09');
37
+	$trackid = GETPOST('trackid', 'aZ09');
38 38
 
39 39
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
40 40
 
41 41
 	// Set tmp user directory
42
-	$vardir=$conf->user->dir_output."/".$user->id;
43
-	$upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
42
+	$vardir = $conf->user->dir_output."/".$user->id;
43
+	$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
44 44
 
45 45
 	dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0);
46
-	$action='presend';
46
+	$action = 'presend';
47 47
 }
48 48
 
49 49
 /*
50 50
  * Remove file in email form
51 51
  */
52
-if (! empty($_POST['removedfile']) && empty($_POST['removAll']))
52
+if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
53 53
 {
54
-	$trackid = GETPOST('trackid','aZ09');
54
+	$trackid = GETPOST('trackid', 'aZ09');
55 55
 
56 56
 	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
57 57
 
58 58
 	// Set tmp user directory
59
-	$vardir=$conf->user->dir_output."/".$user->id;
60
-	$upload_dir_tmp = $vardir.'/temp';             // TODO Add $keytoavoidconflict in upload_dir path
59
+	$vardir = $conf->user->dir_output."/".$user->id;
60
+	$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
61 61
 
62 62
 	// TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
63 63
 	// GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
64
-	dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid);   // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
65
-	$action='presend';
64
+	dol_remove_file_process(GETPOST('removedfile', 'alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
65
+	$action = 'presend';
66 66
 }
67 67
 
68 68
 /*
69 69
  * Remove all files in email form
70 70
  */
71
-if (GETPOST('removAll','alpha'))
71
+if (GETPOST('removAll', 'alpha'))
72 72
 {
73
-	$trackid = GETPOST('trackid','aZ09');
73
+	$trackid = GETPOST('trackid', 'aZ09');
74 74
 
75
-	$listofpaths=array();
76
-	$listofnames=array();
77
-	$listofmimes=array();
78
-	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
79
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
80
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
81
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
75
+	$listofpaths = array();
76
+	$listofnames = array();
77
+	$listofmimes = array();
78
+	$keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
79
+	if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
80
+	if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
81
+	if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
82 82
 
83 83
 	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
84 84
 	$formmail = new FormMail($db);
85 85
 	$formmail->trackid = $trackid;
86 86
 
87
-	foreach($listofpaths as $key => $value)
87
+	foreach ($listofpaths as $key => $value)
88 88
 	{
89 89
 		$pathtodelete = $value;
90 90
 		$filetodelete = $listofnames[$key];
91
-		$result = dol_delete_file($pathtodelete,1); // Delete uploded Files
91
+		$result = dol_delete_file($pathtodelete, 1); // Delete uploded Files
92 92
 
93 93
 		$langs->load("other");
94
-		setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
94
+		setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
95 95
 
96 96
 		$formmail->remove_attached_files($key); // Update Session
97 97
 	}
@@ -100,76 +100,76 @@  discard block
 block discarded – undo
100 100
 /*
101 101
  * Send mail
102 102
  */
103
-if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
103
+if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
104 104
 {
105
-	if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
105
+	if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
106 106
 
107
-	$subject='';$actionmsg='';$actionmsg2='';
107
+	$subject = ''; $actionmsg = ''; $actionmsg2 = '';
108 108
 
109 109
 	$langs->load('mails');
110 110
 
111 111
 	if (is_object($object))
112 112
 	{
113
-		$result=$object->fetch($id);
113
+		$result = $object->fetch($id);
114 114
 
115
-		$sendtosocid=0;    // Thirdparty on object
116
-		if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact')))
115
+		$sendtosocid = 0; // Thirdparty on object
116
+		if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact')))
117 117
 		{
118
-			$result=$object->fetch_thirdparty();
119
-			if ($object->element == 'user' && $result == 0) $result=1;    // Even if not found, we consider ok
120
-			$thirdparty=$object->thirdparty;
121
-			$sendtosocid=$thirdparty->id;
118
+			$result = $object->fetch_thirdparty();
119
+			if ($object->element == 'user' && $result == 0) $result = 1; // Even if not found, we consider ok
120
+			$thirdparty = $object->thirdparty;
121
+			$sendtosocid = $thirdparty->id;
122 122
 		}
123 123
 		else if ($object->element == 'member' || $object->element == 'user')
124 124
 		{
125
-			$thirdparty=$object;
126
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
125
+			$thirdparty = $object;
126
+			if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id;
127 127
 		}
128 128
 		else if ($object->element == 'societe')
129 129
 		{
130
-			$thirdparty=$object;
131
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
130
+			$thirdparty = $object;
131
+			if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id;
132 132
 		}
133 133
 		else if ($object->element == 'contact')
134 134
 		{
135
-			$contact=$object;
136
-			if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id;
135
+			$contact = $object;
136
+			if ($contact->id > 0) $sendtosocid = $contact->fetch_thirdparty()->id;
137 137
 		}
138
-		else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
138
+		else dol_print_error('', 'Use actions_sendmails.in.php for an element/object that is not supported');
139 139
 
140 140
 		if (is_object($hookmanager))
141 141
 		{
142
-			$parameters=array();
143
-			$reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
142
+			$parameters = array();
143
+			$reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
144 144
 		}
145 145
 	}
146 146
 	else $thirdparty = $mysoc;
147 147
 
148 148
 	if ($result > 0)
149 149
 	{
150
-		$sendto='';
151
-		$sendtocc='';
152
-		$sendtobcc='';
150
+		$sendto = '';
151
+		$sendtocc = '';
152
+		$sendtobcc = '';
153 153
 		$sendtoid = array();
154
-		$sendtouserid=array();
155
-		$sendtoccuserid=array();
154
+		$sendtouserid = array();
155
+		$sendtoccuserid = array();
156 156
 
157 157
 		// Define $sendto
158
-		$receiver=$_POST['receiver'];
159
-		if (! is_array($receiver))
158
+		$receiver = $_POST['receiver'];
159
+		if (!is_array($receiver))
160 160
 		{
161
-			if ($receiver == '-1') $receiver=array();
162
-			else $receiver=array($receiver);
161
+			if ($receiver == '-1') $receiver = array();
162
+			else $receiver = array($receiver);
163 163
 		}
164
-		$tmparray=array();
164
+		$tmparray = array();
165 165
 		if (trim($_POST['sendto']))
166 166
 		{
167 167
 			// Recipients are provided into free text
168 168
 			$tmparray[] = trim($_POST['sendto']);
169 169
 		}
170
-		if (count($receiver)>0)
170
+		if (count($receiver) > 0)
171 171
 		{
172
-			foreach($receiver as $key=>$val)
172
+			foreach ($receiver as $key=>$val)
173 173
 			{
174 174
 				// Recipient was provided from combo list
175 175
 				if ($val == 'thirdparty') // Id of third party
@@ -183,42 +183,42 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 				elseif ($val)	// Id du contact
185 185
 				{
186
-					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
186
+					$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
187 187
 					$sendtoid[] = $val;
188 188
 				}
189 189
 			}
190 190
 		}
191 191
 		if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
192 192
 		{
193
-			$receiveruser=$_POST['receiveruser'];
194
-			if (is_array($receiveruser) && count($receiveruser)>0)
193
+			$receiveruser = $_POST['receiveruser'];
194
+			if (is_array($receiveruser) && count($receiveruser) > 0)
195 195
 			{
196 196
 				$fuserdest = new User($db);
197
-				foreach($receiveruser as $key=>$val)
197
+				foreach ($receiveruser as $key=>$val)
198 198
 				{
199
-					$tmparray[] = $fuserdest->user_get_property($val,'email');
199
+					$tmparray[] = $fuserdest->user_get_property($val, 'email');
200 200
 					$sendtouserid[] = $val;
201 201
 				}
202 202
 			}
203 203
 		}
204 204
 
205
-		$sendto=implode(',',$tmparray);
205
+		$sendto = implode(',', $tmparray);
206 206
 
207 207
 		// Define $sendtocc
208
-		$receivercc=$_POST['receivercc'];
209
-		if (! is_array($receivercc))
208
+		$receivercc = $_POST['receivercc'];
209
+		if (!is_array($receivercc))
210 210
 		{
211
-			if ($receivercc == '-1') $receivercc=array();
212
-			else $receivercc=array($receivercc);
211
+			if ($receivercc == '-1') $receivercc = array();
212
+			else $receivercc = array($receivercc);
213 213
 		}
214
-		$tmparray=array();
214
+		$tmparray = array();
215 215
 		if (trim($_POST['sendtocc']))
216 216
 		{
217 217
 			$tmparray[] = trim($_POST['sendtocc']);
218 218
 		}
219 219
 		if (count($receivercc) > 0)
220 220
 		{
221
-			foreach($receivercc as $key=>$val)
221
+			foreach ($receivercc as $key=>$val)
222 222
 			{
223 223
 				// Recipient was provided from combo list
224 224
 				if ($val == 'thirdparty') // Id of third party
@@ -232,57 +232,57 @@  discard block
 block discarded – undo
232 232
 				}
233 233
 				elseif ($val)	// Id du contact
234 234
 				{
235
-					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
235
+					$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
236 236
 					//$sendtoid[] = $val;  TODO Add also id of contact in CC ?
237 237
 				}
238 238
 			}
239 239
 		}
240 240
 		if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
241
-			$receiverccuser=$_POST['receiverccuser'];
241
+			$receiverccuser = $_POST['receiverccuser'];
242 242
 
243
-			if (is_array($receiverccuser) && count($receiverccuser)>0)
243
+			if (is_array($receiverccuser) && count($receiverccuser) > 0)
244 244
 			{
245 245
 				$fuserdest = new User($db);
246
-				foreach($receiverccuser as $key=>$val)
246
+				foreach ($receiverccuser as $key=>$val)
247 247
 				{
248
-					$tmparray[] = $fuserdest->user_get_property($val,'email');
248
+					$tmparray[] = $fuserdest->user_get_property($val, 'email');
249 249
 					$sendtoccuserid[] = $val;
250 250
 				}
251 251
 			}
252 252
 		}
253
-		$sendtocc=implode(',',$tmparray);
253
+		$sendtocc = implode(',', $tmparray);
254 254
 
255 255
 		if (dol_strlen($sendto))
256 256
 		{
257 257
             // Define $urlwithroot
258
-            $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
259
-            $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
258
+            $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
259
+            $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
260 260
             //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
261 261
 
262 262
 		    require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
263 263
 
264 264
 			$langs->load("commercial");
265 265
 
266
-			$fromtype = GETPOST('fromtype','alpha');
266
+			$fromtype = GETPOST('fromtype', 'alpha');
267 267
 			if ($fromtype === 'robot') {
268
-				$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
268
+				$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
269 269
 			}
270 270
 			elseif ($fromtype === 'user') {
271
-				$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
271
+				$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
272 272
 			}
273 273
 			elseif ($fromtype === 'company') {
274
-				$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
274
+				$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
275 275
 			}
276 276
 			elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
277
-				$tmp=explode(',', $user->email_aliases);
277
+				$tmp = explode(',', $user->email_aliases);
278 278
 				$from = trim($tmp[($reg[1] - 1)]);
279 279
 			}
280 280
 			elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
281
-				$tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
281
+				$tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
282 282
 				$from = trim($tmp[($reg[1] - 1)]);
283 283
 			}
284 284
 			elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
285
-				$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
285
+				$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
286 286
 				$resql = $db->query($sql);
287 287
 				$obj = $db->fetch_object($resql);
288 288
 				if ($obj)
@@ -291,39 +291,39 @@  discard block
 block discarded – undo
291 291
 				}
292 292
 			}
293 293
 			else {
294
-				$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
294
+				$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")).' <'.$_POST['frommail'].'>';
295 295
 			}
296 296
 
297
-			$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>';
298
-			$message = GETPOST('message','none');
299
-			$subject = GETPOST('subject','none');
297
+			$replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")).' <'.$_POST['replytomail'].'>';
298
+			$message = GETPOST('message', 'none');
299
+			$subject = GETPOST('subject', 'none');
300 300
 
301 301
 			// Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
302 302
 			// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
303 303
 			// become
304 304
 			// <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
305
-			$message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
305
+			$message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
306 306
 
307
-			$sendtobcc= GETPOST('sendtoccc');
307
+			$sendtobcc = GETPOST('sendtoccc');
308 308
 			// Autocomplete the $sendtobcc
309 309
 			// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
310
-			if (! empty($autocopy))
310
+			if (!empty($autocopy))
311 311
 			{
312
-				$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
312
+				$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
313 313
 			}
314 314
 
315 315
 			$deliveryreceipt = $_POST['deliveryreceipt'];
316 316
 
317 317
 			if ($action == 'send' || $action == 'relance')
318 318
 			{
319
-				$actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1);
319
+				$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
320 320
 				if ($message)
321 321
 				{
322
-					$actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323
-					$actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
-					if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
325
-					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
326
-					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
322
+					$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323
+					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
+					if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
325
+					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
326
+					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
327 327
 					$actionmsg = dol_concatdesc($actionmsg, $message);
328 328
 				}
329 329
 			}
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 			// Create form object
332 332
 			include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
333 333
 			$formmail = new FormMail($db);
334
-			$formmail->trackid = $trackid;      // $trackid must be defined
334
+			$formmail->trackid = $trackid; // $trackid must be defined
335 335
 
336
-			$attachedfiles=$formmail->get_attached_files();
336
+			$attachedfiles = $formmail->get_attached_files();
337 337
 			$filepath = $attachedfiles['paths'];
338 338
 			$filename = $attachedfiles['names'];
339 339
 			$mimetype = $attachedfiles['mimes'];
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
 			*/
384 384
 
385 385
 			// Make substitution in email content
386
-			$substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
386
+			$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
387 387
 			$substitutionarray['__EMAIL__'] = $sendto;
388
-			$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'';
388
+			$substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
389 389
 
390
-			$parameters=array('mode'=>'formemail');
390
+			$parameters = array('mode'=>'formemail');
391 391
 			complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
392 392
 
393
-			$subject=make_substitutions($subject, $substitutionarray);
394
-			$message=make_substitutions($message, $substitutionarray);
393
+			$subject = make_substitutions($subject, $substitutionarray);
394
+			$message = make_substitutions($message, $substitutionarray);
395 395
 
396 396
 			if (method_exists($object, 'makeSubstitution'))
397 397
 			{
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 
402 402
 			// Send mail (substitutionarray must be done just before this)
403 403
 			if (empty($sendcontext)) $sendcontext = 'standard';
404
-			$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
404
+			$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
405 405
 
406 406
 			if ($mailfile->error)
407 407
 			{
408 408
 				setEventMessages($mailfile->error, $mailfile->errors, 'errors');
409
-				$action='presend';
409
+				$action = 'presend';
410 410
 			}
411 411
 			else
412 412
 			{
413
-				$result=$mailfile->sendfile();
413
+				$result = $mailfile->sendfile();
414 414
 				if ($result)
415 415
 				{
416 416
 					// Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
@@ -437,25 +437,25 @@  discard block
 block discarded – undo
437 437
 					// Initialisation of datas of object to call trigger
438 438
 					if (is_object($object))
439 439
 					{
440
-					    if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
440
+					    if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
441 441
 
442
-						$object->socid			= $sendtosocid;	   // To link to a company
443
-						$object->sendtoid		= $sendtoid;	   // To link to contact addresses. This is an array.
444
-						$object->actiontypecode	= $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
445
-						$object->actionmsg		= $actionmsg;      // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
446
-						$object->actionmsg2		= $actionmsg2;     // Short text ($langs->transnoentities('MailSentBy')...);
442
+						$object->socid = $sendtosocid; // To link to a company
443
+						$object->sendtoid = $sendtoid; // To link to contact addresses. This is an array.
444
+						$object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
445
+						$object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
446
+						$object->actionmsg2		= $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
447 447
 
448
-						$object->trackid        = $trackid;
448
+						$object->trackid = $trackid;
449 449
 						$object->fk_element		= $object->id;
450 450
 						$object->elementtype	= $object->element;
451
-						if (is_array($attachedfiles) && count($attachedfiles)>0) {
452
-							$object->attachedfiles	= $attachedfiles;
451
+						if (is_array($attachedfiles) && count($attachedfiles) > 0) {
452
+							$object->attachedfiles = $attachedfiles;
453 453
 						}
454
-						if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
455
-							$object->sendtouserid	= $sendtouserid;
454
+						if (is_array($sendtouserid) && count($sendtouserid) > 0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
455
+							$object->sendtouserid = $sendtouserid;
456 456
 						}
457 457
 
458
-						$object->email_msgid = $mailfile->msgid;	// @TODO Set msgid into $mailfile after sending
458
+						$object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending
459 459
 						$object->email_from = $from;
460 460
 						$object->email_subject = $subject;
461 461
 						$object->email_to = $sendto;
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 						$object->email_msgid = $mailfile->msgid;
466 466
 
467 467
 						// Call of triggers
468
-						if (! empty($trigger_name))
468
+						if (!empty($trigger_name))
469 469
 						{
470
-    						include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
471
-    						$interface=new Interfaces($db);
472
-    						$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
470
+    						include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
471
+    						$interface = new Interfaces($db);
472
+    						$result = $interface->run_triggers($trigger_name, $object, $user, $langs, $conf);
473 473
 							if ($result < 0) {
474 474
     							setEventMessages($interface->error, $interface->errors, 'errors');
475 475
     						}
@@ -478,28 +478,28 @@  discard block
 block discarded – undo
478 478
 
479 479
 					// Redirect here
480 480
 					// This avoid sending mail twice if going out and then back to page
481
-					$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
481
+					$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
482 482
 					setEventMessages($mesg, null, 'mesgs');
483 483
 
484
-  					$moreparam='';
485
-	  				if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
486
-		  			header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
484
+  					$moreparam = '';
485
+	  				if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
486
+		  			header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
487 487
 			  		exit;
488 488
 				}
489 489
 				else
490 490
 				{
491 491
 					$langs->load("other");
492
-					$mesg='<div class="error">';
492
+					$mesg = '<div class="error">';
493 493
 					if ($mailfile->error)
494 494
 					{
495
-						$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
496
-						$mesg.='<br>'.$mailfile->error;
495
+						$mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
496
+						$mesg .= '<br>'.$mailfile->error;
497 497
 					}
498 498
 					else
499 499
 					{
500
-						$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
500
+						$mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
501 501
 					}
502
-					$mesg.='</div>';
502
+					$mesg .= '</div>';
503 503
 
504 504
 					setEventMessages($mesg, null, 'warnings');
505 505
 					$action = 'presend';
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		else
510 510
 		{
511 511
 			$langs->load("errors");
512
-			setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
512
+			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
513 513
 			dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
514 514
 			$action = 'presend';
515 515
 		}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	else
518 518
 	{
519 519
 		$langs->load("other");
520
-		setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
520
+		setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors');
521 521
 		dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
522 522
 		$action = 'presend';
523 523
 	}
Please login to merge, or discard this patch.
Braces   +82 added lines, -52 removed lines patch added patch discarded remove patch
@@ -76,9 +76,15 @@  discard block
 block discarded – undo
76 76
 	$listofnames=array();
77 77
 	$listofmimes=array();
78 78
 	$keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
79
-	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
80
-	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
81
-	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
79
+	if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) {
80
+	    $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
81
+	}
82
+	if (! empty($_SESSION["listofnames".$keytoavoidconflict])) {
83
+	    $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
84
+	}
85
+	if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) {
86
+	    $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
87
+	}
82 88
 
83 89
 	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
84 90
 	$formmail = new FormMail($db);
@@ -102,7 +108,9 @@  discard block
 block discarded – undo
102 108
  */
103 109
 if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
104 110
 {
105
-	if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
111
+	if (empty($trackid)) {
112
+	    $trackid = GETPOST('trackid','aZ09');
113
+	}
106 114
 
107 115
 	$subject='';$actionmsg='';$actionmsg2='';
108 116
 
@@ -116,34 +124,42 @@  discard block
 block discarded – undo
116 124
 		if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact')))
117 125
 		{
118 126
 			$result=$object->fetch_thirdparty();
119
-			if ($object->element == 'user' && $result == 0) $result=1;    // Even if not found, we consider ok
127
+			if ($object->element == 'user' && $result == 0) {
128
+			    $result=1;
129
+			}
130
+			// Even if not found, we consider ok
120 131
 			$thirdparty=$object->thirdparty;
121 132
 			$sendtosocid=$thirdparty->id;
122
-		}
123
-		else if ($object->element == 'member' || $object->element == 'user')
133
+		} else if ($object->element == 'member' || $object->element == 'user')
124 134
 		{
125 135
 			$thirdparty=$object;
126
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
127
-		}
128
-		else if ($object->element == 'societe')
136
+			if ($thirdparty->id > 0) {
137
+			    $sendtosocid=$thirdparty->id;
138
+			}
139
+		} else if ($object->element == 'societe')
129 140
 		{
130 141
 			$thirdparty=$object;
131
-			if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
132
-		}
133
-		else if ($object->element == 'contact')
142
+			if ($thirdparty->id > 0) {
143
+			    $sendtosocid=$thirdparty->id;
144
+			}
145
+		} else if ($object->element == 'contact')
134 146
 		{
135 147
 			$contact=$object;
136
-			if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id;
148
+			if ($contact->id > 0) {
149
+			    $sendtosocid=$contact->fetch_thirdparty()->id;
150
+			}
151
+		} else {
152
+		    dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
137 153
 		}
138
-		else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
139 154
 
140 155
 		if (is_object($hookmanager))
141 156
 		{
142 157
 			$parameters=array();
143 158
 			$reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
144 159
 		}
160
+	} else {
161
+	    $thirdparty = $mysoc;
145 162
 	}
146
-	else $thirdparty = $mysoc;
147 163
 
148 164
 	if ($result > 0)
149 165
 	{
@@ -158,8 +174,11 @@  discard block
 block discarded – undo
158 174
 		$receiver=$_POST['receiver'];
159 175
 		if (! is_array($receiver))
160 176
 		{
161
-			if ($receiver == '-1') $receiver=array();
162
-			else $receiver=array($receiver);
177
+			if ($receiver == '-1') {
178
+			    $receiver=array();
179
+			} else {
180
+			    $receiver=array($receiver);
181
+			}
163 182
 		}
164 183
 		$tmparray=array();
165 184
 		if (trim($_POST['sendto']))
@@ -172,18 +191,23 @@  discard block
 block discarded – undo
172 191
 			foreach($receiver as $key=>$val)
173 192
 			{
174 193
 				// Recipient was provided from combo list
175
-				if ($val == 'thirdparty') // Id of third party
194
+				if ($val == 'thirdparty') {
195
+				    // Id of third party
176 196
 				{
177 197
 					$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
178 198
 				}
199
+				}
179 200
 				// Recipient was provided from combo list
180
-				elseif ($val == 'contact') // Id of contact
201
+				elseif ($val == 'contact') {
202
+				    // Id of contact
181 203
 				{
182 204
 					$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
183 205
 				}
184
-				elseif ($val)	// Id du contact
206
+				} elseif ($val) {
207
+				    // Id du contact
185 208
 				{
186 209
 					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
210
+				}
187 211
 					$sendtoid[] = $val;
188 212
 				}
189 213
 			}
@@ -208,8 +232,11 @@  discard block
 block discarded – undo
208 232
 		$receivercc=$_POST['receivercc'];
209 233
 		if (! is_array($receivercc))
210 234
 		{
211
-			if ($receivercc == '-1') $receivercc=array();
212
-			else $receivercc=array($receivercc);
235
+			if ($receivercc == '-1') {
236
+			    $receivercc=array();
237
+			} else {
238
+			    $receivercc=array($receivercc);
239
+			}
213 240
 		}
214 241
 		$tmparray=array();
215 242
 		if (trim($_POST['sendtocc']))
@@ -221,18 +248,23 @@  discard block
 block discarded – undo
221 248
 			foreach($receivercc as $key=>$val)
222 249
 			{
223 250
 				// Recipient was provided from combo list
224
-				if ($val == 'thirdparty') // Id of third party
251
+				if ($val == 'thirdparty') {
252
+				    // Id of third party
225 253
 				{
226 254
 					$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
227 255
 				}
256
+				}
228 257
 				// Recipient was provided from combo list
229
-				elseif ($val == 'contact') // Id of contact
258
+				elseif ($val == 'contact') {
259
+				    // Id of contact
230 260
 				{
231 261
 					$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
232 262
 				}
233
-				elseif ($val)	// Id du contact
263
+				} elseif ($val) {
264
+				    // Id du contact
234 265
 				{
235 266
 					$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
267
+				}
236 268
 					//$sendtoid[] = $val;  TODO Add also id of contact in CC ?
237 269
 				}
238 270
 			}
@@ -266,22 +298,17 @@  discard block
 block discarded – undo
266 298
 			$fromtype = GETPOST('fromtype','alpha');
267 299
 			if ($fromtype === 'robot') {
268 300
 				$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
269
-			}
270
-			elseif ($fromtype === 'user') {
301
+			} elseif ($fromtype === 'user') {
271 302
 				$from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
272
-			}
273
-			elseif ($fromtype === 'company') {
303
+			} elseif ($fromtype === 'company') {
274 304
 				$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
275
-			}
276
-			elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
305
+			} elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
277 306
 				$tmp=explode(',', $user->email_aliases);
278 307
 				$from = trim($tmp[($reg[1] - 1)]);
279
-			}
280
-			elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
308
+			} elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
281 309
 				$tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
282 310
 				$from = trim($tmp[($reg[1] - 1)]);
283
-			}
284
-			elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
311
+			} elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
285 312
 				$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
286 313
 				$resql = $db->query($sql);
287 314
 				$obj = $db->fetch_object($resql);
@@ -289,8 +316,7 @@  discard block
 block discarded – undo
289 316
 				{
290 317
 					$from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
291 318
 				}
292
-			}
293
-			else {
319
+			} else {
294 320
 				$from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
295 321
 			}
296 322
 
@@ -321,7 +347,9 @@  discard block
 block discarded – undo
321 347
 				{
322 348
 					$actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
323 349
 					$actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
324
-					if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
350
+					if ($sendtocc) {
351
+					    $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
352
+					}
325 353
 					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
326 354
 					$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
327 355
 					$actionmsg = dol_concatdesc($actionmsg, $message);
@@ -400,15 +428,16 @@  discard block
 block discarded – undo
400 428
 			}
401 429
 
402 430
 			// Send mail (substitutionarray must be done just before this)
403
-			if (empty($sendcontext)) $sendcontext = 'standard';
431
+			if (empty($sendcontext)) {
432
+			    $sendcontext = 'standard';
433
+			}
404 434
 			$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
405 435
 
406 436
 			if ($mailfile->error)
407 437
 			{
408 438
 				setEventMessages($mailfile->error, $mailfile->errors, 'errors');
409 439
 				$action='presend';
410
-			}
411
-			else
440
+			} else
412 441
 			{
413 442
 				$result=$mailfile->sendfile();
414 443
 				if ($result)
@@ -437,7 +466,10 @@  discard block
 block discarded – undo
437 466
 					// Initialisation of datas of object to call trigger
438 467
 					if (is_object($object))
439 468
 					{
440
-					    if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
469
+					    if (empty($actiontypecode)) {
470
+					        $actiontypecode='AC_OTH_AUTO';
471
+					    }
472
+					    // Event insert into agenda automatically
441 473
 
442 474
 						$object->socid			= $sendtosocid;	   // To link to a company
443 475
 						$object->sendtoid		= $sendtoid;	   // To link to contact addresses. This is an array.
@@ -482,11 +514,12 @@  discard block
 block discarded – undo
482 514
 					setEventMessages($mesg, null, 'mesgs');
483 515
 
484 516
   					$moreparam='';
485
-	  				if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
517
+	  				if (isset($paramname2) || isset($paramval2)) {
518
+	  				    $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
519
+	  				}
486 520
 		  			header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
487 521
 			  		exit;
488
-				}
489
-				else
522
+				} else
490 523
 				{
491 524
 					$langs->load("other");
492 525
 					$mesg='<div class="error">';
@@ -494,8 +527,7 @@  discard block
 block discarded – undo
494 527
 					{
495 528
 						$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
496 529
 						$mesg.='<br>'.$mailfile->error;
497
-					}
498
-					else
530
+					} else
499 531
 					{
500 532
 						$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
501 533
 					}
@@ -505,16 +537,14 @@  discard block
 block discarded – undo
505 537
 					$action = 'presend';
506 538
 				}
507 539
 			}
508
-		}
509
-		else
540
+		} else
510 541
 		{
511 542
 			$langs->load("errors");
512 543
 			setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
513 544
 			dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
514 545
 			$action = 'presend';
515 546
 		}
516
-	}
517
-	else
547
+	} else
518 548
 	{
519 549
 		$langs->load("other");
520 550
 		setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
Please login to merge, or discard this patch.