Skip to content

Commit 79f2ecd

Browse files
author
Damian
committed
Merge branch 'release/3.1'
2 parents c03f5c3 + 98c0c90 commit 79f2ecd

File tree

27 files changed

+672
-257
lines changed

27 files changed

+672
-257
lines changed

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
3.1
2+
IMPORTANT !
3+
Before update, please! make backup of database - I have to improve settings in database (remove duplicate data).
4+
5+
Change:
6+
* start and end date/time
7+
* time in modal
8+
* time format
9+
* add menu in dashboard to better navigation
10+
* bug fixes
11+
112
3.0.2
213
Join all JS scripts in block
314

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,22 @@ If you choose "One day with time" event you can resize event for more days.
2525

2626
Version
2727
----
28-
3.0.2
28+
3.1
2929

3030
Changelog
3131
----
32+
3.1
33+
IMPORTANT !
34+
Before update, please! make backup of database - I have to improve settings in database (remove duplicate data).
35+
36+
Change:
37+
* start and end date/time
38+
* time in modal
39+
* time format
40+
* add menu in dashboard to better navigation
41+
* bug fixes
42+
43+
3244
3.0.2
3345
Join all JS scripts in block
3446

blocks/event_calendar/css/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blocks/event_calendar/icon.png

814 Bytes
Loading

blocks/event_calendar/sass/style.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ $blue-dark: darken($blue, 5%);
8585
}
8686

