Passed
Push — master ( 8f7a8e...7e4a07 )
by Alxarafe
20:11
created
dolibarr/htdocs/core/triggers/dolibarrtriggers.class.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -21,129 +21,129 @@
 block discarded – undo
21 21
 abstract class DolibarrTriggers
22 22
 {
23 23
 
24
-	/**
25
-	 * Database handler
26
-	 * @var DoliDB
27
-	 */
28
-	protected $db;
29
-
30
-	/**
31
-	 * Name of the trigger
32
-	 * @var mixed|string
33
-	 */
34
-	public $name = '';
35
-
36
-	/**
37
-	 * Description of the trigger
38
-	 * @var string
39
-	 */
40
-	public $description = '';
41
-
42
-	/**
43
-	 * Version of the trigger
44
-	 * @var string
45
-	 */
46
-	public $version = self::VERSION_DEVELOPMENT;
47
-
48
-	/**
49
-	 * Image of the trigger
50
-	 * @var string
51
-	 */
52
-	public $picto = 'technic';
53
-
54
-	/**
55
-	 * Category of the trigger
56
-	 * @var string
57
-	 */
58
-	public $family = '';
59
-
60
-	/**
61
-	 * Error reported by the trigger
62
-	 * @var string
63
-	 * @deprecated Use $this->errors
64
-	 * @see errors
65
-	 */
66
-	public $error = '';
67
-
68
-	/**
69
-	 * Errors reported by the trigger
70
-	 * @var array
71
-	 */
72
-	public $errors = array();
73
-
74
-	const VERSION_DEVELOPMENT = 'development';
75
-	const VERSION_EXPERIMENTAL = 'experimental';
76
-	const VERSION_DOLIBARR = 'dolibarr';
77
-
78
-	/**
79
-	 * Constructor
80
-	 *
81
-	 * @param DoliDB $db Database handler
82
-	 */
24
+    /**
25
+     * Database handler
26
+     * @var DoliDB
27
+     */
28
+    protected $db;
29
+
30
+    /**
31
+     * Name of the trigger
32
+     * @var mixed|string
33
+     */
34
+    public $name = '';
35
+
36
+    /**
37
+     * Description of the trigger
38
+     * @var string
39
+     */
40
+    public $description = '';
41
+
42
+    /**
43
+     * Version of the trigger
44
+     * @var string
45
+     */
46
+    public $version = self::VERSION_DEVELOPMENT;
47
+
48
+    /**
49
+     * Image of the trigger
50
+     * @var string
51
+     */
52
+    public $picto = 'technic';
53
+
54
+    /**
55
+     * Category of the trigger
56
+     * @var string
57
+     */
58
+    public $family = '';
59
+
60
+    /**
61
+     * Error reported by the trigger
62
+     * @var string
63
+     * @deprecated Use $this->errors
64
+     * @see errors
65
+     */
66
+    public $error = '';
67
+
68
+    /**
69
+     * Errors reported by the trigger
70
+     * @var array
71
+     */
72
+    public $errors = array();
73
+
74
+    const VERSION_DEVELOPMENT = 'development';
75
+    const VERSION_EXPERIMENTAL = 'experimental';
76
+    const VERSION_DOLIBARR = 'dolibarr';
77
+
78
+    /**
79
+     * Constructor
80
+     *
81
+     * @param DoliDB $db Database handler
82
+     */
83 83
     public function __construct(DoliDB $db)
84 84
     {
85 85
 
86
-		$this->db = $db;
87
-
88
-		if (empty($this->name))
89
-		{
90
-			$this->name = preg_replace('/^Interface/i', '', get_class($this));
91
-		}
92
-	}
93
-
94
-	/**
95
-	 * Returns the name of the trigger file
96
-	 *
97
-	 * @return string
98
-	 */
99
-	public function getName()
100
-	{
101
-		return $this->name;
102
-	}
103
-
104
-	/**
105
-	 * Returns the description of trigger file
106
-	 *
107
-	 * @return string
108
-	 */
109
-	public function getDesc()
110
-	{
111
-		return $this->description;
112
-	}
113
-
114
-	/**
115
-	 * Returns the version of the trigger file
116
-	 *
117
-	 * @return string Version of trigger file
118
-	 */
119
-	public function getVersion()
120
-	{
121
-		global $langs;
122
-		$langs->load("admin");
123
-
124
-		if ($this->version == self::VERSION_DEVELOPMENT) {
125
-			return $langs->trans("VersionDevelopment");
126
-		} elseif ($this->version == self::VERSION_EXPERIMENTAL) {
127
-			return $langs->trans("VersionExperimental");
128
-		} elseif ($this->version == self::VERSION_DOLIBARR) {
129
-			return DOL_VERSION;
130
-		} elseif ($this->version) {
131
-			return $this->version;
132
-		} else {
133
-			return $langs->trans("Unknown");
134
-		}
135
-	}
136
-
137
-	/**
138
-	 * Function called when a Dolibarrr business event is done.
139
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
140
-	 *
141
-	 * @param string		$action		Event action code
142
-	 * @param Object		$object     Object
143
-	 * @param User		    $user       Object user
144
-	 * @param Translate 	$langs      Object langs
145
-	 * @param conf		    $conf       Object conf
146
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
147
-	 */
148
-	abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf);
86
+        $this->db = $db;
87
+
88
+        if (empty($this->name))
89
+        {
90
+            $this->name = preg_replace('/^Interface/i', '', get_class($this));
91
+        }
92
+    }
93
+
94
+    /**
95
+     * Returns the name of the trigger file
96
+     *
97
+     * @return string
98
+     */
99
+    public function getName()
100
+    {
101
+        return $this->name;
102
+    }
103
+
104
+    /**
105
+     * Returns the description of trigger file
106
+     *
107
+     * @return string
108
+     */
109
+    public function getDesc()
110
+    {
111
+        return $this->description;
112
+    }
113
+
114
+    /**
115
+     * Returns the version of the trigger file
116
+     *
117
+     * @return string Version of trigger file
118
+     */
119
+    public function getVersion()
120
+    {
121
+        global $langs;
122
+        $langs->load("admin");
123
+
124
+        if ($this->version == self::VERSION_DEVELOPMENT) {
125
+            return $langs->trans("VersionDevelopment");
126
+        } elseif ($this->version == self::VERSION_EXPERIMENTAL) {
127
+            return $langs->trans("VersionExperimental");
128
+        } elseif ($this->version == self::VERSION_DOLIBARR) {
129
+            return DOL_VERSION;
130
+        } elseif ($this->version) {
131
+            return $this->version;
132
+        } else {
133
+            return $langs->trans("Unknown");
134
+        }
135
+    }
136
+
137
+    /**
138
+     * Function called when a Dolibarrr business event is done.
139
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
140
+     *
141
+     * @param string		$action		Event action code
142
+     * @param Object		$object     Object
143
+     * @param User		    $user       Object user
144
+     * @param Translate 	$langs      Object langs
145
+     * @param conf		    $conf       Object conf
146
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
147
+     */
148
+    abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf);
149 149
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php 3 patches
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -107,233 +107,233 @@
 block discarded – undo
107 107
      */
108 108
     public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
109 109
     {
110
-		$ok = 0;
111
-
112
-    	switch ($action) {
113
-    		case 'TICKET_ASSIGNED':
114
-	            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
115
-
116
-	            if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id)
117
-	            {
118
-	                $userstat = new User($this->db);
119
-	                $res = $userstat->fetch($object->fk_user_assign);
120
-	                if ($res > 0)
121
-	                {
122
-	                	if (empty($conf->global->TICKET_DISABLE_ALL_MAILS))
123
-	                	{
124
-	                		// Init to avoid errors
125
-	                		$filepath = array();
126
-	                		$filename = array();
127
-	                		$mimetype = array();
128
-
129
-	                		// Send email to assigned user
130
-		                    $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
131
-		                    $message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
132
-		                    $message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
133
-		                    $message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
134
-		                    $message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
135
-		                    $message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
136
-		                    // Extrafields
137
-		                    if (is_array($object->array_options) && count($object->array_options) > 0) {
138
-		                        foreach ($object->array_options as $key => $value) {
139
-	                                $message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
140
-		                        }
141
-		                    }
142
-
143
-		                    $message .= '</ul>';
144
-		                    $message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
145
-		                    $message .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
146
-
147
-		                    $sendto = $userstat->email;
148
-		                    $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
149
-
150
-	                        $message = dol_nl2br($message);
151
-
152
-	                        if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
153
-	                            $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
154
-	                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
155
-	                        }
156
-	                        include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
157
-		                    $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
158
-		                    if ($mailfile->error) {
159
-	                            setEventMessages($mailfile->error, $mailfile->errors, 'errors');
160
-		                    } else {
161
-		                        $result = $mailfile->sendfile();
162
-		                    }
163
-	                        if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
164
-	                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
165
-	                        }
166
-	                	}
110
+        $ok = 0;
111
+
112
+        switch ($action) {
113
+            case 'TICKET_ASSIGNED':
114
+                dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
115
+
116
+                if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id)
117
+                {
118
+                    $userstat = new User($this->db);
119
+                    $res = $userstat->fetch($object->fk_user_assign);
120
+                    if ($res > 0)
121
+                    {
122
+                        if (empty($conf->global->TICKET_DISABLE_ALL_MAILS))
123
+                        {
124
+                            // Init to avoid errors
125
+                            $filepath = array();
126
+                            $filename = array();
127
+                            $mimetype = array();
128
+
129
+                            // Send email to assigned user
130
+                            $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
131
+                            $message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
132
+                            $message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
133
+                            $message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
134
+                            $message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
135
+                            $message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
136
+                            // Extrafields
137
+                            if (is_array($object->array_options) && count($object->array_options) > 0) {
138
+                                foreach ($object->array_options as $key => $value) {
139
+                                    $message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
140
+                                }
141
+                            }
142
+
143
+                            $message .= '</ul>';
144
+                            $message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
145
+                            $message .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
146
+
147
+                            $sendto = $userstat->email;
148
+                            $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
149
+
150
+                            $message = dol_nl2br($message);
151
+
152
+                            if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
153
+                                $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
154
+                                $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
155
+                            }
156
+                            include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
157
+                            $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
158
+                            if ($mailfile->error) {
159
+                                setEventMessages($mailfile->error, $mailfile->errors, 'errors');
160
+                            } else {
161
+                                $result = $mailfile->sendfile();
162
+                            }
163
+                            if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
164
+                                $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
165
+                            }
166
+                        }
167 167
 
168 168
                         $ok = 1;
169
-	                }
170
-	                else
171
-	                {
172
-	                	$this->error = $userstat->error;
173
-	                	$this->errors = $userstat->errors;
174
-	                }
175
-	            }
176
-	            break;
177
-
178
-    		case 'TICKET_CREATE':
179
-	            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
180
-
181
-	            $langs->load('ticket');
182
-
183
-	            $object->fetch('', $object->track_id);	// Should be useless
184
-
185
-
186
-	            // Send email to notification email
187
-
188
-	            if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']))
189
-	            {
190
-		            $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
191
-
192
-		            if ($sendto)
193
-					{
194
-						// Init to avoid errors
195
-						$filepath = array();
196
-						$filename = array();
197
-						$mimetype = array();
198
-
199
-						/* Send email to admin */
200
-			            $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
201
-			            $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
202
-			            $message_admin.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
203
-			            $message_admin.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
204
-			            $message_admin.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
205
-			            $message_admin.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
206
-			            $message_admin.='<li>'.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
207
-			            // Extrafields
208
-			            if (is_array($object->array_options) && count($object->array_options) > 0) {
209
-			                foreach ($object->array_options as $key => $value) {
210
-			                      $message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>';
211
-			                }
212
-			            }
213
-			            $message_admin.='</ul>';
214
-
215
-			            if ($object->fk_soc > 0) {
216
-			                      $object->fetch_thirdparty();
217
-			                      $message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
218
-			            }
219
-
220
-			            $message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
221
-			            $message_admin.='<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
222
-
223
-			            $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
224
-			            $replyto = $from;
225
-
226
-		                $message_admin = dol_nl2br($message_admin);
227
-
228
-		                if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
229
-		                    $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
230
-		                    $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
231
-		                }
232
-		                include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
233
-			            $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
234
-			            if ($mailfile->error) {
235
-		                    dol_syslog($mailfile->error, LOG_DEBUG);
236
-			            } else {
237
-			                     $result=$mailfile->sendfile();
238
-			            }
239
-		                if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
240
-		                    $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
241
-		                }
242
-					}
243
-	            }
244
-
245
-				// Send email to customer
246
-
247
-				if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create)
248
-	            {
249
-		            $sendto = '';
250
-		            if (empty($user->socid) && empty($user->email)) {
251
-		                      $object->fetch_thirdparty();
252
-		                      $sendto = $object->thirdparty->email;
253
-		            } else {
254
-		                $sendto = $user->email;
255
-		            }
256
-
257
-		            if ($sendto) {
258
-		            	// Init to avoid errors
259
-		            	$filepath = array();
260
-		            	$filename = array();
261
-		            	$mimetype = array();
262
-
263
-		            	$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
264
-			            $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
265
-			            $message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
266
-			            $message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
267
-			            $message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
268
-			            $message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
269
-
270
-			            // Extrafields
271
-			            foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
272
-			            {
273
-			            	$enabled = 1;
274
-			            	if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
275
-			            	{
276
-			            		$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
277
-			            	}
278
-			            	$perms = 1;
279
-			            	if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
280
-			            	{
281
-			            		$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
282
-			            	}
283
-
284
-			            	$qualified = true;
285
-			            	if (empty($enabled)) $qualified = false;
286
-			            	if (empty($perms)) $qualified = false;
287
-
288
-			            	if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
289
-			            }
290
-
291
-			            $message_customer.='</ul>';
292
-			            $message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
293
-			            $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE?$conf->global->TICKET_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
294
-			            $message_customer.='<p>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
295
-			            $message_customer.='<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
296
-
297
-			            $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
298
-			            $replyto = $from;
299
-
300
-	                    $message_customer = dol_nl2br($message_customer);
301
-
302
-	                    if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
303
-	                        $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
304
-	                        $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
305
-	                    }
306
-	                    include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
307
-			            $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
308
-			            if ($mailfile->error) {
309
-	                        dol_syslog($mailfile->error, LOG_DEBUG);
310
-			            } else {
311
-			                      $result=$mailfile->sendfile();
312
-			            }
313
-	                    if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
314
-	                        $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
315
-	                    }
316
-	                }
317
-	            }
169
+                    }
170
+                    else
171
+                    {
172
+                        $this->error = $userstat->error;
173
+                        $this->errors = $userstat->errors;
174
+                    }
175
+                }
176
+                break;
177
+
178
+            case 'TICKET_CREATE':
179
+                dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
180
+
181
+                $langs->load('ticket');
182
+
183
+                $object->fetch('', $object->track_id);	// Should be useless
184
+
185
+
186
+                // Send email to notification email
187
+
188
+                if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']))
189
+                {
190
+                    $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
191
+
192
+                    if ($sendto)
193
+                    {
194
+                        // Init to avoid errors
195
+                        $filepath = array();
196
+                        $filename = array();
197
+                        $mimetype = array();
198
+
199
+                        /* Send email to admin */
200
+                        $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
201
+                        $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
202
+                        $message_admin.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
203
+                        $message_admin.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
204
+                        $message_admin.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
205
+                        $message_admin.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
206
+                        $message_admin.='<li>'.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
207
+                        // Extrafields
208
+                        if (is_array($object->array_options) && count($object->array_options) > 0) {
209
+                            foreach ($object->array_options as $key => $value) {
210
+                                    $message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>';
211
+                            }
212
+                        }
213
+                        $message_admin.='</ul>';
214
+
215
+                        if ($object->fk_soc > 0) {
216
+                                    $object->fetch_thirdparty();
217
+                                    $message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
218
+                        }
219
+
220
+                        $message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
221
+                        $message_admin.='<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
222
+
223
+                        $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
224
+                        $replyto = $from;
225
+
226
+                        $message_admin = dol_nl2br($message_admin);
227
+
228
+                        if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
229
+                            $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
230
+                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
231
+                        }
232
+                        include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
233
+                        $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
234
+                        if ($mailfile->error) {
235
+                            dol_syslog($mailfile->error, LOG_DEBUG);
236
+                        } else {
237
+                                    $result=$mailfile->sendfile();
238
+                        }
239
+                        if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
240
+                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
241
+                        }
242
+                    }
243
+                }
244
+
245
+                // Send email to customer
246
+
247
+                if (empty($conf->global->TICKET_DISABLE_ALL_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create)
248
+                {
249
+                    $sendto = '';
250
+                    if (empty($user->socid) && empty($user->email)) {
251
+                                $object->fetch_thirdparty();
252
+                                $sendto = $object->thirdparty->email;
253
+                    } else {
254
+                        $sendto = $user->email;
255
+                    }
256
+
257
+                    if ($sendto) {
258
+                        // Init to avoid errors
259
+                        $filepath = array();
260
+                        $filename = array();
261
+                        $mimetype = array();
262
+
263
+                        $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
264
+                        $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
265
+                        $message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
266
+                        $message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
267
+                        $message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
268
+                        $message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
269
+
270
+                        // Extrafields
271
+                        foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
272
+                        {
273
+                            $enabled = 1;
274
+                            if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
275
+                            {
276
+                                $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
277
+                            }
278
+                            $perms = 1;
279
+                            if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
280
+                            {
281
+                                $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
282
+                            }
283
+
284
+                            $qualified = true;
285
+                            if (empty($enabled)) $qualified = false;
286
+                            if (empty($perms)) $qualified = false;
287
+
288
+                            if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
289
+                        }
290
+
291
+                        $message_customer.='</ul>';
292
+                        $message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
293
+                        $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE?$conf->global->TICKET_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
294
+                        $message_customer.='<p>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
295
+                        $message_customer.='<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
296
+
297
+                        $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
298
+                        $replyto = $from;
299
+
300
+                        $message_customer = dol_nl2br($message_customer);
301
+
302
+                        if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
303
+                            $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
304
+                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
305
+                        }
306
+                        include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
307
+                        $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
308
+                        if ($mailfile->error) {
309
+                            dol_syslog($mailfile->error, LOG_DEBUG);
310
+                        } else {
311
+                                    $result=$mailfile->sendfile();
312
+                        }
313
+                        if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
314
+                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
315
+                        }
316
+                    }
317
+                }
318 318
                 $ok = 1;
319
-	            break;
319
+                break;
320 320
 
321 321
             case 'TICKET_DELETE':
322
-            	dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
323
-            	break;
322
+                dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
323
+                break;
324 324
 
325
-           	case 'TICKET_MODIFY':
326
-           		dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
327
-           		break;
325
+                case 'TICKET_MODIFY':
326
+                   dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
327
+                    break;
328 328
 
329
-           	case 'TICKET_MARK_READ':
330
-           		dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
331
-           		break;
329
+                case 'TICKET_MARK_READ':
330
+                   dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
331
+                    break;
332 332
 
333
-           	case 'TICKET_CLOSE':
334
-           		dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
335
-           		break;
336
-    	}
333
+                case 'TICKET_CLOSE':
334
+                   dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
335
+                    break;
336
+        }
337 337
 
338 338
 
339 339
         return $ok;
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
     	switch ($action) {
113 113
     		case 'TICKET_ASSIGNED':
114
-	            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
114
+	            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
115 115
 
116 116
 	            if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id)
117 117
 	            {
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 	                		$mimetype = array();
128 128
 
129 129
 	                		// Send email to assigned user
130
-		                    $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
131
-		                    $message = '<p>' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "</p>";
132
-		                    $message .= '<ul><li>' . $langs->trans('Title') . ' : ' . $object->subject . '</li>';
133
-		                    $message .= '<li>' . $langs->trans('Type') . ' : ' . $object->type_label . '</li>';
134
-		                    $message .= '<li>' . $langs->trans('Category') . ' : ' . $object->category_label . '</li>';
135
-		                    $message .= '<li>' . $langs->trans('Severity') . ' : ' . $object->severity_label . '</li>';
130
+		                    $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketAssignedToYou');
131
+		                    $message = '<p>'.$langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname))."</p>";
132
+		                    $message .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
133
+		                    $message .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
134
+		                    $message .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
135
+		                    $message .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
136 136
 		                    // Extrafields
