From 45de7ad221f9e505abdabcc5084dd12c80851469 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 18 Apr 2012 17:27:34 +0200 Subject: move files to app folder --- apps/files/ajax/autocomplete.php | 56 +++++++++++++++++++++++++++++++++++ apps/files/ajax/delete.php | 29 ++++++++++++++++++ apps/files/ajax/download.php | 37 +++++++++++++++++++++++ apps/files/ajax/list.php | 46 +++++++++++++++++++++++++++++ apps/files/ajax/mimeicon.php | 11 +++++++ apps/files/ajax/move.php | 20 +++++++++++++ apps/files/ajax/newfile.php | 47 +++++++++++++++++++++++++++++ apps/files/ajax/newfolder.php | 22 ++++++++++++++ apps/files/ajax/rawlist.php | 26 ++++++++++++++++ apps/files/ajax/rename.php | 21 +++++++++++++ apps/files/ajax/scan.php | 38 ++++++++++++++++++++++++ apps/files/ajax/timezone.php | 6 ++++ apps/files/ajax/upload.php | 64 ++++++++++++++++++++++++++++++++++++++++ 13 files changed, 423 insertions(+) create mode 100644 apps/files/ajax/autocomplete.php create mode 100644 apps/files/ajax/delete.php create mode 100644 apps/files/ajax/download.php create mode 100644 apps/files/ajax/list.php create mode 100644 apps/files/ajax/mimeicon.php create mode 100644 apps/files/ajax/move.php create mode 100644 apps/files/ajax/newfile.php create mode 100644 apps/files/ajax/newfolder.php create mode 100644 apps/files/ajax/rawlist.php create mode 100644 apps/files/ajax/rename.php create mode 100644 apps/files/ajax/scan.php create mode 100644 apps/files/ajax/timezone.php create mode 100644 apps/files/ajax/upload.php (limited to 'apps/files/ajax') diff --git a/apps/files/ajax/autocomplete.php b/apps/files/ajax/autocomplete.php new file mode 100644 index 00000000000..8cdb6188a02 --- /dev/null +++ b/apps/files/ajax/autocomplete.php @@ -0,0 +1,56 @@ +$item,'label'=>$item,'name'=>$item); + } + } + } + } + } +} +OC_JSON::encodedPrint($files); + +?> diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php new file mode 100644 index 00000000000..d8a01d7acf1 --- /dev/null +++ b/apps/files/ajax/delete.php @@ -0,0 +1,29 @@ + array( "dir" => $dir, "files" => $files ))); +} else { + OC_JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError ))); +} + +?> diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php new file mode 100644 index 00000000000..65c04c36faf --- /dev/null +++ b/apps/files/ajax/download.php @@ -0,0 +1,37 @@ +. +* +*/ + +// only need filesystem apps +$RUNTIME_APPTYPES=array('filesystem'); + +// Init owncloud + + +// Check if we are a user +OC_Util::checkLoggedIn(); + +$files = $_GET["files"]; +$dir = $_GET["dir"]; + +OC_Files::get($dir,$files); +?> diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php new file mode 100644 index 00000000000..83914332a7d --- /dev/null +++ b/apps/files/ajax/list.php @@ -0,0 +1,46 @@ + $pathtohere, "name" => $i ); + } + } + + $breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" ); + $breadcrumbNav->assign( "breadcrumb", $breadcrumb ); + + $data['breadcrumb'] = $breadcrumbNav->fetchPage(); +} + +// make filelist +$files = array(); +foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ + $i["date"] = OC_Util::formatDate($i["mtime"] ); + $files[] = $i; +} + +$list = new OC_Template( "files", "part.list", "" ); +$list->assign( "files", $files ); +$data = array('files' => $list->fetchPage()); + +OC_JSON::success(array('data' => $data)); + +?> diff --git a/apps/files/ajax/mimeicon.php b/apps/files/ajax/mimeicon.php new file mode 100644 index 00000000000..57898cd82d9 --- /dev/null +++ b/apps/files/ajax/mimeicon.php @@ -0,0 +1,11 @@ + diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php new file mode 100644 index 00000000000..0ad314f873c --- /dev/null +++ b/apps/files/ajax/move.php @@ -0,0 +1,20 @@ + array( "dir" => $dir, "files" => $file ))); +}else{ + OC_JSON::error(array("data" => array( "message" => "Could not move $file" ))); +} + +?> diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php new file mode 100644 index 00000000000..472b577a32a --- /dev/null +++ b/apps/files/ajax/newfile.php @@ -0,0 +1,47 @@ + array( "message" => "Empty Filename" ))); + exit(); +} + +if($source){ + if(substr($source,0,8)!='https://' and substr($source,0,7)!='http://'){ + OC_JSON::error(array("data" => array( "message" => "Not a valid source" ))); + exit(); + } + $sourceStream=fopen($source,'rb'); + $target=$dir.'/'.$filename; + $result=OC_Filesystem::file_put_contents($target,$sourceStream); + if($result){ + $mime=OC_Filesystem::getMimetype($target); + OC_JSON::success(array("data" => array('mime'=>$mime))); + exit(); + }else{ + OC_JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target ))); + exit(); + } +} + + +if(OC_Files::newFile($dir, $filename, 'file')) { + if($content){ + OC_Filesystem::file_put_contents($dir.'/'.$filename,$content); + } + OC_JSON::success(array("data" => array('content'=>$content))); + exit(); +} + + +OC_JSON::error(array("data" => array( "message" => "Error when creating the file" ))); diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php new file mode 100644 index 00000000000..2aff95e5b35 --- /dev/null +++ b/apps/files/ajax/newfolder.php @@ -0,0 +1,22 @@ + array( "message" => "Empty Foldername" ))); + exit(); +} + +if(OC_Files::newFile($dir, stripslashes($foldername), 'dir')) { + OC_JSON::success(array("data" => array())); + exit(); +} + +OC_JSON::error(array("data" => array( "message" => "Error when creating the folder" ))); diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php new file mode 100644 index 00000000000..8f1990d1b8f --- /dev/null +++ b/apps/files/ajax/rawlist.php @@ -0,0 +1,26 @@ + $files)); + +?> diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php new file mode 100644 index 00000000000..dc5d3962abd --- /dev/null +++ b/apps/files/ajax/rename.php @@ -0,0 +1,21 @@ + array( "dir" => $dir, "file" => $file, "newname" => $newname ))); +} +else{ + OC_JSON::error(array("data" => array( "message" => "Unable to rename file" ))); +} + +?> diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php new file mode 100644 index 00000000000..db09b7d5c64 --- /dev/null +++ b/apps/files/ajax/scan.php @@ -0,0 +1,38 @@ +send('success',true); + }else{ + OC_JSON::success(array('data'=>array('done'=>true))); + exit; + } +}else{ + if($checkOnly){ + OC_JSON::success(array('data'=>array('done'=>false))); + exit; + } + if(isset($eventSource)){ + $eventSource->send('success',false); + }else{ + exit; + } +} +$eventSource->close(); \ No newline at end of file diff --git a/apps/files/ajax/timezone.php b/apps/files/ajax/timezone.php new file mode 100644 index 00000000000..8e1d2aa1ec1 --- /dev/null +++ b/apps/files/ajax/timezone.php @@ -0,0 +1,6 @@ + diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php new file mode 100644 index 00000000000..c60e1a3752a --- /dev/null +++ b/apps/files/ajax/upload.php @@ -0,0 +1,64 @@ + array( "message" => "No file was uploaded. Unknown error" ))); + exit(); +} +foreach ($_FILES['files']['error'] as $error) { + if ($error != 0) { + $l=OC_L10N::get('files'); + $errors = array( + UPLOAD_ERR_OK=>$l->t("There is no error, the file uploaded with success"), + UPLOAD_ERR_INI_SIZE=>$l->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), + UPLOAD_ERR_FORM_SIZE=>$l->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), + UPLOAD_ERR_PARTIAL=>$l->t("The uploaded file was only partially uploaded"), + UPLOAD_ERR_NO_FILE=>$l->t("No file was uploaded"), + UPLOAD_ERR_NO_TMP_DIR=>$l->t("Missing a temporary folder"), + UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'), + ); + OC_JSON::error(array("data" => array( "message" => $errors[$error] ))); + exit(); + } +} +$files=$_FILES['files']; + +$dir = $_POST['dir']; +$dir .= '/'; +$error=''; + +$totalSize=0; +foreach($files['size'] as $size){ + $totalSize+=$size; +} +if($totalSize>OC_Filesystem::free_space('/')){ + OC_JSON::error(array("data" => array( "message" => "Not enough space available" ))); + exit(); +} + +$result=array(); +if(strpos($dir,'..') === false){ + $fileCount=count($files['name']); + for($i=0;$i<$fileCount;$i++){ + $target = OC_Helper::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); + if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){ + $meta=OC_FileCache::getCached($target); + $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target)); + } + } + OC_JSON::encodedPrint($result); + exit(); +}else{ + $error='invalid dir'; +} + +OC_JSON::error(array('data' => array('error' => $error, "file" => $fileName))); + +?> -- cgit v1.2.3 From c3d78cf77aa18b54cb2d1c9d0e16874a0fea804e Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 20 Apr 2012 22:34:13 +0200 Subject: remove require once lib base in files scan.php --- apps/files/ajax/scan.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'apps/files/ajax') diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php index db09b7d5c64..488f68e6b3c 100644 --- a/apps/files/ajax/scan.php +++ b/apps/files/ajax/scan.php @@ -1,7 +1,5 @@ Date: Fri, 27 Apr 2012 22:47:24 +0200 Subject: fix duplicated entries on upload --- apps/files/ajax/upload.php | 1 - 1 file changed, 1 deletion(-) (limited to 'apps/files/ajax') diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index c60e1a3752a..3ac8ef59560 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -31,7 +31,6 @@ foreach ($_FILES['files']['error'] as $error) { $files=$_FILES['files']; $dir = $_POST['dir']; -$dir .= '/'; $error=''; $totalSize=0; -- cgit v1.2.3 From 9c520c70a8df5057ab20db8282e8fb63520bde88 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 30 Apr 2012 01:48:01 +0200 Subject: Various file path fixes. --- apps/contacts/ajax/currentphoto.php | 2 +- apps/contacts/ajax/oc_photo.php | 8 ++++---- apps/contacts/js/contacts.js | 3 +++ apps/contacts/templates/part.contact.php | 2 +- apps/contacts/templates/part.importaddressbook.php | 2 +- apps/files/ajax/rawlist.php | 2 +- core/js/oc-dialogs.js | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) (limited to 'apps/files/ajax') diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php index 15cb6c7a083..171f5c34785 100644 --- a/apps/contacts/ajax/currentphoto.php +++ b/apps/contacts/ajax/currentphoto.php @@ -20,7 +20,7 @@ * */ // Init owncloud -require_once('../../../lib/base.php'); +//require_once('../../../lib/base.php'); // Check if we are a user // Firefox and Konqueror tries to download application/json for me. --Arthur diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php index 14d77ea50b7..e46441c4821 100644 --- a/apps/contacts/ajax/oc_photo.php +++ b/apps/contacts/ajax/oc_photo.php @@ -20,7 +20,7 @@ * */ // Init owncloud -require_once('../../../lib/base.php'); +require_once('lib/base.php'); // Check if we are a user // Firefox and Konqueror tries to download application/json for me. --Arthur @@ -36,11 +36,11 @@ function debug($msg) { OC_Log::write('contacts','ajax/oc_photo.php: '.$msg, OC_Log::DEBUG); } -if (!isset($_GET['id'])) { +if(!isset($_GET['id'])) { bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); } -if (!isset($_GET['path'])) { +if(!isset($_GET['path'])) { bailOut(OC_Contacts_App::$l10n->t('No photo path was submitted.')); } @@ -66,7 +66,7 @@ if(!$image->fixOrientation()) { // No fatal error so we don't bail out. debug('Couldn\'t save correct image orientation: '.$tmpfname); } if($image->save($tmpfname)) { - OC_JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpfname))); + OC_JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpfname))); exit(); } else { bailOut('Couldn\'t save temporary image: '.$tmpfname); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 7333b0e8d42..ba8e08fd875 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1066,6 +1066,9 @@ Contacts={ }, loadPhotoHandlers:function(){ $('#phototools li a').tipsy(); + $('#phototools li a').click(function() { + $(this).tipsy('hide'); + }); $('#contacts_details_photo_wrapper').hover( function () { $('#phototools').slideDown(200); diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index a35d38e8867..bbe20143325 100644 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -23,7 +23,7 @@ $id = isset($_['id']) ? $_['id'] : '';
-
+
diff --git a/apps/contacts/templates/part.importaddressbook.php b/apps/contacts/templates/part.importaddressbook.php index 3efb90cd220..2db23368866 100644 --- a/apps/contacts/templates/part.importaddressbook.php +++ b/apps/contacts/templates/part.importaddressbook.php @@ -22,7 +22,7 @@ - + "> diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php index 8f1990d1b8f..0b37b93674f 100644 --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -5,7 +5,7 @@ $RUNTIME_APPTYPES=array('filesystem'); // Init owncloud -require_once('../../lib/template.php'); +require_once('lib/template.php'); OC_JSON::checkLoggedIn(); diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index 6a3dac02ea7..7e41c1a7a59 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -240,6 +240,6 @@ OCdialogs = { var newval = parseInt($(dcid + ' #dirtree option:last').val())+1; $(dcid + ' #dirtree').append(''); $(dcid + ' .filepicker_loader').css('visibility', 'visible'); - $.getJSON(OC.webroot+'/files/ajax/rawlist.php', {dir: p, mimetype: $(dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, dcid)}); + $.getJSON(OC.filePath('files', 'ajax', 'rawlist.php'), {dir: p, mimetype: $(dcid).data('mimetype')}, function(r){OC.dialogs.fillFilePicker(r, dcid)}); } }; -- cgit v1.2.3 From e2fb094693e94d425fa9f59278806ef636fc127b Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Tue, 1 May 2012 21:07:08 +0200 Subject: some more porting --- apps/files/ajax/list.php | 2 +- apps/files/ajax/rawlist.php | 2 +- apps/files/index.php | 2 +- apps/files_sharing/get.php | 2 +- apps/files_versions/ajax/getVersions.php | 2 +- apps/files_versions/history.php | 4 ++-- apps/files_versions/templates/history.php | 2 +- apps/user_openid/appinfo/app.php | 4 ++-- lib/public/user.php | 31 +++++++++++++++++++++++- lib/public/util.php | 39 ++++++++++++++++++++++++++++++- lib/user.php | 2 +- lib/util.php | 6 +++-- 12 files changed, 83 insertions(+), 15 deletions(-) mode change 100644 => 100755 apps/files/ajax/list.php mode change 100644 => 100755 apps/files/ajax/rawlist.php mode change 100644 => 100755 apps/files_sharing/get.php mode change 100644 => 100755 apps/files_versions/history.php mode change 100644 => 100755 apps/files_versions/templates/history.php (limited to 'apps/files/ajax') diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php old mode 100644 new mode 100755 index 83914332a7d..0bff5742ef4 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -33,7 +33,7 @@ if($doBreadcrumb){ // make filelist $files = array(); foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ - $i["date"] = OC_Util::formatDate($i["mtime"] ); + $i["date"] = OCP\Util::formatDate($i["mtime"] ); $files[] = $i; } diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php old mode 100644 new mode 100755 index 0b37b93674f..86119de2d1b --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -16,7 +16,7 @@ $mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : ''; // make filelist $files = array(); foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){ - $i["date"] = OC_Util::formatDate($i["mtime"] ); + $i["date"] = OCP\Util::formatDate($i["mtime"] ); $i['mimetype_icon'] = $i['type'] == 'dir' ? mimetype_icon('dir'): mimetype_icon($i['mimetype']); $files[] = $i; } diff --git a/apps/files/index.php b/apps/files/index.php index c1b99cfaf5a..180452593ab 100755 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -44,7 +44,7 @@ if(!OC_Filesystem::is_dir($dir.'/')) { $files = array(); foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ - $i["date"] = OC_Util::formatDate($i["mtime"] ); + $i["date"] = OCP\Util::formatDate($i["mtime"] ); if($i['type']=='file'){ $fileinfo=pathinfo($i['name']); $i['basename']=$fileinfo['filename']; diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php old mode 100644 new mode 100755 index fbcb265fc03..f6ae4bf075f --- a/apps/files_sharing/get.php +++ b/apps/files_sharing/get.php @@ -27,7 +27,7 @@ if ($source !== false) { $files = array(); $rootLength = strlen($root); foreach (OC_Files::getdirectorycontent($source) as $i) { - $i['date'] = OC_Util::formatDate($i['mtime'] ); + $i['date'] = OCP\Util::formatDate($i['mtime'] ); if ($i['type'] == 'file') { $fileinfo = pathinfo($i['name']); $i['basename'] = $fileinfo['filename']; diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 9f5b5908797..d12cf368f18 100755 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -16,7 +16,7 @@ if( OCA_Versions\Storage::isversioned( $source ) ) { foreach ( $versions AS $version ) { - $versionsFormatted[] = OC_Util::formatDate( $version ); + $versionsFormatted[] = OCP\Util::formatDate( $version ); } diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php old mode 100644 new mode 100755 index 16ad92b90da..d806638e011 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -39,13 +39,13 @@ if ( isset( $_GET['path'] ) ) { $tmpl->assign( 'outcome_stat', 'success' ); - $tmpl->assign( 'outcome_msg', "File {$_GET['path']} was reverted to version ".OC_Util::formatDate( $_GET['revert'] ) ); + $tmpl->assign( 'outcome_msg', "File {$_GET['path']} was reverted to version ".OCP\Util::formatDate( $_GET['revert'] ) ); } else { $tmpl->assign( 'outcome_stat', 'failure' ); - $tmpl->assign( 'outcome_msg', "File {$_GET['path']} could not be reverted to version ".OC_Util::formatDate( $_GET['revert'] ) ); + $tmpl->assign( 'outcome_msg', "File {$_GET['path']} could not be reverted to version ".OCP\Util::formatDate( $_GET['revert'] ) ); } diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php old mode 100644 new mode 100755 index 2ef0c89e229..3b29625b3b0 --- a/apps/files_versions/templates/history.php +++ b/apps/files_versions/templates/history.php @@ -22,7 +22,7 @@ if( isset( $_['message'] ) ) { foreach ( $_['versions'] as $v ) { echo ' '; - echo OC_Util::formatDate( $v ); + echo OCP\Util::formatDate( $v ); echo ' Revert

'; } diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 867a0a3ed33..3e26d922689 100755 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -14,8 +14,8 @@ if(strpos($_SERVER["REQUEST_URI"],'?') and !strpos($_SERVER["REQUEST_URI"],'=')) } } -OC_Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); -OC_Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); +OCP\Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); +OCP\Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName)); OC_APP::registerPersonal('user_openid','settings'); diff --git a/lib/public/user.php b/lib/public/user.php index f59fbe0b25a..febac06730f 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -53,10 +53,39 @@ class User { return \OC_USER::isLoggedIn(); } + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public static function userExists($uid){ + return \OC_USER::userExists($uid); + } -} + /** + * @brief Loggs the user out including all the session data + * @returns true + * + * Logout, destroys session + */ + public static function logout(){ + return \OC_USER::logout(); + } + + /** + * @brief Check if the password is correct + * @param $uid The username + * @param $password The password + * @returns true/false + * + * Check if the password is correct without logging in the user + */ + public static function checkPassword( $uid, $password ){ + return \OC_USER::checkPassword($uid, $password); + } +} ?> diff --git a/lib/public/util.php b/lib/public/util.php index 3e647fc6605..c4a73a5a7fc 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -39,6 +39,15 @@ class Util { const ERROR=3; const FATAL=4; + /** + * get the current installed version of ownCloud + * @return array + */ + public static function getVersion(){ + return(\OC_Util::getVersion()); + } + + /** * send an email * @@ -81,10 +90,38 @@ class Util { \OC_Util::addStyle($application, $file); } + /** + * add a javascript file + * + * @param appid $application + * @param filename $file + */ + public static function addScript( $application, $file = null ){ + \OC_Util::addScript($application, $file); + } -} + /** + * @brief Add a custom element to the header + * @param string tag tag name of the element + * @param array $attributes array of attributes for the element + * @param string $text the text content for the element + */ + public static function addHeader( $tag, $attributes, $text=''){ + \OC_Util::addHeader($tag, $attribute, $text); + } + /** + * formats a timestamp in the "right" way + * + * @param int timestamp $timestamp + * @param bool dateOnly option to ommit time from the result + */ + public static function formatDate( $timestamp,$dateOnly=false){ + return(\OC_Util::formatDate($timestamp,$dateOnly)); + } +} + ?> diff --git a/lib/user.php b/lib/user.php index 57ddb9e511b..8b887559df3 100644 --- a/lib/user.php +++ b/lib/user.php @@ -215,7 +215,7 @@ class OC_User { } /** - * @brief Kick the user + * @brief Logs the current user out and kills all the session data * @returns true * * Logout, destroys session diff --git a/lib/util.php b/lib/util.php index 5de5b8df384..d22d8710867 100644 --- a/lib/util.php +++ b/lib/util.php @@ -96,7 +96,8 @@ class OC_Util { /** * add a javascript file * - * @param url $url + * @param appid $application + * @param filename $file */ public static function addScript( $application, $file = null ){ if( is_null( $file )){ @@ -113,7 +114,8 @@ class OC_Util { /** * add a css file * - * @param url $url + * @param appid $application + * @param filename $file */ public static function addStyle( $application, $file = null ){ if( is_null( $file )){ -- cgit v1.2.3 From 31e32e3c10ace169e0d841ff6e4b17d11fe64f1b Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Tue, 1 May 2012 22:59:38 +0200 Subject: ported checkLoggedIn and checkAdmin --- apps/admin_migrate/settings.php | 2 +- apps/bookmarks/addBm.php | 2 +- apps/bookmarks/index.php | 2 +- apps/calendar/export.php | 2 +- apps/calendar/index.php | 2 +- apps/contacts/export.php | 2 +- apps/contacts/index.php | 2 +- apps/contacts/photo.php | 2 +- apps/contacts/thumbnail.php | 2 +- apps/external/ajax/setsites.php | 2 +- apps/external/index.php | 2 +- apps/external/settings.php | 2 +- apps/files/admin.php | 2 +- apps/files/ajax/download.php | 2 +- apps/files/download.php | 2 +- apps/files/index.php | 2 +- apps/files/settings.php | 2 +- apps/files_sharing/list.php | 2 +- apps/files_sharing/settings.php | 2 +- apps/files_versions/history.php | 2 +- apps/files_versions/settings.php | 2 +- apps/gallery/index.php | 2 +- apps/media/index.php | 2 +- apps/user_migrate/admin.php | 2 +- lib/public/user.php | 15 +++++++++++++++ lib/public/util.php | 9 +++++++++ 26 files changed, 48 insertions(+), 24 deletions(-) mode change 100644 => 100755 apps/admin_migrate/settings.php mode change 100644 => 100755 apps/bookmarks/addBm.php mode change 100644 => 100755 apps/calendar/export.php mode change 100644 => 100755 apps/contacts/export.php mode change 100644 => 100755 apps/external/ajax/setsites.php mode change 100644 => 100755 apps/external/index.php mode change 100644 => 100755 apps/files/admin.php mode change 100644 => 100755 apps/files/ajax/download.php mode change 100644 => 100755 apps/files/download.php (limited to 'apps/files/ajax') diff --git a/apps/admin_migrate/settings.php b/apps/admin_migrate/settings.php old mode 100644 new mode 100755 index 94bf6052a6b..da96e1a8684 --- a/apps/admin_migrate/settings.php +++ b/apps/admin_migrate/settings.php @@ -22,7 +22,7 @@ * License along with this library. If not, see . * */ -OC_Util::checkAdminUser(); +OCP\User::checkAdminUser(); OC_Util::checkAppEnabled('admin_migrate'); // Export? diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php old mode 100644 new mode 100755 index 27e01bb3baf..afe61875737 --- a/apps/bookmarks/addBm.php +++ b/apps/bookmarks/addBm.php @@ -24,7 +24,7 @@ // Check if we are a user -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('bookmarks'); require_once('bookmarksHelper.php'); diff --git a/apps/bookmarks/index.php b/apps/bookmarks/index.php index 575c14c114c..7ab74c5f3f3 100755 --- a/apps/bookmarks/index.php +++ b/apps/bookmarks/index.php @@ -24,7 +24,7 @@ // Check if we are a user -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('bookmarks'); OC_App::setActiveNavigationEntry( 'bookmarks_index' ); diff --git a/apps/calendar/export.php b/apps/calendar/export.php old mode 100644 new mode 100755 index 0972ee0f788..9b71bc6910f --- a/apps/calendar/export.php +++ b/apps/calendar/export.php @@ -7,7 +7,7 @@ */ -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); $cal = isset($_GET['calid']) ? $_GET['calid'] : NULL; $event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL; diff --git a/apps/calendar/index.php b/apps/calendar/index.php index cc6b19a0402..77550420b53 100755 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -7,7 +7,7 @@ */ -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); // Create default calendar ... diff --git a/apps/contacts/export.php b/apps/contacts/export.php old mode 100644 new mode 100755 index 95d02a9afd4..84bf26042fb --- a/apps/contacts/export.php +++ b/apps/contacts/export.php @@ -7,7 +7,7 @@ */ -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); $bookid = isset($_GET['bookid']) ? $_GET['bookid'] : NULL; $contactid = isset($_GET['contactid']) ? $_GET['contactid'] : NULL; diff --git a/apps/contacts/index.php b/apps/contacts/index.php index a680da3fa97..8f2a561b312 100755 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -9,7 +9,7 @@ // Check if we are a user -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); // Get active address books. This creates a default one if none exists. diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index f9e62455c13..12d7f370710 100755 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -10,7 +10,7 @@ // Init owncloud -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); function getStandardImage(){ diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index 1f9fbd7135e..ab5d160135e 100755 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -23,7 +23,7 @@ // Init owncloud OC_JSON::checkLoggedIn(); -//OC_Util::checkLoggedIn(); +//OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); function getStandardImage(){ diff --git a/apps/external/ajax/setsites.php b/apps/external/ajax/setsites.php old mode 100644 new mode 100755 index 3223bf68d9b..5f36b3d13d5 --- a/apps/external/ajax/setsites.php +++ b/apps/external/ajax/setsites.php @@ -7,7 +7,7 @@ */ -OC_Util::checkAdminUser(); +OCP\User::checkAdminUser(); $sites = array(); for ($i = 0; $i < sizeof($_POST['site_name']); $i++) { diff --git a/apps/external/index.php b/apps/external/index.php old mode 100644 new mode 100755 index 0baa62a94b6..1d4e5cc5051 --- a/apps/external/index.php +++ b/apps/external/index.php @@ -23,7 +23,7 @@ require_once('lib/external.php'); -OC_Util::checkLoggedIn(); +OCP\User::checkLoggedIn(); if (isset($_GET['id'])) { diff --git a/apps/external/settings.php b/apps/external/settings.php index a0c4bb0523d..c1a4242c333 100755 --- a/apps/external/settings.php +++ b/apps/external/settings.php @@ -1,6 +1,6 @@ assign('allowResharing', OC_Appconfig::getValue('files_sharing', 'resharing', 'yes')); diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index d806638e011..eb8886239d3 100755 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -22,7 +22,7 @@ */ require_once( '../../lib/base.php' ); -OC_Util::checkLoggedIn( ); +OCP\User::checkLoggedIn( ); OCP\Util::addStyle('files_versions','versions'); $tmpl = new OC_Template( 'files_versions', 'history', 'user' ); diff --git a/apps/files_versions/settings.php b/apps/files_versions/settings.php index c6312b7be7b..59609de15b4 100755 --- a/apps/files_versions/settings.php +++ b/apps/files_versions/settings.php @@ -1,6 +1,6 @@ . * */ -OC_Util::checkAdminUser(); +OCP\User::checkAdminUser(); OC_Util::checkAppEnabled('user_migrate'); // Import? diff --git a/lib/public/user.php b/lib/public/user.php index febac06730f..b39235bb965 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -84,6 +84,21 @@ class User { return \OC_USER::checkPassword($uid, $password); } + /** + * Check if the user is a admin, redirects to home if not + */ + public static function checkAdminUser(){ + \OC_Util::checkAdminUser(); + } + + /** + * Check if the user is logged in, redirects to home if not. With + * redirect URL parameter to the request URI. + */ + public static function checkLoggedIn(){ + \OC_Util::checkLoggedIn(); + } + } diff --git a/lib/public/util.php b/lib/public/util.php index c4a73a5a7fc..5cfcbaeeffc 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -122,6 +122,15 @@ class Util { + + + + + + + + + } ?> -- cgit v1.2.3 From 93b63cf3755d3f1295c976c308b81c6340883abb Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Wed, 2 May 2012 00:20:45 +0200 Subject: ported the rest of the OC_Helper calls --- apps/bookmarks/appinfo/app.php | 2 +- apps/calendar/appinfo/app.php | 2 +- apps/calendar/templates/calendar.php | 2 +- apps/contacts/ajax/importaddressbook.php | 6 +- apps/contacts/ajax/loadcard.php | 6 +- apps/contacts/appinfo/app.php | 2 +- apps/contacts/index.php | 6 +- apps/contacts/photo.php | 2 +- apps/contacts/thumbnail.php | 2 +- apps/external/appinfo/app.php | 2 +- apps/files/admin.php | 16 ++-- apps/files/ajax/upload.php | 2 +- apps/files/appinfo/app.php | 2 +- apps/files/index.php | 6 +- apps/files_archive/lib/storage.php | 2 +- apps/files_archive/lib/tar.php | 12 +-- apps/files_archive/lib/zip.php | 2 +- apps/files_archive/tests/archive.php | 8 +- apps/files_archive/tests/storage.php | 2 +- apps/files_archive/tests/tar.php | 2 +- apps/files_archive/tests/zip.php | 2 +- apps/files_encryption/lib/proxy.php | 4 +- apps/files_encryption/tests/encryption.php | 4 +- apps/files_encryption/tests/stream.php | 4 +- apps/files_external/lib/ftp.php | 2 +- apps/files_external/lib/google.php | 2 +- apps/files_external/lib/swift.php | 8 +- apps/files_external/lib/webdav.php | 2 +- apps/files_external/tests/ftp.php | 2 +- apps/gallery/appinfo/app.php | 2 +- apps/media/appinfo/app.php | 2 +- apps/user_ldap/user_ldap.php | 2 +- lib/helper.php | 3 +- lib/public/util.php | 115 ++++++++++++++++++++++++++++- 34 files changed, 173 insertions(+), 67 deletions(-) mode change 100644 => 100755 apps/contacts/ajax/importaddressbook.php mode change 100644 => 100755 apps/files/ajax/upload.php mode change 100644 => 100755 apps/files_archive/lib/storage.php mode change 100644 => 100755 apps/files_archive/lib/tar.php mode change 100644 => 100755 apps/files_archive/tests/archive.php mode change 100644 => 100755 apps/files_archive/tests/storage.php mode change 100644 => 100755 apps/files_archive/tests/tar.php mode change 100644 => 100755 apps/files_archive/tests/zip.php mode change 100644 => 100755 apps/files_encryption/tests/encryption.php mode change 100644 => 100755 apps/files_encryption/tests/stream.php mode change 100644 => 100755 apps/files_external/lib/ftp.php mode change 100644 => 100755 apps/files_external/lib/google.php mode change 100644 => 100755 apps/files_external/lib/swift.php mode change 100644 => 100755 apps/files_external/lib/webdav.php mode change 100644 => 100755 apps/files_external/tests/ftp.php mode change 100644 => 100755 apps/user_ldap/user_ldap.php (limited to 'apps/files/ajax') diff --git a/apps/bookmarks/appinfo/app.php b/apps/bookmarks/appinfo/app.php index 449969d8e5f..246a0d0ecd7 100755 --- a/apps/bookmarks/appinfo/app.php +++ b/apps/bookmarks/appinfo/app.php @@ -13,7 +13,7 @@ OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php' OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' )); $l = new OC_l10n('bookmarks'); -OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks'))); +OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks'))); OC_App::registerPersonal('bookmarks', 'settings'); OCP\Util::addscript('bookmarks','bookmarksearch'); diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 9a60aaeeb95..cf1325fad7a 100755 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -19,7 +19,7 @@ OC_App::addNavigationEntry( array( 'id' => 'calendar_index', 'order' => 10, 'href' => OCP\Util::linkTo( 'calendar', 'index.php' ), - 'icon' => OC_Helper::imagePath( 'calendar', 'icon.svg' ), + 'icon' => OCP\Util::imagePath( 'calendar', 'icon.svg' ), 'name' => $l->t('Calendar'))); OC_App::registerPersonal('calendar', 'settings'); OC_Search::registerProvider('OC_Search_Provider_Calendar'); diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index f8bd91640e5..4285dc0f833 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -40,7 +40,7 @@    - +
diff --git a/apps/contacts/ajax/importaddressbook.php b/apps/contacts/ajax/importaddressbook.php old mode 100644 new mode 100755 index 5776c801a76..e54d22b9caf --- a/apps/contacts/ajax/importaddressbook.php +++ b/apps/contacts/ajax/importaddressbook.php @@ -9,8 +9,8 @@ require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_Util::checkAppEnabled('contacts'); -$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); +$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); +$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace=OC_Filesystem::free_space('/'); @@ -19,6 +19,6 @@ $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); $tmpl = new OC_Template('contacts', 'part.importaddressbook'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); -$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); +$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->printpage(); ?> diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php index a2660130a25..90ba3f66097 100755 --- a/apps/contacts/ajax/loadcard.php +++ b/apps/contacts/ajax/loadcard.php @@ -38,8 +38,8 @@ function debug($msg) { OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); +$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); +$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace=OC_Filesystem::free_space('/'); @@ -51,7 +51,7 @@ $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL'); $tmpl = new OC_Template('contacts','part.contact'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); -$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); +$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('adr_types',$adr_types); $tmpl->assign('phone_types',$phone_types); $tmpl->assign('email_types',$email_types); diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 2c4da2fd6cd..87c36959743 100755 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -18,7 +18,7 @@ OC_App::addNavigationEntry( array( 'id' => 'contacts_index', 'order' => 10, 'href' => OCP\Util::linkTo( 'contacts', 'index.php' ), - 'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ), + 'icon' => OCP\Util::imagePath( 'settings', 'users.svg' ), 'name' => OC_L10N::get('contact')->t('Contacts') )); diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 8f2a561b312..c018fca764a 100755 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -37,8 +37,8 @@ $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL'); $categories = OC_Contacts_App::getCategories(); -$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); +$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); +$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace=OC_Filesystem::free_space('/'); @@ -59,7 +59,7 @@ OCP\Util::addStyle('contacts','contacts'); $tmpl = new OC_Template( "contacts", "index", "user" ); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); -$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); +$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('property_types', $property_types); $tmpl->assign('phone_types', $phone_types); $tmpl->assign('email_types', $email_types); diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index 12d7f370710..a545afc434b 100755 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -16,7 +16,7 @@ OC_Util::checkAppEnabled('contacts'); function getStandardImage(){ OC_Response::setExpiresHeader('P10D'); OC_Response::enableCaching(); - OC_Response::redirect(OC_Helper::imagePath('contacts', 'person_large.png')); + OC_Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png')); } $id = isset($_GET['id']) ? $_GET['id'] : null; diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index ab5d160135e..239ec7f4d47 100755 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -29,7 +29,7 @@ OC_Util::checkAppEnabled('contacts'); function getStandardImage(){ OC_Response::setExpiresHeader('P10D'); OC_Response::enableCaching(); - OC_Response::redirect(OC_Helper::imagePath('contacts', 'person.png')); + OC_Response::redirect(OCP\Util::imagePath('contacts', 'person.png')); } if(!function_exists('imagecreatefromjpeg')) { diff --git a/apps/external/appinfo/app.php b/apps/external/appinfo/app.php index b69cc3b2d6b..66116ac4c6e 100755 --- a/apps/external/appinfo/app.php +++ b/apps/external/appinfo/app.php @@ -31,5 +31,5 @@ OC_App::register(array('order' => 70, 'id' => 'external', 'name' => 'External')) $sites = OC_External::getSites(); for ($i = 0; $i < sizeof($sites); $i++) { OC_App::addNavigationEntry( - array('id' => 'external_index' . ($i + 1), 'order' => 80 + $i, 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), 'icon' => OC_Helper::imagePath('external', 'external.png'), 'name' => $sites[$i][0])); + array('id' => 'external_index' . ($i + 1), 'order' => 80 + $i, 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), 'icon' => OCP\Util::imagePath('external', 'external.png'), 'name' => $sites[$i][0])); } diff --git a/apps/files/admin.php b/apps/files/admin.php index ae7ea0436a0..120e245fd42 100755 --- a/apps/files/admin.php +++ b/apps/files/admin.php @@ -29,24 +29,24 @@ OCP\User::checkAdminUser(); $htaccessWorking=(getenv('htaccessWorking')=='true'); -$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); -$maxUploadFilesize = OC_Helper::humanFileSize(min($upload_max_filesize, $post_max_size)); +$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); +$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); +$maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size)); if($_POST) { if(isset($_POST['maxUploadSize'])){ - if(($setMaxSize = OC_Files::setUploadLimit(OC_Helper::computerFileSize($_POST['maxUploadSize']))) !== false) { - $maxUploadFilesize = OC_Helper::humanFileSize($setMaxSize); + if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) { + $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize); } } if(isset($_POST['maxZipInputSize'])) { $maxZipInputSize=$_POST['maxZipInputSize']; - OC_Config::setValue('maxZipInputSize', OC_Helper::computerFileSize($maxZipInputSize)); + OC_Config::setValue('maxZipInputSize', OCP\Util::computerFileSize($maxZipInputSize)); } if(isset($_POST['submitFilesAdminSettings'])) { OC_Config::setValue('allowZipDownload', isset($_POST['allowZipDownload'])); } } -$maxZipInputSize = OC_Helper::humanFileSize(OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'))); +$maxZipInputSize = OCP\Util::humanFileSize(OC_Config::getValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB'))); $allowZipDownload = intval(OC_Config::getValue('allowZipDownload', true)); OC_App::setActiveNavigationEntry( "files_administration" ); @@ -54,7 +54,7 @@ OC_App::setActiveNavigationEntry( "files_administration" ); $tmpl = new OC_Template( 'files', 'admin' ); $tmpl->assign( 'htaccessWorking', $htaccessWorking ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); -$tmpl->assign( 'maxPossibleUploadSize', OC_Helper::humanFileSize(PHP_INT_MAX)); +$tmpl->assign( 'maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX)); $tmpl->assign( 'allowZipDownload', $allowZipDownload); $tmpl->assign( 'maxZipInputSize', $maxZipInputSize); return $tmpl->fetchPage(); \ No newline at end of file diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php old mode 100644 new mode 100755 index 3ac8ef59560..c50f6233a46 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -46,7 +46,7 @@ $result=array(); if(strpos($dir,'..') === false){ $fileCount=count($files['name']); for($i=0;$i<$fileCount;$i++){ - $target = OC_Helper::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); + $target = OCP\Util::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){ $meta=OC_FileCache::getCached($target); $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target)); diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index 40523521d9c..0e82713fe5c 100755 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -5,6 +5,6 @@ $l=OC_L10N::get('files'); OC_App::register( array( "order" => 2, "id" => "files", "name" => "Files" )); -OC_App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OC_Helper::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") )); +OC_App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") )); OC_Search::registerProvider('OC_Search_Provider_File'); diff --git a/apps/files/index.php b/apps/files/index.php index 9634a725866..3f97317fc5f 100755 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -80,8 +80,8 @@ $breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" ); $breadcrumbNav->assign( "breadcrumb", $breadcrumb ); $breadcrumbNav->assign( "baseURL", OCP\Util::linkTo("files", "index.php")."?dir="); -$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); +$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); +$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace=OC_Filesystem::free_space('/'); @@ -95,7 +95,7 @@ $tmpl->assign( 'dir', $dir); $tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir)); $tmpl->assign( "files", $files ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); -$tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); +$tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign( 'allowZipDownload', intval(OC_Config::getValue('allowZipDownload', true))); $tmpl->printPage(); diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php old mode 100644 new mode 100755 index 700d9633042..7a4ae339621 --- a/apps/files_archive/lib/storage.php +++ b/apps/files_archive/lib/storage.php @@ -104,7 +104,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{ } public function touch($path, $mtime=null){ if(is_null($mtime)){ - $tmpFile=OC_Helper::tmpFile(); + $tmpFile=OCP\Util::tmpFile(); $this->archive->extractFile($path,$tmpFile); $this->archive->addfile($path,$tmpFile); }else{ diff --git a/apps/files_archive/lib/tar.php b/apps/files_archive/lib/tar.php old mode 100644 new mode 100755 index 1eed11a762d..3a07a28906c --- a/apps/files_archive/lib/tar.php +++ b/apps/files_archive/lib/tar.php @@ -93,7 +93,7 @@ class OC_Archive_TAR extends OC_Archive{ */ function rename($source,$dest){ //no proper way to delete, rename entire archive, rename file and remake archive - $tmp=OC_Helper::tmpFolder(); + $tmp=OCP\Util::tmpFolder(); $this->tar->extract($tmp); rename($tmp.$source,$tmp.$dest); $this->tar=null; @@ -177,7 +177,7 @@ class OC_Archive_TAR extends OC_Archive{ * @return bool */ function extractFile($path,$dest){ - $tmp=OC_Helper::tmpFolder(); + $tmp=OCP\Util::tmpFolder(); if(!$this->fileExists($path)){ return false; } @@ -185,7 +185,7 @@ class OC_Archive_TAR extends OC_Archive{ if($success){ rename($tmp.$path,$dest); } - OC_Helper::rmdirr($tmp); + OCP\Util::rmdirr($tmp); return $success; } /** @@ -216,9 +216,9 @@ class OC_Archive_TAR extends OC_Archive{ return false; } //no proper way to delete, extract entire archive, delete file and remake archive - $tmp=OC_Helper::tmpFolder(); + $tmp=OCP\Util::tmpFolder(); $this->tar->extract($tmp); - OC_Helper::rmdirr($tmp.$path); + OCP\Util::rmdirr($tmp.$path); $this->tar=null; unlink($this->path); $this->reopen(); @@ -237,7 +237,7 @@ class OC_Archive_TAR extends OC_Archive{ }else{ $ext=''; } - $tmpFile=OC_Helper::tmpFile($ext); + $tmpFile=OCP\Util::tmpFile($ext); if($this->fileExists($path)){ $this->extractFile($path,$tmpFile); }elseif($mode=='r' or $mode=='rb'){ diff --git a/apps/files_archive/lib/zip.php b/apps/files_archive/lib/zip.php index dd94859f089..16f722a734e 100755 --- a/apps/files_archive/lib/zip.php +++ b/apps/files_archive/lib/zip.php @@ -169,7 +169,7 @@ class OC_Archive_ZIP extends OC_Archive{ }else{ $ext=''; } - $tmpFile=OC_Helper::tmpFile($ext); + $tmpFile=OCP\Util::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); if($this->fileExists($path)){ $this->extractFile($path,$tmpFile); diff --git a/apps/files_archive/tests/archive.php b/apps/files_archive/tests/archive.php old mode 100644 new mode 100755 index 9e99466a521..512afe9e915 --- a/apps/files_archive/tests/archive.php +++ b/apps/files_archive/tests/archive.php @@ -55,7 +55,7 @@ abstract class Test_Archive extends UnitTestCase { $textFile=$dir.'/lorem.txt'; $this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt')); - $tmpFile=OC_Helper::tmpFile('.txt'); + $tmpFile=OCP\Util::tmpFile('.txt'); $this->instance->extractFile('lorem.txt',$tmpFile); $this->assertEqual(file_get_contents($textFile),file_get_contents($tmpFile)); } @@ -89,7 +89,7 @@ abstract class Test_Archive extends UnitTestCase { $this->instance=$this->getNew(); $fh=$this->instance->getStream('lorem.txt','w'); $source=fopen($dir.'/lorem.txt','r'); - OC_Helper::streamCopy($source,$fh); + OCP\Util::streamCopy($source,$fh); fclose($source); fclose($fh); $this->assertTrue($this->instance->fileExists('lorem.txt')); @@ -109,13 +109,13 @@ abstract class Test_Archive extends UnitTestCase { public function testExtract(){ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $this->instance=$this->getExisting(); - $tmpDir=OC_Helper::tmpFolder(); + $tmpDir=OCP\Util::tmpFolder(); $this->instance->extract($tmpDir); $this->assertEqual(true,file_exists($tmpDir.'lorem.txt')); $this->assertEqual(true,file_exists($tmpDir.'dir/lorem.txt')); $this->assertEqual(true,file_exists($tmpDir.'logo-wide.png')); $this->assertEqual(file_get_contents($dir.'/lorem.txt'),file_get_contents($tmpDir.'lorem.txt')); - OC_Helper::rmdirr($tmpDir); + OCP\Util::rmdirr($tmpDir); } public function testMoveRemove(){ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; diff --git a/apps/files_archive/tests/storage.php b/apps/files_archive/tests/storage.php old mode 100644 new mode 100755 index 4d0a83356bd..52d6a4296e9 --- a/apps/files_archive/tests/storage.php +++ b/apps/files_archive/tests/storage.php @@ -13,7 +13,7 @@ class Test_Filestorage_Archive_Zip extends Test_FileStorage { private $tmpFile; public function setUp(){ - $this->tmpFile=OC_Helper::tmpFile('.zip'); + $this->tmpFile=OCP\Util::tmpFile('.zip'); $this->instance=new OC_Filestorage_Archive(array('archive'=>$this->tmpFile)); } diff --git a/apps/files_archive/tests/tar.php b/apps/files_archive/tests/tar.php old mode 100644 new mode 100755 index aa46455e659..c543c226bef --- a/apps/files_archive/tests/tar.php +++ b/apps/files_archive/tests/tar.php @@ -16,7 +16,7 @@ if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){ } protected function getNew(){ - return new OC_Archive_TAR(OC_Helper::tmpFile('.tar.gz')); + return new OC_Archive_TAR(OCP\Util::tmpFile('.tar.gz')); } } }else{ diff --git a/apps/files_archive/tests/zip.php b/apps/files_archive/tests/zip.php old mode 100644 new mode 100755 index 18a2997c1a5..b22ea3b79e9 --- a/apps/files_archive/tests/zip.php +++ b/apps/files_archive/tests/zip.php @@ -16,7 +16,7 @@ if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){ } protected function getNew(){ - return new OC_Archive_ZIP(OC_Helper::tmpFile('.zip')); + return new OC_Archive_ZIP(OCP\Util::tmpFile('.zip')); } } }else{ diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 11a6a84e667..cbe88adb5e4 100755 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -92,7 +92,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ //first encrypt the target file so we don't end up with a half encrypted file OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing',OCP\Util::DEBUG); $tmp=fopen('php://temp'); - OC_Helper::streamCopy($result,$tmp); + OCP\Util::streamCopy($result,$tmp); fclose($result); OC_Filesystem::file_put_contents($path,$tmp); fclose($tmp); @@ -104,7 +104,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ public function postGetMimeType($path,$mime){ if(self::isEncrypted($path)){ - $mime=OC_Helper::getMimeType('crypt://'.$path,'w'); + $mime=OCP\Util::getMimeType('crypt://'.$path,'w'); } return $mime; } diff --git a/apps/files_encryption/tests/encryption.php b/apps/files_encryption/tests/encryption.php old mode 100644 new mode 100755 index 13093256717..24b3bbcaf40 --- a/apps/files_encryption/tests/encryption.php +++ b/apps/files_encryption/tests/encryption.php @@ -27,14 +27,14 @@ class Test_Encryption extends UnitTestCase { $this->assertNotEqual($encrypted,$source); $this->assertEqual($decrypted,$source); - $tmpFileEncrypted=OC_Helper::tmpFile(); + $tmpFileEncrypted=OCP\Util::tmpFile(); OC_Crypt::encryptfile($file,$tmpFileEncrypted,$key); $encrypted=file_get_contents($tmpFileEncrypted); $decrypted=OC_Crypt::blockDecrypt($encrypted,$key); $this->assertNotEqual($encrypted,$source); $this->assertEqual($decrypted,$source); - $tmpFileDecrypted=OC_Helper::tmpFile(); + $tmpFileDecrypted=OCP\Util::tmpFile(); OC_Crypt::decryptfile($tmpFileEncrypted,$tmpFileDecrypted,$key); $decrypted=file_get_contents($tmpFileDecrypted); $this->assertEqual($decrypted,$source); diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php old mode 100644 new mode 100755 index 578b091a36c..225e82c99e8 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -22,7 +22,7 @@ class Test_CryptStream extends UnitTestCase { $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; $source=fopen($file,'r'); $target=$this->getStream('test2','w'); - OC_Helper::streamCopy($source,$target); + OCP\Util::streamCopy($source,$target); fclose($target); fclose($source); @@ -44,7 +44,7 @@ class Test_CryptStream extends UnitTestCase { $id=uniqid(); } if(!isset($this->tmpFiles[$id])){ - $file=OC_Helper::tmpFile(); + $file=OCP\Util::tmpFile(); $this->tmpFiles[$id]=$file; }else{ $file=$this->tmpFiles[$id]; diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php old mode 100644 new mode 100755 index 802446b4fd8..1618a22ba8a --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -108,7 +108,7 @@ class OC_FileStorage_FTP extends OC_Filestorage_Common{ }else{ $ext=''; } - $tmpFile=OC_Helper::tmpFile($ext); + $tmpFile=OCP\Util::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); if($this->file_exists($path)){ $this->getFile($path,$tmpFile); diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php old mode 100644 new mode 100755 index 0d6db1987f8..24a9d6c3d52 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -84,7 +84,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } if ($isDownload) { - $tmpFile = OC_Helper::tmpFile(); + $tmpFile = OCP\Util::tmpFile(); $fp = fopen($tmpFile, 'w'); curl_setopt($curl, CURLOPT_FILE, $fp); curl_exec($curl); diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php old mode 100644 new mode 100755 index a987d17d799..aaba79d9b7b --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -164,7 +164,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @return array */ private function getSubContainers($container){ - $tmpFile=OC_Helper::tmpFile(); + $tmpFile=OCP\Util::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); @@ -190,7 +190,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ if(!$name){ return false; } - $tmpFile=OC_Helper::tmpFile(); + $tmpFile=OCP\Util::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); @@ -225,7 +225,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ if(!$name){ return false; } - $tmpFile=OC_Helper::tmpFile(); + $tmpFile=OCP\Util::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); @@ -501,7 +501,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ private function getTmpFile($path){ $obj=$this->getObject($path); if(!is_null($obj)){ - $tmpFile=OC_Helper::tmpFile(); + $tmpFile=OCP\Util::tmpFile(); $obj->save_to_filename($tmpFile); return $tmpFile; }else{ diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php old mode 100644 new mode 100755 index 7a2da5c8ec0..75e5f80d217 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -150,7 +150,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ }else{ $ext=''; } - $tmpFile=OC_Helper::tmpFile($ext); + $tmpFile=OCP\Util::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); if($this->file_exists($path)){ $this->getFile($path,$tmpFile); diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php old mode 100644 new mode 100755 index e30fb9a1c38..d2d3622fa78 --- a/apps/files_external/tests/ftp.php +++ b/apps/files_external/tests/ftp.php @@ -23,7 +23,7 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){ } public function tearDown(){ - OC_Helper::rmdirr($this->instance->constructUrl('')); + OCP\Util::rmdirr($this->instance->constructUrl('')); } } } diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 8f657576224..ad4723c1425 100755 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -38,7 +38,7 @@ OC_App::addNavigationEntry( array( 'id' => 'gallery_index', 'order' => 20, 'href' => OCP\Util::linkTo('gallery', 'index.php'), - 'icon' => OC_Helper::imagePath('core', 'places/picture.svg'), + 'icon' => OCP\Util::imagePath('core', 'places/picture.svg'), 'name' => $l->t('Pictures'))); class OC_GallerySearchProvider extends OC_Search_Provider{ diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index 11aeac2b5b4..5e7a411f677 100755 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -29,6 +29,6 @@ OC_APP::registerPersonal('media','settings'); OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' )); -OC_App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OC_Helper::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music'))); +OC_App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music'))); OC_Search::registerProvider('OC_MediaSearchProvider'); diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php old mode 100644 new mode 100755 index 1e8dc6aacce..1e454ab682f --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -87,7 +87,7 @@ class OC_USER_LDAP extends OC_User_Backend { $quota = false; } $quota = $quota != -1 ? $quota : $this->ldap_quota_def; - OC_Preferences::setValue($uid, 'files', 'quota', OC_Helper::computerFileSize($quota)); + OC_Preferences::setValue($uid, 'files', 'quota', OCP\Util::computerFileSize($quota)); } private function setEmail( $uid ) { diff --git a/lib/helper.php b/lib/helper.php index c5af76dbe52..82d1017debd 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -528,8 +528,7 @@ class OC_Helper { * @param $filename * @return string */ - public static function buildNotExistingFileName($path, $filename) - { + public static function buildNotExistingFileName($path, $filename){ if($path==='/'){ $path=''; } diff --git a/lib/public/util.php b/lib/public/util.php index b18f0d2311f..05be41a2a05 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -60,10 +60,8 @@ class Util { * @param bool $html */ public static function sendMail($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') { - // call the internal mail class \OC_MAIL::send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc=''); - } /** @@ -74,10 +72,8 @@ class Util { * @param int level */ public static function writeLog($app, $message, $level) { - // call the internal log class \OC_LOG::write($app, $message, $level); - } @@ -158,6 +154,117 @@ class Util { return(\OC_Helper::severHost()); } + /** + * @brief Creates path to an image + * @param $app app + * @param $image image name + * @returns the url + * + * Returns the path to the image. + */ + public static function imagePath( $app, $image ){ + return(\OC_Helper::imagePath( $app, $image )); + } + + + /** + * @brief Make a human file size + * @param $bytes file size in bytes + * @returns a human readable file size + * + * Makes 2048 to 2 kB. + */ + public static function humanFileSize( $bytes ){ + return(\OC_Helper::humanFileSize( $bytes )); + } + + /** + * @brief Make a computer file size + * @param $str file size in a fancy format + * @returns a file size in bytes + * + * Makes 2kB to 2048. + * + * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 + */ + public static function computerFileSize( $str ){ + return(\OC_Helper::computerFileSize( $str )); + } + + + + /** + * @brief Recusive deletion of folders + * @param string $dir path to the folder + * + */ + static function rmdirr($dir) { + \OC_Helper::rmdirr( $dir ); + } + + + /** + * get the mimetype form a local file + * @param string path + * @return string + * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead + */ + static function getMimeType($path){ + return(\OC_Helper::getMimeType( $path )); + } + + /** + * copy the contents of one stream to another + * @param resource source + * @param resource target + * @return int the number of bytes copied + */ + public static function streamCopy($source,$target){ + return(\OC_Helper::streamCopy($source,$target)); + } + + + /** + * create a temporary file with an unique filename + * @param string postfix + * @return string + * + * temporary files are automatically cleaned up after the script is finished + */ + public static function tmpFile($postfix=''){ + return(\OC_Helper::tmpFile($postfix)); + } + + /** + * create a temporary folder with an unique filename + * @return string + * + * temporary files are automatically cleaned up after the script is finished + */ + public static function tmpFolder(){ + return(\OC_Helper::tmpFolder()); + } + + /** + * Adds a suffix to the name in case the file exists + * + * @param $path + * @param $filename + * @return string + */ + public static function buildNotExistingFileName($path, $filename){ + return(\OC_Helper::buildNotExistingFileName($path, $filename)); + } + + + + + + + + + + -- cgit v1.2.3 From 8c7f8546716ac77cdeaa134caf9fae22232ce213 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Wed, 2 May 2012 12:54:31 +0200 Subject: move all the files stuff into a files class --- apps/files/ajax/upload.php | 2 +- apps/files_archive/lib/storage.php | 2 +- apps/files_archive/lib/tar.php | 12 +-- apps/files_archive/lib/zip.php | 2 +- apps/files_archive/tests/archive.php | 8 +- apps/files_archive/tests/storage.php | 2 +- apps/files_archive/tests/tar.php | 2 +- apps/files_archive/tests/zip.php | 2 +- apps/files_encryption/lib/proxy.php | 4 +- apps/files_encryption/tests/encryption.php | 4 +- apps/files_encryption/tests/stream.php | 4 +- apps/files_external/lib/ftp.php | 2 +- apps/files_external/lib/google.php | 2 +- apps/files_external/lib/swift.php | 8 +- apps/files_external/lib/webdav.php | 2 +- apps/files_external/tests/ftp.php | 2 +- lib/public/files.php | 114 +++++++++++++++++++++++++++++ lib/public/util.php | 74 ------------------- 18 files changed, 144 insertions(+), 104 deletions(-) create mode 100644 lib/public/files.php (limited to 'apps/files/ajax') diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index c50f6233a46..ca64f58e14b 100755 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -46,7 +46,7 @@ $result=array(); if(strpos($dir,'..') === false){ $fileCount=count($files['name']); for($i=0;$i<$fileCount;$i++){ - $target = OCP\Util::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); + $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){ $meta=OC_FileCache::getCached($target); $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target)); diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php index 7a4ae339621..086a338db25 100755 --- a/apps/files_archive/lib/storage.php +++ b/apps/files_archive/lib/storage.php @@ -104,7 +104,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{ } public function touch($path, $mtime=null){ if(is_null($mtime)){ - $tmpFile=OCP\Util::tmpFile(); + $tmpFile=OCP\Files::tmpFile(); $this->archive->extractFile($path,$tmpFile); $this->archive->addfile($path,$tmpFile); }else{ diff --git a/apps/files_archive/lib/tar.php b/apps/files_archive/lib/tar.php index 3a07a28906c..2cb8dc2a8ae 100755 --- a/apps/files_archive/lib/tar.php +++ b/apps/files_archive/lib/tar.php @@ -93,7 +93,7 @@ class OC_Archive_TAR extends OC_Archive{ */ function rename($source,$dest){ //no proper way to delete, rename entire archive, rename file and remake archive - $tmp=OCP\Util::tmpFolder(); + $tmp=OCP\Files::tmpFolder(); $this->tar->extract($tmp); rename($tmp.$source,$tmp.$dest); $this->tar=null; @@ -177,7 +177,7 @@ class OC_Archive_TAR extends OC_Archive{ * @return bool */ function extractFile($path,$dest){ - $tmp=OCP\Util::tmpFolder(); + $tmp=OCP\Files::tmpFolder(); if(!$this->fileExists($path)){ return false; } @@ -185,7 +185,7 @@ class OC_Archive_TAR extends OC_Archive{ if($success){ rename($tmp.$path,$dest); } - OCP\Util::rmdirr($tmp); + OCP\Files::rmdirr($tmp); return $success; } /** @@ -216,9 +216,9 @@ class OC_Archive_TAR extends OC_Archive{ return false; } //no proper way to delete, extract entire archive, delete file and remake archive - $tmp=OCP\Util::tmpFolder(); + $tmp=OCP\Files::tmpFolder(); $this->tar->extract($tmp); - OCP\Util::rmdirr($tmp.$path); + OCP\Files::rmdirr($tmp.$path); $this->tar=null; unlink($this->path); $this->reopen(); @@ -237,7 +237,7 @@ class OC_Archive_TAR extends OC_Archive{ }else{ $ext=''; } - $tmpFile=OCP\Util::tmpFile($ext); + $tmpFile=OCP\Files::tmpFile($ext); if($this->fileExists($path)){ $this->extractFile($path,$tmpFile); }elseif($mode=='r' or $mode=='rb'){ diff --git a/apps/files_archive/lib/zip.php b/apps/files_archive/lib/zip.php index 16f722a734e..22ab48937eb 100755 --- a/apps/files_archive/lib/zip.php +++ b/apps/files_archive/lib/zip.php @@ -169,7 +169,7 @@ class OC_Archive_ZIP extends OC_Archive{ }else{ $ext=''; } - $tmpFile=OCP\Util::tmpFile($ext); + $tmpFile=OCP\Files::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); if($this->fileExists($path)){ $this->extractFile($path,$tmpFile); diff --git a/apps/files_archive/tests/archive.php b/apps/files_archive/tests/archive.php index 512afe9e915..1779127c932 100755 --- a/apps/files_archive/tests/archive.php +++ b/apps/files_archive/tests/archive.php @@ -55,7 +55,7 @@ abstract class Test_Archive extends UnitTestCase { $textFile=$dir.'/lorem.txt'; $this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt')); - $tmpFile=OCP\Util::tmpFile('.txt'); + $tmpFile=OCP\Files::tmpFile('.txt'); $this->instance->extractFile('lorem.txt',$tmpFile); $this->assertEqual(file_get_contents($textFile),file_get_contents($tmpFile)); } @@ -89,7 +89,7 @@ abstract class Test_Archive extends UnitTestCase { $this->instance=$this->getNew(); $fh=$this->instance->getStream('lorem.txt','w'); $source=fopen($dir.'/lorem.txt','r'); - OCP\Util::streamCopy($source,$fh); + OCP\Files::streamCopy($source,$fh); fclose($source); fclose($fh); $this->assertTrue($this->instance->fileExists('lorem.txt')); @@ -109,13 +109,13 @@ abstract class Test_Archive extends UnitTestCase { public function testExtract(){ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $this->instance=$this->getExisting(); - $tmpDir=OCP\Util::tmpFolder(); + $tmpDir=OCP\Files::tmpFolder(); $this->instance->extract($tmpDir); $this->assertEqual(true,file_exists($tmpDir.'lorem.txt')); $this->assertEqual(true,file_exists($tmpDir.'dir/lorem.txt')); $this->assertEqual(true,file_exists($tmpDir.'logo-wide.png')); $this->assertEqual(file_get_contents($dir.'/lorem.txt'),file_get_contents($tmpDir.'lorem.txt')); - OCP\Util::rmdirr($tmpDir); + OCP\Files::rmdirr($tmpDir); } public function testMoveRemove(){ $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; diff --git a/apps/files_archive/tests/storage.php b/apps/files_archive/tests/storage.php index 52d6a4296e9..7ebcce4ac6f 100755 --- a/apps/files_archive/tests/storage.php +++ b/apps/files_archive/tests/storage.php @@ -13,7 +13,7 @@ class Test_Filestorage_Archive_Zip extends Test_FileStorage { private $tmpFile; public function setUp(){ - $this->tmpFile=OCP\Util::tmpFile('.zip'); + $this->tmpFile=OCP\Files::tmpFile('.zip'); $this->instance=new OC_Filestorage_Archive(array('archive'=>$this->tmpFile)); } diff --git a/apps/files_archive/tests/tar.php b/apps/files_archive/tests/tar.php index c543c226bef..c138a51a651 100755 --- a/apps/files_archive/tests/tar.php +++ b/apps/files_archive/tests/tar.php @@ -16,7 +16,7 @@ if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){ } protected function getNew(){ - return new OC_Archive_TAR(OCP\Util::tmpFile('.tar.gz')); + return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz')); } } }else{ diff --git a/apps/files_archive/tests/zip.php b/apps/files_archive/tests/zip.php index b22ea3b79e9..615c9e3c7e2 100755 --- a/apps/files_archive/tests/zip.php +++ b/apps/files_archive/tests/zip.php @@ -16,7 +16,7 @@ if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){ } protected function getNew(){ - return new OC_Archive_ZIP(OCP\Util::tmpFile('.zip')); + return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip')); } } }else{ diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index cbe88adb5e4..ba357f23502 100755 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -92,7 +92,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ //first encrypt the target file so we don't end up with a half encrypted file OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing',OCP\Util::DEBUG); $tmp=fopen('php://temp'); - OCP\Util::streamCopy($result,$tmp); + OCP\Files::streamCopy($result,$tmp); fclose($result); OC_Filesystem::file_put_contents($path,$tmp); fclose($tmp); @@ -104,7 +104,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ public function postGetMimeType($path,$mime){ if(self::isEncrypted($path)){ - $mime=OCP\Util::getMimeType('crypt://'.$path,'w'); + $mime=OCP\Files::getMimeType('crypt://'.$path,'w'); } return $mime; } diff --git a/apps/files_encryption/tests/encryption.php b/apps/files_encryption/tests/encryption.php index 24b3bbcaf40..00466cc671c 100755 --- a/apps/files_encryption/tests/encryption.php +++ b/apps/files_encryption/tests/encryption.php @@ -27,14 +27,14 @@ class Test_Encryption extends UnitTestCase { $this->assertNotEqual($encrypted,$source); $this->assertEqual($decrypted,$source); - $tmpFileEncrypted=OCP\Util::tmpFile(); + $tmpFileEncrypted=OCP\Files::tmpFile(); OC_Crypt::encryptfile($file,$tmpFileEncrypted,$key); $encrypted=file_get_contents($tmpFileEncrypted); $decrypted=OC_Crypt::blockDecrypt($encrypted,$key); $this->assertNotEqual($encrypted,$source); $this->assertEqual($decrypted,$source); - $tmpFileDecrypted=OCP\Util::tmpFile(); + $tmpFileDecrypted=OCP\Files::tmpFile(); OC_Crypt::decryptfile($tmpFileEncrypted,$tmpFileDecrypted,$key); $decrypted=file_get_contents($tmpFileDecrypted); $this->assertEqual($decrypted,$source); diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index 225e82c99e8..b23805d60b0 100755 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -22,7 +22,7 @@ class Test_CryptStream extends UnitTestCase { $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; $source=fopen($file,'r'); $target=$this->getStream('test2','w'); - OCP\Util::streamCopy($source,$target); + OCP\Files::streamCopy($source,$target); fclose($target); fclose($source); @@ -44,7 +44,7 @@ class Test_CryptStream extends UnitTestCase { $id=uniqid(); } if(!isset($this->tmpFiles[$id])){ - $file=OCP\Util::tmpFile(); + $file=OCP\Files::tmpFile(); $this->tmpFiles[$id]=$file; }else{ $file=$this->tmpFiles[$id]; diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index 1618a22ba8a..981eeab58bf 100755 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -108,7 +108,7 @@ class OC_FileStorage_FTP extends OC_Filestorage_Common{ }else{ $ext=''; } - $tmpFile=OCP\Util::tmpFile($ext); + $tmpFile=OCP\Files::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); if($this->file_exists($path)){ $this->getFile($path,$tmpFile); diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 24a9d6c3d52..a133d35e737 100755 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -84,7 +84,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } if ($isDownload) { - $tmpFile = OCP\Util::tmpFile(); + $tmpFile = OCP\Files::tmpFile(); $fp = fopen($tmpFile, 'w'); curl_setopt($curl, CURLOPT_FILE, $fp); curl_exec($curl); diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index aaba79d9b7b..e3ba9c240cf 100755 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -164,7 +164,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @return array */ private function getSubContainers($container){ - $tmpFile=OCP\Util::tmpFile(); + $tmpFile=OCP\Files::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); @@ -190,7 +190,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ if(!$name){ return false; } - $tmpFile=OCP\Util::tmpFile(); + $tmpFile=OCP\Files::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); @@ -225,7 +225,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ if(!$name){ return false; } - $tmpFile=OCP\Util::tmpFile(); + $tmpFile=OCP\Files::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); @@ -501,7 +501,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ private function getTmpFile($path){ $obj=$this->getObject($path); if(!is_null($obj)){ - $tmpFile=OCP\Util::tmpFile(); + $tmpFile=OCP\Files::tmpFile(); $obj->save_to_filename($tmpFile); return $tmpFile; }else{ diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 75e5f80d217..07c90d4878e 100755 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -150,7 +150,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ }else{ $ext=''; } - $tmpFile=OCP\Util::tmpFile($ext); + $tmpFile=OCP\Files::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); if($this->file_exists($path)){ $this->getFile($path,$tmpFile); diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php index d2d3622fa78..68481b4e66b 100755 --- a/apps/files_external/tests/ftp.php +++ b/apps/files_external/tests/ftp.php @@ -23,7 +23,7 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){ } public function tearDown(){ - OCP\Util::rmdirr($this->instance->constructUrl('')); + OCP\Files::rmdirr($this->instance->constructUrl('')); } } } diff --git a/lib/public/files.php b/lib/public/files.php new file mode 100644 index 00000000000..f2153f33b90 --- /dev/null +++ b/lib/public/files.php @@ -0,0 +1,114 @@ +. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * Files Class + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +class Files { + + + /** + * @brief Recusive deletion of folders + * @param string $dir path to the folder + * + */ + static function rmdirr($dir) { + \OC_Helper::rmdirr( $dir ); + } + + + /** + * get the mimetype form a local file + * @param string path + * @return string + * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead + */ + static function getMimeType($path){ + return(\OC_Helper::getMimeType( $path )); + } + + /** + * copy the contents of one stream to another + * @param resource source + * @param resource target + * @return int the number of bytes copied + */ + public static function streamCopy($source,$target){ + return(\OC_Helper::streamCopy($source,$target)); + } + + + /** + * create a temporary file with an unique filename + * @param string postfix + * @return string + * + * temporary files are automatically cleaned up after the script is finished + */ + public static function tmpFile($postfix=''){ + return(\OC_Helper::tmpFile($postfix)); + } + + /** + * create a temporary folder with an unique filename + * @return string + * + * temporary files are automatically cleaned up after the script is finished + */ + public static function tmpFolder(){ + return(\OC_Helper::tmpFolder()); + } + + /** + * Adds a suffix to the name in case the file exists + * + * @param $path + * @param $filename + * @return string + */ + public static function buildNotExistingFileName($path, $filename){ + return(\OC_Helper::buildNotExistingFileName($path, $filename)); + } + + + + + + + + + + + + + + +} + +?> diff --git a/lib/public/util.php b/lib/public/util.php index 05be41a2a05..a65b9aa2627 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -193,80 +193,6 @@ class Util { - /** - * @brief Recusive deletion of folders - * @param string $dir path to the folder - * - */ - static function rmdirr($dir) { - \OC_Helper::rmdirr( $dir ); - } - - - /** - * get the mimetype form a local file - * @param string path - * @return string - * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead - */ - static function getMimeType($path){ - return(\OC_Helper::getMimeType( $path )); - } - - /** - * copy the contents of one stream to another - * @param resource source - * @param resource target - * @return int the number of bytes copied - */ - public static function streamCopy($source,$target){ - return(\OC_Helper::streamCopy($source,$target)); - } - - - /** - * create a temporary file with an unique filename - * @param string postfix - * @return string - * - * temporary files are automatically cleaned up after the script is finished - */ - public static function tmpFile($postfix=''){ - return(\OC_Helper::tmpFile($postfix)); - } - - /** - * create a temporary folder with an unique filename - * @return string - * - * temporary files are automatically cleaned up after the script is finished - */ - public static function tmpFolder(){ - return(\OC_Helper::tmpFolder()); - } - - /** - * Adds a suffix to the name in case the file exists - * - * @param $path - * @param $filename - * @return string - */ - public static function buildNotExistingFileName($path, $filename){ - return(\OC_Helper::buildNotExistingFileName($path, $filename)); - } - - - - - - - - - - - - } -- cgit v1.2.3 From 43caa3b3b9cc9dbbf73ab2f6695a801a07a1dba5 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 3 May 2012 12:23:29 +0200 Subject: ported oc_json --- apps/bookmarks/ajax/addBookmark.php | 6 +- apps/bookmarks/ajax/delBookmark.php | 6 +- apps/bookmarks/ajax/editBookmark.php | 4 +- apps/bookmarks/ajax/recordClick.php | 4 +- apps/bookmarks/ajax/updateList.php | 6 +- apps/calendar/ajax/calendar/activation.php | 6 +- apps/calendar/ajax/calendar/delete.php | 8 +- apps/calendar/ajax/calendar/edit.form.php | 4 +- apps/calendar/ajax/calendar/edit.php | 4 +- apps/calendar/ajax/calendar/new.form.php | 4 +- apps/calendar/ajax/calendar/new.php | 10 +-- apps/calendar/ajax/calendar/overview.php | 4 +- apps/calendar/ajax/calendar/update.php | 10 +-- apps/calendar/ajax/categories/rescan.php | 8 +- apps/calendar/ajax/changeview.php | 8 +- apps/calendar/ajax/event/delete.php | 8 +- apps/calendar/ajax/event/edit.form.php | 4 +- apps/calendar/ajax/event/edit.php | 10 +-- apps/calendar/ajax/event/move.php | 6 +- apps/calendar/ajax/event/new.form.php | 4 +- apps/calendar/ajax/event/new.php | 8 +- apps/calendar/ajax/event/resize.php | 6 +- apps/calendar/ajax/events.php | 6 +- apps/calendar/ajax/import/dialog.php | 2 +- apps/calendar/ajax/import/import.php | 6 +- apps/calendar/ajax/settings/getfirstday.php | 4 +- .../ajax/settings/gettimezonedetection.php | 6 +- apps/calendar/ajax/settings/guesstimezone.php | 8 +- apps/calendar/ajax/settings/setfirstday.php | 6 +- apps/calendar/ajax/settings/settimeformat.php | 6 +- apps/calendar/ajax/settings/settimezone.php | 8 +- apps/calendar/ajax/settings/timeformat.php | 4 +- apps/calendar/ajax/settings/timezonedetection.php | 8 +- apps/calendar/ajax/share/activation.php | 2 +- apps/calendar/ajax/share/changepermission.php | 10 +-- apps/calendar/ajax/share/dropdown.php | 2 +- apps/calendar/ajax/share/share.php | 20 ++--- apps/calendar/ajax/share/unshare.php | 12 +-- apps/calendar/lib/app.php | 2 +- apps/contacts/ajax/activation.php | 8 +- apps/contacts/ajax/addbook.php | 4 +- apps/contacts/ajax/addcontact.php | 10 +-- apps/contacts/ajax/addproperty.php | 14 ++-- apps/contacts/ajax/categories/categoriesfor.php | 10 +-- apps/contacts/ajax/categories/delete.php | 8 +- apps/contacts/ajax/categories/list.php | 6 +- apps/contacts/ajax/categories/rescan.php | 8 +- apps/contacts/ajax/chooseaddressbook.php | 4 +- apps/contacts/ajax/contactdetails.php | 8 +- apps/contacts/ajax/contacts.php | 6 +- apps/contacts/ajax/createaddressbook.php | 12 +-- apps/contacts/ajax/cropphoto.php | 6 +- apps/contacts/ajax/currentphoto.php | 10 +-- apps/contacts/ajax/deletebook.php | 6 +- apps/contacts/ajax/deletecard.php | 8 +- apps/contacts/ajax/deleteproperty.php | 10 +-- apps/contacts/ajax/editaddress.php | 4 +- apps/contacts/ajax/editaddressbook.php | 4 +- apps/contacts/ajax/editname.php | 6 +- apps/contacts/ajax/importaddressbook.php | 2 +- apps/contacts/ajax/importdialog.php | 2 +- apps/contacts/ajax/loadcard.php | 8 +- apps/contacts/ajax/loadintro.php | 6 +- apps/contacts/ajax/loadphoto.php | 8 +- apps/contacts/ajax/oc_photo.php | 10 +-- apps/contacts/ajax/savecrop.php | 10 +-- apps/contacts/ajax/saveproperty.php | 8 +- apps/contacts/ajax/updateaddressbook.php | 12 +-- apps/contacts/ajax/uploadimport.php | 12 +-- apps/contacts/ajax/uploadphoto.php | 18 ++--- apps/contacts/import.php | 6 +- apps/contacts/lib/app.php | 6 +- apps/contacts/thumbnail.php | 2 +- apps/files/ajax/autocomplete.php | 4 +- apps/files/ajax/delete.php | 6 +- apps/files/ajax/list.php | 4 +- apps/files/ajax/move.php | 6 +- apps/files/ajax/newfile.php | 14 ++-- apps/files/ajax/newfolder.php | 8 +- apps/files/ajax/rawlist.php | 4 +- apps/files/ajax/rename.php | 6 +- apps/files/ajax/scan.php | 4 +- apps/files/ajax/upload.php | 14 ++-- apps/files_sharing/ajax/email.php | 4 +- apps/files_sharing/ajax/getitem.php | 4 +- apps/files_sharing/ajax/setpermissions.php | 2 +- apps/files_sharing/ajax/share.php | 2 +- apps/files_sharing/ajax/toggleresharing.php | 4 +- apps/files_sharing/ajax/unshare.php | 2 +- apps/files_sharing/ajax/userautocomplete.php | 6 +- apps/files_sharing/get.php | 2 +- apps/files_texteditor/ajax/loadfile.php | 8 +- apps/files_texteditor/ajax/mtime.php | 8 +- apps/files_texteditor/ajax/savefile.php | 10 +-- apps/files_versions/ajax/getVersions.php | 6 +- apps/files_versions/ajax/rollbackVersion.php | 2 +- apps/files_versions/ajax/togglesettings.php | 4 +- apps/gallery/ajax/createAlbum.php | 6 +- apps/gallery/ajax/galleryOp.php | 28 +++---- apps/gallery/ajax/sharing.php | 6 +- apps/gallery/ajax/thumbnail.php | 4 +- apps/gallery/lib/images_utils.php | 4 +- apps/media/ajax/api.php | 14 ++-- apps/media/ajax/autoupdate.php | 4 +- apps/media/tomahawk.php | 4 +- apps/user_migrate/ajax/export.php | 10 +-- lib/public/json.php | 94 ++++++++++++++++++++++ 107 files changed, 457 insertions(+), 363 deletions(-) mode change 100644 => 100755 apps/bookmarks/ajax/addBookmark.php mode change 100644 => 100755 apps/bookmarks/ajax/updateList.php mode change 100644 => 100755 apps/calendar/ajax/calendar/activation.php mode change 100644 => 100755 apps/calendar/ajax/calendar/delete.php mode change 100644 => 100755 apps/calendar/ajax/calendar/edit.form.php mode change 100644 => 100755 apps/calendar/ajax/calendar/edit.php mode change 100644 => 100755 apps/calendar/ajax/calendar/new.form.php mode change 100644 => 100755 apps/calendar/ajax/calendar/overview.php mode change 100644 => 100755 apps/calendar/ajax/event/delete.php mode change 100644 => 100755 apps/calendar/ajax/event/edit.php mode change 100644 => 100755 apps/calendar/ajax/event/move.php mode change 100644 => 100755 apps/calendar/ajax/event/new.php mode change 100644 => 100755 apps/calendar/ajax/event/resize.php mode change 100644 => 100755 apps/calendar/ajax/events.php mode change 100644 => 100755 apps/contacts/ajax/addbook.php mode change 100644 => 100755 apps/contacts/ajax/categories/list.php mode change 100644 => 100755 apps/contacts/ajax/chooseaddressbook.php mode change 100644 => 100755 apps/contacts/ajax/deletebook.php mode change 100644 => 100755 apps/contacts/ajax/editaddress.php mode change 100644 => 100755 apps/contacts/ajax/editaddressbook.php mode change 100644 => 100755 apps/contacts/ajax/loadintro.php mode change 100644 => 100755 apps/files/ajax/autocomplete.php mode change 100644 => 100755 apps/files/ajax/delete.php mode change 100644 => 100755 apps/files/ajax/move.php mode change 100644 => 100755 apps/files/ajax/newfile.php mode change 100644 => 100755 apps/files/ajax/newfolder.php mode change 100644 => 100755 apps/files/ajax/rename.php mode change 100644 => 100755 apps/files/ajax/scan.php mode change 100644 => 100755 apps/files_texteditor/ajax/loadfile.php mode change 100644 => 100755 apps/files_texteditor/ajax/mtime.php mode change 100644 => 100755 apps/gallery/lib/images_utils.php create mode 100644 lib/public/json.php (limited to 'apps/files/ajax') diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php old mode 100644 new mode 100755 index ceeb034ec9d..9241dc8ddf6 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -27,9 +27,9 @@ $RUNTIME_NOSETUPFS=true; // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('bookmarks'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('bookmarks'); require_once(OC::$APPSROOT . '/apps/bookmarks/bookmarksHelper.php'); $id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']); -OC_JSON::success(array('data' => $id)); \ No newline at end of file +OCP\JSON::success(array('data' => $id)); \ No newline at end of file diff --git a/apps/bookmarks/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php index 984a8593169..f40192943e4 100755 --- a/apps/bookmarks/ajax/delBookmark.php +++ b/apps/bookmarks/ajax/delBookmark.php @@ -27,8 +27,8 @@ $RUNTIME_NOSETUPFS=true; // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('bookmarks'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('bookmarks'); $params=array( htmlspecialchars_decode($_GET["url"]), @@ -59,4 +59,4 @@ $query = OC_DB::prepare(" $result = $query->execute(); // var_dump($params); -OC_JSON::success(array('data' => array())); +OCP\JSON::success(array('data' => array())); diff --git a/apps/bookmarks/ajax/editBookmark.php b/apps/bookmarks/ajax/editBookmark.php index 5bed9d08448..1b6d6d6ce44 100755 --- a/apps/bookmarks/ajax/editBookmark.php +++ b/apps/bookmarks/ajax/editBookmark.php @@ -27,8 +27,8 @@ $RUNTIME_NOSETUPFS=true; // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('bookmarks'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('bookmarks'); $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php index 6519de241b6..03d010637fc 100755 --- a/apps/bookmarks/ajax/recordClick.php +++ b/apps/bookmarks/ajax/recordClick.php @@ -27,8 +27,8 @@ $RUNTIME_NOSETUPFS=true; // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('bookmarks'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('bookmarks'); $query = OC_DB::prepare(" UPDATE *PREFIX*bookmarks diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php old mode 100644 new mode 100755 index 6aa951bbb65..c919a5fc439 --- a/apps/bookmarks/ajax/updateList.php +++ b/apps/bookmarks/ajax/updateList.php @@ -28,8 +28,8 @@ $RUNTIME_NOSETUPFS=true; // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('bookmarks'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('bookmarks'); //Filter for tag? @@ -47,4 +47,4 @@ if($sort == 'bookmarks_sorting_clicks') { $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $filterTag, true); -OC_JSON::success(array('data' => $bookmarks)); +OCP\JSON::success(array('data' => $bookmarks)); diff --git a/apps/calendar/ajax/calendar/activation.php b/apps/calendar/ajax/calendar/activation.php old mode 100644 new mode 100755 index c93a0495717..3523590aa27 --- a/apps/calendar/ajax/calendar/activation.php +++ b/apps/calendar/ajax/calendar/activation.php @@ -7,13 +7,13 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarid = $_POST['calendarid']; $calendar = OC_Calendar_App::getCalendar($calendarid);//access check OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); -OC_JSON::success(array( +OCP\JSON::success(array( 'active' => $calendar['active'], 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), )); diff --git a/apps/calendar/ajax/calendar/delete.php b/apps/calendar/ajax/calendar/delete.php old mode 100644 new mode 100755 index 4bef912333c..a36a0534650 --- a/apps/calendar/ajax/calendar/delete.php +++ b/apps/calendar/ajax/calendar/delete.php @@ -7,15 +7,15 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $cal = $_POST["calendarid"]; $calendar = OC_Calendar_App::getCalendar($cal); $del = OC_Calendar_Calendar::deleteCalendar($cal); if($del == true){ - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(array('error'=>'dberror')); + OCP\JSON::error(array('error'=>'dberror')); } ?> diff --git a/apps/calendar/ajax/calendar/edit.form.php b/apps/calendar/ajax/calendar/edit.form.php old mode 100644 new mode 100755 index d3f9629f1ae..17118c5165f --- a/apps/calendar/ajax/calendar/edit.form.php +++ b/apps/calendar/ajax/calendar/edit.form.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); diff --git a/apps/calendar/ajax/calendar/edit.php b/apps/calendar/ajax/calendar/edit.php old mode 100644 new mode 100755 index d3f9629f1ae..17118c5165f --- a/apps/calendar/ajax/calendar/edit.php +++ b/apps/calendar/ajax/calendar/edit.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = OC_Calendar_App::getCalendar($_GET['calendarid']); diff --git a/apps/calendar/ajax/calendar/new.form.php b/apps/calendar/ajax/calendar/new.form.php old mode 100644 new mode 100755 index 3de56460c2d..fa30b871e42 --- a/apps/calendar/ajax/calendar/new.form.php +++ b/apps/calendar/ajax/calendar/new.form.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); $calendar = array( 'id' => 'new', diff --git a/apps/calendar/ajax/calendar/new.php b/apps/calendar/ajax/calendar/new.php index b7136981633..4b8688e3d1d 100755 --- a/apps/calendar/ajax/calendar/new.php +++ b/apps/calendar/ajax/calendar/new.php @@ -9,17 +9,17 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); if(trim($_POST['name']) == ''){ - OC_JSON::error(array('message'=>'empty')); + OCP\JSON::error(array('message'=>'empty')); exit; } $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); foreach($calendars as $cal){ if($cal['displayname'] == $_POST['name']){ - OC_JSON::error(array('message'=>'namenotavailable')); + OCP\JSON::error(array('message'=>'namenotavailable')); exit; } } @@ -31,7 +31,7 @@ OC_Calendar_Calendar::setCalendarActive($calendarid, 1); $calendar = OC_Calendar_Calendar::find($calendarid); $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); -OC_JSON::success(array( +OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), )); diff --git a/apps/calendar/ajax/calendar/overview.php b/apps/calendar/ajax/calendar/overview.php old mode 100644 new mode 100755 index f66d1eae8f8..586bf3db814 --- a/apps/calendar/ajax/calendar/overview.php +++ b/apps/calendar/ajax/calendar/overview.php @@ -8,8 +8,8 @@ $l10n = OC_L10N::get('calendar'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $output = new OC_TEMPLATE("calendar", "part.choosecalendar"); $output -> printpage(); ?> diff --git a/apps/calendar/ajax/calendar/update.php b/apps/calendar/ajax/calendar/update.php index 1e35035fa48..408ac900912 100755 --- a/apps/calendar/ajax/calendar/update.php +++ b/apps/calendar/ajax/calendar/update.php @@ -9,17 +9,17 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); if(trim($_POST['name']) == ''){ - OC_JSON::error(array('message'=>'empty')); + OCP\JSON::error(array('message'=>'empty')); exit; } $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); foreach($calendars as $cal){ if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']){ - OC_JSON::error(array('message'=>'namenotavailable')); + OCP\JSON::error(array('message'=>'namenotavailable')); exit; } } @@ -32,7 +32,7 @@ OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); $tmpl->assign('calendar', $calendar); -OC_JSON::success(array( +OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), )); diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php index a8e62f64a5b..93e8c50954a 100755 --- a/apps/calendar/ajax/categories/rescan.php +++ b/apps/calendar/ajax/categories/rescan.php @@ -7,15 +7,15 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.print_r($element, true)); } function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -39,4 +39,4 @@ if(count($events) == 0) { OC_Calendar_App::scanCategories($events); $categories = OC_Calendar_App::getCategoryOptions(); -OC_JSON::success(array('data' => array('categories'=>$categories))); +OCP\JSON::success(array('data' => array('categories'=>$categories))); diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index a637e62aad1..2c2d09ccb12 100755 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -5,8 +5,8 @@ * later. * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $view = $_GET['v']; switch($view){ case 'agendaWeek': @@ -14,9 +14,9 @@ switch($view){ case 'list': break; default: - OC_JSON::error(array('message'=>'unexspected parameter: ' . $view)); + OCP\JSON::error(array('message'=>'unexspected parameter: ' . $view)); exit; } OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'currentview', $view); -OC_JSON::success(); +OCP\JSON::success(); ?> diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php old mode 100644 new mode 100755 index 3b726651641..cb30621af4d --- a/apps/calendar/ajax/event/delete.php +++ b/apps/calendar/ajax/event/delete.php @@ -7,14 +7,14 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $id = $_POST['id']; $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); if($access != 'owner' && $access != 'rw'){ - OC_JSON::error(array('message'=>'permission denied')); + OCP\JSON::error(array('message'=>'permission denied')); exit; } $result = OC_Calendar_Object::delete($id); -OC_JSON::success(); +OCP\JSON::success(); diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 675a417eba8..91d07d3897a 100755 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -11,13 +11,13 @@ if(!OCP\User::isLoggedIn()) { die(''); } -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkAppEnabled('calendar'); $id = $_GET['id']; $data = OC_Calendar_App::getEventObject($id, true, true); if(!$data){ - OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); + OCP\JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); exit; } $access = OC_Calendar_App::getaccess($id, OC_Calendar_Share::EVENT); diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php old mode 100644 new mode 100755 index 172488f6241..e615fb093de --- a/apps/calendar/ajax/event/edit.php +++ b/apps/calendar/ajax/event/edit.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $id = $_POST['id']; @@ -21,14 +21,14 @@ if(!array_key_exists('calendar', $_POST)){ $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); if($access != 'owner' && $access != 'rw'){ - OC_JSON::error(array('message'=>'permission denied')); + OCP\JSON::error(array('message'=>'permission denied')); exit; } $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ //show validate errors - OC_JSON::error($errarr); + OCP\JSON::error($errarr); exit; }else{ $data = OC_Calendar_App::getEventObject($id, false, false); @@ -41,6 +41,6 @@ if($errarr){ if ($data['calendarid'] != $cal) { OC_Calendar_Object::moveToCalendar($id, $cal); } - OC_JSON::success(); + OCP\JSON::success(); } ?> diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php old mode 100644 new mode 100755 index 75d174c13e1..8added69143 --- a/apps/calendar/ajax/event/move.php +++ b/apps/calendar/ajax/event/move.php @@ -6,12 +6,12 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); $id = $_POST['id']; $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); if($access != 'owner' && $access != 'rw'){ - OC_JSON::error(array('message'=>'permission denied')); + OCP\JSON::error(array('message'=>'permission denied')); exit; } $vcalendar = OC_Calendar_App::getVCalendar($id, false, false); @@ -43,4 +43,4 @@ $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC); $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); +OCP\JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php index 376149b57c3..42cdb81642e 100755 --- a/apps/calendar/ajax/event/new.form.php +++ b/apps/calendar/ajax/event/new.form.php @@ -11,10 +11,10 @@ if(!OCP\User::isLoggedIn()) { die(''); } -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkAppEnabled('calendar'); if (!isset($_POST['start'])){ - OC_JSON::error(); + OCP\JSON::error(); die; } $start = $_POST['start']; diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php old mode 100644 new mode 100755 index 5e8c305e97a..72d57be03bf --- a/apps/calendar/ajax/event/new.php +++ b/apps/calendar/ajax/event/new.php @@ -8,18 +8,18 @@ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ //show validate errors - OC_JSON::error($errarr); + OCP\JSON::error($errarr); exit; }else{ $cal = $_POST['calendar']; $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST); $result = OC_Calendar_Object::add($cal, $vcalendar->serialize()); - OC_JSON::success(); + OCP\JSON::success(); } ?> diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php old mode 100644 new mode 100755 index 260b6914426..0dc0a5fca7f --- a/apps/calendar/ajax/event/resize.php +++ b/apps/calendar/ajax/event/resize.php @@ -6,13 +6,13 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); $id = $_POST['id']; $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); if($access != 'owner' && $access != 'rw'){ - OC_JSON::error(array('message'=>'permission denied')); + OCP\JSON::error(array('message'=>'permission denied')); exit; } @@ -35,4 +35,4 @@ $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC); OC_Calendar_Object::edit($id, $vcalendar->serialize()); $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); +OCP\JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php old mode 100644 new mode 100755 index 8adaa4c98f3..2499c5163a2 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -9,8 +9,8 @@ require_once('when/When.php'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $start = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['start']):new DateTime('@' . $_GET['start']); $end = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['end']):new DateTime('@' . $_GET['end']); @@ -21,5 +21,5 @@ $output = array(); foreach($events as $event){ $output[] = OC_Calendar_App::generateEventOutput($event, $start, $end); } -OC_JSON::encodedPrint($output); +OCP\JSON::encodedPrint($output); ?> diff --git a/apps/calendar/ajax/import/dialog.php b/apps/calendar/ajax/import/dialog.php index 9ee989c0dee..e686066a993 100755 --- a/apps/calendar/ajax/import/dialog.php +++ b/apps/calendar/ajax/import/dialog.php @@ -7,7 +7,7 @@ */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); $tmpl = new OC_Template('calendar', 'part.import'); $tmpl->assign('path', $_POST['path']); diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index 43dfb5493fc..202af1eb46e 100755 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -7,7 +7,7 @@ */ //check for calendar rights or create new one ob_start(); -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); $nl="\r\n"; $comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); @@ -24,7 +24,7 @@ if($_POST['method'] == 'new'){ }else{ $calendar = OC_Calendar_App::getCalendar($_POST['id']); if($calendar['userid'] != OCP\USER::getUser()){ - OC_JSON::error(); + OCP\JSON::error(); exit(); } $id = $_POST['id']; @@ -126,4 +126,4 @@ sleep(3); if(is_writable('import_tmp/')){ unlink($progressfile); } -OC_JSON::success(); +OCP\JSON::success(); diff --git a/apps/calendar/ajax/settings/getfirstday.php b/apps/calendar/ajax/settings/getfirstday.php index dfc8b304b69..23b71bba043 100755 --- a/apps/calendar/ajax/settings/getfirstday.php +++ b/apps/calendar/ajax/settings/getfirstday.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); $firstday = OCP\Config::getUserValue( OCP\USER::getUser(), 'calendar', 'firstday', 'mo'); -OC_JSON::encodedPrint(array('firstday' => $firstday)); +OCP\JSON::encodedPrint(array('firstday' => $firstday)); ?> diff --git a/apps/calendar/ajax/settings/gettimezonedetection.php b/apps/calendar/ajax/settings/gettimezonedetection.php index be01807bbb4..6bc9a07a1e9 100755 --- a/apps/calendar/ajax/settings/gettimezonedetection.php +++ b/apps/calendar/ajax/settings/gettimezonedetection.php @@ -6,6 +6,6 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); -OC_JSON::success(array('detection' => OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection'))); \ No newline at end of file +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); +OCP\JSON::success(array('detection' => OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection'))); \ No newline at end of file diff --git a/apps/calendar/ajax/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php index 19aa778472d..13092777b78 100755 --- a/apps/calendar/ajax/settings/guesstimezone.php +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); $l = OC_L10N::get('calendar'); @@ -18,10 +18,10 @@ $lng = $_GET['long']; $timezone = OC_Geo::timezone($lat, $lng); if($timezone == OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone')){ - OC_JSON::success(); + OCP\JSON::success(); exit; } OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezone', $timezone); $message = array('message'=> $l->t('New Timezone:') . $timezone); -OC_JSON::success($message); +OCP\JSON::success($message); ?> \ No newline at end of file diff --git a/apps/calendar/ajax/settings/setfirstday.php b/apps/calendar/ajax/settings/setfirstday.php index 0c6ab695365..373eeee7968 100755 --- a/apps/calendar/ajax/settings/setfirstday.php +++ b/apps/calendar/ajax/settings/setfirstday.php @@ -6,12 +6,12 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); if(isset($_POST["firstday"])){ OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'firstday', $_POST["firstday"]); - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(); + OCP\JSON::error(); } ?> diff --git a/apps/calendar/ajax/settings/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php index d648545d9ca..eae7be54e80 100755 --- a/apps/calendar/ajax/settings/settimeformat.php +++ b/apps/calendar/ajax/settings/settimeformat.php @@ -6,12 +6,12 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); if(isset($_POST["timeformat"])){ OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(); + OCP\JSON::error(); } ?> diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php index abe14bd0ec7..d2797a08aae 100755 --- a/apps/calendar/ajax/settings/settimezone.php +++ b/apps/calendar/ajax/settings/settimezone.php @@ -12,16 +12,16 @@ $l=OC_L10N::get('calendar'); // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); // Get data if( isset( $_POST['timezone'] ) ){ $timezone=$_POST['timezone']; OCP\Config::setUserValue( OCP\USER::getUser(), 'calendar', 'timezone', $timezone ); - OC_JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); + OCP\JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); }else{ - OC_JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); + OCP\JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); } ?> diff --git a/apps/calendar/ajax/settings/timeformat.php b/apps/calendar/ajax/settings/timeformat.php index dbcfcb29b42..809164e870a 100755 --- a/apps/calendar/ajax/settings/timeformat.php +++ b/apps/calendar/ajax/settings/timeformat.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); $timeformat = OCP\Config::getUserValue( OCP\USER::getUser(), 'calendar', 'timeformat', "24"); -OC_JSON::encodedPrint(array("timeformat" => $timeformat)); +OCP\JSON::encodedPrint(array("timeformat" => $timeformat)); ?> diff --git a/apps/calendar/ajax/settings/timezonedetection.php b/apps/calendar/ajax/settings/timezonedetection.php index 8cb375183bb..ba5f2af5fd9 100755 --- a/apps/calendar/ajax/settings/timezonedetection.php +++ b/apps/calendar/ajax/settings/timezonedetection.php @@ -6,15 +6,15 @@ * See the COPYING-README file. */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('calendar'); if(array_key_exists('timezonedetection', $_POST)){ if($_POST['timezonedetection'] == 'on'){ OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'true'); }else{ OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'false'); } - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(); + OCP\JSON::error(); } \ No newline at end of file diff --git a/apps/calendar/ajax/share/activation.php b/apps/calendar/ajax/share/activation.php index 5c2fe8efd13..5526e5230f4 100755 --- a/apps/calendar/ajax/share/activation.php +++ b/apps/calendar/ajax/share/activation.php @@ -9,4 +9,4 @@ require_once('../../../../lib/base.php'); $id = strip_tags($_GET['id']); $activation = strip_tags($_GET['activation']); OC_Calendar_Share::set_active(OCP\USER::getUser(), $id, $activation); -OC_JSON::success(); \ No newline at end of file +OCP\JSON::success(); \ No newline at end of file diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php index 431ef7964b6..e4a4f186ab0 100755 --- a/apps/calendar/ajax/share/changepermission.php +++ b/apps/calendar/ajax/share/changepermission.php @@ -14,7 +14,7 @@ switch($idtype){ case 'event': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } $sharewith = $_GET['sharewith']; @@ -25,16 +25,16 @@ switch($sharetype){ case 'public': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } if($sharetype == 'user' && !OCP\User::userExists($sharewith)){ - OC_JSON::error(array('message'=>'user not found')); + OCP\JSON::error(array('message'=>'user not found')); exit; } if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ - OC_JSON::error(array('message'=>'group not found')); + OCP\JSON::error(array('message'=>'group not found')); exit; } $success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT)); -OC_JSON::success(); \ No newline at end of file +OCP\JSON::success(); \ No newline at end of file diff --git a/apps/calendar/ajax/share/dropdown.php b/apps/calendar/ajax/share/dropdown.php index 988e18c0b03..bac487f0d0b 100755 --- a/apps/calendar/ajax/share/dropdown.php +++ b/apps/calendar/ajax/share/dropdown.php @@ -10,7 +10,7 @@ $user = OCP\USER::getUser(); $calid = $_GET['calid']; $calendar = OC_Calendar_Calendar::find($calid); if($calendar['userid'] != $user){ - OC_JSON::error(); + OCP\JSON::error(); exit; } $tmpl = new OC_Template('calendar', 'share.dropdown'); diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php index 39d97522338..3ce2bf1e217 100755 --- a/apps/calendar/ajax/share/share.php +++ b/apps/calendar/ajax/share/share.php @@ -13,15 +13,15 @@ switch($idtype){ case 'event': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } if($idtype == 'calendar' && !OC_Calendar_App::getCalendar($id)){ - OC_JSON::error(array('message'=>'permission denied')); + OCP\JSON::error(array('message'=>'permission denied')); exit; } if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){ - OC_JSON::error(array('message'=>'permission denied')); + OCP\JSON::error(array('message'=>'permission denied')); exit; } $sharewith = $_GET['sharewith']; @@ -32,28 +32,28 @@ switch($sharetype){ case 'public': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } if($sharetype == 'user' && !OCP\User::userExists($sharewith)){ - OC_JSON::error(array('message'=>'user not found')); + OCP\JSON::error(array('message'=>'user not found')); exit; } if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ - OC_JSON::error(array('message'=>'group not found')); + OCP\JSON::error(array('message'=>'group not found')); exit; } if($sharetype == 'user' && OCP\USER::getUser() == $sharewith){ - OC_JSON::error(array('meesage'=>'you can not share with yourself')); + OCP\JSON::error(array('meesage'=>'you can not share with yourself')); } $success = OC_Calendar_Share::share(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT)); if($success){ if($sharetype == 'public'){ - OC_JSON::success(array('message'=>$success)); + OCP\JSON::success(array('message'=>$success)); }else{ - OC_JSON::success(array('message'=>'shared')); + OCP\JSON::success(array('message'=>'shared')); } }else{ - OC_JSON::error(array('message'=>'can not share')); + OCP\JSON::error(array('message'=>'can not share')); exit; } \ No newline at end of file diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php index e5676c72f31..cbd5ed8e505 100755 --- a/apps/calendar/ajax/share/unshare.php +++ b/apps/calendar/ajax/share/unshare.php @@ -13,7 +13,7 @@ switch($idtype){ case 'event': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } $sharewith = $_GET['sharewith']; @@ -24,20 +24,20 @@ switch($sharetype){ case 'public': break; default: - OC_JSON::error(array('message'=>'unexspected parameter')); + OCP\JSON::error(array('message'=>'unexspected parameter')); exit; } if($sharetype == 'user' && !OCP\User::userExists($sharewith)){ - OC_JSON::error(array('message'=>'user not found')); + OCP\JSON::error(array('message'=>'user not found')); exit; }elseif($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ - OC_JSON::error(array('message'=>'group not found')); + OCP\JSON::error(array('message'=>'group not found')); exit; } $success = OC_Calendar_Share::unshare(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT)); if($success){ - OC_JSON::success(); + OCP\JSON::success(); }else{ - OC_JSON::error(array('message'=>'can not unshare')); + OCP\JSON::error(array('message'=>'can not unshare')); exit; } \ No newline at end of file diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 8e2679a43f4..e8fdbe8c78a 100755 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -106,7 +106,7 @@ class OC_Calendar_App{ public static function isNotModified($vevent, $lastmodified){ $last_modified = $vevent->__get('LAST-MODIFIED'); if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){ - OC_JSON::error(array('modified'=>true)); + OCP\JSON::error(array('modified'=>true)); exit; } return true; diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php index b45d1a6ccbe..388a3b5438c 100755 --- a/apps/contacts/ajax/activation.php +++ b/apps/contacts/ajax/activation.php @@ -8,19 +8,19 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $bookid = $_POST['bookid']; $book = OC_Contacts_App::getAddressbook($bookid);// is owner access check if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { OCP\Util::writeLog('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR); - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')))); exit(); } -OC_JSON::success(array( +OCP\JSON::success(array( 'active' => OC_Contacts_Addressbook::isActive($bookid), 'bookid' => $bookid, 'book' => $book, diff --git a/apps/contacts/ajax/addbook.php b/apps/contacts/ajax/addbook.php old mode 100644 new mode 100755 index f466d57e12e..254af1c3f50 --- a/apps/contacts/ajax/addbook.php +++ b/apps/contacts/ajax/addbook.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $book = array( 'id' => 'new', 'displayname' => '', diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php index d87cbabe819..dc083df1fa5 100755 --- a/apps/contacts/ajax/addcontact.php +++ b/apps/contacts/ajax/addcontact.php @@ -23,7 +23,7 @@ // Init owncloud function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/addcontact.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -32,8 +32,8 @@ function debug($msg) { } // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.$element); @@ -55,9 +55,9 @@ $vcard->setString('N',$n); $id = OC_Contacts_VCard::add($aid,$vcard); if(!$id) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR); exit(); } -OC_JSON::success(array('data' => array( 'id' => $id ))); +OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 8623c6fdca7..bf23df67585 100755 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -24,8 +24,8 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; @@ -37,7 +37,7 @@ $vcard = OC_Contacts_App::getContactVCard($id); if(!is_array($value)){ $value = trim($value); if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'NICKNAME', 'NOTE'))) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add empty property.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add empty property.')))); exit(); } } elseif($name === 'ADR') { // only add if non-empty elements. @@ -49,7 +49,7 @@ if(!is_array($value)){ } } if($empty) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.')))); exit(); } } @@ -59,7 +59,7 @@ $current = $vcard->select($name); foreach($current as $item) { $tmpvalue = (is_array($value)?implode(';', $value):$value); if($tmpvalue == $item->value) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); OCP\Util::writeLog('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OCP\Util::DEBUG); exit(); } @@ -117,9 +117,9 @@ foreach ($parameters as $key=>$element) { $checksum = md5($vcard->children[$line]->serialize()); if(!OC_Contacts_VCard::edit($id,$vcard)) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.')))); OCP\Util::writeLog('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OCP\Util::ERROR); exit(); } -OC_JSON::success(array('data' => array( 'checksum' => $checksum ))); +OCP\JSON::success(array('data' => array( 'checksum' => $checksum ))); diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php index c6b753a73b5..846af300de8 100755 --- a/apps/contacts/ajax/categories/categoriesfor.php +++ b/apps/contacts/ajax/categories/categoriesfor.php @@ -7,12 +7,12 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $id = isset($_GET['id'])?$_GET['id']:null; if(is_null($id)) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided')))); exit(); } $vcard = OC_Contacts_App::getContactVCard( $id ); @@ -20,9 +20,9 @@ foreach($vcard->children as $property){ //OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG); if($property->name == 'CATEGORIES') { $checksum = md5($property->serialize()); - OC_JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum))); + OCP\JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum))); exit(); } } -OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.')))); +OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.')))); ?> diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php index d1099da044a..bee2dbe3f6b 100755 --- a/apps/contacts/ajax/categories/delete.php +++ b/apps/contacts/ajax/categories/delete.php @@ -7,15 +7,15 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.print_r($element, true)); } function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -55,6 +55,6 @@ $catman = new OC_VCategories('contacts'); $catman->delete($categories, $cards); debug('After delete: '.print_r($catman->categories(), true)); OC_Contacts_VCard::updateDataByID($cards); -OC_JSON::success(array('data' => array('categories'=>$catman->categories()))); +OCP\JSON::success(array('data' => array('categories'=>$catman->categories()))); ?> diff --git a/apps/contacts/ajax/categories/list.php b/apps/contacts/ajax/categories/list.php old mode 100644 new mode 100755 index 98c1c705180..3ae7635390c --- a/apps/contacts/ajax/categories/list.php +++ b/apps/contacts/ajax/categories/list.php @@ -7,11 +7,11 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $categories = OC_Contacts_App::getCategories(); -OC_JSON::success(array('data' => array('categories'=>$categories))); +OCP\JSON::success(array('data' => array('categories'=>$categories))); ?> diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php index 37a19fbce4a..84a67dec0b1 100755 --- a/apps/contacts/ajax/categories/rescan.php +++ b/apps/contacts/ajax/categories/rescan.php @@ -7,15 +7,15 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); foreach ($_POST as $key=>$element) { debug('_POST: '.$key.'=>'.print_r($element, true)); } function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -39,6 +39,6 @@ if(count($contacts) == 0) { OC_Contacts_App::scanCategories($contacts); $categories = OC_Contacts_App::getCategories(); -OC_JSON::success(array('data' => array('categories'=>$categories))); +OCP\JSON::success(array('data' => array('categories'=>$categories))); ?> diff --git a/apps/contacts/ajax/chooseaddressbook.php b/apps/contacts/ajax/chooseaddressbook.php old mode 100644 new mode 100755 index b47c872e9aa..2fe55606d1d --- a/apps/contacts/ajax/chooseaddressbook.php +++ b/apps/contacts/ajax/chooseaddressbook.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $output = new OC_TEMPLATE("contacts", "part.chooseaddressbook"); $output -> printpage(); diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php index aa6aca4562a..0cbd55258de 100755 --- a/apps/contacts/ajax/contactdetails.php +++ b/apps/contacts/ajax/contactdetails.php @@ -23,14 +23,14 @@ // Init owncloud function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG); exit(); } // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $id = isset($_GET['id'])?$_GET['id']:null; if(is_null($id)) { @@ -69,4 +69,4 @@ if(isset($details['PHOTO'])) { } $details['id'] = $id; OC_Contacts_App::setLastModifiedHeader($vcard); -OC_JSON::success(array('data' => $details)); +OCP\JSON::success(array('data' => $details)); diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index f0e7dde088c..93e618a0800 100755 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); $contacts = OC_Contacts_VCard::all($ids); @@ -16,5 +16,5 @@ $tmpl = new OC_TEMPLATE("contacts", "part.contacts"); $tmpl->assign('contacts', $contacts); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'page' => $page ))); +OCP\JSON::success(array('data' => array( 'page' => $page ))); ?> diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index 3a331131a15..772232b67d7 100755 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -9,32 +9,32 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $userid = OCP\USER::getUser(); $name = trim(strip_tags($_POST['name'])); if(!$name) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR); exit(); } $bookid = OC_Contacts_Addressbook::add($userid, $name, null); if(!$bookid) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR); exit(); } if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR); //exit(); } $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); -OC_JSON::success(array( +OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), 'addressbook' => $addressbook, )); diff --git a/apps/contacts/ajax/cropphoto.php b/apps/contacts/ajax/cropphoto.php index 09bdbbc439a..125dd107602 100755 --- a/apps/contacts/ajax/cropphoto.php +++ b/apps/contacts/ajax/cropphoto.php @@ -24,8 +24,8 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $tmp_path = $_GET['tmp_path']; $id = $_GET['id']; @@ -35,4 +35,4 @@ $tmpl->assign('tmp_path', $tmp_path); $tmpl->assign('id', $id); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'page' => $page ))); +OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php index 488f064836b..d8afa060b1e 100755 --- a/apps/contacts/ajax/currentphoto.php +++ b/apps/contacts/ajax/currentphoto.php @@ -24,11 +24,11 @@ // Check if we are a user // Firefox and Konqueror tries to download application/json for me. --Arthur -OC_JSON::setContentTypeHeader('text/plain'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::setContentTypeHeader('text/plain'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR); exit(); } @@ -55,7 +55,7 @@ if( is_null($contact)) { } if($image->valid()) { if($image->save($tmpfname)) { - OC_JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpfname))); + OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpfname))); exit(); } else { bailOut(OC_Contacts_App::$l10n->t('Error saving temporary file.')); diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php old mode 100644 new mode 100755 index b80df526f95..bcf6aa44329 --- a/apps/contacts/ajax/deletebook.php +++ b/apps/contacts/ajax/deletebook.php @@ -24,12 +24,12 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); //$id = $_GET['id']; $id = $_POST['id']; OC_Contacts_App::getAddressbook( $id ); // is owner access check OC_Contacts_Addressbook::delete($id); -OC_JSON::success(array('data' => array( 'id' => $id ))); +OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php index 84526e9b13b..46fd8252d47 100755 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -20,7 +20,7 @@ * */ function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -29,8 +29,8 @@ function bailOut($msg) { // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $id = isset($_GET['id'])?$_GET['id']:null; if(!$id) { @@ -39,4 +39,4 @@ if(!$id) { $card = OC_Contacts_App::getContactObject( $id ); OC_Contacts_VCard::delete($id); -OC_JSON::success(array('data' => array( 'id' => $id ))); +OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 4c753816218..9bb1208cdd1 100755 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -24,8 +24,8 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $id = $_GET['id']; $checksum = $_GET['checksum']; @@ -33,16 +33,16 @@ $checksum = $_GET['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); if(is_null($line)){ - OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); + OCP\JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); exit(); } unset($vcard->children[$line]); if(!OC_Contacts_VCard::edit($id,$vcard)) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR); exit(); } -OC_JSON::success(array('data' => array( 'id' => $id ))); +OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php old mode 100644 new mode 100755 index 73f34ef5c6c..4044eb5a359 --- a/apps/contacts/ajax/editaddress.php +++ b/apps/contacts/ajax/editaddress.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $id = $_GET['id']; $checksum = isset($_GET['checksum'])?$_GET['checksum']:''; diff --git a/apps/contacts/ajax/editaddressbook.php b/apps/contacts/ajax/editaddressbook.php old mode 100644 new mode 100755 index ef797778d95..fe1806a7b8a --- a/apps/contacts/ajax/editaddressbook.php +++ b/apps/contacts/ajax/editaddressbook.php @@ -7,8 +7,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']); $tmpl = new OC_Template("contacts", "part.editaddressbook"); $tmpl->assign('new', false); diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php index 331aa4c7742..155bee70a7f 100755 --- a/apps/contacts/ajax/editname.php +++ b/apps/contacts/ajax/editname.php @@ -7,10 +7,10 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG); exit(); } diff --git a/apps/contacts/ajax/importaddressbook.php b/apps/contacts/ajax/importaddressbook.php index dc251de201a..bc02e814f5b 100755 --- a/apps/contacts/ajax/importaddressbook.php +++ b/apps/contacts/ajax/importaddressbook.php @@ -7,7 +7,7 @@ */ require_once('../../../lib/base.php'); -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); diff --git a/apps/contacts/ajax/importdialog.php b/apps/contacts/ajax/importdialog.php index bd195023dd2..7a564ccec83 100755 --- a/apps/contacts/ajax/importdialog.php +++ b/apps/contacts/ajax/importdialog.php @@ -7,7 +7,7 @@ */ -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); $tmpl = new OC_Template('contacts', 'part.import'); $tmpl->assign('path', $_POST['path']); diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php index 90ba3f66097..047db4d940c 100755 --- a/apps/contacts/ajax/loadcard.php +++ b/apps/contacts/ajax/loadcard.php @@ -23,7 +23,7 @@ // Init owncloud function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/loadcard.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -35,8 +35,8 @@ function debug($msg) { // } // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); @@ -58,4 +58,4 @@ $tmpl->assign('email_types',$email_types); $tmpl->assign('id',''); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'page' => $page ))); +OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php old mode 100644 new mode 100755 index 1aa03a62f38..8ad828ebba3 --- a/apps/contacts/ajax/loadintro.php +++ b/apps/contacts/ajax/loadintro.php @@ -21,11 +21,11 @@ */ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $tmpl = new OC_Template('contacts','part.no_contacts'); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'page' => $page ))); +OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php index 8d40669a5b3..9913fe13e11 100755 --- a/apps/contacts/ajax/loadphoto.php +++ b/apps/contacts/ajax/loadphoto.php @@ -22,15 +22,15 @@ // Init owncloud // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); // foreach ($_POST as $key=>$element) { // OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG); // } function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -59,5 +59,5 @@ if($refresh) { $tmpl->assign('refresh', 1); } $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum))); +OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum))); ?> diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php index 8c6b95c5563..0fd978e325a 100755 --- a/apps/contacts/ajax/oc_photo.php +++ b/apps/contacts/ajax/oc_photo.php @@ -24,11 +24,11 @@ require_once('lib/base.php'); // Check if we are a user // Firefox and Konqueror tries to download application/json for me. --Arthur -OC_JSON::setContentTypeHeader('text/plain'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::setContentTypeHeader('text/plain'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR); exit(); } @@ -66,7 +66,7 @@ if(!$image->fixOrientation()) { // No fatal error so we don't bail out. debug('Couldn\'t save correct image orientation: '.$tmpfname); } if($image->save($tmpfname)) { - OC_JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpfname))); + OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpfname))); exit(); } else { bailOut('Couldn\'t save temporary image: '.$tmpfname); diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php index 958f9fd926c..5418e26cd10 100755 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -26,18 +26,18 @@ OCP\Util::writeLog('contacts','ajax/savecrop.php: Huzzah!!!', OCP\Util::DEBUG); // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); // foreach ($_POST as $key=>$element) { // OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG); // } // Firefox and Konqueror tries to download application/json for me. --Arthur -OC_JSON::setContentTypeHeader('text/plain'); +OCP\JSON::setContentTypeHeader('text/plain'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -109,7 +109,7 @@ if(file_exists($tmp_path)) { $tmpl->assign('width', $image->width()); $tmpl->assign('height', $image->height()); $page = $tmpl->fetchPage(); - OC_JSON::success(array('data' => array('page'=>$page, 'tmp'=>$tmpfname))); + OCP\JSON::success(array('data' => array('page'=>$page, 'tmp'=>$tmpfname))); exit(); } else { if(file_exists($tmpfname)) { diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index b8b4a422cf2..0cd6d5b36fb 100755 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -24,11 +24,11 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -154,4 +154,4 @@ if(!OC_Contacts_VCard::edit($id,$vcard)) { exit(); } -OC_JSON::success(array('data' => array( 'line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'] ))); +OCP\JSON::success(array('data' => array( 'line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'] ))); diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index b016cf92939..13f1c15ac23 100755 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -9,27 +9,27 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); $bookid = $_POST['id']; OC_Contacts_App::getAddressbook($bookid); // is owner access check $name = trim(strip_tags($_POST['name'])); if(!$name) { - OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); + OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR); exit(); } if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { - OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); + OCP\JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR); //exit(); } if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { - OC_JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); + OCP\JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR); //exit(); } @@ -37,7 +37,7 @@ if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl->assign('addressbook', $addressbook); -OC_JSON::success(array( +OCP\JSON::success(array( 'page' => $tmpl->fetchPage(), 'addressbook' => $addressbook, )); diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php index 51ae949b680..947d4670a29 100755 --- a/apps/contacts/ajax/uploadimport.php +++ b/apps/contacts/ajax/uploadimport.php @@ -23,10 +23,10 @@ require_once('../../../lib/base.php'); // Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR); exit(); } @@ -42,7 +42,7 @@ $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : fals if($fn) { if($view->file_put_contents('/'.$tmpfile, file_get_contents('php://input'))) { debug($fn.' uploaded'); - OC_JSON::success(array('data' => array('path'=>'', 'file'=>$tmpfile))); + OCP\JSON::success(array('data' => array('path'=>'', 'file'=>$tmpfile))); exit(); } else { bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.')); @@ -52,7 +52,7 @@ if($fn) { // File input transfers are handled here if (!isset($_FILES['importfile'])) { OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG); - OC_JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' ))); + OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' ))); exit(); } $error = $_FILES['importfile']['error']; @@ -73,7 +73,7 @@ $tmpfname = tempnam("/tmp", "occOrig"); if(file_exists($file['tmp_name'])) { if($view->file_put_contents('/'.$tmpfile, file_get_contents($file['tmp_name']))) { debug($fn.' uploaded'); - OC_JSON::success(array('data' => array('path'=>'', 'file'=>$tmpfile))); + OCP\JSON::success(array('data' => array('path'=>'', 'file'=>$tmpfile))); } else { bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.')); } diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php index 1148c271dcd..99015e2d502 100755 --- a/apps/contacts/ajax/uploadphoto.php +++ b/apps/contacts/ajax/uploadphoto.php @@ -24,11 +24,11 @@ // Check if we are a user // Firefox and Konqueror tries to download application/json for me. --Arthur -OC_JSON::setContentTypeHeader('text/plain'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); +OCP\JSON::setContentTypeHeader('text/plain'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); + OCP\JSON::error(array('data' => array('message' => $msg))); OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG); exit(); } @@ -42,7 +42,7 @@ if ($fn) { // AJAX call if (!isset($_GET['id'])) { OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OCP\Util::DEBUG); - OC_JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' ))); + OCP\JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' ))); exit(); } $id = $_GET['id']; @@ -58,7 +58,7 @@ if ($fn) { debug('Couldn\'t save correct image orientation: '.$tmpfname); } if($image->save($tmpfname)) { - OC_JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpfname))); + OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpfname))); exit(); } else { bailOut('Couldn\'t save temporary image: '.$tmpfname); @@ -71,12 +71,12 @@ if ($fn) { if (!isset($_POST['id'])) { OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OCP\Util::DEBUG); - OC_JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' ))); + OCP\JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' ))); exit(); } if (!isset($_FILES['imagefile'])) { OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG); - OC_JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' ))); + OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' ))); exit(); } $error = $_FILES['imagefile']['error']; @@ -104,7 +104,7 @@ if(file_exists($file['tmp_name'])) { debug('Couldn\'t save correct image orientation: '.$tmpfname); } if($image->save($tmpfname)) { - OC_JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpfname))); + OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpfname))); exit(); } else { bailOut('Couldn\'t save temporary image: '.$tmpfname); diff --git a/apps/contacts/import.php b/apps/contacts/import.php index 2bcb40f7d42..346db5924c6 100755 --- a/apps/contacts/import.php +++ b/apps/contacts/import.php @@ -8,7 +8,7 @@ //check for addressbooks rights or create new one ob_start(); -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); $nl = "\n"; $progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; @@ -25,7 +25,7 @@ if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); } if(!$file) { - OC_JSON::error(array('message' => 'Import file was empty.')); + OCP\JSON::error(array('message' => 'Import file was empty.')); exit(); } error_log('File: '.$file); @@ -137,4 +137,4 @@ if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR); } } -OC_JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed))); +OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed))); diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index f4b9562605e..58cc7f03462 100755 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -20,11 +20,11 @@ class OC_Contacts_App { if( $addressbook === false || $addressbook['userid'] != OCP\USER::getUser()) { if ($addressbook === false) { OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR); - OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.')))); + OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.')))); } else { OCP\Util::writeLog('contacts', 'Addressbook('.$id.') is not from '.OCP\USER::getUser(), OCP\Util::ERROR); - OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); + OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); } exit(); } @@ -35,7 +35,7 @@ class OC_Contacts_App { $card = OC_Contacts_VCard::find( $id ); if( $card === false ) { OCP\Util::writeLog('contacts', 'Contact could not be found: '.$id, OCP\Util::ERROR); - OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.$id))); + OCP\JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.$id))); exit(); } diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index d7bf1fd8c3c..11d1db03108 100755 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -22,7 +22,7 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); //OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); diff --git a/apps/files/ajax/autocomplete.php b/apps/files/ajax/autocomplete.php old mode 100644 new mode 100755 index 8cdb6188a02..7ff34da96b3 --- a/apps/files/ajax/autocomplete.php +++ b/apps/files/ajax/autocomplete.php @@ -5,7 +5,7 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get data $query = $_GET['term']; @@ -51,6 +51,6 @@ if(OC_Filesystem::file_exists($base) and OC_Filesystem::is_dir($base)){ } } } -OC_JSON::encodedPrint($files); +OCP\JSON::encodedPrint($files); ?> diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php old mode 100644 new mode 100755 index d8a01d7acf1..ed155de0dc7 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -3,7 +3,7 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get data $dir = stripslashes($_GET["dir"]); @@ -21,9 +21,9 @@ foreach($files as $file) { } if($success) { - OC_JSON::success(array("data" => array( "dir" => $dir, "files" => $files ))); + OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files ))); } else { - OC_JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError ))); + OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError ))); } ?> diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 0bff5742ef4..520e54e708d 100755 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -6,7 +6,7 @@ $RUNTIME_APPTYPES=array('filesystem'); // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; @@ -41,6 +41,6 @@ $list = new OC_Template( "files", "part.list", "" ); $list->assign( "files", $files ); $data = array('files' => $list->fetchPage()); -OC_JSON::success(array('data' => $data)); +OCP\JSON::success(array('data' => $data)); ?> diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php old mode 100644 new mode 100755 index 0ad314f873c..945fe4e7b82 --- a/apps/files/ajax/move.php +++ b/apps/files/ajax/move.php @@ -3,7 +3,7 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get data $dir = stripslashes($_GET["dir"]); @@ -12,9 +12,9 @@ $target = stripslashes($_GET["target"]); if(OC_Files::move($dir,$file,$target,$file)){ - OC_JSON::success(array("data" => array( "dir" => $dir, "files" => $file ))); + OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file ))); }else{ - OC_JSON::error(array("data" => array( "message" => "Could not move $file" ))); + OCP\JSON::error(array("data" => array( "message" => "Could not move $file" ))); } ?> diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php old mode 100644 new mode 100755 index 472b577a32a..2712b54f063 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -3,7 +3,7 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get the params $dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : ''; @@ -12,13 +12,13 @@ $content = isset( $_POST['content'] ) ? $_POST['content'] : ''; $source = isset( $_POST['source'] ) ? stripslashes($_POST['source']) : ''; if($filename == '') { - OC_JSON::error(array("data" => array( "message" => "Empty Filename" ))); + OCP\JSON::error(array("data" => array( "message" => "Empty Filename" ))); exit(); } if($source){ if(substr($source,0,8)!='https://' and substr($source,0,7)!='http://'){ - OC_JSON::error(array("data" => array( "message" => "Not a valid source" ))); + OCP\JSON::error(array("data" => array( "message" => "Not a valid source" ))); exit(); } $sourceStream=fopen($source,'rb'); @@ -26,10 +26,10 @@ if($source){ $result=OC_Filesystem::file_put_contents($target,$sourceStream); if($result){ $mime=OC_Filesystem::getMimetype($target); - OC_JSON::success(array("data" => array('mime'=>$mime))); + OCP\JSON::success(array("data" => array('mime'=>$mime))); exit(); }else{ - OC_JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target ))); + OCP\JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target ))); exit(); } } @@ -39,9 +39,9 @@ if(OC_Files::newFile($dir, $filename, 'file')) { if($content){ OC_Filesystem::file_put_contents($dir.'/'.$filename,$content); } - OC_JSON::success(array("data" => array('content'=>$content))); + OCP\JSON::success(array("data" => array('content'=>$content))); exit(); } -OC_JSON::error(array("data" => array( "message" => "Error when creating the file" ))); +OCP\JSON::error(array("data" => array( "message" => "Error when creating the file" ))); diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php old mode 100644 new mode 100755 index 2aff95e5b35..512e0e1f6d9 --- a/apps/files/ajax/newfolder.php +++ b/apps/files/ajax/newfolder.php @@ -3,20 +3,20 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get the params $dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : ''; $foldername = isset( $_POST['foldername'] ) ? stripslashes($_POST['foldername']) : ''; if(trim($foldername) == '') { - OC_JSON::error(array("data" => array( "message" => "Empty Foldername" ))); + OCP\JSON::error(array("data" => array( "message" => "Empty Foldername" ))); exit(); } if(OC_Files::newFile($dir, stripslashes($foldername), 'dir')) { - OC_JSON::success(array("data" => array())); + OCP\JSON::success(array("data" => array())); exit(); } -OC_JSON::error(array("data" => array( "message" => "Error when creating the folder" ))); +OCP\JSON::error(array("data" => array( "message" => "Error when creating the folder" ))); diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php index 86119de2d1b..36dd35cc73e 100755 --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -7,7 +7,7 @@ $RUNTIME_APPTYPES=array('filesystem'); require_once('lib/template.php'); -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; @@ -21,6 +21,6 @@ foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){ $files[] = $i; } -OC_JSON::success(array('data' => $files)); +OCP\JSON::success(array('data' => $files)); ?> diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php old mode 100644 new mode 100755 index dc5d3962abd..e2fa3d54a61 --- a/apps/files/ajax/rename.php +++ b/apps/files/ajax/rename.php @@ -3,7 +3,7 @@ // Init owncloud -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get data $dir = stripslashes($_GET["dir"]); @@ -12,10 +12,10 @@ $newname = stripslashes($_GET["newname"]); // Delete if( OC_Files::move( $dir, $file, $dir, $newname )) { - OC_JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname ))); + OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname ))); } else{ - OC_JSON::error(array("data" => array( "message" => "Unable to rename file" ))); + OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" ))); } ?> diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php old mode 100644 new mode 100755 index a227dcc3ffc..d36366caf49 --- a/apps/files/ajax/scan.php +++ b/apps/files/ajax/scan.php @@ -20,12 +20,12 @@ if($force or !OC_FileCache::inCache('')){ OC_DB::commit(); $eventSource->send('success',true); }else{ - OC_JSON::success(array('data'=>array('done'=>true))); + OCP\JSON::success(array('data'=>array('done'=>true))); exit; } }else{ if($checkOnly){ - OC_JSON::success(array('data'=>array('done'=>false))); + OCP\JSON::success(array('data'=>array('done'=>false))); exit; } if(isset($eventSource)){ diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index ca64f58e14b..d6c799af32c 100755 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -4,12 +4,12 @@ // Firefox and Konqueror tries to download application/json for me. --Arthur -OC_JSON::setContentTypeHeader('text/plain'); +OCP\JSON::setContentTypeHeader('text/plain'); -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); if (!isset($_FILES['files'])) { - OC_JSON::error(array("data" => array( "message" => "No file was uploaded. Unknown error" ))); + OCP\JSON::error(array("data" => array( "message" => "No file was uploaded. Unknown error" ))); exit(); } foreach ($_FILES['files']['error'] as $error) { @@ -24,7 +24,7 @@ foreach ($_FILES['files']['error'] as $error) { UPLOAD_ERR_NO_TMP_DIR=>$l->t("Missing a temporary folder"), UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'), ); - OC_JSON::error(array("data" => array( "message" => $errors[$error] ))); + OCP\JSON::error(array("data" => array( "message" => $errors[$error] ))); exit(); } } @@ -38,7 +38,7 @@ foreach($files['size'] as $size){ $totalSize+=$size; } if($totalSize>OC_Filesystem::free_space('/')){ - OC_JSON::error(array("data" => array( "message" => "Not enough space available" ))); + OCP\JSON::error(array("data" => array( "message" => "Not enough space available" ))); exit(); } @@ -52,12 +52,12 @@ if(strpos($dir,'..') === false){ $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target)); } } - OC_JSON::encodedPrint($result); + OCP\JSON::encodedPrint($result); exit(); }else{ $error='invalid dir'; } -OC_JSON::error(array('data' => array('error' => $error, "file" => $fileName))); +OCP\JSON::error(array('data' => array('error' => $error, "file" => $fileName))); ?> diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php index 84202a23f5c..9eba203465e 100755 --- a/apps/files_sharing/ajax/email.php +++ b/apps/files_sharing/ajax/email.php @@ -1,6 +1,6 @@ "; $groups[] = ""; $users = array_merge($users, $groups); -OC_JSON::encodedPrint($users); +OCP\JSON::encodedPrint($users); ?> diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php index b17dc85c5ba..de3bc5f46dc 100755 --- a/apps/files_sharing/get.php +++ b/apps/files_sharing/get.php @@ -1,7 +1,7 @@ array('filecontents' => $filecontents, 'write' => 'true', 'mtime' => $mtime))); + OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'true', 'mtime' => $mtime))); } else { $mtime = OC_Filesystem::filemtime($path); $filecontents = OC_Filesystem::file_get_contents($path); - OC_JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'false', 'mtime' => $mtime))); + OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'write' => 'false', 'mtime' => $mtime))); } } else { - OC_JSON::error(array('data' => array( 'message' => 'Invalid file path supplied.'))); + OCP\JSON::error(array('data' => array( 'message' => 'Invalid file path supplied.'))); } \ No newline at end of file diff --git a/apps/files_texteditor/ajax/mtime.php b/apps/files_texteditor/ajax/mtime.php old mode 100644 new mode 100755 index 436592c383f..ee683722add --- a/apps/files_texteditor/ajax/mtime.php +++ b/apps/files_texteditor/ajax/mtime.php @@ -25,7 +25,7 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get the path from GET $path = isset($_GEt['path']) ? $_GET['path'] : ''; @@ -36,14 +36,14 @@ if($path != '') $mtime = OC_Filesystem::filemtime($path); if($mtime) { - OC_JSON::success(array('data' => array('path' => $path, 'mtime' => $mtime))); + OCP\JSON::success(array('data' => array('path' => $path, 'mtime' => $mtime))); } else { - OC_JSON::error(); + OCP\JSON::error(); } } else { - OC_JSON::error(); + OCP\JSON::error(); } \ No newline at end of file diff --git a/apps/files_texteditor/ajax/savefile.php b/apps/files_texteditor/ajax/savefile.php index 7c7fb90e7c6..4c260e237c5 100755 --- a/apps/files_texteditor/ajax/savefile.php +++ b/apps/files_texteditor/ajax/savefile.php @@ -25,7 +25,7 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); // Get paramteres $filecontents = $_POST['filecontents']; @@ -39,7 +39,7 @@ if($path != '' && $mtime != '') if($mtime != $filemtime) { // Then the file has changed since opening - OC_JSON::error(); + OCP\JSON::error(); OCP\Util::writeLog('files_texteditor',"File: ".$path." modified since opening.",OCP\Util::ERROR); } else @@ -53,16 +53,16 @@ if($path != '' && $mtime != '') clearstatcache(); // Get new mtime $newmtime = OC_Filesystem::filemtime($path); - OC_JSON::success(array('data' => array('mtime' => $newmtime))); + OCP\JSON::success(array('data' => array('mtime' => $newmtime))); } else { // Not writeable! - OC_JSON::error(array('data' => array( 'message' => 'Insufficient permissions'))); + OCP\JSON::error(array('data' => array( 'message' => 'Insufficient permissions'))); OCP\Util::writeLog('files_texteditor',"User does not have permission to write to file: ".$path,OCP\Util::ERROR); } } } else { - OC_JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied'))); + OCP\JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied'))); OCP\Util::writeLog('files_texteditor',"Invalid path supplied:".$path,OCP\Util::ERROR); } diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index d12cf368f18..5949c32ed16 100755 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -1,7 +1,7 @@ $_GET['album_name'])); +OCP\JSON::success(array('name' => $_GET['album_name'])); ?> diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index c302a3a734c..b9ca31901c3 100755 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -24,8 +24,8 @@ header('Content-type: text/html; charset=UTF-8') ; -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('gallery'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('gallery'); function handleRename($oldname, $newname) { OC_Gallery_Album::rename($oldname, $newname, OCP\USER::getUser()); @@ -61,16 +61,16 @@ function handleFilescan($cleanup) { if ($cleanup) OC_Gallery_Album::cleanup(); $pathlist = OC_Gallery_Scanner::find_paths(); sort($pathlist); - OC_JSON::success(array('paths' => $pathlist)); + OCP\JSON::success(array('paths' => $pathlist)); } function handleStoreSettings($root, $order) { if (!OC_Filesystem::file_exists($root)) { - OC_JSON::error(array('cause' => 'No such file or directory')); + OCP\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')); + OCP\JSON::error(array('cause' => $root . ' is not a directory')); return; } @@ -80,7 +80,7 @@ function handleStoreSettings($root, $order) { $rescan = $current_root==$root?'no':'yes'; OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'root', $root); OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'order', $order); - OC_JSON::success(array('rescan' => $rescan)); + OCP\JSON::success(array('rescan' => $rescan)); } function handleGetGallery($path) { @@ -121,7 +121,7 @@ function handleGetGallery($path) { $token = $row['token']; } - OC_JSON::success(array('albums'=>$a, 'photos'=>$p, 'shared' => $shared, 'recursive' => $recursive, 'token' => $token)); + OCP\JSON::success(array('albums'=>$a, 'photos'=>$p, 'shared' => $shared, 'recursive' => $recursive, 'token' => $token)); } function handleShare($path, $share, $recursive) { @@ -134,23 +134,23 @@ function handleShare($path, $share, $recursive) { if ($row = $r->fetchRow()) { $albumId = $row['album_id']; } else { - OC_JSON::error(array('cause' => 'Couldn\'t find requested gallery')); + OCP\JSON::error(array('cause' => 'Couldn\'t find requested gallery')); exit; } if ($share == false) { OC_Gallery_Sharing::remove($albumId); - OC_JSON::success(array('sharing' => false)); + OCP\JSON::success(array('sharing' => false)); } else { // share, yeah \o/ $r = OC_Gallery_Sharing::getEntryByAlbumId($albumId); if (($row = $r->fetchRow())) { // update entry OC_Gallery_Sharing::updateSharingByToken($row['token'], $recursive); - OC_JSON::success(array('sharing' => true, 'token' => $row['token'], 'recursive' => $recursive == 1 ? true : false )); + OCP\JSON::success(array('sharing' => true, 'token' => $row['token'], 'recursive' => $recursive == 1 ? true : false )); } else { // and new sharing entry $date = new DateTime(); $token = md5($owner . $date->getTimestamp()); OC_Gallery_Sharing::addShared($token, intval($albumId), $recursive); - OC_JSON::success(array('sharing' => true, 'token' => $token, 'recursive' => $recursive == 1 ? true : false )); + OCP\JSON::success(array('sharing' => true, 'token' => $token, 'recursive' => $recursive == 1 ? true : false )); } } } @@ -160,11 +160,11 @@ if ($_GET['operation']) { switch($_GET['operation']) { case 'rename': handleRename($_GET['oldname'], $_GET['newname']); - OC_JSON::success(array('newname' => $_GET['newname'])); + OCP\JSON::success(array('newname' => $_GET['newname'])); break; case 'remove': handleRemove($_GET['name']); - OC_JSON::success(); + OCP\JSON::success(); break; case 'get_covers': handleGetThumbnails(urldecode($_GET['albumname'])); @@ -182,7 +182,7 @@ if ($_GET['operation']) { handleShare($_GET['path'], $_GET['share'] == 'true' ? true : false, $_GET['recursive']); break; default: - OC_JSON::error(array('cause' => 'Unknown operation')); + OCP\JSON::error(array('cause' => 'Unknown operation')); } } ?> diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php index a1af75ad461..1223320120b 100755 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -24,7 +24,7 @@ if (!isset($_GET['token']) || !isset($_GET['operation'])) { - OC_JSON::error(array('cause' => 'Not enought arguments')); + OCP\JSON::error(array('cause' => 'Not enought arguments')); exit; } @@ -32,7 +32,7 @@ $operation = $_GET['operation']; $token = $_GET['token']; if (!OC_Gallery_Sharing::isTokenValid($token)) { - OC_JSON::error(array('cause' => 'Given token is not valid')); + OCP\JSON::error(array('cause' => 'Given token is not valid')); exit; } @@ -65,7 +65,7 @@ function handleGetGallery($token, $path) { $photos[] = $row['file_path']; } - OC_JSON::success(array('albums' => $albums, 'photos' => $photos)); + OCP\JSON::success(array('albums' => $albums, 'photos' => $photos)); } function handleGetThumbnail($token, $imgpath) { diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php index 92e9fd4269e..ff0cb44022c 100755 --- a/apps/gallery/ajax/thumbnail.php +++ b/apps/gallery/ajax/thumbnail.php @@ -22,8 +22,8 @@ */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('gallery'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('gallery'); $img = $_GET['img']; diff --git a/apps/gallery/lib/images_utils.php b/apps/gallery/lib/images_utils.php old mode 100644 new mode 100755 index eb50f5217ea..ac3a383c977 --- a/apps/gallery/lib/images_utils.php +++ b/apps/gallery/lib/images_utils.php @@ -21,8 +21,8 @@ * */ -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('gallery'); +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('gallery'); function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $shift) { //getting the image dimensions diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php index 95259fdefa0..130344ac6dc 100755 --- a/apps/media/ajax/api.php +++ b/apps/media/ajax/api.php @@ -23,7 +23,7 @@ header('Content-type: text/html; charset=UTF-8') ; -OC_JSON::checkAppEnabled('media'); +OCP\JSON::checkAppEnabled('media'); require_once(OC::$APPSROOT . '/apps/media/lib_collection.php'); require_once(OC::$APPSROOT . '/apps/media/lib_scanner.php'); @@ -64,7 +64,7 @@ if($arguments['action']){ $data['artists']=OC_MEDIA_COLLECTION::getArtists(); $data['albums']=OC_MEDIA_COLLECTION::getAlbums(); $data['songs']=OC_MEDIA_COLLECTION::getSongs(); - OC_JSON::encodedPrint($data); + OCP\JSON::encodedPrint($data); break; case 'scan': OC_DB::beginTransaction(); @@ -78,13 +78,13 @@ if($arguments['action']){ echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false'; break; case 'get_artists': - OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search'])); + OCP\JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search'])); break; case 'get_albums': - OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'],$arguments['search'])); + OCP\JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'],$arguments['search'])); break; case 'get_songs': - OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search'])); + OCP\JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search'])); break; case 'get_path_info': if(OC_Filesystem::file_exists($arguments['path'])){ @@ -97,7 +97,7 @@ if($arguments['action']){ $song=OC_MEDIA_COLLECTION::getSong($songId); $song['artist']=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']); $song['album']=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']); - OC_JSON::encodedPrint($song); + OCP\JSON::encodedPrint($song); } } break; @@ -122,7 +122,7 @@ if($arguments['action']){ $music=OC_FileCache::searchByMime('audio'); $ogg=OC_FileCache::searchByMime('application','ogg'); $music=array_merge($music,$ogg); - OC_JSON::encodedPrint($music); + OCP\JSON::encodedPrint($music); exit; } } diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php index 1efbea3acef..3122c7e6754 100755 --- a/apps/media/ajax/autoupdate.php +++ b/apps/media/ajax/autoupdate.php @@ -28,11 +28,11 @@ $RUNTIME_NOAPPS=true; $RUNTIME_NOSETUPFS=true; -OC_JSON::checkAppEnabled('media'); +OCP\JSON::checkAppEnabled('media'); $autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true'); OCP\Config::setUserValue(OCP\USER::getUser(),'media','autoupdate',(integer)$autoUpdate); -OC_JSON::success(array('data' => $autoUpdate)); +OCP\JSON::success(array('data' => $autoUpdate)); ?> diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php index d4f5ac6afad..700a75bf41e 100755 --- a/apps/media/tomahawk.php +++ b/apps/media/tomahawk.php @@ -24,7 +24,7 @@ $_POST=$_GET; //debug require_once('../inc.php'); -OC_JSON::checkAppEnabled('media'); +OCP\JSON::checkAppEnabled('media'); require_once(OC::$APPSROOT . '/apps/media/lib_collection.php'); $user=isset($_POST['user'])?$_POST['user']:''; @@ -76,5 +76,5 @@ foreach($songs as $song) { 'score' => (float)1.0 ); } -OC_JSON::encodedPrint($results); +OCP\JSON::encodedPrint($results); ?> diff --git a/apps/user_migrate/ajax/export.php b/apps/user_migrate/ajax/export.php index ef8e331c68c..07c35c73470 100755 --- a/apps/user_migrate/ajax/export.php +++ b/apps/user_migrate/ajax/export.php @@ -24,33 +24,33 @@ // Check if we are a user -OC_JSON::checkLoggedIn(); +OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('user_migrate'); // Which operation if( $_GET['operation']=='create' ){ $uid = !empty( $_POST['uid'] ) ? $_POST['uid'] : OCP\USER::getUser(); if( $uid != OCP\USER::getUser() ){ // Needs to be admin to export someone elses account - OC_JSON::error(); + OCP\JSON::error(); die(); } // Create the export zip $response = json_decode( OC_Migrate::export( $uid ) ); if( !$response->success ){ // Error - OC_JSON::error(); + OCP\JSON::error(); die(); } else { // Save path in session $_SESSION['ocuserexportpath'] = $response->data; } - OC_JSON::success(); + OCP\JSON::success(); die(); } else if( $_GET['operation']=='download' ){ // Download the export $path = isset( $_SESSION['ocuserexportpath'] ) ? $_SESSION['ocuserexportpath'] : false; if( !$path ){ - OC_JSON::error(); + OCP\JSON::error(); } header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=" . basename($path)); diff --git a/lib/public/json.php b/lib/public/json.php new file mode 100644 index 00000000000..36d3bed807f --- /dev/null +++ b/lib/public/json.php @@ -0,0 +1,94 @@ +. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * JSON Class + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +class JSON { + + + + /** + * Encode and print $data in JSON format + */ + public static function encodedPrint($data,$setContentType=true){ + return(\OC_JSON::encodedPrint($data,$setContentType)); + } + + /** + * Check if the user is logged in, send json error msg if not + */ + public static function checkLoggedIn(){ + return(\OC_JSON::checkLoggedIn()); + } + + + + /** + * Send json success msg + */ + public static function success($data = array()){ + return(\OC_JSON::success($data)); + } + + + /** + * Send json error msg + */ + public static function error($data = array()){ + return(\OC_JSON::error($data)); + } + + + /** + * set Content-Type header to jsonrequest + */ + public static function setContentTypeHeader($type='application/json'){ + return(\OC_JSON::setContentTypeHeader($type)); + } + + + /** + * Check if the app is enabled, send json error msg if not + */ + public static function checkAppEnabled($app){ + return(\OC_JSON::checkAppEnabled($app)); + } + + + /** + * Check if the user is a admin, send json error msg if not + */ + public static function checkAdminUser(){ + return(\OC_JSON::checkAdminUser()); + } + +} + +?> -- cgit v1.2.3 From 97a8af7f2519e9ba01c2ff0c16a3102f716c0d13 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 3 May 2012 13:06:08 +0200 Subject: ported oc_db --- apps/bookmarks/ajax/delBookmark.php | 6 +-- apps/bookmarks/ajax/editBookmark.php | 6 +-- apps/bookmarks/ajax/recordClick.php | 2 +- apps/bookmarks/appinfo/migrate.php | 6 +-- apps/bookmarks/bookmarksHelper.php | 6 +-- apps/bookmarks/lib/bookmarks.php | 4 +- apps/calendar/appinfo/update.php | 4 +- apps/calendar/lib/calendar.php | 22 ++++---- apps/calendar/lib/object.php | 26 ++++----- apps/calendar/lib/share.php | 22 ++++---- apps/contacts/appinfo/migrate.php | 6 +-- apps/contacts/lib/addressbook.php | 20 +++---- apps/contacts/lib/vcard.php | 26 ++++----- apps/files/ajax/scan.php | 4 +- apps/files_sharing/lib_share.php | 50 ++++++++--------- apps/files_sharing/sharedstorage.php | 4 +- apps/gallery/ajax/galleryOp.php | 4 +- apps/gallery/appinfo/app.php | 2 +- apps/gallery/lib/album.php | 12 ++--- apps/gallery/lib/photo.php | 14 ++--- apps/gallery/lib/sharing.php | 14 ++--- apps/media/ajax/api.php | 4 +- apps/media/lib_ampache.php | 10 ++-- apps/media/lib_collection.php | 42 +++++++-------- apps/media/lib_media.php | 4 +- apps/remoteStorage/lib_remoteStorage.php | 8 +-- apps/user_ldap/lib_ldap.php | 10 ++-- apps/user_openid/user_openid.php | 2 +- lib/public/db.php | 92 ++++++++++++++++++++++++++++++++ 29 files changed, 262 insertions(+), 170 deletions(-) mode change 100644 => 100755 apps/bookmarks/appinfo/migrate.php mode change 100644 => 100755 apps/calendar/lib/share.php mode change 100644 => 100755 apps/contacts/appinfo/migrate.php mode change 100644 => 100755 apps/gallery/lib/sharing.php mode change 100644 => 100755 apps/user_openid/user_openid.php create mode 100644 lib/public/db.php (limited to 'apps/files/ajax') diff --git a/apps/bookmarks/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php index f40192943e4..2634bed0b9c 100755 --- a/apps/bookmarks/ajax/delBookmark.php +++ b/apps/bookmarks/ajax/delBookmark.php @@ -35,7 +35,7 @@ $params=array( OCP\USER::getUser() ); -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" SELECT id FROM *PREFIX*bookmarks WHERE url LIKE ? AND user_id = ? @@ -43,7 +43,7 @@ $query = OC_DB::prepare(" $id = $query->execute($params)->fetchOne(); -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" DELETE FROM *PREFIX*bookmarks WHERE id = $id "); @@ -51,7 +51,7 @@ $query = OC_DB::prepare(" $result = $query->execute(); -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" DELETE FROM *PREFIX*bookmarks_tags WHERE bookmark_id = $id "); diff --git a/apps/bookmarks/ajax/editBookmark.php b/apps/bookmarks/ajax/editBookmark.php index 1b6d6d6ce44..db349af35c1 100755 --- a/apps/bookmarks/ajax/editBookmark.php +++ b/apps/bookmarks/ajax/editBookmark.php @@ -41,7 +41,7 @@ if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ $bookmark_id = (int)$_GET["id"]; -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" UPDATE *PREFIX*bookmarks SET url = ?, title =?, lastmodified = $_ut WHERE id = $bookmark_id @@ -54,14 +54,14 @@ $params=array( $query->execute($params); # Remove old tags and insert new ones. -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" DELETE FROM *PREFIX*bookmarks_tags WHERE bookmark_id = $bookmark_id "); $query->execute(); -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" INSERT INTO *PREFIX*bookmarks_tags (bookmark_id, tag) VALUES (?, ?) diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php index 03d010637fc..2bd91f232a4 100755 --- a/apps/bookmarks/ajax/recordClick.php +++ b/apps/bookmarks/ajax/recordClick.php @@ -30,7 +30,7 @@ $RUNTIME_NOSETUPFS=true; OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); -$query = OC_DB::prepare(" +$query = OCP\DB::prepare(" UPDATE *PREFIX*bookmarks SET clickcount = clickcount + 1 WHERE user_id = ? diff --git a/apps/bookmarks/appinfo/migrate.php b/apps/bookmarks/appinfo/migrate.php old mode 100644 new mode 100755 index c1251e816ec..e7e572f52dc --- a/apps/bookmarks/appinfo/migrate.php +++ b/apps/bookmarks/appinfo/migrate.php @@ -40,10 +40,10 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{ $idmap = array(); while( $row = $results->fetchRow() ){ // Import each bookmark, saving its id into the map - $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" ); + $query = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)" ); $query->execute( array( $row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified'] ) ); // Map the id - $idmap[$row['id']] = OC_DB::insertid(); + $idmap[$row['id']] = OCP\DB::insertid(); } // Now tags foreach($idmap as $oldid => $newid){ @@ -51,7 +51,7 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{ $results = $query->execute( array( $oldid ) ); while( $row = $results->fetchRow() ){ // Import the tags for this bookmark, using the new bookmark id - $query = OC_DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" ); + $query = OCP\DB::prepare( "INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)" ); $query->execute( array( $newid, $row['tag'] ) ); } } diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index e299f9ee19b..01b551111e0 100755 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -82,7 +82,7 @@ function addBookmark($url, $title, $tags='') { } //FIXME: Detect when user adds a known URL - $query = OC_DB::prepare(" + $query = OCP\DB::prepare(" INSERT INTO *PREFIX*bookmarks (url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, 0, $_ut, $_ut) @@ -105,10 +105,10 @@ function addBookmark($url, $title, $tags='') { ); $query->execute($params); - $b_id = OC_DB::insertid('*PREFIX*bookmarks'); + $b_id = OCP\DB::insertid('*PREFIX*bookmarks'); if($b_id !== false) { - $query = OC_DB::prepare(" + $query = OCP\DB::prepare(" INSERT INTO *PREFIX*bookmarks_tags (bookmark_id, tag) VALUES (?, ?) diff --git a/apps/bookmarks/lib/bookmarks.php b/apps/bookmarks/lib/bookmarks.php index cbc50fdb81c..67b8e2f780e 100755 --- a/apps/bookmarks/lib/bookmarks.php +++ b/apps/bookmarks/lib/bookmarks.php @@ -70,7 +70,7 @@ class OC_Bookmarks_Bookmarks{ } if($CONFIG_DBTYPE == 'pgsql' ){ - $query = OC_DB::prepare(' + $query = OCP\DB::prepare(' SELECT id, url, title, '.($filterTagOnly?'':'url || title ||').' array_to_string(array_agg(tag), \' \') as tags FROM *PREFIX*bookmarks LEFT JOIN *PREFIX*bookmarks_tags ON *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id @@ -87,7 +87,7 @@ class OC_Bookmarks_Bookmarks{ else $concatFunction = 'Concat(Concat( url, title), '; - $query = OC_DB::prepare(' + $query = OCP\DB::prepare(' SELECT id, url, title, ' .($filterTagOnly?'':$concatFunction). 'CASE WHEN *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id diff --git a/apps/calendar/appinfo/update.php b/apps/calendar/appinfo/update.php index 78e4f2d8748..1c042428089 100755 --- a/apps/calendar/appinfo/update.php +++ b/apps/calendar/appinfo/update.php @@ -2,7 +2,7 @@ $installedVersion=OCP\Config::getAppValue('calendar', 'installed_version'); if (version_compare($installedVersion, '0.2.1', '<')) { - $stmt = OC_DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' ); + $stmt = OCP\DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' ); $result = $stmt->execute(); while( $row = $result->fetchRow()) { $id = $row['id']; @@ -11,7 +11,7 @@ if (version_compare($installedVersion, '0.2.1', '<')) { continue; } $color = '#' .$color; - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' ); $r = $stmt->execute(array($color,$id)); } } diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 2aba83d32a3..1d008508040 100755 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -54,7 +54,7 @@ class OC_Calendar_Calendar{ $active_where = ' AND active = ?'; $values[] = $active; } - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE userid = ?' . $active_where ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE userid = ?' . $active_where ); $result = $stmt->execute($values); $calendars = array(); @@ -81,7 +81,7 @@ class OC_Calendar_Calendar{ * @return associative array */ public static function find($id){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' ); $result = $stmt->execute(array($id)); return $result->fetchRow(); @@ -106,10 +106,10 @@ class OC_Calendar_Calendar{ $uri = self::createURI($name, $uris ); - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); $result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components)); - return OC_DB::insertid('*PREFIX*calendar_calendar'); + return OCP\DB::insertid('*PREFIX*calendar_calendar'); } /** @@ -126,10 +126,10 @@ class OC_Calendar_Calendar{ public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color){ $userid = self::extractUserID($principaluri); - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' ); $result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components)); - return OC_DB::insertid('*PREFIX*calendar_calendars'); + return OCP\DB::insertid('*PREFIX*calendar_calendars'); } /** @@ -155,7 +155,7 @@ class OC_Calendar_Calendar{ if(is_null($order)) $order = $calendar['calendarorder']; if(is_null($color)) $color = $calendar['calendarcolor']; - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET displayname=?,calendarorder=?,calendarcolor=?,timezone=?,components=?,ctag=ctag+1 WHERE id=?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET displayname=?,calendarorder=?,calendarcolor=?,timezone=?,components=?,ctag=ctag+1 WHERE id=?' ); $result = $stmt->execute(array($name,$order,$color,$timezone,$components,$id)); return true; @@ -168,7 +168,7 @@ class OC_Calendar_Calendar{ * @return boolean */ public static function setCalendarActive($id,$active){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET active = ? WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET active = ? WHERE id = ?' ); $stmt->execute(array($active, $id)); return true; @@ -180,7 +180,7 @@ class OC_Calendar_Calendar{ * @return boolean */ public static function touchCalendar($id){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET ctag = ctag + 1 WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET ctag = ctag + 1 WHERE id = ?' ); $stmt->execute(array($id)); return true; @@ -192,10 +192,10 @@ class OC_Calendar_Calendar{ * @return boolean */ public static function deleteCalendar($id){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_calendars WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_calendars WHERE id = ?' ); $stmt->execute(array($id)); - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); $stmt->execute(array($id)); return true; diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 018bf5beff1..3d4174a57be 100755 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -19,7 +19,7 @@ class OC_Calendar_Object{ * ['calendardata'] */ public static function all($id){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' ); $result = $stmt->execute(array($id)); $calendarobjects = array(); @@ -41,7 +41,7 @@ class OC_Calendar_Object{ * in ['calendardata'] */ public static function allInPeriod($id, $start, $end){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' .' AND ((startdate >= ? AND startdate <= ? AND repeating = 0)' .' OR (enddate >= ? AND enddate <= ? AND repeating = 0)' .' OR (startdate <= ? AND repeating = 1))' ); @@ -66,7 +66,7 @@ class OC_Calendar_Object{ * @return associative array */ public static function find($id){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE id = ?' ); $result = $stmt->execute(array($id)); return $result->fetchRow(); @@ -79,7 +79,7 @@ class OC_Calendar_Object{ * @return associative array */ public static function findWhereDAVDataIs($cid,$uri){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri = ?' ); + $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri = ?' ); $result = $stmt->execute(array($cid,$uri)); return $result->fetchRow(); @@ -103,12 +103,12 @@ class OC_Calendar_Object{ $uri = 'owncloud-'.md5($data.rand().time()).'.ics'; - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); OC_Calendar_Calendar::touchCalendar($id); - return OC_DB::insertid('*PREFIX*calendar_objects'); + return OCP\DB::insertid('*PREFIX*calendar_objects'); } /** @@ -122,12 +122,12 @@ class OC_Calendar_Object{ $object = OC_VObject::parse($data); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); + $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' ); $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time())); OC_Calendar_Calendar::touchCalendar($id); - return OC_DB::insertid('*PREFIX*calendar_objects'); + return OCP\DB::insertid('*PREFIX*calendar_objects'); } /** @@ -143,7 +143,7 @@ class OC_Calendar_Object{ OC_Calendar_App::loadCategoriesFromVCalendar($object); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$id)); OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); @@ -164,7 +164,7 @@ class OC_Calendar_Object{ $object = OC_VObject::parse($data); list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object); - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$oldobject['id'])); OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); @@ -179,7 +179,7 @@ class OC_Calendar_Object{ */ public static function delete($id){ $oldobject = self::find($id); - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' ); $stmt->execute(array($id)); OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); @@ -193,7 +193,7 @@ class OC_Calendar_Object{ * @return boolean */ public static function deleteFromDAVData($cid,$uri){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' ); $stmt->execute(array($cid,$uri)); OC_Calendar_Calendar::touchCalendar($cid); @@ -201,7 +201,7 @@ class OC_Calendar_Object{ } public static function moveToCalendar($id, $calendarid){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET calendarid=? WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*calendar_objects SET calendarid=? WHERE id = ?' ); $stmt->execute(array($calendarid,$id)); OC_Calendar_Calendar::touchCalendar($id); diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php old mode 100644 new mode 100755 index 8f91be97474..a53bf763324 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -25,7 +25,7 @@ class OC_Calendar_Share{ }else{ $active_where = ''; } - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where); $result = $stmt->execute(array($userid, $userid)); $return = array(); while( $row = $result->fetchRow()){ @@ -40,7 +40,7 @@ class OC_Calendar_Share{ * @return: (array) $users - information about users a calendar / event is shared with */ public static function allUsersSharedwith($id, $type){ - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ' . $type . 'id = ? ORDER BY share'); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ' . $type . 'id = ? ORDER BY share'); $result = $stmt->execute(array($id)); $users = array(); while( $row = $result->fetchRow()){ @@ -72,7 +72,7 @@ class OC_Calendar_Share{ if($sharetype == 'public'){ $share = self::generate_token($id, $type); } - $stmt = OC_DB::prepare('INSERT INTO *PREFIX*calendar_share_' . $type . ' (owner,share,sharetype,' . $type . 'id,permissions' . (($type == self::CALENDAR)?', active':'') . ') VALUES(?,?,?,?,0' . (($type == self::CALENDAR)?', 1':'') . ')' ); + $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*calendar_share_' . $type . ' (owner,share,sharetype,' . $type . 'id,permissions' . (($type == self::CALENDAR)?', active':'') . ') VALUES(?,?,?,?,0' . (($type == self::CALENDAR)?', 1':'') . ')' ); $result = $stmt->execute(array($owner,$share,$sharetype,$id)); if($sharetype == 'public'){ return $share; @@ -90,7 +90,7 @@ class OC_Calendar_Share{ * @return (bool) */ public static function unshare($owner, $share, $sharetype, $id, $type){ - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? ' . (($sharetype != 'public')?'AND share = ?':'') . ' AND sharetype = ? AND ' . $type . 'id = ?'); + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? ' . (($sharetype != 'public')?'AND share = ?':'') . ' AND sharetype = ? AND ' . $type . 'id = ?'); if($sharetype != 'public'){ $stmt->execute(array($owner,$share,$sharetype,$id)); }else{ @@ -111,7 +111,7 @@ class OC_Calendar_Share{ if($sharetype == 'public' && $permission == 1){ $permission = 0; } - $stmt = OC_DB::prepare('UPDATE *PREFIX*calendar_share_' . $type . ' SET permissions = ? WHERE share = ? AND sharetype = ? AND ' . $type . 'id = ?'); + $stmt = OCP\DB::prepare('UPDATE *PREFIX*calendar_share_' . $type . ' SET permissions = ? WHERE share = ? AND sharetype = ? AND ' . $type . 'id = ?'); $stmt->execute(array($permission, $share, $sharetype, $id)); return true; } @@ -148,7 +148,7 @@ class OC_Calendar_Share{ * @return (bool) */ public static function is_already_shared($owner, $share, $sharetype, $id, $type){ - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? AND share = ? AND sharetype = ? AND ' . $type . 'id = ?'); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? AND share = ? AND sharetype = ? AND ' . $type . 'id = ?'); $result = $stmt->execute(array($owner, $share, $sharetype, $id)); if($result->numRows() > 0){ return true; @@ -191,7 +191,7 @@ class OC_Calendar_Share{ public static function is_editing_allowed($share, $id, $type){ $group_where = self::group_sql(OC_Group::getUserGroups($share)); $permission_where = self::permission_sql('rw'); - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where); $result = $stmt->execute(array($share)); if($result->numRows() == 1){ return true; @@ -211,7 +211,7 @@ class OC_Calendar_Share{ */ public static function check_access($share, $id, $type){ $group_where = self::group_sql(OC_Group::getUserGroups($share)); - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE (' . $type . 'id = ? AND (share = ? AND sharetype = "user") ' . $group_where . ')'); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE (' . $type . 'id = ? AND (share = ? AND sharetype = "user") ' . $group_where . ')'); $result = $stmt->execute(array($id,$share)); $rows = $result->numRows(); if($rows > 0){ @@ -229,9 +229,9 @@ class OC_Calendar_Share{ * @return: mixed - bool if false, array with type and id if true */ public static function getElementByToken($token){ - $stmt_calendar = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::CALENDAR . ' WHERE sharetype = "public" AND share = ?'); + $stmt_calendar = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::CALENDAR . ' WHERE sharetype = "public" AND share = ?'); $result_calendar = $stmt_calendar->execute(array($token)); - $stmt_event = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::EVENT . ' WHERE sharetype = "public" AND share = ?'); + $stmt_event = OCP\DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::EVENT . ' WHERE sharetype = "public" AND share = ?'); $result_event = $stmt_event->execute(array($token)); $return = array(); if($result_calendar->numRows() == 0 && $result_event->numRows() == 0){ @@ -253,7 +253,7 @@ class OC_Calendar_Share{ * @param (string) $ */ public static function set_active($share, $id, $active){ - $stmt = OC_DB::prepare('UPDATE *PREFIX*calendar_share_calendar SET active = ? WHERE share = ? AND sharetype = "user" AND calendarid = ?'); + $stmt = OCP\DB::prepare('UPDATE *PREFIX*calendar_share_calendar SET active = ? WHERE share = ? AND sharetype = "user" AND calendarid = ?'); $stmt->execute(array($active, $share, $id)); } } \ No newline at end of file diff --git a/apps/contacts/appinfo/migrate.php b/apps/contacts/appinfo/migrate.php old mode 100644 new mode 100755 index a6c6bc20fa4..1400cdf79d4 --- a/apps/contacts/appinfo/migrate.php +++ b/apps/contacts/appinfo/migrate.php @@ -40,10 +40,10 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ $idmap = array(); while( $row = $results->fetchRow() ){ // Import each bookmark, saving its id into the map - $query = OC_DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" ); + $query = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" ); $query->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) ); // Map the id - $idmap[$row['id']] = OC_DB::insertid(); + $idmap[$row['id']] = OCP\DB::insertid(); } // Now tags foreach($idmap as $oldid => $newid){ @@ -51,7 +51,7 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{ $results = $query->execute( array( $oldid ) ); while( $row = $results->fetchRow() ){ // Import the tags for this bookmark, using the new bookmark id - $query = OC_DB::prepare( "INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)" ); + $query = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)" ); $query->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) ); } } diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index b4bcc20d3bb..78e94762f2e 100755 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -44,7 +44,7 @@ class OC_Contacts_Addressbook{ * @return array */ public static function all($uid){ - $stmt = OC_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)); $addressbooks = array(); @@ -71,7 +71,7 @@ class OC_Contacts_Addressbook{ * @return associative array */ public static function find($id){ - $stmt = OC_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)); return $result->fetchRow(); @@ -93,10 +93,10 @@ class OC_Contacts_Addressbook{ $uri = self::createURI($name, $uris ); - $stmt = OC_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)); - return OC_DB::insertid('*PREFIX*contacts_addressbooks'); + return OCP\DB::insertid('*PREFIX*contacts_addressbooks'); } /** @@ -110,10 +110,10 @@ class OC_Contacts_Addressbook{ public static function addFromDAVData($principaluri,$uri,$name,$description){ $userid = self::extractUserID($principaluri); - $stmt = OC_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)); - return OC_DB::insertid('*PREFIX*contacts_addressbooks'); + return OCP\DB::insertid('*PREFIX*contacts_addressbooks'); } /** @@ -134,7 +134,7 @@ class OC_Contacts_Addressbook{ $description = $addressbook['description']; } - $stmt = OC_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)); return true; @@ -192,7 +192,7 @@ class OC_Contacts_Addressbook{ $ids_sql = join(',', array_fill(0, count($active), '?')); $prep = 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id IN ('.$ids_sql.') ORDER BY displayname'; try { - $stmt = OC_DB::prepare( $prep ); + $stmt = OCP\DB::prepare( $prep ); $result = $stmt->execute($active); } catch(Exception $e) { OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OCP\Util::DEBUG); @@ -258,7 +258,7 @@ class OC_Contacts_Addressbook{ public static function delete($id){ // FIXME: There's no error checking at all. self::setActive($id, false); - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $stmt->execute(array($id)); $cards = OC_Contacts_VCard::all($id); @@ -275,7 +275,7 @@ class OC_Contacts_Addressbook{ * @return boolean */ public static function touch($id){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' ); $stmt->execute(array($id)); return true; diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 53600e18b0c..4be6819054b 100755 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -53,7 +53,7 @@ class OC_Contacts_VCard{ $id_sql = join(',', array_fill(0, count($id), '?')); $prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname'; try { - $stmt = OC_DB::prepare( $prep ); + $stmt = OCP\DB::prepare( $prep ); $result = $stmt->execute($id); } catch(Exception $e) { OCP\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG); @@ -62,7 +62,7 @@ class OC_Contacts_VCard{ } } elseif($id) { try { - $stmt = OC_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)); } catch(Exception $e) { OCP\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG); @@ -85,7 +85,7 @@ class OC_Contacts_VCard{ * @return associative array */ public static function find($id){ - $stmt = OC_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)); return $result->fetchRow(); @@ -98,7 +98,7 @@ class OC_Contacts_VCard{ * @return associative array */ public static function findWhereDAVDataIs($aid,$uri){ - $stmt = OC_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)); return $result->fetchRow(); @@ -147,7 +147,7 @@ class OC_Contacts_VCard{ * @returns true if the UID has been changed. */ protected static function trueUID($aid, &$uid) { - $stmt = OC_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'; $result = $stmt->execute(array($aid,$uri)); if($result->numRows() > 0){ @@ -282,9 +282,9 @@ class OC_Contacts_VCard{ } $data = $card->serialize(); - $stmt = OC_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(?,?,?,?,?)' ); $result = $stmt->execute(array($aid,$fn,$data,$uri,time())); - $newid = OC_DB::insertid('*PREFIX*contacts_cards'); + $newid = OCP\DB::insertid('*PREFIX*contacts_cards'); OC_Contacts_Addressbook::touch($aid); @@ -308,7 +308,7 @@ class OC_Contacts_VCard{ * @param array $objects An array of [id, carddata]. */ public static function updateDataByID($objects){ - $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET carddata = ?, lastmodified = ? WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET carddata = ?, lastmodified = ? WHERE id = ?' ); $now = new DateTime; foreach($objects as $object) { $vcard = OC_VObject::parse($object[1]); @@ -350,7 +350,7 @@ class OC_Contacts_VCard{ $card->setString('REV', $now->format(DateTime::W3C)); $data = $card->serialize(); - $stmt = OC_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 = ?' ); $result = $stmt->execute(array($fn,$data,time(),$id)); OC_Contacts_Addressbook::touch($oldcard['addressbookid']); @@ -378,7 +378,7 @@ class OC_Contacts_VCard{ */ public static function delete($id){ // FIXME: Add error checking. - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' ); $stmt->execute(array($id)); return true; @@ -392,7 +392,7 @@ class OC_Contacts_VCard{ */ public static function deleteFromDAVData($aid,$uri){ // FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error. - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); + $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); $stmt->execute(array($aid,$uri)); OC_Contacts_Addressbook::touch($aid); @@ -521,7 +521,7 @@ class OC_Contacts_VCard{ $id_sql = join(',', array_fill(0, count($id), '?')); $prep = 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id IN ('.$id_sql.')'; try { - $stmt = OC_DB::prepare( $prep ); + $stmt = OCP\DB::prepare( $prep ); //$aid = array($aid); $vals = array_merge((array)$aid, $id); $result = $stmt->execute($vals); @@ -533,7 +533,7 @@ class OC_Contacts_VCard{ } } else { try { - $stmt = OC_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)); } catch(Exception $e) { OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG); diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php index d36366caf49..d695ce81617 100755 --- a/apps/files/ajax/scan.php +++ b/apps/files/ajax/scan.php @@ -14,10 +14,10 @@ if(!$checkOnly){ //create the file cache if necesary if($force or !OC_FileCache::inCache('')){ if(!$checkOnly){ - OC_DB::beginTransaction(); + OCP\DB::beginTransaction(); OC_FileCache::scan($dir,$eventSource); OC_FileCache::clean(); - OC_DB::commit(); + OCP\DB::commit(); $eventSource->send('success',true); }else{ OCP\JSON::success(array('data'=>array('done'=>true))); diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index 96df29c4f42..fe8aa64fa81 100755 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -40,7 +40,7 @@ class OC_Share { */ public function __construct($source, $uid_shared_with, $permissions) { $uid_owner = OCP\USER::getUser(); - $query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)"); + $query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)"); if ($uid_shared_with == self::PUBLICLINK) { $token = sha1("$uid_shared_with-$source"); $query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions)); @@ -69,7 +69,7 @@ class OC_Share { } foreach ($uid_shared_with as $uid) { // Check if this item is already shared with the user - $checkSource = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid)); + $checkSource = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid)); $resultCheckSource = $checkSource->execute(array($source))->fetchAll(); // TODO Check if the source is inside a folder if (count($resultCheckSource) > 0 && !isset($gid)) { @@ -101,11 +101,11 @@ class OC_Share { // Add file to filesystem cache $userDirectory = "/".OCP\USER::getUser()."/files"; $data = OC_Filecache::get(substr($source, strlen($userDirectory))); - $parentQuery = OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?'); + $parentQuery = OCP\DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?'); $parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow(); $parent = $parentResult['id']; $is_writeable = $permissions & OC_Share::WRITE; - $cacheQuery = OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)'); + $cacheQuery = OCP\DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)'); $cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable)); } } @@ -169,7 +169,7 @@ class OC_Share { $folders = self::getParentFolders($oldTarget); $source = $folders['source'].substr($oldTarget, strlen($folders['target'])); $item = self::getItem($folders['target']); - $query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)"); + $query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)"); $query->execute(array($item[0]['uid_owner'], OCP\USER::getUser(), $source, $newTarget, $item[0]['permissions'])); } @@ -180,7 +180,7 @@ class OC_Share { */ public static function getItem($target) { $target = self::cleanPath($target); - $query = OC_DB::prepare("SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1"); + $query = OCP\DB::prepare("SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1"); return $query->execute(array($target, OCP\USER::getUser()))->fetchAll(); } @@ -191,7 +191,7 @@ class OC_Share { */ public static function getMySharedItem($source) { $source = self::cleanPath($source); - $query = OC_DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?"); + $query = OCP\DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?"); $result = $query->execute(array($source, OCP\USER::getUser()))->fetchAll(); if (count($result) > 0) { return $result; @@ -207,7 +207,7 @@ class OC_Share { * @return An array with all items the user is sharing */ public static function getMySharedItems() { - $query = OC_DB::prepare("SELECT uid_shared_with, source, permissions FROM *PREFIX*sharing WHERE uid_owner = ?"); + $query = OCP\DB::prepare("SELECT uid_shared_with, source, permissions FROM *PREFIX*sharing WHERE uid_owner = ?"); return $query->execute(array(OCP\USER::getUser()))->fetchAll(); } @@ -226,7 +226,7 @@ class OC_Share { $folder .= "/"; } $length = strlen($folder); - $query = OC_DB::prepare("SELECT uid_owner, source, target, permissions FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? OR SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups()); + $query = OCP\DB::prepare("SELECT uid_owner, source, target, permissions FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? OR SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups()); return $query->execute(array($length, $folder, $length, $folder))->fetchAll(); } @@ -237,7 +237,7 @@ class OC_Share { */ public static function getParentFolders($target) { $target = self::cleanPath($target); - $query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with".self::getUsersAndGroups()." LIMIT 1"); + $query = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with".self::getUsersAndGroups()." LIMIT 1"); // Prevent searching for user directory e.g. '/MTGap/files' $userDirectory = substr($target, 0, strpos($target, "files") + 5); $target = dirname($target); @@ -265,7 +265,7 @@ class OC_Share { */ public static function getSource($target) { $target = self::cleanPath($target); - $query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1"); + $query = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1"); $result = $query->execute(array($target))->fetchAll(); if (count($result) > 0) { return $result[0]['source']; @@ -281,7 +281,7 @@ class OC_Share { public static function getTarget($source) { $source = self::cleanPath($source); - $query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ? LIMIT 1"); + $query = OCP\DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ? LIMIT 1"); $result = $query->execute(array($source, OCP\USER::getUser()))->fetchAll(); if (count($result) > 0) { return $result[0]['target']; @@ -298,7 +298,7 @@ class OC_Share { */ public static function getPermissions($target) { $target = self::cleanPath($target); - $query = OC_DB::prepare("SELECT permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1"); + $query = OCP\DB::prepare("SELECT permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1"); $result = $query->execute(array($target))->fetchAll(); if (count($result) > 0) { return $result[0]['permissions']; @@ -330,7 +330,7 @@ class OC_Share { * @return The token of the public link, a sha1 hash */ public static function getTokenFromSource($source) { - $query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? AND uid_owner = ? LIMIT 1"); + $query = OCP\DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? AND uid_owner = ? LIMIT 1"); $result = $query->execute(array($source, self::PUBLICLINK, OCP\USER::getUser()))->fetchAll(); if (count($result) > 0) { return $result[0]['target']; @@ -350,7 +350,7 @@ class OC_Share { public static function setTarget($oldTarget, $newTarget) { $oldTarget = self::cleanPath($oldTarget); $newTarget = self::cleanPath($newTarget); - $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET target = REPLACE(target, ?, ?) WHERE uid_shared_with ".self::getUsersAndGroups()); + $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET target = REPLACE(target, ?, ?) WHERE uid_shared_with ".self::getUsersAndGroups()); $query->execute(array($oldTarget, $newTarget)); } @@ -365,7 +365,7 @@ class OC_Share { */ public static function setPermissions($source, $uid_shared_with, $permissions) { $source = self::cleanPath($source); - $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with)); + $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with)); $query->execute(array($permissions, strlen($source), $source, OCP\USER::getUser())); } @@ -379,7 +379,7 @@ class OC_Share { */ public static function unshare($source, $uid_shared_with) { $source = self::cleanPath($source); - $query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with)); + $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with)); $query->execute(array(strlen($source), $source, OCP\USER::getUser())); } @@ -394,10 +394,10 @@ class OC_Share { public static function unshareFromMySelf($target, $delete = true) { $target = self::cleanPath($target); if ($delete) { - $query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups()); + $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups()); $query->execute(array(strlen($target), $target)); } else { - $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups()); + $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups()); $query->execute(array(self::UNSHARED, strlen($target), $target)); } } @@ -411,7 +411,7 @@ class OC_Share { if ($target = self::getTarget($source)) { // Forward hook to notify of changes to target file OC_Hook::emit("OC_Filesystem", "post_delete", array('path' => $target)); - $query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ?"); + $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ?"); $query->execute(array(strlen($source), $source, OCP\USER::getUser())); } @@ -424,7 +424,7 @@ class OC_Share { public static function renameItem($arguments) { $oldSource = "/".OCP\USER::getUser()."/files".self::cleanPath($arguments['oldpath']); $newSource = "/".OCP\USER::getUser()."/files".self::cleanPath($arguments['newpath']); - $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET source = REPLACE(source, ?, ?) WHERE uid_owner = ?"); + $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET source = REPLACE(source, ?, ?) WHERE uid_owner = ?"); $query->execute(array($oldSource, $newSource, OCP\USER::getUser())); } @@ -437,17 +437,17 @@ class OC_Share { } public static function removeUser($arguments) { - $query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_owner = ? OR uid_shared_with '.self::getUsersAndGroups($arguments['uid'])); + $query = OCP\DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_owner = ? OR uid_shared_with '.self::getUsersAndGroups($arguments['uid'])); $query->execute(array($arguments['uid'])); } public static function addToGroupShare($arguments) { $length = -strlen($arguments['gid']) - 1; - $query = OC_DB::prepare('SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE SUBSTR(uid_shared_with, '.$length.') = ?'); + $query = OCP\DB::prepare('SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE SUBSTR(uid_shared_with, '.$length.') = ?'); $gid = '@'.$arguments['gid']; $result = $query->execute(array($gid))->fetchAll(); if (count($result) > 0) { - $query = OC_DB::prepare('INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)'); + $query = OCP\DB::prepare('INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)'); $sharedFolder = '/'.$arguments['uid'].'/files/Shared/'; $lastSource = ''; for ($i = 0; $i < count($result) - 1; $i++) { @@ -460,7 +460,7 @@ class OC_Share { } public static function removeFromGroupShare($arguments) { - $query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?'); + $query = OCP\DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?'); $query->execute(array($arguments['uid'].'@'.$arguments['gid'])); } diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index f64d52551ff..c7c2131f872 100755 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -227,7 +227,7 @@ class OC_Filestorage_Shared extends OC_Filestorage { } if ($size > 0) { $dbpath = rtrim($this->datadir.$path, "/"); -// $query = OC_DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)"); +// $query = OCP\DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)"); // $result = $query->execute(array($dbpath, $size)); } } @@ -241,7 +241,7 @@ class OC_Filestorage_Shared extends OC_Filestorage { $path = dirname($path); } $dbpath = rtrim($this->datadir.$path, "/"); -// $query = OC_DB::prepare("DELETE FROM *PREFIX*/*foldersize*/ WHERE path = ?"); +// $query = OCP\DB::prepare("DELETE FROM *PREFIX*/*foldersize*/ WHERE path = ?"); // $result = $query->execute(array($dbpath)); if ($path != "/" && $path != "") { $parts = explode("/", $path); diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index b9ca31901c3..0cd825f3e50 100755 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -48,13 +48,13 @@ function handleGetThumbnails($albumname) { } function handleGalleryScanning() { - OC_DB::beginTransaction(); + OCP\DB::beginTransaction(); set_time_limit(0); OC_Gallery_Album::cleanup(); $eventSource = new OC_EventSource(); OC_Gallery_Scanner::scan($eventSource); $eventSource->close(); - OC_DB::commit(); + OCP\DB::commit(); } function handleFilescan($cleanup) { diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index e6305a76b75..2501ae7bbd5 100755 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -43,7 +43,7 @@ OCP\App::addNavigationEntry( array( class OC_GallerySearchProvider extends OC_Search_Provider{ function search($query){ - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name LIKE ?'); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name LIKE ?'); $result = $stmt->execute(array(OCP\USER::getUser(),'%'.$query.'%')); $results=array(); while($row=$result->fetchRow()){ diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index f58140c4999..27d40cdb91f 100755 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -25,7 +25,7 @@ require_once('base.php'); class OC_Gallery_Album { public static function create($owner, $name, $path){ - $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name, album_path, parent_path) VALUES (?, ?, ?, ?)'); + $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name, album_path, parent_path) VALUES (?, ?, ?, ?)'); $stmt->execute(array($owner, $name, $path, self::getParentPath($path))); } @@ -56,7 +56,7 @@ class OC_Gallery_Album { $sql .= ' AND parent_path LIKE ?'; $args[] = $parent; } - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); return $stmt->execute($args); } @@ -82,12 +82,12 @@ class OC_Gallery_Album { $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); $sql .= ' ORDER BY album_name ' . $order; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); return $stmt->execute($args); } public static function changePath($oldname, $newname, $owner) { - $stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_albums SET album_path=? WHERE uid_owner=? AND album_path=?'); + $stmt = OCP\DB::prepare('UPDATE *PREFIX*gallery_albums SET album_path=? WHERE uid_owner=? AND album_path=?'); $stmt->execute(array($newname, $owner, $oldname)); } @@ -99,7 +99,7 @@ class OC_Gallery_Album { public static function getAlbumSize($id){ $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); $result=$stmt->execute(array($id))->fetchRow(); return $result['size']; } @@ -107,7 +107,7 @@ class OC_Gallery_Album { public static function getIntermediateGallerySize($path) { $path .= '%'; $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); return $result['size']; } diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 010eb9ab91b..99384af621a 100755 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -23,7 +23,7 @@ class OC_Gallery_Photo { public static function create($albumId, $img){ - $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (album_id, file_path) VALUES (?, ?)'); + $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*gallery_photos (album_id, file_path) VALUES (?, ?)'); $stmt->execute(array($albumId, $img)); } public static function find($albumId, $img=null){ @@ -33,11 +33,11 @@ class OC_Gallery_Photo { $sql .= ' AND file_path = ?'; $args[] = $img; } - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); return $stmt->execute($args); } public static function findForAlbum($owner, $album_name){ - $stmt = OC_DB::prepare('SELECT *' + $stmt = OCP\DB::prepare('SELECT *' .' FROM *PREFIX*gallery_photos photos,' .' *PREFIX*gallery_albums albums' .' WHERE albums.uid_owner = ?' @@ -47,22 +47,22 @@ class OC_Gallery_Photo { } public static function removeByPath($path, $album_id) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path LIKE ? and album_id = ?'); + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path LIKE ? and album_id = ?'); $stmt->execute(array($path, $album_id)); } public static function removeById($id) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE photo_id = ?'); + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE photo_id = ?'); $stmt->execute(array($id)); } public static function removeByAlbumId($albumid) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE album_id = ?'); + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE album_id = ?'); $stmt->execute(array($albumid)); } public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath) { - $stmt = OC_DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?"); + $stmt = OCP\DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?"); $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath)); } diff --git a/apps/gallery/lib/sharing.php b/apps/gallery/lib/sharing.php old mode 100644 new mode 100755 index 60f108bd6c6..fffeca032a3 --- a/apps/gallery/lib/sharing.php +++ b/apps/gallery/lib/sharing.php @@ -24,7 +24,7 @@ class OC_Gallery_Sharing { private static function getEntries($token) { $sql = 'SELECT * FROM *PREFIX*gallery_sharing WHERE token = ?'; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); return $stmt->execute(array($token)); } @@ -45,7 +45,7 @@ class OC_Gallery_Sharing { if ($row = $r->fetchRow()) { $galleryId = $row['gallery_id']; $sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE album_id = ?'; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); $r = $stmt->execute(array($galleryId)); if ($row = $r->fetchRow()) return $row['uid_owner']; @@ -58,7 +58,7 @@ class OC_Gallery_Sharing { if ($row = $r->fetchRow()) { $galleryId = $row['gallery_id']; $sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE album_id = ?'; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); $r = $stmt->execute(array($galleryId)); if ($row = $r->fetchRow()) return $row['album_path']; @@ -66,23 +66,23 @@ class OC_Gallery_Sharing { } public static function updateSharingByToken($token, $recursive) { - $stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_sharing SET recursive = ? WHERE token = ?'); + $stmt = OCP\DB::prepare('UPDATE *PREFIX*gallery_sharing SET recursive = ? WHERE token = ?'); $stmt->execute(array($recursive, $token)); } public static function getEntryByAlbumId($album_id) { - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_sharing WHERE gallery_id = ?'); + $stmt = OCP\DB::prepare('SELECT * FROM *PREFIX*gallery_sharing WHERE gallery_id = ?'); return $stmt->execute(array($album_id)); } public static function addShared($token, $albumId, $recursive) { $sql = 'INSERT INTO *PREFIX*gallery_sharing (token, gallery_id, recursive) VALUES (?, ?, ?)'; - $stmt = OC_DB::prepare($sql); + $stmt = OCP\DB::prepare($sql); $stmt->execute(array($token, $albumId, $recursive)); } public static function remove($albumId) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_sharing WHERE gallery_id = ?'); + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*gallery_sharing WHERE gallery_id = ?'); $stmt->execute(array($albumId)); } } diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php index 130344ac6dc..37dc6380198 100755 --- a/apps/media/ajax/api.php +++ b/apps/media/ajax/api.php @@ -67,12 +67,12 @@ if($arguments['action']){ OCP\JSON::encodedPrint($data); break; case 'scan': - OC_DB::beginTransaction(); + OCP\DB::beginTransaction(); set_time_limit(0); //recursive scan can take a while $eventSource=new OC_EventSource(); OC_MEDIA_SCANNER::scanCollection($eventSource); $eventSource->close(); - OC_DB::commit(); + OCP\DB::commit(); break; case 'scanFile': echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false'; diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index e84c3a00ae2..d658605611c 100755 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -65,7 +65,7 @@ class OC_MEDIA_AMPACHE{ "); } if($auth and $user and $time){ - $query=OC_DB::prepare("SELECT user_id, user_password_sha256 from *PREFIX*media_users WHERE user_id=?"); + $query=OCP\DB::prepare("SELECT user_id, user_password_sha256 from *PREFIX*media_users WHERE user_id=?"); $users=$query->execute(array($user))->fetchAll(); if(count($users)>0){ $pass=$users[0]['user_password_sha256']; @@ -77,7 +77,7 @@ class OC_MEDIA_AMPACHE{ $songs=OC_MEDIA_COLLECTION::getSongCount(); $artists=OC_MEDIA_COLLECTION::getArtistCount(); $albums=OC_MEDIA_COLLECTION::getAlbumCount(); - $query=OC_DB::prepare("INSERT INTO *PREFIX*media_sessions (`session_id`, `token`, `user_id`, `start`) VALUES (NULL, ?, ?, now());"); + $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`session_id`, `token`, `user_id`, `start`) VALUES (NULL, ?, ?, now());"); $query->execute(array($token,$user)); $expire=date('c',time()+600); echo(''); @@ -137,10 +137,10 @@ class OC_MEDIA_AMPACHE{ } } //remove old sessions - $query=OC_DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW()-600)"); + $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW()-600)"); $query->execute(); - $query=OC_DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?"); + $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?"); $users=$query->execute(array($auth))->fetchAll(); if(count($users)>0){ OC_MEDIA_COLLECTION::$uid=$users[0]['user_id']; @@ -151,7 +151,7 @@ class OC_MEDIA_AMPACHE{ } public static function updateAuth($auth){ - $query=OC_DB::prepare("UPDATE *PREFIX*media_sessions SET start=CURRENT_TIMESTAMP WHERE token=?"); + $query=OCP\DB::prepare("UPDATE *PREFIX*media_sessions SET start=CURRENT_TIMESTAMP WHERE token=?"); $query->execute(array($auth)); } diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index 128fcde28d1..a32a50534ed 100755 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -43,7 +43,7 @@ class OC_MEDIA_COLLECTION{ if(isset(self::$artistIdCache[$name])){ return self::$artistIdCache[$name]; }else{ - $query=OC_DB::prepare("SELECT artist_id FROM *PREFIX*media_artists WHERE lower(artist_name) LIKE ?"); + $query=OCP\DB::prepare("SELECT artist_id FROM *PREFIX*media_artists WHERE lower(artist_name) LIKE ?"); $artists=$query->execute(array($name))->fetchAll(); if(is_array($artists) and isset($artists[0])){ self::$artistIdCache[$name]=$artists[0]['artist_id']; @@ -71,7 +71,7 @@ class OC_MEDIA_COLLECTION{ if(isset(self::$albumIdCache[$artistId][$name])){ return self::$albumIdCache[$artistId][$name]; }else{ - $query=OC_DB::prepare("SELECT album_id FROM *PREFIX*media_albums WHERE lower(album_name) LIKE ? AND album_artist=?"); + $query=OCP\DB::prepare("SELECT album_id FROM *PREFIX*media_albums WHERE lower(album_name) LIKE ? AND album_artist=?"); $albums=$query->execute(array($name,$artistId))->fetchAll(); if(is_array($albums) and isset($albums[0])){ self::$albumIdCache[$artistId][$name]=$albums[0]['album_id']; @@ -104,7 +104,7 @@ class OC_MEDIA_COLLECTION{ return self::$albumIdCache[$artistId][$albumId][$name]; }else{ $uid=$_SESSION['user_id']; - $query=OC_DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_user=? AND song_name LIKE ? AND song_artist=? AND song_album=?"); + $query=OCP\DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_user=? AND song_name LIKE ? AND song_artist=? AND song_album=?"); $songs=$query->execute(array($uid,$name,$artistId,$albumId))->fetchAll(); if(is_array($songs) and isset($songs[0])){ self::$albumIdCache[$artistId][$albumId][$name]=$songs[0]['song_id']; @@ -130,7 +130,7 @@ class OC_MEDIA_COLLECTION{ }elseif($search==''){ $search='%'; } - $query=OC_DB::prepare("SELECT DISTINCT artist_name, artist_id FROM *PREFIX*media_artists + $query=OCP\DB::prepare("SELECT DISTINCT artist_name, artist_id FROM *PREFIX*media_artists INNER JOIN *PREFIX*media_songs ON artist_id=song_artist WHERE artist_name LIKE ? AND song_user=? ORDER BY artist_name"); $result=$query->execute(array($search,self::$uid)); return $result->fetchAll(); @@ -151,7 +151,7 @@ class OC_MEDIA_COLLECTION{ if($artistId!=0){ return $artistId; }else{ - $query=OC_DB::prepare("INSERT INTO `*PREFIX*media_artists` (`artist_name`) VALUES (?)"); + $query=OCP\DB::prepare("INSERT INTO `*PREFIX*media_artists` (`artist_name`) VALUES (?)"); $result=$query->execute(array($name)); return self::getArtistId($name);; } @@ -183,7 +183,7 @@ class OC_MEDIA_COLLECTION{ array_push($params,$search); } $cmd.=' ORDER BY album_name'; - $query=OC_DB::prepare($cmd); + $query=OCP\DB::prepare($cmd); return $query->execute($params)->fetchAll(); } @@ -203,7 +203,7 @@ class OC_MEDIA_COLLECTION{ if($albumId!=0){ return $albumId; }else{ - $query=OC_DB::prepare("INSERT INTO `*PREFIX*media_albums` (`album_name` ,`album_artist`) VALUES ( ?, ?)"); + $query=OCP\DB::prepare("INSERT INTO `*PREFIX*media_albums` (`album_name` ,`album_artist`) VALUES ( ?, ?)"); $query->execute(array($name,$artist)); return self::getAlbumId($name,$artist); } @@ -243,7 +243,7 @@ class OC_MEDIA_COLLECTION{ }else{ $searchString=''; } - $query=OC_DB::prepare("SELECT * FROM *PREFIX*media_songs WHERE song_user=? $artistString $albumString $searchString ORDER BY song_track, song_name, song_path"); + $query=OCP\DB::prepare("SELECT * FROM *PREFIX*media_songs WHERE song_user=? $artistString $albumString $searchString ORDER BY song_track, song_name, song_path"); return $query->execute($params)->fetchAll(); } @@ -270,39 +270,39 @@ class OC_MEDIA_COLLECTION{ return $songId; }else{ if(!isset(self::$queries['addsong'])){ - $query=OC_DB::prepare("INSERT INTO `*PREFIX*media_songs` (`song_name` ,`song_artist` ,`song_album` ,`song_path` ,`song_user`,`song_length`,`song_track`,`song_size`,`song_playcount`,`song_lastplayed`) + $query=OCP\DB::prepare("INSERT INTO `*PREFIX*media_songs` (`song_name` ,`song_artist` ,`song_album` ,`song_path` ,`song_user`,`song_length`,`song_track`,`song_size`,`song_playcount`,`song_lastplayed`) VALUES (?, ?, ?, ?,?,?,?,?,0,0)"); self::$queries['addsong']=$query; }else{ $query=self::$queries['addsong']; } $query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size)); - $songId=OC_DB::insertid('*PREFIX*media_songs'); + $songId=OCP\DB::insertid('*PREFIX*media_songs'); // self::setLastUpdated(); return self::getSongId($name,$artist,$album); } } public static function getSongCount(){ - $query=OC_DB::prepare("SELECT COUNT(song_id) AS count FROM *PREFIX*media_songs"); + $query=OCP\DB::prepare("SELECT COUNT(song_id) AS count FROM *PREFIX*media_songs"); $result=$query->execute()->fetchAll(); return $result[0]['count']; } public static function getArtistCount(){ - $query=OC_DB::prepare("SELECT COUNT(artist_id) AS count FROM *PREFIX*media_artists"); + $query=OCP\DB::prepare("SELECT COUNT(artist_id) AS count FROM *PREFIX*media_artists"); $result=$query->execute()->fetchAll(); return $result[0]['count']; } public static function getAlbumCount(){ - $query=OC_DB::prepare("SELECT COUNT(album_id) AS count FROM *PREFIX*media_albums"); + $query=OCP\DB::prepare("SELECT COUNT(album_id) AS count FROM *PREFIX*media_albums"); $result=$query->execute()->fetchAll(); return $result[0]['count']; } public static function getArtistName($artistId){ - $query=OC_DB::prepare("SELECT artist_name FROM *PREFIX*media_artists WHERE artist_id=?"); + $query=OCP\DB::prepare("SELECT artist_name FROM *PREFIX*media_artists WHERE artist_id=?"); $artist=$query->execute(array($artistId))->fetchAll(); if(count($artist)>0){ return $artist[0]['artist_name']; @@ -312,7 +312,7 @@ class OC_MEDIA_COLLECTION{ } public static function getAlbumName($albumId){ - $query=OC_DB::prepare("SELECT album_name FROM *PREFIX*media_albums WHERE album_id=?"); + $query=OCP\DB::prepare("SELECT album_name FROM *PREFIX*media_albums WHERE album_id=?"); $album=$query->execute(array($albumId))->fetchAll(); if(count($album)>0){ return $album[0]['album_name']; @@ -322,7 +322,7 @@ class OC_MEDIA_COLLECTION{ } public static function getSong($id){ - $query=OC_DB::prepare("SELECT * FROM *PREFIX*media_songs WHERE song_id=?"); + $query=OCP\DB::prepare("SELECT * FROM *PREFIX*media_songs WHERE song_id=?"); $song=$query->execute(array($id))->fetchAll(); if(count($song)>0){ return $song[0]; @@ -336,7 +336,7 @@ class OC_MEDIA_COLLECTION{ * @param string $path */ public static function getSongCountByPath($path){ - $query=OC_DB::prepare("SELECT COUNT(song_id) AS count FROM *PREFIX*media_songs WHERE song_path LIKE ?"); + $query=OCP\DB::prepare("SELECT COUNT(song_id) AS count FROM *PREFIX*media_songs WHERE song_path LIKE ?"); $result=$query->execute(array("$path%"))->fetchAll(); return $result[0]['count']; } @@ -348,7 +348,7 @@ class OC_MEDIA_COLLECTION{ * if a path of a folder is passed, all songs stored in the folder will be removed from the database */ public static function deleteSongByPath($path){ - $query=OC_DB::prepare("DELETE FROM *PREFIX*media_songs WHERE song_path LIKE ?"); + $query=OCP\DB::prepare("DELETE FROM *PREFIX*media_songs WHERE song_path LIKE ?"); $query->execute(array("$path%")); } @@ -358,7 +358,7 @@ class OC_MEDIA_COLLECTION{ */ public static function registerPlay($songId){ $now=time(); - $query=OC_DB::prepare('UPDATE *PREFIX*media_songs SET song_playcount=song_playcount+1, song_lastplayed=? WHERE song_id=? AND song_lastplayedexecute(array($now,$songId,$now-60)); } @@ -368,7 +368,7 @@ class OC_MEDIA_COLLECTION{ * @return int */ public static function getSongByPath($path){ - $query=OC_DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_path = ?"); + $query=OCP\DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_path = ?"); $result=$query->execute(array($path)); if($row=$result->fetchRow()){ return $row['song_id']; @@ -383,7 +383,7 @@ class OC_MEDIA_COLLECTION{ * @param string $newPath */ public static function moveSong($oldPath,$newPath){ - $query=OC_DB::prepare("UPDATE *PREFIX*media_songs SET song_path = ? WHERE song_path = ?"); + $query=OCP\DB::prepare("UPDATE *PREFIX*media_songs SET song_path = ? WHERE song_path = ?"); $query->execute(array($newPath,$oldPath)); } } diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 5b3bfd87474..94c3fabe8a0 100755 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -41,11 +41,11 @@ class OC_MEDIA{ public static function loginListener($params){ if(isset($_POST['user']) and $_POST['password']){ $name=$_POST['user']; - $query=OC_DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?"); + $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?"); $uid=$query->execute(array($name))->fetchAll(); if(count($uid)==0){ $password=hash('sha256',$_POST['password']); - $query=OC_DB::prepare("INSERT INTO *PREFIX*media_users (user_id, user_password_sha256) VALUES (?, ?);"); + $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_users (user_id, user_password_sha256) VALUES (?, ?);"); $query->execute(array($name,$password)); } } diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php index 89dfc3247e9..b6a7a43b7b2 100755 --- a/apps/remoteStorage/lib_remoteStorage.php +++ b/apps/remoteStorage/lib_remoteStorage.php @@ -2,7 +2,7 @@ class OC_remoteStorage { public static function getValidTokens($ownCloudUser, $category) { - $query=OC_DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100"); + $query=OCP\DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100"); $result=$query->execute(array($ownCloudUser)); $ret = array(); while($row=$result->fetchRow()){ @@ -15,7 +15,7 @@ class OC_remoteStorage { public static function getAllTokens() { $user=OCP\USER::getUser(); - $query=OC_DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100"); + $query=OCP\DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100"); $result=$query->execute(array($user)); $ret = array(); while($row=$result->fetchRow()){ @@ -29,13 +29,13 @@ class OC_remoteStorage { public static function deleteToken($token) { $user=OCP\USER::getUser(); - $query=OC_DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?"); + $query=OCP\DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?"); $result=$query->execute(array($token,$user)); return 'unknown';//how can we see if any rows were affected? } private static function addToken($token, $appUrl, $categories){ $user=OCP\USER::getUser(); - $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)"); + $query=OCP\DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)"); $result=$query->execute(array($token,$appUrl,$user,$categories)); } public static function createCategories($appUrl, $categories) { diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index e5b935bfb33..2571ff8d76f 100755 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -137,7 +137,7 @@ class OC_LDAP { static private function ocname2dn($name, $isUser) { $table = self::getMapTable($isUser); - $query = OC_DB::prepare(' + $query = OCP\DB::prepare(' SELECT ldap_dn FROM '.$table.' WHERE owncloud_name = ? @@ -189,7 +189,7 @@ class OC_LDAP { $nameAttribute = self::conf('ldapGroupDisplayName'); } - $query = OC_DB::prepare(' + $query = OCP\DB::prepare(' SELECT owncloud_name FROM '.$table.' WHERE ldap_dn = ? @@ -316,7 +316,7 @@ class OC_LDAP { static private function mappedComponents($isUsers) { $table = self::getMapTable($isUsers); - $query = OC_DB::prepare(' + $query = OCP\DB::prepare(' SELECT ldap_dn, owncloud_name FROM '. $table ); @@ -360,7 +360,7 @@ class OC_LDAP { static private function mapComponent($dn, $ocname, $isUser = true) { $table = self::getMapTable($isUser); - $insert = OC_DB::prepare(' + $insert = OCP\DB::prepare(' INSERT IGNORE INTO '.$table.' (ldap_dn, owncloud_name) VALUES (?,?) @@ -368,7 +368,7 @@ class OC_LDAP { $res = $insert->execute(array($dn, $ocname)); - return !OC_DB::isError($res); + return !OCP\DB::isError($res); } /** diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php old mode 100644 new mode 100755 index df050e908de..8deb42f68c8 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -54,7 +54,7 @@ class OC_USER_OPENID extends OC_User_Backend { * find the user that can be authenticated with an openid identity */ public static function findUserForIdentity($identity){ - $query=OC_DB::prepare('SELECT userid FROM *PREFIX*preferences WHERE appid=? AND configkey=? AND configvalue=?'); + $query=OCP\DB::prepare('SELECT userid FROM *PREFIX*preferences WHERE appid=? AND configkey=? AND configvalue=?'); $result=$query->execute(array('user_openid','identity',$identity))->fetchAll(); if(count($result)>0){ return $result[0]['userid']; diff --git a/lib/public/db.php b/lib/public/db.php new file mode 100644 index 00000000000..b534756a5a0 --- /dev/null +++ b/lib/public/db.php @@ -0,0 +1,92 @@ +. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * DB Class + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +class DB { + + + /** + * @brief Prepare a SQL query + * @param $query Query string + * @returns prepared SQL query + * + * SQL query via MDB2 prepare(), needs to be execute()'d! + */ + static public function prepare( $query ){ + return(\OC_DB::prepare($query)); + } + + /** + * @brief gets last value of autoincrement + * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix + * @returns id + * + * MDB2 lastInsertID() + * + * Call this method right after the insert command or other functions may + * cause trouble! + */ + public static function insertid($table=null){ + return(\OC_DB::insertid($table)); + } + + + + /** + * Start a transaction + */ + public static function beginTransaction(){ + return(\OC_DB::beginTransaction()); + } + + + /** + * Commit the database changes done during a transaction that is in progress + */ + public static function commit(){ + return(\OC_DB::commit()); + } + + + /** + * check if a result is an error, works with MDB2 and PDOException + * @param mixed $result + * @return bool + */ + public static function isError($result){ + return(\OC_DB::isError($result)); + } + + + +} + +?> -- cgit v1.2.3