Passed
Push — 1.10.x ( f9cbcd...83c791 )
by Yannick
657:30 queued 614:41
created
main/inc/lib/phpmailer/class.phpmailer.php 1 patch
Spacing   +235 added lines, -236 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
39 39
  */
40 40
 
41
-if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
41
+if (version_compare(PHP_VERSION, '5.0.0', '<')) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
42 42
 
43 43
 class PHPMailer {
44 44
 
@@ -50,64 +50,64 @@  discard block
 block discarded – undo
50 50
    * Email priority (1 = High, 3 = Normal, 5 = low).
51 51
    * @var int
52 52
    */
53
-  public $Priority          = 3;
53
+  public $Priority = 3;
54 54
 
55 55
   /**
56 56
    * Sets the CharSet of the message.
57 57
    * @var string
58 58
    */
59
-  public $CharSet           = 'iso-8859-1';
59
+  public $CharSet = 'iso-8859-1';
60 60
 
61 61
   /**
62 62
    * Sets the Content-type of the message.
63 63
    * @var string
64 64
    */
65
-  public $ContentType       = 'text/plain';
65
+  public $ContentType = 'text/plain';
66 66
 
67 67
   /**
68 68
    * Sets the Encoding of the message. Options for this are
69 69
    *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
70 70
    * @var string
71 71
    */
72
-  public $Encoding          = '8bit';
72
+  public $Encoding = '8bit';
73 73
 
74 74
   /**
75 75
    * Holds the most recent mailer error message.
76 76
    * @var string
77 77
    */
78
-  public $ErrorInfo         = '';
78
+  public $ErrorInfo = '';
79 79
 
80 80
   /**
81 81
    * Sets the From email address for the message.
82 82
    * @var string
83 83
    */
84
-  public $From              = 'root@localhost';
84
+  public $From = 'root@localhost';
85 85
 
86 86
   /**
87 87
    * Sets the From name of the message.
88 88
    * @var string
89 89
    */
90
-  public $FromName          = 'Root User';
90
+  public $FromName = 'Root User';
91 91
 
92 92
   /**
93 93
    * Sets the Sender email (Return-Path) of the message.  If not empty,
94 94
    * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95 95
    * @var string
96 96
    */
97
-  public $Sender            = '';
97
+  public $Sender = '';
98 98
 
99 99
   /**
100 100
    * Sets the Subject of the message.
101 101
    * @var string
102 102
    */
103
-  public $Subject           = '';
103
+  public $Subject = '';
104 104
 
105 105
   /**
106 106
    * Sets the Body of the message.  This can be either an HTML or text body.
107 107
    * If HTML then run IsHTML(true).
108 108
    * @var string
109 109
    */
110
-  public $Body              = '';
110
+  public $Body = '';
111 111
 
112 112
   /**
113 113
    * Sets the text-only body of the message.  This automatically sets the
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
    * that can read HTML will view the normal Body.
117 117
    * @var string
118 118
    */
119
-  public $AltBody           = '';
119
+  public $AltBody = '';
120 120
 
121 121
   /**
122 122
    * Sets word wrapping on the body of the message to a given number of
123 123
    * characters.
124 124
    * @var int
125 125
    */
126
-  public $WordWrap          = 0;
126
+  public $WordWrap = 0;
127 127
 
128 128
   /**
129 129
    * Method to send mail: ("mail", "sendmail", or "smtp").
130 130
    * @var string
131 131
    */
132
-  public $Mailer            = 'mail';
132
+  public $Mailer = 'mail';
133 133
 
134 134
   /**
135 135
    * Sets the path of the sendmail program.
136 136
    * @var string
137 137
    */
138
-  public $Sendmail          = '/usr/sbin/sendmail';
138
+  public $Sendmail = '/usr/sbin/sendmail';
139 139
 
140 140
   /**
141 141
    * Path to PHPMailer plugins.  Useful if the SMTP class
142 142
    * is in a different directory than the PHP include path.
143 143
    * @var string
144 144
    */
145
-  public $PluginDir         = '';
145
+  public $PluginDir = '';
146 146
 
147 147
   /**
148 148
    * Sets the email address that a reading confirmation will be sent.
149 149
    * @var string
150 150
    */
151
-  public $ConfirmReadingTo  = '';
151
+  public $ConfirmReadingTo = '';
152 152
 
153 153
   /**
154 154
    * Sets the hostname to use in Message-Id and Received headers
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
    * by SERVER_NAME is used or 'localhost.localdomain'.
157 157
    * @var string
158 158
    */
159
-  public $Hostname          = '';
159
+  public $Hostname = '';
160 160
 
161 161
   /**
162 162
    * Sets the message ID to be used in the Message-Id header.
163 163
    * If empty, a unique id will be generated.
164 164
    * @var string
165 165
    */
166
-  public $MessageID         = '';
166
+  public $MessageID = '';
167 167
 
168 168
   /////////////////////////////////////////////////
169 169
   // PROPERTIES FOR SMTP
@@ -177,57 +177,57 @@  discard block
 block discarded – undo
177 177
    * Hosts will be tried in order.
178 178
    * @var string
179 179
    */
180
-  public $Host          = 'localhost';
180
+  public $Host = 'localhost';
181 181
 
182 182
   /**
183 183
    * Sets the default SMTP server port.
184 184
    * @var int
185 185
    */
186
-  public $Port          = 25;
186
+  public $Port = 25;
187 187
 
188 188
   /**
189 189
    * Sets the SMTP HELO of the message (Default is $Hostname).
190 190
    * @var string
191 191
    */
192
-  public $Helo          = '';
192
+  public $Helo = '';
193 193
 
194 194
   /**
195 195
    * Sets connection prefix.
196 196
    * Options are "", "ssl" or "tls"
197 197
    * @var string
198 198
    */
199
-  public $SMTPSecure    = '';
199
+  public $SMTPSecure = '';
200 200
 
201 201
   /**
202 202
    * Sets SMTP authentication. Utilizes the Username and Password variables.
203 203
    * @var bool
204 204
    */
205
-  public $SMTPAuth      = false;
205
+  public $SMTPAuth = false;
206 206
 
207 207
   /**
208 208
    * Sets SMTP username.
209 209
    * @var string
210 210
    */
211
-  public $Username      = '';
211
+  public $Username = '';
212 212
 
213 213
   /**
214 214
    * Sets SMTP password.
215 215
    * @var string
216 216
    */
217
-  public $Password      = '';
217
+  public $Password = '';
218 218
 
219 219
   /**
220 220
    * Sets the SMTP server timeout in seconds.
221 221
    * This function will not work with the win32 version.
222 222
    * @var int
223 223
    */
224
-  public $Timeout       = 10;
224
+  public $Timeout = 10;
225 225
 
226 226
   /**
227 227
    * Sets SMTP class debugging on or off.
228 228
    * @var bool
229 229
    */
230
-  public $SMTPDebug     = false;
230
+  public $SMTPDebug = false;
231 231
 
232 232
   /**
233 233
    * Prevents the SMTP connection from being closed after each mail
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
    * emails, instead of sending to entire TO addresses
243 243
    * @var bool
244 244
    */
245
-  public $SingleTo      = false;
245
+  public $SingleTo = false;
246 246
 
247 247
    /**
248 248
    * If SingleTo is true, this provides the array to hold the email addresses
@@ -254,34 +254,34 @@  discard block
 block discarded – undo
254 254
    * Provides the ability to change the line ending
255 255
    * @var string
256 256
    */
257
-  public $LE              = "\n";
257
+  public $LE = "\n";
258 258
 
259 259
   /**
260 260
    * Used with DKIM DNS Resource Record
261 261
    * @var string
262 262
    */
263
-  public $DKIM_selector   = 'phpmailer';
263
+  public $DKIM_selector = 'phpmailer';
264 264
 
265 265
   /**
266 266
    * Used with DKIM DNS Resource Record
267 267
    * optional, in format of email address '[email protected]'
268 268
    * @var string
269 269
    */
270
-  public $DKIM_identity   = '';
270
+  public $DKIM_identity = '';
271 271
 
272 272
   /**
273 273
    * Used with DKIM DNS Resource Record
274 274
    * optional, in format of email address '[email protected]'
275 275
    * @var string
276 276
    */
277
-  public $DKIM_domain     = '';
277
+  public $DKIM_domain = '';
278 278
 
279 279
   /**
280 280
    * Used with DKIM DNS Resource Record
281 281
    * optional, in format of email address '[email protected]'
282 282
    * @var string
283 283
    */
284
-  public $DKIM_private    = '';
284
+  public $DKIM_private = '';
285 285
 
286 286
   /**
287 287
    * Callback Action function name
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
    * Sets the PHPMailer Version number
301 301
    * @var string
302 302
    */
303
-  public $Version         = '5.1';
303
+  public $Version = '5.1';
304 304
 
305 305
   /////////////////////////////////////////////////
306 306
   // PROPERTIES, PRIVATE AND PROTECTED
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
    */
452 452
   private function AddAnAddress($kind, $address, $name = '') {
453 453
     if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
454
-      error_log('Invalid recipient array: ' . $kind);
454
+      error_log('Invalid recipient array: '.$kind);
455 455
       return false;
456 456
     }
457 457
     $address = trim($address);
458 458
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459 459
     if (!self::ValidateAddress($address)) {
460
-      $this->SetError($this->Lang('invalid_address').': '. $address);
460
+      $this->SetError($this->Lang('invalid_address').': '.$address);
461 461
       if ($this->exceptions) {
462 462
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
463 463
       }
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
  * @param string $name
486 486
  * @return boolean
487 487
  */
488
-  public function SetFrom($address, $name = '',$auto=1) {
488
+  public function SetFrom($address, $name = '', $auto = 1) {
489 489
     $address = trim($address);
490 490
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491 491
     if (!self::ValidateAddress($address)) {
492
-      $this->SetError($this->Lang('invalid_address').': '. $address);
492
+      $this->SetError($this->Lang('invalid_address').': '.$address);
493 493
       if ($this->exceptions) {
494 494
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
495 495
       }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
    */
523 523
   public static function ValidateAddress($address) {
524 524
     if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
-      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
525
+      if (filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526 526
         return false;
527 527
       } else {
528 528
         return true;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
       }
550 550
 
551 551
       // Set whether the message is multipart/alternative
552
-      if(!empty($this->AltBody)) {
552
+      if (!empty($this->AltBody)) {
553 553
         $this->ContentType = 'multipart/alternative';
554 554
       }
555 555
 
@@ -564,12 +564,12 @@  discard block
 block discarded – undo
564 564
 
565 565
       // digitally sign with DKIM if enabled
566 566
       if ($this->DKIM_domain && $this->DKIM_private) {
567
-        $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568
-        $header = str_replace("\r\n","\n",$header_dkim) . $header;
567
+        $header_dkim = $this->DKIM_Add($header, $this->Subject, $body);
568
+        $header = str_replace("\r\n", "\n", $header_dkim).$header;
569 569
       }
570 570
 
571 571
       // Choose the mailer and send through it
572
-      switch($this->Mailer) {
572
+      switch ($this->Mailer) {
573 573
         case 'sendmail':
574 574
           return $this->SendmailSend($header, $body);
575 575
         case 'smtp':
@@ -602,32 +602,32 @@  discard block
 block discarded – undo
602 602
     }
603 603
     if ($this->SingleTo === true) {
604 604
       foreach ($this->SingleToArray as $key => $val) {
605
-        if(!@$mail = popen($sendmail, 'w')) {
606
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
605
+        if (!@$mail = popen($sendmail, 'w')) {
606
+          throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
607 607
         }
608
-        fputs($mail, "To: " . $val . "\n");
608
+        fputs($mail, "To: ".$val."\n");
609 609
         fputs($mail, $header);
610 610
         fputs($mail, $body);
611 611
         $result = pclose($mail);
612 612
         // implement call back function if it exists
613 613
         $isSent = ($result == 0) ? 1 : 0;
614
-        $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
615
-        if($result != 0) {
616
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
614
+        $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
615
+        if ($result != 0) {
616
+          throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
617 617
         }
618 618
       }
619 619
     } else {
620
-      if(!@$mail = popen($sendmail, 'w')) {
621
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
620
+      if (!@$mail = popen($sendmail, 'w')) {
621
+        throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
622 622
       }
623 623
       fputs($mail, $header);
624 624
       fputs($mail, $body);
625 625
       $result = pclose($mail);
626 626
       // implement call back function if it exists
627 627
       $isSent = ($result == 0) ? 1 : 0;
628
-      $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
629
-      if($result != 0) {
630
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
628
+      $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
629
+      if ($result != 0) {
630
+        throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
631 631
       }
632 632
     }
633 633
     return true;
@@ -642,13 +642,13 @@  discard block
 block discarded – undo
642 642
    */
643 643
   protected function MailSend($header, $body) {
644 644
     $toArr = array();
645
-    foreach($this->to as $t) {
645
+    foreach ($this->to as $t) {
646 646
       $toArr[] = $this->AddrFormat($t);
647 647
     }
648 648
     $to = implode(', ', $toArr);
649 649
 
650 650
     $params = sprintf("-oi -f %s", $this->Sender);
651
-    if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
651
+    if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
652 652
       $old_from = ini_get('sendmail_from');
653 653
       ini_set('sendmail_from', $this->Sender);
654 654
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
657 657
           // implement call back function if it exists
658 658
           $isSent = ($rt == 1) ? 1 : 0;
659
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
659
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
660 660
         }
661 661
       } else {
662 662
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
663 663
         // implement call back function if it exists
664 664
         $isSent = ($rt == 1) ? 1 : 0;
665
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
665
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
666 666
       }
667 667
     } else {
668 668
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -670,19 +670,19 @@  discard block
 block discarded – undo
670 670
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
671 671
           // implement call back function if it exists
672 672
           $isSent = ($rt == 1) ? 1 : 0;
673
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
673
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
674 674
         }
675 675
       } else {
676 676
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
677 677
         // implement call back function if it exists
678 678
         $isSent = ($rt == 1) ? 1 : 0;
679
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
679
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
680 680
       }
681 681
     }
682 682
     if (isset($old_from)) {
683 683
       ini_set('sendmail_from', $old_from);
684 684
     }
685
-    if(!$rt) {
685
+    if (!$rt) {
686 686
       throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
687 687
     }
688 688
     return true;
@@ -698,64 +698,64 @@  discard block
 block discarded – undo
698 698
    * @return bool
699 699
    */
700 700
   protected function SmtpSend($header, $body) {
701
-    require_once $this->PluginDir . 'class.smtp.php';
701
+    require_once $this->PluginDir.'class.smtp.php';
702 702
     $bad_rcpt = array();
703 703
 
704
-    if(!$this->SmtpConnect()) {
704
+    if (!$this->SmtpConnect()) {
705 705
       throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
706 706
     }
707 707
     $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
708
-    if(!$this->smtp->Mail($smtp_from)) {
709
-      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
708
+    if (!$this->smtp->Mail($smtp_from)) {
709
+      throw new phpmailerException($this->Lang('from_failed').$smtp_from, self::STOP_CRITICAL);
710 710
     }
711 711
 
712 712
     // Attempt to send attach all recipients
713
-    foreach($this->to as $to) {
713
+    foreach ($this->to as $to) {
714 714
       if (!$this->smtp->Recipient($to[0])) {
715 715
         $bad_rcpt[] = $to[0];
716 716
         // implement call back function if it exists
717 717
         $isSent = 0;
718
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
718
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
719 719
       } else {
720 720
         // implement call back function if it exists
721 721
         $isSent = 1;
722
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
722
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
723 723
       }
724 724
     }
725
-    foreach($this->cc as $cc) {
725
+    foreach ($this->cc as $cc) {
726 726
       if (!$this->smtp->Recipient($cc[0])) {
727 727
         $bad_rcpt[] = $cc[0];
728 728
         // implement call back function if it exists
729 729
         $isSent = 0;
730
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
730
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
731 731
       } else {
732 732
         // implement call back function if it exists
733 733
         $isSent = 1;
734
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
734
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
735 735
       }
736 736
     }
737
-    foreach($this->bcc as $bcc) {
737
+    foreach ($this->bcc as $bcc) {
738 738
       if (!$this->smtp->Recipient($bcc[0])) {
739 739
         $bad_rcpt[] = $bcc[0];
740 740
         // implement call back function if it exists
741 741
         $isSent = 0;
742
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
742
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
743 743
       } else {
744 744
         // implement call back function if it exists
745 745
         $isSent = 1;
746
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
746
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
747 747
       }
748 748
     }
749 749
 
750 750
 
751
-    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
751
+    if (count($bad_rcpt) > 0) { //Create error message for any bad addresses
752 752
       $badaddresses = implode(', ', $bad_rcpt);
753
-      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
753
+      throw new phpmailerException($this->Lang('recipients_failed').$badaddresses);
754 754
     }
755
-    if(!$this->smtp->Data($header . $body)) {
755
+    if (!$this->smtp->Data($header.$body)) {
756 756
       throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
757 757
     }
758
-    if($this->SMTPKeepAlive == true) {
758
+    if ($this->SMTPKeepAlive == true) {
759 759
       $this->smtp->Reset();
760 760
     }
761 761
     return true;
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
    * @return bool
770 770
    */
771 771
   public function SmtpConnect() {
772
-    if(is_null($this->smtp)) {
772
+    if (is_null($this->smtp)) {
773 773
       $this->smtp = new SMTP();
774 774
     }
775 775
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 
781 781
     // Retry while there is no connection
782 782
     try {
783
-      while($index < count($hosts) && !$connection) {
783
+      while ($index < count($hosts) && !$connection) {
784 784
         $hostinfo = array();
785 785
         if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
786 786
           $host = $hostinfo[1];
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         $tls = ($this->SMTPSecure == 'tls');
794 794
         $ssl = ($this->SMTPSecure == 'ssl');
795 795
 
796
-        if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
796
+        if ($this->smtp->Connect(($ssl ? 'ssl://' : '').$host, $port, $this->Timeout)) {
797 797
 
798 798
           $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
799 799
           $this->smtp->Hello($hello);
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
    * @return void
832 832
    */
833 833
   public function SmtpClose() {
834
-    if(!is_null($this->smtp)) {
835
-      if($this->smtp->Connected()) {
834
+    if (!is_null($this->smtp)) {
835
+      if ($this->smtp->Connected()) {
836 836
         $this->smtp->Quit();
837 837
         $this->smtp->Close();
838 838
       }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
    * @return string
895 895
    */
896 896
   public function AddrAppend($type, $addr) {
897
-    $addr_str = $type . ': ';
897
+    $addr_str = $type.': ';
898 898
     $addresses = array();
899 899
     foreach ($addr as $a) {
900 900
       $addresses[] = $this->AddrFormat($a);
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
     if (empty($addr[1])) {
915 915
       return $this->SecureHeader($addr[0]);
916 916
     } else {
917
-      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
917
+      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase')." <".$this->SecureHeader($addr[0]).">";
918 918
     }
919 919
   }
920 920
 
@@ -941,10 +941,10 @@  discard block
 block discarded – undo
941 941
 
942 942
     $line = explode($this->LE, $message);
943 943
     $message = '';
944
-    for ($i=0 ;$i < count($line); $i++) {
944
+    for ($i = 0; $i < count($line); $i++) {
945 945
       $line_part = explode(' ', $line[$i]);
946 946
       $buf = '';
947
-      for ($e = 0; $e<count($line_part); $e++) {
947
+      for ($e = 0; $e < count($line_part); $e++) {
948 948
         $word = $line_part[$e];
949 949
         if ($qp_mode and (strlen($word) > $length)) {
950 950
           $space_left = $length - strlen($buf) - 1;
@@ -960,10 +960,10 @@  discard block
 block discarded – undo
960 960
               }
961 961
               $part = substr($word, 0, $len);
962 962
               $word = substr($word, $len);
963
-              $buf .= ' ' . $part;
964
-              $message .= $buf . sprintf("=%s", $this->LE);
963
+              $buf .= ' '.$part;
964
+              $message .= $buf.sprintf("=%s", $this->LE);
965 965
             } else {
966
-              $message .= $buf . $soft_break;
966
+              $message .= $buf.$soft_break;
967 967
             }
968 968
             $buf = '';
969 969
           }
@@ -980,22 +980,22 @@  discard block
 block discarded – undo
980 980
             $word = substr($word, $len);
981 981
 
982 982
             if (strlen($word) > 0) {
983
-              $message .= $part . sprintf("=%s", $this->LE);
983
+              $message .= $part.sprintf("=%s", $this->LE);
984 984
             } else {
985 985
               $buf = $part;
986 986
             }
987 987
           }
988 988
         } else {
989 989
           $buf_o = $buf;
990
-          $buf .= ($e == 0) ? $word : (' ' . $word);
990
+          $buf .= ($e == 0) ? $word : (' '.$word);
991 991
 
992 992
           if (strlen($buf) > $length and $buf_o != '') {
993
-            $message .= $buf_o . $soft_break;
993
+            $message .= $buf_o.$soft_break;
994 994
             $buf = $word;
995 995
           }
996 996
         }
997 997
       }
998
-      $message .= $buf . $this->LE;
998
+      $message .= $buf.$this->LE;
999 999
     }
1000 1000
 
1001 1001
     return $message;
@@ -1024,8 +1024,7 @@  discard block
 block discarded – undo
1024 1024
         if ($dec < 128) { // Single byte character.
1025 1025
           // If the encoded char was found at pos 0, it will fit
1026 1026
           // otherwise reduce maxLength to start of the encoded char
1027
-          $maxLength = ($encodedCharPos == 0) ? $maxLength :
1028
-          $maxLength - ($lookBack - $encodedCharPos);
1027
+          $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos);
1029 1028
           $foundSplitPos = true;
1030 1029
         } elseif ($dec >= 192) { // First byte of a multi byte character
1031 1030
           // Reduce maxLength to split at start of character
@@ -1049,11 +1048,11 @@  discard block
 block discarded – undo
1049 1048
    * @return void
1050 1049
    */
1051 1050
   public function SetWordWrap() {
1052
-    if($this->WordWrap < 1) {
1051
+    if ($this->WordWrap < 1) {
1053 1052
       return;
1054 1053
     }
1055 1054
 
1056
-    switch($this->message_type) {
1055
+    switch ($this->message_type) {
1057 1056
       case 'alt':
1058 1057
       case 'alt_attachments':
1059 1058
         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
@@ -1074,24 +1073,24 @@  discard block
 block discarded – undo
1074 1073
 
1075 1074
     // Set the boundaries
1076 1075
     $uniq_id = md5(uniqid(time()));
1077
-    $this->boundary[1] = 'b1_' . $uniq_id;
1078
-    $this->boundary[2] = 'b2_' . $uniq_id;
1076
+    $this->boundary[1] = 'b1_'.$uniq_id;
1077
+    $this->boundary[2] = 'b2_'.$uniq_id;
1079 1078
 
1080 1079
     $result .= $this->HeaderLine('Date', self::RFCDate());
1081
-    if($this->Sender == '') {
1080
+    if ($this->Sender == '') {
1082 1081
       $result .= $this->HeaderLine('Return-Path', trim($this->From));
1083 1082
     } else {
1084 1083
       $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1085 1084
     }
1086 1085
 
1087 1086
     // To be created automatically by mail()
1088
-    if($this->Mailer != 'mail') {
1087
+    if ($this->Mailer != 'mail') {
1089 1088
       if ($this->SingleTo === true) {
1090
-        foreach($this->to as $t) {
1089
+        foreach ($this->to as $t) {
1091 1090
           $this->SingleToArray[] = $this->AddrFormat($t);
1092 1091
         }
1093 1092
       } else {
1094
-        if(count($this->to) > 0) {
1093
+        if (count($this->to) > 0) {
1095 1094
           $result .= $this->AddrAppend('To', $this->to);
1096 1095
         } elseif (count($this->cc) == 0) {
1097 1096
           $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
@@ -1105,38 +1104,38 @@  discard block
 block discarded – undo
1105 1104
     $result .= $this->AddrAppend('From', $from);
1106 1105
 
1107 1106
     // sendmail and mail() extract Cc from the header before sending
1108
-    if(count($this->cc) > 0) {
1107
+    if (count($this->cc) > 0) {
1109 1108
       $result .= $this->AddrAppend('Cc', $this->cc);
1110 1109
     }
1111 1110
 
1112 1111
     // sendmail and mail() extract Bcc from the header before sending
1113
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1112
+    if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1114 1113
       $result .= $this->AddrAppend('Bcc', $this->bcc);
1115 1114
     }
1116 1115
 
1117
-    if(count($this->ReplyTo) > 0) {
1116
+    if (count($this->ReplyTo) > 0) {
1118 1117
       $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1119 1118
     }
1120 1119
 
1121 1120
     // mail() sets the subject itself
1122
-    if($this->Mailer != 'mail') {
1121
+    if ($this->Mailer != 'mail') {
1123 1122
       $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1124 1123
     }
1125 1124
 
1126
-    if($this->MessageID != '') {
1127
-      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1125
+    if ($this->MessageID != '') {
1126
+      $result .= $this->HeaderLine('Message-ID', $this->MessageID);
1128 1127
     } else {
1129 1128
       $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1130 1129
     }
1131 1130
     $result .= $this->HeaderLine('X-Priority', $this->Priority);
1132 1131
     $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1133 1132
 
1134
-    if($this->ConfirmReadingTo != '') {
1135
-      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1133
+    if ($this->ConfirmReadingTo != '') {
1134
+      $result .= $this->HeaderLine('Disposition-Notification-To', '<'.trim($this->ConfirmReadingTo).'>');
1136 1135
     }
1137 1136
 
1138 1137
     // Add custom headers
1139
-    for($index = 0; $index < count($this->CustomHeader); $index++) {
1138
+    for ($index = 0; $index < count($this->CustomHeader); $index++) {
1140 1139
       $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1141 1140
     }
1142 1141
     if (!$this->sign_key_file) {
@@ -1154,27 +1153,27 @@  discard block
 block discarded – undo
1154 1153
    */
1155 1154
   public function GetMailMIME() {
1156 1155
     $result = '';
1157
-    switch($this->message_type) {
1156
+    switch ($this->message_type) {
1158 1157
       case 'plain':
1159 1158
         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1160 1159
         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1161 1160
         break;
1162 1161
       case 'attachments':
1163 1162
       case 'alt_attachments':
1164
-        if($this->InlineImageExists()){
1163
+        if ($this->InlineImageExists()) {
1165 1164
           $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1166 1165
         } else {
1167 1166
           $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1168
-          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1167
+          $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"');
1169 1168
         }
1170 1169
         break;
1171 1170
       case 'alt':
1172 1171
         $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1173
-        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1172
+        $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"');
1174 1173
         break;
1175 1174
     }
1176 1175
 
1177
-    if($this->Mailer != 'mail') {
1176
+    if ($this->Mailer != 'mail') {
1178 1177
       $result .= $this->LE.$this->LE;
1179 1178
     }
1180 1179
 
@@ -1195,7 +1194,7 @@  discard block
 block discarded – undo
1195 1194
 
1196 1195
     $this->SetWordWrap();
1197 1196
 
1198
-    switch($this->message_type) {
1197
+    switch ($this->message_type) {
1199 1198
       case 'alt':
1200 1199
         $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1201 1200
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
@@ -1216,11 +1215,11 @@  discard block
 block discarded – undo
1216 1215
         break;
1217 1216
       case 'alt_attachments':
1218 1217
         $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1219
-        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1220
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
1218
+        $body .= sprintf("Content-Type: %s;%s"."\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1219
+        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '').$this->LE; // Create text body
1221 1220
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1222 1221
         $body .= $this->LE.$this->LE;
1223
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
1222
+        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '').$this->LE; // Create the HTML body
1224 1223
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1225 1224
         $body .= $this->LE.$this->LE;
1226 1225
         $body .= $this->EndBoundary($this->boundary[2]);
@@ -1261,16 +1260,16 @@  discard block
 block discarded – undo
1261 1260
    */
1262 1261
   private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1263 1262
     $result = '';
1264
-    if($charSet == '') {
1263
+    if ($charSet == '') {
1265 1264
       $charSet = $this->CharSet;
1266 1265
     }
1267
-    if($contentType == '') {
1266
+    if ($contentType == '') {
1268 1267
       $contentType = $this->ContentType;
1269 1268
     }
1270
-    if($encoding == '') {
1269
+    if ($encoding == '') {
1271 1270
       $encoding = $this->Encoding;
1272 1271
     }
1273
-    $result .= $this->TextLine('--' . $boundary);
1272
+    $result .= $this->TextLine('--'.$boundary);
1274 1273
     $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
1275 1274
     $result .= $this->LE;
1276 1275
     $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
@@ -1284,7 +1283,7 @@  discard block
 block discarded – undo
1284 1283
    * @access private
1285 1284
    */
1286 1285
   private function EndBoundary($boundary) {
1287
-    return $this->LE . '--' . $boundary . '--' . $this->LE;
1286
+    return $this->LE.'--'.$boundary.'--'.$this->LE;
1288 1287
   }
1289 1288
 
1290 1289
   /**
@@ -1293,16 +1292,16 @@  discard block
 block discarded – undo
1293 1292
    * @return void
1294 1293
    */
1295 1294
   private function SetMessageType() {
1296
-    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1295
+    if (count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1297 1296
       $this->message_type = 'plain';
1298 1297
     } else {
1299
-      if(count($this->attachment) > 0) {
1298
+      if (count($this->attachment) > 0) {
1300 1299
         $this->message_type = 'attachments';
1301 1300
       }
1302
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1301
+      if (strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1303 1302
         $this->message_type = 'alt';
1304 1303
       }
1305
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1304
+      if (strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1306 1305
         $this->message_type = 'alt_attachments';
1307 1306
       }
1308 1307
     }
@@ -1314,7 +1313,7 @@  discard block
 block discarded – undo
1314 1313
    * @return string
1315 1314
    */
1316 1315
   public function HeaderLine($name, $value) {
1317
-    return $name . ': ' . $value . $this->LE;
1316
+    return $name.': '.$value.$this->LE;
1318 1317
   }
1319 1318
 
1320 1319
   /**
@@ -1323,7 +1322,7 @@  discard block
 block discarded – undo
1323 1322
    * @return string
1324 1323
    */
1325 1324
   public function TextLine($value) {
1326
-    return $value . $this->LE;
1325
+    return $value.$this->LE;
1327 1326
   }
1328 1327
 
1329 1328
   /////////////////////////////////////////////////
@@ -1342,11 +1341,11 @@  discard block
 block discarded – undo
1342 1341
    */
1343 1342
   public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1344 1343
     try {
1345
-      if ( !@is_file($path) ) {
1346
-        throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1344
+      if (!@is_file($path)) {
1345
+        throw new phpmailerException($this->Lang('file_access').$path, self::STOP_CONTINUE);
1347 1346
       }
1348 1347
       $filename = basename($path);
1349
-      if ( $name == '' ) {
1348
+      if ($name == '') {
1350 1349
         $name = $filename;
1351 1350
       }
1352 1351
 
@@ -1356,7 +1355,7 @@  discard block
 block discarded – undo
1356 1355
         2 => $name,
1357 1356
         3 => $encoding,
1358 1357
         4 => $type,
1359
-        5 => false,  // isStringAttachment
1358
+        5 => false, // isStringAttachment
1360 1359
         6 => 'attachment',
1361 1360
         7 => 0
1362 1361
       );
@@ -1367,7 +1366,7 @@  discard block
 block discarded – undo
1367 1366
         throw $e;
1368 1367
       }
1369 1368
       error_log($e->getMessage()."\n");
1370
-      if ( $e->getCode() == self::STOP_CRITICAL ) {
1369
+      if ($e->getCode() == self::STOP_CRITICAL) {
1371 1370
         return false;
1372 1371
       }
1373 1372
     }
@@ -1412,29 +1411,29 @@  discard block
 block discarded – undo
1412 1411
       $disposition = $attachment[6];
1413 1412
       $cid         = $attachment[7];
1414 1413
       $incl[]      = $attachment[0];
1415
-      if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1414
+      if ($disposition == 'inline' && isset($cidUniq[$cid])) { continue; }
1416 1415
       $cidUniq[$cid] = true;
1417 1416
 
1418 1417
       $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1419 1418
       $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1420 1419
       $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1421 1420
 
1422
-      if($disposition == 'inline') {
1421
+      if ($disposition == 'inline') {
1423 1422
         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1424 1423
       }
1425 1424
 
1426 1425
       $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1427 1426
 
1428 1427
       // Encode as string attachment
1429
-      if($bString) {
1428
+      if ($bString) {
1430 1429
         $mime[] = $this->EncodeString($string, $encoding);
1431
-        if($this->IsError()) {
1430
+        if ($this->IsError()) {
1432 1431
           return '';
1433 1432
         }
1434 1433
         $mime[] = $this->LE.$this->LE;
1435 1434
       } else {
1436 1435
         $mime[] = $this->EncodeFile($path, $encoding);
1437
-        if($this->IsError()) {
1436
+        if ($this->IsError()) {
1438 1437
           return '';
1439 1438
         }
1440 1439
         $mime[] = $this->LE.$this->LE;
@@ -1458,7 +1457,7 @@  discard block
 block discarded – undo
1458 1457
   private function EncodeFile($path, $encoding = 'base64') {
1459 1458
     try {
1460 1459
       if (!is_readable($path)) {
1461
-        throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1460
+        throw new phpmailerException($this->Lang('file_open').$path, self::STOP_CONTINUE);
1462 1461
       }
1463 1462
         $magic_quotes = get_magic_quotes_runtime();
1464 1463
         if ($magic_quotes) {
@@ -1492,9 +1491,9 @@  discard block
 block discarded – undo
1492 1491
    * @access public
1493 1492
    * @return string
1494 1493
    */
1495
-  public function EncodeString ($str, $encoding = 'base64') {
1494
+  public function EncodeString($str, $encoding = 'base64') {
1496 1495
     $encoded = '';
1497
-    switch(strtolower($encoding)) {
1496
+    switch (strtolower($encoding)) {
1498 1497
       case 'base64':
1499 1498
         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1500 1499
         break;
@@ -1512,7 +1511,7 @@  discard block
 block discarded – undo
1512 1511
         $encoded = $this->EncodeQP($str);
1513 1512
         break;
1514 1513
       default:
1515
-        $this->SetError($this->Lang('encoding') . $encoding);
1514
+        $this->SetError($this->Lang('encoding').$encoding);
1516 1515
         break;
1517 1516
     }
1518 1517
     return $encoded;
@@ -1554,7 +1553,7 @@  discard block
 block discarded – undo
1554 1553
 
1555 1554
     $maxlen = 75 - 7 - strlen($this->CharSet);
1556 1555
     // Try to select the encoding which should produce the shortest output
1557
-    if (strlen($str)/3 < $x) {
1556
+    if (strlen($str) / 3 < $x) {
1558 1557
       $encoding = 'B';
1559 1558
       // Modified by Ivan Tcholakov, 24-JAN-2010.
1560 1559
       //if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
@@ -1635,7 +1634,7 @@  discard block
 block discarded – undo
1635 1634
       }
1636 1635
       while (strlen($chunk) > $length);
1637 1636
 
1638
-      $encoded .= $chunk . $this->LE;
1637
+      $encoded .= $chunk.$this->LE;
1639 1638
     }
1640 1639
 
1641 1640
     // Chomp the last linefeed
@@ -1651,37 +1650,37 @@  discard block
 block discarded – undo
1651 1650
   * @param integer $line_max Number of chars allowed on a line before wrapping
1652 1651
   * @return string
1653 1652
   */
1654
-  public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1655
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1653
+  public function EncodeQPphp($input = '', $line_max = 76, $space_conv = false) {
1654
+    $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
1656 1655
     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1657 1656
     $eol = "\r\n";
1658 1657
     $escape = '=';
1659 1658
     $output = '';
1660
-    while( list(, $line) = each($lines) ) {
1659
+    while (list(, $line) = each($lines)) {
1661 1660
       $linlen = strlen($line);
1662 1661
       $newline = '';
1663
-      for($i = 0; $i < $linlen; $i++) {
1664
-        $c = substr( $line, $i, 1 );
1665
-        $dec = ord( $c );
1666
-        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1662
+      for ($i = 0; $i < $linlen; $i++) {
1663
+        $c = substr($line, $i, 1);
1664
+        $dec = ord($c);
1665
+        if (($i == 0) && ($dec == 46)) { // convert first point in the line into =2E
1667 1666
           $c = '=2E';
1668 1667
         }
1669
-        if ( $dec == 32 ) {
1670
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1668
+        if ($dec == 32) {
1669
+          if ($i == ($linlen - 1)) { // convert space at eol only
1671 1670
             $c = '=20';
1672
-          } else if ( $space_conv ) {
1671
+          } else if ($space_conv) {
1673 1672
             $c = '=20';
1674 1673
           }
1675
-        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1676
-          $h2 = floor($dec/16);
1677
-          $h1 = floor($dec%16);
1674
+        } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1675
+          $h2 = floor($dec / 16);
1676
+          $h1 = floor($dec % 16);
1678 1677
           $c = $escape.$hex[$h2].$hex[$h1];
1679 1678
         }
1680
-        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1679
+        if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1681 1680
           $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1682 1681
           $newline = '';
1683 1682
           // check if newline first character will be point or not
1684
-          if ( $dec == 46 ) {
1683
+          if ($dec == 46) {
1685 1684
             $c = '=2E';
1686 1685
           }
1687 1686
         }
@@ -1733,7 +1732,7 @@  discard block
 block discarded – undo
1733 1732
    * @access public
1734 1733
    * @return string
1735 1734
    */
1736
-  public function EncodeQ ($str, $position = 'text') {
1735
+  public function EncodeQ($str, $position = 'text') {
1737 1736
     // There should not be any EOL in the string
1738 1737
     $encoded = preg_replace('/[\r\n]*/', '', $str);
1739 1738
 
@@ -1776,7 +1775,7 @@  discard block
 block discarded – undo
1776 1775
       2 => basename($filename),
1777 1776
       3 => $encoding,
1778 1777
       4 => $type,
1779
-      5 => true,  // isStringAttachment
1778
+      5 => true, // isStringAttachment
1780 1779
       6 => 'attachment',
1781 1780
       7 => 0
1782 1781
     );
@@ -1797,13 +1796,13 @@  discard block
 block discarded – undo
1797 1796
    */
1798 1797
   public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1799 1798
 
1800
-    if ( !@is_file($path) ) {
1801
-      $this->SetError($this->Lang('file_access') . $path);
1799
+    if (!@is_file($path)) {
1800
+      $this->SetError($this->Lang('file_access').$path);
1802 1801
       return false;
1803 1802
     }
1804 1803
 
1805 1804
     $filename = basename($path);
1806
-    if ( $name == '' ) {
1805
+    if ($name == '') {
1807 1806
       $name = $filename;
1808 1807
     }
1809 1808
 
@@ -1814,7 +1813,7 @@  discard block
 block discarded – undo
1814 1813
       2 => $name,
1815 1814
       3 => $encoding,
1816 1815
       4 => $type,
1817
-      5 => false,  // isStringAttachment
1816
+      5 => false, // isStringAttachment
1818 1817
       6 => 'inline',
1819 1818
       7 => $cid
1820 1819
     );
@@ -1828,7 +1827,7 @@  discard block
 block discarded – undo
1828 1827
    * @return bool
1829 1828
    */
1830 1829
   public function InlineImageExists() {
1831
-    foreach($this->attachment as $attachment) {
1830
+    foreach ($this->attachment as $attachment) {
1832 1831
       if ($attachment[6] == 'inline') {
1833 1832
         return true;
1834 1833
       }
@@ -1845,7 +1844,7 @@  discard block
 block discarded – undo
1845 1844
    * @return void
1846 1845
    */
1847 1846
   public function ClearAddresses() {
1848
-    foreach($this->to as $to) {
1847
+    foreach ($this->to as $to) {
1849 1848
       unset($this->all_recipients[strtolower($to[0])]);
1850 1849
     }
1851 1850
     $this->to = array();
@@ -1856,7 +1855,7 @@  discard block
 block discarded – undo
1856 1855
    * @return void
1857 1856
    */
1858 1857
   public function ClearCCs() {
1859
-    foreach($this->cc as $cc) {
1858
+    foreach ($this->cc as $cc) {
1860 1859
       unset($this->all_recipients[strtolower($cc[0])]);
1861 1860
     }
1862 1861
     $this->cc = array();
@@ -1867,7 +1866,7 @@  discard block
 block discarded – undo
1867 1866
    * @return void
1868 1867
    */
1869 1868
   public function ClearBCCs() {
1870
-    foreach($this->bcc as $bcc) {
1869
+    foreach ($this->bcc as $bcc) {
1871 1870
       unset($this->all_recipients[strtolower($bcc[0])]);
1872 1871
     }
1873 1872
     $this->bcc = array();
@@ -1924,7 +1923,7 @@  discard block
 block discarded – undo
1924 1923
     if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
1925 1924
       $lasterror = $this->smtp->getError();
1926 1925
       if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1927
-        $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
1926
+        $msg .= '<p>'.$this->Lang('smtp_error').$lasterror['smtp_msg']."</p>\n";
1928 1927
       }
1929 1928
     }
1930 1929
     $this->ErrorInfo = $msg;
@@ -1940,7 +1939,7 @@  discard block
 block discarded – undo
1940 1939
     $tz = date('Z');
1941 1940
     $tzs = ($tz < 0) ? '-' : '+';
1942 1941
     $tz = abs($tz);
1943
-    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1942
+    $tz = (int) ($tz / 3600) * 100 + ($tz % 3600) / 60;
1944 1943
     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1945 1944
 
1946 1945
     return $result;
@@ -1969,14 +1968,14 @@  discard block
 block discarded – undo
1969 1968
    * @return string
1970 1969
    */
1971 1970
   private function Lang($key) {
1972
-    if(count($this->language) < 1) {
1971
+    if (count($this->language) < 1) {
1973 1972
       $this->SetLanguage('en'); // set the default language
1974 1973
     }
1975 1974
 
1976
-    if(isset($this->language[$key])) {
1975
+    if (isset($this->language[$key])) {
1977 1976
       return $this->language[$key];
1978 1977
     } else {
1979
-      return 'Language string failed to load: ' . $key;
1978
+      return 'Language string failed to load: '.$key;
1980 1979
     }
1981 1980
   }
1982 1981
 
@@ -2017,19 +2016,19 @@  discard block
 block discarded – undo
2017 2016
    */
2018 2017
   public function MsgHTML($message, $basedir = '') {
2019 2018
     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2020
-    if(isset($images[2])) {
2021
-      foreach($images[2] as $i => $url) {
2019
+    if (isset($images[2])) {
2020
+      foreach ($images[2] as $i => $url) {
2022 2021
         // do not change urls for absolute images (thanks to corvuscorax)
2023
-        if (!preg_match('#^[A-z]+://#',$url)) {
2022
+        if (!preg_match('#^[A-z]+://#', $url)) {
2024 2023
           $filename = basename($url);
2025 2024
           $directory = dirname($url);
2026
-          ($directory == '.')?$directory='':'';
2027
-          $cid = 'cid:' . md5($filename);
2025
+          ($directory == '.') ? $directory = '' : '';
2026
+          $cid = 'cid:'.md5($filename);
2028 2027
           $ext = pathinfo($filename, PATHINFO_EXTENSION);
2029
-          $mimeType  = self::_mime_types($ext);
2030
-          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2031
-          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2032
-          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2028
+          $mimeType = self::_mime_types($ext);
2029
+          if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
2030
+          if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
2031
+          if ($this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType)) {
2033 2032
             $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2034 2033
           }
2035 2034
         }
@@ -2037,12 +2036,12 @@  discard block
 block discarded – undo
2037 2036
     }
2038 2037
     $this->IsHTML(true);
2039 2038
     $this->Body = $message;
2040
-    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2039
+    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2041 2040
     if (!empty($textMsg) && empty($this->AltBody)) {
2042 2041
       $this->AltBody = html_entity_decode($textMsg);
2043 2042
     }
2044 2043
     if (empty($this->AltBody)) {
2045
-      $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2044
+      $this->AltBody = 'To view this email message, open it in a program that understands HTML!'."\n\n";
2046 2045
     }
2047 2046
   }
2048 2047
 
@@ -2160,10 +2159,10 @@  discard block
 block discarded – undo
2160 2159
   */
2161 2160
   public function set($name, $value = '') {
2162 2161
     try {
2163
-      if (isset($this->$name) ) {
2162
+      if (isset($this->$name)) {
2164 2163
         $this->$name = $value;
2165 2164
       } else {
2166
-        throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2165
+        throw new phpmailerException($this->Lang('variable_set').$name, self::STOP_CRITICAL);
2167 2166
       }
2168 2167
     } catch (Exception $e) {
2169 2168
       $this->SetError($e->getMessage());
@@ -2207,14 +2206,14 @@  discard block
 block discarded – undo
2207 2206
    * @param string $key_pass Password for private key
2208 2207
    */
2209 2208
   public function DKIM_QP($txt) {
2210
-    $tmp="";
2211
-    $line="";
2212
-    for ($i=0;$i<strlen($txt);$i++) {
2213
-      $ord=ord($txt[$i]);
2214
-      if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2215
-        $line.=$txt[$i];
2209
+    $tmp = "";
2210
+    $line = "";
2211
+    for ($i = 0; $i < strlen($txt); $i++) {
2212
+      $ord = ord($txt[$i]);
2213
+      if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
2214
+        $line .= $txt[$i];
2216 2215
       } else {
2217
-        $line.="=".sprintf("%02X",$ord);
2216
+        $line .= "=".sprintf("%02X", $ord);
2218 2217
       }
2219 2218
     }
2220 2219
     return $line;
@@ -2228,8 +2227,8 @@  discard block
 block discarded – undo
2228 2227
    */
2229 2228
   public function DKIM_Sign($s) {
2230 2229
     $privKeyStr = file_get_contents($this->DKIM_private);
2231
-    if ($this->DKIM_passphrase!='') {
2232
-      $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2230
+    if ($this->DKIM_passphrase != '') {
2231
+      $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
2233 2232
     } else {
2234 2233
       $privKey = $privKeyStr;
2235 2234
     }
@@ -2245,15 +2244,15 @@  discard block
 block discarded – undo
2245 2244
    * @param string $s Header
2246 2245
    */
2247 2246
   public function DKIM_HeaderC($s) {
2248
-    $s=preg_replace("/\r\n\s+/"," ",$s);
2249
-    $lines=explode("\r\n",$s);
2247
+    $s = preg_replace("/\r\n\s+/", " ", $s);
2248
+    $lines = explode("\r\n", $s);
2250 2249
     foreach ($lines as $key=>$line) {
2251
-      list($heading,$value)=explode(":",$line,2);
2252
-      $heading=strtolower($heading);
2253
-      $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2254
-      $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2250
+      list($heading, $value) = explode(":", $line, 2);
2251
+      $heading = strtolower($heading);
2252
+      $value = preg_replace("/\s+/", " ", $value); // Compress useless spaces
2253
+      $lines[$key] = $heading.":".trim($value); // Don't forget to remove WSP around the value
2255 2254
     }
2256
-    $s=implode("\r\n",$lines);
2255
+    $s = implode("\r\n", $lines);
2257 2256
     return $s;
2258 2257
   }
2259 2258
 
@@ -2266,11 +2265,11 @@  discard block
 block discarded – undo
2266 2265
   public function DKIM_BodyC($body) {
2267 2266
     if ($body == '') return "\r\n";
2268 2267
     // stabilize line endings
2269
-    $body=str_replace("\r\n","\n",$body);
2270
-    $body=str_replace("\n","\r\n",$body);
2268
+    $body = str_replace("\r\n", "\n", $body);
2269
+    $body = str_replace("\n", "\r\n", $body);
2271 2270
     // END stabilize line endings
2272
-    while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2273
-      $body=substr($body,0,strlen($body)-2);
2271
+    while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
2272
+      $body = substr($body, 0, strlen($body) - 2);
2274 2273
     }
2275 2274
     return $body;
2276 2275
   }
@@ -2283,52 +2282,52 @@  discard block
 block discarded – undo
2283 2282
    * @param string $subject Subject
2284 2283
    * @param string $body Body
2285 2284
    */
2286
-  public function DKIM_Add($headers_line,$subject,$body) {
2285
+  public function DKIM_Add($headers_line, $subject, $body) {
2287 2286
     $DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2288 2287
     $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2289 2288
     $DKIMquery            = 'dns/txt'; // Query method
2290
-    $DKIMtime             = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2289
+    $DKIMtime             = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2291 2290
     $subject_header       = "Subject: $subject";
2292
-    $headers              = explode("\r\n",$headers_line);
2293
-    foreach($headers as $header) {
2294
-      if (strpos($header,'From:') === 0) {
2295
-        $from_header=$header;
2296
-      } elseif (strpos($header,'To:') === 0) {
2297
-        $to_header=$header;
2291
+    $headers              = explode("\r\n", $headers_line);
2292
+    foreach ($headers as $header) {
2293
+      if (strpos($header, 'From:') === 0) {
2294
+        $from_header = $header;
2295
+      } elseif (strpos($header, 'To:') === 0) {
2296
+        $to_header = $header;
2298 2297
       }
2299 2298
     }
2300
-    $from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2301
-    $to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
2302
-    $subject  = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2299
+    $from     = str_replace('|', '=7C', $this->DKIM_QP($from_header));
2300
+    $to       = str_replace('|', '=7C', $this->DKIM_QP($to_header));
2301
+    $subject  = str_replace('|', '=7C', $this->DKIM_QP($subject_header)); // Copied header fields (dkim-quoted-printable
2303 2302
     $body     = $this->DKIM_BodyC($body);
2304
-    $DKIMlen  = strlen($body) ; // Length of body
2305
-    $DKIMb64  = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2306
-    $ident    = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2307
-    $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2308
-                "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2303
+    $DKIMlen  = strlen($body); // Length of body
2304
+    $DKIMb64  = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body
2305
+    $ident    = ($this->DKIM_identity == '') ? '' : " i=".$this->DKIM_identity.";";
2306
+    $dkimhdrs = "DKIM-Signature: v=1; a=".$DKIMsignatureType."; q=".$DKIMquery."; l=".$DKIMlen."; s=".$this->DKIM_selector.";\r\n".
2307
+                "\tt=".$DKIMtime."; c=".$DKIMcanonicalization.";\r\n".
2309 2308
                 "\th=From:To:Subject;\r\n".
2310
-                "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2309
+                "\td=".$this->DKIM_domain.";".$ident."\r\n".
2311 2310
                 "\tz=$from\r\n".
2312 2311
                 "\t|$to\r\n".
2313 2312
                 "\t|$subject;\r\n".
2314
-                "\tbh=" . $DKIMb64 . ";\r\n".
2313
+                "\tbh=".$DKIMb64.";\r\n".
2315 2314
                 "\tb=";
2316
-    $toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2315
+    $toSign   = $this->DKIM_HeaderC($from_header."\r\n".$to_header."\r\n".$subject_header."\r\n".$dkimhdrs);
2317 2316
     $signed   = $this->DKIM_Sign($toSign);
2318 2317
     return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2319 2318
   }
2320 2319
 
2321
-  protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2320
+  protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) {
2322 2321
     if (!empty($this->action_function) && function_exists($this->action_function)) {
2323
-      $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2324
-      call_user_func_array($this->action_function,$params);
2322
+      $params = array($isSent, $to, $cc, $bcc, $subject, $body);
2323
+      call_user_func_array($this->action_function, $params);
2325 2324
     }
2326 2325
   }
2327 2326
 }
2328 2327
 
2329 2328
 class phpmailerException extends Exception {
2330 2329
   public function errorMessage() {
2331
-    $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2330
+    $errorMsg = '<strong>'.$this->getMessage()."</strong><br />\n";
2332 2331
     return $errorMsg;
2333 2332
   }
2334 2333
 }
Please login to merge, or discard this patch.
main/inc/lib/chat.lib.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $to_user_id,
187 187
         $message,
188 188
         $printResult = true,
189
-        $sanitize =  true
189
+        $sanitize = true
190 190
     )
191 191
     {
192 192
         $user_friend_relation = SocialManager::get_relation_between_contacts(
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 $messagesan = $message;
207 207
             }
208 208
 
209
-            error_log(print_r($sanitize) . '----' . $messagesan);
209
+            error_log(print_r($sanitize).'----'.$messagesan);
210 210
 
211 211
             if (!isset($_SESSION['chatHistory'][$to_user_id])) {
212 212
                 $_SESSION['chatHistory'][$to_user_id] = array();
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public static function disableChat()
291 291
     {
292
-        if (!empty($_SESSION['disable_chat'])){
292
+        if (!empty($_SESSION['disable_chat'])) {
293 293
             $status = $_SESSION['disable_chat'];
294
-            if ($status == true){
294
+            if ($status == true) {
295 295
                 $_SESSION['disable_chat'] = null;
296 296
                 return true;
297 297
             }
Please login to merge, or discard this patch.
main/inc/lib/array.lib.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 {
111 111
 	$old_locale = setlocale(LC_ALL, null);
112 112
 	$code = api_get_language_isocode();
113
-	$locale_list = array($code.'.utf8', 'en.utf8','en_US.utf8','en_GB.utf8');
113
+	$locale_list = array($code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8');
114 114
 	$try_sort = false;
115 115
 
116
-	foreach($locale_list as $locale) {
116
+	foreach ($locale_list as $locale) {
117 117
 		$my_local = setlocale(LC_COLLATE, $locale);
118 118
 		if ($my_local) {
119 119
 			$try_sort = true;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     $flatten = array();
152 152
     array_walk_recursive(
153 153
         $array,
154
-        function ($value) use (&$flatten) {
154
+        function($value) use (&$flatten) {
155 155
             $flatten[] = $value;
156 156
         }
157 157
     );
Please login to merge, or discard this patch.
main/inc/lib/surveymanager.lib.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     {
20 20
         // Database table definitions
21 21
         $table_survey = Database :: get_course_table(TABLE_SURVEY);
22
-        $table_survey_question 	= Database :: get_course_table(TABLE_SURVEY_QUESTION);
22
+        $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
23 23
         $table_user = Database :: get_main_table(TABLE_MAIN_USER);
24 24
 
25 25
         // searching
@@ -45,23 +45,23 @@  discard block
 block discarded – undo
45 45
 				GROUP BY survey.survey_id";
46 46
 
47 47
         $res = Database::query($sql);
48
-        $surveys_parents = array ();
48
+        $surveys_parents = array();
49 49
         $refs = array();
50 50
         $list = array();
51
-        $plain_array=array();
51
+        $plain_array = array();
52 52
 
53
-        while ($survey = Database::fetch_array($res,'ASSOC')) {
54
-            $plain_array[$survey['survey_id']]=$survey;
55
-            $surveys_parents[]=$survey['survey_version'];
56
-            $thisref = &$refs[ $survey['survey_id'] ];
53
+        while ($survey = Database::fetch_array($res, 'ASSOC')) {
54
+            $plain_array[$survey['survey_id']] = $survey;
55
+            $surveys_parents[] = $survey['survey_version'];
56
+            $thisref = &$refs[$survey['survey_id']];
57 57
             $thisref['parent_id'] = $survey['parent_id'];
58 58
             $thisref['name'] = $survey['name'];
59 59
             $thisref['id'] = $survey['survey_id'];
60 60
             $thisref['survey_version'] = $survey['survey_version'];
61 61
             if ($survey['parent_id'] == 0) {
62
-                $list[ $survey['survey_id'] ] = &$thisref;
62
+                $list[$survey['survey_id']] = &$thisref;
63 63
             } else {
64
-                $refs[ $survey['parent_id'] ]['children'][ $survey['survey_id'] ] = &$thisref;
64
+                $refs[$survey['parent_id']]['children'][$survey['survey_id']] = &$thisref;
65 65
             }
66 66
         }
67 67
         $this->surveylist = $list;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     public function getParentId($id)
81 81
     {
82 82
         $node = $this->plainsurveylist[$id];
83
-        if (is_array($node)&& !empty($node['parent_id'])) {
83
+        if (is_array($node) && !empty($node['parent_id'])) {
84 84
             return $node['parent_id'];
85 85
         } else {
86 86
             return -1;
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
         if (is_array($list)) {
101 101
             foreach ($list as $key => $node) {
102 102
                 if (isset($node['children']) && is_array($node['children'])) {
103
-                    $result[$key]= $node['name'];
103
+                    $result[$key] = $node['name'];
104 104
                     $re = self::createList($node['children']);
105 105
                     if (!empty($re)) {
106 106
                         if (is_array($re)) {
107 107
                             foreach ($re as $key => $r) {
108
-                                $result[$key] = '' . $r;
108
+                                $result[$key] = ''.$r;
109 109
                             }
110 110
                         } else {
111 111
                             $result[] = $re;
Please login to merge, or discard this patch.
main/inc/lib/notebook.lib.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         return "<script>
30 30
 				function confirmation (name)
31 31
 				{
32
-					if (confirm(\" " . get_lang("NoteConfirmDelete") . " \"+ name + \" ?\"))
32
+					if (confirm(\" " . get_lang("NoteConfirmDelete")." \"+ name + \" ?\"))
33 33
 						{return true;}
34 34
 					else
35 35
 						{return false;}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 description 		AS note_comment,
108 108
                 session_id			AS session_id
109 109
                FROM $t_notebook
110
-               WHERE c_id = $course_id AND notebook_id = '" . intval($notebook_id) . "' ";
110
+               WHERE c_id = $course_id AND notebook_id = '".intval($notebook_id)."' ";
111 111
         $result = Database::query($sql);
112 112
         if (Database::num_rows($result) != 1) {
113 113
             return array();
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
         $sql = "DELETE FROM $t_notebook
182 182
                 WHERE
183 183
                     c_id = $course_id AND
184
-                    notebook_id='" . intval($notebook_id) . "' AND
185
-                    user_id = '" . api_get_user_id() . "'";
184
+                    notebook_id='".intval($notebook_id)."' AND
185
+                    user_id = '" . api_get_user_id()."'";
186 186
         $result = Database::query($sql);
187 187
         $affected_rows = Database::affected_rows($result);
188 188
         if ($affected_rows != 1) {
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
         echo '<div class="actions">';
221 221
         if (!api_is_anonymous()) {
222 222
             if (api_get_session_id() == 0)
223
-                echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' .
224
-                    Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
223
+                echo '<a href="index.php?'.api_get_cidreq().'&action=addnote">'.
224
+                    Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32').'</a>';
225 225
             elseif (api_is_allowed_to_session_edit(false, true)) {
226
-                echo '<a href="index.php?' . api_get_cidreq() . '&action=addnote">' .
227
-                    Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
226
+                echo '<a href="index.php?'.api_get_cidreq().'&action=addnote">'.
227
+                    Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32').'</a>';
228 228
             }
229 229
         } else {
230
-            echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
230
+            echo '<a href="javascript:void(0)">'.Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32').'</a>';
231 231
         }
232 232
 
233
-        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' .
234
-            Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
235
-        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' .
236
-            Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
237
-        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' .
238
-            Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
233
+        echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=creation_date&direction='.$link_sort_direction.'">'.
234
+            Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32').'</a>';
235
+        echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=update_date&direction='.$link_sort_direction.'">'.
236
+            Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32').'</a>';
237
+        echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=title&direction='.$link_sort_direction.'">'.
238
+            Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32').'</a>';
239 239
         echo '</div>';
240 240
 
241 241
         if (!isset($_SESSION['notebook_view']) || !in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) {
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
         $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
247 247
         $order_by = "";
248 248
         if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') {
249
-            $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
249
+            $order_by = " ORDER BY ".$_SESSION['notebook_view']." $sort_direction ";
250 250
         } else {
251
-            $order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
251
+            $order_by = " ORDER BY ".$_SESSION['notebook_view']." $sort_direction ";
252 252
         }
253 253
 
254 254
         //condition for the session
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         $sql = "SELECT * FROM $t_notebook
262 262
                 WHERE
263 263
                     c_id = $course_id AND
264
-                    user_id = '" . api_get_user_id() . "'
264
+                    user_id = '".api_get_user_id()."'
265 265
                     $condition_session
266 266
                     $cond_extra $order_by
267 267
                 ";
@@ -274,18 +274,18 @@  discard block
 block discarded – undo
274 274
 
275 275
             $updateValue = '';
276 276
             if ($row['update_date'] <> $row['creation_date']) {
277
-                $updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
277
+                $updateValue = ', '.get_lang('UpdateDate').': '.date_to_str_ago($update_date).'&nbsp;&nbsp;<span class="dropbox_date">'.$update_date.'</span>';
278 278
             }
279 279
 
280
-            $actions = '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' .
281
-                Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
282
-            $actions .= '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' .
283
-                Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
280
+            $actions = '<a href="'.api_get_self().'?action=editnote&notebook_id='.$row['notebook_id'].'">'.
281
+                Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
282
+            $actions .= '<a href="'.api_get_self().'?action=deletenote&notebook_id='.$row['notebook_id'].'" onclick="return confirmation(\''.$row['title'].'\');">'.
283
+                Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
284 284
 
285 285
             echo Display::panel(
286 286
                 $row['description'],
287
-                $row['title'] . $session_img.' <div class="pull-right">'.$actions.'</div>',
288
-                get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue."</span>"
287
+                $row['title'].$session_img.' <div class="pull-right">'.$actions.'</div>',
288
+                get_lang('CreationDate').': '.date_to_str_ago($creation_date).'&nbsp;&nbsp;<span class="dropbox_date">'.$creation_date.$updateValue."</span>"
289 289
             );
290 290
         }
291 291
     }
Please login to merge, or discard this patch.
main/inc/lib/legal.lib.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             Database::insert($legal_table, $params);
45 45
 
46 46
             return true;
47
-        } elseif($last['type'] != $type && $language==$last['language_id']) {
47
+        } elseif ($last['type'] != $type && $language == $last['language_id']) {
48 48
             //update
49 49
             $id = $last['legal_id'];
50 50
             $params = [
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	public static function get_last_condition_version($language)
78 78
     {
79 79
 		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
80
-		$language= Database::escape_string($language);
80
+		$language = Database::escape_string($language);
81 81
 		$sql = "SELECT version FROM $legal_conditions_table
82 82
 		        WHERE language_id = '".$language."'
83 83
 		        ORDER BY legal_id DESC LIMIT 1 ";
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 	 * @param int $language language id
98 98
 	 * @return array all the info of a Term and condition
99 99
 	 */
100
-	public static function get_last_condition ($language)
100
+	public static function get_last_condition($language)
101 101
     {
102 102
 		$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
103
-		$language= Database::escape_string($language);
103
+		$language = Database::escape_string($language);
104 104
 		$sql = "SELECT * FROM $legal_conditions_table
105 105
                 WHERE language_id = '".$language."'
106 106
                 ORDER BY version DESC
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
                 ORDER BY version DESC
125 125
                 LIMIT 1 ";
126 126
         $result = Database::query($sql);
127
-        if (Database::num_rows($result)>0){
127
+        if (Database::num_rows($result) > 0) {
128 128
             $version = Database::fetch_array($result);
129
-            $version = explode(':',$version[0]);
129
+            $version = explode(':', $version[0]);
130 130
 
131 131
             return $version[0];
132 132
         } else {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 break;
154 154
                 // Page link
155 155
             case 1:
156
-                $preview ='<fieldset>
156
+                $preview = '<fieldset>
157 157
                              <legend>'.get_lang('TermsAndConditions').'</legend>';
158 158
                 $preview .= '<div id="legal-accept-wrapper" class="form-item">
159 159
                 <label class="option" for="legal-accept">
@@ -185,25 +185,25 @@  discard block
 block discarded – undo
185 185
 		$number_of_items = intval($number_of_items);
186 186
 		$column = intval($column);
187 187
 
188
- 		$sql  = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
188
+ 		$sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date)
189 189
 				FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) ";
190 190
 		$sql .= "ORDER BY language, version ASC ";
191 191
 		$sql .= "LIMIT $from, $number_of_items ";
192 192
 
193 193
 		$result = Database::query($sql);
194
-		$legals = array ();
195
-		$versions = array ();
194
+		$legals = array();
195
+		$versions = array();
196 196
 		while ($legal = Database::fetch_array($result)) {
197 197
 			// max 2000 chars
198 198
 			//echo strlen($legal[1]); echo '<br>';
199
-			$versions[]=$legal[0];
200
-			$languages[]=$legal[1];
201
-			if (strlen($legal[2])>2000)
202
-				$legal[2]= substr($legal[2],0,2000).' ... ';
203
-			if ($legal[4]==0)
204
-				$legal[4]= get_lang('HTMLText');
205
-			elseif($legal[4]==1)
206
-				$legal[4]=get_lang('PageLink');
199
+			$versions[] = $legal[0];
200
+			$languages[] = $legal[1];
201
+			if (strlen($legal[2]) > 2000)
202
+				$legal[2] = substr($legal[2], 0, 2000).' ... ';
203
+			if ($legal[4] == 0)
204
+				$legal[4] = get_lang('HTMLText');
205
+			elseif ($legal[4] == 1)
206
+				$legal[4] = get_lang('PageLink');
207 207
 			$legals[] = $legal;
208 208
 		}
209 209
 		return $legals;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		        FROM $legal_conditions_table
221 221
 		        ORDER BY legal_id DESC ";
222 222
 		$result = Database::query($sql);
223
-		$url = Database::fetch_array($result,'ASSOC');
223
+		$url = Database::fetch_array($result, 'ASSOC');
224 224
 		$result = $url['count_result'];
225 225
 
226 226
 		return $result;
@@ -241,6 +241,6 @@  discard block
 block discarded – undo
241 241
 		        WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
242 242
 		$rs = Database::query($sql);
243 243
 
244
-		return Database::result($rs,0,'type');
244
+		return Database::result($rs, 0, 'type');
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.
main/inc/lib/blog.lib.php 1 patch
Spacing   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return String Blog Title
23 23
 	 */
24
-	public static function get_blog_title ($blog_id)
24
+	public static function get_blog_title($blog_id)
25 25
 	{
26 26
 	    $course_id = api_get_course_int_id();
27 27
 
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 			$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
31 31
 
32 32
 			$sql = "SELECT blog_name
33
-					FROM " . $tbl_blogs . "
34
-					WHERE c_id = $course_id AND blog_id = " . intval($blog_id);
33
+					FROM " . $tbl_blogs."
34
+					WHERE c_id = $course_id AND blog_id = ".intval($blog_id);
35 35
 
36 36
 			$result = Database::query($sql);
37 37
 			$blog = Database::fetch_array($result);
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// Get blog members
80 80
 		$sql = "SELECT user.user_id, user.firstname, user.lastname
81
-				FROM " . $tbl_blogs_rel_user . " blogs_rel_user
82
-				INNER JOIN " . $tbl_users . " user
81
+				FROM " . $tbl_blogs_rel_user." blogs_rel_user
82
+				INNER JOIN " . $tbl_users." user
83 83
 				ON blogs_rel_user.user_id = user.user_id
84 84
 				WHERE
85 85
 				    blogs_rel_user.c_id = $course_id AND
86
-					blogs_rel_user.blog_id = '" . (int)$blog_id."'";
86
+					blogs_rel_user.blog_id = '".(int) $blog_id."'";
87 87
 		$result = Database::query($sql);
88
-		$blog_members = array ();
89
-		while($user = Database::fetch_array($result)) {
88
+		$blog_members = array();
89
+		while ($user = Database::fetch_array($result)) {
90 90
 			$blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
91 91
 		}
92 92
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$_user = api_get_user_info();
106 106
         $course_id = api_get_course_int_id();
107 107
 
108
-		$current_date=date('Y-m-d H:i:s',time());
108
+		$current_date = date('Y-m-d H:i:s', time());
109 109
 		$session_id = api_get_session_id();
110 110
 		// Tabel definitions
111 111
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                 'blog_name' => $title,
131 131
                 'blog_subtitle' =>  $subtitle,
132 132
                 'date_creation' => $current_date,
133
-                'visibility' => 1 ,
133
+                'visibility' => 1,
134 134
                 'session_id' => $session_id,
135 135
             ];
136 136
 			$this_blog_id = Database::insert($tbl_blogs, $params);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 			// Put it on course homepage
171 171
 			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
172
-					VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
172
+					VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int) $this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
173 173
 			Database::query($sql);
174 174
 
175 175
             $toolId = Database::insert_id();
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		        blog_subtitle = '".Database::escape_string($subtitle)."'
205 205
 		        WHERE
206 206
 		            c_id = $course_id AND
207
-		            blog_id ='".Database::escape_string((int)$blog_id)."'
207
+		            blog_id ='".Database::escape_string((int) $blog_id)."'
208 208
                 LIMIT 1";
209 209
 		Database::query($sql);
210 210
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		// Update course homepage link
221 221
 		$sql = "UPDATE $tbl_tool SET
222 222
 		        name = '".Database::escape_string($title)."'
223
-		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1";
223
+		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int) $blog_id."' LIMIT 1";
224 224
 		Database::query($sql);
225 225
 	}
226 226
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		Database::query($sql);
264 264
 
265 265
 		// Delete blog
266
-		$sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
266
+		$sql = "DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
267 267
 		Database::query($sql);
268 268
 
269 269
 		// Delete from course homepage
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 		$course_id = $_course['real_id'];
295 295
 
296 296
 		$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
297
-		$upload_ok=true;
298
-		$has_attachment=false;
297
+		$upload_ok = true;
298
+		$has_attachment = false;
299 299
 		$current_date = api_get_utc_datetime();
300 300
 
301 301
 		if (!empty($_FILES['user_upload']['name'])) {
302 302
 			$upload_ok = process_uploaded_file($_FILES['user_upload']);
303
-			$has_attachment=true;
303
+			$has_attachment = true;
304 304
 		}
305 305
 
306 306
 		if ($upload_ok) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 			// Create the post
311 311
 			$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
312
-					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
312
+					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int) $blog_id."', '".(int) $_user['user_id']."');";
313 313
 
314 314
 			Database::query($sql);
315 315
 			$last_post_id = Database::insert_id();
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             }
321 321
 
322 322
 			if ($has_attachment) {
323
-				$courseDir   = $_course['path'].'/upload/blog';
323
+				$courseDir = $_course['path'].'/upload/blog';
324 324
 				$sys_course_path = api_get_path(SYS_COURSE_PATH);
325 325
 				$updir = $sys_course_path.$courseDir;
326 326
 
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 
372 372
 		// Create the post
373 373
 		$sql = "UPDATE $tbl_blogs_posts SET
374
-		        title = '" . Database::escape_string($title)."',
374
+		        title = '".Database::escape_string($title)."',
375 375
 		        full_text = '" . Database::escape_string($full_text)."'
376
-		        WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."'
376
+		        WHERE c_id = $course_id AND post_id ='".(int) $post_id."' AND blog_id ='".(int) $blog_id."'
377 377
 		        LIMIT 1 ";
378 378
 		Database::query($sql);
379 379
 	}
@@ -394,21 +394,21 @@  discard block
 block discarded – undo
394 394
 
395 395
 		// Delete ratings on this comment
396 396
 		$sql = "DELETE FROM $tbl_blogs_rating
397
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'";
397
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND item_id = '".(int) $post_id."' AND rating_type = 'post'";
398 398
 		Database::query($sql);
399 399
 
400 400
 		// Delete the post
401 401
 		$sql = "DELETE FROM $tbl_blogs_posts
402
-				WHERE c_id = $course_id AND post_id = '".(int)$post_id."'";
402
+				WHERE c_id = $course_id AND post_id = '".(int) $post_id."'";
403 403
 		Database::query($sql);
404 404
 
405 405
 		// Delete the comments
406 406
 		$sql = "DELETE FROM $tbl_blogs_comments
407
-				WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'";
407
+				WHERE c_id = $course_id AND post_id = '".(int) $post_id."' AND blog_id = '".(int) $blog_id."'";
408 408
 		Database::query($sql);
409 409
 
410 410
 		// Delete posts and attachments
411
-		delete_all_blog_attachment($blog_id,$post_id);
411
+		delete_all_blog_attachment($blog_id, $post_id);
412 412
 	}
413 413
 
414 414
 	/**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	{
425 425
 		$_user = api_get_user_info();
426 426
 		$_course = api_get_course_info();
427
-        $blog_table_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
427
+        $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
428 428
 
429 429
         $upload_ok = true;
430 430
         $has_attachment = false;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 		if (!empty($_FILES['user_upload']['name'])) {
435 435
 			$upload_ok = process_uploaded_file($_FILES['user_upload']);
436
-			$has_attachment=true;
436
+			$has_attachment = true;
437 437
 		}
438 438
 
439 439
 		if ($upload_ok) {
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 
443 443
 			// Create the comment
444 444
 			$sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
445
-					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
445
+					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int) $_user['user_id']."','".$current_date."', '".(int) $blog_id."', '".(int) $post_id."', '".(int) $parent_id."', '".(int) $task_id."')";
446 446
 			Database::query($sql);
447 447
 
448 448
 			// Empty post values, or they are shown on the page again
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             }
455 455
 
456 456
 			if ($has_attachment) {
457
-				$courseDir   = $_course['path'].'/upload/blog';
457
+				$courseDir = $_course['path'].'/upload/blog';
458 458
 				$sys_course_path = api_get_path(SYS_COURSE_PATH);
459 459
 				$updir = $sys_course_path.$courseDir;
460 460
 
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 				);
466 466
 
467 467
 				// user's file name
468
-				$file_name =$_FILES['user_upload']['name'];
468
+				$file_name = $_FILES['user_upload']['name'];
469 469
 
470 470
 				if (!filter_extension($new_file_name)) {
471 471
 					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
472 472
 				} else {
473 473
 					$new_file_name = uniqid('');
474
-					$new_path=$updir.'/'.$new_file_name;
475
-					$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
474
+					$new_path = $updir.'/'.$new_file_name;
475
+					$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
476 476
 					$comment = Database::escape_string($file_comment);
477 477
 
478 478
 					// Storing the attachments if any
479 479
 					if ($result) {
480
-						$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
480
+						$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
481 481
 							 "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."',  '".$blog_id."', '".$last_id."'  )";
482 482
 						Database::query($sql);
483 483
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 		// Delete them recursively
528 528
 		while ($comment = Database::fetch_array($result)) {
529
-			Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
529
+			Blog::delete_comment($blog_id, $post_id, $comment['comment_id']);
530 530
 		}
531 531
 
532 532
 		// Finally, delete the selected comment to
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 
554 554
 		// Create the task
555 555
 		$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
556
-				VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
556
+				VALUES ($course_id , '".(int) $blog_id."', '".Database::escape_string($title)."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');";
557 557
 		Database::query($sql);
558 558
 
559 559
 		$task_id = Database::insert_id();
@@ -563,13 +563,13 @@  discard block
 block discarded – undo
563 563
             Database::query($sql);
564 564
         }
565 565
 
566
-		$tool = 'BLOG_' . $blog_id;
566
+		$tool = 'BLOG_'.$blog_id;
567 567
 
568 568
 		if ($articleDelete == 'on') {
569
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
570
-					'" . (int)$course_id . "',
571
-					'" . (int)$task_id . "',
572
-					'" . Database::escape_string($tool) . "',
569
+			$sql = " INSERT INTO ".$tbl_tasks_permissions." ( c_id,  task_id, tool, action) VALUES (
570
+					'" . (int) $course_id."',
571
+					'" . (int) $task_id."',
572
+					'" . Database::escape_string($tool)."',
573 573
 					'article_delete'
574 574
 				)";
575 575
 			Database::query($sql);
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 
585 585
 		if ($articleEdit == 'on') {
586 586
 			$sql = "
587
-				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
588
-					'" . (int)$course_id . "',
589
-					'" . (int)$task_id . "',
590
-					'" . Database::escape_string($tool) . "',
587
+				INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES (
588
+					'" . (int) $course_id."',
589
+					'" . (int) $task_id."',
590
+					'" . Database::escape_string($tool)."',
591 591
 					'article_edit'
592 592
 				)";
593 593
 			Database::query($sql);
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
 
602 602
 		if ($commentsDelete == 'on') {
603 603
 			$sql = "
604
-				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
605
-					'" . (int)$course_id . "',
606
-					'" . (int)$task_id . "',
607
-					'" . Database::escape_string($tool) . "',
604
+				INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES (
605
+					'" . (int) $course_id."',
606
+					'" . (int) $task_id."',
607
+					'" . Database::escape_string($tool)."',
608 608
 					'article_comments_delete'
609 609
 				)";
610 610
 			Database::query($sql);
@@ -637,20 +637,20 @@  discard block
 block discarded – undo
637 637
 					title = '".Database::escape_string($title)."',
638 638
 					description = '".Database::escape_string($description)."',
639 639
 					color = '".Database::escape_string($color)."'
640
-				WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1";
640
+				WHERE c_id = $course_id AND task_id ='".(int) $task_id."' LIMIT 1";
641 641
 		Database::query($sql);
642 642
 
643
-		$tool = 'BLOG_' . $blog_id;
643
+		$tool = 'BLOG_'.$blog_id;
644 644
 
645
-		$sql = "DELETE FROM " . $tbl_tasks_permissions . "
646
-				WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
645
+		$sql = "DELETE FROM ".$tbl_tasks_permissions."
646
+				WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
647 647
 		Database::query($sql);
648 648
 
649 649
 		if ($articleDelete == 'on') {
650
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
651
-					'" . (int)$course_id . "',
652
-					'" . (int)$task_id . "',
653
-					'" . Database::escape_string($tool) . "',
650
+			$sql = "INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES (
651
+					'" . (int) $course_id."',
652
+					'" . (int) $task_id."',
653
+					'" . Database::escape_string($tool)."',
654 654
 					'article_delete'
655 655
 				)";
656 656
 			Database::query($sql);
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
 		}
664 664
 
665 665
 		if ($articleEdit == 'on') {
666
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
667
-					'" . (int)$course_id . "',
668
-					'" . (int)$task_id . "',
669
-					'" . Database::escape_string($tool) . "',
666
+			$sql = "INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES (
667
+					'" . (int) $course_id."',
668
+					'" . (int) $task_id."',
669
+					'" . Database::escape_string($tool)."',
670 670
 					'article_edit'
671 671
 				)";
672 672
 			Database::query($sql);
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
 		}
680 680
 
681 681
 		if ($commentsDelete == 'on') {
682
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
683
-					'" . (int)$course_id . "',
684
-					'" . (int)$task_id . "',
685
-					'" . Database::escape_string($tool) . "',
682
+			$sql = " INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES (
683
+					'" . (int) $course_id."',
684
+					'" . (int) $task_id."',
685
+					'" . Database::escape_string($tool)."',
686 686
 					'article_comments_delete'
687 687
 				)";
688 688
 			Database::query($sql);
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 
708 708
 		// Delete posts
709 709
 		$sql = "DELETE FROM $tbl_blogs_tasks
710
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'";
710
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND task_id = '".(int) $task_id."'";
711 711
 		Database::query($sql);
712 712
 	}
713 713
 
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 		$sql = "DELETE FROM $tbl_blogs_tasks_rel_user
726 726
 				WHERE
727 727
 				    c_id = $course_id AND
728
-				    blog_id = '".(int)$blog_id."' AND
729
-				    task_id = '".(int)$task_id."' AND
730
-				    user_id = '".(int)$user_id."'";
728
+				    blog_id = '".(int) $blog_id."' AND
729
+				    task_id = '".(int) $task_id."' AND
730
+				    user_id = '".(int) $user_id."'";
731 731
 		Database::query($sql);
732 732
 	}
733 733
 
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		$_user = api_get_user_info();
742 742
 
743 743
 		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
744
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
744
+		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
745 745
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
746 746
 
747 747
 		$course_id = api_get_course_int_id();
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
                         task.c_id = $course_id AND
759 759
                         blog.c_id = $course_id AND
760 760
                         task_rel_user.c_id = $course_id AND
761
-                        task_rel_user.user_id = ".(int)$_user['user_id']."
761
+                        task_rel_user.user_id = ".(int) $_user['user_id']."
762 762
                     ORDER BY target_date ASC";
763 763
 
764 764
 			$result = Database::query($sql);
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			if (Database::num_rows($result) > 0) {
767 767
 				echo '<ul>';
768 768
 				while ($mytask = Database::fetch_array($result)) {
769
-					echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
769
+					echo '<li><a href="blog.php?action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes($mytask['task_id']).'" title="[Blog: '.stripslashes($mytask['blog_name']).'] '.get_lang('ExecuteThisTask').'">'.stripslashes($mytask['title']).'</a></li>';
770 770
 				}
771 771
 				echo '<ul>';
772 772
 			} else {
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 
791 791
 		// Get blog properties
792 792
 		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
793
-				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
793
+				WHERE c_id = $course_id AND blog_id='".(int) $blog_id."'";
794 794
 		$result = Database::query($sql);
795 795
 		$blog = Database::fetch_array($result);
796 796
 		$visibility = $blog['visibility'];
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 		if ($visibility == 1) {
800 800
 			// Change visibility state, remove from course home.
801 801
 			$sql = "UPDATE $tbl_blogs SET visibility = '0'
802
-					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
802
+					WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1";
803 803
 			Database::query($sql);
804 804
 
805 805
 			$sql = "DELETE FROM $tbl_tool
@@ -808,11 +808,11 @@  discard block
 block discarded – undo
808 808
 		} else {
809 809
 			// Change visibility state, add to course home.
810 810
 			$sql = "UPDATE $tbl_blogs SET visibility = '1'
811
-					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
811
+					WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1";
812 812
 			Database::query($sql);
813 813
 
814 814
 			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
815
-					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
815
+					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int) $blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
816 816
 			Database::query($sql);
817 817
             $id = Database::insert_id();
818 818
 
@@ -843,14 +843,14 @@  discard block
 block discarded – undo
843 843
 		        FROM $tbl_blogs_posts post
844 844
                 INNER JOIN $tbl_users user
845 845
                 ON post.author_id = user.user_id
846
-				WHERE 	post.blog_id = '".(int)$blog_id."' AND
846
+				WHERE 	post.blog_id = '".(int) $blog_id."' AND
847 847
 						post.c_id = $course_id AND
848 848
 						$filter
849
-				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
849
+				ORDER BY post_id DESC LIMIT 0,".(int) $max_number_of_posts;
850 850
 		$result = Database::query($sql);
851 851
 
852 852
 		// Display
853
-		if(Database::num_rows($result) > 0) {
853
+		if (Database::num_rows($result) > 0) {
854 854
 		    $limit = 200;
855 855
 			while ($blog_post = Database::fetch_array($result)) {
856 856
 				// Get number of comments
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 						FROM $tbl_blogs_comments
859 859
 						WHERE
860 860
 						    c_id = $course_id AND
861
-						    blog_id = '".(int)$blog_id."' AND
862
-						    post_id = '" . (int)$blog_post['post_id']."'";
861
+						    blog_id = '".(int) $blog_id."' AND
862
+						    post_id = '" . (int) $blog_post['post_id']."'";
863 863
 				$tmp = Database::query($sql);
864 864
 				$blog_post_comments = Database::fetch_array($tmp);
865 865
 
@@ -870,11 +870,11 @@  discard block
 block discarded – undo
870 870
 
871 871
 				// Create an introduction text (but keep FULL sentences)
872 872
 				$words = 0;
873
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
873
+				$blog_post_text_cut = cut($blog_post_text, $limit);
874 874
 				$words = strlen($blog_post_text);
875 875
 
876 876
 				if ($words >= $limit) {
877
-					$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
877
+					$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_'.$blog_post_id.'\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_'.$blog_post_id.'\').style.display=\'none\'">'.get_lang('ReadMore').'</div>';
878 878
 					$introduction_text = $blog_post_text_cut;
879 879
 				} else {
880 880
 				    $introduction_text = $blog_post_text;
@@ -884,27 +884,27 @@  discard block
 block discarded – undo
884 884
 				$introduction_text = stripslashes($introduction_text);
885 885
 
886 886
 				echo '<div class="blogpost">';
887
-				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
888
-				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
889
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
890
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
887
+				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>';
888
+				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.$blog_post_date.'</a></span>';
889
+				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">'.$introduction_text.$readMoreLink.'</div>';
890
+				echo '<div class="blogpost_text" id="blogpost_text_'.$blog_post_id.'" style="display: none">'.$blog_post_text.'</div>';
891 891
 
892
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
892
+				$file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0);
893 893
 
894 894
 				if (!empty($file_name_array)) {
895 895
 					echo '<br /><br />';
896
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
896
+					echo Display::return_icon('attachment.gif', get_lang('Attachment'));
897 897
 					echo '<a href="download.php?file=';
898 898
 					echo $file_name_array['path'];
899 899
 					echo ' "> '.$file_name_array['filename'].' </a><br />';
900 900
 					echo '</span>';
901 901
 				}
902 902
 				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
903
-				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
903
+				echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - <a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].'</a></span>';
904 904
 				echo '</div>';
905 905
 			}
906 906
 		} else {
907
-			if($filter == '1=1') {
907
+			if ($filter == '1=1') {
908 908
 				echo get_lang('NoArticles');
909 909
 			} else {
910 910
 				echo get_lang('NoArticleMatches');
@@ -918,19 +918,19 @@  discard block
 block discarded – undo
918 918
 	 * @param Integer $blog_id
919 919
 	 * @param String $query_string
920 920
 	 */
921
-	public static function display_search_results ($blog_id, $query_string)
921
+	public static function display_search_results($blog_id, $query_string)
922 922
 	{
923 923
 		// Init
924 924
 		$query_string = Database::escape_string($query_string);
925
-		$query_string_parts = explode(' ',$query_string);
925
+		$query_string_parts = explode(' ', $query_string);
926 926
 		$query_string = array();
927 927
 		foreach ($query_string_parts as $query_part) {
928
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
928
+			$query_string[] = " full_text LIKE '%".$query_part."%' OR title LIKE '%".$query_part."%' ";
929 929
 		}
930
-		$query_string = '('.implode('OR',$query_string) . ')';
930
+		$query_string = '('.implode('OR', $query_string).')';
931 931
 
932 932
 		// Display the posts
933
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
933
+		echo '<span class="blogpost_title">'.get_lang('SearchResults').'</span>';
934 934
 		Blog::display_blog_posts($blog_id, $query_string);
935 935
 	}
936 936
 
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 	public static function display_day_results($blog_id, $query_string)
944 944
 	{
945 945
 		$date_output = $query_string;
946
-		$date = explode('-',$query_string);
947
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
946
+		$date = explode('-', $query_string);
947
+		$query_string = ' DAYOFMONTH(date_creation) ='.intval($date[2]).' AND MONTH(date_creation) ='.intval($date[1]).' AND YEAR(date_creation) ='.intval($date[0]);
948 948
 
949 949
 		// Put date in correct output format
950 950
 		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
951 951
 
952 952
 		// Display the posts
953
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
953
+		echo '<span class="blogpost_title">'.get_lang('PostsOf').': '.$date_output.'</span>';
954 954
 		Blog::display_blog_posts($blog_id, $query_string);
955 955
 	}
956 956
 
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 					ON post.author_id = user.user_id
978 978
                 WHERE
979 979
                     post.c_id = $course_id AND
980
-                    post.blog_id = '".(int)$blog_id."' AND
981
-                    post.post_id = '".(int)$post_id."'
980
+                    post.blog_id = '".(int) $blog_id."' AND
981
+                    post.post_id = '".(int) $post_id."'
982 982
                 ORDER BY post_id DESC";
983 983
 		$result = Database::query($sql);
984 984
 		$blog_post = Database::fetch_array($result);
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 		// Get number of comments
987 987
 		$sql = "SELECT COUNT(1) as number_of_comments
988 988
 		        FROM $tbl_blogs_comments
989
-				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
989
+				WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND post_id = '".(int) $post_id."'";
990 990
 		$result = Database::query($sql);
991 991
 		$blog_post_comments = Database::fetch_array($result);
992 992
 
@@ -997,28 +997,28 @@  discard block
 block discarded – undo
997 997
 
998 998
 		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
999 999
 
1000
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1001
-			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '"><img src="../img/edit.gif" /></a>';
1000
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id))
1001
+			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('EditThisPost').'"><img src="../img/edit.gif" /></a>';
1002 1002
 
1003
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1004
-			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
1003
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id))
1004
+			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('DeleteThisArticle').'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
1005 1005
 
1006
-		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1007
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1006
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_rate'))
1007
+			$rating_select = Blog::display_rating_form('post', $blog_id, $post_id);
1008 1008
 
1009
-		$blog_post_text=stripslashes($blog_post_text);
1009
+		$blog_post_text = stripslashes($blog_post_text);
1010 1010
 
1011 1011
 		// Display post
1012 1012
 		echo '<div class="blogpost">';
1013
-		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
1014
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1015
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1013
+		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>';
1014
+		echo '<span class="blogpost_date">'.$blog_post_date.'</span>';
1015
+		echo '<span class="blogpost_text">'.$blog_post_text.'</span><br />';
1016 1016
 
1017 1017
 		$file_name_array = get_blog_attachment($blog_id, $post_id);
1018 1018
 
1019 1019
         if (!empty($file_name_array)) {
1020 1020
 			echo ' <br />';
1021
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1021
+			echo Display::return_icon('attachment.gif', get_lang('Attachment'));
1022 1022
 			echo '<a href="download.php?file=';
1023 1023
 			echo $file_name_array['path'];
1024 1024
 			echo ' "> '.$file_name_array['filename'].' </a>';
@@ -1029,20 +1029,20 @@  discard block
 block discarded – undo
1029 1029
 			echo '<br />';
1030 1030
 		}
1031 1031
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1032
-		echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
1033
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1032
+		echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post', $blog_id, $post_id).$rating_select.'</span>';
1033
+		echo '<span class="blogpost_actions">'.$blog_post_actions.'</span>';
1034 1034
 		echo '</div>';
1035 1035
 
1036 1036
 		// Display comments if there are any
1037
-		if($blog_post_comments['number_of_comments'] > 0) {
1037
+		if ($blog_post_comments['number_of_comments'] > 0) {
1038 1038
 			echo '<div class="comments">';
1039
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1039
+				echo '<span class="blogpost_title">'.get_lang('Comments').'</span><br />';
1040 1040
 				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1041 1041
 			echo '</div>';
1042 1042
 		}
1043 1043
 
1044 1044
 		// Display comment form
1045
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1045
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) {
1046 1046
 			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1047 1047
 		}
1048 1048
 	}
@@ -1070,16 +1070,16 @@  discard block
 block discarded – undo
1070 1070
 		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1071 1071
                 WHERE
1072 1072
                     c_id = $course_id AND
1073
-                    blog_id = '".(int)$blog_id."' AND
1074
-                    item_id = '".(int)$item_id."' AND
1073
+                    blog_id = '".(int) $blog_id."' AND
1074
+                    item_id = '".(int) $item_id."' AND
1075 1075
                     rating_type = '".Database::escape_string($type)."' AND
1076
-                    user_id = '".(int)$_user['user_id']."'";
1076
+                    user_id = '".(int) $_user['user_id']."'";
1077 1077
 		$result = Database::query($sql);
1078 1078
 
1079 1079
         // Add rating
1080 1080
 		if (Database::num_rows($result) == 0) {
1081 1081
 			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1082
-					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1082
+					VALUES ($course_id, '".(int) $blog_id."', '".Database::escape_string($type)."', '".(int) $item_id."', '".(int) $_user['user_id']."', '".Database::escape_string($rating)."')";
1083 1083
 			Database::query($sql);
1084 1084
 
1085 1085
             $id = Database::insert_id();
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
 		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1113 1113
 				WHERE
1114 1114
 				    c_id = $course_id AND
1115
-				    blog_id = '".(int)$blog_id."' AND
1116
-				    item_id = '".(int)$item_id."' AND
1115
+				    blog_id = '".(int) $blog_id."' AND
1116
+				    item_id = '".(int) $item_id."' AND
1117 1117
 				    rating_type = '".Database::escape_string($type)."' ";
1118 1118
 		$result = Database::query($sql);
1119 1119
 		$result = Database::fetch_array($result);
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	 *
1131 1131
 	 *@return String
1132 1132
 	 */
1133
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1133
+	public static function display_rating_form($type, $blog_id, $post_id, $comment_id = NULL)
1134 1134
 	{
1135 1135
 		$_user = api_get_user_info();
1136 1136
 		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
@@ -1140,14 +1140,14 @@  discard block
 block discarded – undo
1140 1140
 			// Check if the user has already rated this post
1141 1141
 			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1142 1142
 					WHERE c_id = $course_id AND
1143
-					blog_id = '".(int)$blog_id."'
1144
-					AND item_id = '".(int)$post_id."'
1143
+					blog_id = '".(int) $blog_id."'
1144
+					AND item_id = '".(int) $post_id."'
1145 1145
 					AND rating_type = '".Database::escape_string($type)."'
1146
-					AND user_id = '".(int)$_user['user_id']."'";
1146
+					AND user_id = '".(int) $_user['user_id']."'";
1147 1147
 			$result = Database::query($sql);
1148 1148
             // Add rating
1149 1149
             if (Database::num_rows($result) == 0) {
1150
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>';
1150
+				return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" style="display: inline" id="frm_rating_'.$type.'_'.$post_id.'" name="frm_rating_'.$type.'_'.$post_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$post_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /></form>';
1151 1151
             } else {
1152 1152
 				return '';
1153 1153
 			}
@@ -1156,14 +1156,14 @@  discard block
 block discarded – undo
1156 1156
         if ($type = 'comment') {
1157 1157
 			// Check if the user has already rated this comment
1158 1158
 			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1159
-					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1160
-					AND item_id = '".(int)$comment_id."'
1159
+					WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."'
1160
+					AND item_id = '".(int) $comment_id."'
1161 1161
 					AND rating_type = '".Database::escape_string($type)."'
1162
-					AND user_id = '".(int)$_user['user_id']."'";
1162
+					AND user_id = '".(int) $_user['user_id']."'";
1163 1163
 			$result = Database::query($sql);
1164 1164
 
1165 1165
             if (Database::num_rows($result) == 0) {
1166
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>';
1166
+				return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" style="display: inline" id="frm_rating_'.$type.'_'.$comment_id.'" name="frm_rating_'.$type.'_'.$comment_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$comment_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /><input type="hidden" name="comment_id" value="'.$comment_id.'" /></form>';
1167 1167
             } else {
1168 1168
 				return '';
1169 1169
 			}
@@ -1198,11 +1198,11 @@  discard block
 block discarded – undo
1198 1198
                 WHERE
1199 1199
                     comments.c_id = $course_id AND
1200 1200
                     parent_comment_id = $current AND
1201
-                    comments.blog_id = '".(int)$blog_id."' AND
1202
-                    comments.post_id = '".(int)$post_id."'";
1201
+                    comments.blog_id = '".(int) $blog_id."' AND
1202
+                    comments.post_id = '".(int) $post_id."'";
1203 1203
 		$result = Database::query($sql);
1204 1204
 
1205
-		while($comment = Database::fetch_array($result)) {
1205
+		while ($comment = Database::fetch_array($result)) {
1206 1206
 			// Select the children recursivly
1207 1207
 			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1208 1208
 			        FROM $tbl_blogs_comments comments
@@ -1211,8 +1211,8 @@  discard block
 block discarded – undo
1211 1211
 					WHERE
1212 1212
 						comments.c_id = $course_id AND
1213 1213
 						comment_id = $current
1214
-						AND blog_id = '".(int)$blog_id."'
1215
-						AND post_id = '".(int)$post_id."'";
1214
+						AND blog_id = '".(int) $blog_id."'
1215
+						AND post_id = '".(int) $post_id."'";
1216 1216
 			$tmp = Database::query($tmp);
1217 1217
 			$tmp = Database::fetch_array($tmp);
1218 1218
 			$parent_cat = $tmp['parent_comment_id'];
@@ -1222,26 +1222,26 @@  discard block
 block discarded – undo
1222 1222
 			$comment_text = make_clickable(stripslashes($comment['comment']));
1223 1223
 			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1224 1224
 			$blog_comment_actions = "";
1225
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_comment&comment_id=' . $comment['comment_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1226
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1225
+			if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang('DeleteThisComment').'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1226
+			if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1227 1227
 
1228 1228
 			if (!is_null($comment['task_id'])) {
1229
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1229
+				$border_color = ' border-left: 3px solid #'.$comment['color'];
1230 1230
 			}
1231 1231
 
1232 1232
 			$comment_text = stripslashes($comment_text);
1233 1233
 
1234 1234
 			// Output...
1235 1235
 			$margin = $current_level * 30;
1236
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1237
-				echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>';
1238
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1239
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1236
+			echo '<div class="blogpost_comment" style="margin-left: '.$margin.'px;'.$border_color.'">';
1237
+				echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']).'\'" title="'.get_lang('ReplyToThisComment').'" >'.stripslashes($comment['title']).'</a></span>';
1238
+				echo '<span class="blogpost_comment_date">'.$blog_comment_date.'</span>';
1239
+				echo '<span class="blogpost_text">'.$comment_text.'</span>';
1240 1240
 
1241
-				$file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1241
+				$file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']);
1242 1242
 				if (!empty($file_name_array)) {
1243 1243
 					echo '<br /><br />';
1244
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1244
+					echo Display::return_icon('attachment.gif', get_lang('Attachment'));
1245 1245
 					echo '<a href="download.php?file=';
1246 1246
 					echo $file_name_array['path'];
1247 1247
 					echo ' "> '.$file_name_array['filename'].' </a>';
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 				}
1252 1252
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1253 1253
 				echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
1254
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1254
+				echo '<span class="blogpost_actions">'.$blog_comment_actions.'</span>';
1255 1255
 			echo '</div>';
1256 1256
 
1257 1257
 			// Go further down the tree.
@@ -1267,11 +1267,11 @@  discard block
 block discarded – undo
1267 1267
 	 */
1268 1268
 	public static function display_form_new_post($blog_id)
1269 1269
 	{
1270
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1270
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
1271 1271
 			$form = new FormValidator(
1272 1272
 				'add_post',
1273 1273
 				'post',
1274
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1274
+				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=".$blog_id."&".api_get_cidreq(),
1275 1275
 				null,
1276 1276
 				array('enctype' => 'multipart/form-data')
1277 1277
 			);
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1316 1316
 				WHERE
1317 1317
 				post.c_id 			= $course_id AND
1318
-				post.blog_id 		= '".(int)$blog_id ."'
1319
-				AND post.post_id	= '".(int)$post_id."'
1318
+				post.blog_id 		= '".(int) $blog_id."'
1319
+				AND post.post_id	= '".(int) $post_id."'
1320 1320
 				ORDER BY post_id DESC";
1321 1321
 		$result = Database::query($sql);
1322 1322
 		$blog_post = Database::fetch_array($result);
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 		$form = new FormValidator(
1326 1326
 			'edit_post',
1327 1327
 			'post',
1328
-			api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1328
+			api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id='.intval($_GET['post_id']).'&blog_id='.intval($blog_id).'&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1329 1329
 		);
1330 1330
 
1331 1331
 		$form->addHeader(get_lang('EditPost'));
@@ -1357,26 +1357,26 @@  discard block
 block discarded – undo
1357 1357
 		global $charset;
1358 1358
         $course_id = api_get_course_int_id();
1359 1359
 
1360
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1360
+		if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) {
1361 1361
 			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1362 1362
 			$counter = 0;
1363 1363
 			global $color2;
1364 1364
 
1365 1365
 			echo '<div class="actions">';
1366
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
1367
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
1366
+			echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />'.get_lang('AddTasks').'</a> ';
1367
+			echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />'.get_lang('AssignTasks').'</a>';
1368 1368
 			?>
1369
-				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1369
+				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'), '', ICON_SIZE_SMALL).get_lang('RightsManager') ?></a>
1370 1370
 			<?php
1371 1371
 			echo '</div>';
1372 1372
 
1373
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1373
+			echo '<span class="blogpost_title">'.get_lang('TaskList').'</span><br />';
1374 1374
 			echo "<table class=\"data_table\">";
1375 1375
 			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1376
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1377
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
1378
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
1379
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1376
+					 "<th width='240'><b>", get_lang('Title'), "</b></th>\n",
1377
+					 "<th><b>", get_lang('Description'), "</b></th>\n",
1378
+					 "<th><b>", get_lang('Color'), "</b></th>\n",
1379
+					 "<th width='50'><b>", get_lang('Modify'), "</b></th>\n",
1380 1380
 				"</tr>\n";
1381 1381
 
1382 1382
 
@@ -1388,31 +1388,31 @@  discard block
 block discarded – undo
1388 1388
                         description,
1389 1389
                         color,
1390 1390
                         system_task
1391
-                    FROM " . $tbl_blogs_tasks . "
1392
-                    WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1391
+                    FROM " . $tbl_blogs_tasks."
1392
+                    WHERE c_id = $course_id AND blog_id = ".(int) $blog_id."
1393 1393
                     ORDER BY system_task, title";
1394 1394
 			$result = Database::query($sql);
1395 1395
 
1396 1396
 
1397
-			while($task = Database::fetch_array($result)) {
1397
+			while ($task = Database::fetch_array($result)) {
1398 1398
 				$counter++;
1399 1399
 				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1400 1400
 				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1401 1401
 				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1402
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1403
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1402
+				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=delete&task_id='.$task['task_id'];
1403
+				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1404 1404
 
1405
-				echo	'<tr class="' . $css_class . '" valign="top">',
1406
-							 '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1407
-							 '<td>' . Security::remove_XSS($task['description']) . '</td>',
1408
-							 '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1405
+				echo	'<tr class="'.$css_class.'" valign="top">',
1406
+							 '<td width="240">'.Security::remove_XSS($task['title']).'</td>',
1407
+							 '<td>'.Security::remove_XSS($task['description']).'</td>',
1408
+							 '<td><span style="background-color: #'.$task['color'].'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1409 1409
 							 '<td width="50">',
1410
-							 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1411
-								'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1410
+							 	'<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">',
1411
+								'<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />',
1412 1412
 								"</a>\n",
1413
-								'<a href="' . $delete_link . '"',
1413
+								'<a href="'.$delete_link.'"',
1414 1414
 								$delete_confirm,
1415
-								'><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1415
+								'><img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />',
1416 1416
 								"</a>\n",
1417 1417
 							 '</td>',
1418 1418
 						'</tr>';
@@ -1427,23 +1427,23 @@  discard block
 block discarded – undo
1427 1427
 	 *
1428 1428
 	 * @param Integer $blog_id
1429 1429
 	 */
1430
-	public static function display_assigned_task_list ($blog_id)
1430
+	public static function display_assigned_task_list($blog_id)
1431 1431
     {
1432 1432
 		// Init
1433 1433
 		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1434 1434
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1435 1435
 		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1436 1436
 		$counter = 0;
1437
-		global $charset,$color2;
1437
+		global $charset, $color2;
1438 1438
 
1439
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1439
+		echo '<span class="blogpost_title">'.get_lang('AssignedTasks').'</span><br />';
1440 1440
 		echo "<table class=\"data_table\">";
1441 1441
 		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1442
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1443
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
1444
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
1445
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1446
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1442
+				 "<th width='240'><b>", get_lang('Member'), "</b></th>\n",
1443
+				 "<th><b>", get_lang('Task'), "</b></th>\n",
1444
+				 "<th><b>", get_lang('Description'), "</b></th>\n",
1445
+				 "<th><b>", get_lang('TargetDate'), "</b></th>\n",
1446
+				 "<th width='50'><b>", get_lang('Modify'), "</b></th>\n",
1447 1447
 			"</tr>";
1448 1448
 
1449 1449
 		$course_id = api_get_course_int_id();
@@ -1455,32 +1455,32 @@  discard block
 block discarded – undo
1455 1455
 				WHERE
1456 1456
 				    task_rel_user.c_id = $course_id AND
1457 1457
 					task.c_id = $course_id AND
1458
-					task_rel_user.blog_id = '".(int)$blog_id."'
1458
+					task_rel_user.blog_id = '".(int) $blog_id."'
1459 1459
 				ORDER BY target_date ASC";
1460 1460
 		$result = Database::query($sql);
1461 1461
 
1462 1462
 		while ($assignment = Database::fetch_array($result)) {
1463 1463
 			$counter++;
1464
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1464
+			$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1465 1465
 			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1466 1466
 			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1467
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1468
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1467
+			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete&task_id='.$assignment['task_id'];
1468
+			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"';
1469 1469
 
1470 1470
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1471 1471
 
1472
-			echo	'<tr class="' . $css_class . '" valign="top">',
1473
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1474
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
1475
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
1476
-						 '<td>' . $assignment['target_date'] . '</td>',
1472
+			echo	'<tr class="'.$css_class.'" valign="top">',
1473
+						 '<td width="240">'.Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)).'</td>',
1474
+						 '<td>'.stripslashes($assignment['title']).'</td>',
1475
+						 '<td>'.stripslashes($assignment['description']).'</td>',
1476
+						 '<td>'.$assignment['target_date'].'</td>',
1477 1477
 						 '<td width="50">',
1478
-						 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
1479
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1478
+						 	'<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">',
1479
+							'<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />',
1480 1480
 							"</a>\n",
1481
-							'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
1482
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1483
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1481
+							'<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" ',
1482
+							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"',
1483
+							'<img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />',
1484 1484
 							"</a>\n",
1485 1485
 						 '</td>',
1486 1486
 					'</tr>';
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
 	 * @author Toon Keppens
1494 1494
 	 *
1495 1495
 	 */
1496
-	public static function display_new_task_form ($blog_id)
1496
+	public static function display_new_task_form($blog_id)
1497 1497
 	{
1498 1498
 		// Init
1499 1499
         $colors = array(
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
         );
1516 1516
 
1517 1517
 		// form
1518
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1518
+		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'">';
1519 1519
 
1520 1520
 		// form title
1521 1521
 		echo '<legend>'.get_lang('AddTask').'</legend>';
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 		// task title
1524 1524
 		echo '	<div class="control-group">
1525 1525
 					<label class="control-label">
1526
-						<span class="form_required">*</span>' . get_lang('Title') . '
1526
+						<span class="form_required">*</span>' . get_lang('Title').'
1527 1527
 					</label>
1528 1528
 					<div class="controls">
1529 1529
 						<input name="task_name" type="text" size="70" />
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 		// task comment
1534 1534
 		echo '	<div class="control-group">
1535 1535
 					<label class="control-label">
1536
-						' . get_lang('Description') . '
1536
+						' . get_lang('Description').'
1537 1537
 					</label>
1538 1538
 					<div class="controls">
1539 1539
 						<textarea name="task_description" cols="45"></textarea>
@@ -1543,18 +1543,18 @@  discard block
 block discarded – undo
1543 1543
 		// task management
1544 1544
 		echo '	<div class="control-group">
1545 1545
 					<label class="control-label">
1546
-						' . get_lang('TaskManager') . '
1546
+						' . get_lang('TaskManager').'
1547 1547
 					</label>
1548 1548
 					<div class="controls">';
1549 1549
                 echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1550 1550
                     echo '<tr>';
1551
-                        echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1552
-                        echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1551
+                        echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>';
1552
+                        echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1553 1553
                     echo '</tr>';
1554 1554
                     echo '<tr>';
1555
-                        echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1556
-                        echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1557
-                        echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1555
+                        echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>';
1556
+                        echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>';
1557
+                        echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>';
1558 1558
                     echo '</tr>';
1559 1559
                     echo '<tr>';
1560 1560
                         echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
@@ -1569,13 +1569,13 @@  discard block
 block discarded – undo
1569 1569
 		// task color
1570 1570
 		echo '	<div class="control-group">
1571 1571
 					<label class="control-label">
1572
-						' . get_lang('Color') . '
1572
+						' . get_lang('Color').'
1573 1573
 					</label>
1574 1574
 					<div class="controls">';
1575 1575
         echo '<select name="task_color" id="color" style="width: 150px; background-color: #eeeeee" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
1576 1576
                 foreach ($colors as $color) {
1577
-                    $style = 'style="background-color: #' . $color . '"';
1578
-                    echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1577
+                    $style = 'style="background-color: #'.$color.'"';
1578
+                    echo '<option value="'.$color.'" '.$style.'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1579 1579
                 }
1580 1580
         echo '</select>';
1581 1581
 		echo '		</div>
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
 					<div class="controls">
1587 1587
 							<input type="hidden" name="action" value="" />
1588 1588
 							<input type="hidden" name="new_task_submit" value="true" />
1589
-						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1589
+						<button class="save" type="submit" name="Submit">' . get_lang('Save').'</button>
1590 1590
 					</div>
1591 1591
 				</div>';
1592 1592
 		echo '</form>';
@@ -1600,34 +1600,34 @@  discard block
 block discarded – undo
1600 1600
 	 * @author Toon Keppens
1601 1601
 	 *
1602 1602
 	 */
1603
-	public static function display_edit_task_form ($blog_id, $task_id) {
1603
+	public static function display_edit_task_form($blog_id, $task_id) {
1604 1604
 		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1605 1605
         $course_id = api_get_course_int_id();
1606 1606
 
1607
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1607
+		$colors = array('FFFFFF', 'FFFF99', 'FFCC99', 'FF9933', 'FF6699', 'CCFF99', 'CC9966', '66FF00', '9966FF', 'CF3F3F', '990033', '669933', '0033FF', '003366', '000000');
1608 1608
 
1609
-		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1609
+		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
1610 1610
 		$result = Database::query($sql);
1611 1611
 		$task = Database::fetch_array($result);
1612 1612
 
1613 1613
 		// Display
1614
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1615
-					<legend>' . get_lang('EditTask') . '</legend>
1614
+		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'">
1615
+					<legend>' . get_lang('EditTask').'</legend>
1616 1616
 					<table width="100%" border="0" cellspacing="2">
1617 1617
 						<tr>
1618
-					   <td align="right">' . get_lang('Title') . ':&nbsp;&nbsp;</td>
1619
-					   <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']) . '" /></td>
1618
+					   <td align="right">' . get_lang('Title').':&nbsp;&nbsp;</td>
1619
+					   <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']).'" /></td>
1620 1620
 						</tr>
1621 1621
 						<tr>
1622
-					   <td align="right">' . get_lang('Description') . ':&nbsp;&nbsp;</td>
1622
+					   <td align="right">' . get_lang('Description').':&nbsp;&nbsp;</td>
1623 1623
 					   <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td>
1624 1624
 						</tr>';
1625 1625
 
1626 1626
 						/* edit by Kevin Van Den Haute ([email protected]) */
1627 1627
 						$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1628 1628
 
1629
-						$sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1630
-							     WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
1629
+						$sql = " SELECT id, action FROM ".$tbl_tasks_permissions."
1630
+							     WHERE c_id = $course_id AND task_id = '".(int) $task_id."'";
1631 1631
 						$result = Database::query($sql);
1632 1632
 
1633 1633
 						$arrPermissions = array();
@@ -1636,22 +1636,22 @@  discard block
 block discarded – undo
1636 1636
 							$arrPermissions[] = $row['action'];
1637 1637
 
1638 1638
 						    echo '<tr>';
1639
-							echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1639
+							echo '<td style="text-align:right; vertical-align:top;">'.get_lang('TaskManager').':&nbsp;&nbsp;</td>';
1640 1640
 							echo '<td>';
1641 1641
 								echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1642 1642
 									echo '<tr>';
1643
-										echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1644
-										echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1643
+										echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>';
1644
+										echo '<th width:223px;>'.get_lang('CommentManager').'</th>';
1645 1645
 									echo '</tr>';
1646 1646
 									echo '<tr>';
1647
-										echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1648
-										echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1649
-										echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1647
+										echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>';
1648
+										echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>';
1649
+										echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>';
1650 1650
 									echo '</tr>';
1651 1651
 									echo '<tr>';
1652
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1653
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1654
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1652
+										echo '<td style="text-align:center;"><input '.((in_array('article_delete', $arrPermissions)) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1653
+										echo '<td style="text-align:center;"><input '.((in_array('article_edit', $arrPermissions)) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1654
+										echo '<td style="text-align:center;"><input '.((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1655 1655
 									echo '</tr>';
1656 1656
 								echo '</table>';
1657 1657
 							echo '</td>';
@@ -1659,13 +1659,13 @@  discard block
 block discarded – undo
1659 1659
 						/* end of edit */
1660 1660
 
1661 1661
 						echo '<tr>
1662
-					   <td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td>
1662
+					   <td align="right">' . get_lang('Color').':&nbsp;&nbsp;</td>
1663 1663
 					   <td>
1664
-					   	<select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
1664
+					   	<select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'].'" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
1665 1665
                             foreach ($colors as $color) {
1666 1666
                                 $selected = ($color == $task['color']) ? ' selected' : '';
1667
-                                $style = 'style="background-color: #' . $color . '"';
1668
-                                echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1667
+                                $style = 'style="background-color: #'.$color.'"';
1668
+                                echo '<option value="'.$color.'" '.$style.' '.$selected.' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1669 1669
                             }
1670 1670
 		echo '			   </select>
1671 1671
 						  </td>
@@ -1674,9 +1674,9 @@  discard block
 block discarded – undo
1674 1674
 							<td align="right">&nbsp;</td>
1675 1675
 							<td><br /><input type="hidden" name="action" value="" />
1676 1676
 							<input type="hidden" name="edit_task_submit" value="true" />
1677
-							<input type="hidden" name="task_id" value="' . $task['task_id'] . '" />
1678
-							<input type="hidden" name="blog_id" value="' . $task['blog_id'] . '" />
1679
-							<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button></td>
1677
+							<input type="hidden" name="task_id" value="' . $task['task_id'].'" />
1678
+							<input type="hidden" name="blog_id" value="' . $task['blog_id'].'" />
1679
+							<button class="save" type="submit" name="Submit">' . get_lang('Save').'</button></td>
1680 1680
 						</tr>
1681 1681
 					</table>
1682 1682
 				</form>';
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 				FROM $tbl_users user
1699 1699
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1700 1700
 				ON user.user_id = blogs_rel_user.user_id
1701
-				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1701
+				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'";
1702 1702
 		$result = Database::query($sql);
1703 1703
 
1704 1704
 		$options = array();
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 				color,
1718 1718
 				system_task
1719 1719
 			FROM $tbl_blogs_tasks
1720
-			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1720
+			WHERE c_id = $course_id AND blog_id = ".(int) $blog_id."
1721 1721
 			ORDER BY system_task, title";
1722 1722
 		$result = Database::query($sql);
1723 1723
 
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 	 */
1766 1766
 	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1767 1767
 	{
1768
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1768
+		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1769 1769
 
1770 1770
 		$course_id = api_get_course_int_id();
1771 1771
 
@@ -1774,9 +1774,9 @@  discard block
 block discarded – undo
1774 1774
 			SELECT target_date
1775 1775
 			FROM $tbl_blogs_tasks_rel_user
1776 1776
 			WHERE c_id = $course_id AND
1777
-			      blog_id = '".(int)$blog_id."' AND
1778
-			      user_id = '".(int)$user_id."' AND
1779
-			      task_id = '".(int)$task_id."'";
1777
+			      blog_id = '".(int) $blog_id."' AND
1778
+			      user_id = '".(int) $user_id."' AND
1779
+			      task_id = '".(int) $task_id."'";
1780 1780
 		$result = Database::query($sql);
1781 1781
 		$row = Database::fetch_assoc($result);
1782 1782
 
@@ -1811,11 +1811,11 @@  discard block
 block discarded – undo
1811 1811
 
1812 1812
 		$sql = "
1813 1813
 			SELECT COUNT(*) as 'number'
1814
-			FROM " . $tbl_blogs_tasks_rel_user . "
1814
+			FROM " . $tbl_blogs_tasks_rel_user."
1815 1815
 			WHERE c_id = $course_id AND
1816
-			blog_id = " . (int)$blog_id . "
1817
-			AND	user_id = " . (int)$user_id . "
1818
-			AND	task_id = " . (int)$task_id . "
1816
+			blog_id = ".(int) $blog_id."
1817
+			AND	user_id = " . (int) $user_id."
1818
+			AND	task_id = " . (int) $task_id."
1819 1819
 		";
1820 1820
 
1821 1821
 		$result = Database::query($sql);
@@ -1823,18 +1823,18 @@  discard block
 block discarded – undo
1823 1823
 
1824 1824
 		if ($row['number'] == 0) {
1825 1825
 			$sql = "
1826
-				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1826
+				INSERT INTO " . $tbl_blogs_tasks_rel_user." (
1827 1827
 					c_id,
1828 1828
 					blog_id,
1829 1829
 					user_id,
1830 1830
 					task_id,
1831 1831
 					target_date
1832 1832
 				) VALUES (
1833
-					'" . (int)$course_id . "',
1834
-					'" . (int)$blog_id . "',
1835
-					'" . (int)$user_id . "',
1836
-					'" . (int)$task_id . "',
1837
-					'" . Database::escape_string($target_date) . "'
1833
+					'" . (int) $course_id."',
1834
+					'" . (int) $blog_id."',
1835
+					'" . (int) $user_id."',
1836
+					'" . (int) $task_id."',
1837
+					'" . Database::escape_string($target_date)."'
1838 1838
 				)";
1839 1839
 
1840 1840
 			Database::query($sql);
@@ -1864,12 +1864,12 @@  discard block
 block discarded – undo
1864 1864
 		$course_id = api_get_course_int_id();
1865 1865
 
1866 1866
 		$sql = "SELECT COUNT(*) as 'number'
1867
-                FROM " . $tbl_blogs_tasks_rel_user . "
1867
+                FROM " . $tbl_blogs_tasks_rel_user."
1868 1868
                 WHERE
1869 1869
                     c_id = $course_id AND
1870
-                    blog_id = " . (int)$blog_id . " AND
1871
-                    user_id = " . (int)$user_id . " AND
1872
-                    task_id = " . (int)$task_id . "
1870
+                    blog_id = ".(int) $blog_id." AND
1871
+                    user_id = " . (int) $user_id." AND
1872
+                    task_id = " . (int) $task_id."
1873 1873
             ";
1874 1874
 
1875 1875
 		$result = Database::query($sql);
@@ -1877,17 +1877,17 @@  discard block
 block discarded – undo
1877 1877
 
1878 1878
 		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1879 1879
 			$sql = "
1880
-				UPDATE " . $tbl_blogs_tasks_rel_user . "
1880
+				UPDATE " . $tbl_blogs_tasks_rel_user."
1881 1881
 				SET
1882
-					user_id = " . (int)$user_id . ",
1883
-					task_id = " . (int)$task_id . ",
1884
-					target_date = '" . Database::escape_string($target_date) . "'
1882
+					user_id = " . (int) $user_id.",
1883
+					task_id = " . (int) $task_id.",
1884
+					target_date = '" . Database::escape_string($target_date)."'
1885 1885
 				WHERE
1886 1886
 					c_id = $course_id AND
1887
-					blog_id = " . (int)$blog_id . " AND
1888
-					user_id = " . (int)$old_user_id . " AND
1889
-					task_id = " . (int)$old_task_id . " AND
1890
-					target_date = '" . Database::escape_string($old_target_date) . "'
1887
+					blog_id = ".(int) $blog_id." AND
1888
+					user_id = " . (int) $old_user_id." AND
1889
+					task_id = " . (int) $old_task_id." AND
1890
+					target_date = '" . Database::escape_string($old_target_date)."'
1891 1891
 			";
1892 1892
 			Database::query($sql);
1893 1893
 		}
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
 
1909 1909
 
1910 1910
 		$sql = "SELECT title, description FROM $tbl_blogs_tasks
1911
-				WHERE task_id = '".(int)$task_id."'
1911
+				WHERE task_id = '".(int) $task_id."'
1912 1912
 				AND c_id = $course_id";
1913 1913
 		$result = Database::query($sql);
1914 1914
 		$row = Database::fetch_assoc($result);
@@ -1916,19 +1916,19 @@  discard block
 block discarded – undo
1916 1916
 		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
1917 1917
 				FROM $tbl_blogs_posts post
1918 1918
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1919
-				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
1919
+				WHERE post.blog_id = '".(int) $blog_id."' AND post.c_id = $course_id
1920 1920
 				ORDER BY post_id DESC
1921 1921
 				LIMIT 0, 100";
1922 1922
 		$result = Database::query($sql);
1923 1923
 
1924 1924
 		// Display
1925
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1926
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1925
+		echo '<span class="blogpost_title">'.get_lang('SelectTaskArticle').' "'.stripslashes($row['title']).'"</span>';
1926
+		echo '<span style="font-style: italic;"">'.stripslashes($row['description']).'</span><br><br>';
1927 1927
 
1928 1928
 		if (Database::num_rows($result) > 0) {
1929
-			while($blog_post = Database::fetch_array($result)) {
1929
+			while ($blog_post = Database::fetch_array($result)) {
1930 1930
 			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1931
-				echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
1931
+				echo '<a href="blog.php?action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.stripslashes($blog_post['title']).'</a>, '.get_lang('WrittenBy').' '.stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))).'<br />';
1932 1932
 			}
1933 1933
         } else {
1934 1934
             echo get_lang('NoArticles');
@@ -1952,12 +1952,12 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 		// Subscribe the user
1954 1954
 		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1955
-		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
1955
+		        VALUES ($course_id, '".(int) $blog_id."', '".(int) $user_id."');";
1956 1956
 		Database::query($sql);
1957 1957
 
1958 1958
 		// Give this user basic rights
1959 1959
 		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1960
-		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
1960
+		        VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_add')";
1961 1961
 		Database::query($sql);
1962 1962
 
1963 1963
         $id = Database::insert_id();
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
         }
1968 1968
 
1969 1969
 		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1970
-		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
1970
+		        VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_comments_add')";
1971 1971
 		Database::query($sql);
1972 1972
 
1973 1973
         $id = Database::insert_id();
@@ -1993,12 +1993,12 @@  discard block
 block discarded – undo
1993 1993
 
1994 1994
 		// Unsubscribe the user
1995 1995
 		$sql = "DELETE FROM $tbl_blogs_rel_user
1996
-		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
1996
+		        WHERE blog_id = '".(int) $blog_id."' AND user_id = '".(int) $user_id."'";
1997 1997
 		Database::query($sql);
1998 1998
 
1999 1999
 		// Remove this user's permissions.
2000 2000
 		$sql = "DELETE FROM $tbl_user_permissions
2001
-		        WHERE user_id = '".(int)$user_id."'";
2001
+		        WHERE user_id = '".(int) $user_id."'";
2002 2002
 		Database::query($sql);
2003 2003
 	}
2004 2004
 
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
 		$course_id = $_course['real_id'];
2020 2020
 
2021 2021
 		$currentCourse = $_course['code'];
2022
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2022
+		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2023 2023
 		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2024 2024
 
2025 2025
 		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
@@ -2034,12 +2034,12 @@  discard block
 block discarded – undo
2034 2034
 		$result = Database::query($sql);
2035 2035
 
2036 2036
 		$blog_member_ids = array();
2037
-		while($user = Database::fetch_array($result)) {
2037
+		while ($user = Database::fetch_array($result)) {
2038 2038
 			$blog_member_ids[] = $user['user_id'];
2039 2039
 		}
2040 2040
 
2041 2041
 		// Set table headers
2042
-		$column_header[] = array ('', false, '');
2042
+		$column_header[] = array('', false, '');
2043 2043
 		if ($is_western_name_order) {
2044 2044
 			$column_header[] = array(get_lang('FirstName'), true, '');
2045 2045
 			$column_header[] = array(get_lang('LastName'), true, '');
@@ -2059,13 +2059,13 @@  discard block
 block discarded – undo
2059 2059
 
2060 2060
 		// Add users that are not in this blog to the list.
2061 2061
 		foreach ($student_list as $key=>$user) {
2062
-			if(isset($user['id_user'])) {
2062
+			if (isset($user['id_user'])) {
2063 2063
 				$user['user_id'] = $user['id_user'];
2064 2064
 			}
2065
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2065
+			if (!in_array($user['user_id'], $blog_member_ids)) {
2066 2066
 				$a_infosUser = api_get_user_info($user['user_id']);
2067
-				$row = array ();
2068
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2067
+				$row = array();
2068
+				$row[] = '<input type="checkbox" name="user[]" value="'.$a_infosUser['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '').'/>';
2069 2069
 				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2070 2070
 				if ($is_western_name_order) {
2071 2071
 					$row[] = $a_infosUser["firstname"];
@@ -2077,8 +2077,8 @@  discard block
 block discarded – undo
2077 2077
 				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
2078 2078
 
2079 2079
 				//Link to register users
2080
-				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2081
-					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2080
+				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']) {
2081
+					$row[] = "<a class=\"btn btn-primary \" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=".$a_infosUser["user_id"]."\">".get_lang('Register')."</a>";
2082 2082
 				} else {
2083 2083
 					$row[] = '';
2084 2084
 				}
@@ -2089,20 +2089,20 @@  discard block
 block discarded – undo
2089 2089
 		// Display
2090 2090
 		$query_vars['action'] = 'manage_members';
2091 2091
 		$query_vars['blog_id'] = $blog_id;
2092
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2093
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2092
+		echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
2093
+			Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
2094 2094
 			$link = '';
2095
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2095
+			$link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
2096 2096
 			$link .= "blog_id=$blog_id&";
2097 2097
 
2098
-			echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2099
-			echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2100
-			echo get_lang('WithSelected') . ' : ';
2098
+			echo '<a href="blog.php?'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - ';
2099
+			echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> ';
2100
+			echo get_lang('WithSelected').' : ';
2101 2101
 			echo '<select name="action">';
2102
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2102
+			echo '<option value="select_subscribe">'.get_lang('Register').'</option>';
2103 2103
 			echo '</select>';
2104 2104
 			echo '<input type="hidden" name="register" value="true" />';
2105
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2105
+			echo '<button class="save" type="submit">'.get_lang('Ok').'</button>';
2106 2106
 		echo '</form>';
2107 2107
 	}
2108 2108
 
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 	 *
2116 2116
 	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2117 2117
 	 */
2118
-	public static function display_form_user_unsubscribe ($blog_id)
2118
+	public static function display_form_user_unsubscribe($blog_id)
2119 2119
 	{
2120 2120
 		$_user = api_get_user_info();
2121 2121
 		$is_western_name_order = api_is_western_name_order();
@@ -2128,34 +2128,34 @@  discard block
 block discarded – undo
2128 2128
 
2129 2129
 		$properties["width"] = "100%";
2130 2130
 		//table column titles
2131
-		$column_header[] = array ('', false, '');
2131
+		$column_header[] = array('', false, '');
2132 2132
 		if ($is_western_name_order) {
2133
-			$column_header[] = array (get_lang('FirstName'), true, '');
2134
-			$column_header[] = array (get_lang('LastName'), true, '');
2133
+			$column_header[] = array(get_lang('FirstName'), true, '');
2134
+			$column_header[] = array(get_lang('LastName'), true, '');
2135 2135
 		} else {
2136
-			$column_header[] = array (get_lang('LastName'), true, '');
2137
-			$column_header[] = array (get_lang('FirstName'), true, '');
2136
+			$column_header[] = array(get_lang('LastName'), true, '');
2137
+			$column_header[] = array(get_lang('FirstName'), true, '');
2138 2138
 		}
2139
-		$column_header[] = array (get_lang('Email'), false, '');
2140
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2141
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2139
+		$column_header[] = array(get_lang('Email'), false, '');
2140
+		$column_header[] = array(get_lang('TaskManager'), true, '');
2141
+		$column_header[] = array(get_lang('UnRegister'), false, '');
2142 2142
 
2143 2143
 		$course_id = api_get_course_int_id();
2144 2144
 
2145 2145
 		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2146 2146
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2147 2147
                 ON user.user_id = blogs_rel_user.user_id
2148
-                WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2148
+                WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int) $blog_id."'";
2149 2149
 
2150 2150
 		if (!($sql_result = Database::query($sql))) {
2151 2151
 			return false;
2152 2152
 		}
2153 2153
 
2154
-		$user_data = array ();
2154
+		$user_data = array();
2155 2155
 
2156 2156
 		while ($myrow = Database::fetch_array($sql_result)) {
2157
-			$row = array ();
2158
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2157
+			$row = array();
2158
+			$row[] = '<input type="checkbox" name="user[]" value="'.$myrow['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '').'/>';
2159 2159
 			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2160 2160
 			if ($is_western_name_order) {
2161 2161
 				$row[] = $myrow["firstname"];
@@ -2167,19 +2167,19 @@  discard block
 block discarded – undo
2167 2167
 			$row[] = Display::icon_mailto_link($myrow["email"]);
2168 2168
 
2169 2169
 			$sql = "SELECT bt.title task
2170
-					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2171
-					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2170
+					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." btu
2171
+					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS)." bt
2172 2172
 					ON btu.task_id = bt.task_id
2173 2173
 					WHERE 	btu.c_id 	= $course_id  AND
2174 2174
 							bt.c_id 	= $course_id  AND
2175 2175
 							btu.blog_id = $blog_id AND
2176
-							btu.user_id = " . $myrow['user_id'];
2176
+							btu.user_id = ".$myrow['user_id'];
2177 2177
 			$sql_res = Database::query($sql);
2178 2178
 
2179 2179
 			$task = '';
2180 2180
 
2181
-			while($r = Database::fetch_array($sql_res)) {
2182
-				$task .= stripslashes($r['task']) . ', ';
2181
+			while ($r = Database::fetch_array($sql_res)) {
2182
+				$task .= stripslashes($r['task']).', ';
2183 2183
 			}
2184 2184
 			//echo $task;
2185 2185
 			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
 			//Link to register users
2188 2188
 
2189 2189
 			if ($myrow["user_id"] != $_user['user_id']) {
2190
-				$row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
2190
+				$row[] = "<a class=\"btn btn-primary\" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=".$myrow['user_id']."\">".get_lang('UnRegister')."</a>";
2191 2191
 			} else {
2192 2192
 				$row[] = '';
2193 2193
 			}
@@ -2197,20 +2197,20 @@  discard block
 block discarded – undo
2197 2197
 
2198 2198
 		$query_vars['action'] = 'manage_members';
2199 2199
 		$query_vars['blog_id'] = $blog_id;
2200
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2201
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2200
+		echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">';
2201
+		Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
2202 2202
 		$link = '';
2203
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2203
+		$link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : '';
2204 2204
 		$link .= "blog_id=$blog_id&";
2205 2205
 
2206
-		echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2207
-		echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2208
-		echo get_lang('WithSelected') . ' : ';
2206
+		echo '<a href="blog.php?'.$link.'selectall=unsubscribe">'.get_lang('SelectAll').'</a> - ';
2207
+		echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> ';
2208
+		echo get_lang('WithSelected').' : ';
2209 2209
 		echo '<select name="action">';
2210
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2210
+		echo '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>';
2211 2211
 		echo '</select>';
2212 2212
 		echo '<input type="hidden" name="unregister" value="true" />';
2213
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2213
+		echo '<button class="save" type="submit">'.get_lang('Ok').'</button>';
2214 2214
 		echo '</form>';
2215 2215
 	}
2216 2216
 
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 	 *
2221 2221
 	 * @param Integer $blog_id
2222 2222
 	 */
2223
-	public static function display_form_user_rights ($blog_id)
2223
+	public static function display_form_user_rights($blog_id)
2224 2224
     {
2225 2225
 		echo '<legend>'.get_lang('RightsManager').'</legend>';
2226 2226
 		echo '<br />';
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 		$form = new FormValidator(
2241 2241
 			'add_post',
2242 2242
 			'post',
2243
-			api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id)  . "&post_id=".intval($post_id)."&".api_get_cidreq(),
2243
+			api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=".intval($blog_id)."&post_id=".intval($post_id)."&".api_get_cidreq(),
2244 2244
 			null,
2245 2245
 			array('enctype' => 'multipart/form-data')
2246 2246
 		);
@@ -2308,21 +2308,21 @@  discard block
 block discarded – undo
2308 2308
 		$course_id = api_get_course_int_id();
2309 2309
 
2310 2310
 		//Handle leap year
2311
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2311
+		$numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2312 2312
 
2313
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2313
+		if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2314 2314
 			$numberofdays[2] = 29;
2315 2315
 
2316 2316
 		//Get the first day of the month
2317 2317
 		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2318
-		$monthName = $MonthsLong[$month-1];
2318
+		$monthName = $MonthsLong[$month - 1];
2319 2319
 
2320 2320
 		//Start the week on monday
2321 2321
 		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2322 2322
 		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2323 2323
 		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2324
-		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2325
-		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2324
+		$backwardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year);
2325
+		$forewardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year);
2326 2326
 
2327 2327
 		// Get posts for this month
2328 2328
 		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
@@ -2331,15 +2331,15 @@  discard block
 block discarded – undo
2331 2331
 				ON post.author_id = user.user_id
2332 2332
 				WHERE
2333 2333
 					post.c_id = $course_id AND
2334
-					post.blog_id = '".(int)$blog_id."' AND
2335
-					MONTH(date_creation) = '".(int)$month."' AND
2336
-					YEAR(date_creation) = '".(int)$year."'
2334
+					post.blog_id = '".(int) $blog_id."' AND
2335
+					MONTH(date_creation) = '".(int) $month."' AND
2336
+					YEAR(date_creation) = '".(int) $year."'
2337 2337
 				ORDER BY date_creation";
2338 2338
 		$result = Database::query($sql);
2339 2339
 
2340 2340
 		// We will create an array of days on which there are posts.
2341
-		if( Database::num_rows($result) > 0) {
2342
-			while($blog_post = Database::fetch_array($result)) {
2341
+		if (Database::num_rows($result) > 0) {
2342
+			while ($blog_post = Database::fetch_array($result)) {
2343 2343
 				// If the day of this post is not yet in the array, add it.
2344 2344
 				if (!in_array($blog_post['post_day'], $posts))
2345 2345
 					$posts[] = $blog_post['post_day'];
@@ -2356,9 +2356,9 @@  discard block
 block discarded – undo
2356 2356
 					task_rel_user.c_id = $course_id AND
2357 2357
 					task.c_id = $course_id AND
2358 2358
 					blog.c_id = $course_id AND
2359
-					task_rel_user.user_id = '".(int)$_user['user_id']."' AND
2360
-					MONTH(target_date) = '".(int)$month."' AND
2361
-					YEAR(target_date) = '".(int)$year."'
2359
+					task_rel_user.user_id = '".(int) $_user['user_id']."' AND
2360
+					MONTH(target_date) = '".(int) $month."' AND
2361
+					YEAR(target_date) = '".(int) $year."'
2362 2362
 				ORDER BY target_date ASC";
2363 2363
 			$result = Database::query($sql);
2364 2364
 
@@ -2381,7 +2381,7 @@  discard block
 block discarded – undo
2381 2381
 
2382 2382
 		echo "<tr>\n";
2383 2383
 
2384
-		for($ii = 1; $ii < 8; $ii ++)
2384
+		for ($ii = 1; $ii < 8; $ii++)
2385 2385
 			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2386 2386
 
2387 2387
 		echo "</tr>";
@@ -2391,24 +2391,24 @@  discard block
 block discarded – undo
2391 2391
 
2392 2392
 		while ($curday <= $numberofdays[$month]) {
2393 2393
 			echo "<tr>";
2394
-			for ($ii = 0; $ii < 7; $ii ++) {
2394
+			for ($ii = 0; $ii < 7; $ii++) {
2395 2395
 				if (($curday == -1) && ($ii == $startdayofweek))
2396 2396
 					$curday = 1;
2397 2397
 
2398 2398
 			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2399
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2399
+					$bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
2400 2400
 					$dayheader = "$curday";
2401 2401
 
2402
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2402
+					if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2403 2403
 						$dayheader = "$curday";
2404 2404
 						$class = "class=\"days_today\"";
2405 2405
 					}
2406 2406
 
2407
-					echo "<td " . $class.">";
2407
+					echo "<td ".$class.">";
2408 2408
 
2409 2409
 					// If there are posts on this day, create a filter link.
2410
-					if(in_array($curday, $posts))
2411
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2410
+					if (in_array($curday, $posts))
2411
+						echo '<a href="blog.php?blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang('ViewPostsOfThisDay').'">'.$curday.'</a>';
2412 2412
 					else
2413 2413
 						echo $dayheader;
2414 2414
 
@@ -2416,14 +2416,14 @@  discard block
 block discarded – undo
2416 2416
 						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2417 2417
 							// Add tasks to calendar
2418 2418
 							foreach ($tasks[$curday] as $task) {
2419
-								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
2420
-								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
2419
+								echo '<a href="blog.php?action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes($task['task_id']).'" title="'.$task['title'].' : '.get_lang('InBlog').' : '.$task['blog_name'].' - '.get_lang('ExecuteThisTask').'">
2420
+								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask').'" /></a>';
2421 2421
 							}
2422 2422
 						}
2423 2423
 					}
2424 2424
 
2425 2425
 					echo "</td>";
2426
-					$curday ++;
2426
+					$curday++;
2427 2427
 				} else
2428 2428
 					echo "<td>&nbsp;</td>";
2429 2429
 			}
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 	public static function display_edit_blog_form($blog_id)
2462 2462
 	{
2463 2463
 	    $course_id = api_get_course_int_id();
2464
-		$blog_id= intval($blog_id);
2464
+		$blog_id = intval($blog_id);
2465 2465
 		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2466 2466
 
2467 2467
 		$sql = "SELECT blog_id, blog_name, blog_subtitle
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
 			$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2477 2477
 		}
2478 2478
 
2479
-        $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2479
+        $form = new FormValidator('edit_blog', 'post', 'blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2480 2480
         $form->addElement('header', get_lang('EditBlog'));
2481 2481
         $form->addElement('text', 'blog_name', get_lang('Title'));
2482 2482
         $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle'));
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 		$result = Database::query($sql);
2514 2514
 		$list_info = array();
2515 2515
 		if (Database::num_rows($result)) {
2516
-			while ($row_project=Database::fetch_row($result)) {
2517
-				$list_info[]=$row_project;
2516
+			while ($row_project = Database::fetch_row($result)) {
2517
+				$list_info[] = $row_project;
2518 2518
 			}
2519 2519
 		}
2520 2520
 
@@ -2526,39 +2526,39 @@  discard block
 block discarded – undo
2526 2526
 				// Validation when belongs to a session
2527 2527
 				$session_img = api_get_session_image($info_log[4], $_user['status']);
2528 2528
 
2529
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2529
+				$url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq();
2530 2530
 				$title = $info_log[0];
2531 2531
                         $image = Display::return_icon('blog.png', $title);
2532
-    			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
2532
+    			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">'.$image.'</a></div><a href="'.$url_start_blog.'">'.$title.'</a>'.$session_img;
2533 2533
 
2534 2534
 				$list_body_blog[] = $list_name;
2535 2535
 				$list_body_blog[] = $info_log[1];
2536 2536
 
2537
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2538
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2539
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2540
-                                $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2537
+				$visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible';
2538
+				$visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible';
2539
+			 	$my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">';
2540
+                                $my_image .= Display::return_icon('edit.png', get_lang('EditBlog'));
2541 2541
 
2542
-				$my_image.= "</a>\n";
2543
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2544
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2545
-                                $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2542
+				$my_image .= "</a>\n";
2543
+				$my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" ';
2544
+				$my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;" >';
2545
+                                $my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2546 2546
 
2547
-				$my_image.= "</a>\n";
2548
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2549
-                                $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2547
+				$my_image .= "</a>\n";
2548
+				$my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">';
2549
+                                $my_image .= Display::return_icon($visibility_icon.'.gif', get_lang($visibility_info));
2550 2550
 
2551
-				$my_image.= "</a>\n";
2551
+				$my_image .= "</a>\n";
2552 2552
 
2553
-				$list_body_blog[]=$my_image;
2553
+				$list_body_blog[] = $my_image;
2554 2554
 
2555
-				$list_content_blog[]=$list_body_blog;
2555
+				$list_content_blog[] = $list_body_blog;
2556 2556
 				$list_body_blog = array();
2557 2557
 
2558 2558
 			}
2559
-			$parameters='';
2559
+			$parameters = '';
2560 2560
 			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2561
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2561
+			$table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project');
2562 2562
 			//$table->set_additional_parameters($parameters);
2563 2563
 			$table->set_header(0, get_lang('Title'));
2564 2564
 			$table->set_header(1, get_lang('SubTitle'));
@@ -2583,34 +2583,34 @@  discard block
 block discarded – undo
2583 2583
  * @author Julio Montoya Dokeos
2584 2584
  * @version avril 2008, dokeos 1.8.5
2585 2585
  */
2586
-function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2586
+function get_blog_attachment($blog_id, $post_id = null, $comment_id = null)
2587 2587
 {
2588 2588
 	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2589 2589
 
2590 2590
 	$blog_id = intval($blog_id);
2591 2591
 	$comment_id = intval($comment_id);
2592 2592
 	$post_id = intval($post_id);
2593
-	$row=array();
2594
-	$where='';
2593
+	$row = array();
2594
+	$where = '';
2595 2595
 	if (!empty ($post_id) && is_numeric($post_id)) {
2596
-		$where.=' AND post_id ="'.$post_id.'" ';
2596
+		$where .= ' AND post_id ="'.$post_id.'" ';
2597 2597
 	}
2598 2598
 
2599 2599
 	if (!empty ($comment_id) && is_numeric($comment_id)) {
2600 2600
 		if (!empty ($post_id)) {
2601
-			$where.= ' AND ';
2601
+			$where .= ' AND ';
2602 2602
 		}
2603
-		$where.=' comment_id ="'.$comment_id.'" ';
2603
+		$where .= ' comment_id ="'.$comment_id.'" ';
2604 2604
 	}
2605 2605
 
2606 2606
     $course_id = api_get_course_int_id();
2607 2607
 
2608
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2608
+	$sql = 'SELECT path, filename, comment FROM '.$blog_table_attachment.'
2609 2609
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2610 2610
 
2611
-	$result=Database::query($sql);
2612
-	if (Database::num_rows($result)!=0) {
2613
-		$row=Database::fetch_array($result);
2611
+	$result = Database::query($sql);
2612
+	if (Database::num_rows($result) != 0) {
2613
+		$row = Database::fetch_array($result);
2614 2614
 	}
2615 2615
 	return $row;
2616 2616
 }
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
  * @version avril 2008, dokeos 1.8.5
2625 2625
  */
2626 2626
 
2627
-function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2627
+function delete_all_blog_attachment($blog_id, $post_id = null, $comment_id = null)
2628 2628
 {
2629 2629
 	$_course = api_get_course_info();
2630 2630
 	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
@@ -2648,22 +2648,22 @@  discard block
 block discarded – undo
2648 2648
     }
2649 2649
 
2650 2650
 	// delete all files in directory
2651
-	$courseDir   = $_course['path'].'/upload/blog';
2651
+	$courseDir = $_course['path'].'/upload/blog';
2652 2652
 	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2653 2653
 	$updir = $sys_course_path.$courseDir;
2654 2654
 
2655 2655
 	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2656 2656
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2657
-	$result=Database::query($sql);
2657
+	$result = Database::query($sql);
2658 2658
 
2659
-	while ($row=Database::fetch_row($result)) {
2660
-		$file=$updir.'/'.$row[0];
2661
-		if (Security::check_abs_path($file,$updir) )
2659
+	while ($row = Database::fetch_row($result)) {
2660
+		$file = $updir.'/'.$row[0];
2661
+		if (Security::check_abs_path($file, $updir))
2662 2662
 		{
2663 2663
 			@ unlink($file);
2664 2664
 		}
2665 2665
 	}
2666
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2666
+	$sql = 'DELETE FROM '.$blog_table_attachment.'
2667 2667
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2668 2668
 	Database::query($sql);
2669 2669
 }
@@ -2676,8 +2676,8 @@  discard block
 block discarded – undo
2676 2676
 function get_blog_post_from_user($course_code, $user_id)
2677 2677
 {
2678 2678
 	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2679
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2680
-	$course_info 	= api_get_course_info($course_code);
2679
+	$tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS);
2680
+	$course_info = api_get_course_info($course_code);
2681 2681
 	$course_id 		= $course_info['real_id'];
2682 2682
 
2683 2683
 	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
@@ -2692,13 +2692,13 @@  discard block
 block discarded – undo
2692 2692
 	$result = Database::query($sql);
2693 2693
 	$return_data = '';
2694 2694
 
2695
-	if (Database::num_rows($result)!=0) {
2696
-		while ($row=Database::fetch_array($result)) {
2697
-			$return_data.=  '<div class="clear"></div><br />';
2698
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2699
-			$return_data.=  '<br / >';
2700
-			$return_data.= $row['full_text'];
2701
-			$return_data.= '<br /><br />';
2695
+	if (Database::num_rows($result) != 0) {
2696
+		while ($row = Database::fetch_array($result)) {
2697
+			$return_data .= '<div class="clear"></div><br />';
2698
+			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png', get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2699
+			$return_data .= '<br / >';
2700
+			$return_data .= $row['full_text'];
2701
+			$return_data .= '<br /><br />';
2702 2702
 		}
2703 2703
 	}
2704 2704
 	return $return_data;
@@ -2728,14 +2728,14 @@  discard block
 block discarded – undo
2728 2728
 			ORDER BY blog_name";
2729 2729
 	$result = Database::query($sql);
2730 2730
 	$return_data = '';
2731
-	if (Database::num_rows($result)!=0) {
2732
-		while ($row=Database::fetch_array($result)) {
2733
-			$return_data.=  '<div class="clear"></div><br />';
2734
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2735
-			$return_data.=  '<br / >';
2731
+	if (Database::num_rows($result) != 0) {
2732
+		while ($row = Database::fetch_array($result)) {
2733
+			$return_data .= '<div class="clear"></div><br />';
2734
+			$return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2735
+			$return_data .= '<br / >';
2736 2736
 			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2737
-			$return_data.=  $row['comment'];
2738
-			$return_data.=  '<br />';
2737
+			$return_data .= $row['comment'];
2738
+			$return_data .= '<br />';
2739 2739
 		}
2740 2740
 	}
2741 2741
 	return $return_data;
Please login to merge, or discard this patch.
main/inc/lib/plugin.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->fields = $settings;
61 61
 
62 62
         global $language_files;
63
-        $language_files[] = 'plugin_' . $this->get_name();
63
+        $language_files[] = 'plugin_'.$this->get_name();
64 64
     }
65 65
 
66 66
     /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
     {
267 267
         $settings = $this->get_settings();
268 268
         foreach ($settings as $setting) {
269
-            if ($setting['variable'] == ($this->get_name() . '_' . $name)) {
269
+            if ($setting['variable'] == ($this->get_name().'_'.$name)) {
270 270
                 return $setting['selected_value'];
271 271
             }
272 272
         }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 
322 322
             $interfaceLanguageId = api_get_language_id($language_interface);
323 323
             $interfaceLanguageInfo = api_get_language_info($interfaceLanguageId);
324
-            $languageParentId = (!empty($interfaceLanguageInfo['parent_id'])?intval($interfaceLanguageInfo['parent_id']):0);
324
+            $languageParentId = (!empty($interfaceLanguageInfo['parent_id']) ? intval($interfaceLanguageInfo['parent_id']) : 0);
325 325
 
326 326
             //1. Loading english if exists
327 327
             $english_path = $root.$plugin_name."/lang/english.php";
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         if (!empty($this->course_settings)) {
400 400
             foreach ($this->course_settings as $setting) {
401 401
                 $variable = $setting['name'];
402
-                $value ='';
402
+                $value = '';
403 403
                 if (isset($setting['init_value'])) {
404 404
                     $value = ($setting['init_value']);
405 405
                 }
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 
612 612
         //Avoid Tab Name Spaces
613 613
         $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName);
614
-        $subkeytext = "Tabs" . $tabNameNoSpaces;
614
+        $subkeytext = "Tabs".$tabNameNoSpaces;
615 615
 
616 616
         //Check if it is already added
617 617
         $checkCondition = array(
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             return false;
628 628
         }
629 629
         //End Check
630
-        $subkey = 'custom_tab_' . $tabNum;
630
+        $subkey = 'custom_tab_'.$tabNum;
631 631
         $attributes = array(
632 632
             'variable' => 'show_tabs',
633 633
             'subkey' => $subkey,
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 
646 646
         //Save the id
647 647
         $settings = $this->get_settings();
648
-        $setData = array (
648
+        $setData = array(
649 649
             'comment' => $subkey
650 650
         );
651 651
         $whereCondition = array(
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
                 $i = 1;
687 687
                 foreach ($tabs as $row) {
688 688
                     $attributes = array(
689
-                        'subkey' => 'custom_tab_' . $i
689
+                        'subkey' => 'custom_tab_'.$i
690 690
                     );
691 691
                     $this->updateTab($row['subkey'], $attributes);
692 692
                     $i++;
Please login to merge, or discard this patch.
main/inc/lib/events.lib.php 1 patch
Spacing   +10 added lines, -12 removed lines patch added patch discarded remove patch
@@ -78,9 +78,7 @@  discard block
 block discarded – undo
78 78
         Database::query($sql);
79 79
 
80 80
         // Auto subscribe
81
-        $user_status = $userInfo['status']  == SESSIONADMIN ? 'sessionadmin' :
82
-            $userInfo['status'] == COURSEMANAGER ? 'teacher' :
83
-                $userInfo['status'] == DRH ? 'DRH' : 'student';
81
+        $user_status = $userInfo['status'] == SESSIONADMIN ? 'sessionadmin' : $userInfo['status'] == COURSEMANAGER ? 'teacher' : $userInfo['status'] == DRH ? 'DRH' : 'student';
84 82
         $autoSubscribe = api_get_setting($user_status.'_autosubscribe');
85 83
         if ($autoSubscribe) {
86 84
             $autoSubscribe = explode('|', $autoSubscribe);
@@ -334,7 +332,7 @@  discard block
 block discarded – undo
334 332
         global $debug;
335 333
 
336 334
         if ($debug) error_log('Called to update_event_exercice');
337
-        if ($debug) error_log('duration:' . $duration);
335
+        if ($debug) error_log('duration:'.$duration);
338 336
 
339 337
         if ($exeid != '') {
340 338
             /*
@@ -382,7 +380,7 @@  discard block
 block discarded – undo
382 380
         		   status = '".$status."',
383 381
         		   questions_to_check = '".$remind_list."',
384 382
         		   data_tracking = '".implode(',', $question_list)."',
385
-                   user_ip = '" . Database::escape_string(api_get_real_ip()) . "'
383
+                   user_ip = '" . Database::escape_string(api_get_real_ip())."'
386 384
         		 WHERE exe_id = '".Database::escape_string($exeid)."'";
387 385
             $res = Database::query($sql);
388 386
 
@@ -1036,15 +1034,15 @@  discard block
 block discarded – undo
1036 1034
 
1037 1035
         if (!empty($exe_list) && is_array($exe_list) && count($exe_list) > 0) {
1038 1036
             $sql = "DELETE FROM $track_e_exercises
1039
-                WHERE exe_id IN (" . implode(',', $exe_list) . ")";
1037
+                WHERE exe_id IN (".implode(',', $exe_list).")";
1040 1038
             Database::query($sql);
1041 1039
 
1042 1040
             $sql = "DELETE FROM $track_attempts
1043
-                WHERE exe_id IN (" . implode(',', $exe_list) . ")";
1041
+                WHERE exe_id IN (".implode(',', $exe_list).")";
1044 1042
             Database::query($sql);
1045 1043
 
1046 1044
             $sql = "DELETE FROM $recording_table
1047
-                WHERE exe_id IN (" . implode(',', $exe_list) . ")";
1045
+                WHERE exe_id IN (".implode(',', $exe_list).")";
1048 1046
             Database::query($sql);
1049 1047
         }
1050 1048
 
@@ -1086,7 +1084,7 @@  discard block
 block discarded – undo
1086 1084
             Event::addEvent(
1087 1085
                 LOG_EXERCISE_RESULT_DELETE,
1088 1086
                 LOG_EXERCISE_AND_USER_ID,
1089
-                $exercise_id . '-' . $user_id,
1087
+                $exercise_id.'-'.$user_id,
1090 1088
                 null,
1091 1089
                 null,
1092 1090
                 $course_id,
@@ -1458,7 +1456,7 @@  discard block
 block discarded – undo
1458 1456
         $res = Database::query($sql);
1459 1457
         $list = array();
1460 1458
         while ($row = Database::fetch_array($res, 'ASSOC')) {
1461
-            $list[$row['exe_id']] = $row;  /*
1459
+            $list[$row['exe_id']] = $row; /*
1462 1460
               $sql = "SELECT * FROM $table_track_attempt WHERE exe_id = {$row['exe_id']}";
1463 1461
               $res_question = Database::query($sql);
1464 1462
               while($row_q = Database::fetch_array($res_question,'ASSOC')) {
@@ -1684,7 +1682,7 @@  discard block
 block discarded – undo
1684 1682
         Event::addEvent(
1685 1683
             LOG_QUESTION_RESULT_DELETE,
1686 1684
             LOG_EXERCISE_ATTEMPT_QUESTION_ID,
1687
-            $exe_id . '-' . $question_id,
1685
+            $exe_id.'-'.$question_id,
1688 1686
             null,
1689 1687
             null,
1690 1688
             $courseId,
@@ -1720,7 +1718,7 @@  discard block
 block discarded – undo
1720 1718
         Event::addEvent(
1721 1719
             LOG_QUESTION_RESULT_DELETE,
1722 1720
             LOG_EXERCISE_ATTEMPT_QUESTION_ID,
1723
-            $exe_id . '-' . $question_id,
1721
+            $exe_id.'-'.$question_id,
1724 1722
             null,
1725 1723
             null,
1726 1724
             $courseId,
Please login to merge, or discard this patch.