Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
calendar/inc/class.calendar_uiforms.inc.php 2 patches
Switch Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -557,214 +557,214 @@  discard block
 block discarded – undo
557 557
 
558 558
 		switch((string)$button)
559 559
 		{
560
-		case 'exception':	// create an exception in a recuring event
561
-			$msg = $this->_create_exception($event,$preserv);
562
-			break;
560
+			case 'exception':	// create an exception in a recuring event
561
+				$msg = $this->_create_exception($event,$preserv);
562
+				break;
563 563
 
564
-		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
565
-			unset($event['id']);
566
-			unset($event['uid']);
567
-			unset($event['reference']);
568
-			unset($preserv['reference']);
569
-			unset($event['recurrence']);
570
-			unset($preserv['recurrence']);
571
-			unset($event['recur_exception']);
572
-			unset($event['edit_single']);	// in case it has been set
573
-			unset($event['modified']);
574
-			unset($event['modifier']);
575
-			unset($event['caldav_name']);
576
-			$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
564
+			case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
565
+				unset($event['id']);
566
+				unset($event['uid']);
567
+				unset($event['reference']);
568
+				unset($preserv['reference']);
569
+				unset($event['recurrence']);
570
+				unset($preserv['recurrence']);
571
+				unset($event['recur_exception']);
572
+				unset($event['edit_single']);	// in case it has been set
573
+				unset($event['modified']);
574
+				unset($event['modifier']);
575
+				unset($event['caldav_name']);
576
+				$event['owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
577
+
578
+				// Clear participant stati
579
+				foreach($event['participant_types'] as $type => &$participants)
580
+				{
581
+					foreach($participants as $id => &$p_response)
582
+					{
583
+						if($type == 'u' && $id == $event['owner']) continue;
584
+						calendar_so::split_status($p_response, $quantity, $role);
585
+						// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586
+						$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
587
+						$p_response = calendar_so::combine_status($status,$quantity,$role);
588
+					}
589
+				}
577 590
 
578
-			// Clear participant stati
579
-			foreach($event['participant_types'] as $type => &$participants)
580
-			{
581
-				foreach($participants as $id => &$p_response)
591
+				// Copy alarms
592
+				if (is_array($event['alarm']))
582 593
 				{
583
-					if($type == 'u' && $id == $event['owner']) continue;
584
-					calendar_so::split_status($p_response, $quantity, $role);
585
-					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
587
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
594
+					foreach($event['alarm'] as $n => &$alarm)
595
+					{
596
+						unset($alarm['id']);
597
+						unset($alarm['cal_id']);
598
+					}
588 599
 				}
589
-			}
590 600
 
591
-			// Copy alarms
592
-			if (is_array($event['alarm']))
593
-			{
594
-				foreach($event['alarm'] as $n => &$alarm)
601
+				// Get links to be copied
602
+				// With no ID, $content['link_to']['to_id'] is used
603
+				$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
604
+				foreach(Link::get_links('calendar', $content['id']) as $link)
595 605
 				{
596
-					unset($alarm['id']);
597
-					unset($alarm['cal_id']);
606
+					if ($link['app'] != Link::VFS_APPNAME)
607
+					{
608
+						Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
609
+					}
610
+					elseif ($link['app'] == Link::VFS_APPNAME)
611
+					{
612
+						Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
613
+							'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
614
+							'name' => $link['id'],
615
+						), $link['remark']);
616
+					}
598 617
 				}
599
-			}
618
+				unset($link);
619
+				$preserv['view'] = $preserv['edit_single'] = false;
620
+				$msg = lang('Event copied - the copy can now be edited');
621
+				$event['title'] = lang('Copy of:').' '.$event['title'];
622
+				break;
600 623
 
601
-			// Get links to be copied
602
-			// With no ID, $content['link_to']['to_id'] is used
603
-			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
604
-			foreach(Link::get_links('calendar', $content['id']) as $link)
605
-			{
606
-				if ($link['app'] != Link::VFS_APPNAME)
624
+			case 'mail':
625
+			case 'sendrequest':
626
+			case 'save':
627
+			case 'print':
628
+			case 'apply':
629
+			case 'infolog':
630
+				if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
607 631
 				{
608
-					Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
632
+					$msg = lang('Permission denied');
633
+					$button = '';
634
+					break;
609 635
 				}
610
-				elseif ($link['app'] == Link::VFS_APPNAME)
636
+				if ($event['start'] > $event['end'])
611 637
 				{
612
-					Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array(
613
-						'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'],
614
-						'name' => $link['id'],
615
-					), $link['remark']);
638
+					$msg = lang('Error: Starttime has to be before the endtime !!!');
639
+					$button = '';
640
+					break;
616 641
 				}
617
-			}
618
-			unset($link);
619
-			$preserv['view'] = $preserv['edit_single'] = false;
620
-			$msg = lang('Event copied - the copy can now be edited');
621
-			$event['title'] = lang('Copy of:').' '.$event['title'];
622
-			break;
623
-
624
-		case 'mail':
625
-		case 'sendrequest':
626
-		case 'save':
627
-		case 'print':
628
-		case 'apply':
629
-		case 'infolog':
630
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
631
-			{
632
-				$msg = lang('Permission denied');
633
-				$button = '';
634
-				break;
635
-			}
636
-			if ($event['start'] > $event['end'])
637
-			{
638
-				$msg = lang('Error: Starttime has to be before the endtime !!!');
639
-				$button = '';
640
-				break;
641
-			}
642
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
643
-			{
644
-				$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
645
-				$button = '';
646
-				break;
647
-			}
648
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
649
-			{
650
-				$msg = lang('Error: Duration of event longer then recurrence interval!');
651
-				$button = '';
652
-				break;
653
-			}
654
-			if (!$event['participants'])
655
-			{
656
-				$msg = lang('Error: no participants selected !!!');
657
-				$button = '';
658
-				break;
659
-			}
660
-			// if private event with ressource reservation is forbidden
661
-			if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
662
-			{
663
-				foreach (array_keys($event['participants']) as $uid)
642
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate'])
664 643
 				{
665
-					if ($uid[0] == 'r') //ressource detection
644
+					$msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!');
645
+					$button = '';
646
+					break;
647
+				}
648
+				if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
649
+				{
650
+					$msg = lang('Error: Duration of event longer then recurrence interval!');
651
+					$button = '';
652
+					break;
653
+				}
654
+				if (!$event['participants'])
655
+				{
656
+					$msg = lang('Error: no participants selected !!!');
657
+					$button = '';
658
+					break;
659
+				}
660
+				// if private event with ressource reservation is forbidden
661
+				if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private'])
662
+				{
663
+					foreach (array_keys($event['participants']) as $uid)
666 664
 					{
667
-						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
668
-						$button = '';
669
-						break 2; //break foreach and case
665
+						if ($uid[0] == 'r') //ressource detection
666
+						{
667
+							$msg = lang('Error: ressources reservation in private events is not allowed!!!');
668
+							$button = '';
669
+							break 2; //break foreach and case
670
+						}
670 671
 					}
671 672
 				}
672
-			}
673
-			if ($content['edit_single'])	// we edited a single event from a series
674
-			{
675
-				$event['reference'] = $event['id'];
676
-				$event['recurrence'] = $content['edit_single'];
677
-				unset($event['id']);
678
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
679
-				if (!is_array($conflicts) && $conflicts)
673
+				if ($content['edit_single'])	// we edited a single event from a series
680 674
 				{
681
-					// now we need to add the original start as recur-execption to the series
682
-					$recur_event = $this->bo->read($event['reference']);
683
-					$recur_event['recur_exception'][] = $content['edit_single'];
684
-					// check if we need to move the alarms, because they are next on that exception
685
-					foreach($recur_event['alarm'] as $id => $alarm)
675
+					$event['reference'] = $event['id'];
676
+					$event['recurrence'] = $content['edit_single'];
677
+					unset($event['id']);
678
+					$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
679
+					if (!is_array($conflicts) && $conflicts)
686 680
 					{
687
-						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
681
+						// now we need to add the original start as recur-execption to the series
682
+						$recur_event = $this->bo->read($event['reference']);
683
+						$recur_event['recur_exception'][] = $content['edit_single'];
684
+						// check if we need to move the alarms, because they are next on that exception
685
+						foreach($recur_event['alarm'] as $id => $alarm)
688 686
 						{
689
-							$rrule = calendar_rrule::event2rrule($recur_event, true);
690
-							foreach ($rrule as $time)
687
+							if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
691 688
 							{
692
-								if ($content['edit_single'] < $time->format('ts'))
689
+								$rrule = calendar_rrule::event2rrule($recur_event, true);
690
+								foreach ($rrule as $time)
693 691
 								{
694
-									$alarm['time'] = $time->format('ts') - $alarm['offset'];
695
-									$this->bo->save_alarm($event['reference'], $alarm);
696
-									break;
692
+									if ($content['edit_single'] < $time->format('ts'))
693
+									{
694
+										$alarm['time'] = $time->format('ts') - $alarm['offset'];
695
+										$this->bo->save_alarm($event['reference'], $alarm);
696
+										break;
697
+									}
697 698
 								}
698 699
 							}
699 700
 						}
700
-					}
701
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
702
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
703
-					$this->bo->update($recur_event,true);	// no conflict check here
701
+						unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
702
+						unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
703
+						$this->bo->update($recur_event,true);	// no conflict check here
704 704
 
705
-					if(Api\Json\Response::isJSONResponse())
705
+						if(Api\Json\Response::isJSONResponse())
706
+						{
707
+							// Sending null will trigger a removal of the original
708
+							// for that date
709
+							Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
710
+						}
711
+
712
+						unset($recur_event);
713
+						unset($event['edit_single']);			// if we further edit it, it's just a single event
714
+						unset($preserv['edit_single']);
715
+					}
716
+					else	// conflict or error, we need to reset everything to the state befor we tried to save it
706 717
 					{
707
-						// Sending null will trigger a removal of the original
708
-						// for that date
709
-						Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null));
718
+						$event['id'] = $event['reference'];
719
+						$event['reference'] = $event['recurrence'] = 0;
720
+						$event['uid'] = $content['uid'];
710 721
 					}
711
-
712
-					unset($recur_event);
713
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
714
-					unset($preserv['edit_single']);
715
-				}
716
-				else	// conflict or error, we need to reset everything to the state befor we tried to save it
717
-				{
718
-					$event['id'] = $event['reference'];
719
-					$event['reference'] = $event['recurrence'] = 0;
720
-					$event['uid'] = $content['uid'];
722
+					$update_type = 'edit';
721 723
 				}
722
-				$update_type = 'edit';
723
-			}
724
-			else	// we edited a non-reccuring event or the whole series
725
-			{
726
-				if (($old_event = $this->bo->read($event['id'])))
724
+				else	// we edited a non-reccuring event or the whole series
727 725
 				{
728
-					if ($event['recur_type'] != MCAL_RECUR_NONE)
726
+					if (($old_event = $this->bo->read($event['id'])))
729 727
 					{
730
-						$update_type = 'edit';
731
-
732
-						// we edit a existing series event
733
-						if ($event['start'] != $old_event['start'] ||
734
-							$event['whole_day'] != $old_event['whole_day'] ||
735
-							$event['end'] != $old_event['end'])
728
+						if ($event['recur_type'] != MCAL_RECUR_NONE)
736 729
 						{
737
-							// calculate offset against old series start or clicked recurrance,
738
-							// depending on which is smaller
739
-							$offset = $event['start'] - $old_event['start'];
740
-							if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
741
-							{
742
-								$offset = $off2;
743
-							}
744
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
745
-							if($msg)
730
+							$update_type = 'edit';
731
+
732
+							// we edit a existing series event
733
+							if ($event['start'] != $old_event['start'] ||
734
+								$event['whole_day'] != $old_event['whole_day'] ||
735
+								$event['end'] != $old_event['end'])
746 736
 							{
747
-								$noerror = false;
737
+								// calculate offset against old series start or clicked recurrance,
738
+								// depending on which is smaller
739
+								$offset = $event['start'] - $old_event['start'];
740
+								if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date']))
741
+								{
742
+									$offset = $off2;
743
+								}
744
+								$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
745
+								if($msg)
746
+								{
747
+									$noerror = false;
748
+								}
748 749
 							}
749 750
 						}
750
-					}
751
-					else
752
-					{
753
-						if ($old_event['start'] != $event['start'] ||
754
-							$old_event['end'] != $event['end'] ||
755
-							$event['whole_day'] != $old_event['whole_day'])
751
+						else
756 752
 						{
757
-							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
758
-							foreach((array)$event['participants'] as $uid => $status)
753
+							if ($old_event['start'] != $event['start'] ||
754
+								$old_event['end'] != $event['end'] ||
755
+								$event['whole_day'] != $old_event['whole_day'])
759 756
 							{
760
-								$q = $r = null;
761
-								calendar_so::split_status($status,$q,$r);
762
-								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
757
+								$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
758
+								foreach((array)$event['participants'] as $uid => $status)
763 759
 								{
764
-									$preferences = CreateObject('phpgwapi.preferences',$uid);
765
-									$part_prefs = $preferences->read_repository();
766
-									switch ($part_prefs['calendar']['reset_stati'])
760
+									$q = $r = null;
761
+									calendar_so::split_status($status,$q,$r);
762
+									if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
767 763
 									{
764
+										$preferences = CreateObject('phpgwapi.preferences',$uid);
765
+										$part_prefs = $preferences->read_repository();
766
+										switch ($part_prefs['calendar']['reset_stati'])
767
+										{
768 768
 										case 'no':
769 769
 											break;
770 770
 										case 'startday':
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 											$status_reset_to_unknown = true;
774 774
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
775 775
 											// todo: report reset status to user
776
-									}
776
+										}
777 777
 								}
778 778
 							}
779 779
 							// check if we need to move the alarms, because they are relative
@@ -910,83 +910,83 @@  discard block
 block discarded – undo
910 910
 			}
911 911
 			break;
912 912
 
913
-		case 'cancel':
914
-			if($content['cancel_needs_refresh'])
915
-			{
916
-				Framework::refresh_opener($msg, 'calendar');
917
-			}
918
-			break;
919
-
920
-		case 'delete':					// delete of event (regular or series)
921
-			$exceptions_kept = null;
922
-			if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
923
-				$content['delete_exceptions'] == 'true', $exceptions_kept))
924
-			{
925
-				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
913
+			case 'cancel':
914
+				if($content['cancel_needs_refresh'])
926 915
 				{
927
-					$msg = lang('Series deleted');
928
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
916
+					Framework::refresh_opener($msg, 'calendar');
929 917
 				}
930
-				else
918
+				break;
919
+
920
+			case 'delete':					// delete of event (regular or series)
921
+				$exceptions_kept = null;
922
+				if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'],
923
+					$content['delete_exceptions'] == 'true', $exceptions_kept))
931 924
 				{
932
-					$msg = lang('Event deleted');
933
-				}
925
+					if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
926
+					{
927
+						$msg = lang('Series deleted');
928
+						if ($exceptions_kept) $msg .= lang(', exceptions preserved');
929
+					}
930
+					else
931
+					{
932
+						$msg = lang('Event deleted');
933
+					}
934 934
 
935
-			}
936
-			break;
935
+				}
936
+				break;
937 937
 
938
-		case 'freetime':
939
-			// the "click" has to be in onload, to make sure the button is already created
940
-			$event['button_was'] = $button;
941
-			break;
938
+			case 'freetime':
939
+				// the "click" has to be in onload, to make sure the button is already created
940
+				$event['button_was'] = $button;
941
+				break;
942 942
 
943
-		case 'add_alarm':
944
-			$time = $content['start'];
945
-			$offset = $time - $content['new_alarm']['date'];
946
-			if ($event['recur_type'] != MCAL_RECUR_NONE &&
947
-				($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
948
-				$time < $next_occurrence['start'])
949
-			{
950
-				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
951
-			}
952
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
953
-			{
954
-				$alarm = array(
955
-					'offset' => $offset,
956
-					'time'   => $content['new_alarm']['date'],
957
-					'all'    => !$content['new_alarm']['owner'],
958
-					'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
959
-				);
960
-				if ($alarm['time'] < $this->bo->now_su)
943
+			case 'add_alarm':
944
+				$time = $content['start'];
945
+				$offset = $time - $content['new_alarm']['date'];
946
+				if ($event['recur_type'] != MCAL_RECUR_NONE &&
947
+					($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) &&
948
+					$time < $next_occurrence['start'])
961 949
 				{
962
-					$msg = lang("Can't add alarms in the past !!!");
950
+					$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
963 951
 				}
964
-				elseif ($event['id'])	// save the alarm immediatly
952
+				if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
965 953
 				{
966
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
954
+					$alarm = array(
955
+						'offset' => $offset,
956
+						'time'   => $content['new_alarm']['date'],
957
+						'all'    => !$content['new_alarm']['owner'],
958
+						'owner'  => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user,
959
+					);
960
+					if ($alarm['time'] < $this->bo->now_su)
961
+					{
962
+						$msg = lang("Can't add alarms in the past !!!");
963
+					}
964
+					elseif ($event['id'])	// save the alarm immediatly
967 965
 					{
968
-						$alarm['id'] = $alarm_id;
969
-						$event['alarm'][$alarm_id] = $alarm;
966
+						if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
967
+						{
968
+							$alarm['id'] = $alarm_id;
969
+							$event['alarm'][$alarm_id] = $alarm;
970 970
 
971
-						$msg = lang('Alarm added');
972
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
971
+							$msg = lang('Alarm added');
972
+							Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
973
+						}
974
+						else
975
+						{
976
+							$msg = lang('Error adding the alarm');
977
+						}
973 978
 					}
974 979
 					else
975 980
 					{
976
-						$msg = lang('Error adding the alarm');
981
+						for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
982
+						$event['alarm'][$alarm['id']] = $alarm;
977 983
 					}
978 984
 				}
979 985
 				else
980 986
 				{
981
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
982
-					$event['alarm'][$alarm['id']] = $alarm;
987
+					$msg = lang('Permission denied');
983 988
 				}
984
-			}
985
-			else
986
-			{
987
-				$msg = lang('Permission denied');
988
-			}
989
-			break;
989
+				break;
990 990
 		}
991 991
 		// add notification-errors, if we have some
992 992
 		if (($notification_errors = notifications::errors(true)))
Please login to merge, or discard this patch.
Braces   +288 added lines, -74 removed lines patch added patch discarded remove patch
@@ -110,11 +110,14 @@  discard block
 block discarded – undo
110 110
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
111 111
 			!$this->bo->check_perms(Acl::ADD,0,$owner))
