Merge branch 'master' into calendar_export

This commit is contained in:
Georg Ehrke 2012-06-27 14:05:11 +02:00
commit 90b5cf680f
20 changed files with 316 additions and 132 deletions

View File

@ -217,6 +217,14 @@ class OC_Calendar_Object{
return true; return true;
} }
/**
* @brief Creates a UID
* @return string
*/
protected static function createUID(){
return substr(md5(rand().time()),0,10);
}
/** /**
* @brief Extracts data from a vObject-Object * @brief Extracts data from a vObject-Object
* @param Sabre_VObject $object * @param Sabre_VObject $object

View File

@ -31,6 +31,7 @@ foreach($active_addressbooks as $addressbook) {
$contacts_alphabet = OC_Contacts_VCard::all($ids); $contacts_alphabet = OC_Contacts_VCard::all($ids);
// Our new array for the contacts sorted by addressbook // Our new array for the contacts sorted by addressbook
if($contacts_alphabet) {
foreach($contacts_alphabet as $contact) { foreach($contacts_alphabet as $contact) {
if(!isset($contacts_addressbook[$contact['addressbookid']])) { // It should never execute. if(!isset($contacts_addressbook[$contact['addressbookid']])) { // It should never execute.
$contacts_addressbook[$contact['addressbookid']] = array('contacts' => array()); $contacts_addressbook[$contact['addressbookid']] = array('contacts' => array());
@ -45,6 +46,7 @@ foreach($contacts_alphabet as $contact) {
} }
$contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display)); $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
} }
}
unset($contacts_alphabet); unset($contacts_alphabet);
uasort($contacts_addressbook, 'cmp'); uasort($contacts_addressbook, 'cmp');

View File

@ -27,6 +27,7 @@ OCP\JSON::checkAppEnabled('contacts');
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size); $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$requesttoken = $_GET['requesttoken'];
$freeSpace=OC_Filesystem::free_space('/'); $freeSpace=OC_Filesystem::free_space('/');
$freeSpace=max($freeSpace,0); $freeSpace=max($freeSpace,0);
@ -41,6 +42,7 @@ $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesi
$tmpl->assign('adr_types',$adr_types); $tmpl->assign('adr_types',$adr_types);
$tmpl->assign('phone_types',$phone_types); $tmpl->assign('phone_types',$phone_types);
$tmpl->assign('email_types',$email_types); $tmpl->assign('email_types',$email_types);
$tmpl->assign('requesttoken', $requesttoken);
$tmpl->assign('id',''); $tmpl->assign('id','');
$page = $tmpl->fetchPage(); $page = $tmpl->fetchPage();

View File

@ -5,6 +5,7 @@ OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php'; OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php'; OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php'; OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php';
OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Contacts_Hooks', 'createUser');
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser'); OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser');
OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents'); OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents');
OCP\Util::connectHook('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources'); OCP\Util::connectHook('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources');

View File

@ -15,6 +15,9 @@ OCP\App::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists. // Get active address books. This creates a default one if none exists.
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
$contacts = OC_Contacts_VCard::all($ids); $contacts = OC_Contacts_VCard::all($ids);
if($contacts === false) {
OCP\Util::writeLog('contacts','index.html: No contacts found.',OCP\Util::DEBUG);
}
$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser()); $addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());

View File

@ -48,7 +48,7 @@ Contacts={
adrstr = adrstr + adrarr[6].trim(); adrstr = adrstr + adrarr[6].trim();
} }
adrstr = encodeURIComponent(adrstr); adrstr = encodeURIComponent(adrstr);
var uri = 'http://open.mapquestapi.com/nominatim/v1/search.php?q=' + adrstr + '&limit=10&addressdetails=1&zoom='; var uri = 'http://open.mapquestapi.com/nominatim/v1/search.php?q=' + adrstr + '&limit=10&addressdetails=1&polygon=1&zoom=';
var newWindow = window.open(uri,'_blank'); var newWindow = window.open(uri,'_blank');
newWindow.focus(); newWindow.focus();
}, },
@ -234,6 +234,30 @@ Contacts={
$('#contacts_downloadcard').tipsy({gravity: 'ne'}); $('#contacts_downloadcard').tipsy({gravity: 'ne'});
$('#contacts_propertymenu_button').tipsy(); $('#contacts_propertymenu_button').tipsy();
$('#contacts_newcontact, #chooseaddressbook').tipsy({gravity: 'sw'}); $('#contacts_newcontact, #chooseaddressbook').tipsy({gravity: 'sw'});
$('body').click(function(e){
if(!$(e.target).is('#contacts_propertymenu_button')) {
$('#contacts_propertymenu_dropdown').hide();
}
});
function propertyMenu(){
var menu = $('#contacts_propertymenu_dropdown');
if(menu.is(':hidden')) {
menu.show();
menu.find('li').first().focus();
} else {
menu.hide();
}
}
$('#contacts_propertymenu_button').click(propertyMenu);
$('#contacts_propertymenu_button').keydown(propertyMenu);
function propertyMenuItem(){
var type = $(this).data('type');
Contacts.UI.Card.addProperty(type);
$('#contacts_propertymenu_dropdown').hide();
}
$('#contacts_propertymenu_dropdown a').click(propertyMenuItem);
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem);
}, },
Card:{ Card:{
id:'', id:'',
@ -258,6 +282,9 @@ Contacts={
newid = id; newid = id;
bookid = bookid?bookid:$('#contacts li[data-id="'+newid+'"]').data('bookid'); bookid = bookid?bookid:$('#contacts li[data-id="'+newid+'"]').data('bookid');
} }
if(!bookid) {
bookid = $('#contacts h3').first().data('id');
}
var localLoadContact = function(newid, bookid) { var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) { if($('.contacts li').length > 0) {
$('#contacts li[data-id="'+newid+'"]').addClass('active'); $('#contacts li[data-id="'+newid+'"]').addClass('active');
@ -359,7 +386,7 @@ Contacts={
var card = $('#card')[0]; var card = $('#card')[0];
if(!card) { if(!card) {
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){ $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{'requesttoken': requesttoken},function(jsondata){
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page).ready(function() { $('#rightcontent').html(jsondata.data.page).ready(function() {
Contacts.UI.loadHandlers(); Contacts.UI.loadHandlers();
@ -1566,6 +1593,8 @@ Contacts={
scroll: true, scrollSensitivity: 100, scroll: true, scrollSensitivity: 100,
opacity: 0.7, helper: 'clone' opacity: 0.7, helper: 'clone'
}); });
} else {
$('#contacts h3').first().addClass('active');
} }
}); });
Contacts.UI.Card.update(id); Contacts.UI.Card.update(id);
@ -1734,30 +1763,6 @@ $(document).ready(function(){
xhr.send(file); xhr.send(file);
} }
$('body').click(function(e){
if(!$(e.target).is('#contacts_propertymenu_button')) {
$('#contacts_propertymenu_dropdown').hide();
}
});
function propertyMenu(){
var menu = $('#contacts_propertymenu_dropdown');
if(menu.is(':hidden')) {
menu.show();
menu.find('li').first().focus();
} else {
menu.hide();
}
}
$('#contacts_propertymenu_button').click(propertyMenu);
$('#contacts_propertymenu_button').keydown(propertyMenu);
function propertyMenuItem(){
var type = $(this).data('type');
Contacts.UI.Card.addProperty(type);
$('#contacts_propertymenu_dropdown').hide();
}
$('#contacts_propertymenu_dropdown a').click(propertyMenuItem);
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem);
Contacts.UI.loadHandlers(); Contacts.UI.loadHandlers();
Contacts.UI.Contacts.update(id); Contacts.UI.Contacts.update(id);
}); });

View File

@ -41,11 +41,18 @@ class OC_Contacts_Addressbook{
/** /**
* @brief Returns the list of addressbooks for a specific user. * @brief Returns the list of addressbooks for a specific user.
* @param string $uid * @param string $uid
* @return array * @return array or false.
*/ */
public static function all($uid){ public static function all($uid){
try {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ? ORDER BY displayname' ); $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ? ORDER BY displayname' );
$result = $stmt->execute(array($uid)); $result = $stmt->execute(array($uid));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG);
return false;
}
$addressbooks = array(); $addressbooks = array();
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
@ -68,15 +75,36 @@ class OC_Contacts_Addressbook{
/** /**
* @brief Gets the data of one address book * @brief Gets the data of one address book
* @param integer $id * @param integer $id
* @return associative array * @return associative array or false.
*/ */
public static function find($id){ public static function find($id){
try {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
$result = $stmt->execute(array($id)); $result = $stmt->execute(array($id));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG);
return false;
}
return $result->fetchRow(); return $result->fetchRow();
} }
/**
* @brief Adds default address book
* @return $id ID of the newly created addressbook or false on error.
*/
public static function addDefault($uid = null){
if(is_null($uid)) {
$uid = OCP\USER::getUser();
}
$id = self::add($uid,'default','Default Address Book');
if($id !== false) {
self::setActive($id, true);
}
return $id;
}
/** /**
* @brief Creates a new address book * @brief Creates a new address book
* @param string $userid * @param string $userid
@ -84,17 +112,22 @@ class OC_Contacts_Addressbook{
* @param string $description * @param string $description
* @return insertid * @return insertid
*/ */
public static function add($userid,$name,$description=''){ public static function add($uid,$name,$description=''){
$all = self::all($userid); $all = self::all($uid);
$uris = array(); $uris = array();
foreach($all as $i){ foreach($all as $i){
$uris[] = $i['uri']; $uris[] = $i['uri'];
} }
$uri = self::createURI($name, $uris ); $uri = self::createURI($name, $uris );
try {
$stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' ); $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,$description,1)); $result = $stmt->execute(array($uid,$name,$uri,$description,1));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG);
return false;
}
return OCP\DB::insertid('*PREFIX*contacts_addressbooks'); return OCP\DB::insertid('*PREFIX*contacts_addressbooks');
} }
@ -105,13 +138,20 @@ class OC_Contacts_Addressbook{
* @param string $uri * @param string $uri
* @param string $name * @param string $name
* @param string $description * @param string $description
* @return insertid * @return insertid or false
*/ */
public static function addFromDAVData($principaluri,$uri,$name,$description){ public static function addFromDAVData($principaluri,$uri,$name,$description){
$userid = self::extractUserID($principaluri); $uid = self::extractUserID($principaluri);
try {
$stmt = OCP\DB::prepare('INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)'); $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)');
$result = $stmt->execute(array($userid,$name,$uri,$description,1)); $result = $stmt->execute(array($uid,$name,$uri,$description,1));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uri: '.$uri,OCP\Util::DEBUG);
return false;
}
return OCP\DB::insertid('*PREFIX*contacts_addressbooks'); return OCP\DB::insertid('*PREFIX*contacts_addressbooks');
} }
@ -134,8 +174,14 @@ class OC_Contacts_Addressbook{
$description = $addressbook['description']; $description = $addressbook['description'];
} }
try {
$stmt = OCP\DB::prepare('UPDATE *PREFIX*contacts_addressbooks SET displayname=?,description=?, ctag=ctag+1 WHERE id=?'); $stmt = OCP\DB::prepare('UPDATE *PREFIX*contacts_addressbooks SET displayname=?,description=?, ctag=ctag+1 WHERE id=?');
$result = $stmt->execute(array($name,$description,$id)); $result = $stmt->execute(array($name,$description,$id));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG);
return false;
}
return true; return true;
} }
@ -172,8 +218,7 @@ class OC_Contacts_Addressbook{
if(!$prefbooks){ if(!$prefbooks){
$addressbooks = OC_Contacts_Addressbook::all($uid); $addressbooks = OC_Contacts_Addressbook::all($uid);
if(count($addressbooks) == 0){ if(count($addressbooks) == 0){
$id = OC_Contacts_Addressbook::add($uid,'default','Default Address Book'); self::addDefault($uid);
self::setActive($id, true);
} }
} }
$prefbooks = OCP\Config::getUserValue($uid,'contacts','openaddressbooks',null); $prefbooks = OCP\Config::getUserValue($uid,'contacts','openaddressbooks',null);
@ -186,6 +231,9 @@ class OC_Contacts_Addressbook{
* @return array * @return array
*/ */
public static function active($uid){ public static function active($uid){
if(is_null($uid)){
$uid = OCP\USER::getUser();
}
$active = self::activeIds($uid); $active = self::activeIds($uid);
$addressbooks = array(); $addressbooks = array();
$ids_sql = join(',', array_fill(0, count($active), '?')); $ids_sql = join(',', array_fill(0, count($active), '?'));
@ -194,15 +242,18 @@ class OC_Contacts_Addressbook{
$stmt = OCP\DB::prepare( $prep ); $stmt = OCP\DB::prepare( $prep );
$result = $stmt->execute($active); $result = $stmt->execute($active);
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OCP\Util::ERROR); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG);
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $active),OCP\Util::DEBUG);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', SQL:'.$prep,OCP\Util::DEBUG);
} }
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
$addressbooks[] = $row; $addressbooks[] = $row;
} }
if(!count($addressbooks)) {
self::addDefault($uid);
}
return $addressbooks; return $addressbooks;
} }
@ -260,7 +311,7 @@ class OC_Contacts_Addressbook{
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
$stmt->execute(array($id)); $stmt->execute(array($id));
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:delete:, exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR);
return false; return false;
} }