137 137
 		                    if (is_array($object->array_options) && count($object->array_options) > 0) {
138 138
 		                        foreach ($object->array_options as $key => $value) {
139
-	                                $message .= '<li>' . $langs->trans($key) . ' : ' . $value . '</li>';
139
+	                                $message .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
140 140
 		                        }
141 141
 		                    }
142 142
 
143 143
 		                    $message .= '</ul>';
144
-		                    $message .= '<p>' . $langs->trans('Message') . ' : <br>' . $object->message . '</p>';
145
-		                    $message .= '<p><a href="' . dol_buildpath('/ticket/card.php', 2) . '?track_id=' . $object->track_id . '">' . $langs->trans('SeeThisTicketIntomanagementInterface') . '</a></p>';
144
+		                    $message .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
145
+		                    $message .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
146 146
 
147 147
 		                    $sendto = $userstat->email;
148
-		                    $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
148
+		                    $from = dolGetFirstLastname($user->firstname, $user->lastname).'<'.$user->email.'>';
149 149
 
150 150
 	                        $message = dol_nl2br($message);
151 151
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	                            $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
154 154
 	                            $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
155 155
 	                        }
156
-	                        include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
156
+	                        include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
157 157
 		                    $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
158 158
 		                    if ($mailfile->error) {
159 159
 	                            setEventMessages($mailfile->error, $mailfile->errors, 'errors');
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 	            break;
177 177
 
178 178
     		case 'TICKET_CREATE':
179
-	            dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
179
+	            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
180 180
 
181 181
 	            $langs->load('ticket');
182 182
 
183
-	            $object->fetch('', $object->track_id);	// Should be useless
183
+	            $object->fetch('', $object->track_id); // Should be useless
184 184
 
185 185
 
186 186
 	            // Send email to notification email
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 
199 199
 						/* Send email to admin */
200 200
 			            $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
201
-			            $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
202
-			            $message_admin.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
203
-			            $message_admin.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
204
-			            $message_admin.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
205
-			            $message_admin.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
206
-			            $message_admin.='<li>'.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'</li>';
201
+			            $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
202
+			            $message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
203
+			            $message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
204
+			            $message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
205
+			            $message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
206
+			            $message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
207 207
 			            // Extrafields
208 208
 			            if (is_array($object->array_options) && count($object->array_options) > 0) {
209 209
 			                foreach ($object->array_options as $key => $value) {
210
-			                      $message_admin.='<li>'.$langs->trans($key).' : '.$value.'</li>';
210
+			                      $message_admin .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
211 211
 			                }
212 212
 			            }
213
-			            $message_admin.='</ul>';
213
+			            $message_admin .= '</ul>';
214 214
 
215 215
 			            if ($object->fk_soc > 0) {
216 216
 			                      $object->fetch_thirdparty();
217
-			                      $message_admin.='<p>'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'</p>';
217
+			                      $message_admin .= '<p>'.$langs->trans('Company').' : '.$object->thirdparty->name.'</p>';
218 218
 			            }
219 219
 
220
-			            $message_admin.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
221
-			            $message_admin.='<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
220
+			            $message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
221
+			            $message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
222 222
 
223 223
 			            $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
224 224
 			            $replyto = $from;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			            if ($mailfile->error) {
235 235
 		                    dol_syslog($mailfile->error, LOG_DEBUG);
236 236
 			            } else {
237
-			                     $result=$mailfile->sendfile();
237
+			                     $result = $mailfile->sendfile();
238 238
 			            }
239 239
 		                if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
240 240
 		                    $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 		            	$mimetype = array();
262 262
 
263 263
 		            	$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
264
-			            $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
265
-			            $message_customer.='<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
266
-			            $message_customer.='<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
267
-			            $message_customer.='<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
268
-			            $message_customer.='<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
264
+			            $message_customer = $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
265
+			            $message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
266
+			            $message_customer .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
267
+			            $message_customer .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
268
+			            $message_customer .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
269 269
 
270 270
 			            // Extrafields
271 271
 			            foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 			            	if (empty($enabled)) $qualified = false;
286 286
 			            	if (empty($perms)) $qualified = false;
287 287
 
288
-			            	if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
288
+			            	if ($qualified) $message_customer .= '<li>'.$langs->trans($key).' : '.$value.'</li>';
289 289
 			            }
290 290
 
291
-			            $message_customer.='</ul>';
292
-			            $message_customer.='<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
293
-			            $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE?$conf->global->TICKET_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
294
-			            $message_customer.='<p>' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
295
-			            $message_customer.='<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
291
+			            $message_customer .= '</ul>';
292
+			            $message_customer .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
293
+			            $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
294
+			            $message_customer .= '<p>'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$url_public_ticket.'</a></p>';
295
+			            $message_customer .= '<p>'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'</p>';
296 296
 
297 297
 			            $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
298 298
 			            $replyto = $from;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 			            if ($mailfile->error) {
309 309
 	                        dol_syslog($mailfile->error, LOG_DEBUG);
310 310
 			            } else {
311
-			                      $result=$mailfile->sendfile();
311
+			                      $result = $mailfile->sendfile();
312 312
 			            }
313 313
 	                    if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
314 314
 	                        $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
@@ -319,19 +319,19 @@  discard block
 block discarded – undo
319 319
 	            break;
320 320
 
321 321
             case 'TICKET_DELETE':
322
-            	dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
322
+            	dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
323 323
             	break;
324 324
 
325 325
            	case 'TICKET_MODIFY':
326
-           		dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
326
+           		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
327 327
            		break;
328 328
 
329 329
            	case 'TICKET_MARK_READ':
330
-           		dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
330
+           		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
331 331
            		break;
332 332
 
333 333
            	case 'TICKET_CLOSE':
334
-           		dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
334
+           		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
335 335
            		break;
336 336
     	}
337 337
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
 	                	}
167 167
 
168 168
                         $ok = 1;
169
-	                }
170
-	                else
169
+	                } else
171 170
 	                {
172 171
 	                	$this->error = $userstat->error;
173 172
 	                	$this->errors = $userstat->errors;
@@ -282,10 +281,16 @@  discard block
 block discarded – undo
282 281
 			            	}
283 282
 
284 283
 			            	$qualified = true;
285
-			            	if (empty($enabled)) $qualified = false;
286
-			            	if (empty($perms)) $qualified = false;
284
+			            	if (empty($enabled)) {
285
+			            	    $qualified = false;
286
+			            	}
287
+			            	if (empty($perms)) {
288
+			            	    $qualified = false;
289
+			            	}
287 290
 
288
-			            	if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
291
+			            	if ($qualified) {
292
+			            	    $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
293
+			            	}
289 294
 			            }
290 295
 
291 296
 			            $message_customer.='</ul>';
Please login to merge, or discard this patch.
htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php 3 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -30,121 +30,121 @@
 block discarded – undo
30 30
  */
31 31
 class InterfaceActionsBlockedLog extends DolibarrTriggers
