Implement editing of calendar info

This commit is contained in:
Bart Visscher 2011-08-30 15:02:34 +02:00
parent c8a544eaea
commit 2815db2b07
7 changed files with 126 additions and 8 deletions

View File

@ -0,0 +1,29 @@
<?php
/*************************************************
* ownCloud - Calendar Plugin *
* *
* (c) Copyright 2011 Georg Ehrke *
* author: Georg Ehrke *
* email: ownclouddev at georgswebsite dot de *
* homepage: ownclouddev.georgswebsite.de *
* manual: ownclouddev.georgswebsite.de/manual *
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
* *
* If you are not able to view the License, *
* <http://www.gnu.org/licenses/> *
* <http://ownclouddev.georgswebsite.de/license/> *
* please write to the Free Software Foundation. *
* Address: *
* 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
*************************************************/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
$tmpl = new OC_Template("calendar", "part.editcalendar");
$tmpl->assign('calendar',$calendar);
$tmpl->printPage();
?>

View File

@ -0,0 +1,39 @@
<?php
/*************************************************
* ownCloud - Calendar Plugin *
* *
* (c) Copyright 2011 Georg Ehrke *
* author: Georg Ehrke *
* email: ownclouddev at georgswebsite dot de *
* homepage: ownclouddev.georgswebsite.de *
* manual: ownclouddev.georgswebsite.de/manual *
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
* *
* If you are not able to view the License, *
* <http://www.gnu.org/licenses/> *
* <http://ownclouddev.georgswebsite.de/license/> *
* please write to the Free Software Foundation. *
* Address: *
* 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
*************************************************/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('calendar');
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Authentication error") )));
exit();
}
$calendarid = $_POST['id'];
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
$tmpl = new OC_Template('calendar', 'part.calendar.row');
$tmpl->assign('calendar', $calendar);
echo json_encode( array( "status" => "success", "data" => $tmpl->fetchPage() ));

View File

@ -903,3 +903,20 @@ function oc_cal_calender_activation(checkbox, calendarid)
checkbox.checked = data == 1;
});
}
function oc_cal_editcalendar(object, calendarid){
$(object).closest('tr').load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid);
}
function oc_cal_editcalendar_submit(button, calendarid){
var displayname = $("#displayname_"+calendarid).val();
var active = $("#active_"+calendarid+":checked").length;
var description = $("#description_"+calendarid).val();
var calendarcolor = $("#calendarcolor_"+calendarid).val();
$.post("ajax/updatecalendar.php", { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
function(data){
if(data.error == "true"){
}else{
$(button).closest('tr').html(data.data)
}
}, 'json');
}

View File

@ -112,14 +112,14 @@ class OC_Calendar_Calendar{
public static function editCalendar($id,$name=null,$description=null,$components=null,$timezone=null,$order=null,$color=null){
// Need these ones for checking uri
$calendar = self::find($id);
$calendar = self::findCalendar($id);
// Keep old stuff
if(is_null($name)) $name = $calendar['name'];
if(is_null($description)) $description = $calendar['description'];
if(is_null($components)) $components = $calendar['components'];
if(is_null($timezone)) $timezone = $calendar['timezone'];
if(is_null($order)) $order = $calendar['order'];
if(is_null($order)) $order = $calendar['calendarorder'];
if(is_null($color)) $color = $calendar['color'];
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET displayname=?,description=?,calendarorder=?,calendarcolor=?,timezone=?,components=?,ctag=ctag+1 WHERE id=?' );

View File

@ -4,16 +4,13 @@
$option_calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
for($i = 0; $i < count($option_calendars); $i++){
echo "<tr>";
echo "<td width=\"20px\"><input id=\"active_" . $option_calendars[$i]["id"] . "\" type=\"checkbox\" onClick=\"oc_cal_calender_activation(this, " . $option_calendars[$i]["id"] . ")\"" . ($option_calendars[$i]["active"] ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $option_calendars[$i]["id"] . "\">" . $option_calendars[$i]["displayname"] . "</label></td>";
echo "<td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Download") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/download.svg\"></a></td><td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Rename") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/rename.svg\"></a></td>";
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $option_calendars[$i]);
$tmpl->printpage();
echo "</tr>";
}
?>
</table>
<br /><br /><br />
<input style="float: left;" type="button" onclick="oc_cal_choosecalendar_submit();" value="<?php echo $l->t("Submit"); ?>">
</div>
<script type="text/javascript">
$( "#choosecalendar_dialog" ).dialog({
width : 500,

View File

@ -0,0 +1,4 @@
<?php
echo "<td width=\"20px\"><input id=\"active_" . $_['calendar']["id"] . "\" type=\"checkbox\" onClick=\"oc_cal_calender_activation(this, " . $_['calendar']["id"] . ")\"" . ($_['calendar']["active"] ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $_['calendar']["id"] . "\">" . $_['calendar']["displayname"] . "</label></td>";
echo "<td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Download") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/download.svg\"></a></td><td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"oc_cal_editcalendar(this, " . $_['calendar']["id"] . ");\"><img src=\"/owncloud/core/img/actions/rename.svg\"></a></td>";

View File

@ -0,0 +1,32 @@
<td id="editcalendar_dialog" title="<?php echo $l->t("Edit calendar"); ?>" colspan="4">
<table width="100%" style="border: 0;">
<tr>
<th><?php echo $l->t('Displayname') ?></th>
<td>
<input id="displayname_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['displayname'] ?>">
</td>
</tr>
<tr>
<td></td>
<td>
<input id="active_<?php echo $_['calendar']['id'] ?>" type="checkbox"<?php echo ($_['calendar']['active'] ? ' checked="checked"' : '' ) ?>>
<label for="active_<?php echo $_['calendar']['id'] ?>">
<?php echo $l->t('Active') ?>
</label>
</td>
</tr>
<tr>
<th><?php echo $l->t('Description') ?></th>
<td>
<textarea id="description_<?php echo $_['calendar']['id'] ?>"><?php echo $_['calendar']['description'] ?></textarea>
</td>
</tr>
<tr>
<th><?php echo $l->t('Calendar color') ?></th>
<td>
<input id="calendarcolor_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['calendarcolor'] ?>">
</td>
</tr>
</table>
<input style="float: left;" type="button" onclick="oc_cal_editcalendar_submit(this, <?php echo $_['calendar']['id'] ?>);" value="<?php echo $l->t("Submit"); ?>">
</td>