112 112
 		{
113
-			if ($owner)	// make an owner who is no user or we have no add-rights a participant
113
+			if ($owner)
114
+			{
115
+				// make an owner who is no user or we have no add-rights a participant
114 116
 			{
115 117
 				if(!is_array($owner))
116 118
 				{
117 119
 					$owner = explode(',',$owner);
120
+			}
118 121
 				}
119 122
 				// if we come from ressources we don't need any users selected in calendar
120 123
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
@@ -150,9 +153,17 @@  discard block
 block discarded – undo
150 153
 		$participant_types['u'] = $participant_types = $participants = array();
151 154
 		foreach($extra_participants as $uid)
152 155
 		{
153
-			if (isset($participants[$uid])) continue;	// already included
156
+			if (isset($participants[$uid]))
157
+			{
158
+				continue;
159
+			}
160
+			// already included
154 161
 
155
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
162
+			if (!$this->bo->check_acl_invite($uid))
163
+			{
164
+				continue;
165
+			}
166
+			// no right to invite --> ignored
156 167
 
157 168
 			if (is_numeric($uid))
158 169
 			{
@@ -180,10 +191,13 @@  discard block
 block discarded – undo
180 191
 				}
181 192
 			}
182 193
 		}
183
-		if (!$participants)	// if all participants got removed, include current user
194
+		if (!$participants)
195
+		{
196
+			// if all participants got removed, include current user
184 197
 		{
185 198
 			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
186 199
 		}
200
+		}
187 201
 		if(isset($_GET['cat_id']))
188 202
 		{
189 203
 			$cat_id = explode(',',$_GET['cat_id']);
@@ -231,10 +245,13 @@  discard block
 block discarded – undo
231 245
 	 */
232 246
 	function process_edit($content)
233 247
 	{
234
-		if (!is_array($content))	// redirect from etemplate, if POST empty
248
+		if (!is_array($content))
249
+		{
250
+			// redirect from etemplate, if POST empty
235 251
 		{
236 252
 			return $this->edit(null,null,strip_tags($_GET['msg']));
237 253
 		}
254
+		}
238 255
 		// clear notification errors
239 256
 		notifications::errors(true);
240 257
 		$messages = null;
@@ -247,7 +264,11 @@  discard block
 block discarded – undo
247 264
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
248 265
 
249 266
 		list($button) = @each($content['button']);
250
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
267
+		if (!$button && $content['action'])
268
+		{
269
+			$button = $content['action'];
270
+		}
271
+		// action selectbox
251 272
 		unset($content['button']); unset($content['action']);
252 273
 
253 274
 		$view = $content['view'];
@@ -260,7 +281,10 @@  discard block
 block discarded – undo
260 281
 		{
261 282
 			list($date) = each($content['recur_exception']['delete_exception']);
262 283
 			// eT2 converts time to
263
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
284
+			if (!is_numeric($date))
285
+			{
286
+				$date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
287
+			}
264 288
 			unset($content['recur_exception']['delete_exception']);
265 289
 			if (($key = array_search($date,$content['recur_exception'])) !== false)
266 290
 			{
@@ -269,7 +293,10 @@  discard block
 block discarded – undo
269 293
 				foreach ($recur_exceptions as $id)
270 294
 				{
271 295
 					if (!($exception = $this->bo->read($id)) ||
272
-							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
296
+							$exception['recurrence'] != $content['recur_exception'][$key])
297
+					{
298
+						continue;
299
+					}
273 300
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
274 301
 					$exception['reference'] = $exception['recurrence'] = 0;
275 302
 					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
@@ -344,7 +371,10 @@  discard block
 block discarded – undo
344 371
 				$event['end'] = $this->bo->date2ts($event['end']);
345 372
 			}
346 373
 			// some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
347
-			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
374
+			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data'])
375
+			{
376
+				$event['recur_type'] = MCAL_RECUR_WEEKLY;
377
+			}
348 378
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
349 379
 			{
350 380
 				$event['recur_data'] = 1 << (int)date('w',$event['start']);
@@ -371,7 +401,8 @@  discard block
 block discarded – undo
371 401
 							break;
372 402
 						case 'participant':
373 403
 							foreach($data as $participant)
374
-							{								// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
404
+							{
405
+// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
375 406
 								$email = array();
376 407
 								if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email))
377 408
 								{
@@ -451,7 +482,11 @@  discard block
 block discarded – undo
451 482
 							break;
452 483
 
453 484
 						default:		// existing participant row
454
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
485
+							if (!is_array($data))
486
+							{
487
+								continue;
488
+							}
489
+							// widgets in participant tab, above participant list
455 490
 							foreach(array('uid','status','quantity','role') as $name)
456 491
 							{
457 492
 								$$name = $data[$name];
@@ -580,7 +615,10 @@  discard block
 block discarded – undo
580 615
 			{
581 616
 				foreach($participants as $id => &$p_response)
582 617
 				{
583
-					if($type == 'u' && $id == $event['owner']) continue;
618
+					if($type == 'u' && $id == $event['owner'])
619
+					{
620
+						continue;
621
+					}
584 622
 					calendar_so::split_status($p_response, $quantity, $role);
585 623
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
586 624
 					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
@@ -662,17 +700,23 @@  discard block
 block discarded – undo
662 700
 			{
663 701
 				foreach (array_keys($event['participants']) as $uid)
664 702
 				{
665
-					if ($uid[0] == 'r') //ressource detection
703
+					if ($uid[0] == 'r')
704
+					{
705
+						//ressource detection
666 706
 					{
667 707
 						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
708
+					}
668 709
 						$button = '';
669 710
 						break 2; //break foreach and case
670 711
 					}
671 712
 				}
672 713
 			}
673
-			if ($content['edit_single'])	// we edited a single event from a series
714
+			if ($content['edit_single'])
715
+			{
716
+				// we edited a single event from a series
674 717
 			{
675 718
 				$event['reference'] = $event['id'];
719
+			}
676 720
 				$event['recurrence'] = $content['edit_single'];
677 721
 				unset($event['id']);
678 722
 				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
@@ -768,7 +812,10 @@  discard block
 block discarded – undo
768 812
 										case 'no':
769 813
 											break;
770 814
 										case 'startday':
771
-											if ($sameday) break;
815
+											if ($sameday)
816
+											{
817
+												break;
818
+											}
772 819
 										default:
773 820
 											$status_reset_to_unknown = true;
774 821
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -925,7 +972,10 @@  discard block
 block discarded – undo
925 972
 				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
926 973
 				{
927 974
 					$msg = lang('Series deleted');
928
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
975
+					if ($exceptions_kept)
976
+					{
977
+						$msg .= lang(', exceptions preserved');
978
+					}
929 979
 				}
930 980
 				else
931 981
 				{
@@ -961,11 +1011,14 @@  discard block
 block discarded – undo
961 1011
 				{
962 1012
 					$msg = lang("Can't add alarms in the past !!!");
963 1013
 				}
964
-				elseif ($event['id'])	// save the alarm immediatly
1014
+				elseif ($event['id'])
1015
+				{
1016
+					// save the alarm immediatly
965 1017
 				{
966 1018
 					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
967 1019
 					{
968 1020
 						$alarm['id'] = $alarm_id;
1021
+				}
969 1022
 						$event['alarm'][$alarm_id] = $alarm;
970 1023
 
971 1024
 						$msg = lang('Alarm added');
@@ -978,7 +1031,9 @@  discard block
 block discarded – undo
978 1031
 				}
979 1032
 				else
980 1033
 				{
981
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1034
+					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++)
1035
+					{
1036
+}	// get a temporary non-conflicting, numeric id
982 1037
 					$event['alarm'][$alarm['id']] = $alarm;
983 1038
 				}
984 1039
 			}
@@ -1001,10 +1056,13 @@  discard block
 block discarded – undo
1001 1056
 		}
1002 1057
 		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1003 1058
 		{
1004
-			if ($content['lock_token'])	// remove an existing lock
1059
+			if ($content['lock_token'])
1060
+			{
1061
+				// remove an existing lock
1005 1062
 			{
1006 1063
 				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1007 1064
 			}
1065
+			}
1008 1066
 			if ($content['no_popup'])
1009 1067
 			{
1010 1068
 				Egw::redirect_link('/index.php',array(
@@ -1108,8 +1166,7 @@  discard block
 block discarded – undo
1108 1166
 		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1109 1167
 			// Adjust for requested date in the past
1110 1168
 			Api\DateTime::to($as_of_date,'ts') < time()
1111
-		)
1112
-		{
1169
+		) {
1113 1170
 
1114 1171
 			unset($orig_event);
1115 1172
 			// copy event by unsetting the id(s)
@@ -1197,32 +1254,50 @@  discard block
 block discarded – undo
1197 1254
 		foreach($event['participants'] as $uid => $status)
1198 1255
 		{
1199 1256
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1200
-			if (empty($status)) continue;
1257
+			if (empty($status))
1258
+			{
1259
+				continue;
1260
+			}
1201 1261
 			$toadd = '';
1202
-			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue;
1262
+			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user))
1263
+			{
1264
+				continue;
1265
+			}
1203 1266
 
1204 1267
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1205 1268
 			{
1206
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1269
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email')))
1270
+				{
1271
+					continue;
1272
+				}
1207 1273
 
1208 1274
 				$lid = $firstname = $lastname = null;
1209 1275
 				$GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname);
1210 1276
 
1211 1277
 				$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1212
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1278
+				if (!in_array($toadd,$to))
1279
+				{
1280
+					$to[] = $toadd;
1281
+				}
1213 1282
 				//error_log(__METHOD__.__LINE__.array2string($to));
1214 1283
 			}
1215 1284
 			elseif ($uid < 0)
1216 1285
 			{
1217 1286
 				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1218 1287
 				{
1219
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1288
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email')))
1289
+					{
1290
+						continue;
1291
+					}
1220 1292
 
1221 1293
 					$GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname);
1222 1294
 
1223 1295
 					$toadd = $firstname.' '.$lastname.' <'.$email.'>';
1224 1296
 					// dont add groupmembers if they already rejected the event, or are the current user
1225
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1297
+					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user))
1298
+					{
1299
+						$to[] = $toadd;
1300
+					}
1226 1301
 					//error_log(__METHOD__.__LINE__.array2string($to));
1227 1302
 				}
1228 1303
 			}
@@ -1275,7 +1350,10 @@  discard block
 block discarded – undo
1275 1350
 			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1276 1351
 			'preset[size]'    => filesize($ics_file),
1277 1352
 		);
1278
-		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1353
+		if ($asrequest)
1354
+		{
1355
+			$vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1356
+		}
1279 1357
 		$response = Api\Json\Response::get();
1280 1358
 		$response->call('app.calendar.custom_mail', $vars);
1281 1359
 	}
@@ -1461,9 +1539,15 @@  discard block
 block discarded – undo
1461 1539
 				}
1462 1540
 			}
1463 1541
 			// set new start and end if given by $_GET
1464
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1465
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1466
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1542
+			if(isset($_GET['start']))
1543
+			{
1544
+$event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1545
+			if(isset($_GET['end']))
1546
+			{
1547
+$event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1548
+			if(isset($_GET['non_blocking']))
1549
+			{
1550
+$event['non_blocking'] = (bool)$_GET['non_blocking']; }
1467 1551
 			// check if the event is the whole day
1468 1552
 			$start = $this->bo->date2array($event['start']);
1469 1553
 			$end = $this->bo->date2array($event['end']);
@@ -1476,10 +1560,13 @@  discard block
 block discarded – undo
1476 1560
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1477 1561
 				{
1478 1562
 					$link_id = $link_ids[$n];
1479
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1563
+					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
1564
+					{
1565
+						// guard against XSS
1480 1566
 					{
1481 1567
 						continue;
1482 1568
 					}
1569
+					}
1483 1570
 					if(!$n)
1484 1571
 					{
1485 1572
 						$event['title'] = Link::title($link_app,$link_id);
@@ -1488,7 +1575,10 @@  discard block
 block discarded – undo
1488 1575
 						{
1489 1576
 							foreach((array)$set['link_app'] as $i => $l_app)
1490 1577
 							{
1491
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1578
+								if (($l_id=$set['link_id'][$i]))
1579
+								{
1580
+									Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1581
+								}
1492 1582
 							}
1493 1583
 							unset($set['link_app']);
1494 1584
 							unset($set['link_id']);
@@ -1514,10 +1604,13 @@  discard block
 block discarded – undo
1514 1604
 			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1515 1605
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1516 1606
 
1517
-			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1607
+			if (($preserv['lock_token'] = $event['lock_token']))
1608
+			{
1609
+				// already locked --> refresh the lock
1518 1610
 			{
1519 1611
 				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1520 1612
 			}
1613
+			}
1521 1614
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1522 1615
 			{
1523 1616
 				$msg .= ' '.lang('This entry is currently opened by %1!',
@@ -1550,14 +1643,20 @@  discard block
 block discarded – undo
1550 1643
 		));
1551 1644
 		Framework::message($msg, $msg_type);
1552 1645
 		$content['duration'] = $content['end'] - $content['start'];
1553
-		if (isset($this->durations[$content['duration']])) $content['end'] = '';
1646
+		if (isset($this->durations[$content['duration']]))
1647
+		{
1648
+			$content['end'] = '';
1649
+		}
1554 1650
 
1555 1651
 		$row = 3;
1556 1652
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1557 1653
 		// preserve some ui elements, if set eg. under error-conditions
1558 1654
 		foreach(array('quantity','resource','role') as $n)
1559 1655
 		{
1560
-			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1656
+			if (isset($event['participants'][$n]))
1657
+			{
1658
+				$content['participants'][$n] = $event['participants'][$n];
1659
+			}
1561 1660
 		}
1562 1661
 		foreach($event['participant_types'] as $type => $participants)
1563 1662
 		{
@@ -1599,9 +1698,13 @@  discard block
 block discarded – undo
1599 1698
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1600 1699
 
1601 1700
 				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1602
-					$readonlys['participants'][$row]['status'] = $no_status;
1701
+				{
1702
+									$readonlys['participants'][$row]['status'] = $no_status;
1703
+				}
1603 1704
 				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1604
-					$readonlys['participants']['delete'][$uid] = true;
1705
+				{
1706
+									$readonlys['participants']['delete'][$uid] = true;
1707
+				}
1605 1708
 				// todo: make the participants available as links with email as title
1606 1709
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1607 1710
 				// enumerate group-invitations, so people can accept/reject them
@@ -1632,7 +1735,11 @@  discard block
 block discarded – undo
1632 1735
 			$content['participants']['cal_resources'] = '';
1633 1736
 			foreach($this->bo->resources as $data)
1634 1737
 			{
1635
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1738
+				if ($data['app'] == 'email')
1739
+				{
1740
+					continue;
1741
+				}
1742
+				// make no sense, as we cant search for email
1636 1743
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1637 1744
 			}
1638 1745
 		}
@@ -1660,9 +1767,18 @@  discard block
 block discarded – undo
1660 1767
 				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1661 1768
 				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1662 1769
 				$label = array();
1663
-				if ($days) $label[] = $days.' '.lang('days');
1664
-				if ($hours) $label[] = $hours.' '.lang('hours');
1665
-				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1770
+				if ($days)
1771
+				{
1772
+					$label[] = $days.' '.lang('days');
1773
+				}
1774
+				if ($hours)
1775
+				{
1776
+					$label[] = $hours.' '.lang('hours');
1777
+				}
1778
+				if ($minutes)
1779
+				{
1780
+					$label[] = $minutes.' '.lang('Minutes');
1781
+				}
1666 1782
 				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1667 1783
 				$content['alarm'][] = $alarm;
1668 1784
 
@@ -1725,25 +1841,34 @@  discard block
 block discarded – undo
1725 1841
 			'participants' => $this->accountsel->account_selection == 'none',
1726 1842
 			'history' => !$event['id'],
1727 1843
 		);
1728
-		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))	// no mail without mail-app
1844
+		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))
1845
+		{
1846
+			// no mail without mail-app
1729 1847
 		{
1730 1848
 			unset($sel_options['action']['mail']);
1849
+		}
1731 1850
 			unset($sel_options['action']['sendmeetingrequest']);
1732 1851
 		}
1733
-		if (!$event['id'])	// no ical export for new (not saved) events
1852
+		if (!$event['id'])
1853
+		{
1854
+			// no ical export for new (not saved) events
1734 1855
 		{
1735 1856
 			$readonlys['action'] = true;
1736 1857
 		}
1858
+		}
1737 1859
 		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1738 1860
 		{
1739 1861
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1740 1862
 		}
1741 1863
 		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1742 1864
 
1743
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1865
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))
1866
+		{
1867
+			// new event or edit rights to the event ==> allow to add alarm for all users
1744 1868
 		{
1745 1869
 			$sel_options['owner'][0] = lang('All participants');
1746 1870
 		}
1871
+		}
1747 1872
 		if (isset($event['participant_types']['u'][$this->user]))
1748 1873
 		{
1749 1874
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
@@ -1785,7 +1910,10 @@  discard block
 block discarded – undo
1785 1910
 
1786 1911
 		$content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh'];
1787 1912
 
1788
-		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1913
+		if (!empty($preserved['lock_token']))
1914
+		{
1915
+			$content['lock_token'] = $preserved['lock_token'];
1916
+		}
1789 1917
 
1790 1918
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1791 1919
 		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
@@ -1987,7 +2115,10 @@  discard block
 block discarded – undo
1987 2115
 					// set status and send notification / meeting response
1988 2116
 					if ($this->bo->set_status($event['id'], $user, $status))
1989 2117
 					{
1990
-						if (!$msg) $msg = lang('Status changed');
2118
+						if (!$msg)
2119
+						{
2120
+							$msg = lang('Status changed');
2121
+						}
1991 2122
 					}
1992 2123
 					break;
1993 2124
 
@@ -2066,13 +2197,16 @@  discard block
 block discarded – undo
2066 2197
 
2067 2198
 		foreach (array_keys($allConflicts) as $pId)
2068 2199
 		{
2069
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2200
+			if(substr($pId,0,1) == 'r' && $resources_config )
2201
+			{
2202
+				// resources Allow ignore conflicts
2070 2203
 			{
2071 2204
 
2072 2205
 				switch ($resources_config['ignoreconflicts'])
2073 2206
 				{
2074 2207
 					case 'no':
2075 2208
 						$readonlys['button[ignore]'] = true;
2209
+			}
2076 2210
 						break;
2077 2211
 					case 'allusers':
2078 2212
 						$readonlys['button[ignore]'] = false;
@@ -2216,7 +2350,10 @@  discard block
 block discarded – undo
2216 2350
 		}
2217 2351
 		else
2218 2352
 		{
2219
-			if (!$content['duration']) $content['duration'] = $content['end'] - $content['start'];
2353
+			if (!$content['duration'])
2354
+			{
2355
+				$content['duration'] = $content['end'] - $content['start'];
2356
+			}
2220 2357
 			$weekds = 0;
2221 2358
 			foreach ($content['weekdays'] as &$wdays)
2222 2359
 			{
@@ -2238,7 +2375,10 @@  discard block
 block discarded – undo
2238 2375
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2239 2376
 
2240 2377
 		$sel_options['duration'] = $this->durations;
2241
-		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2378
+		if ($content['duration'] && isset($sel_options['duration'][$content['duration']]))
2379
+		{
2380
+			$content['end'] = '';
2381
+		}
2242 2382
 
2243 2383
 		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2244 2384
 				'participants'	=> $content['participants'],
@@ -2259,7 +2399,10 @@  discard block
 block discarded – undo
2259 2399
 	 */
2260 2400
 	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2261 2401
 	{
2262
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2402
+		if ($this->debug > 2)
2403
+		{
2404
+			$this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2405
+		}
2263 2406
 
2264 2407
 		$busy = $this->bo->search(array(
2265 2408
 			'start' => $start,
@@ -2276,15 +2419,26 @@  discard block
 block discarded – undo
2276 2419
 		$n = 0;
2277 2420
 		foreach($busy as $event)
2278 2421
 		{
2279
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2422
+			if ((int)$cal_id && $event['id'] == (int)$cal_id)
2423
+			{
2424
+				continue;
2425
+			}
2426
+			// ignore our own event
2280 2427
 
2281
- 			if ($event['non_blocking']) continue; // ignore non_blocking events
2428
+ 			if ($event['non_blocking'])
2429
+ 			{
2430
+ 				continue;
2431
+ 			}
2432
+ 			// ignore non_blocking events
2282 2433
 
2283 2434
 			// check if from all wanted participants at least one has a not rejected status in found event
2284 2435
 			$non_rejected_found = false;
2285 2436
 			foreach($participants as $uid)
2286 2437
 			{
2287
-				if ($event['participants'][$uid] == 'R') continue;
2438
+				if ($event['participants'][$uid] == 'R')
2439
+				{
2440
+					continue;
2441
+				}
2288 2442
 
2289 2443
 				if (isset($event['participants'][$uid]) ||
2290 2444
 					$uid > 0 && array_intersect(array_keys((array)$event['participants']),
@@ -2294,7 +2448,10 @@  discard block
 block discarded – undo
2294 2448
 					break;
2295 2449
 				}
2296 2450
 			}
2297
-			if (!$non_rejected_found) continue;
2451
+			if (!$non_rejected_found)
2452
+			{
2453
+				continue;
2454
+			}
2298 2455
 
2299 2456
 			if ($this->debug)
2300 2457
 			{
@@ -2325,11 +2482,17 @@  discard block
 block discarded – undo
2325 2482
 					'start'	=> $ft_start,
2326 2483
 					'end'	=> $ft_end,
2327 2484
 				);
2328
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2485
+				if ($this->debug > 1)
2486
+				{
2487
+					echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2488
+				}
2329 2489
 			}
2330 2490
 			$ft_start = $event['end'];
2331 2491
 		}
2332
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2492
+		if ($this->debug > 0)
2493
+		{
2494
+			$this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2495
+		}
2333 2496
 
2334 2497
 		return $freetime;
2335 2498
 	}
@@ -2349,10 +2512,16 @@  discard block
 block discarded – undo
2349 2512
 	 */
2350 2513
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2351 2514
 	{
2352
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2515
+		if ($this->debug > 1)
2516
+		{
2517
+			$this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2518
+		}
2353 2519
 
2354 2520
 		$freetime_daywise = array();
2355
-		if (!is_array($sel_options)) $sel_options = array();
2521
+		if (!is_array($sel_options))
2522
+		{
2523
+			$sel_options = array();
2524
+		}
2356 2525
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2357 2526
 
2358 2527
 		$start_time = (int) $_start_time;	// ignore leading zeros
@@ -2362,7 +2531,10 @@  discard block
 block discarded – undo
2362 2531
 		if (($end_time - $start_time)*HOUR_s < $duration)
2363 2532
 		{
2364 2533
 			$end_time = 0;
2365
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2534
+			if ($this->debug > 1)
2535
+			{
2536
+				$this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2537
+			}
2366 2538
 		}
2367 2539
 		$n = 0;
2368 2540
 		foreach($freetime as $ft)
@@ -2383,13 +2555,19 @@  discard block
 block discarded – undo
2383 2555
 				}
2384 2556
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2385 2557
 
2386
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2558
+				if ($start-$daybegin < $start_time*HOUR_s)
2559
+				{
2560
+					// start earlier then start_time
2387 2561
 				{
2388 2562
 					$start = $daybegin + $start_time*HOUR_s;
2389 2563
 				}
2564
+				}
2390 2565
 				// if end_time given use it, else the original slot's end
2391 2566
 				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2392
-				if ($end > $ft['end']) $end = $ft['end'];
2567
+				if ($end > $ft['end'])
2568
+				{
2569
+					$end = $ft['end'];
2570
+				}
2393 2571
 
2394 2572
 				// slot to small for duration
2395 2573
 				if ($end - $start < $duration)
@@ -2431,7 +2609,10 @@  discard block
 block discarded – undo
2431 2609
 			{
2432 2610
 				$msg = lang('Permission denied');
2433 2611
 
2434
-				if ($return_error) return $msg;
2612
+				if ($return_error)
2613
+				{
2614
+					return $msg;
2615
+				}
2435 2616
 			}
2436 2617
 			else
2437 2618
 			{
@@ -2493,27 +2674,42 @@  discard block
 block discarded – undo
2493 2674
 		{
2494 2675
 			list($button) = each($_content['button']);
2495 2676
 			unset($_content['button']);
2496
-			if ($button != 'cancel')	// store changed Acl
2677
+			if ($button != 'cancel')
2678
+			{
2679
+				// store changed Acl
2497 2680
 			{
2498 2681
 				foreach($_content as $data)
2499 2682
 				{
2500 2683
 					if (!($cat_id = $data['cat_id'])) continue;
2684
+			}
2501 2685
 					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2502 2686
 					{
2503 2687
 						$rights = 0;
2504
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2505
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2506
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2688
+						if (in_array($account_id,(array)$data['add']))
2689
+						{
2690
+							$rights |= calendar_boupdate::CAT_ACL_ADD;
2691
+						}
2692
+						if (in_array($account_id,(array)$data['status']))
2693
+						{
2694
+							$rights |= calendar_boupdate::CAT_ACL_STATUS;
2695
+						}
2696
+						if ($account_id)
2697
+						{
2698
+							$this->bo->set_cat_rights($cat_id,$account_id,$rights);
2699
+						}
2507 2700
 					}
2508 2701
 				}
2509 2702
 			}
2510
-			if ($button != 'apply')	// end dialog
2703
+			if ($button != 'apply')
2704
+			{
2705
+				// end dialog
2511 2706
 			{
2512 2707
 				Egw::redirect_link('/index.php', array(
2513 2708
 					'menuaction' => 'admin.admin_ui.index',
2514 2709
 					'ajax' => 'true'
2515 2710
 				), 'admin');
2516 2711
 			}
2712
+			}
2517 2713
 		}
2518 2714
 		$content= $preserv = array();
2519 2715
 		$n = 1;
@@ -2527,8 +2723,14 @@  discard block
 block discarded – undo
2527 2723
 			);
2528 2724
 			foreach($data as $account_id => $rights)
2529 2725
 			{
2530
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2531
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2726
+				if ($rights & calendar_boupdate::CAT_ACL_ADD)
2727
+				{
2728
+					$row['add'][] = $account_id;
2729
+				}
2730
+				if ($rights & calendar_boupdate::CAT_ACL_STATUS)
2731
+				{
2732
+					$row['status'][] = $account_id;
2733
+				}
2532 2734
 			}
2533 2735
 			$content[$n] = $row;
2534 2736
 			$preserv[$n] = array(
@@ -2656,7 +2858,10 @@  discard block
 block discarded – undo
2656 2858
 					break;
2657 2859
 				}
2658 2860
 			}
2659
-			if($return) return;
2861
+			if($return)
2862
+			{
2863
+				return;
2864
+			}
2660 2865
 		}
2661 2866
 		$old_event=$event=$this->bo->read($eventId);
2662 2867
 		if (!$durationT)
@@ -2741,7 +2946,10 @@  discard block
 block discarded – undo
2741 2946
 			$this->bo->update($event,true, true, false, true, $message,true);
2742 2947
 
2743 2948
 			// Whole day non blocking with DAY_s would add a day
2744
-			if($duration==DAY_s) $duration=0;
2949
+			if($duration==DAY_s)
2950
+			{
2951
+				$duration=0;
2952
+			}
2745 2953
 		}
2746 2954
 		// Drag a normal event to whole day non-blocking
2747 2955
 		else if ($durationT == 'whole_day')
@@ -2765,7 +2973,10 @@  discard block
 block discarded – undo
2765 2973
 					case 'no':
2766 2974
 						break;
2767 2975
 					case 'startday':
2768
-						if ($sameday) break;
2976
+						if ($sameday)
2977
+						{
2978
+							break;
2979
+						}
2769 2980
 					default:
2770 2981
 						$status_reset_to_unknown = true;
2771 2982
 						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -2803,7 +3014,10 @@  discard block
 block discarded – undo
2803 3014
 		{
2804 3015
 			$response->call('egw.message',  implode('<br />', $message));
2805 3016
 		}
2806
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
3017
+		if($event['id'] != $eventId )
3018
+		{
3019
+			$this->update_client($_eventId);
3020
+		}
2807 3021
 		if ($status_reset_to_unknown)
2808 3022
 		{
2809 3023
 			foreach((array)$event['participants'] as $uid => $status)
Please login to merge, or discard this patch.
api/src/Vfs/WebDAV.php 2 patches
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -171,16 +171,16 @@
 block discarded – undo
171 171
 
172 172
         if (is_dir($source)) { // resource is a collection
173 173
             switch ($options["depth"]) {
174
-            case "infinity": // valid
175
-                break;
176
-            case "0": // valid for COPY only
177
-                if ($del) { // MOVE?
178
-                    return "400 Bad request";
179
-                }
180
-                break;
181
-            case "1": // invalid for both COPY and MOVE
182
-            default:
183
-                return "400 Bad request";
174
+            	case "infinity": // valid
175
+                	break;
176
+            	case "0": // valid for COPY only
177
+                	if ($del) { // MOVE?
178
+                    	return "400 Bad request";
179
+                	}
180
+                	break;
181
+            	case "1": // invalid for both COPY and MOVE
182
+            	default:
183
+                	return "400 Bad request";
184 184
             }
185 185
         }
186 186
 
Please login to merge, or discard this patch.
Braces   +133 added lines, -50 removed lines patch added patch discarded remove patch
@@ -64,7 +64,8 @@  discard block
 block discarded – undo
64 64
 		// special treatment for litmus compliance test
65 65
 		// reply on its identifier header
66 66
 		// not needed for the test itself but eases debugging
67
-		if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
67
+		if (isset($this->_SERVER['HTTP_X_LITMUS']))
68
+		{
68 69
 			error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
69 70
 			header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
70 71
 		}
@@ -123,24 +124,30 @@  discard block
 block discarded – undo
123 124
         $path   = $this->_unslashify($this->base .$options["path"]);
124 125
         $parent = Vfs::dirname($path);
125 126
 
126
-        if (!file_exists($parent)) {
127
+        if (!file_exists($parent))
128
+        {
127 129
             return "409 Conflict";
128 130
         }
129 131
 
130
-        if (!is_dir($parent)) {
132
+        if (!is_dir($parent))
133
+        {
131 134
             return "403 Forbidden";
132 135
         }
133 136
 
134
-        if ( file_exists($path) ) {
137
+        if ( file_exists($path) )
138
+        {
135 139
             return "405 Method not allowed";
136 140
         }
137 141
 
138
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
142
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
143
+        {
144
+// no body parsing yet
139 145
             return "415 Unsupported media type";
140 146
         }
141 147
 
142 148
         $stat = mkdir($path, 0777);
143
-        if (!$stat) {
149
+        if (!$stat)
150
+        {
144 151
             return "403 Forbidden";
145 152
         }
146 153
 
@@ -157,24 +164,35 @@  discard block
 block discarded – undo
157 164
     {
158 165
         // TODO Property updates still broken (Litmus should detect this?)
159 166
 
160
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
167
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
168
+        {
169
+// no body parsing yet
161 170
             return "415 Unsupported media type";
162 171
         }
163 172
 
164 173
         // no copying to different WebDAV Servers yet
165
-        if (isset($options["dest_url"])) {
174
+        if (isset($options["dest_url"]))
175
+        {
166 176
             return "502 bad gateway";
167 177
         }
168 178
 
169 179
         $source = $this->base .$options["path"];
170
-        if (!file_exists($source)) return "404 Not found";
180
+        if (!file_exists($source))
181
+        {
182
+        	return "404 Not found";
183
+        }
171 184
 
172
-        if (is_dir($source)) { // resource is a collection
173
-            switch ($options["depth"]) {
185
+        if (is_dir($source))
186
+        {
187
+// resource is a collection
188
+            switch ($options["depth"])
189
+            {
174 190
             case "infinity": // valid
175 191
                 break;
176 192
             case "0": // valid for COPY only
177
-                if ($del) { // MOVE?
193
+                if ($del)
194
+                {
195
+// MOVE?
178 196
                     return "400 Bad request";
179 197
                 }
180 198
                 break;
@@ -187,71 +205,99 @@  discard block
 block discarded – undo
187 205
         $dest         = $this->base . $options["dest"];
188 206
         $destdir      = dirname($dest);
189 207
 
190
-        if (!file_exists($destdir) || !is_dir($destdir)) {
208
+        if (!file_exists($destdir) || !is_dir($destdir))
209
+        {
191 210
             return "409 Conflict";
192 211
         }
193 212
 
194 213
         $new          = !file_exists($dest);
195 214
         $existing_col = false;
196 215
 
197
-        if (!$new) {
198
-            if ($del && is_dir($dest)) {
199
-                if (!$options["overwrite"]) {
216
+        if (!$new)
217
+        {
218
+            if ($del && is_dir($dest))
219
+            {
220
+                if (!$options["overwrite"])
221
+                {
200 222
                     return "412 precondition failed";
201 223
                 }
202 224
                 $dest .= basename($source);
203
-                if (file_exists($dest)) {
225
+                if (file_exists($dest))
226
+                {
204 227
                     $options["dest"] .= basename($source);
205
-                } else {
228
+                }
229
+                else
230
+                {
206 231
                     $new          = true;
207 232
                     $existing_col = true;
208 233
                 }
209 234
             }
210 235
         }
211 236
 
212
-        if (!$new) {
213
-            if ($options["overwrite"]) {
237
+        if (!$new)
238
+        {
239
+            if ($options["overwrite"])
240
+            {
214 241
                 $stat = $this->DELETE(array("path" => $options["dest"]));
215
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
242
+                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404"))
243
+                {
216 244
                     return $stat;
217 245
                 }
218
-            } else {
246
+            }
247
+            else
248
+            {
219 249
                 return "412 precondition failed";
220 250
             }
221 251
         }
222 252
 
223
-        if ($del) {
224
-            if (!rename($source, $dest)) {
253
+        if ($del)
254
+        {
255
+            if (!rename($source, $dest))
256
+            {
225 257
                 return "500 Internal server error";
226 258
             }
227
-        } else {
228
-            if (is_dir($source) && $options['depth'] == 'infinity') {
259
+        }
260
+        else
261
+        {
262
+            if (is_dir($source) && $options['depth'] == 'infinity')
263
+            {
229 264
             	$files = Vfs::find($source,array('depth' => true,'url' => true));	// depth=true: return dirs first, url=true: allow urls!
230
-            } else {
265
+            }
266
+            else
267
+            {
231 268
                 $files = array($source);
232 269
             }
233 270
 
234
-            if (!is_array($files) || empty($files)) {
271
+            if (!is_array($files) || empty($files))
272
+            {
235 273
                 return "500 Internal server error";
236 274
             }
237 275
 
238 276
 
239
-            foreach ($files as $file) {
240
-                if (is_dir($file)) {
277
+            foreach ($files as $file)
278
+            {
279
+                if (is_dir($file))
280
+                {
241 281
                     $file = $this->_slashify($file);
242 282
                 }
243 283
 
244 284
                 $destfile = str_replace($source, $dest, $file);
245 285
 
246
-                if (is_dir($file)) {
247
-                    if (!is_dir($destfile)) {
286
+                if (is_dir($file))
287
+                {
288
+                    if (!is_dir($destfile))
289
+                    {
248 290
                         // TODO "mkdir -p" here? (only natively supported by PHP 5)
249
-                        if (!@mkdir($destfile)) {
291
+                        if (!@mkdir($destfile))
292
+                        {
250 293
                             return "409 Conflict";
251 294
                         }
252 295
                     }
253
-                } else {
254
-                    if (!@copy($file, $destfile)) {
296
+                }
297
+                else
298
+                {
299
+                    if (!@copy($file, $destfile))
300
+                    {
255 301
                         return "409 Conflict";
256 302
                     }
257 303
                 }
@@ -301,17 +347,23 @@  discard block
 block discarded – undo
301 347
         $info["props"][] = self::mkprop("ishidden",        Vfs::is_hidden($fspath));
302 348
 
303 349
 		// type and size (caller already made sure that path exists)
304
-		if (is_dir($fspath)) {
350
+		if (is_dir($fspath))
351
+		{
305 352
 			// directory (WebDAV collection)
306 353
 			$info['props'][] = self::mkprop	('resourcetype', array(
307 354
 			 	self::mkprop('collection', '')));
308 355
 			$info['props'][] = self::mkprop	('getcontenttype', 'httpd/unix-directory');
309
-		} else {
356
+		}
357
+		else
358
+		{
310 359
 			// plain file (WebDAV resource)
311 360
 			$info['props'][] = self::mkprop	('resourcetype', '');
312
-			if (Vfs::is_readable($path)) {
361
+			if (Vfs::is_readable($path))
362
+			{
313 363
 				$info['props'][] = self::mkprop	('getcontenttype', Vfs::mime_content_type($path));
314
-			} else {
364
+			}
365
+			else
366
+			{
315 367
 				error_log(__METHOD__."($path) $fspath is not readable!");
316 368
 				$info['props'][] = self::mkprop	('getcontenttype', 'application/x-non-readable');
317 369
 			}
@@ -383,7 +435,10 @@  discard block
 block discarded – undo
383 435
 				continue;
384 436
 			}
385 437
 			$_path = $info['path'];
386
-			if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/') $_path = substr($info['path'],0,-1);
438
+			if (!$n && $info['path'] != '/' && substr($info['path'],-1) == '/')
439
+			{
440
+				$_path = substr($info['path'],0,-1);
441
+			}
387 442
 
388 443
 			// need to encode path again, as $info['path'] is NOT encoded, but Vfs::(stat|propfind) require it
389 444
 			// otherwise pathes containing url special chars like ? or # will not stat
@@ -422,16 +477,22 @@  discard block
 block discarded – undo
422 477
 				$fileprops =& $files['files'][$path2n[$path]]['props'];
423 478
 				foreach($props as $prop)
424 479
 				{
425
-					if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#')	// eGW's customfields
480
+					if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#')
481
+					{
482
+						// eGW's customfields
426 483
 					{
427 484
 						$prop['ns'] .= 'customfields/';
485
+					}
428 486
 						$prop['name'] = substr($prop['name'],1);
429 487
 					}
430 488
 					$fileprops[] = $prop;
431 489
 				}
432 490
 			}
433 491
 		}
434
-		if ($this->debug) error_log(__METHOD__."() props=".array2string($files['files']));
492
+		if ($this->debug)
493
+		{
494
+			error_log(__METHOD__."() props=".array2string($files['files']));
495
+		}
435 496
 		return true;
436 497
 	}
437 498
 
@@ -483,7 +544,8 @@  discard block
 block discarded – undo
483 544
 	{
484 545
 		$path = Api\Translation::convert($options['path'],'utf-8');
485 546
 
486
-		foreach ($options['props'] as $key => $prop) {
547
+		foreach ($options['props'] as $key => $prop)
548
+		{
487 549
 			$attributes = array();
488 550
 			switch($prop['ns'])
489 551
 			{
@@ -500,7 +562,10 @@  discard block
 block discarded – undo
500 562
 							//$attributes['created'] = strtotime($prop['val']);
501 563
 							//break;
502 564
 						default:
503
-							if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
565
+							if (!Vfs::proppatch($path,array($prop)))
566
+							{
567
+								$options['props'][$key]['status'] = '403 Forbidden';
568
+							}
504 569
 							break;
505 570
 					}
506 571
 					break;
@@ -529,7 +594,10 @@  discard block
 block discarded – undo
529 594
 						case 'Win32LastAccessTime':
530 595
 						case 'Win32FileAttributes':	// not sure what that is, it was always "00000000"
531 596
 						default:
532
-							if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
597
+							if (!Vfs::proppatch($path,array($prop)))
598
+							{
599
+								$options['props'][$key]['status'] = '403 Forbidden';
600
+							}
533 601
 							break;
534 602
 					}
535 603
 					break;
@@ -539,15 +607,24 @@  discard block
 block discarded – undo
539 607
 					$prop['name'] = '#'.$prop['name'];
540 608
 					// fall through
541 609
 				default:
542
-					if (!Vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
610
+					if (!Vfs::proppatch($path,array($prop)))
611
+					{
612
+						$options['props'][$key]['status'] = '403 Forbidden';
613
+					}
543 614
 					break;
544 615
 			}
545
-			if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
616
+			if ($this->debug)
617
+			{
618
+				$props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
619
+			}
546 620
 		}
547 621
 		if ($this->debug)
548 622
 		{
549 623
 			error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props));
550
-			if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
624
+			if ($attributes)
625
+			{
626
+				error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
627
+			}
551 628
 		}
552 629
 
553 630
 		return '';	// this is as the filesystem example handler does it, no true or false ...
@@ -561,7 +638,10 @@  discard block
 block discarded – undo
561 638
 	 */
562 639
 	function LOCK(&$options)
563 640
 	{
564
-		if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
641
+		if ($this->debug)
642
+		{
643
+			error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
644
+		}
565 645
 		// TODO recursive locks on directories not supported yet
566 646
 		if (is_dir($this->base . $options['path']) && !empty($options['depth']))
567 647
 		{
@@ -587,7 +667,10 @@  discard block
 block discarded – undo
587 667
 	 */
588 668
 	function UNLOCK(&$options)
589 669
 	{
590
-		if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
670
+		if ($this->debug)
671
+		{
672
+			error_log(__METHOD__.'('.str_replace(array("\n",'    '),'',print_r($options,true)).')');
673
+		}
591 674
 		return Vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict';
592 675
 	}
593 676
 
Please login to merge, or discard this patch.
api/src/WebDAV/Tools/_parse_lockinfo.php 2 patches
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -179,16 +179,16 @@
 block discarded – undo
179 179
         } else if ($ns == "DAV:") {
180 180
             // parse only the essential tags
181 181
             switch ($tag) {
182
-            case "write":
183
-                $this->locktype = $tag;
184
-                break;
185
-            case "exclusive":
186
-            case "shared":
187
-                $this->lockscope = $tag;
188
-                break;
189
-            case "owner":
190
-                $this->collect_owner = true;
191
-                break;
182
+            	case "write":
183
+                	$this->locktype = $tag;
184
+                	break;
185
+            	case "exclusive":
186
+            	case "shared":
187
+                	$this->lockscope = $tag;
188
+                	break;
189
+            	case "owner":
190
+                	$this->collect_owner = true;
191
+                	break;
192 192
             }
193 193
         }
194 194
     }
Please login to merge, or discard this patch.
Braces   +45 added lines, -20 removed lines patch added patch discarded remove patch
@@ -99,7 +99,8 @@  discard block
 block discarded – undo
99 99
 
100 100
         // open stream
101 101
         $f_in = fopen($path, "r");
102
-        if (!$f_in) {
102
+        if (!$f_in)
103
+        {
103 104
             $this->success = false;
104 105
             return;
105 106
         }
@@ -119,16 +120,19 @@  discard block
 block discarded – undo
119 120
                               XML_OPTION_CASE_FOLDING, false);
120 121
 
121 122
         // parse input
122
-        while ($this->success && !feof($f_in)) {
123
+        while ($this->success && !feof($f_in))
124
+        {
123 125
             $line = fgets($f_in);
124
-            if (is_string($line)) {
126
+            if (is_string($line))
127
+            {
125 128
                 $had_input = true;
126 129
                 $this->success &= xml_parse($xml_parser, $line, false);
127 130
             }
128 131
         }
129 132
 
130 133
         // finish parsing
131
-        if ($had_input) {
134
+        if ($had_input)
135
+        {
132 136
             $this->success &= xml_parse($xml_parser, "", true);
133 137
         }
134 138
 
@@ -156,29 +160,40 @@  discard block
 block discarded – undo
156 160
     function _startElement($parser, $name, $attrs)
157 161
     {
158 162
         // namespace handling
159
-        if (strstr($name, " ")) {
163
+        if (strstr($name, " "))
164
+        {
160 165
             list($ns, $tag) = explode(" ", $name);
161
-        } else {
166
+        }
167
+        else
168
+        {
162 169
             $ns  = "";
163 170
             $tag = $name;
164 171
         }
165 172
 
166 173
 
167
-        if ($this->collect_owner) {
174
+        if ($this->collect_owner)
175
+        {
168 176
             // everything within the <owner> tag needs to be collected
169 177
             $ns_short = "";
170 178
             $ns_attr  = "";
171
-            if ($ns) {
172
-                if ($ns == "DAV:") {
179
+            if ($ns)
180
+            {
181
+                if ($ns == "DAV:")
182
+                {
173 183
                     $ns_short = "D:";
174
-                } else {
184
+                }
185
+                else
186
+                {
175 187
                     $ns_attr = " xmlns='$ns'";
176 188
                 }
177 189
             }
178 190
             $this->owner .= "<$ns_short$tag$ns_attr>";
179
-        } else if ($ns == "DAV:") {
191
+        }
192
+        else if ($ns == "DAV:")
193
+        {
180 194
             // parse only the essential tags
181
-            switch ($tag) {
195
+            switch ($tag)
196
+            {
182 197
             case "write":
183 198
                 $this->locktype = $tag;
184 199
                 break;
@@ -204,7 +219,8 @@  discard block
 block discarded – undo
204 219
     function _data($parser, $data)
205 220
     {
206 221
         // only the <owner> tag has data content
207
-        if ($this->collect_owner) {
222
+        if ($this->collect_owner)
223
+        {
208 224
             $this->owner .= $data;
209 225
         }
210 226
     }
@@ -220,26 +236,35 @@  discard block
 block discarded – undo
220 236
     function _endElement($parser, $name)
221 237
     {
222 238
         // namespace handling
223
-        if (strstr($name, " ")) {
239
+        if (strstr($name, " "))
240
+        {
224 241
             list($ns, $tag) = explode(" ", $name);
225
-        } else {
242
+        }
243
+        else
244
+        {
226 245
             $ns  = "";
227 246
             $tag = $name;
228 247
         }
229 248
 
230 249
         // <owner> finished?
231
-        if (($ns == "DAV:") && ($tag == "owner")) {
250
+        if (($ns == "DAV:") && ($tag == "owner"))
251
+        {
232 252
             $this->collect_owner = false;
233 253
         }
234 254
 
235 255
         // within <owner> we have to collect everything
236
-        if ($this->collect_owner) {
256
+        if ($this->collect_owner)
257
+        {
237 258
             $ns_short = "";
238 259
             $ns_attr  = "";
239
-            if ($ns) {
240
-                if ($ns == "DAV:") {
260
+            if ($ns)
261
+            {
262
+                if ($ns == "DAV:")
263
+                {
241 264
                     $ns_short = "D:";
242
-                } else {
265
+                }
266
+                else
267
+                {
243 268
                     $ns_attr = " xmlns='$ns'";
244 269
                 }
245 270
             }
Please login to merge, or discard this patch.
api/src/WebDAV/Server.php 2 patches
Switch Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -816,34 +816,34 @@  discard block
 block discarded – undo
816 816
 	            	// this can happen if we have allprop and prop in one propfind:
817 817
 	            	// <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop
818 818
 	                switch(is_array($props) ? $props[0] : $props) {
819
-	                case "all":
820
-	                    // nothing to remove
821
-	                    break;
822
-
823
-	                case "names":
824
-	                    // only the names of all existing properties were requested
825
-	                    // so we remove all values
826
-	                    unset($prop["val"]);
827
-	                    break;
828
-
829
-	                default:
830
-	                    $found = false;
831
-
832
-	                    // search property name in requested properties
833
-	                    foreach ((array)$props as $reqprop) {
834
-	                        if (   $reqprop["name"]  == $prop["name"]
835
-	                               && @$reqprop["xmlns"] == $prop["ns"]) {
836
-	                            $found = true;
837
-	                            break;
838
-	                        }
839
-	                    }
840
-
841
-	                    // unset property and continue with next one if not found/requested
842
-	                    if (!$found) {
843
-	                        $prop="";
844
-	                        continue(2);
845
-	                    }
846
-	                    break;
819
+	                	case "all":
820
+	                    	// nothing to remove
821
+	                    	break;
822
+
823
+	                	case "names":
824
+	                    	// only the names of all existing properties were requested
825
+	                    	// so we remove all values
826
+	                    	unset($prop["val"]);
827
+	                    	break;
828
+
829
+	                	default:
830
+	                    	$found = false;
831
+
832
+	                    	// search property name in requested properties
833
+	                    	foreach ((array)$props as $reqprop) {
834
+	                        	if (   $reqprop["name"]  == $prop["name"]
835
+	                               	&& @$reqprop["xmlns"] == $prop["ns"]) {
836
+	                            	$found = true;
837
+	                            	break;
838
+	                        	}
839
+	                    	}
840
+
841
+	                    	// unset property and continue with next one if not found/requested
842
+	                    	if (!$found) {
843
+	                        	$prop="";
844
+	                        	continue(2);
845
+	                    	}
846
+	                    	break;
847 847
 	                }
848 848
 
849 849
 	                // namespace handling
@@ -964,49 +964,49 @@  discard block
 block discarded – undo
964 964
                     } else if ($prop["ns"] == "DAV:") {
965 965
                         // some WebDAV properties need special treatment
966 966
                         switch ($prop["name"]) {
967
-                        case "creationdate":
968
-                            echo '     <'.($this->crrnd?'':'D:')."creationdate ns0:dt=\"dateTime.tz\">"
969
-                                . gmdate("Y-m-d\\TH:i:s\\Z", $prop['val'])
970
-                                . '</'.($this->crrnd?'':'D:')."creationdate>\n";
971
-                            break;
972
-                        case "getlastmodified":
973
-                            echo '     <'.($this->crrnd?'':'D:')."getlastmodified ns0:dt=\"dateTime.rfc1123\">"
974
-                                . gmdate("D, d M Y H:i:s ", $prop['val'])
975
-                                . "GMT</".($this->crrnd?'':'D:')."getlastmodified>\n";
976
-                            break;
977
-                        case "supportedlock":
978
-                            echo '     <'.($this->crrnd?'':'D:')."supportedlock>$prop[val]</".($this->crrnd?'':'D:')."supportedlock>\n";
979
-                            break;
980
-                        case "lockdiscovery":
981
-                            echo '     <'.($this->crrnd?'':'D:')."lockdiscovery>\n";
982
-                            echo $prop["val"];
983
-                            echo '     </'.($this->crrnd?'':'D:')."lockdiscovery>\n";
984
-                            break;
985
-                        // the following are non-standard Microsoft extensions to the DAV namespace
986
-                        case "lastaccessed":
987
-                            echo '     <'.($this->crrnd?'':'D:')."lastaccessed ns0:dt=\"dateTime.rfc1123\">"
988
-                                . gmdate("D, d M Y H:i:s ", $prop['val'])
989
-                                . 'GMT</'.($this->crrnd?'':'D:')."lastaccessed>\n";
990
-                            break;
991
-                        case "ishidden":
992
-                            echo '     <'.($this->crrnd?'':'D:')."ishidden>"
993
-                                . is_string($prop['val']) ? $prop['val'] : ($prop['val'] ? 'true' : 'false')
994
-                                . '</'.($this->crrnd?'':'D:')."</D:ishidden>\n";
995
-                            break;
996
-                        default:
997
-                        	$ns_defs = '';
998
-                            if (is_array($prop['val']))
999
-                            {
1000
-                            	$hns_hash = $ns_hash;
1001
-                            	$val = $this->_hierarchical_prop_encode($prop['val'], 'DAV:', $ns_defs, $hns_hash);
1002
-                            } elseif (isset($prop['raw'])) {
1003
-                            	$val = $this->_prop_encode('<![CDATA['.$prop['val'].']]>');
1004
-                            } else {
1005
-	                    		$val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8'));
1006
-                            }
1007
-	                        echo '     <'.($this->crrnd?'':'D:')."$prop[name]$ns_defs>$val".
1008
-	                        	'</'.($this->crrnd?'':'D:')."$prop[name]>\n";
1009
-                            break;
967
+                        	case "creationdate":
968
+                            	echo '     <'.($this->crrnd?'':'D:')."creationdate ns0:dt=\"dateTime.tz\">"
969
+                                	. gmdate("Y-m-d\\TH:i:s\\Z", $prop['val'])
970
+                                	. '</'.($this->crrnd?'':'D:')."creationdate>\n";
971
+                            	break;
972
+                        	case "getlastmodified":
973
+                            	echo '     <'.($this->crrnd?'':'D:')."getlastmodified ns0:dt=\"dateTime.rfc1123\">"
974
+                                	. gmdate("D, d M Y H:i:s ", $prop['val'])
975
+                                	. "GMT</".($this->crrnd?'':'D:')."getlastmodified>\n";
976
+                            	break;
977
+                        	case "supportedlock":
978
+                            	echo '     <'.($this->crrnd?'':'D:')."supportedlock>$prop[val]</".($this->crrnd?'':'D:')."supportedlock>\n";
979
+                            	break;
980
+                        	case "lockdiscovery":
981
+                            	echo '     <'.($this->crrnd?'':'D:')."lockdiscovery>\n";
982
+                            	echo $prop["val"];
983
+                            	echo '     </'.($this->crrnd?'':'D:')."lockdiscovery>\n";
984
+                            	break;
985
+                        	// the following are non-standard Microsoft extensions to the DAV namespace
986
+                        	case "lastaccessed":
987
+                            	echo '     <'.($this->crrnd?'':'D:')."lastaccessed ns0:dt=\"dateTime.rfc1123\">"
988
+                                	. gmdate("D, d M Y H:i:s ", $prop['val'])
989
+                                	. 'GMT</'.($this->crrnd?'':'D:')."lastaccessed>\n";
990
+                            	break;
991
+                        	case "ishidden":
992
+                            	echo '     <'.($this->crrnd?'':'D:')."ishidden>"
993
+                                	. is_string($prop['val']) ? $prop['val'] : ($prop['val'] ? 'true' : 'false')
994
+                                	. '</'.($this->crrnd?'':'D:')."</D:ishidden>\n";
995
+                            	break;
996
+                        	default:
997
+                        		$ns_defs = '';
998
+                            	if (is_array($prop['val']))
999
+                            	{
1000
+                            		$hns_hash = $ns_hash;
1001
+                            		$val = $this->_hierarchical_prop_encode($prop['val'], 'DAV:', $ns_defs, $hns_hash);
1002
+                            	} elseif (isset($prop['raw'])) {
1003
+                            		$val = $this->_prop_encode('<![CDATA['.$prop['val'].']]>');
1004
+                            	} else {
1005
+	                    			$val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8'));
1006
+                            	}
1007
+	                        	echo '     <'.($this->crrnd?'':'D:')."$prop[name]$ns_defs>$val".
1008
+	                        		'</'.($this->crrnd?'':'D:')."$prop[name]>\n";
1009
+                            	break;
1010 1010
                         }
1011 1011
                     } else {
1012 1012
                         // allow multiple values and attributes, required eg. for caldav:supported-calendar-component-set
@@ -1761,9 +1761,9 @@  discard block
 block discarded – undo
1761 1761
             foreach ($this->_SERVER as $key => $val) {
1762 1762
                 if (strncmp($key, "HTTP_CONTENT", 11)) continue;
1763 1763
                 switch ($key) {
1764
-                case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11
1765
-		        	switch($this->_SERVER['HTTP_CONTENT_ENCODING'])
1766
-		        	{
1764
+                	case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11
1765
+		        		switch($this->_SERVER['HTTP_CONTENT_ENCODING'])
1766
+		        		{
1767 1767
 		        		case 'gzip':
1768 1768
 		        		case 'deflate':	//zlib
1769 1769
 		        			if (extension_loaded('zlib')) break;
@@ -1772,67 +1772,67 @@  discard block
 block discarded – undo
1772 1772
 					        $this->http_status('415 Unsupported Media Type');
1773 1773
 					        echo "The service does not support '$val' content encoding";
1774 1774
 					        return;
1775
-		        	}
1775
+		        		}
1776 1776
 		        	break;
1777 1777
 
1778
-                case 'HTTP_CONTENT_LANGUAGE': // RFC 2616 14.12
1779
-                    // we assume it is not critical if this one is ignored
1780
-                    // in the actual PUT implementation ...
1781
-                    $options["content_language"] = $val;
1782
-                    break;
1778
+                	case 'HTTP_CONTENT_LANGUAGE': // RFC 2616 14.12
1779
+                    	// we assume it is not critical if this one is ignored
1780
+                    	// in the actual PUT implementation ...
1781
+                    	$options["content_language"] = $val;
1782
+                    	break;
1783 1783
 
1784
-                case 'HTTP_CONTENT_LENGTH':
1785
-                    // defined on IIS and has the same value as CONTENT_LENGTH
1786
-                    break;
1784
+                	case 'HTTP_CONTENT_LENGTH':
1785
+                    	// defined on IIS and has the same value as CONTENT_LENGTH
1786
+                    	break;
1787 1787
 
1788
-                case 'HTTP_CONTENT_LOCATION': // RFC 2616 14.14
1789
-                    /* The meaning of the Content-Location header in PUT
1788
+                	case 'HTTP_CONTENT_LOCATION': // RFC 2616 14.14
1789
+                    	/* The meaning of the Content-Location header in PUT
1790 1790
                      or POST requests is undefined; servers are free
1791 1791
                      to ignore it in those cases. */
1792
-                    break;
1793
-
1794
-                case 'HTTP_CONTENT_RANGE':    // RFC 2616 14.16
1795
-                    // single byte range requests are supported
1796
-                    // the header format is also specified in RFC 2616 14.16
1797
-                    // TODO we have to ensure that implementations support this or send 501 instead
1798
-					$matches = null;
1799
-                    if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
1800
-                        $this->http_status("400 bad request");
1801
-                        echo "The service does only support single byte ranges";
1802
-                        return;
1803
-                    }
1804
-
1805
-                    $range = array("start" => $matches[1], "end" => $matches[2]);
1806
-                    if (is_numeric($matches[3])) {
1807
-                        $range["total_length"] = $matches[3];
1808
-                    }
1809
-
1810
-                    if (!isset($options['ranges'])) {
1811
-                        $options['ranges'] = array();
1812
-                    }
1813
-
1814
-                    $options["ranges"][] = $range;
1815
-
1816
-                    // TODO make sure the implementation supports partial PUT
1817
-                    // this has to be done in advance to avoid data being overwritten
1818
-                    // on implementations that do not support this ...
1819
-                    break;
1820
-
1821
-                case 'HTTP_CONTENT_TYPE':
1822
-                    // defined on IIS and has the same value as CONTENT_TYPE
1823
-                    break;
1824
-
1825
-                case 'HTTP_CONTENT_MD5':      // RFC 2616 14.15
1826
-                    // TODO: maybe we can just pretend here?
1827
-                    $this->http_status("501 not implemented");
1828
-                    echo "The service does not support content MD5 checksum verification";
1829
-                    return;
1830
-
1831
-                default:
1832
-                    // any other unknown Content-* headers
1833
-                    $this->http_status("501 not implemented");
1834
-                    echo "The service does not support '$key'";
1835
-                    return;
1792
+                    	break;
1793
+
1794
+                	case 'HTTP_CONTENT_RANGE':    // RFC 2616 14.16
1795
+                    	// single byte range requests are supported
1796
+                    	// the header format is also specified in RFC 2616 14.16
1797
+                    	// TODO we have to ensure that implementations support this or send 501 instead
1798
+						$matches = null;
1799
+                    	if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
1800
+                        	$this->http_status("400 bad request");
1801
+                        	echo "The service does only support single byte ranges";
1802
+                        	return;
1803
+                    	}
1804
+
1805
+                    	$range = array("start" => $matches[1], "end" => $matches[2]);
1806
+                    	if (is_numeric($matches[3])) {
1807
+                        	$range["total_length"] = $matches[3];
1808
+                    	}
1809
+
1810
+                    	if (!isset($options['ranges'])) {
1811
+                        	$options['ranges'] = array();
1812
+                    	}
1813
+
1814
+                    	$options["ranges"][] = $range;
1815
+
1816
+                    	// TODO make sure the implementation supports partial PUT
1817
+                    	// this has to be done in advance to avoid data being overwritten
1818
+                    	// on implementations that do not support this ...
1819
+                    	break;
1820
+
1821
+                	case 'HTTP_CONTENT_TYPE':
1822
+                    	// defined on IIS and has the same value as CONTENT_TYPE
1823
+                    	break;
1824
+
1825
+                	case 'HTTP_CONTENT_MD5':      // RFC 2616 14.15
1826
+                    	// TODO: maybe we can just pretend here?
1827
+                    	$this->http_status("501 not implemented");
1828
+                    	echo "The service does not support content MD5 checksum verification";
1829
+                    	return;
1830
+
1831
+                	default:
1832
+                    	// any other unknown Content-* headers
1833
+                    	$this->http_status("501 not implemented");
1834
+                    	echo "The service does not support '$key'";
1835
+                    	return;
1836 1836
                 }
1837 1837
             }
1838 1838
 
@@ -2390,34 +2390,34 @@  discard block
 block discarded – undo
2390 2390
 
2391 2391
         // now it depends on what we found
2392 2392
         switch ($c) {
2393
-        case "<":
2394
-            // URIs are enclosed in <...>
2395
-            $pos2 = strpos($string, ">", $pos);
2396
-            $uri  = substr($string, $pos, $pos2 - $pos);
2397
-            $pos  = $pos2 + 1;
2398
-            return array("URI", $uri);
2399
-
2400
-        case "[":
2401
-            //Etags are enclosed in [...]
2402
-            if ($string{$pos} == "W") {
2403
-                $type = "ETAG_WEAK";
2404
-                $pos += 2;
2405
-            } else {
2406
-                $type = "ETAG_STRONG";
2407
-            }
2408
-            $pos2 = strpos($string, "]", $pos);
2409
-            $etag = substr($string, $pos + 1, $pos2 - $pos - 2);
2410
-            $pos  = $pos2 + 1;
2411
-            return array($type, $etag);
2412
-
2413
-        case "N":
2414
-            // "N" indicates negation
2415
-            $pos += 2;
2416
-            return array("NOT", "Not");
2417
-
2418
-        default:
2419
-            // anything else is passed verbatim char by char
2420
-            return array("CHAR", $c);
2393
+        	case "<":
2394
+            	// URIs are enclosed in <...>
2395
+            	$pos2 = strpos($string, ">", $pos);
2396
+            	$uri  = substr($string, $pos, $pos2 - $pos);
2397
+            	$pos  = $pos2 + 1;
2398
+            	return array("URI", $uri);
2399
+
2400
+        	case "[":
2401
+            	//Etags are enclosed in [...]
2402
+            	if ($string{$pos} == "W") {
2403
+                	$type = "ETAG_WEAK";
2404
+                	$pos += 2;
2405
+            	} else {
2406
+                	$type = "ETAG_STRONG";
2407
+            	}
2408
+            	$pos2 = strpos($string, "]", $pos);
2409
+            	$etag = substr($string, $pos + 1, $pos2 - $pos - 2);
2410
+            	$pos  = $pos2 + 1;
2411
+            	return array($type, $etag);
2412
+
2413
+        	case "N":
2414
+            	// "N" indicates negation
2415
+            	$pos += 2;
2416
+            	return array("NOT", "Not");
2417
+
2418
+        	default:
2419
+            	// anything else is passed verbatim char by char
2420
+            	return array("CHAR", $c);
2421 2421
         }
2422 2422
     }
2423 2423
 
@@ -2461,33 +2461,33 @@  discard block
 block discarded – undo
2461 2461
                     continue;
2462 2462
                 }
2463 2463
                 switch ($token[0]) {
2464
-                case "CHAR":
2465
-                    switch ($token[1]) {
2466
-                    case "(":
2467
-                        $level++;
2468
-                        break;
2469
-                    case ")":
2470
-                        $level--;
2471
-                        break;
2472
-                    default:
2473
-                        return false;
2474
-                    }
2464
+                	case "CHAR":
2465
+                    	switch ($token[1]) {
2466
+                    		case "(":
2467
+                        		$level++;
2468
+                        		break;
2469
+                    		case ")":
2470
+                        		$level--;
2471
+                        		break;
2472
+                    		default:
2473
+                        		return false;
2474
+                    	}
2475 2475
                     break;
2476 2476
 
2477
-                case "URI":
2478
-                    $list[] = $not."<$token[1]>";
2479
-                    break;
2477
+                	case "URI":
2478
+                    	$list[] = $not."<$token[1]>";
2479
+                    	break;
2480 2480
 
2481
-                case "ETAG_WEAK":
2482
-                    $list[] = $not."[W/'$token[1]']>";
2483
-                    break;
2481
+                	case "ETAG_WEAK":
2482
+                    	$list[] = $not."[W/'$token[1]']>";
2483
+                    	break;
2484 2484
 
2485
-                case "ETAG_STRONG":
2486
-                    $list[] = $not."['$token[1]']>";
2487
-                    break;
2485
+                	case "ETAG_STRONG":
2486
+                    	$list[] = $not."['$token[1]']>";
2487
+                    	break;
2488 2488
 
2489
-                default:
2490
-                    return false;
2489
+                	default:
2490
+                    	return false;
2491 2491
                 }
2492 2492
                 $not = "";
2493 2493
             }
Please login to merge, or discard this patch.
Braces   +700 added lines, -289 removed lines patch added patch discarded remove patch
@@ -196,7 +196,8 @@  discard block
 block discarded – undo
196 196
     function ServeRequest($prefix=null)
197 197
     {
198 198
         // prevent warning in litmus check 'delete_fragment'
199
-        if (strstr($this->_SERVER["REQUEST_URI"], '#')) {
199
+        if (strstr($this->_SERVER["REQUEST_URI"], '#'))
200
+        {
200 201
             $this->http_status("400 Bad Request");
201 202
             return;
202 203
         }
@@ -221,7 +222,8 @@  discard block
 block discarded – undo
221 222
         $path_info_raw = substr($path_info, strlen($this->_SERVER["SCRIPT_NAME"]));
222 223
 
223 224
         // just in case the path came in empty ...
224
-        if (empty($path_info_raw)) {
225
+        if (empty($path_info_raw))
226
+        {
225 227
             $path_info_raw = "/";
226 228
         }
227 229
 
@@ -245,28 +247,36 @@  discard block
 block discarded – undo
245 247
         	'#' => '%23',
246 248
         	'?' => '%3F',
247 249
         ));
248
-        if (!strlen($this->path)) {
249
-            if ($this->_SERVER["REQUEST_METHOD"] == "GET") {
250
+        if (!strlen($this->path))
251
+        {
252
+            if ($this->_SERVER["REQUEST_METHOD"] == "GET")
253
+            {
250 254
                 // redirect clients that try to GET a collection
251 255
                 // WebDAV clients should never try this while
252 256
                 // regular HTTP clients might ...
253 257
                 header("Location: ".$this->base_uri."/");
254 258
                 return;
255
-            } else {
259
+            }
260
+            else
261
+            {
256 262
                 // if a WebDAV client didn't give a path we just assume '/'
257 263
                 $this->path = "/";
258 264
             }
259 265
         }
260 266
 
261
-        if (ini_get("magic_quotes_gpc")) {
267
+        if (ini_get("magic_quotes_gpc"))
268
+        {
262 269
             $this->path = stripslashes($this->path);
263 270
         }
264 271
 
265 272
 
266 273
         // identify ourselves
267
-        if (empty($this->dav_powered_by)) {
274
+        if (empty($this->dav_powered_by))
275
+        {
268 276
             header("X-Dav-Powered-By: PHP class: ".get_class($this));
269
-        } else {
277
+        }
278
+        else
279
+        {
270 280
             header("X-Dav-Powered-By: ".$this->dav_powered_by);
271 281
         }
272 282
 
@@ -274,7 +284,8 @@  discard block
 block discarded – undo
274 284
         // for the motivation for not checking OPTIONS requests on / see
275 285
         // http://pear.php.net/bugs/bug.php?id=5363
276 286
         if ( (   !(($this->_SERVER['REQUEST_METHOD'] == 'OPTIONS') && ($this->path == "/")))
277
-             && (!$this->_check_auth())) {
287
+             && (!$this->_check_auth()))
288
+        {
278 289
             // RFC2518 says we must use Digest instead of Basic
279 290
             // but Microsoft Clients do not support Digest
280 291
             // and we don't support NTLM and Kerberos
@@ -289,7 +300,8 @@  discard block
 block discarded – undo
289 300
         }
290 301
 
291 302
         // check
292
-        if (! $this->_check_if_header_conditions()) {
303
+        if (! $this->_check_if_header_conditions())
304
+        {
293 305
             return;
294 306
         }
295 307
 
@@ -298,16 +310,24 @@  discard block
 block discarded – undo
298 310
         $wrapper = "http_".$method;
299 311
 
300 312
         // activate HEAD emulation by GET if no HEAD method found
301
-        if ($method == "head" && !method_exists($this, "head")) {
313
+        if ($method == "head" && !method_exists($this, "head"))
314
+        {
302 315
             $method = "get";
303 316
         }
304 317
 
305
-        if (method_exists($this, $wrapper) && ($method == "options" || method_exists($this, $method))) {
318
+        if (method_exists($this, $wrapper) && ($method == "options" || method_exists($this, $method)))
319
+        {
306 320
             $this->$wrapper();  // call method by name
307
-        } else { // method not found/implemented
308
-            if ($this->_SERVER["REQUEST_METHOD"] == "LOCK") {
321
+        }
322
+        else
323
+        {
324
+// method not found/implemented
325
+            if ($this->_SERVER["REQUEST_METHOD"] == "LOCK")
326
+            {
309 327
             	$error = '412 Precondition failed';
310
-            } else {
328
+            }
329
+            else
330
+            {
311 331
                 $error = '405 Method not allowed';
312 332
                 header("Allow: ".join(", ", $this->_allow()));  // tell client what's allowed
313 333
             }
@@ -612,12 +632,14 @@  discard block
 block discarded – undo
612 632
 
613 633
         // dav header
614 634
         $dav = array(1);        // assume we are always dav class 1 compliant
615
-        if (isset($allow['LOCK'])) {
635
+        if (isset($allow['LOCK']))
636
+        {
616 637
             $dav[] = 2;         // dav class 2 requires that locking is supported
617 638
         }
618 639
 
619 640
         // allow extending class to modify DAV and Allow headers
620
-		if (method_exists($this,'OPTIONS')) {
641
+		if (method_exists($this,'OPTIONS'))
642
+		{
621 643
 			$this->OPTIONS($this->path,$dav,$allow);
622 644
 		}
623 645
 
@@ -661,34 +683,48 @@  discard block
 block discarded – undo
661 683
         $options["path"] = $this->path;
662 684
 
663 685
         // search depth from header (default is "infinity)
664
-        if (isset($this->_SERVER['HTTP_DEPTH'])) {
686
+        if (isset($this->_SERVER['HTTP_DEPTH']))
687
+        {
665 688
             $options["depth"] = $this->_SERVER["HTTP_DEPTH"];
666
-        } else {
689
+        }
690
+        else
691
+        {
667 692
             $options["depth"] = "infinity";
668 693
         }
669 694
 
670 695
         // analyze request payload
671 696
         $propinfo = new _parse_propfind("php://input", $this->store_request);
672
-        if ($this->store_request) $this->request = $propinfo->request;
673
-        if (!$propinfo->success) {
697
+        if ($this->store_request)
698
+        {
699
+        	$this->request = $propinfo->request;
700
+        }
701
+        if (!$propinfo->success)
702
+        {
674 703
             $this->http_status("400 Error");
675 704
             return;
676 705
         }
677 706
 		$options['root'] = $propinfo->root;
678 707
 		$options['props'] = $propinfo->props;
679 708
 		if ($propinfo->filters)
680
-			$options['filters'] = $propinfo->filters;
709
+		{
710
+					$options['filters'] = $propinfo->filters;
711
+		}
681 712
 		if ($propinfo->other)
682
-			$options['other'] = $propinfo->other;
713
+		{
714
+					$options['other'] = $propinfo->other;
715
+		}
683 716
 
684 717
         // call user handler
685
-        if (!($retval =$this->$handler($options, $files))) {
718
+        if (!($retval =$this->$handler($options, $files)))
719
+        {
686 720
             $files = array("files" => array());
687
-            if (method_exists($this, "checkLock")) {
721
+            if (method_exists($this, "checkLock"))
722
+            {
688 723
                 // is locked?
689 724
                 $lock = $this->checkLock($this->path);
690 725
 
691
-                if (is_array($lock) && count($lock)) {
726
+                if (is_array($lock) && count($lock))
727
+                {
692 728
                     $created          = isset($lock['created'])  ? $lock['created']  : time();
693 729
                     $modified         = isset($lock['modified']) ? $lock['modified'] : time();
694 730
                     $files['files'][] = array("path"  => self::_slashify($this->path),
@@ -702,7 +738,8 @@  discard block
 block discarded – undo
702 738
                 }
703 739
             }
704 740
 
705
-            if (empty($files['files'])) {
741
+            if (empty($files['files']))
742
+            {
706 743
                 $this->http_status("404 Not Found");
707 744
                 return;
708 745
             }
@@ -736,7 +773,8 @@  discard block
 block discarded – undo
736 773
         $allow = false;
737 774
 
738 775
         // allow extending class to modify DAV
739
-		if (method_exists($this,'OPTIONS')) {
776
+		if (method_exists($this,'OPTIONS'))
777
+		{
740 778
 			$this->OPTIONS($this->path,$dav,$allow);
741 779
 		}
742 780
         header("DAV: "  .join(", ", $dav));
@@ -775,8 +813,14 @@  discard block
 block discarded – undo
775 813
      */
776 814
     function multistatus_responses(&$files, $props, $initial_ns_hash=null, $initial_ns_defs=null)
777 815
     {
778
-    	if (!isset($initial_ns_hash)) $initial_ns_hash = array('DAV:' => 'D');
779
-    	if (!isset($initial_ns_defs)) $initial_ns_defs = 'xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"';
816
+    	if (!isset($initial_ns_hash))
817
+    	{
818
+    		$initial_ns_hash = array('DAV:' => 'D');
819
+    	}
820
+    	if (!isset($initial_ns_defs))
821
+    	{
822
+    		$initial_ns_defs = 'xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"';
823
+    	}
780 824
 
781 825
     	// using an ArrayIterator to prevent foreach from copying the array,
782 826
         // as we cant loop by reference, when an iterator is given in $files
@@ -790,10 +834,12 @@  discard block
 block discarded – undo
790 834
         	isset($this->_SERVER['HTTP_PREFER']) && in_array('depth-noroot', preg_split('/, ?/', $this->_SERVER['HTTP_PREFER']));
791 835
 
792 836
         // now we loop over all returned file entries
793
-        foreach ($files as $file) {
837
+        foreach ($files as $file)
838
+        {
794 839
 
795 840
         	// skip first element (root), if requested by Prefer: depth-noroot
796
-        	if ($skip_root) {
841
+        	if ($skip_root)
842
+        	{
797 843
         		$skip_root = false;
798 844
         		continue;
799 845
         	}
@@ -805,17 +851,20 @@  discard block
 block discarded – undo
805 851
 	        $ns_defs = $initial_ns_defs;
806 852
 
807 853
             // nothing to do if no properties were returend for a file
808
-			if (isset($file["props"]) && is_array($file["props"])) {
854
+			if (isset($file["props"]) && is_array($file["props"]))
855
+			{
809 856
 
810 857
 	            // now loop over all returned properties
811
-	            foreach ($file["props"] as &$prop) {
858
+	            foreach ($file["props"] as &$prop)
859
+	            {
812 860
 	                // as a convenience feature we do not require that user handlers
813 861
 	                // restrict returned properties to the requested ones
814 862
 	                // here we strip all unrequested entries out of the response
815 863
 
816 864
 	            	// this can happen if we have allprop and prop in one propfind:
817 865
 	            	// <allprop /><prop><blah /></prop>, eg. blah is not automatic returned by allprop
818
-	                switch(is_array($props) ? $props[0] : $props) {
866
+	                switch(is_array($props) ? $props[0] : $props)
867
+	                {
819 868
 	                case "all":
820 869
 	                    // nothing to remove
821 870
 	                    break;
@@ -830,16 +879,19 @@  discard block
 block discarded – undo
830 879
 	                    $found = false;
831 880
 
832 881
 	                    // search property name in requested properties
833
-	                    foreach ((array)$props as $reqprop) {
882
+	                    foreach ((array)$props as $reqprop)
883
+	                    {
834 884
 	                        if (   $reqprop["name"]  == $prop["name"]
835
-	                               && @$reqprop["xmlns"] == $prop["ns"]) {
885
+	                               && @$reqprop["xmlns"] == $prop["ns"])
886
+	                        {
836 887
 	                            $found = true;
837 888
 	                            break;
838 889
 	                        }
839 890
 	                    }
840 891
 
841 892
 	                    // unset property and continue with next one if not found/requested
842
-	                    if (!$found) {
893
+	                    if (!$found)
894
+	                    {
843 895
 	                        $prop="";
844 896
 	                        continue(2);
845 897
 	                    }
@@ -847,10 +899,18 @@  discard block
 block discarded – undo
847 899
 	                }
848 900
 
849 901
 	                // namespace handling
850
-	                if (empty($prop["ns"])) continue; // no namespace
902
+	                if (empty($prop["ns"]))
903
+	                {
904
+	                	continue;
905
+	                }
906
+	                // no namespace
851 907
 	                $ns = $prop["ns"];
852 908
 	                //if ($ns == "DAV:") continue; // default namespace
853
-	                if (isset($ns_hash[$ns])) continue; // already known
909
+	                if (isset($ns_hash[$ns]))
910
+	                {
911
+	                	continue;
912
+	                }
913
+	                // already known
854 914
 
855 915
 	                // register namespace
856 916
 	                $ns_name = "ns".(count($ns_hash) + 1);
@@ -860,37 +920,50 @@  discard block
 block discarded – undo
860 920
 
861 921
 	            // we also need to add empty entries for properties that were requested
862 922
 	            // but for which no values where returned by the user handler
863
-	            if (is_array($props)) {
864
-	                foreach ($props as $reqprop) {
865
-	                    if (!is_array($reqprop) || $reqprop['name']=="") continue; // skip empty entries, or 'all' if <allprop /> used together with <prop>
923
+	            if (is_array($props))
924
+	            {
925
+	                foreach ($props as $reqprop)
926
+	                {
927
+	                    if (!is_array($reqprop) || $reqprop['name']=="")
928
+	                    {
929
+	                    	continue;
930
+	                    }
931
+	                    // skip empty entries, or 'all' if <allprop /> used together with <prop>
866 932
 
867 933
 	                    $found = false;
868 934
 
869 935
 	                    // check if property exists in result
870
-	                    foreach ($file["props"] as &$prop) {
936
+	                    foreach ($file["props"] as &$prop)
937
+	                    {
871 938
 	                        if (is_array($prop) && $reqprop["name"] == $prop["name"]
872
-	                               && @$reqprop["xmlns"] == $prop["ns"]) {
939
+	                               && @$reqprop["xmlns"] == $prop["ns"])
940
+	                        {
873 941
 	                            $found = true;
874 942
 	                            break;
875 943
 	                        }
876 944
 	                    }
877 945
 
878
-	                    if (!$found) {
879
-	                        if ($reqprop["xmlns"]==="DAV:" && $reqprop["name"]==="lockdiscovery") {
946
+	                    if (!$found)
947
+	                    {
948
+	                        if ($reqprop["xmlns"]==="DAV:" && $reqprop["name"]==="lockdiscovery")
949
+	                        {
880 950
 	                            // lockdiscovery is handled by the base class
881 951
 	                            $file["props"][]
882 952
 	                                = $this->mkprop("DAV:",
883 953
 	                                                "lockdiscovery",
884 954
 	                                                $this->lockdiscovery($file['path']));
885 955
 	                        // only collect $file['noprops'] if we have NO Brief: t and NO Prefer: return=minimal HTTP Header
886
-	                        } elseif ((!isset($this->_SERVER['HTTP_BRIEF']) || $this->_SERVER['HTTP_BRIEF'] != 't') &&
887
-	                        	(!isset($this->_SERVER['HTTP_PREFER']) || !in_array('return=minimal', preg_split('/, ?/', $this->_SERVER['HTTP_PREFER'])))) {
956
+	                        }
957
+	                        elseif ((!isset($this->_SERVER['HTTP_BRIEF']) || $this->_SERVER['HTTP_BRIEF'] != 't') &&
958
+	                        	(!isset($this->_SERVER['HTTP_PREFER']) || !in_array('return=minimal', preg_split('/, ?/', $this->_SERVER['HTTP_PREFER']))))
959
+	                        {
888 960
 	                            // add empty value for this property
889 961
 	                            $file["noprops"][] =
890 962
 	                                $this->mkprop($reqprop["xmlns"], $reqprop["name"], "");
891 963
 
892 964
 	                            // register property namespace if not known yet
893
-	                            if ($reqprop["xmlns"] != "DAV:" && !isset($ns_hash[$reqprop["xmlns"]])) {
965
+	                            if ($reqprop["xmlns"] != "DAV:" && !isset($ns_hash[$reqprop["xmlns"]]))
966
+	                            {
894 967
 	                                $ns_name = "ns".(count($ns_hash) + 1);
895 968
 	                                $ns_hash[$reqprop["xmlns"]] = $ns_name;
896 969
 	                                $ns_defs .= " xmlns:$ns_name=\"$reqprop[xmlns]\"";
@@ -901,9 +974,15 @@  discard block
 block discarded – undo
901 974
 	            }
902 975
 	        }
903 976
             // ignore empty or incomplete entries
904
-            if (!is_array($file) || empty($file) || !isset($file["path"])) continue;
977
+            if (!is_array($file) || empty($file) || !isset($file["path"]))
978
+            {
979
+            	continue;
980
+            }
905 981
             $path = $file['path'];
906
-            if (!is_string($path) || $path==="") continue;
982
+            if (!is_string($path) || $path==="")
983
+            {
984
+            	continue;
985
+            }
907 986
 
908 987
             if ($this->crrnd)
909 988
             {
@@ -932,38 +1011,56 @@  discard block
 block discarded – undo
932 1011
             }
933 1012
 
934 1013
             // report all found properties and their values (if any)
935
-            if (isset($file["props"]) && is_array($file["props"])) {
1014
+            if (isset($file["props"]) && is_array($file["props"]))
1015
+            {
936 1016
                 echo '   <'.($this->crrnd?'':'D:')."propstat>\n";
937 1017
                 echo '    <'.($this->crrnd?'':'D:')."prop>\n";
938 1018
 
939
-                foreach ($file["props"] as &$prop) {
1019
+                foreach ($file["props"] as &$prop)
1020
+                {
940 1021
 
941
-                    if (!is_array($prop)) continue;
942
-                    if (!isset($prop["name"])) continue;
1022
+                    if (!is_array($prop))
1023
+                    {
1024
+                    	continue;
1025
+                    }
1026
+                    if (!isset($prop["name"]))
1027
+                    {
1028
+                    	continue;
1029
+                    }
943 1030
 
944
-                    if (!isset($prop["val"]) || $prop["val"] === "" || $prop["val"] === false) {
1031
+                    if (!isset($prop["val"]) || $prop["val"] === "" || $prop["val"] === false)
1032
+                    {
945 1033
                         // empty properties (cannot use empty() for check as "0" is a legal value here)
946
-                        if ($prop["ns"]=="DAV:") {
1034
+                        if ($prop["ns"]=="DAV:")
1035
+                        {
947 1036
                             echo '     <'.($this->crrnd?'':'D:')."$prop[name]/>\n";
948
-                        } else if (!empty($prop["ns"])) {
1037
+                        }
1038
+                        else if (!empty($prop["ns"]))
1039
+                        {
949 1040
                             echo "     <".$ns_hash[$prop["ns"]].":$prop[name]/>\n";
950
-                        } else {
1041
+                        }
1042
+                        else
1043
+                        {
951 1044
                             echo "     <$prop[name] xmlns=\"\"/>";
952 1045
                         }
953 1046
                     }
954 1047
                     // multiple level of responses required for expand-property reports
955 1048
                     elseif(isset($prop['props']) && is_array($prop['val']))
956 1049
                     {
957
-                        if ($prop['ns'] && !isset($ns_hash[$prop['ns']])) {
1050
+                        if ($prop['ns'] && !isset($ns_hash[$prop['ns']]))
1051
+                        {
958 1052
                             $ns_name = "ns".(count($ns_hash) + 1);
959 1053
                             $ns_hash[$prop['ns']] = $ns_name;
960 1054
                         }
961 1055
                     	echo '     <'.$ns_hash[$prop['ns']].":$prop[name]>\n";
962 1056
                         $this->multistatus_responses($prop['val'], $prop['props'], $ns_hash, '');
963 1057
                     	echo '     </'.$ns_hash[$prop['ns']].":$prop[name]>\n";
964
-                    } else if ($prop["ns"] == "DAV:") {
1058
+                    }
1059
+                    else if ($prop["ns"] == "DAV:")
1060
+                    {
965 1061
                         // some WebDAV properties need special treatment
966
-                        switch ($prop["name"]) {
1062
+                        switch ($prop["name"])
1063
+                        {
967 1064
                         case "creationdate":
968 1065
                             echo '     <'.($this->crrnd?'':'D:')."creationdate ns0:dt=\"dateTime.tz\">"
969 1066
                                 . gmdate("Y-m-d\\TH:i:s\\Z", $prop['val'])
@@ -999,40 +1096,57 @@  discard block
 block discarded – undo
999 1096
                             {
1000 1097
                             	$hns_hash = $ns_hash;
1001 1098
                             	$val = $this->_hierarchical_prop_encode($prop['val'], 'DAV:', $ns_defs, $hns_hash);
1002
-                            } elseif (isset($prop['raw'])) {
1099
+                            }
1100
+                            elseif (isset($prop['raw']))
1101
+                            {
1003 1102
                             	$val = $this->_prop_encode('<![CDATA['.$prop['val'].']]>');
1004
-                            } else {
1103
+                            }
1104
+                            else
1105
+                            {
1005 1106
 	                    		$val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8'));
1006 1107
                             }
1007 1108
 	                        echo '     <'.($this->crrnd?'':'D:')."$prop[name]$ns_defs>$val".
1008 1109
 	                        	'</'.($this->crrnd?'':'D:')."$prop[name]>\n";
1009 1110
                             break;
1010 1111
                         }
1011
-                    } else {
1112
+                    }
1113
+                    else
1114
+                    {
1012 1115
                         // allow multiple values and attributes, required eg. for caldav:supported-calendar-component-set
1013
-                        if ($prop['ns'] && is_array($prop['val'])) {
1014
-                    		if (!isset($ns_hash[$prop['ns']])) {
1116
+                        if ($prop['ns'] && is_array($prop['val']))
1117
+                        {
1118
+                    		if (!isset($ns_hash[$prop['ns']]))
1119
+                    		{
1015 1120
                                 $ns_name = "ns".(count($ns_hash) + 1);
1016 1121
                                 $ns_hash[$prop['ns']] = $ns_name;
1017 1122
                     		}
1018 1123
                   			$vals = $extra_ns = '';
1019 1124
                     		foreach($prop['val'] as $subprop)
1020 1125
                     		{
1021
-                    			if ($subprop['ns'] && $subprop['ns'] != 'DAV:') {
1126
+                    			if ($subprop['ns'] && $subprop['ns'] != 'DAV:')
1127
+                    			{
1022 1128
 		                    		// register property namespace if not known yet
1023
-		                    		if (!isset($ns_hash[$subprop['ns']])) {
1129
+		                    		if (!isset($ns_hash[$subprop['ns']]))
1130
+		                    		{
1024 1131
 			                    		$ns_name = "ns".(count($ns_hash) + 1);
1025 1132
 			                    		$ns_hash[$subprop['ns']] = $ns_name;
1026
-		                    		} else {
1133
+		                    		}
1134
+		                    		else
1135
+		                    		{
1027 1136
 			                    		$ns_name = $ns_hash[$subprop['ns']];
1028 1137
 		                    		}
1029
-		                    		if (strchr($extra_ns,$extra=' xmlns:'.$ns_name.'="'.$subprop['ns'].'"') === false) {
1138
+		                    		if (strchr($extra_ns,$extra=' xmlns:'.$ns_name.'="'.$subprop['ns'].'"') === false)
1139
+		                    		{
1030 1140
 			                    		$extra_ns .= $extra;
1031 1141
 		                    		}
1032 1142
 		                    		$ns_name .= ':';
1033
-	                    		} elseif ($subprop['ns'] == 'DAV:') {
1143
+	                    		}
1144
+	                    		elseif ($subprop['ns'] == 'DAV:')
1145
+	                    		{
1034 1146
 		                    		$ns_name = 'D:';
1035
-	                    		} else {
1147
+	                    		}
1148
+	                    		else
1149
+	                    		{
1036 1150
 		                    		$ns_name = '';
1037 1151
 	                    		}
1038 1152
 	                    		$vals .= "<$ns_name$subprop[name]";
@@ -1047,7 +1161,7 @@  discard block
 block discarded – undo
1047 1161
 	                    			else	// val contains only attributes, no value
1048 1162
 	                    			{
1049 1163
 			                    		foreach($subprop['val'] as $attr => $val)
1050
-										{
1164
+			                    		{
1051 1165
 				                    		$vals .= ' '.$attr.'="'.htmlspecialchars($val, ENT_NOQUOTES, 'utf-8').'"';
1052 1166
 										}
1053 1167
 			                    		$vals .= '/>';
@@ -1056,34 +1170,50 @@  discard block
 block discarded – undo
1056 1170
 	                    		else
1057 1171
 	                    		{
1058 1172
 	                    			$vals .= '>';
1059
-	                    			if (isset($subprop['raw'])) {
1173
+	                    			if (isset($subprop['raw']))
1174
+	                    			{
1060 1175
 	                    				$vals .= '<![CDATA['.$subprop['val'].']]>';
1061
-	                    			} else {
1062
-	                    				if($subprop['name'] == 'href') $subprop['val'] = $this->_urlencode($subprop['val']);
1176
+	                    			}
1177
+	                    			else
1178
+	                    			{
1179
+	                    				if($subprop['name'] == 'href')
1180
+	                    				{
1181
+	                    					$subprop['val'] = $this->_urlencode($subprop['val']);
1182
+	                    				}
1063 1183
 		                    			$vals .= htmlspecialchars($subprop['val'], ENT_NOQUOTES, 'utf-8');
1064 1184
 	                    			}
1065 1185
 	                    			$vals .= "</$ns_name$subprop[name]>";
1066 1186
 	                    		}
1067 1187
                     		}
1068 1188
                     		echo '     <'.$ns_hash[$prop['ns']].":$prop[name]$extra_ns>$vals</".$ns_hash[$prop['ns']].":$prop[name]>\n";
1069
-                        } else {
1189
+                        }
1190
+                        else
1191
+                        {
1070 1192
                         	if ($prop['raw'])
1071 1193
                         	{
1072 1194
                         		$val = '<![CDATA['.$prop['val'].']]>';
1073
-                        	} else {
1195
+                        	}
1196
+                        	else
1197
+                        	{
1074 1198
                         		$val = htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8');
1075 1199
                         	}
1076 1200
                         	$val = $this->_prop_encode($val);
1077 1201
 	                        // properties from namespaces != "DAV:" or without any namespace
1078
-	                        if ($prop['ns']) {
1079
-		                        if ($this->crrnd) {
1202
+	                        if ($prop['ns'])
1203
+	                        {
1204
+		                        if ($this->crrnd)
1205
+		                        {
1080 1206
 			                        echo "     <$prop[name] xmlns=".'"'.$prop["ns"].'">'
1081 1207
 									. $val . "</$prop[name]>\n";
1082
-		                        } else {
1208
+		                        }
1209
+		                        else
1210
+		                        {
1083 1211
 			                        echo "     <" . $ns_hash[$prop["ns"]] . ":$prop[name]>"
1084 1212
 									. $val . '</'.$ns_hash[$prop['ns']].":$prop[name]>\n";
1085 1213
 		                        }
1086
-	                        } else {
1214
+	                        }
1215
+	                        else
1216
+	                        {
1087 1217
 		                        echo "     <$prop[name] xmlns=\"\">$val</$prop[name]>\n";
1088 1218
 	                        }
1089 1219
                         }
@@ -1105,16 +1235,23 @@  discard block
 block discarded – undo
1105 1235
             }
1106 1236
 
1107 1237
             // now report all properties requested but not found
1108
-            if (isset($file["noprops"])) {
1238
+            if (isset($file["noprops"]))
1239
+            {
1109 1240
                 echo '   <'.($this->crrnd?'':'D:')."propstat>\n";
1110 1241
                 echo '    <'.($this->crrnd?'':'D:')."prop>\n";
1111 1242
 
1112
-                foreach ($file["noprops"] as &$prop) {
1113
-                    if ($prop["ns"] == "DAV:") {
1243
+                foreach ($file["noprops"] as &$prop)
1244
+                {
1245
+                    if ($prop["ns"] == "DAV:")
1246
+                    {
1114 1247
                         echo '     <'.($this->crrnd?'':'D:')."$prop[name]/>\n";
1115
-                    } else if ($prop["ns"] == "") {
1248
+                    }
1249
+                    else if ($prop["ns"] == "")
1250
+                    {
1116 1251
                         echo "     <$prop[name] xmlns=\"\"/>\n";
1117
-                    } else {
1252
+                    }
1253
+                    else
1254
+                    {
1118 1255
                         echo "     <" . $ns_hash[$prop["ns"]] . ":$prop[name]/>\n";
1119 1256
                     }
1120 1257
                 }
@@ -1163,15 +1300,20 @@  discard block
 block discarded – undo
1163 1300
      */
1164 1301
     function http_PROPPATCH()
1165 1302
     {
1166
-        if ($this->_check_lock_status($this->path)) {
1303
+        if ($this->_check_lock_status($this->path))
1304
+        {
1167 1305
             $options = Array();
1168 1306
 
1169 1307
             $options["path"] = $this->path;
1170 1308
 
1171 1309
             $propinfo = new _parse_proppatch("php://input", $this->store_request);
1172
-            if ($this->store_request) $this->request = $propinfo->request;
1310
+            if ($this->store_request)
1311
+            {
1312
+            	$this->request = $propinfo->request;
1313
+            }
1173 1314
 
1174
-            if (!$propinfo->success) {
1315
+            if (!$propinfo->success)
1316
+            {
1175 1317
                 $this->http_status("400 Error");
1176 1318
                 return;
1177 1319
             }
@@ -1189,14 +1331,16 @@  discard block
 block discarded – undo
1189 1331
             echo ' <'.($this->crrnd?'':'D:')."response>\n";
1190 1332
             echo '  <'.($this->crrnd?'':'D:')."href>".$this->_urlencode($this->_mergePaths($this->_SERVER["SCRIPT_NAME"], $this->path)).'</'.($this->crrnd?'':'D:')."href>\n";
1191 1333
 
1192
-            foreach ($options["props"] as $prop) {
1334
+            foreach ($options["props"] as $prop)
1335
+            {
1193 1336
                 echo '   <'.($this->crrnd?'':'D:')."propstat>\n";
1194 1337
                 echo '    <'.($this->crrnd?'':'D:')."prop><$prop[name] xmlns=\"$prop[ns]\"/></".($this->crrnd?'':'D:')."prop>\n";
1195 1338
                 echo '    <'.($this->crrnd?'':'D:')."status>HTTP/1.1 $prop[status]</".($this->crrnd?'':'D:')."status>\n";
1196 1339
                 echo '   </'.($this->crrnd?'':'D:')."propstat>\n";
1197 1340
             }
1198 1341
 
1199
-            if ($responsedescr) {
1342
+            if ($responsedescr)
1343
+            {
1200 1344
                 echo '  <'.($this->crrnd?'':'D:')."responsedescription>".
1201 1345
                     $this->_prop_encode(htmlspecialchars($responsedescr, ENT_NOQUOTES, 'utf-8')).
1202 1346
                     '</'.($this->crrnd?'':'D:')."responsedescription>\n";
@@ -1204,7 +1348,9 @@  discard block
 block discarded – undo
1204 1348
 
1205 1349
             echo ' </'.($this->crrnd?'':'D:')."response>\n";
1206 1350
             echo '</'.($this->crrnd?'':'D:')."multistatus>\n";
1207
-        } else {
1351
+        }
1352
+        else
1353
+        {
1208 1354
             $this->http_status("423 Locked");
1209 1355
         }
1210 1356
     }
@@ -1274,11 +1420,14 @@  discard block
 block discarded – undo
1274 1420
 
1275 1421
         $this->_get_ranges($options);
1276 1422
 
1277
-        if (true === ($status = $this->GET($options))) {
1278
-            if (!headers_sent()) {
1423
+        if (true === ($status = $this->GET($options)))
1424
+        {
1425
+            if (!headers_sent())
1426
+            {
1279 1427
                 $status = "200 OK";
1280 1428
 
1281
-                if (!isset($options['mimetype'])) {
1429
+                if (!isset($options['mimetype']))
1430
+                {
1282 1431
                     $options['mimetype'] = "application/octet-stream";
1283 1432
                 }
1284 1433
                 // switching off zlib.output_compression for everything but text files,
@@ -1290,7 +1439,8 @@  discard block
 block discarded – undo
1290 1439
                 }
1291 1440
                 header("Content-type: $options[mimetype]");
1292 1441
 
1293
-                if (isset($options['mtime'])) {
1442
+                if (isset($options['mtime']))
1443
+                {
1294 1444
                     header("Last-modified:".gmdate("D, d M Y H:i:s ", $options['mtime'])."GMT");
1295 1445
                 }
1296 1446
                 // fix for IE and https, thanks to [email protected]
@@ -1299,55 +1449,82 @@  discard block
 block discarded – undo
1299 1449
 				header("Cache-Control: maxage=1"); //In seconds
1300 1450
 				header("Pragma: public");
1301 1451
 
1302
-                if (isset($options['stream'])) {
1452
+                if (isset($options['stream']))
1453
+                {
1303 1454
                     // GET handler returned a stream
1304
-                    if (!empty($options['ranges']) && (0===fseek($options['stream'], 0, SEEK_SET))) {
1455
+                    if (!empty($options['ranges']) && (0===fseek($options['stream'], 0, SEEK_SET)))
1456
+                    {
1305 1457
                         // partial request and stream is seekable
1306 1458
 
1307
-                        if (count($options['ranges']) === 1) {
1459
+                        if (count($options['ranges']) === 1)
1460
+                        {
1308 1461
                             $range = $options['ranges'][0];
1309 1462
 
1310
-                            if (isset($range['start'])) {
1463
+                            if (isset($range['start']))
1464
+                            {
1311 1465
                                 fseek($options['stream'], $range['start'], SEEK_SET);
1312
-                                if (feof($options['stream'])) {
1466
+                                if (feof($options['stream']))
1467
+                                {
1313 1468
                                     $this->http_status("416 Requested range not satisfiable");
1314 1469
                                     return;
1315 1470
                                 }
1316 1471
 
1317
-                                if (!empty($range['end'])) {
1472
+                                if (!empty($range['end']))
1473
+                                {
1318 1474
                                     $size = $range['end']-$range['start']+1;
1319 1475
                                     $this->http_status("206 Partial content");
1320
-                                    if (!self::use_compression()) header("Content-Length: $size");
1476
+                                    if (!self::use_compression())
1477
+                                    {
1478
+                                    	header("Content-Length: $size");
1479
+                                    }
1321 1480
                                     header("Content-Range: bytes $range[start]-$range[end]/"
1322 1481
                                            . (isset($options['size']) ? $options['size'] : "*"));
1323
-                                    while ($size > 0 && !feof($options['stream'])) {
1482
+                                    while ($size > 0 && !feof($options['stream']))
1483
+                                    {
1324 1484
                                         $buffer = fread($options['stream'], $size < 8192 ? $size : 8192);
1325 1485
                                         $size  -= self::bytes($buffer);
1326 1486
                                         echo $buffer;
1327 1487
                                     }
1328
-                                } else {
1488
+                                }
1489
+                                else
1490
+                                {
1329 1491
                                     $this->http_status("206 Partial content");
1330
-                                    if (isset($options['size'])) {
1331
-                                        if (!self::use_compression()) header("Content-Length: ".($options['size'] - $range['start']));
1492
+                                    if (isset($options['size']))
1493
+                                    {
1494
+                                        if (!self::use_compression())
1495
+                                        {
1496
+                                        	header("Content-Length: ".($options['size'] - $range['start']));
1497
+                                        }
1332 1498
                                         header("Content-Range: bytes ".$range['start']."-".
1333 1499
 											(isset($options['size']) ? $options['size']-1 : "")."/"
1334 1500
 										   . (isset($options['size']) ? $options['size'] : "*"));
1335 1501
                                     }
1336 1502
                                     fpassthru($options['stream']);
1337 1503
                                 }
1338
-                            } else {
1339
-                                if (!self::use_compression()) header("Content-length: ".$range['last']);
1504
+                            }
1505
+                            else
1506
+                            {
1507
+                                if (!self::use_compression())
1508
+                                {
1509
+                                	header("Content-length: ".$range['last']);
1510
+                                }
1340 1511
                                 fseek($options['stream'], -$range['last'], SEEK_END);
1341 1512
                                 fpassthru($options['stream']);
1342 1513
                             }
1343
-                        } else {
1514
+                        }
1515
+                        else
1516
+                        {
1344 1517
                             $this->_multipart_byterange_header(); // init multipart
1345
-                            foreach ($options['ranges'] as $range) {
1518
+                            foreach ($options['ranges'] as $range)
1519
+                            {
1346 1520
                                 // TODO what if size unknown? 500?
1347
-                                if (isset($range['start'])) {
1521
+                                if (isset($range['start']))
1522
+                                {
1348 1523
                                     $from = $range['start'];
1349 1524
                                     $to   = !empty($range['end']) ? $range['end'] : $options['size']-1;
1350
-                                } else {
1525
+                                }
1526
+                                else
1527
+                                {
1351 1528
                                     $from = $options['size'] - $range['last']-1;
1352 1529
                                     $to   = $options['size'] -1;
1353 1530
                                 }
@@ -1357,7 +1534,8 @@  discard block
 block discarded – undo
1357 1534
 
1358 1535
 
1359 1536
                                 fseek($options['stream'], $from, SEEK_SET);
1360
-                                while ($size && !feof($options['stream'])) {
1537
+                                while ($size && !feof($options['stream']))
1538
+                                {
1361 1539
                                     $buffer = fread($options['stream'], 4096);
1362 1540
                                     $size  -= self::bytes($buffer);
1363 1541
                                     echo $buffer;
@@ -1365,29 +1543,44 @@  discard block
 block discarded – undo
1365 1543
                             }
1366 1544
                             $this->_multipart_byterange_header(); // end multipart
1367 1545
                         }
1368
-                    } else {
1546
+                    }
1547
+                    else
1548
+                    {
1369 1549
                         // normal request or stream isn't seekable, return full content
1370
-                        if (isset($options['size']) && !self::use_compression()) {
1550
+                        if (isset($options['size']) && !self::use_compression())
1551
+                        {
1371 1552
                             header("Content-Length: ".$options['size']);
1372 1553
                         }
1373 1554
                         fpassthru($options['stream']);
1374 1555
                         return; // no more headers
1375 1556
                     }
1376
-                } elseif (isset($options['data'])) {
1377
-                    if (is_array($options['data'])) {
1557
+                }
1558
+                elseif (isset($options['data']))
1559
+                {
1560
+                    if (is_array($options['data']))
1561
+                    {
1378 1562
                         // reply to partial request
1379
-                    } else {
1380
-                        if (!self::use_compression()) header("Content-Length: ".self::bytes($options['data']));
1563
+                    }
1564
+                    else
1565
+                    {
1566
+                        if (!self::use_compression())
1567
+                        {
1568
+                        	header("Content-Length: ".self::bytes($options['data']));
1569
+                        }
1381 1570
                         echo $options['data'];
1382 1571
                     }
1383 1572
                 }
1384 1573
             }
1385 1574
         }
1386 1575
 
1387
-        if (!headers_sent()) {
1388
-            if (false === $status) {
1576
+        if (!headers_sent())
1577
+        {
1578
+            if (false === $status)
1579
+            {
1389 1580
                 $this->http_status("404 not found");
1390
-            } else {
1581
+            }
1582
+            else
1583
+            {
1391 1584
                 // TODO: check setting of headers in various code paths above
1392 1585
                 $this->http_status("$status");
1393 1586
             }
@@ -1404,15 +1597,18 @@  discard block
 block discarded – undo
1404 1597
     function _get_ranges(&$options)
1405 1598
     {
1406 1599
         // process Range: header if present
1407
-        if (isset($this->_SERVER['HTTP_RANGE'])) {
1600
+        if (isset($this->_SERVER['HTTP_RANGE']))
1601
+        {
1408 1602
 
1409 1603
             // we only support standard "bytes" range specifications for now
1410 1604
 			$matches = null;
1411
-            if (preg_match('/bytes\s*=\s*(.+)/', $this->_SERVER['HTTP_RANGE'], $matches)) {
1605
+            if (preg_match('/bytes\s*=\s*(.+)/', $this->_SERVER['HTTP_RANGE'], $matches))
1606
+            {
1412 1607
                 $options["ranges"] = array();
1413 1608
 
1414 1609
                 // ranges are comma separated
1415
-                foreach (explode(",", $matches[1]) as $range) {
1610
+                foreach (explode(",", $matches[1]) as $range)
1611
+                {
1416 1612
                     // ranges are either from-to pairs or just end positions
1417 1613
                     list($start, $end) = explode("-", $range);
1418 1614
                     $options["ranges"][] = ($start==="")
@@ -1438,8 +1634,10 @@  discard block
 block discarded – undo
1438 1634
      */
1439 1635
     function _multipart_byterange_header($mimetype = false, $from = false, $to=false, $total=false)
1440 1636
     {
1441
-        if ($mimetype === false) {
1442
-            if (!isset($this->multipart_separator)) {
1637
+        if ($mimetype === false)
1638
+        {
1639
+            if (!isset($this->multipart_separator))
1640
+            {
1443 1641
                 // initial
1444 1642
 
1445 1643
                 // a little naive, this sequence *might* be part of the content
@@ -1448,13 +1646,17 @@  discard block
 block discarded – undo
1448 1646
 
1449 1647
                 // generate HTTP header
1450 1648
                 header("Content-type: multipart/byteranges; boundary=".$this->multipart_separator);
1451
-            } else {
1649
+            }
1650
+            else
1651
+            {
1452 1652
                 // final
1453 1653
 
1454 1654
                 // generate closing multipart sequence
1455 1655
                 echo "\n--{$this->multipart_separator}--";
1456 1656
             }
1457
-        } else {
1657
+        }
1658
+        else
1659
+        {
1458 1660
             // generate separator and header for next part
1459 1661
             echo "\n--{$this->multipart_separator}\n";
1460 1662
             echo "Content-type: $mimetype\n";
@@ -1481,32 +1683,45 @@  discard block
 block discarded – undo
1481 1683
         $options         = Array();
1482 1684
         $options["path"] = $this->path;
1483 1685
 
1484
-        if (method_exists($this, "HEAD")) {
1686
+        if (method_exists($this, "HEAD"))
1687
+        {
1485 1688
             $status = $this->head($options);
1486
-        } else if (method_exists($this, "GET")) {
1689
+        }
1690
+        else if (method_exists($this, "GET"))
1691
+        {
1487 1692
             ob_start();
1488 1693
             $status = $this->GET($options);
1489
-            if (!isset($options['size'])) {
1694
+            if (!isset($options['size']))
1695
+            {
1490 1696
                 $options['size'] = ob_get_length();
1491 1697
             }
1492 1698
             ob_end_clean();
1493 1699
         }
1494 1700
 
1495
-        if (!isset($options['mimetype'])) {
1701
+        if (!isset($options['mimetype']))
1702
+        {
1496 1703
             $options['mimetype'] = "application/octet-stream";
1497 1704
         }
1498 1705
         header("Content-type: $options[mimetype]");
1499 1706
 
1500
-        if (isset($options['mtime'])) {
1707
+        if (isset($options['mtime']))
1708
+        {
1501 1709
             header("Last-modified:".gmdate("D, d M Y H:i:s ", $options['mtime'])."GMT");
1502 1710
         }
1503 1711
 
1504
-        if (isset($options['size'])) {
1712
+        if (isset($options['size']))
1713
+        {
1505 1714
             header("Content-Length: ".$options['size']);
1506 1715
         }
1507 1716
 
1508
-        if ($status === true)  $status = "200 OK";
1509
-        if ($status === false) $status = "404 Not found";
1717
+        if ($status === true)
1718
+        {
1719
+        	$status = "200 OK";
1720
+        }
1721
+        if ($status === false)
1722
+        {
1723
+        	$status = "404 Not found";
1724
+        }
1510 1725
 
1511 1726
         $this->http_status($status);
1512 1727
     }
@@ -1532,21 +1747,25 @@  discard block
 block discarded – undo
1532 1747
 	        $options['content_length'] = $this->_SERVER['CONTENT_LENGTH'];
1533 1748
         }
1534 1749
         elseif (isset($this->_SERVER['X-Expected-Entity-Length']))
1535
-		{
1750
+        {
1536 1751
 	        // MacOS gives us that hint
1537 1752
 	        $options['content_length'] = $this->_SERVER['X-Expected-Entity-Length'];
1538 1753
 		}
1539 1754
 
1540 1755
         // get the Content-type
1541
-        if (isset($this->_SERVER["CONTENT_TYPE"])) {
1756
+        if (isset($this->_SERVER["CONTENT_TYPE"]))
1757
+        {
1542 1758
 	        // for now we do not support any sort of multipart requests
1543
-	        if (!strncmp($this->_SERVER["CONTENT_TYPE"], 'multipart/', 10)) {
1759
+	        if (!strncmp($this->_SERVER["CONTENT_TYPE"], 'multipart/', 10))
1760
+	        {
1544 1761
 		        $this->http_status('501 not implemented');
1545 1762
 		        echo 'The service does not support mulipart POST requests';
1546 1763
 		        return;
1547 1764
 	        }
1548 1765
 	        $options['content_type'] = $this->_SERVER['CONTENT_TYPE'];
1549
-        } else {
1766
+        }
1767
+        else
1768
+        {
1550 1769
 	        // default content type if none given
1551 1770
 	        $options['content_type'] = 'application/octet-stream';
1552 1771
         }
@@ -1557,7 +1776,7 @@  discard block
 block discarded – undo
1557 1776
     		case 'gzip':
1558 1777
     		case 'deflate':	//zlib
1559 1778
     			if (extension_loaded('zlib'))
1560
-     			{
1779
+    			{
1561 1780
       				stream_filter_append($options['stream'], 'zlib.inflate', STREAM_FILTER_READ);
1562 1781
        			}
1563 1782
     	}
@@ -1578,15 +1797,23 @@  discard block
 block discarded – undo
1578 1797
          does not understand or implement and MUST return a 501
1579 1798
          (Not Implemented) response in such cases."
1580 1799
          */
1581
-        foreach ($this->_SERVER as $key => $val) {
1582
-	        if (strncmp($key, 'HTTP_CONTENT', 11)) continue;
1583
-	        switch ($key) {
1800
+        foreach ($this->_SERVER as $key => $val)
1801
+        {
1802
+	        if (strncmp($key, 'HTTP_CONTENT', 11))
1803
+	        {
1804
+	        	continue;
1805
+	        }
1806
+	        switch ($key)
1807
+	        {
1584 1808
 		        case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11
1585 1809
 		        	switch($this->_SERVER['HTTP_CONTENT_ENCODING'])
1586 1810
 		        	{
1587 1811
 		        		case 'gzip':
1588 1812
 		        		case 'deflate':	//zlib
1589
-		        			if (extension_loaded('zlib')) break;
1813
+		        			if (extension_loaded('zlib'))
1814
+		        			{
1815
+		        				break;
1816
+		        			}
1590 1817
 		        			// fall through for no zlib support
1591 1818
 		        		default:
1592 1819
 					        $this->http_status('415 Unsupported Media Type');
@@ -1616,14 +1843,16 @@  discard block
 block discarded – undo
1616 1843
 			        // the header format is also specified in RFC 2616 14.16
1617 1844
 			        // TODO we have to ensure that implementations support this or send 501 instead
1618 1845
 					$matches = null;
1619
-			        if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
1846
+			        if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches))
1847
+			        {
1620 1848
 				        $this->http_status('400 bad request');
1621 1849
 				        echo 'The service does only support single byte ranges';
1622 1850
 				        return;
1623 1851
 			        }
1624 1852
 
1625 1853
 			        $range = array('start'=>$matches[1], 'end'=>$matches[2]);
1626
-			        if (is_numeric($matches[3])) {
1854
+			        if (is_numeric($matches[3]))
1855
+			        {
1627 1856
 				        $range['total_length'] = $matches[3];
1628 1857
 			        }
1629 1858
 			        $options['ranges'][] = $range;
@@ -1655,31 +1884,46 @@  discard block
 block discarded – undo
1655 1884
 	        }
1656 1885
         }
1657 1886
 
1658
-        if (method_exists($this, 'POST')) {
1887
+        if (method_exists($this, 'POST'))
1888
+        {
1659 1889
 	        $status = $this->POST($options);
1660 1890
 
1661
-	        if ($status === false) {
1891
+	        if ($status === false)
1892
+	        {
1662 1893
 		        $status = '400 Something went wrong';
1663
-	        } else if ($status === true) {
1894
+	        }
1895
+	        else if ($status === true)
1896
+	        {
1664 1897
 	        	$status = '200 OK';
1665
-	        } else if (is_resource($status) && get_resource_type($status) == 'stream') {
1898
+	        }
1899
+	        else if (is_resource($status) && get_resource_type($status) == 'stream')
1900
+	        {
1666 1901
 		        $stream = $status;
1667 1902
 
1668 1903
 		        $status = empty($options['new']) ? '200 OK' : '201 Created';
1669 1904
 
1670
-		        if (!empty($options['ranges'])) {
1905
+		        if (!empty($options['ranges']))
1906
+		        {
1671 1907
 			        // TODO multipart support is missing (see also above)
1672
-			        if (0 == fseek($stream, $range[0]['start'], SEEK_SET)) {
1908
+			        if (0 == fseek($stream, $range[0]['start'], SEEK_SET))
1909
+			        {
1673 1910
 				        $length = $range[0]['end']-$range[0]['start']+1;
1674
-				        if (!fwrite($stream, fread($options['stream'], $length))) {
1911
+				        if (!fwrite($stream, fread($options['stream'], $length)))
1912
+				        {
1675 1913
 					        $status = '403 Forbidden';
1676 1914
 				        }
1677
-			        } else {
1915
+			        }
1916
+			        else
1917
+			        {
1678 1918
 				        $status = '403 Forbidden';
1679 1919
 			        }
1680
-		        } else {
1681
-			        while (!feof($options['stream'])) {
1682
-				        if (false === fwrite($stream, fread($options['stream'], 4096))) {
1920
+		        }
1921
+		        else
1922
+		        {
1923
+			        while (!feof($options['stream']))
1924
+			        {
1925
+				        if (false === fwrite($stream, fread($options['stream'], 4096)))
1926
+				        {
1683 1927
 					        $status = '403 Forbidden';
1684 1928
 					        break;
1685 1929
 				        }
@@ -1703,7 +1947,8 @@  discard block
 block discarded – undo
1703 1947
      */
1704 1948
     function http_PUT()
1705 1949
     {
1706
-        if ($this->_check_lock_status($this->path)) {
1950
+        if ($this->_check_lock_status($this->path))
1951
+        {
1707 1952
             $options                   = Array();
1708 1953
             $options["path"]           = $this->path;
1709 1954
 
@@ -1718,15 +1963,19 @@  discard block
 block discarded – undo
1718 1963
             }
1719 1964
 
1720 1965
             // get the Content-type
1721
-            if (isset($this->_SERVER["CONTENT_TYPE"])) {
1966
+            if (isset($this->_SERVER["CONTENT_TYPE"]))
1967
+            {
1722 1968
                 // for now we do not support any sort of multipart requests
1723
-                if (!strncmp($this->_SERVER["CONTENT_TYPE"], "multipart/", 10)) {
1969
+                if (!strncmp($this->_SERVER["CONTENT_TYPE"], "multipart/", 10))
1970
+                {
1724 1971
                     $this->http_status("501 not implemented");
1725 1972
                     echo "The service does not support multipart PUT requests";
1726 1973
                     return;
1727 1974
                 }
1728 1975
                 $options["content_type"] = $this->_SERVER["CONTENT_TYPE"];
1729
-            } else {
1976
+            }
1977
+            else
1978
+            {
1730 1979
                 // default content type if none given
1731 1980
                 $options["content_type"] = "application/octet-stream";
1732 1981
             }
@@ -1737,7 +1986,7 @@  discard block
 block discarded – undo
1737 1986
 	    		case 'gzip':
1738 1987
 	    		case 'deflate':	//zlib
1739 1988
 	    			if (extension_loaded('zlib'))
1740
-	     			{
1989
+	    			{
1741 1990
 	      				stream_filter_append($options['stream'], 'zlib.inflate', STREAM_FILTER_READ);
1742 1991
 	       			}
1743 1992
 	    	}
@@ -1758,15 +2007,23 @@  discard block
 block discarded – undo
1758 2007
              does not understand or implement and MUST return a 501
1759 2008
              (Not Implemented) response in such cases."
1760 2009
             */
1761
-            foreach ($this->_SERVER as $key => $val) {
1762
-                if (strncmp($key, "HTTP_CONTENT", 11)) continue;
1763
-                switch ($key) {
2010
+            foreach ($this->_SERVER as $key => $val)
2011
+            {
2012
+                if (strncmp($key, "HTTP_CONTENT", 11))
2013
+                {
2014
+                	continue;
2015
+                }
2016
+                switch ($key)
2017
+                {
1764 2018
                 case 'HTTP_CONTENT_ENCODING': // RFC 2616 14.11
1765 2019
 		        	switch($this->_SERVER['HTTP_CONTENT_ENCODING'])
1766 2020
 		        	{
1767 2021
 		        		case 'gzip':
1768 2022
 		        		case 'deflate':	//zlib
1769
-		        			if (extension_loaded('zlib')) break;
2023
+		        			if (extension_loaded('zlib'))
2024
+		        			{
2025
+		        				break;
2026
+		        			}
1770 2027
 		        			// fall through for no zlib support
1771 2028
 		        		default:
1772 2029
 					        $this->http_status('415 Unsupported Media Type');
@@ -1796,18 +2053,21 @@  discard block
 block discarded – undo
1796 2053
                     // the header format is also specified in RFC 2616 14.16
1797 2054
                     // TODO we have to ensure that implementations support this or send 501 instead
1798 2055
 					$matches = null;
1799
-                    if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches)) {
2056
+                    if (!preg_match('@bytes\s+(\d+)-(\d+)/((\d+)|\*)@', $val, $matches))
2057
+                    {
1800 2058
                         $this->http_status("400 bad request");
1801 2059
                         echo "The service does only support single byte ranges";
1802 2060
                         return;
1803 2061
                     }
1804 2062
 
1805 2063
                     $range = array("start" => $matches[1], "end" => $matches[2]);
1806
-                    if (is_numeric($matches[3])) {
2064
+                    if (is_numeric($matches[3]))
2065
+                    {
1807 2066
                         $range["total_length"] = $matches[3];
1808 2067
                     }
1809 2068
 
1810
-                    if (!isset($options['ranges'])) {
2069
+                    if (!isset($options['ranges']))
2070
+                    {
1811 2071
                         $options['ranges'] = array();
1812 2072
                     }
1813 2073
 
@@ -1838,45 +2098,65 @@  discard block
 block discarded – undo
1838 2098
 
1839 2099
             $stat = $this->PUT($options);
1840 2100
 
1841
-            if ($stat === false) {
2101
+            if ($stat === false)
2102
+            {
1842 2103
                 $stat = "403 Forbidden";
1843
-            } else if (is_resource($stat) && get_resource_type($stat) == "stream") {
2104
+            }
2105
+            else if (is_resource($stat) && get_resource_type($stat) == "stream")
2106
+            {
1844 2107
                 $stream = $stat;
1845 2108
 
1846 2109
                 $stat = $options["new"] ? "201 Created" : "204 No Content";
1847 2110
 
1848
-                if (!empty($options["ranges"])) {
2111
+                if (!empty($options["ranges"]))
2112
+                {
1849 2113
                     // TODO multipart support is missing (see also above)
1850
-                    if (0 == fseek($stream, $options['ranges'][0]["start"], SEEK_SET)) {
2114
+                    if (0 == fseek($stream, $options['ranges'][0]["start"], SEEK_SET))
2115
+                    {
1851 2116
                         $length = $options['ranges'][0]["end"] - $options['ranges'][0]["start"]+1;
1852 2117
 
1853
-                        while (!feof($options['stream'])) {
1854
-                            if ($length <= 0) {
2118
+                        while (!feof($options['stream']))
2119
+                        {
2120
+                            if ($length <= 0)
2121
+                            {
1855 2122
                                break;
1856 2123
                             }
1857 2124
 
1858
-                            if ($length <= 8192) {
2125
+                            if ($length <= 8192)
2126
+                            {
1859 2127
                                 $data = fread($options['stream'], $length);
1860
-                            } else {
2128
+                            }
2129
+                            else
2130
+                            {
1861 2131
                                 $data = fread($options['stream'], 8192);
1862 2132
                             }
1863 2133
 
1864
-                            if ($data === false) {
2134
+                            if ($data === false)
2135
+                            {
1865 2136
                                 $stat = "400 Bad request";
1866
-                            } elseif (strlen($data)) {
1867
-                                if (false === fwrite($stream, $data)) {
2137
+                            }
2138
+                            elseif (strlen($data))
2139
+                            {
2140
+                                if (false === fwrite($stream, $data))
2141
+                                {
1868 2142
                                     $stat = "403 Forbidden";
1869 2143
                                     break;
1870 2144
                                 }
1871 2145
                                 $length -= strlen($data);
1872 2146
                             }
1873 2147
                         }
1874
-                    } else {
2148
+                    }
2149
+                    else
2150
+                    {
1875 2151
                         $stat = "403 Forbidden";
1876 2152
                     }
1877
-                } else {
1878
-                    while (!feof($options["stream"])) {
1879
-                        if (false === fwrite($stream, fread($options["stream"], 8192))) {
2153
+                }
2154
+                else
2155
+                {
2156
+                    while (!feof($options["stream"]))
2157
+                    {
2158
+                        if (false === fwrite($stream, fread($options["stream"], 8192)))
2159
+                        {
1880 2160
                             $stat = "403 Forbidden";
1881 2161
                             break;
1882 2162
                         }
@@ -1887,7 +2167,9 @@  discard block
 block discarded – undo
1887 2167
             }
1888 2168
 
1889 2169
             $this->http_status($stat);
1890
-        } else {
2170
+        }
2171
+        else
2172
+        {
1891 2173
             $this->http_status("423 Locked");
1892 2174
         }
1893 2175
     }
@@ -1906,8 +2188,10 @@  discard block
 block discarded – undo
1906 2188
     function http_DELETE()
1907 2189
     {
1908 2190
         // check RFC 2518 Section 9.2, last paragraph
1909
-        if (isset($this->_SERVER["HTTP_DEPTH"])) {
1910
-            if ($this->_SERVER["HTTP_DEPTH"] != "infinity") {
2191
+        if (isset($this->_SERVER["HTTP_DEPTH"]))
2192
+        {
2193
+            if ($this->_SERVER["HTTP_DEPTH"] != "infinity")
2194
+            {
1911 2195
 				if (stripos($_SERVER['HTTP_USER_AGENT'],'webdrive') !== false)
1912 2196
 				{
1913 2197
 					// pretend we didnt see it, as webdrive does not handle the depth parameter correctly while deleting collections
@@ -1921,7 +2205,8 @@  discard block
 block discarded – undo
1921 2205
         }
1922 2206
 
1923 2207
         // check lock status
1924
-        if ($this->_check_lock_status($this->path)) {
2208
+        if ($this->_check_lock_status($this->path))
2209
+        {
1925 2210
             // ok, proceed
1926 2211
             $options         = Array();
1927 2212
             $options["path"] = $this->path;
@@ -1929,7 +2214,9 @@  discard block
 block discarded – undo
1929 2214
             $stat = $this->DELETE($options);
1930 2215
 
1931 2216
             $this->http_status($stat);
1932
-        } else {
2217
+        }
2218
+        else
2219
+        {
1933 2220
             // sorry, its locked
1934 2221
             $this->http_status("423 Locked");
1935 2222
         }
@@ -1964,10 +2251,13 @@  discard block
 block discarded – undo
1964 2251
      */
1965 2252
     function http_MOVE()
1966 2253
     {
1967
-        if ($this->_check_lock_status($this->path)) {
2254
+        if ($this->_check_lock_status($this->path))
2255
+        {
1968 2256
             // destination lock status is always checked by the helper method
1969 2257
             $this->_copymove("move");
1970
-        } else {
2258
+        }
2259
+        else
2260
+        {
1971 2261
             $this->http_status("423 Locked");
1972 2262
         }
1973 2263
     }
@@ -1988,19 +2278,25 @@  discard block
 block discarded – undo
1988 2278
         $options         = Array();
1989 2279
         $options["path"] = $this->path;
1990 2280
 
1991
-        if (isset($this->_SERVER['HTTP_DEPTH'])) {
2281
+        if (isset($this->_SERVER['HTTP_DEPTH']))
2282
+        {
1992 2283
             $options["depth"] = $this->_SERVER["HTTP_DEPTH"];
1993
-        } else {
2284
+        }
2285
+        else
2286
+        {
1994 2287
             $options["depth"] = "infinity";
1995 2288
         }
1996 2289
 
1997
-        if (isset($this->_SERVER["HTTP_TIMEOUT"])) {
2290
+        if (isset($this->_SERVER["HTTP_TIMEOUT"]))
2291
+        {
1998 2292
             $options["timeout"] = explode(",", $this->_SERVER["HTTP_TIMEOUT"]);
1999 2293
         }
2000 2294
 
2001
-        if (empty($this->_SERVER['CONTENT_LENGTH']) && !empty($this->_SERVER['HTTP_IF'])) {
2295
+        if (empty($this->_SERVER['CONTENT_LENGTH']) && !empty($this->_SERVER['HTTP_IF']))
2296
+        {
2002 2297
             // check if locking is possible
2003
-            if (!$this->_check_lock_status($this->path)) {
2298
+            if (!$this->_check_lock_status($this->path))
2299
+            {
2004 2300
                 $this->http_status("423 Locked");
2005 2301
                 return;
2006 2302
             }
@@ -2016,15 +2312,19 @@  discard block
 block discarded – undo
2016 2312
 
2017 2313
 
2018 2314
             $stat = $this->LOCK($options);
2019
-        } else {
2315
+        }
2316
+        else
2317
+        {
2020 2318
             // extract lock request information from request XML payload
2021 2319
             $lockinfo = new _parse_lockinfo("php://input");
2022
-            if (!$lockinfo->success) {
2320
+            if (!$lockinfo->success)
2321
+            {
2023 2322
                 $this->http_status("400 bad request");
2024 2323
             }
2025 2324
 
2026 2325
             // check if locking is possible
2027
-            if (!$this->_check_lock_status($this->path, $lockinfo->lockscope === "shared")) {
2326
+            if (!$this->_check_lock_status($this->path, $lockinfo->lockscope === "shared"))
2327
+            {
2028 2328
                 $this->http_status("423 Locked");
2029 2329
                 return;
2030 2330
             }
@@ -2039,36 +2339,51 @@  discard block
 block discarded – undo
2039 2339
             $stat = $this->LOCK($options);
2040 2340
         }
2041 2341
 
2042
-        if (is_bool($stat)) {
2342
+        if (is_bool($stat))
2343
+        {
2043 2344
             $http_stat = $stat ? "200 OK" : "423 Locked";
2044
-        } else {
2345
+        }
2346
+        else
2347
+        {
2045 2348
             $http_stat = (string)$stat;
2046 2349
         }
2047 2350
         $this->http_status($http_stat);
2048 2351
 
2049
-        if ($http_stat{0} == 2) { // 2xx states are ok
2050
-            if ($options["timeout"]) {
2352
+        if ($http_stat{0} == 2)
2353
+        {
2354
+// 2xx states are ok
2355
+            if ($options["timeout"])
2356
+            {
2051 2357
                 // if multiple timeout values were given we take the first only
2052
-                if (is_array($options["timeout"])) {
2358
+                if (is_array($options["timeout"]))
2359
+                {
2053 2360
                     reset($options["timeout"]);
2054 2361
                     $options["timeout"] = current($options["timeout"]);
2055 2362
                 }
2056 2363
                 // if the timeout is numeric only we need to reformat it
2057
-                if (is_numeric($options["timeout"])) {
2364
+                if (is_numeric($options["timeout"]))
2365
+                {
2058 2366
                     // more than a million is considered an absolute timestamp
2059 2367
                     // less is more likely a relative value
2060
-                    if ($options["timeout"]>1000000) {
2368
+                    if ($options["timeout"]>1000000)
2369
+                    {
2061 2370
                         $timeout = "Second-".($options['timeout']-time());
2062
-                    } else {
2371
+                    }
2372
+                    else
2373
+                    {
2063 2374
                         $timeout = "Second-$options[timeout]";
2064 2375
                     }
2065
-                } else {
2376
+                }
2377
+                else
2378
+                {
2066 2379
                     // non-numeric values are passed on verbatim,
2067 2380
                     // no error checking is performed here in this case
2068 2381
                     // TODO: send "Infinite" on invalid timeout strings?
2069 2382
                     $timeout = $options["timeout"];
2070 2383
                 }
2071
-            } else {
2384
+            }
2385
+            else
2386
+            {
2072 2387
                 $timeout = "Infinite";
2073 2388
             }
2074 2389
 
@@ -2106,9 +2421,12 @@  discard block
 block discarded – undo
2106 2421
         $options         = Array();
2107 2422
         $options["path"] = $this->path;
2108 2423
 
2109
-        if (isset($this->_SERVER['HTTP_DEPTH'])) {
2424
+        if (isset($this->_SERVER['HTTP_DEPTH']))
2425
+        {
2110 2426
             $options["depth"] = $this->_SERVER["HTTP_DEPTH"];
2111
-        } else {
2427
+        }
2428
+        else
2429
+        {
2112 2430
             $options["depth"] = "infinity";
2113 2431
         }
2114 2432
 
@@ -2137,9 +2455,12 @@  discard block
 block discarded – undo
2137 2455
         $options['path'] = $this->path;
2138 2456
         $options['errors'] = array();
2139 2457
 
2140
-        if (isset($this->_SERVER['HTTP_DEPTH'])) {
2458
+        if (isset($this->_SERVER['HTTP_DEPTH']))
2459
+        {
2141 2460
             $options['depth'] = $this->_SERVER['HTTP_DEPTH'];
2142
-        } else {
2461
+        }
2462
+        else
2463
+        {
2143 2464
             $options['depth'] = 'infinity';
2144 2465
         }
2145 2466
 
@@ -2150,18 +2471,26 @@  discard block
 block discarded – undo
2150 2471
 		$this->http_status($status);
2151 2472
 		$content = '';
2152 2473
 
2153
-        if (is_array($options['errors']) && count($options['errors'])) {
2474
+        if (is_array($options['errors']) && count($options['errors']))
2475
+        {
2154 2476
 	        header('Content-Type: text/xml; charset="utf-8"');
2155 2477
 	        // ... and payload
2156 2478
 	        $content .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
2157 2479
 	        $content .= "<D:error xmlns:D=\"DAV:\"> \n";
2158
-	        foreach ($options['errors'] as $violation) {
2480
+	        foreach ($options['errors'] as $violation)
2481
+	        {
2159 2482
 	        	$content .= '<'.($this->crrnd?'':'D:')."$violation/>\n";
2160 2483
 	        }
2161 2484
 	        $content .=  '</'.($this->crrnd?'':'D:')."error>\n";
2162 2485
         }
2163
-        if (!self::use_compression()) header("Content-Length: ".self::bytes($content));
2164
-        if ($content) echo $options['content'];
2486
+        if (!self::use_compression())
2487
+        {
2488
+        	header("Content-Length: ".self::bytes($content));
2489
+        }
2490
+        if ($content)
2491
+        {
2492
+        	echo $options['content'];
2493
+        }
2165 2494
     }
2166 2495
 
2167 2496
     // }}}
@@ -2175,9 +2504,12 @@  discard block
 block discarded – undo
2175 2504
         $options         = Array();
2176 2505
         $options["path"] = $this->path;
2177 2506
 
2178
-        if (isset($this->_SERVER["HTTP_DEPTH"])) {
2507
+        if (isset($this->_SERVER["HTTP_DEPTH"]))
2508
+        {
2179 2509
             $options["depth"] = $this->_SERVER["HTTP_DEPTH"];
2180
-        } else {
2510
+        }
2511
+        else
2512
+        {
2181 2513
             $options["depth"] = "infinity";
2182 2514
         }
2183 2515
 
@@ -2186,33 +2518,45 @@  discard block
 block discarded – undo
2186 2518
         $url  = parse_url($this->_SERVER["HTTP_DESTINATION"]);
2187 2519
         $path = urldecode($url["path"]);
2188 2520
 
2189
-        if (isset($url["host"])) {
2521
+        if (isset($url["host"]))
2522
+        {
2190 2523
             // TODO check url scheme, too
2191 2524
             $http_host = $url["host"];
2192 2525
             if (isset($url["port"]) && $url["port"] != 80)
2193
-                $http_host.= ":".$url["port"];
2194
-        } else {
2526
+            {
2527
+                            $http_host.= ":".$url["port"];
2528
+            }
2529
+        }
2530
+        else
2531
+        {
2195 2532
             // only path given, set host to self
2196 2533
             $http_host = $http_header_host;
2197 2534
         }
2198 2535
 
2199 2536
         if ($http_host == $http_header_host &&
2200 2537
             !strncmp($this->_SERVER["SCRIPT_NAME"], $path,
2201
-                     strlen($this->_SERVER["SCRIPT_NAME"]))) {
2538
+                     strlen($this->_SERVER["SCRIPT_NAME"])))
2539
+        {
2202 2540
             $options["dest"] = substr($path, strlen($this->_SERVER["SCRIPT_NAME"]));
2203
-            if (!$this->_check_lock_status($options["dest"])) {
2541
+            if (!$this->_check_lock_status($options["dest"]))
2542
+            {
2204 2543
                 $this->http_status("423 Locked");
2205 2544
                 return;
2206 2545
             }
2207 2546
 
2208
-        } else {
2547
+        }
2548
+        else
2549
+        {
2209 2550
             $options["dest_url"] = $this->_SERVER["HTTP_DESTINATION"];
2210 2551
         }
2211 2552
 
2212 2553
         // see RFC 2518 Sections 9.6, 8.8.4 and 8.9.3
2213
-        if (isset($this->_SERVER["HTTP_OVERWRITE"])) {
2554
+        if (isset($this->_SERVER["HTTP_OVERWRITE"]))
2555
+        {
2214 2556
             $options["overwrite"] = $this->_SERVER["HTTP_OVERWRITE"] == "T";
2215
-        } else {
2557
+        }
2558
+        else
2559
+        {
2216 2560
             $options["overwrite"] = true;
2217 2561
         }
2218 2562
 
@@ -2238,10 +2582,13 @@  discard block
 block discarded – undo
2238 2582
         // all other METHODS need both a http_method() wrapper
2239 2583
         // and a method() implementation
2240 2584
         // the base class supplies wrappers only
2241
-        foreach (get_class_methods($this) as $method) {
2242
-            if (!strncmp("http_", $method, 5)) {
2585
+        foreach (get_class_methods($this) as $method)
2586
+        {
2587
+            if (!strncmp("http_", $method, 5))
2588
+            {
2243 2589
                 $method = strtoupper(substr($method, 5));
2244
-                if (method_exists($this, $method)) {
2590
+                if (method_exists($this, $method))
2591
+                {
2245 2592
                     $allow[$method] = $method;
2246 2593
                 }
2247 2594
             }
@@ -2249,10 +2596,13 @@  discard block
 block discarded – undo
2249 2596
 
2250 2597
         // we can emulate a missing HEAD implemetation using GET
2251 2598
         if (isset($allow["GET"]))
2252
-            $allow["HEAD"] = "HEAD";
2599
+        {
2600
+                    $allow["HEAD"] = "HEAD";
2601
+        }
2253 2602
 
2254 2603
         // no LOCK without checklok()
2255
-        if (!method_exists($this, "checklock")) {
2604
+        if (!method_exists($this, "checklock"))
2605
+        {
2256 2606
             unset($allow["LOCK"]);
2257 2607
             unset($allow["UNLOCK"]);
2258 2608
         }
@@ -2274,7 +2624,8 @@  discard block
 block discarded – undo
2274 2624
     public static function mkprop()
2275 2625
     {
2276 2626
 	    $args = func_get_args();
2277
-	    switch (count($args)) {
2627
+	    switch (count($args))
2628
+	    {
2278 2629
 		    case 4:
2279 2630
 			    return array('ns'   => $args[0],
2280 2631
 				    'name' => $args[1],
@@ -2301,17 +2652,22 @@  discard block
 block discarded – undo
2301 2652
      */
2302 2653
     function _check_auth()
2303 2654
     {
2304
-        if (method_exists($this, "checkAuth")) {
2655
+        if (method_exists($this, "checkAuth"))
2656
+        {
2305 2657
             // PEAR style method name
2306 2658
             return $this->checkAuth(@$this->_SERVER["AUTH_TYPE"],
2307 2659
                                     @$this->_SERVER["PHP_AUTH_USER"],
2308 2660
                                     @$this->_SERVER["PHP_AUTH_PW"]);
2309
-        } else if (method_exists($this, "check_auth")) {
2661
+        }
2662
+        else if (method_exists($this, "check_auth"))
2663
+        {
2310 2664
             // old (pre 1.0) method name
2311 2665
             return $this->check_auth(@$this->_SERVER["AUTH_TYPE"],
2312 2666
                                      @$this->_SERVER["PHP_AUTH_USER"],
2313 2667
                                      @$this->_SERVER["PHP_AUTH_PW"]);
2314
-        } else {
2668
+        }
2669
+        else
2670
+        {
2315 2671
             // no method found -> no authentication required
2316 2672
             return true;
2317 2673
         }
@@ -2330,7 +2686,8 @@  discard block
 block discarded – undo
2330 2686
     public static function _new_uuid()
2331 2687
     {
2332 2688
         // use uuid extension from PECL if available
2333
-        if (function_exists("uuid_create")) {
2689
+        if (function_exists("uuid_create"))
2690
+        {
2334 2691
             return uuid_create();
2335 2692
         }
2336 2693
 
@@ -2376,12 +2733,14 @@  discard block
 block discarded – undo
2376 2733
     function _if_header_lexer($string, &$pos)
2377 2734
     {
2378 2735
         // skip whitespace
2379
-        while (ctype_space($string{$pos})) {
2736
+        while (ctype_space($string{$pos}))
2737
+        {
2380 2738
             ++$pos;
2381 2739
         }
2382 2740
 
2383 2741
         // already at end of string?
2384
-        if (strlen($string) <= $pos) {
2742
+        if (strlen($string) <= $pos)
2743
+        {
2385 2744
             return false;
2386 2745
         }
2387 2746
 
@@ -2389,7 +2748,8 @@  discard block
 block discarded – undo
2389 2748
         $c = $string{$pos++};
2390 2749
 
2391 2750
         // now it depends on what we found
2392
-        switch ($c) {
2751
+        switch ($c)
2752
+        {
2393 2753
         case "<":
2394 2754
             // URIs are enclosed in <...>
2395 2755
             $pos2 = strpos($string, ">", $pos);
@@ -2399,10 +2759,13 @@  discard block
 block discarded – undo
2399 2759
 
2400 2760
         case "[":
2401 2761
             //Etags are enclosed in [...]
2402
-            if ($string{$pos} == "W") {
2762
+            if ($string{$pos} == "W")
2763
+            {
2403 2764
                 $type = "ETAG_WEAK";
2404 2765
                 $pos += 2;
2405
-            } else {
2766
+            }
2767
+            else
2768
+            {
2406 2769
                 $type = "ETAG_STRONG";
2407 2770
             }
2408 2771
             $pos2 = strpos($string, "]", $pos);
@@ -2434,35 +2797,44 @@  discard block
 block discarded – undo
2434 2797
         $uris = array();
2435 2798
 
2436 2799
         // parser loop
2437
-        while ($pos < $len) {
2800
+        while ($pos < $len)
2801
+        {
2438 2802
             // get next token
2439 2803
             $token = $this->_if_header_lexer($str, $pos);
2440 2804
 
2441 2805
             // check for URI
2442
-            if ($token[0] == "URI") {
2806
+            if ($token[0] == "URI")
2807
+            {
2443 2808
                 $uri   = $token[1]; // remember URI
2444 2809
                 $token = $this->_if_header_lexer($str, $pos); // get next token
2445
-            } else {
2810
+            }
2811
+            else
2812
+            {
2446 2813
                 $uri = "";
2447 2814
             }
2448 2815
 
2449 2816
             // sanity check
2450
-            if ($token[0] != "CHAR" || $token[1] != "(") {
2817
+            if ($token[0] != "CHAR" || $token[1] != "(")
2818
+            {
2451 2819
                 return false;
2452 2820
             }
2453 2821
 
2454 2822
             $list  = array();
2455 2823
             $level = 1;
2456 2824
             $not   = "";
2457
-            while ($level) {
2825
+            while ($level)
2826
+            {
2458 2827
                 $token = $this->_if_header_lexer($str, $pos);
2459
-                if ($token[0] == "NOT") {
2828
+                if ($token[0] == "NOT")
2829
+                {
2460 2830
                     $not = "!";
2461 2831
                     continue;
2462 2832
                 }
2463
-                switch ($token[0]) {
2833
+                switch ($token[0])
2834
+                {
2464 2835
                 case "CHAR":
2465
-                    switch ($token[1]) {
2836
+                    switch ($token[1])
2837
+                    {
2466 2838
                     case "(":
2467 2839
                         $level++;
2468 2840
                         break;
@@ -2492,9 +2864,12 @@  discard block
 block discarded – undo
2492 2864
                 $not = "";
2493 2865
             }
2494 2866
 
2495
-            if (@is_array($uris[$uri])) {
2867
+            if (@is_array($uris[$uri]))
2868
+            {
2496 2869
                 $uris[$uri] = array_merge($uris[$uri], $list);
2497
-            } else {
2870
+            }
2871
+            else
2872
+            {
2498 2873
                 $uris[$uri] = $list;
2499 2874
             }
2500 2875
         }
@@ -2513,27 +2888,34 @@  discard block
 block discarded – undo
2513 2888
      */
2514 2889
     function _check_if_header_conditions()
2515 2890
     {
2516
-        if (isset($this->_SERVER["HTTP_IF"])) {
2891
+        if (isset($this->_SERVER["HTTP_IF"]))
2892
+        {
2517 2893
             $this->_if_header_uris =
2518 2894
                 $this->_if_header_parser($this->_SERVER["HTTP_IF"]);
2519 2895
 
2520
-            foreach ($this->_if_header_uris as $uri => $conditions) {
2521
-                if ($uri == "") {
2896
+            foreach ($this->_if_header_uris as $uri => $conditions)
2897
+            {
2898
+                if ($uri == "")
2899
+                {
2522 2900
                     $uri = $this->uri;
2523 2901
                 }
2524 2902
                 // all must match
2525 2903
                 $state = true;
2526
-                foreach ($conditions as $condition) {
2904
+                foreach ($conditions as $condition)
2905
+                {
2527 2906
                     // lock tokens may be free form (RFC2518 6.3)
2528 2907
                     // but if opaquelocktokens are used (RFC2518 6.4)
2529 2908
                     // we have to check the format (litmus tests this)
2530
-                    if (!strncmp($condition, "<opaquelocktoken:", strlen("<opaquelocktoken"))) {
2531
-                        if (!preg_match('/^<opaquelocktoken:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}>$/', $condition)) {
2909
+                    if (!strncmp($condition, "<opaquelocktoken:", strlen("<opaquelocktoken")))
2910
+                    {
2911
+                        if (!preg_match('/^<opaquelocktoken:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}>$/', $condition))
2912
+                        {
2532 2913
                             $this->http_status("423 Locked");
2533 2914
                             return false;
2534 2915
                         }
2535 2916
                     }
2536
-                    if (!$this->_check_uri_condition($uri, $condition)) {
2917
+                    if (!$this->_check_uri_condition($uri, $condition))
2918
+                    {
2537 2919
                         $this->http_status("412 Precondition failed");
2538 2920
                         $state = false;
2539 2921
                         break;
@@ -2541,7 +2923,8 @@  discard block
 block discarded – undo
2541 2923
                 }
2542 2924
 
2543 2925
                 // any match is ok
2544
-                if ($state == true) {
2926
+                if ($state == true)
2927
+                {
2545 2928
                     return true;
2546 2929
                 }
2547 2930
             }
@@ -2568,7 +2951,8 @@  discard block
 block discarded – undo
2568 2951
 
2569 2952
         // a lock token can never be from the DAV: scheme
2570 2953
         // litmus uses DAV:no-lock in some tests
2571
-        if (!strncmp("<DAV:", $condition, 5)) {
2954
+        if (!strncmp("<DAV:", $condition, 5))
2955
+        {
2572 2956
             return false;
2573 2957
         }
2574 2958
 
@@ -2585,16 +2969,21 @@  discard block
 block discarded – undo
2585 2969
     function _check_lock_status($path, $exclusive_only = false)
2586 2970
     {
2587 2971
         // FIXME depth -> ignored for now
2588
-        if (method_exists($this, "checkLock")) {
2972
+        if (method_exists($this, "checkLock"))
2973
+        {
2589 2974
             // is locked?
2590 2975
             $lock = $this->checkLock($path);
2591 2976
 
2592 2977
             // ... and lock is not owned?
2593
-            if (is_array($lock) && count($lock)) {
2978
+            if (is_array($lock) && count($lock))
2979
+            {
2594 2980
                 // FIXME doesn't check uri restrictions yet
2595
-                if (!isset($this->_SERVER["HTTP_IF"]) || !strstr($this->_SERVER["HTTP_IF"], $lock["token"])) {
2981
+                if (!isset($this->_SERVER["HTTP_IF"]) || !strstr($this->_SERVER["HTTP_IF"], $lock["token"]))
2982
+                {
2596 2983
                     if (!$exclusive_only || ($lock["scope"] !== "shared"))
2597
-                        return false;
2984
+                    {
2985
+                                            return false;
2986
+                    }
2598 2987
                 }
2599 2988
             }
2600 2989
         }
@@ -2614,7 +3003,8 @@  discard block
 block discarded – undo
2614 3003
     function lockdiscovery($path)
2615 3004
     {
2616 3005
         // no lock support without checklock() method
2617
-        if (!method_exists($this, "checklock")) {
3006
+        if (!method_exists($this, "checklock"))
3007
+        {
2618 3008
             return "";
2619 3009
         }
2620 3010
 
@@ -2625,13 +3015,19 @@  discard block
 block discarded – undo
2625 3015
         $lock = $this->checklock($path);
2626 3016
 
2627 3017
         // generate <activelock> block for returned data
2628
-        if (is_array($lock) && count($lock)) {
3018
+        if (is_array($lock) && count($lock))
3019
+        {
2629 3020
             // check for 'timeout' or 'expires'
2630
-            if (!empty($lock["expires"])) {
3021
+            if (!empty($lock["expires"]))
3022
+            {
2631 3023
                 $timeout = "Second-".($lock["expires"] - time());
2632
-            } else if (!empty($lock["timeout"])) {
3024
+            }
3025
+            else if (!empty($lock["timeout"]))
3026
+            {
2633 3027
                 $timeout = "Second-$lock[timeout]";
2634
-            } else {
3028
+            }
3029
+            else
3030
+            {
2635 3031
                 $timeout = "Infinite";
2636 3032
             }
2637 3033
 
@@ -2678,7 +3074,8 @@  discard block
 block discarded – undo
2678 3074
     function http_status($status)
2679 3075
     {
2680 3076
         // simplified success case
2681
-        if ($status === true) {
3077
+        if ($status === true)
3078
+        {
2682 3079
             $status = "200 OK";
2683 3080
         }
2684 3081
 
@@ -2763,18 +3160,24 @@  discard block
 block discarded – undo
2763 3160
      * @return string
2764 3161
      */
2765 3162
 	function _hierarchical_prop_encode(array $props, $ns, &$ns_defs, array &$ns_hash)
2766
-    {
3163
+	{
2767 3164
     	$ret = '';
2768 3165
 
2769 3166
     	//error_log(__METHOD__.'('.array2string($props).')');
2770
-    	if (isset($props['name'])) $props = array($props);
3167
+    	if (isset($props['name']))
3168
+    	{
3169
+    		$props = array($props);
3170
+    	}
2771 3171
 
2772 3172
     	foreach($props as $prop)
2773
-		{
2774
-	    	if (!isset($ns_hash[$prop['ns']])) // unknown namespace
3173
+    	{
3174
+	    	if (!isset($ns_hash[$prop['ns']]))
3175
+	    	{
3176
+	    		// unknown namespace
2775 3177
 	    	{
2776 3178
 		    	// register namespace
2777 3179
 		    	$ns_name = 'ns'.(count($ns_hash) + 1);
3180
+	    	}
2778 3181
 		    	$ns_hash[$prop['ns']] = $ns_name;
2779 3182
 		    	$ns_defs .= ' xmlns:'.$ns_name.'="'.$prop['ns'].'"';
2780 3183
 	    	}
@@ -2792,7 +3195,7 @@  discard block
 block discarded – undo
2792 3195
 			    	$vals = '';
2793 3196
 
2794 3197
 			    	foreach($subprop as $attr => $val)
2795
-					{
3198
+			    	{
2796 3199
 				    	$vals .= ' '.$attr.'="'.htmlspecialchars($val, ENT_NOQUOTES, 'utf-8').'"';
2797 3200
 					}
2798 3201
 
@@ -2809,9 +3212,11 @@  discard block
 block discarded – undo
2809 3212
 		    	else
2810 3213
 		    	{
2811 3214
 			    	if(isset($prop['raw']))
2812
-					{
3215
+			    	{
2813 3216
 						$val = $this->_prop_encode('<![CDATA['.$prop['val'].']]>');
2814
-					} else {
3217
+					}
3218
+					else
3219
+					{
2815 3220
 						$val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8'));
2816 3221
 						// for href properties we need (minimalistic) urlencoding, eg. space
2817 3222
 						if ($prop['name'] == 'href')
@@ -2842,7 +3247,8 @@  discard block
 block discarded – undo
2842 3247
 		//error_log( __METHOD__."\n" .print_r($text,true));
2843 3248
 		//error_log("prop-encode:" . print_r($this->_prop_encoding,true));
2844 3249
 
2845
-		switch (strtolower($this->_prop_encoding)) {
3250
+		switch (strtolower($this->_prop_encoding))
3251
+		{
2846 3252
 			case "utf-8":
2847 3253
        			//error_log( __METHOD__."allready encoded\n" .print_r($text,true));
2848 3254
 				return $text;
@@ -2864,7 +3270,8 @@  discard block
 block discarded – undo
2864 3270
     public static function _slashify($path)
2865 3271
     {
2866 3272
 		//error_log(__METHOD__." called with $path");
2867
-		if ($path[self::bytes($path)-1] != '/') {
3273
+		if ($path[self::bytes($path)-1] != '/')
3274
+		{
2868 3275
 			//error_log(__METHOD__." added slash at the end of path");
2869 3276
 			$path = $path."/";
2870 3277
 		}
@@ -2880,7 +3287,8 @@  discard block
 block discarded – undo
2880 3287
     public static function _unslashify($path)
2881 3288
     {
2882 3289
         //error_log(__METHOD__." called with $path");
2883
-        if ($path[self::bytes($path)-1] == '/') {
3290
+        if ($path[self::bytes($path)-1] == '/')
3291
+        {
2884 3292
             $path = substr($path, 0, -1);
2885 3293
 			//error_log(__METHOD__." removed slash at the end of path");
2886 3294
         }
@@ -2898,9 +3306,12 @@  discard block
 block discarded – undo
2898 3306
     {
2899 3307
         //error_log("merge called :\n$parent \n$child\n" . function_backtrace());
2900 3308
         //error_log("merge :\n".print_r($this->_mergePaths($this->_SERVER["SCRIPT_NAME"], $this->path)true));
2901
-        if ($child{0} == '/') {
3309
+        if ($child{0} == '/')
3310
+        {
2902 3311
             return self::_unslashify($parent).$child;
2903
-        } else {
3312
+        }
3313
+        else
3314
+        {
2904 3315
             return self::_slashify($parent).$child;
2905 3316
         }
2906 3317
     }
Please login to merge, or discard this patch.
api/src/WebDAV/Server/Filesystem.php 2 patches
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -365,18 +365,18 @@  discard block
 block discarded – undo
365 365
             //       the registry)
366 366
             // TODO: have a seperate PEAR class for mimetype detection?
367 367
             switch (strtolower(strrchr(basename($fspath), "."))) {
368
-            case ".html":
369
-                $mime_type = "text/html";
370
-                break;
371
-            case ".gif":
372
-                $mime_type = "image/gif";
373
-                break;
374
-            case ".jpg":
375
-                $mime_type = "image/jpeg";
376
-                break;
377
-            default:
378
-                $mime_type = "application/octet-stream";
379
-                break;
368
+            	case ".html":
369
+                	$mime_type = "text/html";
370
+                	break;
371
+            	case ".gif":
372
+                	$mime_type = "image/gif";
373
+                	break;
374
+            	case ".jpg":
375
+                	$mime_type = "image/jpeg";
376
+                	break;
377
+            	default:
378
+                	$mime_type = "application/octet-stream";
379
+                	break;
380 380
             }
381 381
         }
382 382
 
@@ -633,16 +633,16 @@  discard block
 block discarded – undo
633 633
 
634 634
         if (is_dir($source)) { // resource is a collection
635 635
             switch ($options["depth"]) {
636
-            case "infinity": // valid
637
-                break;
638
-            case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
640
-                    return "400 Bad request";
641
-                }
642
-                break;
643
-            case "1": // invalid for both COPY and MOVE
644
-            default:
645
-                return "400 Bad request";
636
+            	case "infinity": // valid
637
+                	break;
638
+            	case "0": // valid for COPY only
639
+                	if ($del) { // MOVE?
640
+                    	return "400 Bad request";
641
+                	}
642
+                	break;
643
+            	case "1": // invalid for both COPY and MOVE
644
+            	default:
645
+                	return "400 Bad request";
646 646
             }
647 647
         }
648 648
 
Please login to merge, or discard this patch.
Braces   +212 added lines, -91 removed lines patch added patch discarded remove patch
@@ -105,15 +105,19 @@  discard block
 block discarded – undo
105 105
         // special treatment for litmus compliance test
106 106
         // reply on its identifier header
107 107
         // not needed for the test itself but eases debugging
108
-        if (isset($this->_SERVER['HTTP_X_LITMUS'])) {
108
+        if (isset($this->_SERVER['HTTP_X_LITMUS']))
109
+        {
109 110
             error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']);
110 111
             header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']);
111 112
         }
112 113
 
113 114
         // set root directory, defaults to webserver document root if not set
114
-        if ($base) {
115
+        if ($base)
116
+        {
115 117
             $this->base = realpath($base); // TODO throw if not a directory
116
-        } else if (!$this->base) {
118
+        }
119
+        else if (!$this->base)
120
+        {
117 121
             $this->base = $this->_SERVER['DOCUMENT_ROOT'];
118 122
         }
119 123
 
@@ -154,7 +158,8 @@  discard block
 block discarded – undo
154 158
         $fspath = $this->base . $options["path"];
155 159
 
156 160
         // sanity check
157
-        if (!file_exists($fspath)) {
161
+        if (!file_exists($fspath))
162
+        {
158 163
             return false;
159 164
         }
160 165
 
@@ -165,7 +170,8 @@  discard block
 block discarded – undo
165 170
         $files["files"][] = $this->fileinfo($options["path"]);
166 171
 
167 172
         // information for contained resources requested?
168
-        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) {
173
+        if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath))
174
+        {
169 175
 
170 176
             // make sure path ends with '/'
171 177
             $options["path"] = $this->_slashify($options["path"]);
@@ -173,10 +179,13 @@  discard block
 block discarded – undo
173 179
             // try to open directory
174 180
             $handle = opendir($fspath);
175 181
 
176
-            if ($handle) {
182
+            if ($handle)
183
+            {
177 184
                 // ok, now get all its contents
178
-                while ($filename = readdir($handle)) {
179
-                    if ($filename != "." && $filename != "..") {
185
+                while ($filename = readdir($handle))
186
+                {
187
+                    if ($filename != "." && $filename != "..")
188
+                    {
180 189
                         $files["files"][] = $this->fileinfo($options["path"].$filename);
181 190
                     }
182 191
                 }
@@ -218,16 +227,22 @@  discard block
 block discarded – undo
218 227
         $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1)));
219 228
 
220 229
         // type and size (caller already made sure that path exists)
221
-        if (is_dir($fspath)) {
230
+        if (is_dir($fspath))
231
+        {
222 232
             // directory (WebDAV collection)
223 233
             $info["props"][] = $this->mkprop("resourcetype", "collection");
224 234
             $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory");
225
-        } else {
235
+        }
236
+        else
237
+        {
226 238
             // plain file (WebDAV resource)
227 239
             $info["props"][] = $this->mkprop("resourcetype", "");
228
-            if ($this->_is_readable($fspath)) {
240
+            if ($this->_is_readable($fspath))
241
+            {
229 242
                 $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath));
230
-            } else {
243
+            }
244
+            else
245
+            {
231 246
                 $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable");
232 247
             }
233 248
             $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath));
@@ -238,7 +253,8 @@  discard block
 block discarded – undo
238 253
                         FROM {$this->db_prefix}properties
239 254
                        WHERE path = '$path'";
240 255
         $res = mysql_query($query);
241
-        while ($row = mysql_fetch_assoc($res)) {
256
+        while ($row = mysql_fetch_assoc($res))
257
+        {
242 258
             $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
243 259
         }
244 260
         mysql_free_result($res);
@@ -259,30 +275,45 @@  discard block
 block discarded – undo
259 275
     function _can_execute($name, $path = false)
260 276
     {
261 277
         // path defaults to PATH from environment if not set
262
-        if ($path === false) {
278
+        if ($path === false)
279
+        {
263 280
             $path = getenv("PATH");
264 281
         }
265 282
 
266 283
         // check method depends on operating system
267
-        if (!strncmp(PHP_OS, "WIN", 3)) {
284
+        if (!strncmp(PHP_OS, "WIN", 3))
285
+        {
268 286
             // on Windows an appropriate COM or EXE file needs to exist
269 287
             $exts     = array(".exe", ".com");
270 288
             $check_fn = "file_exists";
271
-        } else {
289
+        }
290
+        else
291
+        {
272 292
             // anywhere else we look for an executable file of that name
273 293
             $exts     = array("");
274 294
             $check_fn = "is_executable";
275 295
         }
276 296
 
277 297
         // now check the directories in the path for the program
278
-        foreach (explode(PATH_SEPARATOR, $path) as $dir) {
298
+        foreach (explode(PATH_SEPARATOR, $path) as $dir)
299
+        {
279 300
             // skip invalid path entries
280
-            if (!file_exists($dir)) continue;
281
-            if (!is_dir($dir)) continue;
301
+            if (!file_exists($dir))
302
+            {
303
+            	continue;
304
+            }
305
+            if (!is_dir($dir))
306
+            {
307
+            	continue;
308
+            }
282 309
 
283 310
             // and now look for the file
284
-            foreach ($exts as $ext) {
285
-                if ($check_fn("$dir/$name".$ext)) return true;
311
+            foreach ($exts as $ext)
312
+            {
313
+                if ($check_fn("$dir/$name".$ext))
314
+                {
315
+                	return true;
316
+                }
286 317
             }
287 318
         }
288 319
 
@@ -323,13 +354,18 @@  discard block
 block discarded – undo
323 354
      */
324 355
     function _mimetype($fspath)
325 356
     {
326
-        if (is_dir($fspath)) {
357
+        if (is_dir($fspath))
358
+        {
327 359
             // directories are easy
328 360
             return "httpd/unix-directory";
329
-        } else if (function_exists("mime_content_type")) {
361
+        }
362
+        else if (function_exists("mime_content_type"))
363
+        {
330 364
             // use mime magic extension if available
331 365
             $mime_type = mime_content_type($fspath);
332
-        } else if ($this->_can_execute("file")) {
366
+        }
367
+        else if ($this->_can_execute("file"))
368
+        {
333 369
             // it looks like we have a 'file' command,
334 370
             // lets see it it does have mime support
335 371
             $fp    = popen("file -i '$fspath' 2>/dev/null", "r");
@@ -341,16 +377,19 @@  discard block
 block discarded – undo
341 377
             // so we test the format of the returned string
342 378
 
343 379
             // the reply begins with the requested filename
344
-            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) {
380
+            if (!strncmp($reply, "$fspath: ", strlen($fspath)+2))
381
+            {
345 382
                 $reply = substr($reply, strlen($fspath)+2);
346 383
                 // followed by the mime type (maybe including options)
347
-                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) {
384
+                if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches))
385
+                {
348 386
                     $mime_type = $matches[0];
349 387
                 }
350 388
             }
351 389
         }
352 390
 
353
-        if (empty($mime_type)) {
391
+        if (empty($mime_type))
392
+        {
354 393
             // Fallback solution: try to guess the type by the file extension
355 394
             // TODO: add more ...
356 395
             // TODO: it has been suggested to delegate mimetype detection
@@ -364,7 +403,8 @@  discard block
 block discarded – undo
364 403
             //       anyway (overriding it with information taken from
365 404
             //       the registry)
366 405
             // TODO: have a seperate PEAR class for mimetype detection?
367
-            switch (strtolower(strrchr(basename($fspath), "."))) {
406
+            switch (strtolower(strrchr(basename($fspath), ".")))
407
+            {
368 408
             case ".html":
369 409
                 $mime_type = "text/html";
370 410
                 break;
@@ -395,7 +435,10 @@  discard block
 block discarded – undo
395 435
         $fspath = $this->base . $options["path"];
396 436
 
397 437
         // sanity check
398
-        if (!file_exists($fspath)) return false;
438
+        if (!file_exists($fspath))
439
+        {
440
+        	return false;
441
+        }
399 442
 
400 443
         // detect resource type
401 444
         $options['mimetype'] = $this->_mimetype($fspath);
@@ -424,12 +467,14 @@  discard block
 block discarded – undo
424 467
         $fspath = $this->base . $options["path"];
425 468
 
426 469
         // is this a collection?
427
-        if (is_dir($fspath)) {
470
+        if (is_dir($fspath))
471
+        {
428 472
             return $this->GetDir($fspath, $options);
429 473
         }
430 474
 
431 475
         // the header output is the same as for HEAD
432
-        if (!$this->HEAD($options)) {
476
+        if (!$this->HEAD($options))
477
+        {
433 478
             return false;
434 479
         }
435 480
 
@@ -451,7 +496,8 @@  discard block
 block discarded – undo
451 496
     function GetDir($fspath, &$options)
452 497
     {
453 498
         $path = $this->_slashify($options["path"]);
454
-        if ($path != $options["path"]) {
499
+        if ($path != $options["path"])
500
+        {
455 501
             header("Location: ".$this->base_uri.$path);
456 502
             exit;
457 503
         }
@@ -459,12 +505,14 @@  discard block
 block discarded – undo
459 505
         // fixed width directory column format
460 506
         $format = "%15s  %-19s  %-s\n";
461 507
 
462
-        if (!$this->_is_readable($fspath)) {
508
+        if (!$this->_is_readable($fspath))
509
+        {
463 510
             return false;
464 511
         }
465 512
 
466 513
         $handle = opendir($fspath);
467
-        if (!$handle) {
514
+        if (!$handle)
515
+        {
468 516
             return false;
469 517
         }
470 518
 
@@ -476,8 +524,10 @@  discard block
 block discarded – undo
476 524
         printf($format, "Size", "Last modified", "Filename");
477 525
         echo "<hr>";
478 526
 
479
-        while ($filename = readdir($handle)) {
480
-            if ($filename != "." && $filename != "..") {
527
+        while ($filename = readdir($handle))
528
+        {
529
+            if ($filename != "." && $filename != "..")
530
+            {
481 531
                 $fullpath = $fspath.$filename;
482 532
                 $name     = htmlspecialchars($filename);
483 533
                 printf($format,
@@ -507,19 +557,23 @@  discard block
 block discarded – undo
507 557
         $fspath = $this->base . $options["path"];
508 558
 
509 559
         $dir = dirname($fspath);
510
-        if (!file_exists($dir) || !is_dir($dir)) {
560
+        if (!file_exists($dir) || !is_dir($dir))
561
+        {
511 562
             return "409 Conflict"; // TODO right status code for both?
512 563
         }
513 564
 
514 565
         $options["new"] = ! file_exists($fspath);
515 566
 
516
-        if ($options["new"] && !$this->_is_writable($dir)) {
567
+        if ($options["new"] && !$this->_is_writable($dir))
568
+        {
517 569
             return "403 Forbidden";
518 570
         }
519
-        if (!$options["new"] && !$this->_is_writable($fspath)) {
571
+        if (!$options["new"] && !$this->_is_writable($fspath))
572
+        {
520 573
             return "403 Forbidden";
521 574
         }
522
-        if (!$options["new"] && is_dir($fspath)) {
575
+        if (!$options["new"] && is_dir($fspath))
576
+        {
523 577
             return "403 Forbidden";
524 578
         }
525 579
 
@@ -541,24 +595,30 @@  discard block
 block discarded – undo
541 595
         $parent = dirname($path);
542 596
         $name   = basename($path);
543 597
 
544
-        if (!file_exists($parent)) {
598
+        if (!file_exists($parent))
599
+        {
545 600
             return "409 Conflict";
546 601
         }
547 602
 
548
-        if (!is_dir($parent)) {
603
+        if (!is_dir($parent))
604
+        {
549 605
             return "403 Forbidden";
550 606
         }
551 607
 
552
-        if ( file_exists($parent."/".$name) ) {
608
+        if ( file_exists($parent."/".$name) )
609
+        {
553 610
             return "405 Method not allowed";
554 611
         }
555 612
 
556
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
613
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
614
+        {
615
+// no body parsing yet
557 616
             return "415 Unsupported media type";
558 617
         }
559 618
 
560 619
         $stat = mkdir($parent."/".$name, 0777);
561
-        if (!$stat) {
620
+        if (!$stat)
621
+        {
562 622
             return "403 Forbidden";
563 623
         }
564 624
 
@@ -576,16 +636,20 @@  discard block
 block discarded – undo
576 636
     {
577 637
         $path = $this->base . "/" .$options["path"];
578 638
 
579
-        if (!file_exists($path)) {
639
+        if (!file_exists($path))
640
+        {
580 641
             return "404 Not found";
581 642
         }
582 643
 
583
-        if (is_dir($path)) {
644
+        if (is_dir($path))
645
+        {
584 646
             $query = "DELETE FROM {$this->db_prefix}properties
585 647
                            WHERE path LIKE '".$this->_slashify($options["path"])."%'";
586 648
             mysql_query($query);
587 649
             System::rm(array("-rf", $path));
588
-        } else {
650
+        }
651
+        else
652
+        {
589 653
             unlink($path);
590 654
         }
591 655
         $query = "DELETE FROM {$this->db_prefix}properties
@@ -617,26 +681,35 @@  discard block
 block discarded – undo
617 681
     {
618 682
         // TODO Property updates still broken (Litmus should detect this?)
619 683
 
620
-        if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
684
+        if (!empty($this->_SERVER["CONTENT_LENGTH"]))
685
+        {
686
+// no body parsing yet
621 687
             return "415 Unsupported media type";
622 688
         }
623 689
 
624 690
         // no copying to different WebDAV Servers yet
625
-        if (isset($options["dest_url"])) {
691
+        if (isset($options["dest_url"]))
692
+        {
626 693
             return "502 bad gateway";
627 694
         }
628 695
 
629 696
         $source = $this->base . $options["path"];
630
-        if (!file_exists($source)) {
697
+        if (!file_exists($source))
698
+        {
631 699
             return "404 Not found";
632 700
         }
633 701
 
634
-        if (is_dir($source)) { // resource is a collection
635
-            switch ($options["depth"]) {
702
+        if (is_dir($source))
703
+        {
704
+// resource is a collection
705
+            switch ($options["depth"])
706
+            {
636 707
             case "infinity": // valid
637 708
                 break;
638 709
             case "0": // valid for COPY only
639
-                if ($del) { // MOVE?
710
+                if ($del)
711
+                {
712
+// MOVE?
640 713
                     return "400 Bad request";
641 714
                 }
642 715
                 break;
@@ -649,7 +722,8 @@  discard block
 block discarded – undo
649 722
         $dest         = $this->base . $options["dest"];
650 723
         $destdir      = dirname($dest);
651 724
 
652
-        if (!file_exists($destdir) || !is_dir($destdir)) {
725
+        if (!file_exists($destdir) || !is_dir($destdir))
726
+        {
653 727
             return "409 Conflict";
654 728
         }
655 729
 
@@ -657,38 +731,52 @@  discard block
 block discarded – undo
657 731
         $new          = !file_exists($dest);
658 732
         $existing_col = false;
659 733
 
660
-        if (!$new) {
661
-            if ($del && is_dir($dest)) {
662
-                if (!$options["overwrite"]) {
734
+        if (!$new)
735
+        {
736
+            if ($del && is_dir($dest))
737
+            {
738
+                if (!$options["overwrite"])
739
+                {
663 740
                     return "412 precondition failed";
664 741
                 }
665 742
                 $dest .= basename($source);
666
-                if (file_exists($dest)) {
743
+                if (file_exists($dest))
744
+                {
667 745
                     $options["dest"] .= basename($source);
668
-                } else {
746
+                }
747
+                else
748
+                {
669 749
                     $new          = true;
670 750
                     $existing_col = true;
671 751
                 }
672 752
             }
673 753
         }
674 754
 
675
-        if (!$new) {
676
-            if ($options["overwrite"]) {
755
+        if (!$new)
756
+        {
757
+            if ($options["overwrite"])
758
+            {
677 759
                 $stat = $this->DELETE(array("path" => $options["dest"]));
678
-                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
760
+                if (($stat{0} != "2") && (substr($stat, 0, 3) != "404"))
761
+                {
679 762
                     return $stat;
680 763
                 }
681
-            } else {
764
+            }
765
+            else
766
+            {
682 767
                 return "412 precondition failed";
683 768
             }
684 769
         }
685 770
 
686
-        if ($del) {
687
-            if (!rename($source, $dest)) {
771
+        if ($del)
772
+        {
773
+            if (!rename($source, $dest))
774
+            {
688 775
                 return "500 Internal server error";
689 776
             }
690 777
             $destpath = $this->_unslashify($options["dest"]);
691
-            if (is_dir($source)) {
778
+            if (is_dir($source))
779
+            {
692 780
                 $query = "UPDATE {$this->db_prefix}properties
693 781
                                  SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
694 782
                                WHERE path LIKE '".$this->_slashify($options["path"])."%'";
@@ -699,40 +787,58 @@  discard block
 block discarded – undo
699 787
                              SET path = '".$destpath."'
700 788
                            WHERE path = '".$options["path"]."'";
701 789
             mysql_query($query);
702
-        } else {
703
-            if (is_dir($source) && $options["depth"] == "infinity") {	// no find for depth="0"
790
+        }
791
+        else
792
+        {
793
+            if (is_dir($source) && $options["depth"] == "infinity")
794
+            {
795
+// no find for depth="0"
704 796
                 $files = System::find($source);
705 797
                 $files = array_reverse($files);
706
-            } else {
798
+            }
799
+            else
800
+            {
707 801
                 $files = array($source);
708 802
             }
709 803
 
710
-            if (!is_array($files) || empty($files)) {
804
+            if (!is_array($files) || empty($files))
805
+            {
711 806
                 return "500 Internal server error";
712 807
             }
713 808
 
714 809
 
715
-            foreach ($files as $file) {
716
-                if (is_dir($file)) {
810
+            foreach ($files as $file)
811
+            {
812
+                if (is_dir($file))
813
+                {
717 814
                     $file = $this->_slashify($file);
718 815
                 }
719 816
 
720 817
                 $destfile = str_replace($source, $dest, $file);
721 818
 
722
-                if (is_dir($file)) {
723
-                    if (!file_exists($destfile)) {
724
-                        if (!$this->_is_writable(dirname($destfile))) {
819
+                if (is_dir($file))
820
+                {
821
+                    if (!file_exists($destfile))
822
+                    {
823
+                        if (!$this->_is_writable(dirname($destfile)))
824
+                        {
725 825
                             return "403 Forbidden";
726 826
                         }
727
-                        if (!mkdir($destfile)) {
827
+                        if (!mkdir($destfile))
828
+                        {
728 829
                             return "409 Conflict";
729 830
                         }
730
-                    } else if (!is_dir($destfile)) {
831
+                    }
832
+                    else if (!is_dir($destfile))
833
+                    {
731 834
                         return "409 Conflict";
732 835
                     }
733
-                } else {
836
+                }
837
+                else
838
+                {
734 839
 
735
-                    if (!copy($file, $destfile)) {
840
+                    if (!copy($file, $destfile))
841
+                    {
736 842
                         return "409 Conflict";
737 843
                     }
738 844
                 }
@@ -762,17 +868,24 @@  discard block
 block discarded – undo
762 868
         $dir  = dirname($path)."/";
763 869
         $base = basename($path);
764 870
 
765
-        foreach ($options["props"] as $key => $prop) {
766
-            if ($prop["ns"] == "DAV:") {
871
+        foreach ($options["props"] as $key => $prop)
872
+        {
873
+            if ($prop["ns"] == "DAV:")
874
+            {
767 875
                 $options["props"][$key]['status'] = "403 Forbidden";
768
-            } else {
769
-                if (isset($prop["val"])) {
876
+            }
877
+            else
878
+            {
879
+                if (isset($prop["val"]))
880
+                {
770 881
                     $query = "REPLACE INTO {$this->db_prefix}properties
771 882
                                            SET path = '$options[path]'
772 883
                                              , name = '$prop[name]'
773 884
                                              , ns= '$prop[ns]'
774 885
                                              , value = '$prop[val]'";
775
-                } else {
886
+                }
887
+                else
888
+                {
776 889
                     $query = "DELETE FROM {$this->db_prefix}properties
777 890
                                         WHERE path = '$options[path]'
778 891
                                           AND name = '$prop[name]'
@@ -799,13 +912,16 @@  discard block
 block discarded – undo
799 912
 
800 913
         // TODO recursive locks on directories not supported yet
801 914
         // makes litmus test "32. lock_collection" fail
802
-        if (is_dir($fspath) && !empty($options["depth"])) {
915
+        if (is_dir($fspath) && !empty($options["depth"]))
916
+        {
803 917
             return "409 Conflict";
804 918
         }
805 919
 
806 920
         $options["timeout"] = time()+300; // 5min. hardcoded
807 921
 
808
-        if (isset($options["update"])) { // Lock Update
922
+        if (isset($options["update"]))
923
+        {
924
+// Lock Update
809 925
             $where = "WHERE path = '$options[path]' AND token = '$options[update]'";
810 926
 
811 927
             $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where";
@@ -813,7 +929,8 @@  discard block
 block discarded – undo
813 929
             $row   = mysql_fetch_assoc($res);
814 930
             mysql_free_result($res);
815 931
 
816
-            if (is_array($row)) {
932
+            if (is_array($row))
933
+            {
817 934
                 $query = "UPDATE {$this->db_prefix}locks
818 935
                                  SET expires = '$options[timeout]'
819 936
                                    , modified = ".time()."
@@ -825,7 +942,9 @@  discard block
 block discarded – undo
825 942
                 $options['type']  = $row["exclusivelock"] ? "write"     : "read";
826 943
 
827 944
                 return true;
828
-            } else {
945
+            }
946
+            else
947
+            {
829 948
                 return false;
830 949
             }
831 950
         }
@@ -876,11 +995,13 @@  discard block
 block discarded – undo
876 995
                ";
877 996
         $res = mysql_query($query);
878 997
 
879
-        if ($res) {
998
+        if ($res)
999
+        {
880 1000
             $row = mysql_fetch_array($res);
881 1001
             mysql_free_result($res);
882 1002
 
883
-            if ($row) {
1003
+            if ($row)
1004
+            {
884 1005
                 $result = array( "type"    => "write",
885 1006
                                  "scope"   => $row["exclusivelock"] ? "exclusive" : "shared",
886 1007
                                  "depth"   => 0,
Please login to merge, or discard this patch.
api/src/Mail/Imap.php 2 patches
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 		$mailbox = '';
581 581
 		if ( is_int( $restriction_search ) ){
582 582
 			switch ( $restriction_search ) {
583
-			case 0:
584
-				$searchstring = $reference."*";
585
-				break;
586
-			case 1:
587
-				$mailbox = $searchstring = $reference;
588
-				//$reference = '%';
589
-				break;
590
-			case 2:
591
-				$searchstring = $reference."%";
592
-				break;
583
+				case 0:
584
+					$searchstring = $reference."*";
585
+					break;
586
+				case 1:
587
+					$mailbox = $searchstring = $reference;
588
+					//$reference = '%';
589
+					break;
590
+				case 2:
591
+					$searchstring = $reference."%";
592
+					break;
593 593
 			}
594 594
 		}else{
595 595
 			if ( is_string( $restriction_search ) ){
@@ -664,16 +664,16 @@  discard block
 block discarded – undo
664 664
 		$mailbox = '';
665 665
 		if ( is_int( $restriction_search ) ){
666 666
 			switch ( $restriction_search ) {
667
-			case 0:
668
-				$searchstring = $reference."*";
669
-				break;
670
-			case 1:
671
-				$mailbox = $searchstring = $reference;
672
-				//$reference = '%';
673
-				break;
674
-			case 2:
675
-				$searchstring = $reference."%";
676
-				break;
667
+				case 0:
668
+					$searchstring = $reference."*";
669
+					break;
670
+				case 1:
671
+					$mailbox = $searchstring = $reference;
672
+					//$reference = '%';
673
+					break;
674
+				case 2:
675
+					$searchstring = $reference."%";
676
+					break;
677 677
 			}
678 678
 		}else{
679 679
 			if ( is_string( $restriction_search ) ){
@@ -730,16 +730,16 @@  discard block
 block discarded – undo
730 730
 
731 731
 		if ( is_int( $restriction_search ) ){
732 732
 			switch ( $restriction_search ) {
733
-			case 0:
734
-				$mailbox = $reference."*";
735
-				break;
736
-			case 1:
737
-				$mailbox = $reference;
738
-				$reference = '%';
739
-				break;
740
-			case 2:
741
-				$mailbox = "%";
742
-				break;
733
+				case 0:
734
+					$mailbox = $reference."*";
735
+					break;
736
+				case 1:
737
+					$mailbox = $reference;
738
+					$reference = '%';
739
+					break;
740
+				case 2:
741
+					$mailbox = "%";
742
+					break;
743 743
 			}
744 744
 		}else{
745 745
 			if ( is_string( $restriction_search ) ){
Please login to merge, or discard this patch.
Braces   +130 added lines, -42 removed lines patch added patch discarded remove patch
@@ -156,7 +156,10 @@  discard block
 block discarded – undo
156 156
 		$this->loginType = $this->params['acc_imap_logintype'];
157 157
 		$this->domainName = $this->params['acc_domain'];
158 158
 
159
-		if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
159
+		if (is_null($_timeout))
160
+		{
161
+			$_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
162
+		}
160 163
 
161 164
 		// Horde use locale for translation of error messages
162 165
 		Api\Preferences::setlocale(LC_MESSAGES);
@@ -167,7 +170,10 @@  discard block
 block discarded – undo
167 170
 		{
168 171
 			$username = $this->getMailBoxUserName($username);
169 172
 		}
170
-		if ($_adminConnection) $this->adminConnection($username);
173
+		if ($_adminConnection)
174
+		{
175
+			$this->adminConnection($username);
176
+		}
171 177
 		$parent_params = array(
172 178
 			'username' => $this->params[$_adminConnection ? 'acc_imap_admin_username' : 'acc_imap_username'],
173 179
 			'password' => $this->params[$_adminConnection ? 'acc_imap_admin_password' : 'acc_imap_password'],
@@ -303,7 +309,11 @@  discard block
 block discarded – undo
303 309
 	static function getTimeOut($_use='IMAP')
304 310
 	{
305 311
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
306
-		if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value
312
+		if (empty($timeout) || !($timeout > 0))
313
+		{
314
+			$timeout = $_use == 'SIEVE' ? 10 : 20;
315
+		}
316
+		// this is the default value
307 317
 		return $timeout;
308 318
 	}
309 319
 
@@ -366,7 +376,8 @@  discard block
 block discarded – undo
366 376
 	 */
367 377
 	function encodeFolderName($_folderName)
368 378
 	{
369
-		if($this->mbAvailable) {
379
+		if($this->mbAvailable)
380
+		{
370 381
 			return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset());
371 382
 		}
372 383
 
@@ -384,14 +395,21 @@  discard block
 block discarded – undo
384 395
 	function getMailbox($mailbox)
385 396
 	{
386 397
 		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL);
387
-		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
398
+		if (empty($mailboxes))
399
+		{
400
+			$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
401
+		}
388 402
 		//error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes));
389 403
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
390 404
 		//_debug_array($mboxes->count());
391 405
 		foreach ($mboxes->getIterator() as $k =>$box)
392 406
 		{
393 407
 			//error_log(__METHOD__.__LINE__.'->'.$k);
394
-			if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
408
+			if ($k!='user' && $k != '' && $k==$mailbox)
409
+			{
410
+				return $box['mailbox'];
411
+			}
412
+			//_debug_array(array($k => $client->status($k)));
395 413
 		}
396 414
 		return ($this->mailboxExist($mailbox)?$mailbox:false);
397 415
 	}
@@ -460,8 +478,14 @@  discard block
 block discarded – undo
460 478
 			//throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage());
461 479
 			unset($e);
462 480
 		}
463
-		if (!empty($mailbox)) return $mailbox['mailbox'];
464
-		if (empty($mailbox) && $this->mailboxExist('INBOX')) return 'INBOX';
481
+		if (!empty($mailbox))
482
+		{
483
+			return $mailbox['mailbox'];
484
+		}
485
+		if (empty($mailbox) && $this->mailboxExist('INBOX'))
486
+		{
487
+			return 'INBOX';
488
+		}
465 489
 		return null;
466 490
 	}
467 491
 
@@ -531,7 +555,10 @@  discard block
 block discarded – undo
531 555
 			));
532 556
 
533 557
 		$flags = Horde_Imap_Client::STATUS_ALL;
534
-		if ($ignoreStatusCache) $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH;
558
+		if ($ignoreStatusCache)
559
+		{
560
+			$flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH;
561
+		}
535 562
 
536 563
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
537 564
 		//error_log(__METHOD__.__LINE__.array2string($mboxes->count()));
@@ -574,12 +601,15 @@  discard block
 block discarded – undo
574 601
 	 */
575 602
 	function getMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
576 603
 	{
577
-		if ( is_bool($restriction_search) ){
604
+		if ( is_bool($restriction_search) )
605
+		{
578 606
 			$restriction_search = (int) $restriction_search;
579 607
 		}
580 608
 		$mailbox = '';
581
-		if ( is_int( $restriction_search ) ){
582
-			switch ( $restriction_search ) {
609
+		if ( is_int( $restriction_search ) )
610
+		{
611
+			switch ( $restriction_search )
612
+			{
583 613
 			case 0:
584 614
 				$searchstring = $reference."*";
585 615
 				break;
@@ -591,8 +621,11 @@  discard block
 block discarded – undo
591 621
 				$searchstring = $reference."%";
592 622
 				break;
593 623
 			}
594
-		}else{
595
-			if ( is_string( $restriction_search ) ){
624
+		}
625
+		else
626
+		{
627
+			if ( is_string( $restriction_search ) )
628
+			{
596 629
 				$mailbox = $searchstring = $restriction_search;
597 630
 			}
598 631
 		}
@@ -658,12 +691,15 @@  discard block
 block discarded – undo
658 691
 	 */
659 692
 	function listSubscribedMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
660 693
 	{
661
-		if ( is_bool($restriction_search) ){
694
+		if ( is_bool($restriction_search) )
695
+		{
662 696
 			$restriction_search = (int) $restriction_search;
663 697
 		}
664 698
 		$mailbox = '';
665
-		if ( is_int( $restriction_search ) ){
666
-			switch ( $restriction_search ) {
699
+		if ( is_int( $restriction_search ) )
700
+		{
701
+			switch ( $restriction_search )
702
+			{
667 703
 			case 0:
668 704
 				$searchstring = $reference."*";
669 705
 				break;
@@ -675,8 +711,11 @@  discard block
 block discarded – undo
675 711
 				$searchstring = $reference."%";
676 712
 				break;
677 713
 			}
678
-		}else{
679
-			if ( is_string( $restriction_search ) ){
714
+		}
715
+		else
716
+		{
717
+			if ( is_string( $restriction_search ) )
718
+			{
680 719
 				$mailbox = $searchstring = $restriction_search;
681 720
 			}
682 721
 		}
@@ -724,12 +763,15 @@  discard block
 block discarded – undo
724 763
 	 */
725 764
 	function listUnSubscribedMailboxes($reference = ''  , $restriction_search = 0)
726 765
 	{
727
-		if ( is_bool($restriction_search) ){
766
+		if ( is_bool($restriction_search) )
767
+		{
728 768
 			$restriction_search = (int) $restriction_search;
729 769
 		}
730 770
 
731
-		if ( is_int( $restriction_search ) ){
732
-			switch ( $restriction_search ) {
771
+		if ( is_int( $restriction_search ) )
772
+		{
773
+			switch ( $restriction_search )
774
+			{
733 775
 			case 0:
734 776
 				$mailbox = $reference."*";
735 777
 				break;
@@ -741,8 +783,11 @@  discard block
 block discarded – undo
741 783
 				$mailbox = "%";
742 784
 				break;
743 785
 			}
744
-		}else{
745
-			if ( is_string( $restriction_search ) ){
786
+		}
787
+		else
788
+		{
789
+			if ( is_string( $restriction_search ) )
790
+			{
746 791
 				$mailbox = $restriction_search;
747 792
 			}
748 793
 		}
@@ -761,7 +806,10 @@  discard block
 block discarded – undo
761 806
 		foreach ($unsubscribed as $box)
762 807
 		{
763 808
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
764
-			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8;
809
+			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX')
810
+			{
811
+				$ret[]=$box['mailbox']->utf8;
812
+			}
765 813
 		}
766 814
 		return $ret;
767 815
 	}
@@ -775,10 +823,16 @@  discard block
 block discarded – undo
775 823
 	 */
776 824
 	function examineMailbox($mailbox, $flags=null)
777 825
 	{
778
-		if ($mailbox=='') return false;
826
+		if ($mailbox=='')
827
+		{
828
+			return false;
829
+		}
779 830
 		$mailboxes = $this->listMailboxes($mailbox);
780 831
 
781
-		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
832
+		if (is_null($flags))
833
+		{
834
+			$flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
835
+		}
782 836
 
783 837
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
784 838
 		//_debug_array($mboxes->count());
@@ -860,7 +914,10 @@  discard block
 block discarded – undo
860 914
 		}
861 915
 		catch (\Exception $e)
862 916
 		{
863
-			if ($this->debug) error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage());
917
+			if ($this->debug)
918
+			{
919
+				error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage());
920
+			}
864 921
 			return false;
865 922
 		}
866 923
 		if (!is_array($cap))
@@ -900,7 +957,10 @@  discard block
 block discarded – undo
900 957
 	{
901 958
 		foreach($_nameSpace as &$singleNameSpace)
902 959
 		{
903
-			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
960
+			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix'])
961
+			{
962
+				return $singleNameSpace['prefix'];
963
+			}
904 964
 		}
905 965
 		return "";
906 966
 	}
@@ -917,7 +977,8 @@  discard block
 block discarded – undo
917 977
 	 */
918 978
 	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
919 979
 	{
920
-		if ($reclevel > 25) {
980
+		if ($reclevel > 25)
981
+		{
921 982
 			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
922 983
 			return array();
923 984
 		}
@@ -933,7 +994,8 @@  discard block
 block discarded – undo
933 994
 		{
934 995
 			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false);
935 996
 			$allMailboxes = array();
936
-			foreach ($buff as $mbxname) {
997
+			foreach ($buff as $mbxname)
998
+			{
937 999
 				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
938 1000
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
939 1001
 				if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix  && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
@@ -941,7 +1003,10 @@  discard block
 block discarded – undo
941 1003
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
942 1004
 				}
943 1005
 			}
944
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
1006
+			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
1007
+			{
1008
+				$allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
1009
+			}
945 1010
 			return $allMailboxes;
946 1011
 		}
947 1012
 		else
@@ -963,9 +1028,16 @@  discard block
 block discarded – undo
963 1028
 		static $nameSpace=null;
964 1029
 		$foldersNameSpace = array();
965 1030
 		$delimiter = $this->getDelimiter();
966
-		if (empty($delimiter)) $delimiter='/';
967
-		if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray();
968
-		if (is_array($nameSpace)) {
1031
+		if (empty($delimiter))
1032
+		{
1033
+			$delimiter='/';
1034
+		}
1035
+		if (is_null($nameSpace))
1036
+		{
1037
+			$nameSpace = $this->getNameSpaceArray();
1038
+		}
1039
+		if (is_array($nameSpace))
1040
+		{
969 1041
 			foreach($nameSpace as $type => $singleNameSpaceArray)
970 1042
 			{
971 1043
 				foreach ($singleNameSpaceArray as $singleNameSpace)
@@ -982,7 +1054,9 @@  discard block
 block discarded – undo
982 1054
 						$_foldersNameSpace['prefix_present'] = 'forced';
983 1055
 						// uw-imap server with mailbox prefix or dovecot maybe
984 1056
 						$_foldersNameSpace['prefix'] = 'mail';
985
-					} else {
1057
+					}
1058
+					else
1059
+					{
986 1060
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
987 1061
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
988 1062
 					}
@@ -1022,7 +1096,10 @@  discard block
 block discarded – undo
1022 1096
 		$namespaces = $this->getNamespaces();
1023 1097
 		foreach ($namespaces as $nsp)
1024 1098
 		{
1025
-			if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter'];
1099
+			if ($nsp['type']==$type && $nsp['delimiter'])
1100
+			{
1101
+				return $nsp['delimiter'];
1102
+			}
1026 1103
 		}
1027 1104
 		return "/";
1028 1105
 	}
@@ -1131,12 +1208,14 @@  discard block
 block discarded – undo
1131 1208
 	{
1132 1209
 		$nameSpaces = $this->getNameSpaceArray();
1133 1210
 
1134
-		if(!isset($nameSpaces['others'])) {
1211
+		if(!isset($nameSpaces['others']))
1212
+		{
1135 1213
 			return false;
1136 1214
 		}
1137 1215
 
1138 1216
 		$username = $this->getMailBoxUserName($_username);
1139
-		if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') {
1217
+		if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber')
1218
+		{
1140 1219
 			$username .= '@'. $this->domainName;
1141 1220
 		}
1142 1221
 
@@ -1288,7 +1367,10 @@  discard block
 block discarded – undo
1288 1367
 	 */
1289 1368
 	public function __call($name,array $params=null)
1290 1369
 	{
1291
-		if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1370
+		if ($this->debug)
1371
+		{
1372
+			error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1373
+		}
1292 1374
 		switch($name)
1293 1375
 		{
1294 1376
 			case 'installScript':
@@ -1323,7 +1405,10 @@  discard block
 block discarded – undo
1323 1405
 	 */
1324 1406
 	public function setVacationUser($_euser, array $_vacation, $_scriptName=null)
1325 1407
 	{
1326
-		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1408
+		if ($this->debug)
1409
+		{
1410
+			error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1411
+		}
1327 1412
 
1328 1413
 		if (is_numeric($_euser))
1329 1414
 		{
@@ -1351,7 +1436,10 @@  discard block
 block discarded – undo
1351 1436
 	 */
1352 1437
 	public function getVacationUser($_euser, $_scriptName=null)
1353 1438
 	{
1354
-		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser));
1439
+		if ($this->debug)
1440
+		{
1441
+			error_log(__METHOD__.' User:'.array2string($_euser));
1442
+		}
1355 1443
 
1356 1444
 		if (is_numeric($_euser))
1357 1445
 		{
Please login to merge, or discard this patch.
setup/setup-cli.php 2 patches
Switch Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -68,91 +68,91 @@
 block discarded – undo
68 68
 
69 69
 switch($action)
70 70
 {
71
-	case '--version':
72
-	case '--check':
73
-		setup_cmd::check_installed($arguments[0],0,true);
74
-		break;
75
-
76
-	case '--create-header':
77
-	case '--edit-header':
78
-	case '--upgrade-header':
79
-	case '--update-header':
80
-		do_header($action == '--create-header',$arguments);
81
-		break;
82
-
83
-	case '--install':
84
-		do_install($arguments);
85
-		break;
86
-
87
-	case '--config':
88
-		do_config($arguments);
89
-		break;
90
-
91
-	case '--admin':
92
-		do_admin($arguments[0]);
93
-		break;
94
-
95
-	case '--update':
96
-		do_update($arguments[0]);
97
-		break;
98
-
99
-	case '--register-hooks':
100
-	case '--register-all-hooks':
101
-		do_hooks($arguments[0]);
102
-		break;
103
-
104
-	case '--backup':
105
-		do_backup($arguments[0]);
106
-		break;
107
-
108
-	case '--languages':
109
-		echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
110
-		break;
111
-
112
-	case '--charsets':
113
-		echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
114
-		break;
115
-
116
-	case '--exit-codes':
117
-		list_exit_codes();
118
-		break;
119
-
120
-	case '--help':
121
-	case '--usage':
122
-		do_usage($arguments[0]);
123
-		break;
124
-
125
-	default:
126
-		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
127
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
128
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
129
-		{
130
-			$args = array();
131
-			list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
132
-			foreach($arguments as $arg)
71
+		case '--version':
72
+		case '--check':
73
+			setup_cmd::check_installed($arguments[0],0,true);
74
+			break;
75
+
76
+		case '--create-header':
77
+		case '--edit-header':
78
+		case '--upgrade-header':
79
+		case '--update-header':
80
+			do_header($action == '--create-header',$arguments);
81
+			break;
82
+
83
+		case '--install':
84
+			do_install($arguments);
85
+			break;
86
+
87
+		case '--config':
88
+			do_config($arguments);
89
+			break;
90
+
91
+		case '--admin':
92
+			do_admin($arguments[0]);
93
+			break;
94
+
95
+		case '--update':
96
+			do_update($arguments[0]);
97
+			break;
98
+
99
+		case '--register-hooks':
100
+		case '--register-all-hooks':
101
+			do_hooks($arguments[0]);
102
+			break;
103
+
104
+		case '--backup':
105
+			do_backup($arguments[0]);
106
+			break;
107
+
108
+		case '--languages':
109
+			echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
110
+			break;
111
+
112
+		case '--charsets':
113
+			echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
114
+			break;
115
+
116
+		case '--exit-codes':
117
+			list_exit_codes();
118
+			break;
119
+
120
+		case '--help':
121
+		case '--usage':
122
+			do_usage($arguments[0]);
123
+			break;
124
+
125
+		default:
126
+			// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
127
+			if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
128
+				is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
133 129
 			{
134
-				list($name,$value) = explode('=',$arg,2);
135
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
136
-				{
137
-					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138
-				}
139
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
130
+				$args = array();
131
+				list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
132
+				foreach($arguments as $arg)
140 133
 				{
141
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
142
-					$args[$name][$sub] = $value;
143
-				}
144
-				else
145
-				{
146
-					$args[$name] = $value;
134
+					list($name,$value) = explode('=',$arg,2);
135
+					if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
136
+					{
137
+						throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138
+					}
139
+					if (substr($name,-1) == ']')	// allow 1-dim. arrays
140
+					{
141
+						list($name,$sub) = explode('[',substr($name,0,-1),2);
142
+						$args[$name][$sub] = $value;
143
+					}
144
+					else
145
+					{
146
+						$args[$name] = $value;
147
+					}
147 148
 				}
149
+				$cmd = new $class($args);
150
+				$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
+				if (is_array($msg)) $msg = print_r($msg,true);
152
+				echo "$msg\n";
153
+				break;
148 154
 			}
149
-			$cmd = new $class($args);
150
-			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
-			if (is_array($msg)) $msg = print_r($msg,true);
152
-			echo "$msg\n";
153
-			break;
154
-		}
155
-		throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90);
155
+			throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90);
156 156
 }
157 157
 exit(0);
158 158
 
Please login to merge, or discard this patch.
Braces   +69 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 
16 16
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
17 17
 
18
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
18
+if (php_sapi_name() !== 'cli')
19
+{
20
+	// security precaution: forbit calling setup-cli as web-page
19 21
 {
20 22
 	die('<h1>setup-cli.php must NOT be called as web-page --> exiting !!!</h1>');
21 23
 }
24
+}
22 25
 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
23 26
 
24 27
 $dry_run = false;
@@ -33,7 +36,11 @@  discard block
 block discarded – undo
33 36
 	}
34 37
 	$arguments = $_SERVER['argv'];
35 38
 	$action = array_shift($arguments);
36
-	if (isset($arguments[0])) list($_POST['FormDomain']) = explode(',',$arguments[0]);	// header include needs that to detects the right domain
39
+	if (isset($arguments[0]))
40
+	{
41
+		list($_POST['FormDomain']) = explode(',',$arguments[0]);
42
+	}
43
+	// header include needs that to detects the right domain
37 44
 }
38 45
 else
39 46
 {
@@ -51,7 +58,10 @@  discard block
 block discarded – undo
51 58
 // check if date.timezone is set, report it and set something if not, as it gives tons of errors in install log
52 59
 if (!ini_get('date.timezone'))
53 60
 {
54
-	if (!($tz = date_default_timezone_get())) $tz = 'UTC';
61
+	if (!($tz = date_default_timezone_get()))
62
+	{
63
+		$tz = 'UTC';
64
+	}
55 65
 	echo "No default timezone (php.ini date.timezone) set, we temporary set '$tz'. You should fix that permanent!\n";
56 66
 	ini_set('date.timezone',$tz);
57 67
 }
@@ -132,13 +142,19 @@  discard block
 block discarded – undo
132 142
 			foreach($arguments as $arg)
133 143
 			{
134 144
 				list($name,$value) = explode('=',$arg,2);
135
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
145
+				if(property_exists('admin_cmd',$name))
146
+				{
147
+					// dont allow to overwrite admin_cmd properties
136 148
 				{
137 149
 					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138 150
 				}
139
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
151
+				}
152
+				if (substr($name,-1) == ']')
153
+				{
154
+					// allow 1-dim. arrays
140 155
 				{
141 156
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
157
+				}
142 158
 					$args[$name][$sub] = $value;
143 159
 				}
144 160
 				else
@@ -148,7 +164,10 @@  discard block
 block discarded – undo
148 164
 			}
149 165
 			$cmd = new $class($args);
150 166
 			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
-			if (is_array($msg)) $msg = print_r($msg,true);
167
+			if (is_array($msg))
168
+			{
169
+				$msg = print_r($msg,true);
170
+			}
152 171
 			echo "$msg\n";
153 172
 			break;
154 173
 		}
@@ -164,14 +183,20 @@  discard block
 block discarded – undo
164 183
 function do_config($args)
165 184
 {
166 185
 	$arg0 = explode(',',array_shift($args));
167
-	if (!($domain = @array_shift($arg0))) $domain = 'default';
186
+	if (!($domain = @array_shift($arg0)))
187
+	{
188
+		$domain = 'default';
189
+	}
168 190
 	$user = @array_shift($arg0);
169 191
 	$password = @array_shift($arg0);
170 192
 	_fetch_user_password($user,$password);
171 193
 
172
-	if ($arg0)	// direct assignments (name=value,...) left
194
+	if ($arg0)
195
+	{
196
+		// direct assignments (name=value,...) left
173 197
 	{
174 198
 		array_unshift($args,implode(',',$arg0));
199
+	}
175 200
 		array_unshift($args,'--config');
176 201
 	}
177 202
 
@@ -238,9 +263,15 @@  discard block
 block discarded – undo
238 263
 	{
239 264
 		$options[0] = $domain;
240 265
 
241
-		if ($quite_check) ob_start();
266
+		if ($quite_check)
267
+		{
268
+			ob_start();
269
+		}
242 270
 		_check_auth_config(implode(',',$options),14);
243
-		if ($quite_check) ob_end_clean();
271
+		if ($quite_check)
272
+		{
273
+			ob_end_clean();
274
+		}
244 275
 
245 276
 		if ($backup == 'no')
246 277
 		{
@@ -316,7 +347,10 @@  discard block
 block discarded – undo
316 347
 function _check_auth_config($arg,$stop,$set_lang=true)
317 348
 {
318 349
 	$options = explode(',',$arg);
319
-	if (!($domain = array_shift($options))) $domain = 'default';
350
+	if (!($domain = array_shift($options)))
351
+	{
352
+		$domain = 'default';
353
+	}
320 354
 	$user = array_shift($options);
321 355
 	$password = array_shift($options);
322 356
 	_fetch_user_password($user,$password);
@@ -324,7 +358,10 @@  discard block
 block discarded – undo
324 358
 	setup_cmd::check_installed($domain,$stop,true);
325 359
 
326 360
 	// reset charset for the output to the charset used by the OS
327
-	if ($set_lang) $GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
361
+	if ($set_lang)
362
+	{
363
+		$GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
364
+	}
328 365
 
329 366
 	setup_cmd::check_setup_auth($user,$password,$domain);
330 367
 
@@ -360,7 +397,10 @@  discard block
 block discarded – undo
360 397
 function _fetch_user_password(&$user,&$password)
361 398
 {
362 399
 	// read password from enviroment or query it from user, if not given
363
-	if (!$user) $user = 'admin';
400
+	if (!$user)
401
+	{
402
+		$user = 'admin';
403
+	}
364 404
 	if (!$password && !($password = $_SERVER['EGW_CLI_PASSWORD']))
365 405
 	{
366 406
 		echo lang('Admin password to header manager').' ';
@@ -406,9 +446,15 @@  discard block
 block discarded – undo
406 446
 		list($code,$language) = explode("\t",$line);
407 447
 		$languages[$code] = $language;
408 448
 	}
409
-	if (isset($languages[$lang.'-'.$nation])) return $lang.'-'.$nation;
449
+	if (isset($languages[$lang.'-'.$nation]))
450
+	{
451
+		return $lang.'-'.$nation;
452
+	}
410 453
 
411
-	if (isset($languages[$lang])) return $lang;
454
+	if (isset($languages[$lang]))
455
+	{
456
+		return $lang;
457
+	}
412 458
 
413 459
 	return 'en';
414 460
 }
@@ -448,7 +494,10 @@  discard block
 block discarded – undo
448 494
 	if (!$what || $what == 'config')
449 495
 	{
450 496
 		echo '--config '.lang('domain(default),[config user(admin)],password,[name=value,...] sets config values beside:')."\n";
451
-		if (!$what) echo '	--help config '.lang('gives further options')."\n";
497
+		if (!$what)
498
+		{
499
+			echo '	--help config '.lang('gives further options')."\n";
500
+		}
452 501
 	}
453 502
 	if ($what == 'config')
454 503
 	{
@@ -477,7 +526,10 @@  discard block
 block discarded – undo
477 526
 		echo lang('Create or edit the EGroupware configuration file: header.inc.php:')."\n";
478 527
 		echo '--create-header '.lang('header-password[,header-user(admin)]')."\n";
479 528
 		echo '--edit-header '.lang('[header-password],[header-user],[new-password],[new-user]')."\n";
480
-		if (!$what) echo '	--help header '.lang('gives further options')."\n";
529
+		if (!$what)
530
+		{
531
+			echo '	--help header '.lang('gives further options')."\n";
532
+		}
481 533
 	}
482 534
 	if ($what == 'header')
483 535
 	{
Please login to merge, or discard this patch.
setup/index.php 2 patches
Switch Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 
185 185
 switch($GLOBALS['egw_info']['setup']['stage']['db'])
186 186
 {
187
-	case 1:
188
-		$setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error);
189
-		$setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set'));
190
-		$setup_tpl->set_var('notcomplete',lang('not complete'));
191
-		$setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly'));
192
-		$setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>');
193
-		$setup_tpl->set_var('create_database',lang('Create database'));
194
-		$setup_tpl->set_var('instr','');
195
-		$info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain];
196
-		switch ($info['db_type'])
197
-		{
187
+		case 1:
188
+			$setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error);
189
+			$setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set'));
190
+			$setup_tpl->set_var('notcomplete',lang('not complete'));
191
+			$setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly'));
192
+			$setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>');
193
+			$setup_tpl->set_var('create_database',lang('Create database'));
194
+			$setup_tpl->set_var('instr','');
195
+			$info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain];
196
+			switch ($info['db_type'])
197
+			{
198 198
 			case 'mysql':
199 199
 			case 'mysqli':
200 200
 			case 'mysqlt':
@@ -227,77 +227,77 @@  discard block
 block discarded – undo
227 227
 				//break;
228 228
 			default:
229 229
 				$setup_tpl->parse('V_db_stage_1','B_db_stage_1a');
230
-		}
230
+			}
231 231
 		$db_filled_block = $setup_tpl->get_var('V_db_stage_1');
232 232
 		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
233 233
 		break;
234
-	case 2:
235
-		$setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.'));
236
-		$setup_tpl->set_var('notcomplete',lang('not complete'));
237
-		$setup_tpl->parse('V_db_stage_2','B_db_stage_2');
238
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_2');
239
-		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
240
-		break;
241
-	case 3:
242
-		$setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>');
243
-		$setup_tpl->set_var('install',lang('Install'));
244
-		$setup_tpl->set_var('proceed',lang('We can proceed'));
245
-		$setup_tpl->set_var('coreapps',lang('all applications'));
246
-		$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
247
-		$setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.'));
248
-		$setup_tpl->set_var('upload','<input type="file" name="uploaded" /> &nbsp;'.
249
-			'<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />');
250
-		$setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>');
251
-		$setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'.
252
-			lang('Convert backup to charset selected above').'</label>');
253
-		$setup_tpl->parse('V_db_stage_3','B_db_stage_3');
254
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_3');
255
-		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
256
-		break;
257
-	case 4:
258
-		$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
259
-		$setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',
260
-			isset($setup_info['api']['currentver']) ? $setup_info['api']['currentver'] : $setup_info['phpgwapi']['currentver']));
261
-		$setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['api']['version']));
262
-		$setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>'));
263
-		$setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB'));
264
-		$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
265
-		$setup_tpl->set_var('upgrade',lang('Upgrade'));
266
-		$setup_tpl->set_var('goto',lang('Go to'));
267
-		$setup_tpl->set_var('configuration',lang('configuration'));
268
-		$setup_tpl->set_var('admin_account',lang('Create admin account'));
269
-		$setup_tpl->set_var('applications',lang('Manage Applications'));
270
-		$setup_tpl->set_var('db_backup',lang('DB backup and restore'));
271
-		$setup_tpl->set_var('language_management',lang('Manage Languages'));
272
-		$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
273
-		$setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data'));
274
-		$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
234
+		case 2:
235
+			$setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.'));
236
+			$setup_tpl->set_var('notcomplete',lang('not complete'));
237
+			$setup_tpl->parse('V_db_stage_2','B_db_stage_2');
238
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_2');
239
+			$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
240
+			break;
241
+		case 3:
242
+			$setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>');
243
+			$setup_tpl->set_var('install',lang('Install'));
244
+			$setup_tpl->set_var('proceed',lang('We can proceed'));
245
+			$setup_tpl->set_var('coreapps',lang('all applications'));
246
+			$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
247
+			$setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.'));
248
+			$setup_tpl->set_var('upload','<input type="file" name="uploaded" /> &nbsp;'.
249
+				'<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />');
250
+			$setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>');
251
+			$setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'.
252
+				lang('Convert backup to charset selected above').'</label>');
253
+			$setup_tpl->parse('V_db_stage_3','B_db_stage_3');
254
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_3');
255
+			$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
256
+			break;
257
+		case 4:
258
+			$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
259
+			$setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',
260
+				isset($setup_info['api']['currentver']) ? $setup_info['api']['currentver'] : $setup_info['phpgwapi']['currentver']));
261
+			$setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['api']['version']));
262
+			$setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>'));
263
+			$setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB'));
264
+			$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
265
+			$setup_tpl->set_var('upgrade',lang('Upgrade'));
266
+			$setup_tpl->set_var('goto',lang('Go to'));
267
+			$setup_tpl->set_var('configuration',lang('configuration'));
268
+			$setup_tpl->set_var('admin_account',lang('Create admin account'));
269
+			$setup_tpl->set_var('applications',lang('Manage Applications'));
270
+			$setup_tpl->set_var('db_backup',lang('DB backup and restore'));
271
+			$setup_tpl->set_var('language_management',lang('Manage Languages'));
272
+			$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
273
+			$setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data'));
274
+			$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
275 275
 
276
-		$setup_tpl->parse('V_db_stage_4','B_db_stage_4');
277
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_4');
278
-		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
279
-		break;
280
-	case 5:
281
-		$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
282
-		$setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?'));
283
-		$setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications'));
284
-		$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
285
-		$setup_tpl->set_var('cancel',lang('cancel'));
286
-		$setup_tpl->parse('V_db_stage_5','B_db_stage_5');
287
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_5');
288
-		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
289
-		break;
290
-	case 6:
291
-		$setup_tpl->set_var('status',lang('Status'));
292
-		$setup_tpl->set_var('notcomplete',lang('not complete'));
293
-		$setup_tpl->set_var('tblchange',lang('Table Change Messages'));
294
-		$setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre');
295
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre');
296
-		$setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been'));
276
+			$setup_tpl->parse('V_db_stage_4','B_db_stage_4');
277
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_4');
278
+			$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
279
+			break;
280
+		case 5:
281
+			$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
282
+			$setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?'));
283
+			$setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications'));
284
+			$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
285
+			$setup_tpl->set_var('cancel',lang('cancel'));
286
+			$setup_tpl->parse('V_db_stage_5','B_db_stage_5');
287
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_5');
288
+			$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
289
+			break;
290
+		case 6:
291
+			$setup_tpl->set_var('status',lang('Status'));
292
+			$setup_tpl->set_var('notcomplete',lang('not complete'));
293
+			$setup_tpl->set_var('tblchange',lang('Table Change Messages'));
294
+			$setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre');
295
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre');
296
+			$setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been'));
297 297
 
298
-		try {	// catch DB errors to report them
299
-			switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi'])
300
-			{
298
+			try {	// catch DB errors to report them
299
+				switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi'])
300
+				{
301 301
 				case 'dbcreate':
302 302
 					$GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], 'utf8',	// create all new db's with utf8
303 303
 						!preg_match('/^[0-9.a-z_]+$/i', $_POST['db_grant_host']) ? 'localhost' : $_POST['db_grant_host']);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 						$GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
377 377
 					}
378 378
 					break;
379
-			}
379
+				}
380 380
 		}
381 381
 		catch (Api\Db\Exception $e)
382 382
 		{
@@ -388,21 +388,21 @@  discard block
 block discarded – undo
388 388
 		$db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post');
389 389
 		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
390 390
 		break;
391
-	case 10:
392
-		$setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current'));
393
-		$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
394
-		$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
395
-		$setup_tpl->set_var('deletetables',lang('Uninstall all applications'));
396
-		$setup_tpl->parse('V_db_stage_10','B_db_stage_10');
397
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_10');
398
-		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
399
-		break;
400
-	default:
401
-		$setup_tpl->set_var('dbnotexist',lang('Your database does not exist'));
402
-		$setup_tpl->parse('V_db_stage_default','B_db_stage_default');
403
-		$db_filled_block = $setup_tpl->get_var('V_db_stage_default');
404
-		$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
405
-		break;
391
+		case 10:
392
+			$setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current'));
393
+			$setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
394
+			$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
395
+			$setup_tpl->set_var('deletetables',lang('Uninstall all applications'));
396
+			$setup_tpl->parse('V_db_stage_10','B_db_stage_10');
397
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_10');
398
+			$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
399
+			break;
400
+		default:
401
+			$setup_tpl->set_var('dbnotexist',lang('Your database does not exist'));
402
+			$setup_tpl->parse('V_db_stage_default','B_db_stage_default');
403
+			$db_filled_block = $setup_tpl->get_var('V_db_stage_default');
404
+			$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
405
+			break;
406 406
 }
407 407
 
408 408
 // Config Section
Please login to merge, or discard this patch.
Braces   +15 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,10 +49,13 @@  discard block
 block discarded – undo
49 49
 $GLOBALS['egw_info']['setup']['stage']['header'] = $GLOBALS['egw_setup']->detection->check_header();
50 50
 if ($GLOBALS['egw_info']['setup']['stage']['header'] != '10')
51 51
 {
52
-	if ($GLOBALS['egw_info']['setup']['stage']['header'] == 4)	// header needs update, go there direct
52
+	if ($GLOBALS['egw_info']['setup']['stage']['header'] == 4)
53
+	{
54
+		// header needs update, go there direct
53 55
 	{
54 56
 		Header('Location: manageheader.php');
55 57
 	}
58
+	}
56 59
 	else	// run check-install first
57 60
 	{
58 61
 		Header('Location: check_install.php?intro=1');
@@ -97,7 +100,9 @@  discard block
 block discarded – undo
97 100
 	}
98 101
 }
99 102
 
100
-if ($GLOBALS['DEBUG']) { echo 'Stage: ' . $GLOBALS['egw_info']['setup']['stage']['db']; }
103
+if ($GLOBALS['DEBUG'])
104
+{
105
+echo 'Stage: ' . $GLOBALS['egw_info']['setup']['stage']['db']; }
101 106
 // begin DEBUG code
102 107
 //$GLOBALS['egw_info']['setup']['stage']['db'] = 0;
103 108
 //$action = 'Upgrade';
@@ -501,8 +506,14 @@  discard block
 block discarded – undo
501 506
 		$msg = '';
502 507
 		if ($to_upgrade || $to_install)
503 508
 		{
504
-			if ($to_upgrade) $msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade);
505
-			if ($to_install) $msg .= ($msg?'<br />':'').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ',$to_install);
509
+			if ($to_upgrade)
510
+			{
511
+				$msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade);
512
+			}
513
+			if ($to_install)
514
+			{
515
+				$msg .= ($msg?'<br />':'').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ',$to_install);
516
+			}
506 517
 		}
507 518
 		$btn_manage_apps = $GLOBALS['egw_setup']->html->make_frm_btn_simple(
508 519
 			$msg ? $msg : lang('This stage is completed<br />'),
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_admin.inc.php 1 patch
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -131,7 +131,10 @@  discard block
 block discarded – undo
131 131
 					($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount']))
132 132
 				{
133 133
 					$url = str_replace('$path',$path,$content['mounts']['url']);
134
-					if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path;
134
+					if (empty($url) && $this->versioning)
135
+					{
136
+						$url = Versioning\StreamWrapper::PREFIX.$path;
137
+					}
135 138
 
136 139
 					if ($content['mounts']['enable'] && !$this->versioning)
137 140
 					{
@@ -227,16 +230,25 @@  discard block
 block discarded – undo
227 230
 			$content['versionedpath'] = '/';
228 231
 			$content['mtime'] = 100;
229 232
 		}
230
-		if (true) $content = array(
233
+		if (true)
234
+		{
235
+			$content = array(
231 236
 			'versionedpath' => $content['versionedpath'],
232 237
 			'mtime' => $content['mtime'],
233 238
 		);
239
+		}
234 240
 		if ($this->versioning)
235 241
 		{
236 242
 			// statistical information
237 243
 			$content += Versioning\StreamWrapper::summary();
238
-			if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
239
-			if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
244
+			if ($content['total_files'])
245
+			{
246
+				$content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%';
247
+			}
248
+			if ($content['total_size'])
249
+			{
250
+				$content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%';
251
+			}
240 252
 		}
241 253
 		if (!($content['is_root']=Vfs::$is_root))
242 254
 		{
Please login to merge, or discard this patch.