Completed
Pull Request — master (#664)
by
unknown
05:50 queued 52s
created
code/SS_Datetimezone.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,20 +6,20 @@
 block discarded – undo
6 6
  */
7 7
 class SS_Datetimezone extends SS_Datetime
8 8
 {
9
-    /**
10
-    * Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04”
11
-    */
12
-    public function Nice() {
13
-        if($timestamp = $this){
14
-            //instantiate new DateTime object based off received timestamp in the default timezone
15
-            $timestamp = new DateTime($timestamp, new DateTimeZone(date_default_timezone_get()));
16
-            //if a user is logged in, has set a timezone that is in the allowed list and 
17
-            //that timezone is NOT the default one then convert the timestamp to use the selected timezone
18
-            if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){
19
-                $timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone));    
20
-            }
21
-        }
22
-        //return timestamp in "Nice" format + the user's timezone
23
-        return $timestamp->Format('d/m/Y g:ia');
24
-    }
9
+	/**
10
+	 * Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04”
11
+	 */
12
+	public function Nice() {
13
+		if($timestamp = $this){
14
+			//instantiate new DateTime object based off received timestamp in the default timezone
15
+			$timestamp = new DateTime($timestamp, new DateTimeZone(date_default_timezone_get()));
16
+			//if a user is logged in, has set a timezone that is in the allowed list and 
17
+			//that timezone is NOT the default one then convert the timestamp to use the selected timezone
18
+			if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){
19
+				$timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone));    
20
+			}
21
+		}
22
+		//return timestamp in "Nice" format + the user's timezone
23
+		return $timestamp->Format('d/m/Y g:ia');
24
+	}
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
     * Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04”
11 11
     */
12 12
     public function Nice() {
13
-        if($timestamp = $this){
13
+        if ($timestamp = $this) {
14 14
             //instantiate new DateTime object based off received timestamp in the default timezone
15 15
             $timestamp = new DateTime($timestamp, new DateTimeZone(date_default_timezone_get()));
16 16
             //if a user is logged in, has set a timezone that is in the allowed list and 
17 17
             //that timezone is NOT the default one then convert the timestamp to use the selected timezone
18
-            if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){
18
+            if (Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()) {
19 19
                 $timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone));    
20 20
             }
21 21
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,18 +4,17 @@
 block discarded – undo
4 4
  *
5 5
  * Adds customisable timezones to the nice method on {@link SS_Datetime}.
6 6
  */
7
-class SS_Datetimezone extends SS_Datetime
8
-{
7
+class SS_Datetimezone extends SS_Datetime {
9 8
     /**
10 9
     * Returns the date in the raw SQL-format specific to a given timezone passed from the Member class, e.g. “2006-01-18 16:32:04”
11 10
     */
12 11
     public function Nice() {
13
-        if($timestamp = $this){
12
+        if($timestamp = $this) {
14 13
             //instantiate new DateTime object based off received timestamp in the default timezone
15 14
             $timestamp = new DateTime($timestamp, new DateTimeZone(date_default_timezone_get()));
16 15
             //if a user is logged in, has set a timezone that is in the allowed list and 
17 16
             //that timezone is NOT the default one then convert the timestamp to use the selected timezone
18
-            if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){
17
+            if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()) {
19 18
                 $timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone));    
20 19
             }
21 20
         }
Please login to merge, or discard this patch.
code/extensions/TimezoneMemberExtension.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
  */
7 7
 class TimezoneMemberExtension extends DataExtension
8 8
 {
9
-    private static $db = [
10
-        'Timezone' => 'Varchar(255)',
11
-    ];
9
+	private static $db = [
10
+		'Timezone' => 'Varchar(255)',
11
+	];
12 12
 
13
-    public function getTimezones() {
14
-        $timezones = timezone_identifiers_list();
15
-        return array_combine($timezones, $timezones);
16
-    }
13
+	public function getTimezones() {
14
+		$timezones = timezone_identifiers_list();
15
+		return array_combine($timezones, $timezones);
16
+	}
17 17
 
18
-    public function updateCMSFields(FieldList $fields)
19
-    {   
20
-        $fields->removeFieldFromTab('Root', 'Timezone');
21
-        $field = DropdownField::create(
22
-          'Timezone',
23
-          'Timezone',
24
-          $this->getTimezones())->setEmptyString('For NZ, choose Pacific/Auckland');
25
-        $fields->addFieldToTab('Root.timezone', $field);
26
-        return $fields;
27
-    }
18
+	public function updateCMSFields(FieldList $fields)
19
+	{   
20
+		$fields->removeFieldFromTab('Root', 'Timezone');
21
+		$field = DropdownField::create(
22
+		  'Timezone',
23
+		  'Timezone',
24
+		  $this->getTimezones())->setEmptyString('For NZ, choose Pacific/Auckland');
25
+		$fields->addFieldToTab('Root.timezone', $field);
26
+		return $fields;
27
+	}
28 28
 
29 29
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  * Adds all available timezones as an optional field to SilverStripe {@link Member}.
6 6
  */
7
-class TimezoneMemberExtension extends DataExtension
8
-{
7
+class TimezoneMemberExtension extends DataExtension {
9 8
     private static $db = [
10 9
         'Timezone' => 'Varchar(255)',
11 10
     ];
@@ -15,8 +14,7 @@  discard block
 block discarded – undo
15 14
         return array_combine($timezones, $timezones);
16 15
     }
17 16
 
18
-    public function updateCMSFields(FieldList $fields)
19
-    {   
17
+    public function updateCMSFields(FieldList $fields) {
20 18
         $fields->removeFieldFromTab('Root', 'Timezone');
21 19
         $field = DropdownField::create(
22 20
           'Timezone',
Please login to merge, or discard this patch.