Merge branch 'master' into calendar

This commit is contained in:
Georg Ehrke 2012-02-04 21:34:38 +01:00
commit 55be59e738
21 changed files with 188 additions and 60 deletions

View File

@ -137,7 +137,7 @@ function showBookmark(event) {
$('.bookmarks_add').slideToggle(); $('.bookmarks_add').slideToggle();
} }
$('html, body').animate({ $('html, body').animate({
scrollTop: $('.bookmarks_menu').offset().top scrollTop: ($('.bookmarks_menu'))?$('.bookmarks_menu').offset().top:0
}, 500); }, 500);
} }

View File

@ -25,7 +25,7 @@ foreach($calendars as $cal){
} }
$userid = OC_User::getUser(); $userid = OC_User::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, htmlspecialchars($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); $calendarid = OC_Calendar_Calendar::addCalendar($userid, strip_tags($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, 1); OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
$calendar = OC_Calendar_Calendar::find($calendarid); $calendar = OC_Calendar_Calendar::find($calendarid);

View File

@ -26,7 +26,7 @@ foreach($calendars as $cal){
$calendarid = $_POST['id']; $calendarid = $_POST['id'];
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check $calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::editCalendar($calendarid, htmlspecialchars($_POST['name']), null, null, null, $_POST['color']); OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$calendar = OC_Calendar_App::getCalendar($calendarid); $calendar = OC_Calendar_App::getCalendar($calendarid);

View File

@ -9,6 +9,7 @@
?> ?>
<form id="calendar"> <form id="calendar">
<fieldset class="personalblock"> <fieldset class="personalblock">
<strong><?php echo $l->t('Calendar'); ?></strong>
<table class="nostyle"> <table class="nostyle">
<tr><td><label for="timezone" class="bold"><?php echo $l->t('Timezone');?></label></td><td><select style="display: none;" id="timezone" name="timezone"> <tr><td><label for="timezone" class="bold"><?php echo $l->t('Timezone');?></label></td><td><select style="display: none;" id="timezone" name="timezone">
<?php <?php

View File

@ -77,7 +77,7 @@ foreach( $add as $propname){
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
$value = OC_VObject::escapeSemicolons($value); $value = OC_VObject::escapeSemicolons($value);
} }
$vcard->addProperty($propname, $value); //, $prop_parameters); $vcard->addProperty($propname, strip_tags($value)); //, $prop_parameters);
$line = count($vcard->children) - 1; $line = count($vcard->children) - 1;
foreach ($prop_parameters as $key=>$element) { foreach ($prop_parameters as $key=>$element) {
if(is_array($element) && strtoupper($key) == 'TYPE') { if(is_array($element) && strtoupper($key) == 'TYPE') {

View File

@ -67,6 +67,8 @@ foreach($current as $item) {
if(is_array($value)) { if(is_array($value)) {
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
} else {
$value = strip_tags($value);
} }
$property = $vcard->addProperty($name, $value); //, $parameters); $property = $vcard->addProperty($name, $value); //, $parameters);

View File

@ -15,7 +15,7 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$userid = OC_User::getUser(); $userid = OC_User::getUser();
$bookid = OC_Contacts_Addressbook::add($userid, $_POST['name'], null); $bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null);
if(!$bookid) { if(!$bookid) {
OC_JSON::error(array('data' => array('message' => $l->t('Error adding addressbook.')))); OC_JSON::error(array('data' => array('message' => $l->t('Error adding addressbook.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR); OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR);

View File

@ -37,9 +37,13 @@ $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
$value = $_POST['value']; $value = $_POST['value'];
if(is_array($value)){ if(is_array($value)){
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
foreach(array_keys($value) as $key) {
OC_Log::write('contacts','ajax/setproperty.php: setting: '.$key.': '.$value[$key], OC_Log::DEBUG);
}
$value = OC_VObject::escapeSemicolons($value);
} }
OC_Log::write('contacts','ajax/setproperty.php: setting: '.$vcard->children[$line]->name.': '.$value, OC_Log::DEBUG); OC_Log::write('contacts','ajax/setproperty.php: setting: '.$vcard->children[$line]->name.': '.$value, OC_Log::DEBUG);
$vcard->children[$line]->setValue($value); $vcard->children[$line]->setValue(strip_tags($value));
// Add parameters // Add parameters
$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array(); $postparameters = isset($_POST['parameters'])?$_POST['parameters']:array();

View File

@ -1,5 +1,5 @@
<?php <?php
// FIXME: Make this readable. // FIXME: Make this readable.
echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>"; echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . $_['addressbook']["displayname"] . "</label></td>"; echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . htmlspecialchars($_['addressbook']["displayname"]) . "</label></td>";
echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OC_User::getUser() . "', '" . $_['addressbook']["uri"] . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook('" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>"; echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OC_User::getUser() . "', '" . $_['addressbook']["uri"] . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook('" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";

View File

@ -11,7 +11,7 @@
<tr> <tr>
<th><?php echo $l->t('Displayname') ?></th> <th><?php echo $l->t('Displayname') ?></th>
<td> <td>
<input id="displayname_<?php echo $_['addressbook']['id'] ?>" type="text" value="<?php echo $_['addressbook']['displayname'] ?>"> <input id="displayname_<?php echo $_['addressbook']['id'] ?>" type="text" value="<?php echo htmlspecialchars($_['addressbook']['displayname']) ?>">
</td> </td>
</tr> </tr>
<?php if (!$_['new']): ?> <?php if (!$_['new']): ?>

View File

@ -1,9 +1,9 @@
<p id="contacts_details_name" class="contacts_property" data-checksum="<?php echo $_['property']['checksum']; ?>"> <p id="contacts_details_name" class="contacts_property" data-checksum="<?php echo $_['property']['checksum']; ?>">
<?php echo $_['property']['value']; ?> <?php echo htmlspecialchars($_['property']['value']); ?>
<span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span> <span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span>
</p> </p>
<?php if (!isset($_['details'])): ?> <?php if (!isset($_['details'])): ?>
<script> <script>
$('#leftcontent li.active a').text('<?php echo $_['property']['value']; ?>'); $('#leftcontent li.active a').text('<?php echo htmlspecialchars($_['property']['value']); ?>');
</script> </script>
<?php endif ?> <?php endif ?>

View File

@ -8,21 +8,21 @@
<?php elseif($_['property']['name'] == 'ORG'): ?> <?php elseif($_['property']['name'] == 'ORG'): ?>
<p class="contacts_property_name"><?php echo $l->t('Organization'); ?></p> <p class="contacts_property_name"><?php echo $l->t('Organization'); ?></p>
<p class="contacts_property_data"> <p class="contacts_property_data">
<?php echo $_['property']['value']; ?> <?php echo htmlspecialchars($_['property']['value']); ?>
<span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span> <span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span>
<span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span> <span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span>
</p> </p>
<?php elseif($_['property']['name'] == 'EMAIL'): ?> <?php elseif($_['property']['name'] == 'EMAIL'): ?>
<p class="contacts_property_name"><?php echo $l->t('Email'); ?></p> <p class="contacts_property_name"><?php echo $l->t('Email'); ?></p>
<p class="contacts_property_data"> <p class="contacts_property_data">
<?php echo $_['property']['value']; ?> <?php echo htmlspecialchars($_['property']['value']); ?>
<span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span> <span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span>
<span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span> <span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span>
</p> </p>
<?php elseif($_['property']['name'] == 'TEL'): ?> <?php elseif($_['property']['name'] == 'TEL'): ?>
<p class="contacts_property_name"><?php echo (isset($_['property']['parameters']['PREF']) && $_['property']['parameters']['PREF']) ? $l->t('Preferred').' ' : '' ?><?php echo $l->t('Phone'); ?></p> <p class="contacts_property_name"><?php echo (isset($_['property']['parameters']['PREF']) && $_['property']['parameters']['PREF']) ? $l->t('Preferred').' ' : '' ?><?php echo $l->t('Phone'); ?></p>
<p class="contacts_property_data"> <p class="contacts_property_data">
<?php echo $_['property']['value']; ?> <?php echo htmlspecialchars($_['property']['value']); ?>
<?php if(isset($_['property']['parameters']['TYPE']) && !empty($_['property']['parameters']['TYPE'])): ?> <?php if(isset($_['property']['parameters']['TYPE']) && !empty($_['property']['parameters']['TYPE'])): ?>
<?php <?php
foreach($_['property']['parameters']['TYPE'] as $type) { foreach($_['property']['parameters']['TYPE'] as $type) {
@ -59,25 +59,25 @@
</p> </p>
<p class="contacts_property_data"> <p class="contacts_property_data">
<?php if(!empty($_['property']['value'][0])): ?> <?php if(!empty($_['property']['value'][0])): ?>
<?php echo $_['property']['value'][0]; ?><br> <?php echo htmlspecialchars($_['property']['value'][0]); ?><br>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($_['property']['value'][1])): ?> <?php if(!empty($_['property']['value'][1])): ?>
<?php echo $_['property']['value'][1]; ?><br> <?php echo htmlspecialchars($_['property']['value'][1]); ?><br>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($_['property']['value'][2])): ?> <?php if(!empty($_['property']['value'][2])): ?>
<?php echo $_['property']['value'][2]; ?><br> <?php echo htmlspecialchars($_['property']['value'][2]); ?><br>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($_['property']['value'][3])): ?> <?php if(!empty($_['property']['value'][3])): ?>
<?php echo $_['property']['value'][3]; ?><br> <?php echo htmlspecialchars($_['property']['value'][3]); ?><br>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($_['property']['value'][4])): ?> <?php if(!empty($_['property']['value'][4])): ?>
<?php echo $_['property']['value'][4]; ?><br> <?php echo htmlspecialchars($_['property']['value'][4]); ?><br>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($_['property']['value'][5])): ?> <?php if(!empty($_['property']['value'][5])): ?>
<?php echo $_['property']['value'][5]; ?><br> <?php echo htmlspecialchars($_['property']['value'][5]); ?><br>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($_['property']['value'][6])): ?> <?php if(!empty($_['property']['value'][6])): ?>
<?php echo $_['property']['value'][6]; ?> <?php echo htmlspecialchars($_['property']['value'][6]); ?>
<?php endif; ?> <?php endif; ?>
<span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span> <span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span>
<span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span> <span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span>

View File

@ -5,18 +5,18 @@
<p class="contacts_property_name"> <p class="contacts_property_name">
<dl class="contacts_property_data form"> <dl class="contacts_property_data form">
<dt><label for="n1"><?php echo $l->t('Given name'); ?></label></dt> <dt><label for="n1"><?php echo $l->t('Given name'); ?></label></dt>
<dd><input id="n1" type="text" name="value[1]" value="<?php echo $_['property']['value'][1]; ?>"></dd> <dd><input id="n1" type="text" name="value[1]" value="<?php echo htmlspecialchars($_['property']['value'][1]); ?>"></dd>
<dt><label for="n0"><?php echo $l->t('Family name'); ?></dt> <dt><label for="n0"><?php echo $l->t('Family name'); ?></dt>
<dd><input id="n0" type="text" name="value[0]" value="<?php echo $_['property']['value'][0]; ?>"></dd> <dd><input id="n0" type="text" name="value[0]" value="<?php echo htmlspecialchars($_['property']['value'][0]); ?>"></dd>
<dt><label for="n2"><?php echo $l->t('Additional names'); ?></dt> <dt><label for="n2"><?php echo $l->t('Additional names'); ?></dt>
<dd><input id="n2" type="text" name="value[2]" value="<?php echo $_['property']['value'][2]; ?>"> <dd><input id="n2" type="text" name="value[2]" value="<?php echo htmlspecialchars($_['property']['value'][2]); ?>">
<input id="n3" type="hidden" name="value[3]" value="<?php echo $_['property']['value'][3]; ?>"> <input id="n3" type="hidden" name="value[3]" value="<?php echo htmlspecialchars($_['property']['value'][3]); ?>">
<input id="n4" type="hidden" name="value[4]" value="<?php echo $_['property']['value'][4]; ?>"> <input id="n4" type="hidden" name="value[4]" value="<?php echo htmlspecialchars($_['property']['value'][4]); ?>">
</dd> </dd>
</dl> </dl>
</p> </p>
<?php elseif($_['property']['name']=='FN'): ?> <?php elseif($_['property']['name']=='FN'): ?>
<p class="contacts_property_data"><input id="fn" type="text" name="value" value="<?php echo $_['property']['value']; ?>"></p> <p class="contacts_property_data"><input id="fn" type="text" name="value" value="<?php echo htmlspecialchars($_['property']['value']); ?>"></p>
<?php elseif($_['property']['name']=='ADR'): ?> <?php elseif($_['property']['name']=='ADR'): ?>
<p class="contacts_property_name"><label for="adr_pobox"><?php echo $l->t('Address'); ?></label></p> <p class="contacts_property_name"><label for="adr_pobox"><?php echo $l->t('Address'); ?></label></p>
<dl class="contacts_property_data form" id="contacts_addresspart"> <dl class="contacts_property_data form" id="contacts_addresspart">
@ -32,60 +32,60 @@
<label for="adr_pobox"><?php echo $l->t('PO Box'); ?></label> <label for="adr_pobox"><?php echo $l->t('PO Box'); ?></label>
</dt> </dt>
<dd> <dd>
<input id="adr_pobox" type="text" name="value[0]" value="<?php echo $_['property']['value'][0] ?>"> <input id="adr_pobox" type="text" name="value[0]" value="<?php echo htmlspecialchars($_['property']['value'][0]) ?>">
</dd> </dd>
<!-- dt> <!-- dt>
<label for="adr_extended"><?php echo $l->t('Extended'); ?></label> <label for="adr_extended"><?php echo $l->t('Extended'); ?></label>
</dt> </dt>
<dd> <dd>
<input style="width: 7em;" id="adr_extended" type="text" name="value[1]" value="<?php echo $_['property']['value'][1] ?>"> <input style="width: 7em;" id="adr_extended" type="text" name="value[1]" value="<?php echo htmlspecialchars($_['property']['value'][1]) ?>">
</dd --> </dd -->
<dt> <dt>
<label for="adr_street"><?php echo $l->t('Street'); ?></label> <label for="adr_street"><?php echo $l->t('Street'); ?></label>
</dt> </dt>
<dd> <dd>
<input style="width: 12em;" id="adr_street" type="text" name="value[2]" value="<?php echo $_['property']['value'][2] ?>"> <input style="width: 12em;" id="adr_street" type="text" name="value[2]" value="<?php echo htmlspecialchars($_['property']['value'][2]) ?>">
<label for="adr_extended"><?php echo $l->t('Extended'); ?></label><input style="width: 7em;" id="adr_extended" type="text" name="value[1]" value="<?php echo $_['property']['value'][1] ?>"> <label for="adr_extended"><?php echo $l->t('Extended'); ?></label><input style="width: 7em;" id="adr_extended" type="text" name="value[1]" value="<?php echo htmlspecialchars($_['property']['value'][1]) ?>">
</dd> </dd>
<dt> <dt>
<label for="adr_city"><?php echo $l->t('City'); ?></label> <label for="adr_city"><?php echo $l->t('City'); ?></label>
</dt> </dt>
<dd> <dd>
<input style="width: 12em;" id="adr_city" type="text" name="value[3]" value="<?php echo $_['property']['value'][3] ?>"> <input style="width: 12em;" id="adr_city" type="text" name="value[3]" value="<?php echo htmlspecialchars($_['property']['value'][3]) ?>">
<label for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label> <label for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
<input style="width: 5em;" id="adr_zipcode" type="text" name="value[5]" value="<?php echo $_['property']['value'][5] ?>"> <input style="width: 5em;" id="adr_zipcode" type="text" name="value[5]" value="<?php echo htmlspecialchars($_['property']['value'][5]) ?>">
</dd> </dd>
<dt> <dt>
<label for="adr_region"><?php echo $l->t('Region'); ?></label> <label for="adr_region"><?php echo $l->t('Region'); ?></label>
</dt> </dt>
<dd> <dd>
<input id="adr_region" type="text" name="value[4]" value="<?php echo $_['property']['value'][4] ?>"> <input id="adr_region" type="text" name="value[4]" value="<?php echo htmlspecialchars($_['property']['value'][4]) ?>">
</dd> </dd>
<!-- dt> <!-- dt>
<label for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label> <label for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
</dt> </dt>
<dd> <dd>
<input style="width: 7em;" id="adr_zipcode" type="text" name="value[5]" value="<?php echo $_['property']['value'][5] ?>"> <input style="width: 7em;" id="adr_zipcode" type="text" name="value[5]" value="<?php echo htmlspecialchars($_['property']['value'][5]) ?>">
</dd --> </dd -->
<dt> <dt>
<label for="adr_country"><?php echo $l->t('Country'); ?></label> <label for="adr_country"><?php echo $l->t('Country'); ?></label>
</dt> </dt>
<dd> <dd>
<input style="width: 25em;" id="adr_country" type="text" name="value[6]" value="<?php echo $_['property']['value'][6] ?>"> <input style="width: 25em;" id="adr_country" type="text" name="value[6]" value="<?php echo htmlspecialchars($_['property']['value'][6]) ?>">
</dd> </dd>
</dl> </dl>
<?php elseif($_['property']['name']=='TEL'): ?> <?php elseif($_['property']['name']=='TEL'): ?>
<p class="contacts_property_name"><label for="tel"><?php echo $l->t('Phone'); ?></label></p> <p class="contacts_property_name"><label for="tel"><?php echo $l->t('Phone'); ?></label></p>
<p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo $_['property']['value'] ?>"> <p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo htmlspecialchars($_['property']['value']) ?>">
<select id="tel_type<?php echo $_['property']['checksum'] ?>" name="parameters[TYPE][]" multiple="multiple" data-placeholder="<?php echo $l->t('Type') ?>"> <select id="tel_type<?php echo $_['property']['checksum'] ?>" name="parameters[TYPE][]" multiple="multiple" data-placeholder="<?php echo $l->t('Type') ?>">
<?php echo html_select_options($_['phone_types'], isset($_['property']['parameters']['TYPE'])?$_['property']['parameters']['TYPE']:array()) ?> <?php echo html_select_options($_['phone_types'], isset($_['property']['parameters']['TYPE'])?$_['property']['parameters']['TYPE']:array()) ?>
</select></p> </select></p>
<?php elseif($_['property']['name']=='EMAIL'): ?> <?php elseif($_['property']['name']=='EMAIL'): ?>
<p class="contacts_property_name"><label for="email"><?php echo $l->t('Email'); ?></label></p> <p class="contacts_property_name"><label for="email"><?php echo $l->t('Email'); ?></label></p>
<p class="contacts_property_data"><input id="email" type="text" name="value" value="<?php echo $_['property']['value']; ?>"></p> <p class="contacts_property_data"><input id="email" type="text" name="value" value="<?php echo htmlspecialchars($_['property']['value']); ?>"></p>
<?php elseif($_['property']['name']=='ORG'): ?> <?php elseif($_['property']['name']=='ORG'): ?>
<p class="contacts_property_name"><label for="org"><?php echo $l->t('Organization'); ?></label></p> <p class="contacts_property_name"><label for="org"><?php echo $l->t('Organization'); ?></label></p>
<p class="contacts_property_data"><input id="org" type="text" name="value" value="<?php echo $_['property']['value']; ?>"></p> <p class="contacts_property_data"><input id="org" type="text" name="value" value="<?php echo htmlspecialchars($_['property']['value']); ?>"></p>
<?php endif; ?> <?php endif; ?>
<input id="contacts_setproperty_button" type="submit" value="<?php echo $l->t('Update'); ?>"> <input id="contacts_setproperty_button" type="submit" value="<?php echo $l->t('Update'); ?>">
</form> </form>

View File

@ -54,9 +54,11 @@ function handleGalleryScanning() {
OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('/'))); OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('/')));
} }
function handleFilescan() { function handleFilescan($cleanup) {
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
$pathlist = OC_Gallery_Scanner::find_paths('/'); if ($cleanup) OC_Gallery_Album::cleanup();
$root = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '').'/';
$pathlist = OC_Gallery_Scanner::find_paths($root);
sort($pathlist); sort($pathlist);
OC_JSON::success(array('paths' => $pathlist)); OC_JSON::success(array('paths' => $pathlist));
} }
@ -72,6 +74,25 @@ function handlePartialCreate($path) {
OC_JSON::success(array('album_details' => $albums)); OC_JSON::success(array('album_details' => $albums));
} }
function handleStoreSettings($root, $order) {
OC_JSON::checkLoggedIn();
if (!OC_Filesystem::file_exists($root)) {
OC_JSON::error(array('cause' => 'No such file or directory'));
return;
}
if (!OC_Filesystem::is_dir($root)) {
OC_JSON::error(array('cause' => $root . ' is not a directory'));
return;
}
$current_root = OC_Preferences::getValue(OC_User::getUser(),'gallery', 'root', '/');
$root = trim(rtrim($root, '/'));
$rescan = $current_root==$root?'no':'yes';
OC_Preferences::setValue(OC_User::getUser(), 'gallery', 'root', $root);
OC_Preferences::setValue(OC_User::getUser(), 'gallery', 'order', $order);
OC_JSON::success(array('rescan' => $rescan));
}
if ($_GET['operation']) { if ($_GET['operation']) {
switch($_GET['operation']) { switch($_GET['operation']) {
case 'rename': case 'rename':
@ -83,16 +104,19 @@ if ($_GET['operation']) {
OC_JSON::success(); OC_JSON::success();
break; break;
case 'get_covers': case 'get_covers':
handleGetThumbnails($_GET['albumname']); handleGetThumbnails(urldecode($_GET['albumname']));
break; break;
case 'scan': case 'scan':
handleGalleryScanning(); handleGalleryScanning();
break; break;
case 'filescan': case 'filescan':
handleFilescan(); handleFilescan($_GET['cleanup']);
break; break;
case 'partial_create': case 'partial_create':
handlePartialCreate($_GET['path']); handlePartialCreate(urldecode($_GET['path']));
break;
case 'store_settings':
handleStoreSettings($_GET['root'], $_GET['order']);
break; break;
default: default:
OC_JSON::error(array('cause' => 'Unknown operation')); OC_JSON::error(array('cause' => 'Unknown operation'));

View File

@ -12,3 +12,6 @@ div.gallery_control_overlay a { color:white; }
#gallery_images.rightcontent { padding:10px 5px; bottom: 0px; overflow: auto; right:0px} #gallery_images.rightcontent { padding:10px 5px; bottom: 0px; overflow: auto; right:0px}
#scan { position:absolute; right:13.5em; top:0em; } #scan { position:absolute; right:13.5em; top:0em; }
#scan #scanprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; } #scan #scanprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; }
#g-settings {position: absolute; left 13.5em; top: 0;}
input[type=button] { -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; opacity: 1}
input[type=button]:disabled { opacity: 0.5 }

View File

@ -38,10 +38,12 @@ function createNewAlbum() {
var albumCounter = 0; var albumCounter = 0;
var totalAlbums = 0; var totalAlbums = 0;
function scanForAlbums() { function scanForAlbums(cleanup) {
cleanup = cleanup?true:false;
var albumCounter = 0; var albumCounter = 0;
var totalAlbums = 0; var totalAlbums = 0;
$.getJSON('ajax/galleryOp.php?operation=filescan', function(r) { $('#g-scan-button').attr('disabled', 'true');
$.getJSON('ajax/galleryOp.php?operation=filescan', {cleanup: cleanup}, function(r) {
if (r.status == 'success') { if (r.status == 'success') {
totalAlbums = r.paths.length; totalAlbums = r.paths.length;
@ -68,6 +70,7 @@ function scanForAlbums() {
} else { } else {
alert('Error occured: no such layer `gallery_list`'); alert('Error occured: no such layer `gallery_list`');
} }
$('#g-scan-button').attr('disabled', null);
} }
}); });
} }
@ -125,13 +128,13 @@ function galleryRename(name) {
$(this).dialog("close"); $(this).dialog("close");
return; return;
} }
$.getJSON("ajax/galleryOp.php", {operation: "rename", oldname: name, newname: newname}, function(r) { $.getJSON('ajax/galleryOp.php', {operation: 'rename', oldname: name, newname: newname}, function(r) {
if (r.status == "success") { if (r.status == "success") {
Albums.rename($(".gallery_album_box").filterAttr('data-album',name), newname); Albums.rename($(".gallery_album_box").filterAttr('data-album',name), newname);
} else { } else {
alert("Error: " + r.cause); alert("Error: " + r.cause);
} }
$('#dialog-form').dialog("close"); $('#dialog-form').dialog('close');
}); });
} }
@ -139,10 +142,49 @@ function galleryRename(name) {
{ {
text: t('gallery', 'Cancel'), text: t('gallery', 'Cancel'),
click: function() { click: function() {
$( this ).dialog( "close" ); $( this ).dialog('close');
} }
} }
], ],
}); });
} }
function settings() {
$( '#g-dialog-settings' ).dialog({
height: 180,
width: 350,
modal: false,
buttons: [{
text: t('gallery', 'Apply'),
click: function() {
var scanning_root = $('#g-scanning-root').val();
var disp_order = $('#g-display-order option:selected').val();
if (scanning_root == '') {
alert('Scanning root cannot be empty');
return;
}
$.getJSON('ajax/galleryOp.php', {operation: 'store_settings', root: scanning_root, order: disp_order}, function(r) {
if (r.status == 'success') {
if (r.rescan == 'yes') {
$('#g-dialog-settings').dialog('close');
Albums.clear(document.getElementById('gallery_list'));
scanForAlbums(true);
return;
}
} else {
alert('Error: ' + r.cause);
return;
}
$('#g-dialog-settings').dialog('close');
});
}
},
{
text: t('gallery', 'Cancel'),
click: function() {
$(this).dialog('close');
}
}
],
});
}