32 32
 {
33
-	public $family = 'system';
34
-	public $description = "Triggers of this module add action for BlockedLog module.";
35
-
36
-	/**
37
-	 * Version of the trigger
38
-	 * @var string
39
-	 */
40
-	public $version = self::VERSION_DOLIBARR;
41
-
42
-	/**
43
-	 * @var string Image of the trigger
44
-	 */
45
-	public $picto = 'technic';
46
-
47
-	/**
48
-	 * Function called on Dolibarrr payment or invoice event.
49
-	 *
50
-	 * @param string		$action		Event action code
51
-	 * @param Object		$object     Object
52
-	 * @param User		    $user       Object user
53
-	 * @param Translate 	$langs      Object langs
54
-	 * @param conf		    $conf       Object conf
55
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
56
-	 */
57
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58
-	{
59
-		if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
60
-
61
-		// Test if event/record is qualified
62
-		$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
63
-		if (! in_array($object->element, $listofqualifiedelement)) return 1;
64
-
65
-		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
66
-
67
-		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
68
-		$b=new BlockedLog($this->db);
69
-
70
-		// Tracked events
71
-		if (! in_array($action, array_keys($b->trackedevents)))
72
-		{
73
-			return 0;
74
-		}
75
-
76
-		// Event/record is qualified
77
-		$qualified = 0;
78
-		$amounts = 0;
79
-		if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL'
80
-			|| $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL'
81
-			|| $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE'
82
-			|| $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE'
83
-			|| $action==='CASHCONTROL_VALIDATE'
84
-			|| (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
85
-		)
86
-		{
87
-			$qualified++;
88
-
89
-			if (in_array($action, array(
90
-				'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE',
91
-				'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount;
92
-			elseif ($action == 'CASHCONTROL_VALIDATE')
93
-			{
94
-				$amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card;
95
-			}
96
-			else $amounts = (double) $object->total_ttc;
97
-		}
98
-		/*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
33
+    public $family = 'system';
34
+    public $description = "Triggers of this module add action for BlockedLog module.";
35
+
36
+    /**
37
+     * Version of the trigger
38
+     * @var string
39
+     */
40
+    public $version = self::VERSION_DOLIBARR;
41
+
42
+    /**
43
+     * @var string Image of the trigger
44
+     */
45
+    public $picto = 'technic';
46
+
47
+    /**
48
+     * Function called on Dolibarrr payment or invoice event.
49
+     *
50
+     * @param string		$action		Event action code
51
+     * @param Object		$object     Object
52
+     * @param User		    $user       Object user
53
+     * @param Translate 	$langs      Object langs
54
+     * @param conf		    $conf       Object conf
55
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
56
+     */
57
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58
+    {
59
+        if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
60
+
61
+        // Test if event/record is qualified
62
+        $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
63
+        if (! in_array($object->element, $listofqualifiedelement)) return 1;
64
+
65
+        dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
66
+
67
+        require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
68
+        $b=new BlockedLog($this->db);
69
+
70
+        // Tracked events
71
+        if (! in_array($action, array_keys($b->trackedevents)))
72
+        {
73
+            return 0;
74
+        }
75
+
76
+        // Event/record is qualified
77
+        $qualified = 0;
78
+        $amounts = 0;
79
+        if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL'
80
+            || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL'
81
+            || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE'
82
+            || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE'
83
+            || $action==='CASHCONTROL_VALIDATE'
84
+            || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
85
+        )
86
+        {
87
+            $qualified++;
88
+
89
+            if (in_array($action, array(
90
+                'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE',
91
+                'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount;
92
+            elseif ($action == 'CASHCONTROL_VALIDATE')
93
+            {
94
+                $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card;
95
+            }
96
+            else $amounts = (double) $object->total_ttc;
97
+        }
98
+        /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
99 99
 		 || $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED')
100 100
 		{
101 101
 			$qualified++;
102 102
 			$amounts=  (double) $object->total_ttc;
103 103
 		}*/
104
-		if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE' || $action === 'DONATION_PAYMENT_CREATE'
105
-			|| $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE')
106
-		{
107
-			$qualified++;
108
-			$amounts = 0;
109
-			if(!empty($object->amounts)) {
110
-				foreach($object->amounts as $amount) {
111
-					$amounts += price2num($amount);
112
-				}
113
-			}
114
-		}
115
-		elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
116
-		{
117
-			$qualified++;
118
-			$amounts = (double) $object->amount;
119
-		}
120
-
121
-		// Another protection.
122
-		// May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice
123
-		if (! $qualified)
124
-		{
125
-			return 0; // not implemented action log
126
-		}
127
-
128
-		$result = $b->setObjectData($object, $action, $amounts, $user);		// Set field date_object, ref_object, fk_object, element, object_data
129
-
130
-		if ($result < 0)
131
-		{
132
-			$this->error = $b->error;
133
-			$this->errors = $b->errors;
134
-			return -1;
135
-		}
136
-
137
-		$res = $b->create($user);
138
-
139
-		if ($res < 0)
140
-		{
141
-			$this->error = $b->error;
142
-			$this->errors = $b->errors;
143
-			return -1;
144
-		}
145
-		else
146
-		{
147
-			return 1;
148
-		}
104
+        if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE' || $action === 'DONATION_PAYMENT_CREATE'
105
+            || $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE')
106
+        {
107
+            $qualified++;
108
+            $amounts = 0;
109
+            if(!empty($object->amounts)) {
110
+                foreach($object->amounts as $amount) {
111
+                    $amounts += price2num($amount);
112
+                }
113
+            }
114
+        }
115
+        elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
116
+        {
117
+            $qualified++;
118
+            $amounts = (double) $object->amount;
119
+        }
120
+
121
+        // Another protection.
122
+        // May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice
123
+        if (! $qualified)
124
+        {
125
+            return 0; // not implemented action log
126
+        }
127
+
128
+        $result = $b->setObjectData($object, $action, $amounts, $user);		// Set field date_object, ref_object, fk_object, element, object_data
129
+
130
+        if ($result < 0)
131
+        {
132
+            $this->error = $b->error;
133
+            $this->errors = $b->errors;
134
+            return -1;
135
+        }
136
+
137
+        $res = $b->create($user);
138
+
139
+        if ($res < 0)
140
+        {
141
+            $this->error = $b->error;
142
+            $this->errors = $b->errors;
143
+            return -1;
144
+        }
145
+        else
146
+        {
147
+            return 1;
148
+        }
149 149
     }
150 150
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -56,19 +56,19 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58 58
 	{
59
-		if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
59
+		if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing
60 60
 
61 61
 		// Test if event/record is qualified
62 62
 		$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
63
-		if (! in_array($object->element, $listofqualifiedelement)) return 1;
63
+		if (!in_array($object->element, $listofqualifiedelement)) return 1;
64 64
 
65 65
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
66 66
 
67 67
 		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
68
-		$b=new BlockedLog($this->db);
68
+		$b = new BlockedLog($this->db);
69 69
 
70 70
 		// Tracked events
71
-		if (! in_array($action, array_keys($b->trackedevents)))
71
+		if (!in_array($action, array_keys($b->trackedevents)))
72 72
 		{
73 73
 			return 0;
74 74
 		}
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 		// Event/record is qualified
77 77
 		$qualified = 0;
78 78
 		$amounts = 0;
79
-		if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL'
80
-			|| $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL'
81
-			|| $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE'
82
-			|| $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE'
83
-			|| $action==='CASHCONTROL_VALIDATE'
84
-			|| (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
79
+		if ($action === 'BILL_VALIDATE' || $action === 'BILL_DELETE' || $action === 'BILL_SENTBYMAIL'
80
+			|| $action === 'BILL_SUPPLIER_VALIDATE' || $action === 'BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL'
81
+			|| $action === 'MEMBER_SUBSCRIPTION_CREATE' || $action === 'MEMBER_SUBSCRIPTION_MODIFY' || $action === 'MEMBER_SUBSCRIPTION_DELETE'
82
+			|| $action === 'DON_VALIDATE' || $action === 'DON_MODIFY' || $action === 'DON_DELETE'
83
+			|| $action === 'CASHCONTROL_VALIDATE'
84
+			|| (in_array($object->element, array('facture', 'suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture', 'suplier_invoice')) && $action === 'DOC_PREVIEW')
85 85
 		)
86 86
 		{
87 87
 			$qualified++;
88 88
 
89 89
 			if (in_array($action, array(
90
-				'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE',
91
-				'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount;
90
+				'MEMBER_SUBSCRIPTION_CREATE', 'MEMBER_SUBSCRIPTION_MODIFY', 'MEMBER_SUBSCRIPTION_DELETE',
91
+				'DON_VALIDATE', 'DON_MODIFY', 'DON_DELETE'))) $amounts = (double) $object->amount;
92 92
 			elseif ($action == 'CASHCONTROL_VALIDATE')
93 93
 			{
94 94
 				$amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card;
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 		{
107 107
 			$qualified++;
108 108
 			$amounts = 0;
109
-			if(!empty($object->amounts)) {
110
-				foreach($object->amounts as $amount) {
109
+			if (!empty($object->amounts)) {
110
+				foreach ($object->amounts as $amount) {
111 111
 					$amounts += price2num($amount);
112 112
 				}
113 113
 			}
114 114
 		}
115
-		elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
115
+		elseif (strpos($action, 'PAYMENT') !== false && !in_array($action, array('PAYMENT_ADD_TO_BANK')))
116 116
 		{
117 117
 			$qualified++;
118 118
 			$amounts = (double) $object->amount;
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 
121 121
 		// Another protection.
122 122
 		// May be used when event is DOC_DOWNLOAD or DOC_PREVIEW and element is not an invoice
123
-		if (! $qualified)
123
+		if (!$qualified)
124 124
 		{
125 125
 			return 0; // not implemented action log
126 126
 		}
127 127
 
128
-		$result = $b->setObjectData($object, $action, $amounts, $user);		// Set field date_object, ref_object, fk_object, element, object_data
128
+		$result = $b->setObjectData($object, $action, $amounts, $user); // Set field date_object, ref_object, fk_object, element, object_data
129 129
 
130 130
 		if ($result < 0)
131 131
 		{
Please login to merge, or discard this patch.
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,11 +56,16 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58 58
 	{
59
-		if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
59
+		if (empty($conf->blockedlog->enabled)) {
60
+		    return 0;
61
+		}
62
+		// Module not active, we do nothing
60 63
 
61 64
 		// Test if event/record is qualified
62 65
 		$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
63
-		if (! in_array($object->element, $listofqualifiedelement)) return 1;
66
+		if (! in_array($object->element, $listofqualifiedelement)) {
67
+		    return 1;
68
+		}
64 69
 
65 70
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
66 71
 
@@ -88,12 +93,14 @@  discard block
 block discarded – undo
88 93
 
89 94
 			if (in_array($action, array(
90 95
 				'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE',
91
-				'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount;
92
-			elseif ($action == 'CASHCONTROL_VALIDATE')
96
+				'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) {
97
+			    $amounts = (double) $object->amount;
98
+			} elseif ($action == 'CASHCONTROL_VALIDATE')
93 99
 			{
94 100
 				$amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card;
101
+			} else {
102
+			    $amounts = (double) $object->total_ttc;
95 103
 			}
96
-			else $amounts = (double) $object->total_ttc;
97 104
 		}
98 105
 		/*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
99 106
 		 || $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED')
@@ -111,8 +118,7 @@  discard block
 block discarded – undo
111 118
 					$amounts += price2num($amount);
112 119
 				}
113 120
 			}
114
-		}
115
-		elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
121
+		} elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
116 122
 		{
117 123
 			$qualified++;
118 124
 			$amounts = (double) $object->amount;
@@ -141,8 +147,7 @@  discard block
 block discarded – undo
141 147
 			$this->error = $b->error;
142 148
 			$this->errors = $b->errors;
143 149
 			return -1;
144
-		}
145
-		else
150
+		} else
146 151
 		{
147 152
 			return 1;
148 153
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/db/Database.interface.php 2 patches
Indentation   +390 added lines, -390 removed lines patch added patch discarded remove patch
@@ -25,479 +25,479 @@
 block discarded – undo
25 25
  */
26 26
 interface Database
27 27
 {
28
-	/**
29
-	 * Format a SQL IF
30
-	 *
31
-	 * @param   string $test Test string (example: 'cd.statut=0', 'field IS NULL')
32
-	 * @param   string $resok resultat si test egal
33
-	 * @param   string $resko resultat si test non egal
34
-	 * @return	string                SQL string
35
-	 */
36
-	function ifsql($test, $resok, $resko);
28
+    /**
29
+     * Format a SQL IF
30
+     *
31
+     * @param   string $test Test string (example: 'cd.statut=0', 'field IS NULL')
32
+     * @param   string $resok resultat si test egal
33
+     * @param   string $resko resultat si test non egal
34
+     * @return	string                SQL string
35
+     */
36
+    function ifsql($test, $resok, $resko);
37 37
 
38 38
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
39
-	/**
40
-	 * Return datas as an array
41
-	 *
42
-	 * @param   resource $resultset Resultset of request
43
-	 * @return  array                    Array
44
-	 */
39
+    /**
40
+     * Return datas as an array
41
+     *
42
+     * @param   resource $resultset Resultset of request
43
+     * @return  array                    Array
44
+     */
45 45
     function fetch_row($resultset);
46 46
     // phpcs:enable
47 47
 
48
-	/**
49
-	 * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
50
-	 * Function to use to build INSERT, UPDATE or WHERE predica
51
-	 *
52
-	 * @param   int		$param 		Date TMS to convert
53
-	 * @return  string            	Date in a string YYYYMMDDHHMMSS
54
-	 */
55
-	function idate($param);
56
-
57
-	/**
58
-	 * Return last error code
59
-	 *
60
-	 * @return  string    lasterrno
61
-	 */
62
-	function lasterrno();
63
-
64
-	/**
65
-	 * Start transaction
66
-	 *
67
-	 * @return  int         1 if transaction successfuly opened or already opened, 0 if error
68
-	 */
69
-	function begin();
48
+    /**
49
+     * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
50
+     * Function to use to build INSERT, UPDATE or WHERE predica
51
+     *
52
+     * @param   int		$param 		Date TMS to convert
53
+     * @return  string            	Date in a string YYYYMMDDHHMMSS
54
+     */
55
+    function idate($param);
56
+
57
+    /**
58
+     * Return last error code
59
+     *
60
+     * @return  string    lasterrno
61
+     */
62
+    function lasterrno();
63
+
64
+    /**
65
+     * Start transaction
66
+     *
67
+     * @return  int         1 if transaction successfuly opened or already opened, 0 if error
68
+     */
69
+    function begin();
70 70
 
71 71
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
72
-	/**
73
-	 * Create a new database
74
-	 * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
75
-	 * We force to create database with charset this->forcecharset and collate this->forcecollate
76
-	 *
77
-	 * @param   string 		$database 		Database name to create
78
-	 * @param   string 		$charset 		Charset used to store data
79
-	 * @param   string 		$collation 		Charset used to sort data
80
-	 * @param   string 		$owner 			Username of database owner
81
-	 * @return  resource                	resource defined if OK, null if KO
82
-	 */
72
+    /**
73
+     * Create a new database
74
+     * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
75
+     * We force to create database with charset this->forcecharset and collate this->forcecollate
76
+     *
77
+     * @param   string 		$database 		Database name to create
78
+     * @param   string 		$charset 		Charset used to store data
79
+     * @param   string 		$collation 		Charset used to sort data
80
+     * @param   string 		$owner 			Username of database owner
81
+     * @return  resource                	resource defined if OK, null if KO
82
+     */
83 83
     function DDLCreateDb($database, $charset = '', $collation = '', $owner = '');
84 84
     // phpcs:enable
85 85
 
86
-	/**
87
-	 * Return version of database server into an array
88
-	 *
89
-	 * @return	array        Version array
90
-	 */
91
-	function getVersionArray();
92
-
93
-	/**
94
-	 *  Convert a SQL request in Mysql syntax to native syntax
95
-	 *
96
-	 * @param   string $line SQL request line to convert
97
-	 * @param   string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
98
-	 * @return  string        SQL request line converted
99
-	 */
100
-	static function convertSQLFromMysql($line, $type = 'ddl');
86
+    /**
87
+     * Return version of database server into an array
88
+     *
89
+     * @return	array        Version array
90
+     */
91
+    function getVersionArray();
92
+
93
+    /**
94
+     *  Convert a SQL request in Mysql syntax to native syntax
95
+     *
96
+     * @param   string $line SQL request line to convert
97
+     * @param   string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
98
+     * @return  string        SQL request line converted
99
+     */
100
+    static function convertSQLFromMysql($line, $type = 'ddl');
101 101
 
102 102
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
103
-	/**
104
-	 * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
105
-	 *
106
-	 * @param   resource $resultset Curseur de la requete voulue
107
-	 * @return 	int            Nombre de lignes
108
-	 * @see    	num_rows
109
-	 */
103
+    /**
104
+     * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE
105
+     *
106
+     * @param   resource $resultset Curseur de la requete voulue
107
+     * @return 	int            Nombre de lignes
108
+     * @see    	num_rows
109
+     */
110 110
     function affected_rows($resultset);
111 111
     // phpcs:enable
112 112
 
113
-	/**
114
-	 * Return description of last error
115
-	 *
116
-	 * @return  string        Error text
117
-	 */
118
-	function error();
113
+    /**
114
+     * Return description of last error
115
+     *
116
+     * @return  string        Error text
117
+     */
118
+    function error();
119 119
 
120 120
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
121
-	/**
122
-	 *  List tables into a database
123
-	 *
124
-	 *  @param	string		$database	Name of database
125
-	 *  @param	string		$table		Nmae of table filter ('xxx%')
126
-	 *  @return	array					List of tables in an array
127
-	 */
121
+    /**
122
+     *  List tables into a database
123
+     *
124
+     *  @param	string		$database	Name of database
125
+     *  @param	string		$table		Nmae of table filter ('xxx%')
126
+     *  @return	array					List of tables in an array
127
+     */
128 128
     function DDLListTables($database, $table = '');
129 129
     // phpcs:enable
130 130
 
131
-	/**
132
-	 * Return last request executed with query()
133
-	 *
134
-	 * @return	string                    Last query
135
-	 */
136
-	function lastquery();
137
-
138
-	/**
139
-	 * Define sort criteria of request
140
-	 *
141
-	 * @param   string $sortfield List of sort fields
142
-	 * @param   string $sortorder Sort order
143
-	 * @return  string            String to provide syntax of a sort sql string
144
-	 */
145
-	function order($sortfield = null, $sortorder = null);
146
-
147
-	/**
148
-	 * Decrypt sensitive data in database
149
-	 *
150
-	 * @param    string $value Value to decrypt
151
-	 * @return   string                    Decrypted value if used
152
-	 */
153
-	function decrypt($value);
131
+    /**
132
+     * Return last request executed with query()
133
+     *
134
+     * @return	string                    Last query
135
+     */
136
+    function lastquery();
137
+
138
+    /**
139
+     * Define sort criteria of request
140
+     *
141
+     * @param   string $sortfield List of sort fields
142
+     * @param   string $sortorder Sort order
143
+     * @return  string            String to provide syntax of a sort sql string
144
+     */
145
+    function order($sortfield = null, $sortorder = null);
146
+
147
+    /**
148
+     * Decrypt sensitive data in database
149
+     *
150
+     * @param    string $value Value to decrypt
151
+     * @return   string                    Decrypted value if used
152
+     */
153
+    function decrypt($value);
154 154
 
155 155
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
156
-	/**
157
-	 *    Return datas as an array
158
-	 *
159
-	 * @param   resource $resultset Resultset of request
160
-	 * @return  array                    Array
161
-	 */
156
+    /**
157
+     *    Return datas as an array
158
+     *
159
+     * @param   resource $resultset Resultset of request
160
+     * @return  array                    Array
161
+     */
162 162
     function fetch_array($resultset);
163 163
     // phpcs:enable
164 164
 
165
-	/**
166
-	 * Return last error label
167
-	 *
168
-	 * @return	string    lasterror
169
-	 */
170
-	function lasterror();
171
-
172
-	/**
173
-	 * Escape a string to insert data
174
-	 *
175
-	 * @param   string $stringtoencode String to escape
176
-	 * @return  string                        String escaped
177
-	 */
178
-	function escape($stringtoencode);
165
+    /**
166
+     * Return last error label
167
+     *
168
+     * @return	string    lasterror
169
+     */
170
+    function lasterror();
171
+
172
+    /**
173
+     * Escape a string to insert data
174
+     *
175
+     * @param   string $stringtoencode String to escape
176
+     * @return  string                        String escaped
177
+     */
178
+    function escape($stringtoencode);
179 179
 
180 180
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
181
-	/**
182
-	 * Get last ID after an insert INSERT
183
-	 *
184
-	 * @param	string 	$tab 		Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql
185
-	 * @param   string 	$fieldid 	Field name
186
-	 * @return  int                	Id of row
187
-	 */
181
+    /**
182
+     * Get last ID after an insert INSERT
183
+     *
184
+     * @param	string 	$tab 		Table name concerned by insert. Ne sert pas sous MySql mais requis pour compatibilite avec Postgresql
185
+     * @param   string 	$fieldid 	Field name
186
+     * @return  int                	Id of row
187
+     */
188 188
     function last_insert_id($tab, $fieldid = 'rowid');
189 189
     // phpcs:enable
190 190
 
191
-	/**
192
-	 *    Return full path of restore program
193
-	 *
194
-	 * @return        string        Full path of restore program
195
-	 */
196
-	function getPathOfRestore();
197
-
198
-	/**
199
-	 *    Annulation d'une transaction et retour aux anciennes valeurs
200
-	 *
201
-	 * @param	string $log Add more log to default log line
202
-	 * @return  int                1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
203
-	 */
204
-	function rollback($log = '');
205
-
206
-	/**
207
-	 * Execute a SQL request and return the resultset
208
-	 *
209
-	 * @param   string $query SQL query string
210
-	 * @param   int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
211
-	 *                            Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
212
-	 * @param   string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
213
-	 * @return  resource                Resultset of answer
214
-	 */
215
-	function query($query, $usesavepoint = 0, $type = 'auto');
216
-
217
-	/**
218
-	 *    Connexion to server
219
-	 *
220
-	 * @param   string $host database server host
221
-	 * @param   string $login login
222
-	 * @param   string $passwd password
223
-	 * @param   string $name name of database (not used for mysql, used for pgsql)
224
-	 * @param   int    $port Port of database server
225
-	 * @return  resource            Database access handler
226
-	 * @see     close
227
-	 */
228
-	function connect($host, $login, $passwd, $name, $port = 0);
229
-
230
-	/**
231
-	 *    Define limits and offset of request
232
-	 *
233
-	 * @param   int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
234
-	 * @param   int $offset Numero of line from where starting fetch
235
-	 * @return  string            String with SQL syntax to add a limit and offset
236
-	 */
237
-	function plimit($limit = 0, $offset = 0);
238
-
239
-	/**
240
-	 * Return value of server parameters
241
-	 *
242
-	 * @param   string	$filter		Filter list on a particular value
243
-	 * @return  array				Array of key-values (key=>value)
244
-	 */
245
-	function getServerParametersValues($filter = '');
246
-
247
-	/**
248
-	 * Return value of server status
249
-	 *
250
-	 * @param   string $filter 		Filter list on a particular value
251
-	 * @return  array				Array of key-values (key=>value)
252
-	 */
253
-	function getServerStatusValues($filter = '');
254
-
255
-	/**
256
-	 * Return collation used in database
257
-	 *
258
-	 * @return  string        Collation value
259
-	 */
260
-	function getDefaultCollationDatabase();
191
+    /**
192
+     *    Return full path of restore program
193
+     *
194
+     * @return        string        Full path of restore program
195
+     */
196
+    function getPathOfRestore();
197
+
198
+    /**
199
+     *    Annulation d'une transaction et retour aux anciennes valeurs
200
+     *
201
+     * @param	string $log Add more log to default log line
202
+     * @return  int                1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
203
+     */
204
+    function rollback($log = '');
205
+
206
+    /**
207
+     * Execute a SQL request and return the resultset
208
+     *
209
+     * @param   string $query SQL query string
210
+     * @param   int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
211
+     *                            Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
212
+     * @param   string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
213
+     * @return  resource                Resultset of answer
214
+     */
215
+    function query($query, $usesavepoint = 0, $type = 'auto');
216
+
217
+    /**
218
+     *    Connexion to server
219
+     *
220
+     * @param   string $host database server host
221
+     * @param   string $login login
222
+     * @param   string $passwd password
223
+     * @param   string $name name of database (not used for mysql, used for pgsql)
224
+     * @param   int    $port Port of database server
225
+     * @return  resource            Database access handler
226
+     * @see     close
227
+     */
228
+    function connect($host, $login, $passwd, $name, $port = 0);
229
+
230
+    /**
231
+     *    Define limits and offset of request
232
+     *
233
+     * @param   int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
234
+     * @param   int $offset Numero of line from where starting fetch
235
+     * @return  string            String with SQL syntax to add a limit and offset
236
+     */
237
+    function plimit($limit = 0, $offset = 0);
238
+
239
+    /**
240
+     * Return value of server parameters
241
+     *
242
+     * @param   string	$filter		Filter list on a particular value
243
+     * @return  array				Array of key-values (key=>value)
244
+     */
245
+    function getServerParametersValues($filter = '');
246
+
247
+    /**
248
+     * Return value of server status
249
+     *
250
+     * @param   string $filter 		Filter list on a particular value
251
+     * @return  array				Array of key-values (key=>value)
252
+     */
253
+    function getServerStatusValues($filter = '');
254
+
255
+    /**
256
+     * Return collation used in database
257
+     *
258
+     * @return  string        Collation value
259
+     */
260
+    function getDefaultCollationDatabase();
261 261
 
262 262
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
263
-	/**
264
-	 * Return number of lines for result of a SELECT
265
-	 *
266
-	 * @param   resource $resultset Resulset of requests
267
-	 * @return 	int                        Nb of lines
268
-	 * @see    	affected_rows
269
-	 */
263
+    /**
264
+     * Return number of lines for result of a SELECT
265
+     *
266
+     * @param   resource $resultset Resulset of requests
267
+     * @return 	int                        Nb of lines
268
+     * @see    	affected_rows
269
+     */
270 270
     function num_rows($resultset);
271 271
     // phpcs:enable
272 272
 
273
-	/**
274
-	 * Return full path of dump program
275
-	 *
276
-	 * @return        string        Full path of dump program
277
-	 */
278
-	function getPathOfDump();
279
-
280
-	/**
281
-	 * Return version of database client driver
282
-	 *
283
-	 * @return            string      Version string
284
-	 */
285
-	function getDriverInfo();
286
-
287
-	/**
288
-	 * Return generic error code of last operation.
289
-	 *
290
-	 * @return    string        Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...)
291
-	 */
292
-	function errno();
273
+    /**
274
+     * Return full path of dump program
275
+     *
276
+     * @return        string        Full path of dump program
277
+     */
278
+    function getPathOfDump();
279
+
280
+    /**
281
+     * Return version of database client driver
282
+     *
283
+     * @return            string      Version string
284
+     */
285
+    function getDriverInfo();
286
+
287
+    /**
288
+     * Return generic error code of last operation.
289
+     *
290
+     * @return    string        Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...)
291
+     */
292
+    function errno();
293 293
 
294 294
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
295
-	/**
296
-	 * Create a table into database
297
-	 *
298
-	 * @param        string $table 			Name of table
299
-	 * @param        array 	$fields 		Tableau associatif [nom champ][tableau des descriptions]
300
-	 * @param        string $primary_key 	Nom du champ qui sera la clef primaire
301
-	 * @param        string $type 			Type de la table
302
-	 * @param        array 	$unique_keys 	Tableau associatifs Nom de champs qui seront clef unique => valeur
303
-	 * @param        array 	$fulltext_keys 	Tableau des Nom de champs qui seront indexes en fulltext
304
-	 * @param        array $keys 			Tableau des champs cles noms => valeur
305
-	 * @return       int                    <0 if KO, >=0 if OK
306
-	 */
295
+    /**
296
+     * Create a table into database
297
+     *
298
+     * @param        string $table 			Name of table
299
+     * @param        array 	$fields 		Tableau associatif [nom champ][tableau des descriptions]
300
+     * @param        string $primary_key 	Nom du champ qui sera la clef primaire
301
+     * @param        string $type 			Type de la table
302
+     * @param        array 	$unique_keys 	Tableau associatifs Nom de champs qui seront clef unique => valeur
303
+     * @param        array 	$fulltext_keys 	Tableau des Nom de champs qui seront indexes en fulltext
304
+     * @param        array $keys 			Tableau des champs cles noms => valeur
305
+     * @return       int                    <0 if KO, >=0 if OK
306
+     */
307 307
     function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
308 308
     // phpcs:enable
309 309
 
310 310
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
311
-	/**
312
-	 * Drop a table into database
313
-	 *
314
-	 * @param        string $table 			Name of table
315
-	 * @return       int                    <0 if KO, >=0 if OK
316
-	 */
311
+    /**
312
+     * Drop a table into database
313
+     *
314
+     * @param        string $table 			Name of table
315
+     * @return       int                    <0 if KO, >=0 if OK
316
+     */
317 317
     function DDLDropTable($table);
318 318
     // phpcs:enable
319 319
 
320
-	/**
321
-	 * Return list of available charset that can be used to store data in database
322
-	 *
323
-	 * @return        array        List of Charset
324
-	 */
325
-	function getListOfCharacterSet();
320
+    /**
321
+     * Return list of available charset that can be used to store data in database
322
+     *
323
+     * @return        array        List of Charset
324
+     */
325
+    function getListOfCharacterSet();
326 326
 
327 327
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
328
-	/**
329
-	 * Create a new field into table
330
-	 *
331
-	 * @param    string $table 				Name of table
332
-	 * @param    string $field_name 		Name of field to add
333
-	 * @param    string $field_desc 		Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
334
-	 * @param    string $field_position 	Optionnel ex.: "after champtruc"
335
-	 * @return   int                        <0 if KO, >0 if OK
336
-	 */
328
+    /**
329
+     * Create a new field into table
330
+     *
331
+     * @param    string $table 				Name of table
332
+     * @param    string $field_name 		Name of field to add
333
+     * @param    string $field_desc 		Tableau associatif de description du champ a inserer[nom du parametre][valeur du parametre]
334
+     * @param    string $field_position 	Optionnel ex.: "after champtruc"
335
+     * @return   int                        <0 if KO, >0 if OK
336
+     */
337 337
     function DDLAddField($table, $field_name, $field_desc, $field_position = "");
338 338
     // phpcs:enable
339 339
 
340 340
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
341
-	/**
342
-	 * Drop a field from table
343
-	 *
344
-	 * @param    string $table 				Name of table
345
-	 * @param    string $field_name 		Name of field to drop
346
-	 * @return   int                        <0 if KO, >0 if OK
347
-	 */
341
+    /**
342
+     * Drop a field from table
343
+     *
344
+     * @param    string $table 				Name of table
345
+     * @param    string $field_name 		Name of field to drop
346
+     * @return   int                        <0 if KO, >0 if OK
347
+     */
348 348
     function DDLDropField($table, $field_name);
349 349
     // phpcs:enable
350 350
 
351 351
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
352
-	/**
353
-	 * Update format of a field into a table
354
-	 *
355
-	 * @param    string 	$table 			Name of table
356
-	 * @param    string 	$field_name 	Name of field to modify
357
-	 * @param    string 	$field_desc 	Array with description of field format
358
-	 * @return   int                        <0 if KO, >0 if OK
359
-	 */
352
+    /**
353
+     * Update format of a field into a table
354
+     *
355
+     * @param    string 	$table 			Name of table
356
+     * @param    string 	$field_name 	Name of field to modify
357
+     * @param    string 	$field_desc 	Array with description of field format
358
+     * @return   int                        <0 if KO, >0 if OK
359
+     */
360 360
     function DDLUpdateField($table, $field_name, $field_desc);
361 361
     // phpcs:enable
362 362
 
363
-	/**
364
-	 * Return list of available collation that can be used for database
365
-	 *
366
-	 * @return        array        			List of Collation
367
-	 */
368
-	function getListOfCollation();
363
+    /**
364
+     * Return list of available collation that can be used for database
365
+     *
366
+     * @return        array        			List of Collation
367
+     */
368
+    function getListOfCollation();
369 369
 
370 370
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
371
-	/**
372
-	 * Return a pointer of line with description of a table or field
373
-	 *
374
-	 * @param    string 	$table 			Name of table
375
-	 * @param    string 	$field 			Optionnel : Name of field if we want description of field
376
-	 * @return   resource            		Resource
377
-	 */
371
+    /**
372
+     * Return a pointer of line with description of a table or field
373
+     *
374
+     * @param    string 	$table 			Name of table
375
+     * @param    string 	$field 			Optionnel : Name of field if we want description of field
376
+     * @return   resource            		Resource
377
+     */
378 378
     function DDLDescTable($table, $field = "");
379 379
     // phpcs:enable
380 380
 
381
-	/**
382
-	 * Return version of database server
383
-	 *
384
-	 * @return            string      		Version string
385
-	 */
386
-	function getVersion();
381
+    /**
382
+     * Return version of database server
383
+     *
384
+     * @return            string      		Version string
385
+     */
386
+    function getVersion();
387 387
 
388
-	/**
389
-	 * Return charset used to store data in database
390
-	 *
391
-	 * @return        string        		Charset
392
-	 */
393
-	function getDefaultCharacterSetDatabase();
388
+    /**
389
+     * Return charset used to store data in database
390
+     *
391
+     * @return        string        		Charset
392
+     */
393
+    function getDefaultCharacterSetDatabase();
394 394
 
395 395
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
396
-	/**
397
-	 * Create a user and privileges to connect to database (even if database does not exists yet)
398
-	 *
399
-	 * @param    string $dolibarr_main_db_host 	Ip serveur
400
-	 * @param    string $dolibarr_main_db_user 	Nom user a creer
401
-	 * @param    string $dolibarr_main_db_pass 	Mot de passe user a creer
402
-	 * @param    string $dolibarr_main_db_name 	Database name where user must be granted
403
-	 * @return   int                            <0 if KO, >=0 if OK
404
-	 */
405
-	function DDLCreateUser(
406
-		$dolibarr_main_db_host,
407
-		$dolibarr_main_db_user,
408
-		$dolibarr_main_db_pass,
409
-		$dolibarr_main_db_name
396
+    /**
397
+     * Create a user and privileges to connect to database (even if database does not exists yet)
398
+     *
399
+     * @param    string $dolibarr_main_db_host 	Ip serveur
400
+     * @param    string $dolibarr_main_db_user 	Nom user a creer
401
+     * @param    string $dolibarr_main_db_pass 	Mot de passe user a creer
402
+     * @param    string $dolibarr_main_db_name 	Database name where user must be granted
403
+     * @return   int                            <0 if KO, >=0 if OK
404
+     */
405
+    function DDLCreateUser(
406
+        $dolibarr_main_db_host,
407
+        $dolibarr_main_db_user,
408
+        $dolibarr_main_db_pass,
409
+        $dolibarr_main_db_name
410 410
     );
411 411
     // phpcs:enable
412 412
 
413
-	/**
414
-	 * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
415
-	 * 19700101020000 -> 3600 with TZ+1 and gmt=0
416
-	 * 19700101020000 -> 7200 whaterver is TZ if gmt=1
417
-	 *
418
-	 * @param	string			$string		Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
419
-	 * @param	bool			$gm			1=Input informations are GMT values, otherwise local to server TZ
420
-	 * @return	int|string					Date TMS or ''
421
-	 */
422
-	function jdate($string, $gm=false);
423
-
424
-	/**
425
-	 * Encrypt sensitive data in database
426
-	 * Warning: This function includes the escape, so it must use direct value
427
-	 *
428
-	 * @param   string 			$fieldorvalue 	Field name or value to encrypt
429
-	 * @param  	int 			$withQuotes 	Return string with quotes
430
-	 * @return 	string                     		XXX(field) or XXX('value') or field or 'value'
431
-	 */
432
-	function encrypt($fieldorvalue, $withQuotes = 0);
433
-
434
-	/**
435
-	 * Validate a database transaction
436
-	 *
437
-	 * @param   string 			$log 			Add more log to default log line
438
-	 * @return	int                				1 if validation is OK or transaction level no started, 0 if ERROR
439
-	 */
440
-	function commit($log = '');
413
+    /**
414
+     * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
415
+     * 19700101020000 -> 3600 with TZ+1 and gmt=0
416
+     * 19700101020000 -> 7200 whaterver is TZ if gmt=1
417
+     *
418
+     * @param	string			$string		Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
419
+     * @param	bool			$gm			1=Input informations are GMT values, otherwise local to server TZ
420
+     * @return	int|string					Date TMS or ''
421
+     */
422
+    function jdate($string, $gm=false);
423
+
424
+    /**
425
+     * Encrypt sensitive data in database
426
+     * Warning: This function includes the escape, so it must use direct value
427
+     *
428
+     * @param   string 			$fieldorvalue 	Field name or value to encrypt
429
+     * @param  	int 			$withQuotes 	Return string with quotes
430
+     * @return 	string                     		XXX(field) or XXX('value') or field or 'value'
431
+     */
432
+    function encrypt($fieldorvalue, $withQuotes = 0);
433
+
434
+    /**
435
+     * Validate a database transaction
436
+     *
437
+     * @param   string 			$log 			Add more log to default log line
438
+     * @return	int                				1 if validation is OK or transaction level no started, 0 if ERROR
439
+     */
440
+    function commit($log = '');
441 441
 
442 442
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
443
-	/**
444
-	 * List information of columns into a table.
445
-	 *
446
-	 * @param   string 			$table 			Name of table
447
-	 * @return  array                			Array with inforation on table
448
-	 */
443
+    /**
444
+     * List information of columns into a table.
445
+     *
446
+     * @param   string 			$table 			Name of table
447
+     * @return  array                			Array with inforation on table
448
+     */
449 449
     function DDLInfoTable($table);
450 450
     // phpcs:enable
451 451
 
452
-	/**
453
-	 * Free last resultset used.
454
-	 *
455
-	 * @param  	resource 		$resultset 		Fre cursor
456
-	 * @return  void
457
-	 */
458
-	function free($resultset = null);
459
-
460
-	/**
461
-	 * Close database connexion
462
-	 *
463
-	 * @return  boolean     					True if disconnect successfull, false otherwise
464
-	 * @see     connect
465
-	 */
466
-	function close();
467
-
468
-	/**
469
-	 * Return last query in error
470
-	 *
471
-	 * @return  string    lastqueryerror
472
-	 */
473
-	function lastqueryerror();
452
+    /**
453
+     * Free last resultset used.
454
+     *
455
+     * @param  	resource 		$resultset 		Fre cursor
456
+     * @return  void
457
+     */
458
+    function free($resultset = null);
459
+
460
+    /**
461
+     * Close database connexion
462
+     *
463
+     * @return  boolean     					True if disconnect successfull, false otherwise
464
+     * @see     connect
465
+     */
466
+    function close();
467
+
468
+    /**
469
+     * Return last query in error
470
+     *
471
+     * @return  string    lastqueryerror
472
+     */
473
+    function lastqueryerror();
474 474
 
475 475
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
476
-	/**
477
-	 * Return connexion ID
478
-	 *
479
-	 * @return  string      Id connexion
480
-	 */
476
+    /**
477
+     * Return connexion ID
478
+     *
479
+     * @return  string      Id connexion
480
+     */
481 481
     function DDLGetConnectId();
482 482
     // phpcs:enable
483 483
 
484 484
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
485
-	/**
486
-	 * Renvoie la ligne courante (comme un objet) pour le curseur resultset
487
-	 *
488
-	 * @param   resource $resultset Curseur de la requete voulue
489
-	 * @return  Object                    Object result line or false if KO or end of cursor
490
-	 */
485
+    /**
486
+     * Renvoie la ligne courante (comme un objet) pour le curseur resultset
487
+     *
488
+     * @param   resource $resultset Curseur de la requete voulue
489
+     * @return  Object                    Object result line or false if KO or end of cursor
490
+     */
491 491
     function fetch_object($resultset);
492 492
     // phpcs:enable
493 493
 
494 494
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
495
-	/**
496
-	 * Select a database
497
-	 *
498
-	 * @param	string $database Name of database
499
-	 * @return  boolean            true if OK, false if KO
500
-	 */
495
+    /**
496
+     * Select a database
497
+     *
498
+     * @param	string $database Name of database
499
+     * @return  boolean            true if OK, false if KO
500
+     */
501 501
     function select_db($database);
502 502
     // phpcs:enable
503 503
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -419,7 +419,7 @@
 block discarded – undo
419 419
 	 * @param	bool			$gm			1=Input informations are GMT values, otherwise local to server TZ
420 420
 	 * @return	int|string					Date TMS or ''
421 421
 	 */
422
-	function jdate($string, $gm=false);
422
+	function jdate($string, $gm = false);
423 423
 
424 424
 	/**
425 425
 	 * Encrypt sensitive data in database
Please login to merge, or discard this patch.
dolibarr/htdocs/core/db/DoliDB.class.php 3 patches
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -29,273 +29,273 @@
 block discarded – undo
29 29
  */
30 30
 abstract class DoliDB implements Database
31 31
 {
32
-	/** @var resource Database handler */
33
-	public $db;
34
-	/** @var string Database type */
35
-	public $type;
36
-	/** @var string Charset used to force charset when creating database */
37
-	public $forcecharset='utf8';
38
-	/** @var string Collate used to force collate when creating database */
39
-	public $forcecollate='utf8_unicode_ci';
40
-	/** @var resource Resultset of last query */
41
-	private $_results;
42
-	/** @var bool true if connected, else false */
43
-	public $connected;
44
-	/** @var bool true if database selected, else false */
45
-	public $database_selected;
46
-	/** @var string Selected database name */
47
-	public $database_name;
48
-	/** @var string Database username */
49
-	public $database_user;
50
-	/** @var string Database host */
51
-	public $database_host;
52
-	/** @var int Database port */
53
-	public $database_port;
54
-	/** @var int >=1 if a transaction is opened, 0 otherwise */
55
-	public $transaction_opened;
56
-	/** @var string Last successful query */
57
-	public $lastquery;
58
-	/** @var string Last failed query */
59
-	public $lastqueryerror;
60
-	/** @var string Last error message */
61
-	public $lasterror;
62
-	/** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */
63
-	public $lasterrno;
32
+    /** @var resource Database handler */
33
+    public $db;
34
+    /** @var string Database type */
35
+    public $type;
36
+    /** @var string Charset used to force charset when creating database */
37
+    public $forcecharset='utf8';
38
+    /** @var string Collate used to force collate when creating database */
39
+    public $forcecollate='utf8_unicode_ci';
40
+    /** @var resource Resultset of last query */
41
+    private $_results;
42
+    /** @var bool true if connected, else false */
43
+    public $connected;
44
+    /** @var bool true if database selected, else false */
45
+    public $database_selected;
46
+    /** @var string Selected database name */
47
+    public $database_name;
48
+    /** @var string Database username */
49
+    public $database_user;
50
+    /** @var string Database host */
51
+    public $database_host;
52
+    /** @var int Database port */
53
+    public $database_port;
54
+    /** @var int >=1 if a transaction is opened, 0 otherwise */
55
+    public $transaction_opened;
56
+    /** @var string Last successful query */
57
+    public $lastquery;
58
+    /** @var string Last failed query */
59
+    public $lastqueryerror;
60
+    /** @var string Last error message */
61
+    public $lasterror;
62
+    /** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */
63
+    public $lasterrno;
64 64
 
65
-	/** @var bool Status */
66
-	public $ok;
67
-	/** @var string */
68
-	public $error;
65
+    /** @var bool Status */
66
+    public $ok;
67
+    /** @var string */
68
+    public $error;
69 69
 
70
-	/**
71
-	 *	Format a SQL IF
72
-	 *
73
-	 *	@param	string	$test           Test string (example: 'cd.statut=0', 'field IS NULL')
74
-	 *	@param	string	$resok          resultat si test egal
75
-	 *	@param	string	$resko          resultat si test non egal
76
-	 *	@return	string          		SQL string
77
-	 */
78
-	function ifsql($test,$resok,$resko)
79
-	{
80
-		return 'IF('.$test.','.$resok.','.$resko.')';
81
-	}
70
+    /**
71
+     *	Format a SQL IF
72
+     *
73
+     *	@param	string	$test           Test string (example: 'cd.statut=0', 'field IS NULL')
74
+     *	@param	string	$resok          resultat si test egal
75
+     *	@param	string	$resko          resultat si test non egal
76
+     *	@return	string          		SQL string
77
+     */
78
+    function ifsql($test,$resok,$resko)
79
+    {
80
+        return 'IF('.$test.','.$resok.','.$resko.')';
81
+    }
82 82
 
83
-	/**
84
-	 *   Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
85
-	 *   Function to use to build INSERT, UPDATE or WHERE predica
86
-	 *
87
-	 *   @param	    int		$param      	Date TMS to convert
88
-	 *   @return	string      			Date in a string YYYY-MM-DD HH:MM:SS
89
-	 */
90
-	function idate($param)
91
-	{
92
-		// TODO GMT $param should be gmt, so we should add tzouptut to 'gmt'
93
-		return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
94
-	}
83
+    /**
84
+     *   Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
85
+     *   Function to use to build INSERT, UPDATE or WHERE predica
86
+     *
87
+     *   @param	    int		$param      	Date TMS to convert
88
+     *   @return	string      			Date in a string YYYY-MM-DD HH:MM:SS
89
+     */
90
+    function idate($param)
91
+    {
92
+        // TODO GMT $param should be gmt, so we should add tzouptut to 'gmt'
93
+        return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
94
+    }
95 95
 
96
-	/**
97
-	 *	Return last error code
98
-	 *
99
-	 *	@return	    string	lasterrno
100
-	 */
101
-	function lasterrno()
102
-	{
103
-		return $this->lasterrno;
104
-	}
96
+    /**
97
+     *	Return last error code
98
+     *
99
+     *	@return	    string	lasterrno
100
+     */
101
+    function lasterrno()
102
+    {
103
+        return $this->lasterrno;
104
+    }
105 105
 
106
-	/**
107
-	 * Start transaction
108
-	 *
109
-	 * @return	    int         1 if transaction successfuly opened or already opened, 0 if error
110
-	 */
111
-	function begin()
112
-	{
113
-		if (! $this->transaction_opened)
114
-		{
115
-			$ret=$this->query("BEGIN");
116
-			if ($ret)
117
-			{
118
-				$this->transaction_opened++;
119
-				dol_syslog("BEGIN Transaction",LOG_DEBUG);
120
-				dol_syslog('',0,1);
121
-			}
122
-			return $ret;
123
-		}
124
-		else
125
-		{
126
-			$this->transaction_opened++;
127
-			dol_syslog('',0,1);
128
-			return 1;
129
-		}
130
-	}
106
+    /**
107
+     * Start transaction
108
+     *
109
+     * @return	    int         1 if transaction successfuly opened or already opened, 0 if error
110
+     */
111
+    function begin()
112
+    {
113
+        if (! $this->transaction_opened)
114
+        {
115
+            $ret=$this->query("BEGIN");
116
+            if ($ret)
117
+            {
118
+                $this->transaction_opened++;
119
+                dol_syslog("BEGIN Transaction",LOG_DEBUG);
120
+                dol_syslog('',0,1);
121
+            }
122
+            return $ret;
123
+        }
124
+        else
125
+        {
126
+            $this->transaction_opened++;
127
+            dol_syslog('',0,1);
128
+            return 1;
129
+        }
130
+    }
131 131
 
132
-	/**
133
-	 * Validate a database transaction
134
-	 *
135
-	 * @param	string	$log		Add more log to default log line
136
-	 * @return	int         		1 if validation is OK or transaction level no started, 0 if ERROR
137
-	 */
138
-	function commit($log='')
139
-	{
140
-		dol_syslog('',0,-1);
141
-		if ($this->transaction_opened<=1)
142
-		{
143
-			$ret=$this->query("COMMIT");
144
-			if ($ret)
145
-			{
146
-				$this->transaction_opened=0;
147
-				dol_syslog("COMMIT Transaction".($log?' '.$log:''),LOG_DEBUG);
148
-				return 1;
149
-			}
150
-			else
151
-			{
152
-				return 0;
153
-			}
154
-		}
155
-		else
156
-		{
157
-			$this->transaction_opened--;
158
-			return 1;
159
-		}
160
-	}
132
+    /**
133
+     * Validate a database transaction
134
+     *
135
+     * @param	string	$log		Add more log to default log line
136
+     * @return	int         		1 if validation is OK or transaction level no started, 0 if ERROR
137
+     */
138
+    function commit($log='')
139
+    {
140
+        dol_syslog('',0,-1);
141
+        if ($this->transaction_opened<=1)
142
+        {
143
+            $ret=$this->query("COMMIT");
144
+            if ($ret)
145
+            {
146
+                $this->transaction_opened=0;
147
+                dol_syslog("COMMIT Transaction".($log?' '.$log:''),LOG_DEBUG);
148
+                return 1;
149
+            }
150
+            else
151
+            {
152
+                return 0;
153
+            }
154
+        }
155
+        else
156
+        {
157
+            $this->transaction_opened--;
158
+            return 1;
159
+        }
160
+    }
161 161
 
162
-	/**
163
-	 *	Annulation d'une transaction et retour aux anciennes valeurs
164
-	 *
165
-	 * 	@param	string			$log		Add more log to default log line
166
-	 * 	@return	resource|int         		1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
167
-	 */
168
-	function rollback($log='')
169
-	{
170
-		dol_syslog('',0,-1);
171
-		if ($this->transaction_opened<=1)
172
-		{
173
-			$ret=$this->query("ROLLBACK");
174
-			$this->transaction_opened=0;
175
-			dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
176
-			return $ret;
177
-		}
178
-		else
179
-		{
180
-			$this->transaction_opened--;
181
-			return 1;
182
-		}
183
-	}
162
+    /**
163
+     *	Annulation d'une transaction et retour aux anciennes valeurs
164
+     *
165
+     * 	@param	string			$log		Add more log to default log line
166
+     * 	@return	resource|int         		1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
167
+     */
168
+    function rollback($log='')
169
+    {
170
+        dol_syslog('',0,-1);
171
+        if ($this->transaction_opened<=1)
172
+        {
173
+            $ret=$this->query("ROLLBACK");
174
+            $this->transaction_opened=0;
175
+            dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
176
+            return $ret;
177
+        }
178
+        else
179
+        {
180
+            $this->transaction_opened--;
181
+            return 1;
182
+        }
183
+    }
184 184
 
185
-	/**
186
-	 *	Define limits and offset of request
187
-	 *
188
-	 *	@param	int		$limit      Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
189
-	 *	@param	int		$offset     Numero of line from where starting fetch
190
-	 *	@return	string      		String with SQL syntax to add a limit and offset
191
-	 */
192
-	function plimit($limit=0,$offset=0)
193
-	{
194
-		global $conf;
195
-		if (empty($limit)) return "";
196
-		if ($limit < 0) $limit=$conf->liste_limit;
197
-		if ($offset > 0) return " LIMIT $offset,$limit ";
198
-		else return " LIMIT $limit ";
199
-	}
185
+    /**
186
+     *	Define limits and offset of request
187
+     *
188
+     *	@param	int		$limit      Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
189
+     *	@param	int		$offset     Numero of line from where starting fetch
190
+     *	@return	string      		String with SQL syntax to add a limit and offset
191
+     */
192
+    function plimit($limit=0,$offset=0)
193
+    {
194
+        global $conf;
195
+        if (empty($limit)) return "";
196
+        if ($limit < 0) $limit=$conf->liste_limit;
197
+        if ($offset > 0) return " LIMIT $offset,$limit ";
198
+        else return " LIMIT $limit ";
199
+    }
200 200
 
201
-	/**
202
-	 *	Return version of database server into an array
203
-	 *
204
-	 *	@return	        array  		Version array
205
-	 */
206
-	function getVersionArray()
207
-	{
208
-		return preg_split("/[\.,-]/",$this->getVersion());
209
-	}
201
+    /**
202
+     *	Return version of database server into an array
203
+     *
204
+     *	@return	        array  		Version array
205
+     */
206
+    function getVersionArray()
207
+    {
208
+        return preg_split("/[\.,-]/",$this->getVersion());
209
+    }
210 210
 
211
-	/**
212
-	 *	Return last request executed with query()
213
-	 *
214
-	 *	@return	string					Last query
215
-	 */
216
-	function lastquery()
217
-	{
218
-		return $this->lastquery;
219
-	}
211
+    /**
212
+     *	Return last request executed with query()
213
+     *
214
+     *	@return	string					Last query
215
+     */
216
+    function lastquery()
217
+    {
218
+        return $this->lastquery;
219
+    }
220 220
 
221
-	/**
222
-	 * Define sort criteria of request
223
-	 *
224
-	 * @param	string		$sortfield		List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb'
225
-	 * @param	string		$sortorder		Sort order, separated by comma. Example: 'ASC,DESC';
226
-	 * @return	string						String to provide syntax of a sort sql string
227
-	 */
228
-	function order($sortfield=null,$sortorder=null)
229
-	{
230
-		if (! empty($sortfield))
231
-		{
232
-			$return='';
233
-			$fields=explode(',',$sortfield);
234
-			$orders=explode(',',$sortorder);
235
-			$i=0;
236
-			foreach($fields as $val)
237
-			{
238
-				if (! $return) $return.=' ORDER BY ';
239
-				else $return.=', ';
221
+    /**
222
+     * Define sort criteria of request
223
+     *
224
+     * @param	string		$sortfield		List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb'
225
+     * @param	string		$sortorder		Sort order, separated by comma. Example: 'ASC,DESC';
226
+     * @return	string						String to provide syntax of a sort sql string
227
+     */
228
+    function order($sortfield=null,$sortorder=null)
229
+    {
230
+        if (! empty($sortfield))
231
+        {
232
+            $return='';
233
+            $fields=explode(',',$sortfield);
234
+            $orders=explode(',',$sortorder);
235
+            $i=0;
236
+            foreach($fields as $val)
237
+            {
238
+                if (! $return) $return.=' ORDER BY ';
239
+                else $return.=', ';
240 240
 
241
-				$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
241
+                $return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
242 242
 
243
-				$tmpsortorder = trim($orders[$i]);
243
+                $tmpsortorder = trim($orders[$i]);
244 244
 
245
-				// Only ASC and DESC values are valid SQL
246
-				if (strtoupper($tmpsortorder) === 'ASC') {
247
-					$return .= ' ASC';
248
-				} elseif (strtoupper($tmpsortorder) === 'DESC') {
249
-					$return .= ' DESC';
250
-				}
245
+                // Only ASC and DESC values are valid SQL
246
+                if (strtoupper($tmpsortorder) === 'ASC') {
247
+                    $return .= ' ASC';
248
+                } elseif (strtoupper($tmpsortorder) === 'DESC') {
249
+                    $return .= ' DESC';
250
+                }
251 251
 
252
-				$i++;
253
-			}
254
-			return $return;
255
-		}
256
-		else
257
-		{
258
-			return '';
259
-		}
260
-	}
252
+                $i++;
253
+            }
254
+            return $return;
255
+        }
256
+        else
257
+        {
258
+            return '';
259
+        }
260
+    }
261 261
 
262
-	/**
263
-	 *	Return last error label
264
-	 *
265
-	 *	@return	    string		Last error
266
-	 */
267
-	function lasterror()
268
-	{
269
-		return $this->lasterror;
270
-	}
262
+    /**
263
+     *	Return last error label
264
+     *
265
+     *	@return	    string		Last error
266
+     */
267
+    function lasterror()
268
+    {
269
+        return $this->lasterror;
270
+    }
271 271
 
272
-	/**
273
-	 *	Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
274
-	 * 	19700101020000 -> 3600 with TZ+1 and gmt=0
275
-	 * 	19700101020000 -> 7200 whaterver is TZ if gmt=1
276
-	 *
277
-	 * 	@param	string				$string		Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
278
-	 *	@param	bool				$gm			1=Input informations are GMT values, otherwise local to server TZ
279
-	 *	@return	int|string						Date TMS or ''
280
-	 */
281
-	function jdate($string, $gm=false)
282
-	{
283
-		// TODO GMT must set param gm to true by default
284
-		if ($string==0 || $string=="0000-00-00 00:00:00") return '';
285
-		$string=preg_replace('/([^0-9])/i','',$string);
286
-		$tmp=$string.'000000';
287
-		$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
288
-		return $date;
289
-	}
272
+    /**
273
+     *	Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true)
274
+     * 	19700101020000 -> 3600 with TZ+1 and gmt=0
275
+     * 	19700101020000 -> 7200 whaterver is TZ if gmt=1
276
+     *
277
+     * 	@param	string				$string		Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
278
+     *	@param	bool				$gm			1=Input informations are GMT values, otherwise local to server TZ
279
+     *	@return	int|string						Date TMS or ''
280
+     */
281
+    function jdate($string, $gm=false)
282
+    {
283
+        // TODO GMT must set param gm to true by default
284
+        if ($string==0 || $string=="0000-00-00 00:00:00") return '';
285
+        $string=preg_replace('/([^0-9])/i','',$string);
286
+        $tmp=$string.'000000';
287
+        $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
288
+        return $date;
289
+    }
290 290
 
291
-	/**
292
-	 *	Return last query in error
293
-	 *
294
-	 *	@return	    string	lastqueryerror
295
-	 */
296
-	function lastqueryerror()
297
-	{
298
-		return $this->lastqueryerror;
299
-	}
291
+    /**
292
+     *	Return last query in error
293
+     *
294
+     *	@return	    string	lastqueryerror
295
+     */
296
+    function lastqueryerror()
297
+    {
298
+        return $this->lastqueryerror;
299
+    }
300 300
 }
301 301
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -17 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@  discard block
 block discarded – undo
120 120
 				dol_syslog('',0,1);
121 121
 			}
122 122
 			return $ret;
123
-		}
124
-		else
123
+		} else
125 124
 		{
126 125
 			$this->transaction_opened++;
127 126
 			dol_syslog('',0,1);
@@ -146,13 +145,11 @@  discard block
 block discarded – undo
146 145
 				$this->transaction_opened=0;
147 146
 				dol_syslog("COMMIT Transaction".($log?' '.$log:''),LOG_DEBUG);
148 147
 				return 1;
149
-			}
150
-			else
148
+			} else
151 149
 			{
152 150
 				return 0;
153 151
 			}
154
-		}
155
-		else
152
+		} else
156 153
 		{
157 154
 			$this->transaction_opened--;
158 155
 			return 1;
@@ -174,8 +171,7 @@  discard block
 block discarded – undo
174 171
 			$this->transaction_opened=0;
175 172
 			dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
176 173
 			return $ret;
177
-		}
178
-		else
174
+		} else
179 175
 		{
180 176
 			$this->transaction_opened--;
181 177
 			return 1;
@@ -192,10 +188,17 @@  discard block
 block discarded – undo
192 188
 	function plimit($limit=0,$offset=0)
193 189
 	{
194 190
 		global $conf;
195
-		if (empty($limit)) return "";
196
-		if ($limit < 0) $limit=$conf->liste_limit;
197
-		if ($offset > 0) return " LIMIT $offset,$limit ";
198
-		else return " LIMIT $limit ";
191
+		if (empty($limit)) {
192
+		    return "";
193
+		}
194
+		if ($limit < 0) {
195
+		    $limit=$conf->liste_limit;
196
+		}
197
+		if ($offset > 0) {
198
+		    return " LIMIT $offset,$limit ";
199
+		} else {
200
+		    return " LIMIT $limit ";
201
+		}
199 202
 	}
200 203
 
201 204
 	/**
@@ -235,8 +238,11 @@  discard block
 block discarded – undo
235 238
 			$i=0;
236 239
 			foreach($fields as $val)
237 240
 			{
238
-				if (! $return) $return.=' ORDER BY ';
239
-				else $return.=', ';
241
+				if (! $return) {
242
+				    $return.=' ORDER BY ';
243
+				} else {
244
+				    $return.=', ';
245
+				}
240 246
 
241 247
 				$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
242 248
 
@@ -252,8 +258,7 @@  discard block
 block discarded – undo
252 258
 				$i++;
253 259
 			}
254 260
 			return $return;
255
-		}
256
-		else
261
+		} else
257 262
 		{
258 263
 			return '';
259 264
 		}
@@ -281,7 +286,9 @@  discard block
 block discarded – undo
281 286
 	function jdate($string, $gm=false)
282 287
 	{
283 288
 		// TODO GMT must set param gm to true by default
284
-		if ($string==0 || $string=="0000-00-00 00:00:00") return '';
289
+		if ($string==0 || $string=="0000-00-00 00:00:00") {
290
+		    return '';
291
+		}
285 292
 		$string=preg_replace('/([^0-9])/i','',$string);
286 293
 		$tmp=$string.'000000';
287 294
 		$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * \brief 		Class file to manage Dolibarr database access
27 27
  */
28 28
 
29
-require_once DOL_BASE_PATH . '/core/db/Database.interface.php';
29
+require_once DOL_BASE_PATH.'/core/db/Database.interface.php';
30 30
 
31 31
 /**
32 32
  * Class to manage Dolibarr database access
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	/** @var string Database type */
39 39
 	public $type;
40 40
 	/** @var string Charset used to force charset when creating database */
41
-	public $forcecharset='utf8';
41
+	public $forcecharset = 'utf8';
42 42
 	/** @var string Collate used to force collate when creating database */
43
-	public $forcecollate='utf8_unicode_ci';
43
+	public $forcecollate = 'utf8_unicode_ci';
44 44
 	/** @var resource Resultset of last query */
45 45
 	private $_results;
46 46
 	/** @var bool true if connected, else false */
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 *	@param	string	$resko          resultat si test non egal
80 80
 	 *	@return	string          		SQL string
81 81
 	 */
82
-	function ifsql($test,$resok,$resko)
82
+	function ifsql($test, $resok, $resko)
83 83
 	{
84 84
 		return 'IF('.$test.','.$resok.','.$resko.')';
85 85
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	function idate($param)
95 95
 	{
96 96
 		// TODO GMT $param should be gmt, so we should add tzouptut to 'gmt'
97
-		return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
97
+		return dol_print_date($param, "%Y-%m-%d %H:%M:%S");
98 98
 	}
99 99
 
100 100
 	/**
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	function begin()
116 116
 	{
117
-		if (! $this->transaction_opened)
117
+		if (!$this->transaction_opened)
118 118
 		{
119
-			$ret=$this->query("BEGIN");
119
+			$ret = $this->query("BEGIN");
120 120
 			if ($ret)
121 121
 			{
122 122
 				$this->transaction_opened++;
123
-				dol_syslog("BEGIN Transaction",LOG_DEBUG);
124
-				dol_syslog('',0,1);
123
+				dol_syslog("BEGIN Transaction", LOG_DEBUG);
124
+				dol_syslog('', 0, 1);
125 125
 			}
126 126
 			return $ret;
127 127
 		}
128 128
 		else
129 129
 		{
130 130
 			$this->transaction_opened++;
131
-			dol_syslog('',0,1);
131
+			dol_syslog('', 0, 1);
132 132
 			return 1;
133 133
 		}
134 134
 	}
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
 	 * @param	string	$log		Add more log to default log line
140 140
 	 * @return	int         		1 if validation is OK or transaction level no started, 0 if ERROR
141 141
 	 */
142
-	function commit($log='')
142
+	function commit($log = '')
143 143
 	{
144
-		dol_syslog('',0,-1);
145
-		if ($this->transaction_opened<=1)
144
+		dol_syslog('', 0, -1);
145
+		if ($this->transaction_opened <= 1)
146 146
 		{
147
-			$ret=$this->query("COMMIT");
147
+			$ret = $this->query("COMMIT");
148 148
 			if ($ret)
149 149
 			{
150
-				$this->transaction_opened=0;
151
-				dol_syslog("COMMIT Transaction".($log?' '.$log:''),LOG_DEBUG);
150
+				$this->transaction_opened = 0;
151
+				dol_syslog("COMMIT Transaction".($log ? ' '.$log : ''), LOG_DEBUG);
152 152
 				return 1;
153 153
 			}
154 154
 			else
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	 * 	@param	string			$log		Add more log to default log line
170 170
 	 * 	@return	resource|int         		1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur
171 171
 	 */
172
-	function rollback($log='')
172
+	function rollback($log = '')
173 173
 	{
174
-		dol_syslog('',0,-1);
175
-		if ($this->transaction_opened<=1)
174
+		dol_syslog('', 0, -1);
175
+		if ($this->transaction_opened <= 1)
176 176
 		{
177
-			$ret=$this->query("ROLLBACK");
178
-			$this->transaction_opened=0;
179
-			dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
177
+			$ret = $this->query("ROLLBACK");
178
+			$this->transaction_opened = 0;
179
+			dol_syslog("ROLLBACK Transaction".($log ? ' '.$log : ''), LOG_DEBUG);
180 180
 			return $ret;
181 181
 		}
182 182
 		else
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
 	 *	@param	int		$offset     Numero of line from where starting fetch
194 194
 	 *	@return	string      		String with SQL syntax to add a limit and offset
195 195
 	 */
196
-	function plimit($limit=0,$offset=0)
196
+	function plimit($limit = 0, $offset = 0)
197 197
 	{
198 198
 		global $conf;
199 199
 		if (empty($limit)) return "";
200
-		if ($limit < 0) $limit=$conf->liste_limit;
200
+		if ($limit < 0) $limit = $conf->liste_limit;
201 201
 		if ($offset > 0) return " LIMIT $offset,$limit ";
202 202
 		else return " LIMIT $limit ";
203 203
 	}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	function getVersionArray()
211 211
 	{
212
-		return preg_split("/[\.,-]/",$this->getVersion());
212
+		return preg_split("/[\.,-]/", $this->getVersion());
213 213
 	}
214 214
 
215 215
 	/**
@@ -229,20 +229,20 @@  discard block
 block discarded – undo
229 229
 	 * @param	string		$sortorder		Sort order, separated by comma. Example: 'ASC,DESC';
230 230
 	 * @return	string						String to provide syntax of a sort sql string
231 231
 	 */
232
-	function order($sortfield=null,$sortorder=null)
232
+	function order($sortfield = null, $sortorder = null)
233 233
 	{
234
-		if (! empty($sortfield))
234
+		if (!empty($sortfield))
235 235
 		{
236
-			$return='';
237
-			$fields=explode(',',$sortfield);
238
-			$orders=explode(',',$sortorder);
239
-			$i=0;
240
-			foreach($fields as $val)
236
+			$return = '';
237
+			$fields = explode(',', $sortfield);
238
+			$orders = explode(',', $sortorder);
239
+			$i = 0;
240
+			foreach ($fields as $val)
241 241
 			{
242
-				if (! $return) $return.=' ORDER BY ';
243
-				else $return.=', ';
242
+				if (!$return) $return .= ' ORDER BY ';
243
+				else $return .= ', ';
244 244
 
245
-				$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
245
+				$return .= preg_replace('/[^0-9a-z_\.]/i', '', $val);
246 246
 
247 247
 				$tmpsortorder = trim($orders[$i]);
248 248
 
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
 	 *	@param	bool				$gm			1=Input informations are GMT values, otherwise local to server TZ
283 283
 	 *	@return	int|string						Date TMS or ''
284 284
 	 */
285
-	function jdate($string, $gm=false)
285
+	function jdate($string, $gm = false)
286 286
 	{
287 287
 		// TODO GMT must set param gm to true by default
288
-		if ($string==0 || $string=="0000-00-00 00:00:00") return '';
289
-		$string=preg_replace('/([^0-9])/i','',$string);
290
-		$tmp=$string.'000000';
291
-		$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
288
+		if ($string == 0 || $string == "0000-00-00 00:00:00") return '';
289
+		$string = preg_replace('/([^0-9])/i', '', $string);
290
+		$tmp = $string.'000000';
291
+		$date = dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), $gm);
292 292
 		return $date;
293 293
 	}
294 294
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_builddoc.inc.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     }
41 41
     else
42 42
     {
43
-   		// Reload to get all modified line records and be ready for hooks
43
+            // Reload to get all modified line records and be ready for hooks
44 44
         $ret = $object->fetch($id);
45 45
         $ret = $object->fetch_thirdparty();
46 46
         /*if (empty($object->id) || ! $object->id > 0)
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
         }*/
51 51
 
52 52
         // Save last template used to generate document
53
-    	if (GETPOST('model','alpha'))
54
-    	{
55
-    	    $object->setDocModel($user, GETPOST('model','alpha'));
56
-    	}
53
+        if (GETPOST('model','alpha'))
54
+        {
55
+            $object->setDocModel($user, GETPOST('model','alpha'));
56
+        }
57 57
 
58 58
         // Special case to force bank account
59 59
         //if (property_exists($object, 'fk_bank'))
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
         }
92 92
         else
93 93
         {
94
-        	if (empty($donotredirect))	// This is set when include is done by bulk action "Bill Orders"
95
-        	{
96
-	            setEventMessages($langs->trans("FileGenerated"), null);
94
+            if (empty($donotredirect))	// This is set when include is done by bulk action "Bill Orders"
95
+            {
96
+                setEventMessages($langs->trans("FileGenerated"), null);
97 97
 
98
-	            $urltoredirect = $_SERVER['REQUEST_URI'];
99
-	            $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
100
-	            $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect);	// To avoid infinite loop
98
+                $urltoredirect = $_SERVER['REQUEST_URI'];
99
+                $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
100
+                $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect);	// To avoid infinite loop
101 101
 
102
-	            header('Location: '.$urltoredirect.'#builddoc');
103
-	            exit;
104
-        	}
102
+                header('Location: '.$urltoredirect.'#builddoc');
103
+                exit;
104
+            }
105 105
         }
106 106
     }
107 107
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 if ($action == 'builddoc' && $permissioncreate)
35 35
 {
36 36
 
37
-    if (is_numeric(GETPOST('model','alpha')))
37
+    if (is_numeric(GETPOST('model', 'alpha')))
38 38
     {
39
-        $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
39
+        $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
40 40
     }
41 41
     else
42 42
     {
@@ -50,44 +50,44 @@  discard block
 block discarded – undo
50 50
         }*/
51 51
 
52 52
         // Save last template used to generate document
53
-    	if (GETPOST('model','alpha'))
53
+    	if (GETPOST('model', 'alpha'))
54 54
     	{
55
-    	    $object->setDocModel($user, GETPOST('model','alpha'));
55
+    	    $object->setDocModel($user, GETPOST('model', 'alpha'));
56 56
     	}
57 57
 
58 58
         // Special case to force bank account
59 59
         //if (property_exists($object, 'fk_bank'))
60 60
         //{
61
-            if (GETPOST('fk_bank','int')) { // this field may come from an external module
62
-                $object->fk_bank = GETPOST('fk_bank','int');
63
-            } else if (! empty($object->fk_account)) {
61
+            if (GETPOST('fk_bank', 'int')) { // this field may come from an external module
62
+                $object->fk_bank = GETPOST('fk_bank', 'int');
63
+            } else if (!empty($object->fk_account)) {
64 64
                 $object->fk_bank = $object->fk_account;
65 65
             }
66 66
         //}
67 67
 
68 68
         $outputlangs = $langs;
69
-        $newlang='';
69
+        $newlang = '';
70 70
 
71
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
72
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang=$object->thirdparty->default_lang;  // for proposal, order, invoice, ...
73
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang;                  // for thirdparty
74
-        if (! empty($newlang))
71
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
72
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ...
73
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty
74
+        if (!empty($newlang))
75 75
         {
76
-            $outputlangs = new Translate("",$conf);
76
+            $outputlangs = new Translate("", $conf);
77 77
             $outputlangs->setDefaultLang($newlang);
78 78
         }
79 79
 
80 80
         // To be sure vars is defined
81
-        if (empty($hidedetails)) $hidedetails=0;
82
-        if (empty($hidedesc)) $hidedesc=0;
83
-        if (empty($hideref)) $hideref=0;
84
-        if (empty($moreparams)) $moreparams=null;
81
+        if (empty($hidedetails)) $hidedetails = 0;
82
+        if (empty($hidedesc)) $hidedesc = 0;
83
+        if (empty($hideref)) $hideref = 0;
84
+        if (empty($moreparams)) $moreparams = null;
85 85
 
86
-        $result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
86
+        $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
87 87
         if ($result <= 0)
88 88
         {
89 89
             setEventMessages($object->error, $object->errors, 'errors');
90
-            $action='';
90
+            $action = '';
91 91
         }
92 92
         else
93 93
         {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 	            $urltoredirect = $_SERVER['REQUEST_URI'];
99 99
 	            $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
100
-	            $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect);	// To avoid infinite loop
100
+	            $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop
101 101
 
102 102
 	            header('Location: '.$urltoredirect.'#builddoc');
103 103
 	            exit;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 {
112 112
     require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
113 113
 
114
-    if (empty($object->id) || ! $object->id > 0)
114
+    if (empty($object->id) || !$object->id > 0)
115 115
     {
116 116
         // Reload to get all modified line records and be ready for hooks
117 117
         $ret = $object->fetch($id);
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
     }
120 120
 
121 121
     $langs->load("other");
122
-    $filetodelete=GETPOST('file','alpha');
123
-    $file =	$upload_dir	. '/' .	$filetodelete;
124
-    $ret=dol_delete_file($file,0,0,0,$object);
122
+    $filetodelete = GETPOST('file', 'alpha');
123
+    $file = $upload_dir.'/'.$filetodelete;
124
+    $ret = dol_delete_file($file, 0, 0, 0, $object);
125 125
     if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
126 126
     else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
127 127
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -14 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
     if (is_numeric(GETPOST('model','alpha')))
38 38
     {
39 39
         $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
40
-    }
41
-    else
40
+    } else
42 41
     {
43 42
    		// Reload to get all modified line records and be ready for hooks
44 43
         $ret = $object->fetch($id);
@@ -68,9 +67,17 @@  discard block
 block discarded – undo
68 67
         $outputlangs = $langs;
69 68
         $newlang='';
70 69
 
71
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
72
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang=$object->thirdparty->default_lang;  // for proposal, order, invoice, ...
73
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang;                  // for thirdparty
70
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) {
71
+            $newlang=GETPOST('lang_id','aZ09');
72
+        }
73
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) {
74
+            $newlang=$object->thirdparty->default_lang;
75
+        }
76
+        // for proposal, order, invoice, ...
77
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) {
78
+            $newlang=$object->default_lang;
79
+        }
80
+        // for thirdparty
74 81
         if (! empty($newlang))
75 82
         {
76 83
             $outputlangs = new Translate("",$conf);
@@ -78,22 +85,31 @@  discard block
 block discarded – undo
78 85
         }
79 86
 
80 87
         // To be sure vars is defined
81
-        if (empty($hidedetails)) $hidedetails=0;
82
-        if (empty($hidedesc)) $hidedesc=0;
83
-        if (empty($hideref)) $hideref=0;
84
-        if (empty($moreparams)) $moreparams=null;
88
+        if (empty($hidedetails)) {
89
+            $hidedetails=0;
90
+        }
91
+        if (empty($hidedesc)) {
92
+            $hidedesc=0;
93
+        }
94
+        if (empty($hideref)) {
95
+            $hideref=0;
96
+        }
97
+        if (empty($moreparams)) {
98
+            $moreparams=null;
99
+        }
85 100
 
86 101
         $result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
87 102
         if ($result <= 0)
88 103
         {
89 104
             setEventMessages($object->error, $object->errors, 'errors');
90 105
             $action='';
91
-        }
92
-        else
106
+        } else
93 107
         {
94
-        	if (empty($donotredirect))	// This is set when include is done by bulk action "Bill Orders"
108
+        	if (empty($donotredirect)) {
109
+        	    // This is set when include is done by bulk action "Bill Orders"
95 110
         	{
96 111
 	            setEventMessages($langs->trans("FileGenerated"), null);
112
+        	}
97 113
 
98 114
 	            $urltoredirect = $_SERVER['REQUEST_URI'];
99 115
 	            $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
@@ -122,8 +138,11 @@  discard block
 block discarded – undo
122 138
     $filetodelete=GETPOST('file','alpha');
123 139
     $file =	$upload_dir	. '/' .	$filetodelete;
124 140
     $ret=dol_delete_file($file,0,0,0,$object);
125
-    if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
126
-    else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
141
+    if ($ret) {
142
+        setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
143
+    } else {
144
+        setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
145
+    }
127 146
 
128 147
     // Make a redirect to avoid to keep the remove_file into the url that create side effects
129 148
     $urltoredirect = $_SERVER['REQUEST_URI'];
Please login to merge, or discard this patch.
dolibarr/htdocs/core/search_page.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 else
79 79
 {
80 80
     $usedbyinclude = 1; // Used into next include
81
-	$showtitlebefore = GETPOST('showtitlebefore','int');
82
-	include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
81
+    $showtitlebefore = GETPOST('showtitlebefore','int');
82
+    include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
83 83
 
84 84
     $accesskeyalreadyassigned=array();
85 85
     foreach($arrayresult as $key => $val)
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 $reshook=$hookmanager->executeHooks('printSearchForm',$parameters);    // Note that $action and $object may have been modified by some hooks
104 104
 if (empty($reshook))
105 105
 {
106
-	$searchform.=$hookmanager->resPrint;
106
+    $searchform.=$hookmanager->resPrint;
107 107
 }
108 108
 else $searchform=$hookmanager->resPrint;
109 109
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -27,32 +27,32 @@  discard block
 block discarded – undo
27 27
 //if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');		// Not disabled cause need to load personalized language
28 28
 //if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
29 29
 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');		// Not disabled cause need to do translations
30
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
31
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
30
+if (!defined('NOCSRFCHECK'))     define('NOCSRFCHECK', 1);
31
+if (!defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL', 1);
32 32
 //if (! defined('NOLOGIN')) define('NOLOGIN',1);					// Not disabled cause need to load personalized language
33
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU',1);
33
+if (!defined('NOREQUIREMENU'))  define('NOREQUIREMENU', 1);
34 34
 //if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML',1);
35 35
 
36 36
 require_once '../main.inc.php';
37 37
 
38
-if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09'));	// If language was forced on URL by the main.inc.php
38
+if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
39 39
 
40 40
 $langs->load("main");
41 41
 
42
-$right=($langs->trans("DIRECTION")=='rtl'?'left':'right');
43
-$left=($langs->trans("DIRECTION")=='rtl'?'right':'left');
42
+$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
43
+$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
44 44
 
45 45
 
46 46
 /*
47 47
  * View
48 48
  */
49 49
 
50
-$title=$langs->trans("Search");
50
+$title = $langs->trans("Search");
51 51
 
52 52
 // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
53
-$head='<!-- Quick access -->'."\n";
54
-$arrayofjs=array();
55
-$arrayofcss=array();
53
+$head = '<!-- Quick access -->'."\n";
54
+$arrayofjs = array();
55
+$arrayofcss = array();
56 56
 top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
57 57
 
58 58
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 print '<div>';
62 62
 //print '<br>';
63 63
 
64
-$nbofsearch=0;
64
+$nbofsearch = 0;
65 65
 
66 66
 // Instantiate hooks of thirdparty module
67 67
 $hookmanager->initHooks(array('searchform'));
@@ -71,41 +71,41 @@  discard block
 block discarded – undo
71 71
 
72 72
 if ($conf->use_javascript_ajax && 1 == 2)   // select2 is ko with jmobile
73 73
 {
74
-    if (! is_object($form)) $form=new Form($db);
75
-    $selected=-1;
76
-    $searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
74
+    if (!is_object($form)) $form = new Form($db);
75
+    $selected = -1;
76
+    $searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
77 77
 }
78 78
 else
79 79
 {
80 80
     $usedbyinclude = 1; // Used into next include
81
-	$showtitlebefore = GETPOST('showtitlebefore','int');
81
+	$showtitlebefore = GETPOST('showtitlebefore', 'int');
82 82
 	include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
83 83
 
84
-    $accesskeyalreadyassigned=array();
85
-    foreach($arrayresult as $key => $val)
84
+    $accesskeyalreadyassigned = array();
85
+    foreach ($arrayresult as $key => $val)
86 86
     {
87
-        $tmp=explode('?', $val['url']);
88
-        $urlaction=$tmp[0];
89
-        $keysearch='search_all';
87
+        $tmp = explode('?', $val['url']);
88
+        $urlaction = $tmp[0];
89
+        $keysearch = 'search_all';
90 90
 
91
-        $accesskey='';
92
-        if (! $accesskeyalreadyassigned[$val['label'][0]])
91
+        $accesskey = '';
92
+        if (!$accesskeyalreadyassigned[$val['label'][0]])
93 93
         {
94
-            $accesskey=$val['label'][0];
95
-            $accesskeyalreadyassigned[$accesskey]=$accesskey;
94
+            $accesskey = $val['label'][0];
95
+            $accesskeyalreadyassigned[$accesskey] = $accesskey;
96 96
         }
97
-        $searchform.=printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('',$val['img'],'', 0, 1), $showtitlebefore);
97
+        $searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, img_picto('', $val['img'], '', 0, 1), $showtitlebefore);
98 98
     }
99 99
 }
100 100
 
101 101
 // Execute hook printSearchForm
102
-$parameters=array('searchform'=>$searchform);
103
-$reshook=$hookmanager->executeHooks('printSearchForm',$parameters);    // Note that $action and $object may have been modified by some hooks
102
+$parameters = array('searchform'=>$searchform);
103
+$reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
104 104
 if (empty($reshook))
105 105
 {
106
-	$searchform.=$hookmanager->resPrint;
106
+	$searchform .= $hookmanager->resPrint;
107 107
 }
108
-else $searchform=$hookmanager->resPrint;
108
+else $searchform = $hookmanager->resPrint;
109 109
 
110 110
 
111 111
 print "\n";
Please login to merge, or discard this patch.
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,15 +27,24 @@  discard block
 block discarded – undo
27 27
 //if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');		// Not disabled cause need to load personalized language
28 28
 //if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
29 29
 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');		// Not disabled cause need to do translations
30
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
31
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
30
+if (! defined('NOCSRFCHECK')) {
31
+    define('NOCSRFCHECK',1);
32
+}
33
+if (! defined('NOTOKENRENEWAL')) {
34
+    define('NOTOKENRENEWAL',1);
35
+}
32 36
 //if (! defined('NOLOGIN')) define('NOLOGIN',1);					// Not disabled cause need to load personalized language
33
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU',1);
37
+if (! defined('NOREQUIREMENU')) {
38
+    define('NOREQUIREMENU',1);
39
+}
34 40
 //if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML',1);
35 41
 
36 42
 require_once '../main.inc.php';
37 43
 
38
-if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09'));	// If language was forced on URL by the main.inc.php
44
+if (GETPOST('lang', 'aZ09')) {
45
+    $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
46
+}
47
+// If language was forced on URL by the main.inc.php
39 48
 
40 49
 $langs->load("main");
41 50
 
@@ -69,13 +78,14 @@  discard block
 block discarded – undo
69 78
 // Define $searchform
70 79
 $searchform = '';
71 80
 
72
-if ($conf->use_javascript_ajax && 1 == 2)   // select2 is ko with jmobile
81
+if ($conf->use_javascript_ajax && 1 == 2) {
82
+    // select2 is ko with jmobile
73 83
 {
74 84
     if (! is_object($form)) $form=new Form($db);
85
+}
75 86
     $selected=-1;
76 87
     $searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
77
-}
78
-else
88
+} else
79 89
 {
80 90
     $usedbyinclude = 1; // Used into next include
81 91
 	$showtitlebefore = GETPOST('showtitlebefore','int');
@@ -104,8 +114,9 @@  discard block
 block discarded – undo
104 114
 if (empty($reshook))
105 115
 {
106 116
 	$searchform.=$hookmanager->resPrint;
117
+} else {
118
+    $searchform=$hookmanager->resPrint;
107 119
 }
108
-else $searchform=$hookmanager->resPrint;
109 120
 
110 121
 
111 122
 print "\n";
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_extrafields.inc.php 3 patches
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
 // Add attribute
41 41
 if ($action == 'add')
42 42
 {
43
-	if ($_POST["button"] != $langs->trans("Cancel"))
44
-	{
45
-	    // Check values
46
-		if (! $type)
47
-		{
48
-			$error++;
49
-			$langs->load("errors");
50
-			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
51
-			$action = 'create';
52
-		}
53
-		if ($type=='varchar' && $extrasize <= 0)
54
-		{
55
-		    $error++;
56
-		    $langs->load("errors");
57
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
58
-		    $action = 'edit';
59
-		}
43
+    if ($_POST["button"] != $langs->trans("Cancel"))
44
+    {
45
+        // Check values
46
+        if (! $type)
47
+        {
48
+            $error++;
49
+            $langs->load("errors");
50
+            $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
51
+            $action = 'create';
52
+        }
53
+        if ($type=='varchar' && $extrasize <= 0)
54
+        {
55
+            $error++;
56
+            $langs->load("errors");
57
+            $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
58
+            $action = 'edit';
59
+        }
60 60
         if ($type=='varchar' && $extrasize > $maxsizestring)
61 61
         {
62 62
             $error++;
@@ -73,168 +73,168 @@  discard block
 block discarded – undo
73 73
         }
74 74
         if ($type=='select' && !$param)
75 75
         {
76
-        	$error++;
77
-        	$langs->load("errors");
78
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
79
-        	$action = 'create';
76
+            $error++;
77
+            $langs->load("errors");
78
+            $mesg[]=$langs->trans("ErrorNoValueForSelectType");
79
+            $action = 'create';
80 80
         }
81 81
         if ($type=='sellist' && !$param)
82 82
         {
83
-        	$error++;
84
-        	$langs->load("errors");
85
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
86
-        	$action = 'create';
83
+            $error++;
84
+            $langs->load("errors");
85
+            $mesg[]=$langs->trans("ErrorNoValueForSelectListType");
86
+            $action = 'create';
87 87
         }
88 88
         if ($type=='checkbox' && !$param)
89 89
         {
90
-        	$error++;
91
-        	$langs->load("errors");
92
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
93
-        	$action = 'create';
90
+            $error++;
91
+            $langs->load("errors");
92
+            $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
93
+            $action = 'create';
94 94
         }
95 95
         if ($type=='link' && !$param)
96 96
         {
97
-        	$error++;
98
-        	$langs->load("errors");
99
-        	$mesg[]=$langs->trans("ErrorNoValueForLinkType");
100
-        	$action = 'create';
97
+            $error++;
98
+            $langs->load("errors");
99
+            $mesg[]=$langs->trans("ErrorNoValueForLinkType");
100
+            $action = 'create';
101 101
         }
102 102
         if ($type=='radio' && !$param)
103 103
         {
104
-        	$error++;
105
-        	$langs->load("errors");
106
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
107
-        	$action = 'create';
104
+            $error++;
105
+            $langs->load("errors");
106
+            $mesg[]=$langs->trans("ErrorNoValueForRadioType");
107
+            $action = 'create';
108 108
         }
109 109
         if  ((($type=='radio') || ($type=='checkbox')) && $param)
110 110
         {
111
-        	// Construct array for parameter (value of select list)
112
-    		$parameters = $param;
113
-    		$parameters_array = explode("\r\n",$parameters);
114
-    		foreach($parameters_array as $param_ligne)
115
-    		{
116
-    			if (!empty($param_ligne)) {
117
-	    			if (preg_match_all('/,/',$param_ligne,$matches))
118
-	    			{
119
-	    				if (count($matches[0])>1) {
120
-	    					$error++;
121
-	    					$langs->load("errors");
122
-	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
123
-	    					$action = 'create';
124
-	    				}
125
-	    			}
126
-	    			else
127
-	    			{
128
-	    				$error++;
129
-	    				$langs->load("errors");
130
-	    				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
131
-	    				$action = 'create';
132
-	    			}
133
-    			}
134
-    		}
111
+            // Construct array for parameter (value of select list)
112
+            $parameters = $param;
113
+            $parameters_array = explode("\r\n",$parameters);
114
+            foreach($parameters_array as $param_ligne)
115
+            {
116
+                if (!empty($param_ligne)) {
117
+                    if (preg_match_all('/,/',$param_ligne,$matches))
118
+                    {
119
+                        if (count($matches[0])>1) {
120
+                            $error++;
121
+                            $langs->load("errors");
122
+                            $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
123
+                            $action = 'create';
124
+                        }
125
+                    }
126
+                    else
127
+                    {
128
+                        $error++;
129
+                        $langs->load("errors");
130
+                        $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
131
+                        $action = 'create';
132
+                    }
133
+                }
134
+            }
135 135
         }
136 136
 
137
-	    if (! $error)
138
-	    {
139
-    		// attrname must be alphabetical and lower case only
140
-    		if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"]))
141
-    		{
142
-    			// Construct array for parameter (value of select list)
143
-        		$default_value = GETPOST('default_value','alpha');
144
-    			$parameters = $param;
145
-    			$parameters_array = explode("\r\n",$parameters);
146
-    			//In sellist we have only one line and it can have come to do SQL expression
147
-    			if ($type=='sellist') {
148
-    				foreach($parameters_array as $param_ligne)
149
-    				{
150
-    					$params['options'] = array($parameters=>null);
151
-    				}
152
-    			}
153
-    			else
154
-    			{
155
-    				//Esle it's separated key/value and coma list
156
-    				foreach($parameters_array as $param_ligne)
157
-    				{
158
-    					list($key,$value) = explode(',',$param_ligne);
159
-    					$params['options'][$key] = $value;
160
-    				}
161
-    			}
137
+        if (! $error)
138
+        {
139
+            // attrname must be alphabetical and lower case only
140
+            if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"]))
141
+            {
142
+                // Construct array for parameter (value of select list)
143
+                $default_value = GETPOST('default_value','alpha');
144
+                $parameters = $param;
145
+                $parameters_array = explode("\r\n",$parameters);
146
+                //In sellist we have only one line and it can have come to do SQL expression
147
+                if ($type=='sellist') {
148
+                    foreach($parameters_array as $param_ligne)
149
+                    {
150
+                        $params['options'] = array($parameters=>null);
151
+                    }
152
+                }
153
+                else
154
+                {
155
+                    //Esle it's separated key/value and coma list
156
+                    foreach($parameters_array as $param_ligne)
157
+                    {
158
+                        list($key,$value) = explode(',',$param_ligne);
159
+                        $params['options'][$key] = $value;
160
+                    }
161
+                }
162 162
 
163
-    			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
164
-    			$visibility = GETPOST('list', 'alpha');
165
-				if ($type == 'separate') $visibility=3;
163
+                // Visibility: -1=not visible by default in list, 1=visible, 0=hidden
164
+                $visibility = GETPOST('list', 'alpha');
165
+                if ($type == 'separate') $visibility=3;
166 166
 
167 167
                 $result=$extrafields->addExtraField(
168
-                	GETPOST('attrname', 'alpha'),
169
-                	GETPOST('label', 'alpha'),
170
-                	$type,
171
-                	GETPOST('pos', 'int'),
172
-                	$extrasize,
173
-                	$elementtype,
174
-                	(GETPOST('unique', 'alpha')?1:0),
175
-                	(GETPOST('required', 'alpha')?1:0),
176
-                	$default_value,
177
-                	$params,
178
-                	(GETPOST('alwayseditable', 'alpha')?1:0),
179
-                	(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
180
-                	$visibility,
181
-					GETPOST('help','alpha'),
168
+                    GETPOST('attrname', 'alpha'),
169
+                    GETPOST('label', 'alpha'),
170
+                    $type,
171
+                    GETPOST('pos', 'int'),
172
+                    $extrasize,
173
+                    $elementtype,
174
+                    (GETPOST('unique', 'alpha')?1:0),
175
+                    (GETPOST('required', 'alpha')?1:0),
176
+                    $default_value,
177
+                    $params,
178
+                    (GETPOST('alwayseditable', 'alpha')?1:0),
179
+                    (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
180
+                    $visibility,
181
+                    GETPOST('help','alpha'),
182 182
                     GETPOST('computed_value','alpha'),
183
-                	(GETPOST('entitycurrentorall', 'alpha')?0:''),
183
+                    (GETPOST('entitycurrentorall', 'alpha')?0:''),
184 184
                     GETPOST('langfile', 'alpha'),
185 185
                     1,
186 186
                     (GETPOST('totalizable', 'alpha')?1:0)
187 187
                 );
188
-    			if ($result > 0)
189
-    			{
190
-    				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
191
-    				header("Location: ".$_SERVER["PHP_SELF"]);
192
-    				exit;
193
-    			}
194
-    			else
195
-    			{
188
+                if ($result > 0)
189
+                {
190
+                    setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
191
+                    header("Location: ".$_SERVER["PHP_SELF"]);
192
+                    exit;
193
+                }
194
+                else
195
+                {
196 196
                     $error++;
197
-    			    $mesg=$extrafields->error;
197
+                    $mesg=$extrafields->error;
198 198
                     setEventMessages($mesg, null, 'errors');
199
-    			}
200
-    		}
201
-    		else
202
-    		{
199
+                }
200
+            }
201
+            else
202
+            {
203 203
                 $error++;
204
-    		    $langs->load("errors");
205
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
206
-    			setEventMessages($mesg, null, 'errors');
207
-    			$action = 'create';
208
-    		}
209
-	    }
210
-	    else
211
-	    {
212
-	    	setEventMessages($mesg, null, 'errors');
213
-	    }
214
-	}
204
+                $langs->load("errors");
205
+                $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
206
+                setEventMessages($mesg, null, 'errors');
207
+                $action = 'create';
208
+            }
209
+        }
210
+        else
211
+        {
212
+            setEventMessages($mesg, null, 'errors');
213
+        }
214
+    }
215 215
 }
216 216
 
217 217
 // Rename field
218 218
 if ($action == 'update')
219 219
 {
220
-	if ($_POST["button"] != $langs->trans("Cancel"))
221
-	{
220
+    if ($_POST["button"] != $langs->trans("Cancel"))
221
+    {
222 222
         // Check values
223
-		if (! $type)
224
-		{
225
-			$error++;
226
-			$langs->load("errors");
227
-			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
228
-			$action = 'edit';
229
-		}
230
-		if ($type=='varchar' && $extrasize <= 0)
231
-		{
232
-		    $error++;
233
-		    $langs->load("errors");
234
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
235
-		    $action = 'edit';
236
-		}
237
-		if ($type=='varchar' && $extrasize > $maxsizestring)
223
+        if (! $type)
224
+        {
225
+            $error++;
226
+            $langs->load("errors");
227
+            $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
228
+            $action = 'edit';
229
+        }
230
+        if ($type=='varchar' && $extrasize <= 0)
231
+        {
232
+            $error++;
233
+            $langs->load("errors");
234
+            $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
235
+            $action = 'edit';
236
+        }
237
+        if ($type=='varchar' && $extrasize > $maxsizestring)
238 238
         {
239 239
             $error++;
240 240
             $langs->load("errors");
@@ -250,143 +250,143 @@  discard block
 block discarded – undo
250 250
         }
251 251
         if ($type=='select' && !$param)
252 252
         {
253
-        	$error++;
254
-        	$langs->load("errors");
255
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
256
-        	$action = 'edit';
253
+            $error++;
254
+            $langs->load("errors");
255
+            $mesg[]=$langs->trans("ErrorNoValueForSelectType");
256
+            $action = 'edit';
257 257
         }
258 258
         if ($type=='sellist' && !$param)
259 259
         {
260
-        	$error++;
261
-        	$langs->load("errors");
262
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
263
-        	$action = 'edit';
260
+            $error++;
261
+            $langs->load("errors");
262
+            $mesg[]=$langs->trans("ErrorNoValueForSelectListType");
263
+            $action = 'edit';
264 264
         }
265 265
         if ($type=='checkbox' && !$param)
266 266
         {
267
-        	$error++;
268
-        	$langs->load("errors");
269
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
270
-        	$action = 'edit';
267
+            $error++;
268
+            $langs->load("errors");
269
+            $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
270
+            $action = 'edit';
271 271
         }
272 272
         if ($type=='radio' && !$param)
273 273
         {
274
-        	$error++;
275
-        	$langs->load("errors");
276
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
277
-        	$action = 'edit';
274
+            $error++;
275
+            $langs->load("errors");
276
+            $mesg[]=$langs->trans("ErrorNoValueForRadioType");
277
+            $action = 'edit';
278 278
         }
279 279
         if  ((($type=='radio') || ($type=='checkbox')) && $param)
280 280
         {
281
-        	// Construct array for parameter (value of select list)
282
-        	$parameters = $param;
283
-        	$parameters_array = explode("\r\n",$parameters);
284
-        	foreach($parameters_array as $param_ligne)
285
-        	{
286
-        		if (!empty($param_ligne)) {
287
-	        		if (preg_match_all('/,/',$param_ligne,$matches))
288
-	        		{
289
-	        			if (count($matches[0])>1) {
290
-	        				$error++;
291
-	        				$langs->load("errors");
292
-	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
293
-	        				$action = 'edit';
294
-	        			}
295
-	        		}
296
-	        		else
297
-	        		{
298
-	        			$error++;
299
-	        			$langs->load("errors");
300
-	        			$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
301
-	        			$action = 'edit';
302
-	        		}
303
-        		}
304
-        	}
281
+            // Construct array for parameter (value of select list)
282
+            $parameters = $param;
283
+            $parameters_array = explode("\r\n",$parameters);
284
+            foreach($parameters_array as $param_ligne)
285
+            {
286
+                if (!empty($param_ligne)) {
287
+                    if (preg_match_all('/,/',$param_ligne,$matches))
288
+                    {
289
+                        if (count($matches[0])>1) {
290
+                            $error++;
291
+                            $langs->load("errors");
292
+                            $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
293
+                            $action = 'edit';
294
+                        }
295
+                    }
296
+                    else
297
+                    {
298
+                        $error++;
299
+                        $langs->load("errors");
300
+                        $mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
301
+                        $action = 'edit';
302
+                    }
303
+                }
304
+            }
305 305
         }
306 306
 
307
-	    if (! $error)
308
-	    {
307
+        if (! $error)
308
+        {
309 309
             if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
310
-    		{
311
-    			$pos = GETPOST('pos','int');
312
-    			// Construct array for parameter (value of select list)
313
-    			$parameters = $param;
314
-    			$parameters_array = explode("\r\n",$parameters);
315
-    			//In sellist we have only one line and it can have come to do SQL expression
316
-    			if ($type=='sellist') {
317
-    				foreach($parameters_array as $param_ligne)
318
-    				{
319
-    					$params['options'] = array($parameters=>null);
320
-    				}
321
-    			}
322
-    			else
323
-    			{
324
-    				//Esle it's separated key/value and coma list
325
-    				foreach($parameters_array as $param_ligne)
326
-    				{
327
-    					list($key,$value) = explode(',',$param_ligne);
328
-    					$params['options'][$key] = $value;
329
-    				}
330
-    			}
310
+            {
311
+                $pos = GETPOST('pos','int');
312
+                // Construct array for parameter (value of select list)
313
+                $parameters = $param;
314
+                $parameters_array = explode("\r\n",$parameters);
315
+                //In sellist we have only one line and it can have come to do SQL expression
316
+                if ($type=='sellist') {
317
+                    foreach($parameters_array as $param_ligne)
318
+                    {
319
+                        $params['options'] = array($parameters=>null);
320
+                    }
321
+                }
322
+                else
323
+                {
324
+                    //Esle it's separated key/value and coma list
325
+                    foreach($parameters_array as $param_ligne)
326
+                    {
327
+                        list($key,$value) = explode(',',$param_ligne);
328
+                        $params['options'][$key] = $value;
329
+                    }
330
+                }
331 331
 
332
-    			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
333
-    			$visibility = GETPOST('list', 'alpha');
334
-    			if ($type == 'separate') $visibility=3;
332
+                // Visibility: -1=not visible by default in list, 1=visible, 0=hidden
333
+                $visibility = GETPOST('list', 'alpha');
334
+                if ($type == 'separate') $visibility=3;
335 335
 
336 336
                 $result=$extrafields->update(
337
-    				GETPOST('attrname', 'alpha'),
338
-    				GETPOST('label', 'alpha'),
339
-    				$type,
340
-    				$extrasize,
341
-    				$elementtype,
342
-    				(GETPOST('unique', 'alpha')?1:0),
343
-    				(GETPOST('required', 'alpha')?1:0),
344
-    				$pos,
345
-    				$params,
346
-    				(GETPOST('alwayseditable', 'alpha')?1:0),
347
-    				(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
348
-                	$visibility,
349
-					GETPOST('help','alpha'),
350
-    			    GETPOST('default_value','alpha'),
351
-    				GETPOST('computed_value','alpha'),
352
-    				(GETPOST('entitycurrentorall', 'alpha')?0:''),
337
+                    GETPOST('attrname', 'alpha'),
338
+                    GETPOST('label', 'alpha'),
339
+                    $type,
340
+                    $extrasize,
341
+                    $elementtype,
342
+                    (GETPOST('unique', 'alpha')?1:0),
343
+                    (GETPOST('required', 'alpha')?1:0),
344
+                    $pos,
345
+                    $params,
346
+                    (GETPOST('alwayseditable', 'alpha')?1:0),
347
+                    (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
348
+                    $visibility,
349
+                    GETPOST('help','alpha'),
350
+                    GETPOST('default_value','alpha'),
351
+                    GETPOST('computed_value','alpha'),
352
+                    (GETPOST('entitycurrentorall', 'alpha')?0:''),
353 353
                     GETPOST('langfile'),
354 354
                     1,
355 355
                     (GETPOST('totalizable', 'alpha')?1:0)
356
-    			);
357
-    			if ($result > 0)
358
-    			{
359
-    				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
360
-    				header("Location: ".$_SERVER["PHP_SELF"]);
361
-    				exit;
362
-    			}
363
-    			else
364
-    			{
356
+                );
357
+                if ($result > 0)
358
+                {
359
+                    setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
360
+                    header("Location: ".$_SERVER["PHP_SELF"]);
361
+                    exit;
362
+                }
363
+                else
364
+                {
365 365
                     $error++;
366
-    			    $mesg=$extrafields->error;
367
-    			    setEventMessages($mesg, null, 'errors');
368
-    			}
369
-    		}
370
-    		else
371
-    		{
372
-    		    $error++;
373
-    			$langs->load("errors");
374
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
375
-    			setEventMessages($mesg, null, 'errors');
376
-    		}
377
-	    }
378
-	    else
379
-	    {
380
-	    	setEventMessages($mesg, null, 'errors');
381
-	    }
382
-	}
366
+                    $mesg=$extrafields->error;
367
+                    setEventMessages($mesg, null, 'errors');
368
+                }
369
+            }
370
+            else
371
+            {
372
+                $error++;
373
+                $langs->load("errors");
374
+                $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
375
+                setEventMessages($mesg, null, 'errors');
376
+            }
377
+        }
378
+        else
379
+        {
380
+            setEventMessages($mesg, null, 'errors');
381
+        }
382
+    }
383 383
 }
384 384
 
385 385
 // Delete attribute
386 386
 if ($action == 'delete')
387 387
 {
388
-	if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
389
-	{
388
+    if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
389
+    {
390 390
         $result=$extrafields->delete($_GET["attrname"],$elementtype);
391 391
         if ($result >= 0)
392 392
         {
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
             exit;
395 395
         }
396 396
         else $mesg=$extrafields->error;
397
-	}
398
-	else
399
-	{
400
-	    $error++;
401
-		$langs->load("errors");
402
-		$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
403
-	}
397
+    }
398
+    else
399
+    {
400
+        $error++;
401
+        $langs->load("errors");
402
+        $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
403
+    }
404 404
 }
405 405
 
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
  *  \brief			Code for actions on extrafields admin pages
24 24
  */
25 25
 
26
-$maxsizestring=255;
27
-$maxsizeint=10;
28
-$mesg=array();
26
+$maxsizestring = 255;
27
+$maxsizeint = 10;
28
+$mesg = array();
29 29
 
30
-$extrasize=GETPOST('size','int');
31
-$type=GETPOST('type','alpha');
32
-$param=GETPOST('param','alpha');
30
+$extrasize = GETPOST('size', 'int');
31
+$type = GETPOST('type', 'alpha');
32
+$param = GETPOST('param', 'alpha');
33 33
 
34
-if ($type=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
35
-if ($type=='date')     $extrasize='';
36
-if ($type=='datetime') $extrasize='';
37
-if ($type=='select')   $extrasize='';
34
+if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8';
35
+if ($type == 'date')     $extrasize = '';
36
+if ($type == 'datetime') $extrasize = '';
37
+if ($type == 'select')   $extrasize = '';
38 38
 
39 39
 
40 40
 // Add attribute
@@ -43,83 +43,83 @@  discard block
 block discarded – undo
43 43
 	if ($_POST["button"] != $langs->trans("Cancel"))
44 44
 	{
45 45
 	    // Check values
46
-		if (! $type)
46
+		if (!$type)
47 47
 		{
48 48
 			$error++;
49 49
 			$langs->load("errors");
50
-			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
50
+			$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
51 51
 			$action = 'create';
52 52
 		}
53
-		if ($type=='varchar' && $extrasize <= 0)
53
+		if ($type == 'varchar' && $extrasize <= 0)
54 54
 		{
55 55
 		    $error++;
56 56
 		    $langs->load("errors");
57
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
57
+		    $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size"));
58 58
 		    $action = 'edit';
59 59
 		}
60
-        if ($type=='varchar' && $extrasize > $maxsizestring)
60
+        if ($type == 'varchar' && $extrasize > $maxsizestring)
61 61
         {
62 62
             $error++;
63 63
             $langs->load("errors");
64
-            $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
64
+            $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring);
65 65
             $action = 'create';
66 66
         }
67
-        if ($type=='int' && $extrasize > $maxsizeint)
67
+        if ($type == 'int' && $extrasize > $maxsizeint)
68 68
         {
69 69
             $error++;
70 70
             $langs->load("errors");
71
-            $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
71
+            $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint);
72 72
             $action = 'create';
73 73
         }
74
-        if ($type=='select' && !$param)
74
+        if ($type == 'select' && !$param)
75 75
         {
76 76
         	$error++;
77 77
         	$langs->load("errors");
78
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
78
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectType");
79 79
         	$action = 'create';
80 80
         }
81
-        if ($type=='sellist' && !$param)
81
+        if ($type == 'sellist' && !$param)
82 82
         {
83 83
         	$error++;
84 84
         	$langs->load("errors");
85
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
85
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectListType");
86 86
         	$action = 'create';
87 87
         }
88
-        if ($type=='checkbox' && !$param)
88
+        if ($type == 'checkbox' && !$param)
89 89
         {
90 90
         	$error++;
91 91
         	$langs->load("errors");
92
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
92
+        	$mesg[] = $langs->trans("ErrorNoValueForCheckBoxType");
93 93
         	$action = 'create';
94 94
         }
95
-        if ($type=='link' && !$param)
95
+        if ($type == 'link' && !$param)
96 96
         {
97 97
         	$error++;
98 98
         	$langs->load("errors");
99
-        	$mesg[]=$langs->trans("ErrorNoValueForLinkType");
99
+        	$mesg[] = $langs->trans("ErrorNoValueForLinkType");
100 100
         	$action = 'create';
101 101
         }
102
-        if ($type=='radio' && !$param)
102
+        if ($type == 'radio' && !$param)
103 103
         {
104 104
         	$error++;
105 105
         	$langs->load("errors");
106
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
106
+        	$mesg[] = $langs->trans("ErrorNoValueForRadioType");
107 107
         	$action = 'create';
108 108
         }
109
-        if  ((($type=='radio') || ($type=='checkbox')) && $param)
109
+        if ((($type == 'radio') || ($type == 'checkbox')) && $param)
110 110
         {
111 111
         	// Construct array for parameter (value of select list)
112 112
     		$parameters = $param;
113
-    		$parameters_array = explode("\r\n",$parameters);
114
-    		foreach($parameters_array as $param_ligne)
113
+    		$parameters_array = explode("\r\n", $parameters);
114
+    		foreach ($parameters_array as $param_ligne)
115 115
     		{
116 116
     			if (!empty($param_ligne)) {
117
-	    			if (preg_match_all('/,/',$param_ligne,$matches))
117
+	    			if (preg_match_all('/,/', $param_ligne, $matches))
118 118
 	    			{
119
-	    				if (count($matches[0])>1) {
119
+	    				if (count($matches[0]) > 1) {
120 120
 	    					$error++;
121 121
 	    					$langs->load("errors");
122
-	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
122
+	    					$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
123 123
 	    					$action = 'create';
124 124
 	    				}
125 125
 	    			}
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 	    			{
128 128
 	    				$error++;
129 129
 	    				$langs->load("errors");
130
-	    				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
130
+	    				$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
131 131
 	    				$action = 'create';
132 132
 	    			}
133 133
     			}
134 134
     		}
135 135
         }
136 136
 
137
-	    if (! $error)
137
+	    if (!$error)
138 138
 	    {
139 139
     		// attrname must be alphabetical and lower case only
140
-    		if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']) && !is_numeric($_POST["attrname"]))
140
+    		if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"]))
141 141
     		{
142 142
     			// Construct array for parameter (value of select list)
143
-        		$default_value = GETPOST('default_value','alpha');
143
+        		$default_value = GETPOST('default_value', 'alpha');
144 144
     			$parameters = $param;
145
-    			$parameters_array = explode("\r\n",$parameters);
145
+    			$parameters_array = explode("\r\n", $parameters);
146 146
     			//In sellist we have only one line and it can have come to do SQL expression
147
-    			if ($type=='sellist') {
148
-    				foreach($parameters_array as $param_ligne)
147
+    			if ($type == 'sellist') {
148
+    				foreach ($parameters_array as $param_ligne)
149 149
     				{
150 150
     					$params['options'] = array($parameters=>null);
151 151
     				}
@@ -153,37 +153,37 @@  discard block
 block discarded – undo
153 153
     			else
154 154
     			{
155 155
     				//Esle it's separated key/value and coma list
156
-    				foreach($parameters_array as $param_ligne)
156
+    				foreach ($parameters_array as $param_ligne)
157 157
     				{
158
-    					list($key,$value) = explode(',',$param_ligne);
158
+    					list($key, $value) = explode(',', $param_ligne);
159 159
     					$params['options'][$key] = $value;
160 160
     				}
161 161
     			}
162 162
 
163 163
     			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
164 164
     			$visibility = GETPOST('list', 'alpha');
165
-				if ($type == 'separate') $visibility=3;
165
+				if ($type == 'separate') $visibility = 3;
166 166
 
167
-                $result=$extrafields->addExtraField(
167
+                $result = $extrafields->addExtraField(
168 168
                 	GETPOST('attrname', 'alpha'),
169 169
                 	GETPOST('label', 'alpha'),
170 170
                 	$type,
171 171
                 	GETPOST('pos', 'int'),
172 172
                 	$extrasize,
173 173
                 	$elementtype,
174
-                	(GETPOST('unique', 'alpha')?1:0),
175
-                	(GETPOST('required', 'alpha')?1:0),
174
+                	(GETPOST('unique', 'alpha') ? 1 : 0),
175
+                	(GETPOST('required', 'alpha') ? 1 : 0),
176 176
                 	$default_value,
177 177
                 	$params,
178
-                	(GETPOST('alwayseditable', 'alpha')?1:0),
179
-                	(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
178
+                	(GETPOST('alwayseditable', 'alpha') ? 1 : 0),
179
+                	(GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''),
180 180
                 	$visibility,
181
-					GETPOST('help','alpha'),
182
-                    GETPOST('computed_value','alpha'),
183
-                	(GETPOST('entitycurrentorall', 'alpha')?0:''),
181
+					GETPOST('help', 'alpha'),
182
+                    GETPOST('computed_value', 'alpha'),
183
+                	(GETPOST('entitycurrentorall', 'alpha') ? 0 : ''),
184 184
                     GETPOST('langfile', 'alpha'),
185 185
                     1,
186
-                    (GETPOST('totalizable', 'alpha')?1:0)
186
+                    (GETPOST('totalizable', 'alpha') ? 1 : 0)
187 187
                 );
188 188
     			if ($result > 0)
189 189
     			{
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     			else
195 195
     			{
196 196
                     $error++;
197
-    			    $mesg=$extrafields->error;
197
+    			    $mesg = $extrafields->error;
198 198
                     setEventMessages($mesg, null, 'errors');
199 199
     			}
200 200
     		}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     		{
203 203
                 $error++;
204 204
     		    $langs->load("errors");
205
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
205
+    			$mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode"));
206 206
     			setEventMessages($mesg, null, 'errors');
207 207
     			$action = 'create';
208 208
     		}
@@ -220,76 +220,76 @@  discard block
 block discarded – undo
220 220
 	if ($_POST["button"] != $langs->trans("Cancel"))
221 221
 	{
222 222
         // Check values
223
-		if (! $type)
223
+		if (!$type)
224 224
 		{
225 225
 			$error++;
226 226
 			$langs->load("errors");
227
-			$mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"));
227
+			$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
228 228
 			$action = 'edit';
229 229
 		}
230
-		if ($type=='varchar' && $extrasize <= 0)
230
+		if ($type == 'varchar' && $extrasize <= 0)
231 231
 		{
232 232
 		    $error++;
233 233
 		    $langs->load("errors");
234
-		    $mesg[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Size"));
234
+		    $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size"));
235 235
 		    $action = 'edit';
236 236
 		}
237
-		if ($type=='varchar' && $extrasize > $maxsizestring)
237
+		if ($type == 'varchar' && $extrasize > $maxsizestring)
238 238
         {
239 239
             $error++;
240 240
             $langs->load("errors");
241
-            $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
241
+            $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring);
242 242
             $action = 'edit';
243 243
         }
244
-        if ($type=='int' && $extrasize > $maxsizeint)
244
+        if ($type == 'int' && $extrasize > $maxsizeint)
245 245
         {
246 246
             $error++;
247 247
             $langs->load("errors");
248
-            $mesg[]=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
248
+            $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint);
249 249
             $action = 'edit';
250 250
         }
251
-        if ($type=='select' && !$param)
251
+        if ($type == 'select' && !$param)
252 252
         {
253 253
         	$error++;
254 254
         	$langs->load("errors");
255
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectType");
255
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectType");
256 256
         	$action = 'edit';
257 257
         }
258
-        if ($type=='sellist' && !$param)
258
+        if ($type == 'sellist' && !$param)
259 259
         {
260 260
         	$error++;
261 261
         	$langs->load("errors");
262
-        	$mesg[]=$langs->trans("ErrorNoValueForSelectListType");
262
+        	$mesg[] = $langs->trans("ErrorNoValueForSelectListType");
263 263
         	$action = 'edit';
264 264
         }
265
-        if ($type=='checkbox' && !$param)
265
+        if ($type == 'checkbox' && !$param)
266 266
         {
267 267
         	$error++;
268 268
         	$langs->load("errors");
269
-        	$mesg[]=$langs->trans("ErrorNoValueForCheckBoxType");
269
+        	$mesg[] = $langs->trans("ErrorNoValueForCheckBoxType");
270 270
         	$action = 'edit';
271 271
         }
272
-        if ($type=='radio' && !$param)
272
+        if ($type == 'radio' && !$param)
273 273
         {
274 274
         	$error++;
275 275
         	$langs->load("errors");
276
-        	$mesg[]=$langs->trans("ErrorNoValueForRadioType");
276
+        	$mesg[] = $langs->trans("ErrorNoValueForRadioType");
277 277
         	$action = 'edit';
278 278
         }
279
-        if  ((($type=='radio') || ($type=='checkbox')) && $param)
279
+        if ((($type == 'radio') || ($type == 'checkbox')) && $param)
280 280
         {
281 281
         	// Construct array for parameter (value of select list)
282 282
         	$parameters = $param;
283
-        	$parameters_array = explode("\r\n",$parameters);
284
-        	foreach($parameters_array as $param_ligne)
283
+        	$parameters_array = explode("\r\n", $parameters);
284
+        	foreach ($parameters_array as $param_ligne)
285 285
         	{
286 286
         		if (!empty($param_ligne)) {
287
-	        		if (preg_match_all('/,/',$param_ligne,$matches))
287
+	        		if (preg_match_all('/,/', $param_ligne, $matches))
288 288
 	        		{
289
-	        			if (count($matches[0])>1) {
289
+	        			if (count($matches[0]) > 1) {
290 290
 	        				$error++;
291 291
 	        				$langs->load("errors");
292
-	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
292
+	        				$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
293 293
 	        				$action = 'edit';
294 294
 	        			}
295 295
 	        		}
@@ -297,24 +297,24 @@  discard block
 block discarded – undo
297 297
 	        		{
298 298
 	        			$error++;
299 299
 	        			$langs->load("errors");
300
-	        			$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
300
+	        			$mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne);
301 301
 	        			$action = 'edit';
302 302
 	        		}
303 303
         		}
304 304
         	}
305 305
         }
306 306
 
307
-	    if (! $error)
307
+	    if (!$error)
308 308
 	    {
309
-            if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
309
+            if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname']))
310 310
     		{
311
-    			$pos = GETPOST('pos','int');
311
+    			$pos = GETPOST('pos', 'int');
312 312
     			// Construct array for parameter (value of select list)
313 313
     			$parameters = $param;
314
-    			$parameters_array = explode("\r\n",$parameters);
314
+    			$parameters_array = explode("\r\n", $parameters);
315 315
     			//In sellist we have only one line and it can have come to do SQL expression
316
-    			if ($type=='sellist') {
317
-    				foreach($parameters_array as $param_ligne)
316
+    			if ($type == 'sellist') {
317
+    				foreach ($parameters_array as $param_ligne)
318 318
     				{
319 319
     					$params['options'] = array($parameters=>null);
320 320
     				}
@@ -322,37 +322,37 @@  discard block
 block discarded – undo
322 322
     			else
323 323
     			{
324 324
     				//Esle it's separated key/value and coma list
325
-    				foreach($parameters_array as $param_ligne)
325
+    				foreach ($parameters_array as $param_ligne)
326 326
     				{
327
-    					list($key,$value) = explode(',',$param_ligne);
327
+    					list($key, $value) = explode(',', $param_ligne);
328 328
     					$params['options'][$key] = $value;
329 329
     				}
330 330
     			}
331 331
 
332 332
     			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
333 333
     			$visibility = GETPOST('list', 'alpha');
334
-    			if ($type == 'separate') $visibility=3;
334
+    			if ($type == 'separate') $visibility = 3;
335 335
 
336
-                $result=$extrafields->update(
336
+                $result = $extrafields->update(
337 337
     				GETPOST('attrname', 'alpha'),
338 338
     				GETPOST('label', 'alpha'),
339 339
     				$type,
340 340
     				$extrasize,
341 341
     				$elementtype,
342
-    				(GETPOST('unique', 'alpha')?1:0),
343
-    				(GETPOST('required', 'alpha')?1:0),
342
+    				(GETPOST('unique', 'alpha') ? 1 : 0),
343
+    				(GETPOST('required', 'alpha') ? 1 : 0),
344 344
     				$pos,
345 345
     				$params,
346
-    				(GETPOST('alwayseditable', 'alpha')?1:0),
347
-    				(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
346
+    				(GETPOST('alwayseditable', 'alpha') ? 1 : 0),
347
+    				(GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''),
348 348
                 	$visibility,
349
-					GETPOST('help','alpha'),
350
-    			    GETPOST('default_value','alpha'),
351
-    				GETPOST('computed_value','alpha'),
352
-    				(GETPOST('entitycurrentorall', 'alpha')?0:''),
349
+					GETPOST('help', 'alpha'),
350
+    			    GETPOST('default_value', 'alpha'),
351
+    				GETPOST('computed_value', 'alpha'),
352
+    				(GETPOST('entitycurrentorall', 'alpha') ? 0 : ''),
353 353
                     GETPOST('langfile'),
354 354
                     1,
355
-                    (GETPOST('totalizable', 'alpha')?1:0)
355
+                    (GETPOST('totalizable', 'alpha') ? 1 : 0)
356 356
     			);
357 357
     			if ($result > 0)
358 358
     			{
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     			else
364 364
     			{
365 365
                     $error++;
366
-    			    $mesg=$extrafields->error;
366
+    			    $mesg = $extrafields->error;
367 367
     			    setEventMessages($mesg, null, 'errors');
368 368
     			}
369 369
     		}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     		{
372 372
     		    $error++;
373 373
     			$langs->load("errors");
374
-    			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
374
+    			$mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode"));
375 375
     			setEventMessages($mesg, null, 'errors');
376 376
     		}
377 377
 	    }
@@ -385,21 +385,21 @@  discard block
 block discarded – undo
385 385
 // Delete attribute
386 386
 if ($action == 'delete')
387 387
 {
388
-	if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
388
+	if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"]))
389 389
 	{
390
-        $result=$extrafields->delete($_GET["attrname"],$elementtype);
390
+        $result = $extrafields->delete($_GET["attrname"], $elementtype);
391 391
         if ($result >= 0)
392 392
         {
393 393
             header("Location: ".$_SERVER["PHP_SELF"]);
394 394
             exit;
395 395
         }
396
-        else $mesg=$extrafields->error;
396
+        else $mesg = $extrafields->error;
397 397
 	}
398 398
 	else
399 399
 	{
400 400
 	    $error++;
401 401
 		$langs->load("errors");
402
-		$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
402
+		$mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode"));
403 403
 	}
404 404
 }
405 405
 
Please login to merge, or discard this patch.
Braces   +31 added lines, -29 removed lines patch added patch discarded remove patch
@@ -31,10 +31,18 @@  discard block
 block discarded – undo
31 31
 $type=GETPOST('type','alpha');
32 32
 $param=GETPOST('param','alpha');
33 33
 
34
-if ($type=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
35
-if ($type=='date')     $extrasize='';
36
-if ($type=='datetime') $extrasize='';
37
-if ($type=='select')   $extrasize='';
34
+if ($type=='double' && strpos($extrasize,',')===false) {
35
+    $extrasize='24,8';
36
+}
37
+if ($type=='date') {
38
+    $extrasize='';
39
+}
40
+if ($type=='datetime') {
41
+    $extrasize='';
42
+}
43
+if ($type=='select') {
44
+    $extrasize='';
45
+}
38 46
 
39 47
 
40 48
 // Add attribute
@@ -122,8 +130,7 @@  discard block
 block discarded – undo
122 130
 	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
123 131
 	    					$action = 'create';
124 132
 	    				}
125
-	    			}
126
-	    			else
133
+	    			} else
127 134
 	    			{
128 135
 	    				$error++;
129 136
 	    				$langs->load("errors");
@@ -149,8 +156,7 @@  discard block
 block discarded – undo
149 156
     				{
150 157
     					$params['options'] = array($parameters=>null);
151 158
     				}
152
-    			}
153
-    			else
159
+    			} else
154 160
     			{
155 161
     				//Esle it's separated key/value and coma list
156 162
     				foreach($parameters_array as $param_ligne)
@@ -162,7 +168,9 @@  discard block
 block discarded – undo
162 168
 
163 169
     			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
164 170
     			$visibility = GETPOST('list', 'alpha');
165
-				if ($type == 'separate') $visibility=3;
171
+				if ($type == 'separate') {
172
+				    $visibility=3;
173
+				}
166 174
 
167 175
                 $result=$extrafields->addExtraField(
168 176
                 	GETPOST('attrname', 'alpha'),
@@ -190,15 +198,13 @@  discard block
 block discarded – undo
190 198
     				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
191 199
     				header("Location: ".$_SERVER["PHP_SELF"]);
192 200
     				exit;
193
-    			}
194
-    			else
201
+    			} else
195 202
     			{
196 203
                     $error++;
197 204
     			    $mesg=$extrafields->error;
198 205
                     setEventMessages($mesg, null, 'errors');
199 206
     			}
200
-    		}
201
-    		else
207
+    		} else
202 208
     		{
203 209
                 $error++;
204 210
     		    $langs->load("errors");
@@ -206,8 +212,7 @@  discard block
 block discarded – undo
206 212
     			setEventMessages($mesg, null, 'errors');
207 213
     			$action = 'create';
208 214
     		}
209
-	    }
210
-	    else
215
+	    } else
211 216
 	    {
212 217
 	    	setEventMessages($mesg, null, 'errors');
213 218
 	    }
@@ -292,8 +297,7 @@  discard block
 block discarded – undo
292 297
 	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
293 298
 	        				$action = 'edit';
294 299
 	        			}
295
-	        		}
296
-	        		else
300
+	        		} else
297 301
 	        		{
298 302
 	        			$error++;
299 303
 	        			$langs->load("errors");
@@ -318,8 +322,7 @@  discard block
 block discarded – undo
318 322
     				{
319 323
     					$params['options'] = array($parameters=>null);
320 324
     				}
321
-    			}
322
-    			else
325
+    			} else
323 326
     			{
324 327
     				//Esle it's separated key/value and coma list
325 328
     				foreach($parameters_array as $param_ligne)
@@ -331,7 +334,9 @@  discard block
 block discarded – undo
331 334
 
332 335
     			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
333 336
     			$visibility = GETPOST('list', 'alpha');
334
-    			if ($type == 'separate') $visibility=3;
337
+    			if ($type == 'separate') {
338
+    			    $visibility=3;
339
+    			}
335 340
 
336 341
                 $result=$extrafields->update(
337 342
     				GETPOST('attrname', 'alpha'),
@@ -359,23 +364,20 @@  discard block
 block discarded – undo
359 364
     				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
360 365
     				header("Location: ".$_SERVER["PHP_SELF"]);
361 366
     				exit;
362
-    			}
363
-    			else
367
+    			} else
364 368
     			{
365 369
                     $error++;
366 370
     			    $mesg=$extrafields->error;
367 371
     			    setEventMessages($mesg, null, 'errors');
368 372
     			}
369
-    		}
370
-    		else
373
+    		} else
371 374
     		{
372 375
     		    $error++;
373 376
     			$langs->load("errors");
374 377
     			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
375 378
     			setEventMessages($mesg, null, 'errors');
376 379
     		}
377
-	    }
378
-	    else
380
+	    } else
379 381
 	    {
380 382
 	    	setEventMessages($mesg, null, 'errors');
381 383
 	    }
@@ -392,10 +394,10 @@  discard block
 block discarded – undo
392 394
         {
393 395
             header("Location: ".$_SERVER["PHP_SELF"]);
394 396
             exit;
397
+        } else {
398
+            $mesg=$extrafields->error;
395 399
         }
396
-        else $mesg=$extrafields->error;
397
-	}
398
-	else
400
+	} else
399 401
 	{
400 402
 	    $error++;
401 403
 		$langs->load("errors");
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_openid.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
  * @param   int		$entitytotest   Number of instance (always 1 if module multicompany not enabled)
35 35
  * @return	string					Login if OK, '' if KO
36 36
  */
37
-function check_user_password_openid($usertotest,$passwordtotest,$entitytotest)
37
+function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
38 38
 {
39
-    global $_POST,$db,$conf,$langs;
39
+    global $_POST, $db, $conf, $langs;
40 40
 
41 41
     dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest);
42 42
 
43
-    $login='';
43
+    $login = '';
44 44
 
45 45
     // Get identity from user and redirect browser to OpenID Server
46 46
     if (isset($_POST['username']))
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         $openid = new SimpleOpenID();
49 49
         $openid->SetIdentity($_POST['username']);
50 50
         $protocol = ($conf->file->main_force_https ? 'https://' : 'http://');
51
-        $openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]);
52
-        $openid->SetRequiredFields(array('email','fullname'));
51
+        $openid->SetTrustRoot($protocol.$_SERVER["HTTP_HOST"]);
52
+        $openid->SetRequiredFields(array('email', 'fullname'));
53 53
         $_SESSION['dol_entity'] = $_POST["entity"];
54 54
         //$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone'));
55 55
         if ($openid->sendDiscoveryRequestToGetXRDS())
56 56
         {
57
-            $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);      // Send Response from OpenID server to this script
58
-            $openid->Redirect();     // This will redirect user to OpenID Server
57
+            $openid->SetApprovedURL($protocol.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script
58
+            $openid->Redirect(); // This will redirect user to OpenID Server
59 59
         }
60 60
         else
61 61
         {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         return false;
66 66
     }
67 67
     // Perform HTTP Request to OpenID server to validate key
68
-    elseif($_GET['openid_mode'] == 'id_res')
68
+    elseif ($_GET['openid_mode'] == 'id_res')
69 69
     {
70 70
         $openid = new SimpleOpenID();
71 71
         $openid->SetIdentity($_GET['openid_identity']);
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
         {
75 75
             // OK HERE KEY IS VALID
76 76
 
77
-            $sql ="SELECT login";
78
-            $sql.=" FROM ".MAIN_DB_PREFIX."user";
79
-            $sql.=" WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
80
-            $sql.=" AND entity IN (0," . ($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1) . ")";
77
+            $sql = "SELECT login";
78
+            $sql .= " FROM ".MAIN_DB_PREFIX."user";
79
+            $sql .= " WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
80
+            $sql .= " AND entity IN (0,".($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1).")";
81 81
 
82 82
             dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG);
83
-            $resql=$db->query($sql);
83
+            $resql = $db->query($sql);
84 84
             if ($resql)
85 85
             {
86
-                $obj=$db->fetch_object($resql);
86
+                $obj = $db->fetch_object($resql);
87 87
                 if ($obj)
88 88
                 {
89
-                    $login=$obj->login;
89
+                    $login = $obj->login;
90 90
                 }
91 91
             }
92 92
         }
93
-        else if($openid->IsError() === true)
93
+        else if ($openid->IsError() === true)
94 94
         {
95 95
             // ON THE WAY, WE GOT SOME ERROR
96 96
             $error = $openid->GetError();
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
         {
57 57
             $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);      // Send Response from OpenID server to this script
58 58
             $openid->Redirect();     // This will redirect user to OpenID Server
59
-        }
60
-        else
59
+        } else
61 60
         {
62 61
             $error = $openid->GetError();
63 62
             return false;
@@ -89,21 +88,18 @@  discard block
 block discarded – undo
89 88
                     $login=$obj->login;
90 89
                 }
91 90
             }
92
-        }
93
-        else if($openid->IsError() === true)
91
+        } else if($openid->IsError() === true)
94 92
         {
95 93
             // ON THE WAY, WE GOT SOME ERROR
96 94
             $error = $openid->GetError();
97 95
             return false;
98
-        }
99
-        else
96
+        } else
100 97
         {
101 98
             // Signature Verification Failed
102 99
             //echo "INVALID AUTHORIZATION";
103 100
             return false;
104 101
         }
105
-    }
106
-    else if ($_GET['openid_mode'] == 'cancel')
102
+    } else if ($_GET['openid_mode'] == 'cancel')
107 103
     {
108 104
         // User Canceled your Request
109 105
         //echo "USER CANCELED REQUEST";
Please login to merge, or discard this patch.