Skip to content

Commit

Permalink
Scrutinizer cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghus committed Mar 8, 2014
1 parent f1aa862 commit f6bfea7
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 426 deletions.
1 change: 1 addition & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
filter:
excluded_paths:
- 'js/modernizr.custom.js'
- 'js/jquery.onfontresize.js'
- 'l10n/*'
- 'js/placeholder*'
- 'css/placeholder*'
Expand Down
7 changes: 4 additions & 3 deletions appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

namespace OCA\Contacts;

use \OC\AppFramework\Core\API;

//require_once __DIR__ . '/../lib/controller/pagecontroller.php';
Expand Down Expand Up @@ -58,11 +59,11 @@
\OCP\Share::registerBackend('addressbook', 'OCA\Contacts\Share\Addressbook', 'contact');
//\OCP\App::registerPersonal('contacts','personalsettings');

if(\OCP\User::isLoggedIn()) {
if (\OCP\User::isLoggedIn()) {
$app = new App($api->getUserId());
$addressBooks = $app->getAddressBooksForUser();
foreach($addressBooks as $addressBook) {
if($addressBook->isActive()) {
foreach ($addressBooks as $addressBook) {
if ($addressBook->isActive()) {
\OCP\Contacts::registerAddressBook(new AddressbookProvider($addressBook));
}
}
Expand Down
9 changes: 5 additions & 4 deletions appinfo/remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

OCP\App::checkAppEnabled('contacts');

if(substr(OCP\Util::getRequestUri(), 0, strlen(OC_App::getAppWebPath('contacts').'/carddav.php'))
if (substr(OCP\Util::getRequestUri(), 0, strlen(OC_App::getAppWebPath('contacts').'/carddav.php'))
=== OC_App::getAppWebPath('contacts').'/carddav.php'
) {
$baseuri = OC_App::getAppWebPath('contacts').'/carddav.php';
}

// only need authentication apps
$RUNTIME_APPTYPES=array('authentication');
$RUNTIME_APPTYPES = array('authentication');
OC_App::loadApps($RUNTIME_APPTYPES);

// Backends
Expand All @@ -53,7 +53,7 @@
$nodes = array(
$principalCollection,
$addressBookRoot,
);
);

// Fire up server
$server = new Sabre_DAV_Server($nodes);
Expand All @@ -67,8 +67,9 @@
$server->addPlugin(new Sabre_CardDAV_VCFExportPlugin());
$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('carddav'));

if(defined('DEBUG') && DEBUG) {
if (defined('DEBUG') && DEBUG) {
$server->debugExceptions = true;
}

// And off we go!
$server->exec();
9 changes: 4 additions & 5 deletions appinfo/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
* See the COPYING-README file.
*/

$installedVersion=OCP\Config::getAppValue('contacts', 'installed_version');
$installedVersion = OCP\Config::getAppValue('contacts', 'installed_version');
if (version_compare($installedVersion, '0.2.5', '>=')) {
// Set all address books active as (de)activating went awol at rewrite.
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`= 1' );
$result = $stmt->execute(array());
}
elseif (version_compare($installedVersion, '0.2.4', '==')) {
} elseif (version_compare($installedVersion, '0.2.4', '==')) {
// First set all address books in-active.
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`=0' );
$result = $stmt->execute(array());
Expand All @@ -24,9 +23,9 @@

// Prepare statement for updating the new 'active' field.
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`=? WHERE `id`=? AND `userid`=?' );
while( $row = $result->fetchRow()) {
while ($row = $result->fetchRow()) {
$ids = explode(';', $row['configvalue']);
foreach($ids as $id) {
foreach ($ids as $id) {
$r = $stmt->execute(array(1, $id, $row['userid']));
}
}
Expand Down
3 changes: 2 additions & 1 deletion carddav.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
if(!file_exists('../../lib/base.php')) {
if (!file_exists('../../lib/base.php')) {
die('Please update the path to /lib/base.php in carddav.php or make use of /remote.php/carddav/');
}

require_once '../../lib/base.php';
require_once 'appinfo/remote.php';
39 changes: 19 additions & 20 deletions js/addressbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OC.Contacts = OC.Contacts || {};
this.storage = storage;
this.book = book;
this.$template = template;
}
};

AddressBook.prototype.render = function() {
var self = this;
Expand Down Expand Up @@ -198,16 +198,17 @@ OC.Contacts = OC.Contacts || {};
if(response.error) {
$(document).trigger('status.contacts.error', response);
}
cb(response);
if(typeof cb === 'function') {
cb(response);
}
});
};

/**
* Delete address book from data store and remove it from the DOM
* @param cb Optional callback function which
* @return An object with a boolean variable 'error'.
*/
AddressBook.prototype.destroy = function(cb) {
AddressBook.prototype.destroy = function() {
var self = this;
$.when(this.storage.deleteAddressBook(this.getBackend(), self.getId()))
.then(function(response) {
Expand All @@ -233,7 +234,7 @@ OC.Contacts = OC.Contacts || {};
bookTemplate,
bookItemTemplate,
isFileAction
) {
) {
var self = this;
this.isFileAction = isFileAction || false;
this.storage = storage;
Expand Down Expand Up @@ -271,7 +272,7 @@ OC.Contacts = OC.Contacts || {};
self.addressBooks.splice(self.addressBooks.indexOf(addressBook), 1);
self.buildImportSelect();
});
$(document).bind('status.addressbook.added', function(e) {
$(document).bind('status.addressbook.added', function() {
self.buildImportSelect();
});
this.$importIntoSelect.on('change', function() {
Expand All @@ -289,7 +290,7 @@ OC.Contacts = OC.Contacts || {};
});
this.$importFileInput.fileupload({
dataType: 'json',
start: function(e, data) {
start: function(/*e, data*/) {
self.$importProgress.progressbar({value:false});
$('.tipsy').remove();
$('.import-upload').hide();
Expand Down Expand Up @@ -370,7 +371,7 @@ OC.Contacts = OC.Contacts || {};
if(!response.error) {
self.$importProgress.progressbar('value', Number(response.data.progress));
self.$importStatusText.text(t('contacts', 'Imported {count} of {total} contacts',
{count:response.data.progress, total: self.importCount}));
{count:response.data.progress, total: self.importCount}));
} else {
console.warn('Error', response.message);
self.$importStatusText.text(response.message);
Expand All @@ -386,7 +387,8 @@ OC.Contacts = OC.Contacts || {};
self.storage.startImport(
data.backend, data.addressBookId,
{filename:data.filename, progresskey:data.progresskey}
))
)
)
.then(function(response) {
console.log('response', response);
if(!response.error) {
Expand Down Expand Up @@ -421,7 +423,7 @@ OC.Contacts = OC.Contacts || {};
$(document).trigger('status.contacts.error', response);
}
return defer;
}
};

/**
* Rebuild the select to choose which address book to import into.
Expand All @@ -446,7 +448,7 @@ OC.Contacts = OC.Contacts || {};
self.$importFileInput.prop('disabled', true);
}
}
}
};

/**
* Create an AddressBook object, save it in internal list and append it's rendered result to the list
Expand Down Expand Up @@ -481,7 +483,7 @@ OC.Contacts = OC.Contacts || {};
}
});
return addressBook;
}
};

/**
* Move a contacts from one address book to another..
Expand All @@ -492,7 +494,6 @@ OC.Contacts = OC.Contacts || {};
*/
AddressBookList.prototype.moveContact = function(contact, from, target) {
console.log('AddressBookList.moveContact, contact', contact, from, target);
var self = this;
$.when(this.storage.moveContact(from.backend, from.id, contact.getId(), {target:target}))
.then(function(response) {
if(!response.error) {
Expand All @@ -505,7 +506,7 @@ OC.Contacts = OC.Contacts || {};
$(document).trigger('status.contacts.error', response);
}
});
}
};

/**
* Get an array of address books with at least the required permission.
Expand All @@ -515,7 +516,6 @@ OC.Contacts = OC.Contacts || {};
*/
AddressBookList.prototype.selectByPermission = function(permission, noClone) {
var books = [];
var self = this;
$.each(this.addressBooks, function(idx, book) {
if(book.getPermissions() & permission) {
// Clone the address book not to mess with with original
Expand Down Expand Up @@ -545,7 +545,7 @@ OC.Contacts = OC.Contacts || {};
}
var error = '';
$.each(this.addressBooks, function(idx, book) {
if(book.getDisplayName() == name) {
if(book.getDisplayName() === name) {
console.log('Dupe');
error = t('contacts', 'An address book called {name} already exists', {name:name});
if(typeof cb === 'function') {
Expand Down Expand Up @@ -580,7 +580,7 @@ OC.Contacts = OC.Contacts || {};
.fail(function(jqxhr, textStatus, error) {
$(this).removeClass('loading');
var err = textStatus + ', ' + error;
console.log( "Request Failed: " + err);
console.log('Request Failed', + err);
error = t('contacts', 'Failed adding address book: {error}', {error:err});
if(typeof cb === 'function') {
cb({error:true, message:error});
Expand All @@ -598,9 +598,8 @@ OC.Contacts = OC.Contacts || {};
var defer = $.Deferred();
$.when(this.storage.getAddressBooksForUser()).then(function(response) {
if(!response.error) {
var num = response.data.addressbooks.length;
$.each(response.data.addressbooks, function(idx, addressBook) {
var book = self.insertAddressBook(addressBook);
self.insertAddressBook(addressBook);
});
self.buildImportSelect();
console.log('After buildImportSelect');
Expand All @@ -620,7 +619,7 @@ OC.Contacts = OC.Contacts || {};
}
})
.fail(function(response) {
console.warn( "Request Failed:", response);
console.warn('Request Failed:', response);
defer.reject({
error: true,
message: t('contacts', 'Failed loading address books: {error}', {error:response.message})
Expand Down
4 changes: 3 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Modernizr.load({
for (var i = 0; i < a.length; ++i)
{
var p=a[i].split('=');
if (p.length !== 2) continue;
if (p.length !== 2) {
continue;
}
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, ' '));
}
return b;
Expand Down
4 changes: 2 additions & 2 deletions js/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ OC.Contacts = OC.Contacts || {};
}
// Not found, so adding it.
self.data[name].push(newproperty);
}
};

var self = this;
$.each(mergees, function(idx, mergee) {
Expand Down Expand Up @@ -591,7 +591,7 @@ OC.Contacts = OC.Contacts || {};
if(!self.data.FN || !self.data.FN.length) {
self.data.FN = [{name:'FN', value:'', parameters:[]}];
}
self.data.FN[0]['value'] = value;
self.data.FN[0].value = value;
// Used for sorting list elements
self.displayNames.fn = value;
var nempty = true;
Expand Down
28 changes: 0 additions & 28 deletions js/cropphoto.js

This file was deleted.

Loading

0 comments on commit f6bfea7

Please sign in to comment.