implementation of html/css link-sharing interface for calendars moves a step further

master
Michał 'rysiek' Woźniak 2014-01-23 15:19:08 +01:00
parent befb604b30
commit 5671ae0c30
2 changed files with 60 additions and 11 deletions

View File

@ -1,5 +1,4 @@
<!-- BEGIN -->
<?php var_dump($_['shared']) ?>
<td width="20px">
<?php if($_['calendar']['userid'] == OCP\USER::getUser()) { ?>
<input type="checkbox" id="active_<?php p($_['calendar']['id']) ?>" class="activeCalendar" data-id="<?php p($_['calendar']['id']) ?>" <?php print_unescaped($_['calendar']['active'] ? ' checked="checked"' : '') ?>>
@ -14,7 +13,7 @@
for="outer-share-link-calendar-<?php p($_['calendar']['id']) ?>"
title="<?php p($l->t('Share Calendar')) ?>"
class="action permanent"
style="cursor: pointer; width:20px; height:20px; display:block; background-repeat:no-repeat; background-image: url(<?php print_unescaped((!$_['shared']) ? OCP\Util::imagePath('core', 'actions/share.svg') : OCP\Util::imagePath('core', 'actions/shared.svg')) ?>);"></label>
style="cursor: pointer; width:20px; height:20px; display:block; background-repeat:no-repeat; background-image: url(<?php print_unescaped($_['share_icon']); ?>);"></label>
<?php endif; ?>
</td>
<td width="20px">
@ -42,7 +41,7 @@ if($_['calendar']['userid'] == OCP\USER::getUser()){
</td>
<?php /* public calendar link-sharing interface */ ?>
<?php if($_['calendar']['permissions'] & OCP\PERMISSION_SHARE): ?>
<tr>
</tr><tr>
<th class="displayable-container" colspan="7">
<input type="checkbox" class="displayable-control hide" id="outer-share-link-calendar-<?php p($_['calendar']['id']) ?>"/>
<div class="displayable noafter" style="padding-left:0.5em"><?php
@ -50,12 +49,10 @@ if($_['calendar']['userid'] == OCP\USER::getUser()){
$tmpl->assign('item_id', $_['calendar']['id']);
$tmpl->assign('item_type', 'calendar');
$tmpl->assign('permissions', $_['calendar']['permissions']);
$tmpl->assign('link_share', $linkShare);
//$tmpl->assign('shared', $shared);
$tmpl->assign('link_share', $_['link_share']);
$tmpl->printpage();
?></div>
</td>
</tr>
<?php endif; ?>
<?php /* end public calendar link-sharing interface */
?>

View File

@ -2,19 +2,71 @@
<p><b><?php p($l->t('Your calendars')); ?>:</b></p>
<table width="100%" style="border: 0;">
<?php
// get user's calendars
$option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
// let's look at them, one by one
for($i = 0; $i < count($option_calendars); $i++) {
// flags init
$shared = false; // is the calendar shared at all (with or by the current user, including link-sharing)?
$sharedBy = false; // is the calendar shared *with* the current user?
$linkShare = array(); // is the calendar publicly link-shared
$sharedWith = array(); // with whom is the calendar shared within this ownCloud instance?
// starting off the calendar row
print_unescaped("<tr data-id='".OC_Util::sanitizeHTML($option_calendars[$i]['id'])."'>");
// calendar row contents template
$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
// calendar data assigned to the template
$tmpl->assign('calendar', $option_calendars[$i]);
// is this owned by the user?
if ($option_calendars[$i]['userid'] != OCP\User::getUser()) {
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']);
$shared = true;
} else {
$shared = false;
}
// nope! apparently shared *with* the user!
$sharedBy = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']);
}
// check sharing status
$sw = OCP\Share::getItemShared('calendar', $option_calendars[$i]['id']);
if(is_array($sw)) {
foreach($sw as $share) {
// sharing with a group or user, are we?
if($share['share_type'] == OCP\Share::SHARE_TYPE_USER || $share['share_type'] == OCP\Share::SHARE_TYPE_GROUP) {
// noted!
$sharedWith[] = $share;
// public link-sharing
} elseif($share['share_type'] == OCP\Share::SHARE_TYPE_LINK) {
// noted also!
$linkShare = $share;
}
}
}
// set the shared flag -- true if shared by, link-shared, or shared with
$shared = ( !empty($sharedBy) or !empty($linkShare) or !empty($sharedWith) );
// shared/sharing info passed to the template
$tmpl->assign('shared', $shared);
$tmpl->assign('shared_by', $sharedBy);
$tmpl->assign('link_share', $linkShare);
$tmpl->assign('shared_with', $sharedWith);
// share status icon
if (!$shared) {
// not shared
$tmpl->assign('share_icon', OCP\Util::imagePath('core', 'actions/share.svg'));
// link-shared
} elseif (!empty($linkShare)) {
$tmpl->assign('share_icon', OCP\Util::imagePath('core', 'actions/public.svg'));
// shared
} else {
$tmpl->assign('share_icon', OCP\Util::imagePath('core', 'actions/shared.svg'));
}
// print the template, yo
$tmpl->printpage();
// finish the job
print_unescaped("</tr>");
}
?>