View File

@ -10,7 +10,6 @@
* This class manages our app actions * This class manages our app actions
*/ */
OC_Contacts_App::$l10n = OC_L10N::get('contacts'); OC_Contacts_App::$l10n = OC_L10N::get('contacts');
OC_Contacts_App::$categories = new OC_VCategories('contacts');
class OC_Contacts_App { class OC_Contacts_App {
/* /*
* @brief language object for calendar app * @brief language object for calendar app
@ -137,28 +136,52 @@ class OC_Contacts_App {
} }
} }
/* /**
* @brief returns the vcategories object of the user * @brief returns the vcategories object of the user
* @return (object) $vcategories * @return (object) $vcategories
*/ */
protected static function getVCategories() { protected static function getVCategories() {
if (is_null(self::$categories)) { if (is_null(self::$categories)) {
self::$categories = new OC_VCategories('contacts'); self::$categories = new OC_VCategories('contacts', null, self::getDefaultCategories());
} }
return self::$categories; return self::$categories;
} }
/* /**
* @brief returns the categories for the user * @brief returns the categories for the user
* @return (Array) $categories * @return (Array) $categories
*/ */
public static function getCategories() { public static function getCategories() {
$categories = self::$categories->categories(); $categories = self::getVCategories()->categories();
if(count($categories) == 0) { if(count($categories) == 0) {
self::scanCategories(); self::scanCategories();
$categories = self::$categories->categories(); $categories = self::$categories->categories();
} }
return $categories; return ($categories ? $categories : self::getDefaultCategories());
}
/**
* @brief returns the default categories of ownCloud
* @return (array) $categories
*/
protected static function getDefaultCategories(){
return array(
(string)self::$l10n->t('Birthday'),
(string)self::$l10n->t('Business'),
(string)self::$l10n->t('Call'),
(string)self::$l10n->t('Clients'),
(string)self::$l10n->t('Deliverer'),
(string)self::$l10n->t('Holidays'),
(string)self::$l10n->t('Ideas'),
(string)self::$l10n->t('Journey'),
(string)self::$l10n->t('Jubilee'),
(string)self::$l10n->t('Meeting'),
(string)self::$l10n->t('Other'),
(string)self::$l10n->t('Personal'),
(string)self::$l10n->t('Projects'),
(string)self::$l10n->t('Questions'),
(string)self::$l10n->t('Work'),
);
} }
/** /**

View File

@ -33,6 +33,16 @@
* This class contains all hooks. * This class contains all hooks.
*/ */
class OC_Contacts_Hooks{ class OC_Contacts_Hooks{
/**
* @brief Add default Addressbooks of a certain user
* @param paramters parameters from postDeleteUser-Hook
* @return array
*/
static public function createUser($parameters) {
OC_Contacts_Addressbook::addDefault($parameters['uid'],'default','Default Address Book');
return true;
}
/** /**
* @brief Deletes all Addressbooks of a certain user * @brief Deletes all Addressbooks of a certain user
* @param paramters parameters from postDeleteUser-Hook * @param paramters parameters from postDeleteUser-Hook

View File

@ -42,32 +42,37 @@ class OC_Contacts_VCard{
/** /**
* @brief Returns all cards of an address book * @brief Returns all cards of an address book
* @param integer $id * @param integer $id
* @return array * @return array|false
* *
* The cards are associative arrays. You'll find the original vCard in * The cards are associative arrays. You'll find the original vCard in
* ['carddata'] * ['carddata']
*/ */
public static function all($id){ public static function all($id){
$result = null; $result = null;
if(is_array($id)) { if(is_array($id) && count($id)) {
$id_sql = join(',', array_fill(0, count($id), '?')); $id_sql = join(',', array_fill(0, count($id), '?'));
$prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname'; $prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname';
try { try {
$stmt = OCP\DB::prepare( $prep ); $stmt = OCP\DB::prepare( $prep );
$result = $stmt->execute($id); $result = $stmt->execute($id);
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::ERROR); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $id),OCP\Util::DEBUG);
OCP\Util::writeLog('contacts','SQL:'.$prep,OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'SQL:'.$prep,OCP\Util::DEBUG);
return false;
} }
} elseif($id) { } elseif(is_int($id) || is_string($id)) {
try { try {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' ); $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
$result = $stmt->execute(array($id)); $result = $stmt->execute(array($id));
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts','OC_Contacts_VCard:all, ids: '. $id,OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '. $id,OCP\Util::DEBUG);
return false;
} }
} else {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id,OCP\Util::DEBUG);
return false;
} }
$cards = array(); $cards = array();
if(!is_null($result)) { if(!is_null($result)) {
@ -82,11 +87,17 @@ class OC_Contacts_VCard{
/** /**
* @brief Returns a card * @brief Returns a card
* @param integer $id * @param integer $id
* @return associative array * @return associative array or false.
*/ */
public static function find($id){ public static function find($id){
try {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' ); $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' );
$result = $stmt->execute(array($id)); $result = $stmt->execute(array($id));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '. $id,OCP\Util::DEBUG);
return false;
}
return $result->fetchRow(); return $result->fetchRow();
} }
@ -95,11 +106,17 @@ class OC_Contacts_VCard{
* @brief finds a card by its DAV Data * @brief finds a card by its DAV Data
* @param integer $aid Addressbook id * @param integer $aid Addressbook id
* @param string $uri the uri ('filename') * @param string $uri the uri ('filename')
* @return associative array * @return associative array or false.
*/ */
public static function findWhereDAVDataIs($aid,$uri){ public static function findWhereDAVDataIs($aid,$uri){
try {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' ); $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' );
$result = $stmt->execute(array($aid,$uri)); $result = $stmt->execute(array($aid,$uri));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG);
return false;
}
return $result->fetchRow(); return $result->fetchRow();
} }
@ -149,7 +166,13 @@ class OC_Contacts_VCard{
protected static function trueUID($aid, &$uid) { protected static function trueUID($aid, &$uid) {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' ); $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' );
$uri = $uid.'.vcf'; $uri = $uid.'.vcf';
try {
$result = $stmt->execute(array($aid,$uri)); $result = $stmt->execute(array($aid,$uri));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG);
return false;
}
if($result->numRows() > 0){ if($result->numRows() > 0){
while(true) { while(true) {
$tmpuid = substr(md5(rand().time()),0,10); $tmpuid = substr(md5(rand().time()),0,10);
@ -254,7 +277,7 @@ class OC_Contacts_VCard{
* @param integer $aid Addressbook id * @param integer $aid Addressbook id
* @param OC_VObject $card vCard file * @param OC_VObject $card vCard file
* @param string $uri the uri of the card, default based on the UID * @param string $uri the uri of the card, default based on the UID
* @return insertid on success or null if no card. * @return insertid on success or false.
*/ */
public static function add($aid, OC_VObject $card, $uri=null, $isnew=false){ public static function add($aid, OC_VObject $card, $uri=null, $isnew=false){
if(is_null($card)){ if(is_null($card)){
@ -289,7 +312,13 @@ class OC_Contacts_VCard{
$data = $card->serialize(); $data = $card->serialize();
$stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' ); $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
try {
$result = $stmt->execute(array($aid,$fn,$data,$uri,time())); $result = $stmt->execute(array($aid,$fn,$data,$uri,time()));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG);
return false;
}
$newid = OCP\DB::insertid('*PREFIX*contacts_cards'); $newid = OCP\DB::insertid('*PREFIX*contacts_cards');
OC_Contacts_Addressbook::touch($aid); OC_Contacts_Addressbook::touch($aid);
@ -325,8 +354,8 @@ class OC_Contacts_VCard{
$result = $stmt->execute(array($data,time(),$object[0])); $result = $stmt->execute(array($data,time(),$object[0]));
//OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG); //OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG);
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID:, exception: '.$e->getMessage(),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0],OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$object[0],OCP\Util::DEBUG);
} }
} }
} }
@ -357,7 +386,13 @@ class OC_Contacts_VCard{
$data = $card->serialize(); $data = $card->serialize();
$stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' ); $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
try {
$result = $stmt->execute(array($fn,$data,time(),$id)); $result = $stmt->execute(array($fn,$data,time(),$id));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG);
return false;
}
OC_Contacts_Addressbook::touch($oldcard['addressbookid']); OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
OC_Hook::emit('OC_Contacts_VCard', 'post_updateVCard', $id); OC_Hook::emit('OC_Contacts_VCard', 'post_updateVCard', $id);
@ -390,7 +425,13 @@ class OC_Contacts_VCard{
// FIXME: Add error checking. // FIXME: Add error checking.
OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => null, 'id' => $id, 'uri' => null)); OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => null, 'id' => $id, 'uri' => null));
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
try {
$stmt->execute(array($id)); $stmt->execute(array($id));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG);
return false;
}
return true; return true;
} }
@ -403,9 +444,15 @@ class OC_Contacts_VCard{
*/ */
public static function deleteFromDAVData($aid,$uri){ public static function deleteFromDAVData($aid,$uri){
// FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error. // FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error.
OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => $aid, 'id' => null, 'uri' => $uid)); OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => $aid, 'id' => null, 'uri' => $uri));
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
try {
$stmt->execute(array($aid,$uri)); $stmt->execute(array($aid,$uri));
} catch(Exception $e) {
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG);
return false;
}
OC_Contacts_Addressbook::touch($aid); OC_Contacts_Addressbook::touch($aid);
return true; return true;
@ -546,9 +593,9 @@ class OC_Contacts_VCard{
$vals = array_merge((array)$aid, $id); $vals = array_merge((array)$aid, $id);
$result = $stmt->execute($vals); $result = $stmt->execute($vals);
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook, ids: '.join(',', $vals),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals),OCP\Util::DEBUG);
OCP\Util::writeLog('contacts','SQL:'.$prep,OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', SQL:'.$prep,OCP\Util::DEBUG);
return false; return false;
} }
} else { } else {
@ -556,8 +603,8 @@ class OC_Contacts_VCard{
$stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' ); $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' );
$result = $stmt->execute(array($aid, $id)); $result = $stmt->execute(array($aid, $id));
} catch(Exception $e) { } catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::DEBUG);
OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook, id: '.$id,OCP\Util::DEBUG); OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' id: '.$id,OCP\Util::DEBUG);
return false; return false;
} }
} }