View File

@ -52,14 +52,14 @@ Albums={
}); });
$(".gallery_album_decoration a.remove", local).bind('click', {name: a.name},function(event){ $(".gallery_album_decoration a.remove", local).bind('click', {name: a.name},function(event){
event.preventDefault(); event.preventDefault();
galleryRemove(a.data.name); galleryRemove(event.data.name);
}); });
$("a.view", local).attr('href','?view='+a.name); $("a.view", local).attr('href','?view='+escape(a.name));
$('h1',local).text(a.name); $('h1',local).text(a.name);
$(".gallery_album_cover", local).attr('title',a.name); $(".gallery_album_cover", local).attr('title',a.name);
$(".gallery_album_cover", local).css('background-repeat', 'no-repeat'); $(".gallery_album_cover", local).css('background-repeat', 'no-repeat');
$(".gallery_album_cover", local).css('background-position', '0'); $(".gallery_album_cover", local).css('background-position', '0');
$(".gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+a.name+'")'); $(".gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+escape(a.name)+'")');
$(".gallery_album_cover", local).mousemove(function(e) { $(".gallery_album_cover", local).mousemove(function(e) {
var albumMetadata = Albums.find(this.title); var albumMetadata = Albums.find(this.title);
@ -80,6 +80,10 @@ Albums={
$("a.view", element).attr("href", "?view="+new_name); $("a.view", element).attr("href", "?view="+new_name);
$("h1", element).text(new_name); $("h1", element).text(new_name);
} }
},
clear: function(element) {
Albums.albums = new Array();
element.innerHTML = '';
} }
} }

