owncloud /
contacts
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | /** |
||
| 2 | * Copyright (c) 2013 Thomas Tanghus ([email protected]) |
||
| 3 | * This file is licensed under the Affero General Public License version 3 or |
||
| 4 | * later. |
||
| 5 | * See the COPYING-README file. |
||
| 6 | */ |
||
| 7 | OC.ContactsImporter = OC.ContactsImporter || { |
||
| 8 | init:function(fileName) { |
||
| 9 | var self = OC.ContactsImporter; |
||
| 10 | self.path = $('#dir').val(); |
||
| 11 | self.fileName = fileName; |
||
| 12 | console.log('fileName', self.path, self.fileName); |
||
| 13 | /*OC.addScript('contacts', 'addressbooks', function() { |
||
| 14 | OC.addScript('contacts', 'storage', function() { |
||
| 15 | $.when(self._getTemplate()).then(function($tmpl) { |
||
| 16 | self.$template = $tmpl; |
||
| 17 | if(self.$dialog) { |
||
| 18 | self.$dialog.ocdialog('close'); |
||
| 19 | } |
||
| 20 | self.$dialog = self.$template.octemplate({ |
||
| 21 | selectText: t('contacts', 'Please choose the addressbook'), |
||
| 22 | defaultText: t('contacts', 'Import into...') |
||
| 23 | }); |
||
| 24 | self.$dialog.appendTo($('body')); |
||
| 25 | self.addressBooks = new OC.Contacts.AddressBookList( |
||
| 26 | new OC.Contacts.Storage(), self.$dialog, null, true |
||
| 27 | ); |
||
| 28 | self.showDialog(); |
||
| 29 | }) |
||
| 30 | .fail(function() { |
||
| 31 | alert(t('contacts', 'Error loading import template')); |
||
| 32 | }); |
||
| 33 | }) |
||
| 34 | .fail(function(jqxhr, settings, exception) { |
||
| 35 | console.warn('Error loading storage backend', jqxhr, settings, exception); |
||
| 36 | }); |
||
| 37 | }) |
||
| 38 | .fail(function(jqxhr, settings, exception) { |
||
| 39 | console.warn('Error loading address book backend', jqxhr, settings, exception); |
||
| 40 | });*/ |
||
| 41 | }, |
||
| 42 | showDialog:function() { |
||
| 43 | var self = this; |
||
| 44 | $.when(self.addressBooks.loadAddressBooks()).then(function(response) { |
||
| 45 | if(!response.error) { |
||
| 46 | self.$dialog.ocdialog({ |
||
| 47 | modal: true, |
||
| 48 | title: t('contacts', 'Import contacts'), |
||
| 49 | close: function() { |
||
| 50 | $(this).ocdialog('destroy').remove(); |
||
| 51 | self.$dialog = null; |
||
| 52 | } |
||
| 53 | }); |
||
| 54 | self.$importIntoSelect = $('#contacts-import-into'); |
||
| 55 | self.$importIntoSelect.on('change', function() { |
||
| 56 | var $selected = $(this).find('option:selected'); |
||
| 57 | if($(this).val() === '-1') { |
||
| 58 | self.$dialog.ocdialog('option', 'buttons', []); |
||
| 59 | } else { |
||
| 60 | self.$dialog.ocdialog('option', 'buttons', [{ |
||
| 61 | text: t('contacts', 'Import'), |
||
| 62 | defaultButton: true, |
||
| 63 | click:function() { |
||
| 64 | console.log('Selected', $selected); |
||
| 65 | self.$dialog.ocdialog('option', { |
||
| 66 | buttons: [], |
||
| 67 | closeButton: false, |
||
| 68 | title: t('contacts', 'Importing...') |
||
| 69 | }); |
||
| 70 | self.startImport($selected.data('backend'), $selected.val(), self.$importFormatSelect.find('option:selected').val()); |
||
| 71 | } |
||
| 72 | }]); |
||
| 73 | } |
||
| 74 | }); |
||
| 75 | } else { |
||
| 76 | console.warn('response.message'); |
||
| 77 | } |
||
| 78 | }) |
||
| 79 | .fail(function(response) { |
||
| 80 | console.warn(response); |
||
| 81 | }); |
||
| 82 | }, |
||
| 83 | startImport: function(backend, addressBookId, importType) { |
||
| 84 | var self = this; |
||
| 85 | $('.import-select').hide(); |
||
| 86 | $('.import-status').show(); |
||
| 87 | $.when(self.addressBooks.prepareImport(backend, addressBookId, importType, this.path, this.fileName)) |
||
| 88 | .then(function(response) { |
||
| 89 | if(!response.error) { |
||
| 90 | $.when(self.addressBooks.doImport(response)).then(function(response) { |
||
| 91 | self.$dialog.ocdialog('option', { |
||
| 92 | title: t('contacts', 'Import done'), |
||
| 93 | closeButton: true, |
||
| 94 | buttons: [{ |
||
| 95 | text: t('contacts', 'Close'), |
||
| 96 | defaultButton: true, |
||
| 97 | click:function() { |
||
| 98 | self.$dialog.ocdialog('close'); |
||
| 99 | } |
||
| 100 | }] |
||
| 101 | }); |
||
| 102 | }) |
||
| 103 | .fail(function(response) { |
||
| 104 | console.warn(response); |
||
| 105 | }); |
||
| 106 | } else { |
||
| 107 | console.warn('response.message'); |
||
| 108 | } |
||
| 109 | }) |
||
| 110 | .fail(function(response) { |
||
| 111 | console.warn(response); |
||
| 112 | }); |
||
| 113 | }, |
||
| 114 | _getTemplate: function() { |
||
| 115 | var defer = $.Deferred(); |
||
| 116 | if(!this.$template) { |
||
| 117 | $.get(OC.filePath('contacts', 'templates', 'importdialog.html'), function(tmpl) { |
||
| 118 | defer.resolve($(tmpl)); |
||
| 119 | }) |
||
| 120 | .fail(function() { |
||
| 121 | defer.reject(); |
||
| 122 | }); |
||
| 123 | } else { |
||
| 124 | defer.resolve(this.$template); |
||
| 125 | } |
||
| 126 | return defer.promise(); |
||
| 127 | } |
||
| 128 | }; |
||
| 129 | |||
| 130 | $(document).ready(function(){ |
||
| 131 | |||
| 132 | // translate search result type |
||
| 133 | OC.search.resultTypes.contact = t('contacts', 'Contact'); |
||
| 134 | |||
| 135 | OC.search.customResults.contact = function (row, item){ |
||
| 136 | var text = ''; |
||
| 137 | if (item.email) { |
||
| 138 | text += '✉ ' + item.email; |
||
| 139 | if (item.phone) { |
||
| 140 | text += ', ' |
||
|
0 ignored issues
–
show
|
|||
| 141 | } |
||
| 142 | } |
||
| 143 | if (item.phone) { |
||
| 144 | text += '☎ ' + item.phone |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 145 | } |
||
| 146 | row.find('td.result .text').text(text); |
||
| 147 | }; |
||
| 148 | |||
| 149 | // If the app is already active there's no need for the FileActions |
||
| 150 | if(OC.Contacts) { |
||
| 151 | return; |
||
| 152 | } |
||
| 153 | |||
| 154 | $(document).bind('status.contacts.error', function(e, data) { |
||
| 155 | console.warn(data.message); |
||
| 156 | //console.trace(); |
||
| 157 | //OC.notify({message:data.message}); |
||
| 158 | }); |
||
| 159 | |||
| 160 | if(typeof FileActions !== 'undefined'){ |
||
| 161 | FileActions.register('text/vcard','importaddressbook', OC.PERMISSION_READ, '', OC.ContactsImporter.init); |
||
| 162 | FileActions.setDefault('text/vcard','importaddressbook'); |
||
| 163 | FileActions.register('text/x-vcard','importaddressbook', OC.PERMISSION_READ, '', OC.ContactsImporter.init); |
||
| 164 | FileActions.setDefault('text/x-vcard','importaddressbook'); |
||
| 165 | } |
||
| 166 | |||
| 167 | }); |
||
| 168 |
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.
Further Readings: