diff options
author | Bart Visscher <bartv@thisnet.nl> | 2011-09-22 22:22:52 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2011-09-23 19:40:06 +0200 |
commit | e9950defb240dfe19a22cf1cce34e0fd25e58ee9 (patch) | |
tree | 1df2da6edcc6985700085d82f0e9a54533989b46 /apps/calendar | |
parent | 5559a0dedef2ac1f366ca17ddb2286629009ee3c (diff) | |
download | nextcloud-server-e9950defb240dfe19a22cf1cce34e0fd25e58ee9.tar.gz nextcloud-server-e9950defb240dfe19a22cf1cce34e0fd25e58ee9.zip |
Make event category choice multiselect
Diffstat (limited to 'apps/calendar')
-rw-r--r-- | apps/calendar/ajax/editeventform.php | 16 | ||||
-rw-r--r-- | apps/calendar/ajax/neweventform.php | 8 | ||||
-rw-r--r-- | apps/calendar/css/style.css | 2 | ||||
-rw-r--r-- | apps/calendar/index.php | 12 | ||||
-rw-r--r-- | apps/calendar/js/calendar.js | 7 | ||||
-rw-r--r-- | apps/calendar/lib/object.php | 18 | ||||
-rw-r--r-- | apps/calendar/templates/part.eventform.php | 8 |
7 files changed, 48 insertions, 23 deletions
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php index 3b8a30f70fc..f310db3e79a 100644 --- a/apps/calendar/ajax/editeventform.php +++ b/apps/calendar/ajax/editeventform.php @@ -20,8 +20,8 @@ if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$categories = OC_Calendar_Object::getCategoryOptions($l10n); +$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$category_options = OC_Calendar_Object::getCategoryOptions($l10n); $repeat_options = OC_Calendar_Object::getRepeatOptions($l10n); $id = $_GET['id']; @@ -55,19 +55,23 @@ switch($dtstart->getDateType()) { $summary = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : ''; $location = isset($vevent->LOCATION) ? $vevent->LOCATION->value : ''; -$category = isset($vevent->CATEGORIES) ? $vevent->CATEGORIES->value : ''; +$categories = array(); +if (isset($vevent->CATEGORIES)){ + $categories = explode(',', $vevent->CATEGORIES->value); + $categories = array_map('trim', $categories); +} $repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : ''; $description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : ''; $tmpl = new OC_Template('calendar', 'part.editevent'); $tmpl->assign('id', $id); -$tmpl->assign('calendars', $calendars); -$tmpl->assign('categories', $categories); +$tmpl->assign('calendar_options', $calendar_options); +$tmpl->assign('category_options', $category_options); $tmpl->assign('repeat_options', $repeat_options); $tmpl->assign('title', $summary); $tmpl->assign('location', $location); -$tmpl->assign('category', $category); +$tmpl->assign('categories', $categories); $tmpl->assign('calendar', $data['calendarid']); $tmpl->assign('allday', $allday); $tmpl->assign('startdate', $startdate); diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php index 1d8a61dffd2..132294b496e 100644 --- a/apps/calendar/ajax/neweventform.php +++ b/apps/calendar/ajax/neweventform.php @@ -25,8 +25,8 @@ if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$categories = OC_Calendar_Object::getCategoryOptions($l10n); +$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$category_options = OC_Calendar_Object::getCategoryOptions($l10n); $repeat_options = OC_Calendar_Object::getRepeatOptions($l10n); $startday = substr($_GET['d'], 0, 2); $startmonth = substr($_GET['d'], 2, 2); @@ -56,8 +56,8 @@ if($endtime == 23) { } $tmpl = new OC_Template('calendar', 'part.newevent'); -$tmpl->assign('calendars', $calendars); -$tmpl->assign('categories', $categories); +$tmpl->assign('calendar_options', $calendar_options); +$tmpl->assign('category_options', $category_options); $tmpl->assign('startdate', $startday . '-' . $startmonth . '-' . $startyear); $tmpl->assign('starttime', ($starttime <= 9 ? '0' : '') . $starttime . ':' . $startminutes); $tmpl->assign('enddate', $endday . '-' . $endmonth . '-' . $endyear); diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index 5d08402422a..b1198062763 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -68,3 +68,5 @@ color:#333; #fromtime.disabled, #totime.disabled { color:#A9A9A9; } +select#category{width:140px;} +button.category{margin:0 3px;} diff --git a/apps/calendar/index.php b/apps/calendar/index.php index c93ea93bb6c..b4e7d5ff48f 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -17,7 +17,7 @@ * 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * *************************************************/ -require_once ("../../lib/base.php"); +require_once ('../../lib/base.php'); OC_Util::checkLoggedIn(); // Create default calendar ... $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); @@ -25,8 +25,10 @@ if( count($calendars) == 0){ OC_Calendar_Calendar::addCalendar(OC_User::getUser(),'default','Default calendar'); $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); } -OC_UTIL::addScript("calendar", "calendar"); -OC_UTIL::addStyle("calendar", "style"); -OC_APP::setActiveNavigationEntry("calendar_index"); -$output = new OC_TEMPLATE("calendar", "calendar", "user"); +OC_UTIL::addScript('calendar', 'calendar'); +OC_UTIL::addStyle('calendar', 'style'); +OC_UTIL::addScript('', 'jquery.multiselect'); +OC_UTIL::addStyle('', 'jquery.multiselect'); +OC_APP::setActiveNavigationEntry('calendar_index'); +$output = new OC_TEMPLATE('calendar', 'calendar', 'user'); $output -> printPage(); diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 5864977eb38..8c1a4afac09 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -288,6 +288,13 @@ Calendar={ $( "#to" ).datepicker({ dateFormat : 'dd-mm-yy' }); + $('#category').multiselect({ + header: false, + noneSelectedText: $('#category').attr('title'), + selectedList: 2, + minWidth:'auto', + classes: 'category', + }); $('#event').dialog({ width : 500, close : function(event, ui) { diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 702033c169c..3bb6543d3fd 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -301,7 +301,6 @@ class OC_Calendar_Object{ public static function getCategoryOptions($l10n) { return array( - $l10n->t('None'), $l10n->t('Birthday'), $l10n->t('Business'), $l10n->t('Call'), @@ -345,6 +344,11 @@ class OC_Calendar_Object{ $errarr['cal'] = 'true'; $errnum++; } + + if(isset($request['categories']) && !is_array($request['categories'])){ + $errors['categories'] = $l10n->t('Not an array'); + } + $fromday = substr($request['from'], 0, 2); $frommonth = substr($request['from'], 3, 2); $fromyear = substr($request['from'], 6, 4); @@ -434,7 +438,7 @@ class OC_Calendar_Object{ { $title = $request["title"]; $location = $request["location"]; - $cat = $request["category"]; + $categories = $request["categories"]; $allday = isset($request["allday"]); $from = $request["from"]; $fromtime = $request["fromtime"]; @@ -493,15 +497,21 @@ class OC_Calendar_Object{ if($location != ""){ $vevent->LOCATION = $location; + }else{ + unset($vevent->LOCATION); } if($description != ""){ $des = str_replace("\n","\\n", $description); $vevent->DESCRIPTION = $des; + }else{ + unset($vevent->DESCRIPTION); } - if($cat != ""){ - $vevent->CATEGORIES = $cat; + if(!empty($categories)){ + $vevent->CATEGORIES = join(',', $categories); + }else{ + unset($vevent->CATEGORIES); } /*if($repeat == "true"){ diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index c63d709e26e..5b12407330a 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -16,10 +16,10 @@ <tr> <th width="75px"><?php echo $l->t("Category");?>:</th> <td> - <select style="width:140px;" name="category"> + <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>"> <?php - foreach($_['categories'] as $category){ - echo '<option value="' . $category . '"' . ($_['category'] == $category ? ' selected="selected"' : '') . '>' . $category . '</option>'; + foreach($_['category_options'] as $category){ + echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>'; } ?> </select></td> @@ -27,7 +27,7 @@ <td> <select style="width:140px;" name="calendar"> <?php - foreach($_['calendars'] as $calendar){ + foreach($_['calendar_options'] as $calendar){ echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>'; } ?> |