View File

@ -41,7 +41,11 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
return $this->metaData[$path]; return $this->metaData[$path];
} else { } else {
if ($list) { if ($list) {
try {
$response = $this->dropbox->getMetaData($path); $response = $this->dropbox->getMetaData($path);
} catch (Exception $exception) {
return false;
}
if ($response && isset($response['contents'])) { if ($response && isset($response['contents'])) {
$contents = $response['contents']; $contents = $response['contents'];
// Cache folder's contents // Cache folder's contents
@ -90,7 +94,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
if ($metaData = $this->getMetaData($path)) { if ($metaData = $this->getMetaData($path)) {
$stat['size'] = $metaData['bytes']; $stat['size'] = $metaData['bytes'];
$stat['atime'] = time(); $stat['atime'] = time();
$stat['mtime'] = strtotime($metaData['modified']); $stat['mtime'] = (isset($metaData['modified'])) ? strtotime($metaData['modified']) : time();
$stat['ctime'] = $stat['mtime']; $stat['ctime'] = $stat['mtime'];
return $stat; return $stat;
} }
@ -111,11 +115,11 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
} }
public function is_readable($path) { public function is_readable($path) {
return true; return self::file_exists($path);
} }
public function is_writable($path) { public function is_writable($path) {
return true; return self::file_exists($path);
} }
public function file_exists($path) { public function file_exists($path) {

View File

@ -67,7 +67,7 @@ function setSyntaxMode(ext){
function showControls(filename,writeperms){ function showControls(filename,writeperms){
// Loads the control bar at the top. // Loads the control bar at the top.
// Load the new toolbar. // Load the new toolbar.
var editorbarhtml = '<div id="editorcontrols" style="display: none;"><div class="crumb svg last" id="breadcrumb_file" style="background-image:url(&quot;'+OC.imagePath('core','breadcrumb.png')+'&quot;)"><p>'+filename+'</p></div>'; var editorbarhtml = '<div id="editorcontrols" style="display: none;"><div class="crumb svg last" id="breadcrumb_file" style="background-image:url(&quot;'+OC.imagePath('core','breadcrumb.png')+'&quot;)"><p>'+filename.replace(/</, "&lt;").replace(/>/, "&gt;")+'</p></div>';
if(writeperms=="true"){ if(writeperms=="true"){
editorbarhtml += '<button id="editor_save">'+t('files_texteditor','Save')+'</button><div class="separator"></div>'; editorbarhtml += '<button id="editor_save">'+t('files_texteditor','Save')+'</button><div class="separator"></div>';
} }

View File

@ -61,7 +61,6 @@ class OC_MEDIA_SCANNER{
* @return boolean * @return boolean
*/ */
public static function scanFile($path){ public static function scanFile($path){
$file=OC_Filesystem::getLocalFile($path);
if(!self::isMusic($path)){ if(!self::isMusic($path)){
return; return;
} }
@ -69,6 +68,7 @@ class OC_MEDIA_SCANNER{
self::$getID3=@new getID3(); self::$getID3=@new getID3();
self::$getID3->encoding='UTF-8'; self::$getID3->encoding='UTF-8';
} }
$file=OC_Filesystem::getLocalFile($path);
$data=@self::$getID3->analyze($file); $data=@self::$getID3->analyze($file);
getid3_lib::CopyTagsToComments($data); getid3_lib::CopyTagsToComments($data);
if(!isset($data['comments'])){ if(!isset($data['comments'])){

View File

@ -84,6 +84,7 @@ class OC_App{
*/ */
public static function loadApp($app){ public static function loadApp($app){
if(is_file(self::getAppPath($app).'/appinfo/app.php')){ if(is_file(self::getAppPath($app).'/appinfo/app.php')){
self::checkUpgrade($app);
require_once( $app.'/appinfo/app.php' ); require_once( $app.'/appinfo/app.php' );
} }
} }
@ -526,17 +527,13 @@ class OC_App{
} }
/** /**
* check if any apps need updating and update those * check if the app need updating and update when needed
*/ */
public static function updateApps(){ public static function checkUpgrade($app) {
$versions = self::getAppVersions(); $versions = self::getAppVersions();
//ensure files app is installed for upgrades
if(!isset($versions['files'])){
$versions['files']='0';
}
foreach( $versions as $app=>$installedVersion ){
$currentVersion=OC_App::getAppVersion($app); $currentVersion=OC_App::getAppVersion($app);
if ($currentVersion) { if ($currentVersion) {
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) { if (version_compare($currentVersion, $installedVersion, '>')) {
OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion,OC_Log::DEBUG); OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion,OC_Log::DEBUG);
OC_App::updateApp($app); OC_App::updateApp($app);
@ -544,7 +541,6 @@ class OC_App{
} }
} }
} }
}
/** /**
* check if the current enabled apps are compatible with the current * check if the current enabled apps are compatible with the current
@ -571,6 +567,10 @@ class OC_App{
* get the installed version of all papps * get the installed version of all papps
*/ */
public static function getAppVersions(){ public static function getAppVersions(){
static $versions;
if (isset($versions)) { // simple cache, needs to be fixed
return $versions; // when function is used besides in checkUpgrade
}
$versions=array(); $versions=array();
$query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = \'installed_version\'' ); $query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = \'installed_version\'' );
$result = $query->execute(); $result = $query->execute();

View File

@ -170,8 +170,10 @@ class OC{
public static function checkInstalled() { public static function checkInstalled() {
// Redirect to installer if not installed // Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') { if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
if(!OC::$CLI){
$url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php'; $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
header("Location: $url"); header("Location: $url");
}
exit(); exit();
} }
} }
@ -180,7 +182,7 @@ class OC{
// redirect to https site if configured // redirect to https site if configured
if( OC_Config::getValue( "forcessl", false )){ if( OC_Config::getValue( "forcessl", false )){
ini_set("session.cookie_secure", "on"); ini_set("session.cookie_secure", "on");
if(OC_Helper::serverProtocol()<>'https') { if(OC_Helper::serverProtocol()<>'https' and !OC::$CLI) {
$url = "https://". OC_Helper::serverHost() . $_SERVER['REQUEST_URI']; $url = "https://". OC_Helper::serverHost() . $_SERVER['REQUEST_URI'];
header("Location: $url"); header("Location: $url");
exit(); exit();
@ -208,9 +210,9 @@ class OC{
OC_Config::setValue('version',implode('.',OC_Util::getVersion())); OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
OC_App::checkAppsRequirements(); OC_App::checkAppsRequirements();
// load all apps to also upgrade enabled apps
OC_App::loadApps();
} }
OC_App::updateApps();
} }
} }

View File

@ -90,17 +90,19 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
foreach($folder_content as $info) { foreach($folder_content as $info) {
$paths[] = $this->path.'/'.$info['name']; $paths[] = $this->path.'/'.$info['name'];
} }
$properties = array_fill_keys($paths, array());
if(count($paths)>0){
$placeholders = join(',', array_fill(0, count($paths), '?')); $placeholders = join(',', array_fill(0, count($paths), '?'));
$query = OC_DB::prepare( 'SELECT * FROM *PREFIX*properties WHERE userid = ?' . ' AND propertypath IN ('.$placeholders.')' ); $query = OC_DB::prepare( 'SELECT * FROM *PREFIX*properties WHERE userid = ?' . ' AND propertypath IN ('.$placeholders.')' );
array_unshift($paths, OC_User::getUser()); // prepend userid array_unshift($paths, OC_User::getUser()); // prepend userid
$result = $query->execute( $paths ); $result = $query->execute( $paths );
$properties = array_fill_keys($paths, array());
while($row = $result->fetchRow()) { while($row = $result->fetchRow()) {
$propertypath = $row['propertypath']; $propertypath = $row['propertypath'];
$propertyname = $row['propertyname']; $propertyname = $row['propertyname'];
$propertyvalue = $row['propertyvalue']; $propertyvalue = $row['propertyvalue'];
$properties[$propertypath][$propertyname] = $propertyvalue; $properties[$propertypath][$propertyname] = $propertyvalue;
} }
}
$nodes = array(); $nodes = array();
foreach($folder_content as $info) { foreach($folder_content as $info) {

View File

@ -75,6 +75,9 @@ class OC_Helper {
* reverse proxies * reverse proxies
*/ */
public static function serverHost() { public static function serverHost() {
if(OC::$CLI){
return 'localhost';
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) { if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) {
$host = trim(array_pop(explode(",", $_SERVER['HTTP_X_FORWARDED_HOST']))); $host = trim(array_pop(explode(",", $_SERVER['HTTP_X_FORWARDED_HOST'])));

View File

@ -55,7 +55,7 @@ class OC_VCategories {
$this->app = $app; $this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user; $this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, '')); $categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
$this->categories = $categories != '' ? unserialize($categories) : $defcategories; $this->categories = $categories != '' ? @unserialize($categories) : $defcategories;
} }
/** /**
@ -64,6 +64,9 @@ class OC_VCategories {
*/ */
public function categories() { public function categories() {
//OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG); //OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG);
if(!$this->categories) {
return array();
}
usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys
return $this->categories; return $this->categories;
} }
@ -203,11 +206,17 @@ class OC_VCategories {
// case-insensitive in_array // case-insensitive in_array
private function in_arrayi($needle, $haystack) { private function in_arrayi($needle, $haystack) {
if(!is_array($haystack)) {
return false;
}
return in_array(strtolower($needle), array_map('strtolower', $haystack)); return in_array(strtolower($needle), array_map('strtolower', $haystack));
} }
// case-insensitive array_search // case-insensitive array_search
private function array_searchi($needle, $haystack) { private function array_searchi($needle, $haystack) {
if(!is_array($haystack)) {
return false;
}
return array_search(strtolower($needle),array_map('strtolower',$haystack)); return array_search(strtolower($needle),array_map('strtolower',$haystack));
} }

View File

@ -10,6 +10,7 @@ if(is_null($file)){
$parts=explode('/',$file,2); $parts=explode('/',$file,2);
$app=$parts[0]; $app=$parts[0];
OC_Util::checkAppEnabled($app);
OC_App::loadApp($app); OC_App::loadApp($app);
require_once(OC_App::getAppPath($app) .'/'. $parts[1]); require_once(OC_App::getAppPath($app) .'/'. $parts[1]);

View File

@ -27,13 +27,24 @@ $file = ltrim ($file, '/');
if(count(explode('/',$file)) == 2) { if(count(explode('/',$file)) == 2) {
$parts=explode('/',$file); $parts=explode('/',$file);
$app=$parts[1]; $app=$parts[0];
switch ($app) {
case 'files':
OC_Util::checkAppEnabled($app);
OC_App::loadApp($app); OC_App::loadApp($app);
break;
case 'core':
break;
default:
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
exit;
}
$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
require_once( OC::$SERVERROOT.'/'.$file); require_once( OC::$SERVERROOT.'/'.$file);
} else { } else {
$parts=explode('/', $file, 2); $parts=explode('/', $file, 2);
$app=$parts[0]; $app=$parts[0];
OC_Util::checkAppEnabled($app);
OC_App::loadApp($app); OC_App::loadApp($app);
$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
require_once(OC_App::getAppPath($app) .'/'. $parts[1]); require_once(OC_App::getAppPath($app) .'/'. $parts[1]);