8787
.container {
88-
width: 35%;
89-
min-width: 500px;
88+
min-width: 35%;
89+
max-width: 90%;
90+
max-height: 80%;
91+
overflow-y: auto;
9092
background-color: #fff;
9193
border: 1px solid $gray;
9294
text-align: center;

blocks/event_calendar/view.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@
4343
var settings = {};
4444
var set_serv = <?php echo $settings; ?>;
4545

46+
if (!Object.keys) {
47+
Object.keys = function(obj) {
48+
var keys = [];
49+
50+
for (var i in obj) {
51+
if (obj.hasOwnProperty(i)) {
52+
keys.push(i);
53+
}
54+
}
55+
56+
return keys;
57+
};
58+
}
59+
4660
for(var key in set_serv) {
4761
var value = set_serv[key];
4862
var k = Object.keys(value);
@@ -61,16 +75,32 @@
6175
},
6276
slotDuration: "00:30:00",
6377
defaultTimedEventDuration: "00:30:00",
64-
timeFormat: "HH:mm",
78+
timeFormat: settings.timeFormat,
6579
eventClick: function(calEvent, jsEvent, view) {
66-
6780
if(calEvent.url)
6881
return;
6982

70-
var start_day = calEvent.start.format(settings.formatEvent);
71-
var end_day = "";
72-
if(calEvent.end != null)
73-
end_day = " - " + calEvent.end.format(settings.formatEvent);
83+
var start_day;
84+
var end_day;
85+
86+
if(calEvent.allDayEvent == 0)
87+
{
88+
//with time
89+
start_day = calEvent.start.format(settings.timeFormat);
90+
end_day = "";
91+
if(calEvent.end != null)
92+
end_day = " - " + calEvent.end.format(settings.timeFormat);
93+
end_day += " " + calEvent.end.format(settings.formatEvent);
94+
95+
}
96+
else
97+
{
98+
//witout time
99+
start_day = calEvent.start.format(settings.formatEvent);
100+
end_day = "";
101+
if(calEvent.end != null)
102+
end_day = " - " + calEvent.end.format(settings.formatEvent);
103+
}
74104

75105
modal.find('.header .title').text(calEvent.title);
76106
modal.find('.content .time').text(start_day + end_day);

controller.php

Lines changed: 120 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class dsEventCalendarPackage extends Package
77

88
protected $pkgHandle = 'dsEventCalendar';
99
protected $appVersionRequired = '5.5.0';
10-
protected $pkgVersion = '3.0.3';
10+
protected $pkgVersion = '3.1.0';
1111

1212
public function getPackageDescription()
1313
{
@@ -30,13 +30,18 @@ public function install()
3030
public function upgrade()
3131
{
3232
$currentVersion = $this->getPackageVersion();
33+
$majorVersion = explode(".", $currentVersion);
34+
$majorVersion = $majorVersion[0];
3335
parent::upgrade();
34-
$this->update2to3();
36+
if ($majorVersion == 2) {
37+
$this->update2to3();
38+
}
3539
$this->installSP($this, $currentVersion);
3640
$this->installSettings();
3741
}
3842

39-
private function update2to3(){
43+
private function update2to3()
44+
{
4045
$p4 = SinglePage::getByPath('/dashboard/event_calendar/list_event');
4146

4247
if (is_object($p4)) {
@@ -66,16 +71,16 @@ private function installSP($pkg)
6671
$p2->update(array('cName' => t('Calendars list'), 'cDescription' => ''));
6772
}
6873

69-
$p3 = SinglePage::add('/dashboard/event_calendar/calendar', $pkg);
70-
if (is_object($p3)) {
71-
$p3->update(array('cName' => t('Add / edit calendar'), 'cDescription' => ''));
72-
}
73-
7474
$p4 = SinglePage::add('/dashboard/event_calendar/list_event', $pkg);
7575
if (is_object($p4)) {
7676
$p4->update(array('cName' => t('Events list'), 'cDescription' => ''));
7777
}
7878

79+
$p3 = SinglePage::add('/dashboard/event_calendar/calendar', $pkg);
80+
if (is_object($p3)) {
81+
$p3->update(array('cName' => t('Add / edit calendar'), 'cDescription' => ''));
82+
}
83+
7984
$p5 = SinglePage::add('/dashboard/event_calendar/event', $pkg);
8085
if (is_object($p5)) {
8186
$p5->update(array('cName' => t('Add / edit event'), 'cDescription' => ''));
@@ -90,32 +95,127 @@ private function installSP($pkg)
9095
if (is_object($p7)) {
9196
$p7->update(array('cName' => t('Settings'), 'cDescription' => ''));
9297
}
98+
99+
// $p8 = SinglePage::add('/dashboard/event_calendar/help', $pkg);
100+
// if (is_object($p8)) {
101+
// $p8->update(array('cName' => t('Help'), 'cDescription' => ''));
102+
// }
93103
}
94104

95105
private function installSettings()
96106
{
97107
$db = Loader::db();
98108

99-
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'lang' , value='en-gb'";
100-
$db->Execute($sql);
109+
//if add new setting - increment this number
110+
$howManySettings = 6;
101111

102-
// $sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'formatTitle' , value='MMMM YYYY'";
103-
// $db->Execute($sql);
112+
//check is settings are duplicate
113+
$sql = "select count(*) as count from dsEventCalendarSettings";
114+
$row = $db->GetRow($sql);
104115

105-
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'formatEvent' , value='DD MMMM YYYY'";
106-
$db->Execute($sql);
116+
if ($row['count'] > $howManySettings) {
117+
$this->removeDuplicateSettings();
118+
}
107119

108-
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'startFrom' , value='1'";
109-
$db->Execute($sql);
110120

111-
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'eventsInDay' , value='3'";
121+
// check is settings exits
122+
$sql = "select count(*) as count from dsEventCalendarSettings where opt = 'lang'";
123+
$row = $db->GetRow($sql);
124+
if ($row['count'] == 0) {
125+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'lang' , value='en-gb'";
126+
$db->Execute($sql);
127+
}
128+
$sql = "select count(*) as count from dsEventCalendarSettings where opt= 'formatEvent'";
129+
$row = $db->GetRow($sql);
130+
if ($row['count'] == 0) {
131+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'formatEvent' , value='DD MMMM YYYY'";
132+
$db->Execute($sql);
133+
}
134+
$sql = "select count(*) as count from dsEventCalendarSettings where opt= 'startFrom'";
135+
$row = $db->GetRow($sql);
136+
if ($row['count'] == 0) {
137+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'startFrom' , value='1'";
138+
$db->Execute($sql);
139+
}
140+
$sql = "select count(*) as count from dsEventCalendarSettings where opt= 'eventsInDay'";
141+
$row = $db->GetRow($sql);
142+
if ($row['count'] == 0) {
143+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'eventsInDay' , value='3'";
144+
$db->Execute($sql);
145+
}
146+
$sql = "select count(*) as count from dsEventCalendarSettings where opt= 'default_color'";
147+
$row = $db->GetRow($sql);
148+
if ($row['count'] == 0) {
149+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'default_color' , value='#808080'";
150+
$db->Execute($sql);
151+
}
152+
$sql = "select count(*) as count from dsEventCalendarSettings where opt= 'timeFormat'";
153+
$row = $db->GetRow($sql);
154+
if ($row['count'] == 0) {
155+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'timeFormat' , value='HH:mm'";
156+
$db->Execute($sql);
157+
}
158+
}
159+
160+
private function removeDuplicateSettings()
161+
{
162+
$db = Loader::db();
163+
$settings = array();
164+
165+
$sql = "select * from dsEventCalendarSettings where opt = 'lang'";
166+
$row = $db->GetRow($sql);
167+
array_push($settings, array(
168+
'opt' => $row['opt'],
169+
'value' => $row['value']
170+
));
171+
172+
$sql = "select * from dsEventCalendarSettings where opt= 'formatEvent'";
173+
$row = $db->GetRow($sql);
174+
array_push($settings, array(
175+
'opt' => $row['opt'],
176+
'value' => $row['value']
177+
));
178+
$sql = "select * from dsEventCalendarSettings where opt= 'startFrom'";
179+
$row = $db->GetRow($sql);
180+
array_push($settings, array(
181+
'opt' => $row['opt'],
182+
'value' => $row['value']
183+
));
184+
185+
$sql = "select * from dsEventCalendarSettings where opt= 'eventsInDay'";
186+
$row = $db->GetRow($sql);
187+
array_push($settings, array(
188+
'opt' => $row['opt'],
189+
'value' => $row['value']
190+
));
191+
$sql = "select * from dsEventCalendarSettings where opt= 'default_color'";
192+
$row = $db->GetRow($sql);
193+
array_push($settings, array(
194+
'opt' => $row['opt'],
195+
'value' => $row['value']
196+
));
197+
198+
$sql = "select * from dsEventCalendarSettings where opt= 'timeFormat'";
199+
$row = $db->GetRow($sql);
200+
array_push($settings, array(
201+
'opt' => $row['opt'],
202+
'value' => $row['value']
203+
));
204+
205+
//clear table
206+
$sql = "TRUNCATE dsEventCalendarSettings";
112207
$db->Execute($sql);
113208

114-
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'default_color' , value='#808080'";
209+
210+
//add unique index
211+
$sql = "ALTER TABLE dsEventCalendarSettings ADD UNIQUE INDEX dsOptUnique (opt);";
115212
$db->Execute($sql);
116213

117-
// $sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= 'default_name' , value='Default'";
118-
// $db->Execute($sql);
214+
foreach($settings as $s)
215+
{
216+
$sql = "INSERT IGNORE INTO dsEventCalendarSettings SET opt= '".$s['opt']."' , value='".$s['value']."'";
217+
$db->Execute($sql);
218+
}
119219
}
120220
}
121221

controllers/dashboard/event_calendar/calendar.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
class DashboardEventCalendarCalendarController extends Controller
44
{
5+
public function on_before_render()
6+
{
7+
$this->addHeaderItem(Loader::helper('html')->css('dsStyle.css', 'dsEventCalendar'));
8+
}
59

610
public function view()
711
{

controllers/dashboard/event_calendar/event.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class DashboardEventCalendarEventController extends Controller
66
public function on_before_render()
77
{
88
$this->addHeaderItem(Loader::helper('html')->css('jquery.datetimepicker.min.css', 'dsEventCalendar'));
9+
$this->addHeaderItem(Loader::helper('html')->css('dsStyle.css', 'dsEventCalendar'));
10+
$this->addHeaderItem(Loader::helper('html')->javascript('moment.min.js', 'dsEventCalendar'));
911
$this->addHeaderItem(Loader::helper('html')->javascript('jquery.datetimepicker.min.js', 'dsEventCalendar'));
1012
}
1113

@@ -20,7 +22,9 @@ public function view()
2022
$validateArray = $_POST;
2123
unset($validateArray['event_url']);
2224
unset($validateArray['event_description']);
23-
unset($validateArray['event_time']);
25+
unset($validateArray['event_start_time']);
26+
unset($validateArray['event_end_date']);
27+
unset($validateArray['event_end_time']);
2428
foreach($validateArray as $vA)
2529
{
2630
if($vA === "")
@@ -31,39 +35,51 @@ public function view()
3135
}
3236

3337

38+
3439
if (!$isSomeValueEmpty) {
35-
if($this->post('event_time') !== '')
40+
$startDate = date_format(date_create($_POST['event_start_date']),"Y-m-d");
41+
$startTime = $this->post('event_start_time');
42+
$date = date_create($_POST['event_end_date']);
43+
$date_end = date_format(date_add($date, date_interval_create_from_date_string('1 day')),"Y-m-d");
44+
if(!empty($startTime))
3645
{
3746
$isAllDay = 0;
38-
$_POST['event_date'] = $_POST['event_date']." ".$_POST['event_time'];
47+
$date_end = $startDate." ".$_POST['event_end_time'];
48+
$startDate = $startDate." ".$_POST['event_start_time'];
3949
}
4050

41-
$sql = "INSERT INTO dsEventCalendarEvents (calendarID,title,date,type,description,url,allDayEvent) VALUES (?,?,?,?,?,?,?)";
51+
$sql = "INSERT INTO dsEventCalendarEvents (calendarID,title,date,type,description,url,end,allDayEvent) VALUES (?,?,?,?,?,?,?,?)";
4252

4353
$args = array(
4454
$this->post('event_calendarID'),
4555
$this->post('event_title'),
46-
$this->post('event_date'),
56+
$startDate,
4757
$this->post('event_type'),
4858
$this->post('event_description'),
4959
$this->post('event_url'),
60+
$date_end,
5061
$isAllDay
5162
);
5263

64+
5365
$db->Execute($sql, $args);
5466

5567
$this->set('event_title', "");
56-
$this->set('event_date', "");
57-
$this->set('event_time', "");
68+
$this->set('event_start_date', "");
69+
$this->set('event_start_time', "");
70+
$this->set('event_end_date', "");
71+
$this->set('event_end_time', "");
5872
$this->set('event_type', "");
5973
$this->set('event_description', "");
6074
$this->set('event_url', "");
6175
$this->set('success', t('Event: ' . $this->post('event_title') . ' has been added'));
6276
unset($_POST);
6377
} else {
6478
$this->set('event_title', $this->post('event_title'));
65-
$this->set('event_date', $this->post('event_date'));
66-
$this->set('event_time', $this->post('event_time'));
79+
$this->set('event_start_date', $this->post('event_start_date'));
80+
$this->set('event_start_time', $this->post('event_start_time'));
81+
$this->set('event_end_date', $this->post('event_end_date'));
82+
$this->set('event_end_time', $this->post('event_end_time'));
6783
$this->set('event_type', $this->post('event_type'));
6884
$this->set('event_description', $this->post('event_description'));
6985
$this->set('event_url', $this->post('event_url'));

0 commit comments

Comments
 (0)