mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-12-01 13:24:10 +01:00
Contacts: Fix property indexing.
This commit is contained in:
parent
a2771fcc5d
commit
addd12c967
@ -77,4 +77,5 @@ $tmpl->assign('categories', $categories, false);
|
||||
$tmpl->assign('im_protocols', $im_protocols, false);
|
||||
$tmpl->assign('has_contacts', $has_contacts, false);
|
||||
$tmpl->assign('id', $id);
|
||||
$tmpl->assign('is_indexed', OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'contacts_indexed', 'no'));
|
||||
$tmpl->printPage();
|
||||
|
@ -577,6 +577,15 @@ OC.Contacts = OC.Contacts || {
|
||||
this.bindEvents();
|
||||
this.$toggleAll.show();
|
||||
this.showActions(['addcontact']);
|
||||
// Wait 2 mins then check if contacts are indexed.
|
||||
setTimeout(function() {
|
||||
if(!is_indexed) {
|
||||
OC.notify({message:t('contacts', 'Indexing contacts'), timeout:20});
|
||||
$.post(OC.filePath('contacts', 'ajax', 'indexproperties.php'));
|
||||
} else {
|
||||
console.log('contacts are indexed.');
|
||||
}
|
||||
}, 10000);
|
||||
},
|
||||
loading:function(obj, state) {
|
||||
$(obj).toggleClass('loading', state);
|
||||
|
24
lib/app.php
24
lib/app.php
@ -29,6 +29,11 @@ class App {
|
||||
*/
|
||||
public static $multi_properties = array('EMAIL', 'TEL', 'IMPP', 'ADR', 'URL');
|
||||
|
||||
/**
|
||||
* Properties to index.
|
||||
*/
|
||||
public static $index_properties = array('FN', 'NICKNAME', 'ORG', 'CATEGORIES', 'EMAIL', 'TEL', 'IMPP', 'ADR', 'URL');
|
||||
|
||||
const THUMBNAIL_PREFIX = 'contact-thumbnail-';
|
||||
const THUMBNAIL_SIZE = 28;
|
||||
|
||||
@ -336,8 +341,12 @@ class App {
|
||||
return;
|
||||
}
|
||||
|
||||
$stmt = \OCP\DB::prepare( 'INSERT INTO `*PREFIX*contacts_cards_properties` (`contactid`,`name`,`value`,`preferred`) VALUES(?,?,?,?)' );
|
||||
$stmt = \OCP\DB::prepare( 'INSERT INTO `*PREFIX*contacts_cards_properties` '
|
||||
. '(`userid`, `contactid`,`name`,`value`,`preferred`) VALUES(?,?,?,?,?)' );
|
||||
foreach($vcard->children as $property) {
|
||||
if(!in_array($property->name, self::$index_properties)) {
|
||||
continue;
|
||||
}
|
||||
$preferred = false;
|
||||
foreach($property->parameters as $parameter) {
|
||||
if($parameter->name == 'TYPE' && strtoupper($parameter->value) == 'PREF') {
|
||||
@ -346,9 +355,18 @@ class App {
|
||||
}
|
||||
}
|
||||
try {
|
||||
$result = $stmt->execute(array($contactid, $property->name, $property->value, $preferred));
|
||||
$result = $stmt->execute(
|
||||
array(
|
||||
\OCP\User::getUser(),
|
||||
$contactid,
|
||||
$property->name,
|
||||
$property->value,
|
||||
$preferred,
|
||||
)
|
||||
);
|
||||
if (\OC_DB::isError($result)) {
|
||||
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: ' . \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
|
||||
\OCP\Util::writeLog('contacts', __METHOD__. 'DB error: '
|
||||
. \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
|
||||
return false;
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
<div id='notification'></div>
|
||||
<div id="appsettings" class="popup topright hidden"></div>
|
||||
<script type='text/javascript'>
|
||||
var is_indexed = <?php echo $_['is_indexed'] == 'yes' ? 'true' : 'false'; ?>;
|
||||
var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks';
|
||||
var categories = <?php echo json_encode($_['categories']); ?>;
|
||||
var id = '<?php echo $_['id']; ?>';
|
||||
|
Loading…
Reference in New Issue
Block a user