View File

@ -32,6 +32,14 @@ class OC_Gallery_Album {
$stmt->execute(array($newname, $owner, $oldname)); $stmt->execute(array($newname, $owner, $oldname));
} }
public static function cleanup() {
$albums = self::find(OC_User::getUser());
while ($r = $albums->fetchRow()) {
OC_Gallery_Photo::removeByAlbumId($r['album_id']);
self::remove(OC_User::getUser(), $r['album_name']);
}
}
public static function remove($owner, $name=null) { public static function remove($owner, $name=null) {
$sql = 'DELETE FROM *PREFIX*gallery_albums WHERE uid_owner = ?'; $sql = 'DELETE FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
$args = array($owner); $args = array($owner);
@ -69,7 +77,8 @@ class OC_Gallery_Album {
$sql .= ' AND album_path = ?'; $sql .= ' AND album_path = ?';
$args[] = $path; $args[] = $path;
} }
$sql .= ' ORDER BY album_name ASC'; $order = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'order', 'ASC');
$sql .= ' ORDER BY album_name ' . $order;
$stmt = OC_DB::prepare($sql); $stmt = OC_DB::prepare($sql);
return $stmt->execute($args); return $stmt->execute($args);

View File

@ -58,12 +58,18 @@ class OC_Gallery_Hooks_Handlers {
return OC_Gallery_Album::find(OC_User::getUser(), null, $path); return OC_Gallery_Album::find(OC_User::getUser(), null, $path);
} }
public static function pathInRoot($path) {
$root = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '/');
return substr($path, 0, strlen($path)>strlen($root)?strlen($root):strlen($path)) == $root;
}
public static function addPhotoFromPath($params) { public static function addPhotoFromPath($params) {
$fullpath = $params[OC_Filesystem::signal_param_path]; $fullpath = $params[OC_Filesystem::signal_param_path];
if (!self::isPhoto($fullpath)) return; if (!self::isPhoto($fullpath)) return;
$path = substr($fullpath, 0, strrpos($fullpath, '/')); $path = substr($fullpath, 0, strrpos($fullpath, '/'));
if (!self::pathInRoot($path)) return;
OC_Gallery_Scanner::scanDir($path, $albums); OC_Gallery_Scanner::scanDir($path, $albums);
} }
@ -71,8 +77,8 @@ class OC_Gallery_Hooks_Handlers {
public static function removePhoto($params) { public static function removePhoto($params) {
$path = $params[OC_Filesystem::signal_param_path]; $path = $params[OC_Filesystem::signal_param_path];
if (OC_Filesystem::is_dir($path) && self::directoryContainsPhotos($path)) { if (OC_Filesystem::is_dir($path) && self::directoryContainsPhotos($path)) {
OC_Gallery_Album::removeByPath($path, OC_User::getUser()); if(!self::pathInRoot($path)) return;
OC_Gallery_Photo::removeByPath($path.'/%'); OC_Gallery_Album::removeByPath($path.'/', OC_User::getUser());
} elseif (self::isPhoto($path)) { } elseif (self::isPhoto($path)) {
OC_Gallery_Photo::removeByPath($path); OC_Gallery_Photo::removeByPath($path);
} }

View File

@ -39,12 +39,19 @@ class OC_Gallery_Scanner {
$stmt->execute(array()); $stmt->execute(array());
} }
public static function createName($name) {
$root = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '/');
$name = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $name));
if (substr($name, 0, strlen($root)) == str_replace('/','.',$root)) {
$name = substr($name, strlen($root));
}
$name = ($name==='.') ? 'main' : trim($name,'.');
return $name;
}
public static function scanDir($path, &$albums) { public static function scanDir($path, &$albums) {
$current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array()); $current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array());
$current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name'])); $current_album['name'] = self::createName($current_album['name']);
$current_album['name'] = ($current_album['name']==='.') ?
'main' :
trim($current_album['name'],'.');
if ($dh = OC_Filesystem::opendir($path)) { if ($dh = OC_Filesystem::opendir($path)) {
while (($filename = readdir($dh)) !== false) { while (($filename = readdir($dh)) !== false) {
@ -106,7 +113,7 @@ class OC_Gallery_Scanner {
if (self::isPhoto($path.$file)) $addpath = TRUE; if (self::isPhoto($path.$file)) $addpath = TRUE;
} }
if ($addpath) $ret[] = $path; if ($addpath) $ret[] = urlencode($path);
return $ret; return $ret;
} }

View File

@ -9,7 +9,10 @@ $l = new OC_L10N('gallery');
<div id="controls"> <div id="controls">
<div id="scan"> <div id="scan">
<div id="scanprogressbar"></div> <div id="scanprogressbar"></div>
<input type="button" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" /> <input type="button" id="g-scan-button" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" />
</div>
<div id="g-settings">
<input type="button" id="g-settings-button" value="<?php echo $l->t('Settings');?>" onclick="javascript:settings();"/>
</div> </div>
</div> </div>
<div id="gallery_list"> <div id="gallery_list">
@ -28,3 +31,26 @@ $l = new OC_L10N('gallery');
</form> </form>
</div> </div>
<div id="g-dialog-settings" title="<?php echo $l->t('Settings');?>" style="display:none">
<form>
<fieldset><?php $root = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '/'); $order = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'order', 'ASC');?>
<label for="name"><?php echo $l->t('Scanning root');?></label>
<input type="text" name="g-scanning-root" id="g-scanning-root" class="text ui-widget-content ui-corner-all" value="<?php echo $root;?>" /><br/>
<label for="sort"><?php echo $l->t('Default sorting'); ?></label>
<select id="g-display-order">
<option value="ASC"<?php echo $order=='ASC'?'selected':'';?>><?php echo $l->t('Ascending'); ?></option>
<option value="DESC"<?php echo $order=='DESC'?'selected':'';?>><?php echo $l->t('Descending'); ?></option>
</select><br/>
<!--
<label for="sort"><?php echo $l->t('Thumbnails size'); ?></label>
<select>
<option value="100">100px</option>
<option value="150">150px</option>
<option value="200">200px</option>
</select>
-->
</fieldset>
</form>
</div>