finish porting of the LOG calls or the apps to the public api

This commit is contained in:
Frank Karlitschek 2012-05-01 17:38:27 +02:00
parent 7ded9cf520
commit d0554bef06
46 changed files with 131 additions and 124 deletions

2
apps/bookmarks/lib/bookmarks.php Normal file → Executable file
View File

@ -34,7 +34,7 @@ class OC_Bookmarks_Bookmarks{
* @return void * @return void
*/ */
public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly){ public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly){
//OC_Log::write('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OC_Log::DEBUG); //OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG);
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' ); $CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
$params=array(OC_User::getUser()); $params=array(OC_User::getUser());

4
apps/bookmarks/lib/search.php Normal file → Executable file
View File

@ -34,9 +34,9 @@ class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
$searchquery = $query; $searchquery = $query;
} }
// OC_Log::write('bookmarks', 'search ' .$query ,OC_Log::DEBUG); // OCP\Util::writeLog('bookmarks', 'search ' .$query ,OCP\Util::DEBUG);
$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false); $bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false);
// OC_Log::write('bookmarks', 'found ' .count($bookmarks) ,OC_Log::DEBUG); // OCP\Util::writeLog('bookmarks', 'found ' .count($bookmarks) ,OCP\Util::DEBUG);
//$l = new OC_l10n('bookmarks'); //resulttype can't be localized, javascript relies on that type //$l = new OC_l10n('bookmarks'); //resulttype can't be localized, javascript relies on that type
foreach($bookmarks as $bookmark){ foreach($bookmarks as $bookmark){
$results[]=new OC_Search_Result($bookmark['title'],'', $bookmark['url'],'Bookm.'); $results[]=new OC_Search_Result($bookmark['title'],'', $bookmark['url'],'Bookm.');

4
apps/calendar/ajax/categories/rescan.php Normal file → Executable file
View File

@ -16,11 +16,11 @@ foreach ($_POST as $key=>$element) {
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
} }
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());

2
apps/contacts/ajax/activation.php Normal file → Executable file
View File

@ -15,7 +15,7 @@ $bookid = $_POST['bookid'];
$book = OC_Contacts_App::getAddressbook($bookid);// is owner access check $book = OC_Contacts_App::getAddressbook($bookid);// is owner access check
if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
OC_Log::write('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OC_Log::ERROR); 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.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
exit(); exit();
} }

6
apps/contacts/ajax/addcontact.php Normal file → Executable file
View File

@ -24,11 +24,11 @@
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/addcontact.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/addcontact.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/addcontact.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/addcontact.php: '.$msg, OCP\Util::DEBUG);
} }
// Check if we are a user // Check if we are a user
@ -56,7 +56,7 @@ $vcard->setString('N',$n);
$id = OC_Contacts_VCard::add($aid,$vcard); $id = OC_Contacts_VCard::add($aid,$vcard);
if(!$id) { if(!$id) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
OC_Log::write('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
exit(); exit();
} }

4
apps/contacts/ajax/addproperty.php Normal file → Executable file
View File

@ -60,7 +60,7 @@ foreach($current as $item) {
$tmpvalue = (is_array($value)?implode(';', $value):$value); $tmpvalue = (is_array($value)?implode(';', $value):$value);
if($tmpvalue == $item->value) { if($tmpvalue == $item->value) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue)));
OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OCP\Util::DEBUG);
exit(); exit();
} }
} }
@ -118,7 +118,7 @@ $checksum = md5($vcard->children[$line]->serialize());
if(!OC_Contacts_VCard::edit($id,$vcard)) { if(!OC_Contacts_VCard::edit($id,$vcard)) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.'))));
OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OCP\Util::ERROR);
exit(); exit();
} }

2
apps/contacts/ajax/categories/categoriesfor.php Normal file → Executable file
View File

@ -17,7 +17,7 @@ if(is_null($id)) {
} }
$vcard = OC_Contacts_App::getContactVCard( $id ); $vcard = OC_Contacts_App::getContactVCard( $id );
foreach($vcard->children as $property){ foreach($vcard->children as $property){
//OC_Log::write('contacts','ajax/categories/checksumfor.php: '.$property->name, OC_Log::DEBUG); //OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG);
if($property->name == 'CATEGORIES') { if($property->name == 'CATEGORIES') {
$checksum = md5($property->serialize()); $checksum = md5($property->serialize());
OC_JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum))); OC_JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum)));

4
apps/contacts/ajax/categories/delete.php Normal file → Executable file
View File

@ -16,11 +16,11 @@ foreach ($_POST as $key=>$element) {
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/categories/delete.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/categories/delete.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG);
} }
$categories = isset($_POST['categories'])?$_POST['categories']:null; $categories = isset($_POST['categories'])?$_POST['categories']:null;

4
apps/contacts/ajax/categories/rescan.php Normal file → Executable file
View File

@ -16,11 +16,11 @@ foreach ($_POST as $key=>$element) {
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
} }
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser()); $addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());

2
apps/contacts/ajax/contactdetails.php Normal file → Executable file
View File

@ -24,7 +24,7 @@
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/contactdetails.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }

6
apps/contacts/ajax/createaddressbook.php Normal file → Executable file
View File

@ -16,19 +16,19 @@ $userid = OC_User::getUser();
$name = trim(strip_tags($_POST['name'])); $name = trim(strip_tags($_POST['name']));
if(!$name) { if(!$name) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR);
exit(); exit();
} }
$bookid = OC_Contacts_Addressbook::add($userid, $name, null); $bookid = OC_Contacts_Addressbook::add($userid, $name, null);
if(!$bookid) { if(!$bookid) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR);
exit(); exit();
} }
if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
//exit(); //exit();
} }
$addressbook = OC_Contacts_App::getAddressbook($bookid); $addressbook = OC_Contacts_App::getAddressbook($bookid);

2
apps/contacts/ajax/cropphoto.php Normal file → Executable file
View File

@ -29,7 +29,7 @@ OC_JSON::checkAppEnabled('contacts');
$tmp_path = $_GET['tmp_path']; $tmp_path = $_GET['tmp_path'];
$id = $_GET['id']; $id = $_GET['id'];
OC_Log::write('contacts','ajax/cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
$tmpl = new OC_TEMPLATE("contacts", "part.cropphoto"); $tmpl = new OC_TEMPLATE("contacts", "part.cropphoto");
$tmpl->assign('tmp_path', $tmp_path); $tmpl->assign('tmp_path', $tmp_path);
$tmpl->assign('id', $id); $tmpl->assign('id', $id);

4
apps/contacts/ajax/currentphoto.php Normal file → Executable file
View File

@ -29,11 +29,11 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/currentphoto.php: '.$msg, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/currentphoto.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::DEBUG);
} }
if (!isset($_GET['id'])) { if (!isset($_GET['id'])) {

2
apps/contacts/ajax/deletecard.php Normal file → Executable file
View File

@ -21,7 +21,7 @@
*/ */
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }

2
apps/contacts/ajax/deleteproperty.php Normal file → Executable file
View File

@ -41,7 +41,7 @@ unset($vcard->children[$line]);
if(!OC_Contacts_VCard::edit($id,$vcard)) { if(!OC_Contacts_VCard::edit($id,$vcard)) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.'))));
OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR);
exit(); exit();
} }

4
apps/contacts/ajax/editname.php Normal file → Executable file
View File

@ -11,11 +11,11 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/editname.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/editname.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
} }
$tmpl = new OC_TEMPLATE("contacts", "part.edit_name_dialog"); $tmpl = new OC_TEMPLATE("contacts", "part.edit_name_dialog");

4
apps/contacts/ajax/loadcard.php Normal file → Executable file
View File

@ -24,11 +24,11 @@
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/loadcard.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/loadcard.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/loadcard.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/loadcard.php: '.$msg, OCP\Util::DEBUG);
} }
// foreach ($_POST as $key=>$element) { // foreach ($_POST as $key=>$element) {
// debug('_POST: '.$key.'=>'.$element); // debug('_POST: '.$key.'=>'.$element);

4
apps/contacts/ajax/loadphoto.php Normal file → Executable file
View File

@ -26,12 +26,12 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
// foreach ($_POST as $key=>$element) { // foreach ($_POST as $key=>$element) {
// OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG); // OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG);
// } // }
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/loadphoto.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }

4
apps/contacts/ajax/oc_photo.php Normal file → Executable file
View File

@ -29,11 +29,11 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/oc_photo.php: '.$msg, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/oc_photo.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::DEBUG);
} }
if(!isset($_GET['id'])) { if(!isset($_GET['id'])) {

14
apps/contacts/ajax/savecrop.php Normal file → Executable file
View File

@ -23,14 +23,14 @@
*/ */
// Init owncloud // Init owncloud
OC_Log::write('contacts','ajax/savecrop.php: Huzzah!!!', OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/savecrop.php: Huzzah!!!', OCP\Util::DEBUG);
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
// foreach ($_POST as $key=>$element) { // foreach ($_POST as $key=>$element) {
// OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG); // OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG);
// } // }
// Firefox and Konqueror tries to download application/json for me. --Arthur // Firefox and Konqueror tries to download application/json for me. --Arthur
@ -38,7 +38,7 @@ OC_JSON::setContentTypeHeader('text/plain');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/savecrop.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
@ -61,14 +61,14 @@ if($id == '') {
bailOut('Missing contact id.'); bailOut('Missing contact id.');
} }
OC_Log::write('contacts','savecrop.php: files: '.$tmp_path.' exists: '.file_exists($tmp_path), OC_Log::DEBUG); OCP\Util::writeLog('contacts','savecrop.php: files: '.$tmp_path.' exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
if(file_exists($tmp_path)) { if(file_exists($tmp_path)) {
$image = new OC_Image(); $image = new OC_Image();
if($image->loadFromFile($tmp_path)) { if($image->loadFromFile($tmp_path)) {
$w = ($w != -1 ? $w : $image->width()); $w = ($w != -1 ? $w : $image->width());
$h = ($h != -1 ? $h : $image->height()); $h = ($h != -1 ? $h : $image->height());
OC_Log::write('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OC_Log::DEBUG); OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
if($image->crop($x1, $y1, $w, $h)) { if($image->crop($x1, $y1, $w, $h)) {
if($image->resize(200)) { if($image->resize(200)) {
$tmpfname = tempnam("/tmp", "occCropped"); // create a new file because of caching issues. $tmpfname = tempnam("/tmp", "occCropped"); // create a new file because of caching issues.
@ -80,7 +80,7 @@ if(file_exists($tmp_path)) {
bailOut('Error getting contact object.'); bailOut('Error getting contact object.');
} }
if($card->__isset('PHOTO')) { if($card->__isset('PHOTO')) {
OC_Log::write('contacts','savecrop.php: PHOTO property exists.', OC_Log::DEBUG); OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
$property = $card->__get('PHOTO'); $property = $card->__get('PHOTO');
if(!$property) { if(!$property) {
unlink($tmpfname); unlink($tmpfname);
@ -91,7 +91,7 @@ if(file_exists($tmp_path)) {
$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType()); $property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
$card->__set('PHOTO', $property); $card->__set('PHOTO', $property);
} else { } else {
OC_Log::write('contacts','savecrop.php: files: Adding PHOTO property.', OC_Log::DEBUG); OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
$card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType())); $card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
} }
$now = new DateTime; $now = new DateTime;

4
apps/contacts/ajax/saveproperty.php Normal file → Executable file
View File

@ -29,11 +29,11 @@ OC_JSON::checkAppEnabled('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
} }
// foreach ($_POST as $key=>$element) { // foreach ($_POST as $key=>$element) {
// debug('_POST: '.$key.'=>'.print_r($element, true)); // debug('_POST: '.$key.'=>'.print_r($element, true));

6
apps/contacts/ajax/updateaddressbook.php Normal file → Executable file
View File

@ -18,19 +18,19 @@ OC_Contacts_App::getAddressbook($bookid); // is owner access check
$name = trim(strip_tags($_POST['name'])); $name = trim(strip_tags($_POST['name']));
if(!$name) { if(!$name) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'))));
OC_Log::write('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR);
exit(); exit();
} }
if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) {
OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.'))));
OC_Log::write('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR);
//exit(); //exit();
} }
if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
OC_JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); OC_JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.'))));
OC_Log::write('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR);
//exit(); //exit();
} }

6
apps/contacts/ajax/uploadimport.php Normal file → Executable file
View File

@ -27,11 +27,11 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/uploadimport.php: '.$msg, OC_Log::ERROR); OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/uploadimport.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::DEBUG);
} }
$view = OC_App::getStorage('contacts'); $view = OC_App::getStorage('contacts');
@ -51,7 +51,7 @@ if($fn) {
// File input transfers are handled here // File input transfers are handled here
if (!isset($_FILES['importfile'])) { if (!isset($_FILES['importfile'])) {
OC_Log::write('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OC_Log::DEBUG); 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' ))); OC_JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
exit(); exit();
} }

10
apps/contacts/ajax/uploadphoto.php Normal file → Executable file
View File

@ -29,11 +29,11 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('contacts','ajax/uploadphoto.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
exit(); exit();
} }
function debug($msg) { function debug($msg) {
OC_Log::write('contacts','ajax/uploadphoto.php: '.$msg, OC_Log::DEBUG); OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
} }
// If it is a Drag'n'Drop transfer it's handled here. // If it is a Drag'n'Drop transfer it's handled here.
@ -41,7 +41,7 @@ $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : fals
if ($fn) { if ($fn) {
// AJAX call // AJAX call
if (!isset($_GET['id'])) { if (!isset($_GET['id'])) {
OC_Log::write('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OC_Log::DEBUG); 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.' ))); OC_JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' )));
exit(); exit();
} }
@ -70,12 +70,12 @@ if ($fn) {
if (!isset($_POST['id'])) { if (!isset($_POST['id'])) {
OC_Log::write('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OC_Log::DEBUG); 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.' ))); OC_JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' )));
exit(); exit();
} }
if (!isset($_FILES['imagefile'])) { if (!isset($_FILES['imagefile'])) {
OC_Log::write('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OC_Log::DEBUG); 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' ))); OC_JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
exit(); exit();
} }

2
apps/contacts/dynphoto.php Normal file → Executable file
View File

@ -26,7 +26,7 @@ $tmp_path = $_GET['tmp_path'];
$maxsize = isset($_GET['maxsize']) ? $_GET['maxsize'] : -1; $maxsize = isset($_GET['maxsize']) ? $_GET['maxsize'] : -1;
header("Cache-Control: no-cache, no-store, must-revalidate"); header("Cache-Control: no-cache, no-store, must-revalidate");
OC_Log::write('contacts','dynphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OC_Log::DEBUG); OCP\Util::writeLog('contacts','dynphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
$image = new OC_Image($tmp_path); $image = new OC_Image($tmp_path);
if($maxsize != -1) { if($maxsize != -1) {

4
apps/contacts/import.php Normal file → Executable file
View File

@ -116,7 +116,7 @@ foreach($importready as $import){
$card = OC_VObject::parse($import); $card = OC_VObject::parse($import);
if (!$card) { if (!$card) {
$failed += 1; $failed += 1;
OC_Log::write('contacts','Import: skipping card. Error parsing VCard: '.$import, OC_Log::ERROR); OCP\Util::writeLog('contacts','Import: skipping card. Error parsing VCard: '.$import, OCP\Util::ERROR);
continue; // Ditch cards that can't be parsed by Sabre. continue; // Ditch cards that can't be parsed by Sabre.
} }
$imported += 1; $imported += 1;
@ -134,7 +134,7 @@ if(is_writable('import_tmp/')){
} }
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
if(!$view->unlink('/' . $_POST['file'])) { if(!$view->unlink('/' . $_POST['file'])) {
OC_Log::write('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OC_Log::ERROR); OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR);
} }
} }
OC_JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed))); OC_JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed)));

8
apps/contacts/lib/addressbook.php Normal file → Executable file
View File

@ -195,9 +195,9 @@ class OC_Contacts_Addressbook{
$stmt = OC_DB::prepare( $prep ); $stmt = OC_DB::prepare( $prep );
$result = $stmt->execute($active); $result = $stmt->execute($active);
} catch(Exception $e) { } catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OCP\Util::DEBUG);
} }
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
@ -246,7 +246,7 @@ class OC_Contacts_Addressbook{
* @return boolean * @return boolean
*/ */
public static function isActive($id){ public static function isActive($id){
//OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG); //OCP\Util::writeLog('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OCP\Util::DEBUG);
return in_array($id, self::activeIds()); return in_array($id, self::activeIds());
} }

12
apps/contacts/lib/app.php Normal file → Executable file
View File

@ -19,11 +19,11 @@ class OC_Contacts_App {
$addressbook = OC_Contacts_Addressbook::find( $id ); $addressbook = OC_Contacts_Addressbook::find( $id );
if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) { if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) {
if ($addressbook === false) { if ($addressbook === false) {
OC_Log::write('contacts', 'Addressbook not found: '. $id, OC_Log::ERROR); OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR);
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.')))); OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
} }
else { else {
OC_Log::write('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OC_Log::ERROR); OCP\Util::writeLog('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OCP\Util::ERROR);
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
} }
exit(); exit();
@ -34,7 +34,7 @@ class OC_Contacts_App {
public static function getContactObject($id) { public static function getContactObject($id) {
$card = OC_Contacts_VCard::find( $id ); $card = OC_Contacts_VCard::find( $id );
if( $card === false ) { if( $card === false ) {
OC_Log::write('contacts', 'Contact could not be found: '.$id, OC_Log::ERROR); 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))); OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.$id)));
exit(); exit();
} }
@ -55,11 +55,11 @@ class OC_Contacts_App {
if(!is_null($vcard) && !$vcard->__isset('N')) { if(!is_null($vcard) && !$vcard->__isset('N')) {
$appinfo = OC_App::getAppInfo('contacts'); $appinfo = OC_App::getAppInfo('contacts');
if($appinfo['version'] >= 5) { if($appinfo['version'] >= 5) {
OC_Log::write('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG);
} }
OC_Log::write('contacts','getContactVCard, Missing N field', OC_Log::DEBUG); OCP\Util::writeLog('contacts','getContactVCard, Missing N field', OCP\Util::DEBUG);
if($vcard->__isset('FN')) { if($vcard->__isset('FN')) {
OC_Log::write('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OC_Log::DEBUG); OCP\Util::writeLog('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG);
$n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;'; $n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;';
$vcard->setString('N', $n); $vcard->setString('N', $n);
OC_Contacts_VCard::edit( $id, $vcard); OC_Contacts_VCard::edit( $id, $vcard);

40
apps/contacts/lib/vcard.php Normal file → Executable file
View File

@ -56,17 +56,17 @@ class OC_Contacts_VCard{
$stmt = OC_DB::prepare( $prep ); $stmt = OC_DB::prepare( $prep );
$result = $stmt->execute($id); $result = $stmt->execute($id);
} catch(Exception $e) { } catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OCP\Util::DEBUG);
OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG); OCP\Util::writeLog('contacts','SQL:'.$prep,OCP\Util::DEBUG);
} }
} elseif($id) { } elseif($id) {
try { try {
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' ); $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
$result = $stmt->execute(array($id)); $result = $stmt->execute(array($id));
} catch(Exception $e) { } catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG); OC\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '. $id,OC_Log::DEBUG); OC\Util::writeLog('contacts','OC_Contacts_VCard:all, ids: '. $id,OCP\Util::DEBUG);
} }
} }
$cards = array(); $cards = array();
@ -181,7 +181,7 @@ class OC_Contacts_VCard{
// Add version if needed // Add version if needed
if($version && $version < '3.0') { if($version && $version < '3.0') {
$upgrade = true; $upgrade = true;
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OCP\Util::DEBUG);
} }
foreach($vcard->children as &$property){ foreach($vcard->children as &$property){
// Decode string properties and remove obsolete properties. // Decode string properties and remove obsolete properties.
@ -190,9 +190,9 @@ class OC_Contacts_VCard{
} }
// Fix format of type parameters. // Fix format of type parameters.
if($upgrade && in_array($property->name, $typeprops)) { if($upgrade && in_array($property->name, $typeprops)) {
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OCP\Util::DEBUG);
self::formatPropertyTypes($property); self::formatPropertyTypes($property);
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OCP\Util::DEBUG);
} }
if($property->name == 'FN'){ if($property->name == 'FN'){
$fn = $property->value; $fn = $property->value;
@ -222,7 +222,7 @@ class OC_Contacts_VCard{
$fn = 'Unknown Name'; $fn = 'Unknown Name';
} }
$vcard->setString('FN', $fn); $vcard->setString('FN', $fn);
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OCP\Util::DEBUG);
} }
if(!$n || $n = ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-) if(!$n || $n = ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-)
$slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse. $slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse.
@ -231,12 +231,12 @@ class OC_Contacts_VCard{
} }
$n = implode(';', $slice).';;;'; $n = implode(';', $slice).';;;';
$vcard->setString('N', $n); $vcard->setString('N', $n);
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OC_Log::DEBUG); OC\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OCP\Util::DEBUG);
} }
if(!$uid) { if(!$uid) {
$vcard->setUID(); $vcard->setUID();
$uid = $vcard->getAsString('UID'); $uid = $vcard->getAsString('UID');
OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OCP\Util::DEBUG);
} }
if(self::trueUID($aid, $uid)) { if(self::trueUID($aid, $uid)) {
$vcard->setString('UID', $uid); $vcard->setString('UID', $uid);
@ -263,7 +263,7 @@ class OC_Contacts_VCard{
*/ */
public static function add($aid, OC_VObject $card, $uri=null){ public static function add($aid, OC_VObject $card, $uri=null){
if(is_null($card)){ if(is_null($card)){
OC_Log::write('contacts','OC_Contacts_VCard::add. No vCard supplied', OC_Log::ERROR); OCP\Util::writeLog('contacts','OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
return null; return null;
}; };
@ -317,10 +317,10 @@ class OC_Contacts_VCard{
$data = $vcard->serialize(); $data = $vcard->serialize();
try { try {
$result = $stmt->execute(array($data,time(),$object[0])); $result = $stmt->execute(array($data,time(),$object[0]));
//OC_Log::write('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OC_Log::DEBUG); //OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG);
} catch(Exception $e) { } catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_VCard::updateDataByID:, exception: '.$e->getMessage(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0],OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0],OCP\Util::DEBUG);
} }
} }
} }
@ -526,9 +526,9 @@ class OC_Contacts_VCard{
$vals = array_merge((array)$aid, $id); $vals = array_merge((array)$aid, $id);
$result = $stmt->execute($vals); $result = $stmt->execute($vals);
} catch(Exception $e) { } catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook, ids: '.join(',', $vals),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook, ids: '.join(',', $vals),OCP\Util::DEBUG);
OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG); OCP\Util::writeLog('contacts','SQL:'.$prep,OCP\Util::DEBUG);
return false; return false;
} }
} else { } else {
@ -536,8 +536,8 @@ class OC_Contacts_VCard{
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' ); $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' );
$result = $stmt->execute(array($aid, $id)); $result = $stmt->execute(array($aid, $id));
} catch(Exception $e) { } catch(Exception $e) {
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook, id: '.$id,OC_Log::DEBUG); OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook, id: '.$id,OCP\Util::DEBUG);
return false; return false;
} }
} }

2
apps/contacts/photo.php Normal file → Executable file
View File

@ -33,7 +33,7 @@ if(!$image) {
} }
// invalid vcard // invalid vcard
if( is_null($contact)) { if( is_null($contact)) {
OC_Log::write('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR); OCP\Util::writeLog('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR);
} else { } else {
OC_Response::enableCaching($caching); OC_Response::enableCaching($caching);
OC_Contacts_App::setLastModifiedHeader($contact); OC_Contacts_App::setLastModifiedHeader($contact);

2
apps/contacts/templates/part.cropphoto.php Normal file → Executable file
View File

@ -1,7 +1,7 @@
<?php <?php
$id = $_['id']; $id = $_['id'];
$tmp_path = $_['tmp_path']; $tmp_path = $_['tmp_path'];
OC_Log::write('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OC_Log::DEBUG); OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
?> ?>
<script language="Javascript"> <script language="Javascript">
jQuery(function($) { jQuery(function($) {

12
apps/contacts/thumbnail.php Normal file → Executable file
View File

@ -33,7 +33,7 @@ function getStandardImage(){
} }
if(!function_exists('imagecreatefromjpeg')) { if(!function_exists('imagecreatefromjpeg')) {
OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG); OCP\Util::writeLog('contacts','thumbnail.php. GD module not installed',OCP\Util::DEBUG);
getStandardImage(); getStandardImage();
exit(); exit();
} }
@ -45,7 +45,7 @@ $contact = OC_Contacts_App::getContactVCard($id);
// invalid vcard // invalid vcard
if(is_null($contact)){ if(is_null($contact)){
OC_Log::write('contacts','thumbnail.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR); OCP\Util::writeLog('contacts','thumbnail.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR);
getStandardImage(); getStandardImage();
exit(); exit();
} }
@ -67,16 +67,16 @@ if($photo) {
// done // done
exit(); exit();
} else { } else {
OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR); OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OCP\Util::ERROR);
} }
} else { } else {
OC_Log::write('contacts','thumbnail.php. Couldn\'t resize thumbnail for ID '.$id,OC_Log::ERROR); OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t resize thumbnail for ID '.$id,OCP\Util::ERROR);
} }
}else{ }else{
OC_Log::write('contacts','thumbnail.php. Couldn\'t crop thumbnail for ID '.$id,OC_Log::ERROR); OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t crop thumbnail for ID '.$id,OCP\Util::ERROR);
} }
} else { } else {
OC_Log::write('contacts','thumbnail.php. Couldn\'t load image string for ID '.$id,OC_Log::ERROR); OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t load image string for ID '.$id,OCP\Util::ERROR);
} }
} }
getStandardImage(); getStandardImage();

2
apps/files_archive/lib/zip.php Normal file → Executable file
View File

@ -19,7 +19,7 @@ class OC_Archive_ZIP extends OC_Archive{
$this->zip=new ZipArchive(); $this->zip=new ZipArchive();
if($this->zip->open($source,ZipArchive::CREATE)){ if($this->zip->open($source,ZipArchive::CREATE)){
}else{ }else{
OC_LOG::write('files_archive','Error while opening archive '.$source,OC_Log::WARN); OCP\Util::writeLog('files_archive','Error while opening archive '.$source,OCP\Util::WARN);
} }
} }
/** /**

6
apps/files_encryption/lib/cryptstream.php Normal file → Executable file
View File

@ -42,12 +42,12 @@ class OC_CryptStream{
$this->path=self::$sourceStreams[basename($path)]['path']; $this->path=self::$sourceStreams[basename($path)]['path'];
}else{ }else{
$this->path=$path; $this->path=$path;
OC_Log::write('files_encryption','open encrypted '.$path. ' in '.$mode,OC_Log::DEBUG); OCP\Util::writeLog('files_encryption','open encrypted '.$path. ' in '.$mode,OCP\Util::DEBUG);
OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file
$this->source=OC_FileSystem::fopen($path,$mode); $this->source=OC_FileSystem::fopen($path,$mode);
OC_FileProxy::$enabled=true; OC_FileProxy::$enabled=true;
if(!is_resource($this->source)){ if(!is_resource($this->source)){
OC_Log::write('files_encryption','failed to open '.$path,OC_Log::ERROR); OCP\Util::writeLog('files_encryption','failed to open '.$path,OCP\Util::ERROR);
} }
} }
if(is_resource($this->source)){ if(is_resource($this->source)){
@ -68,7 +68,7 @@ class OC_CryptStream{
//$count will always be 8192 https://bugs.php.net/bug.php?id=21641 //$count will always be 8192 https://bugs.php.net/bug.php?id=21641
//This makes this function a lot simpler but will breake everything the moment it's fixed //This makes this function a lot simpler but will breake everything the moment it's fixed
if($count!=8192){ if($count!=8192){
OC_Log::write('files_encryption','php bug 21641 no longer holds, decryption will not work',OC_Log::FATAL); OCP\Util::writeLog('files_encryption','php bug 21641 no longer holds, decryption will not work',OCP\Util::FATAL);
die(); die();
} }
$data=fread($this->source,8192); $data=fread($this->source,8192);

2
apps/files_encryption/lib/proxy.php Normal file → Executable file
View File

@ -90,7 +90,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
}elseif(self::shouldEncrypt($path) and $meta['mode']!='r' and $meta['mode']!='rb'){ }elseif(self::shouldEncrypt($path) and $meta['mode']!='r' and $meta['mode']!='rb'){
if(OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path)>0){ if(OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path)>0){
//first encrypt the target file so we don't end up with a half encrypted file //first encrypt the target file so we don't end up with a half encrypted file
OC_Log::write('files_encryption','Decrypting '.$path.' before writing',OC_Log::DEBUG); OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing',OCP\Util::DEBUG);
$tmp=fopen('php://temp'); $tmp=fopen('php://temp');
OC_Helper::streamCopy($result,$tmp); OC_Helper::streamCopy($result,$tmp);
fclose($result); fclose($result);

4
apps/files_sharing/ajax/share.php Normal file → Executable file
View File

@ -15,7 +15,7 @@ foreach ($sources as $source) {
$source = $userDirectory.$source; $source = $userDirectory.$source;
// If the file doesn't exist, it may be shared with the current user // If the file doesn't exist, it may be shared with the current user
} else if (!$source = OC_Share::getSource($userDirectory.$source)) { } else if (!$source = OC_Share::getSource($userDirectory.$source)) {
OC_Log::write('files_sharing',"Shared file doesn't exists :".$source,OC_Log::ERROR); OCP\Util::writeLog('files_sharing',"Shared file doesn't exists :".$source,OCP\Util::ERROR);
echo "false"; echo "false";
} }
try { try {
@ -24,7 +24,7 @@ foreach ($sources as $source) {
echo $shared->getToken(); echo $shared->getToken();
} }
} catch (Exception $exception) { } catch (Exception $exception) {
OC_Log::write('files_sharing',"Unexpected Error : ".$exception->getMessage(),OC_Log::ERROR); OC\Util::writeLog('files_sharing',"Unexpected Error : ".$exception->getMessage(),OCP\Util::ERROR);
echo "false"; echo "false";
} }
} }

2
apps/files_sharing/lib_share.php Normal file → Executable file
View File

@ -310,7 +310,7 @@ class OC_Share {
return $result[0]['permissions']; return $result[0]['permissions'];
} }
} else { } else {
OC_Log::write('files_sharing',"Not existing parent folder : ".$target,OC_Log::ERROR); OCP\Util::writeLog('files_sharing',"Not existing parent folder : ".$target,OCP\Util::ERROR);
return false; return false;
} }
} }

6
apps/files_texteditor/ajax/savefile.php Normal file → Executable file
View File

@ -40,7 +40,7 @@ if($path != '' && $mtime != '')
{ {
// Then the file has changed since opening // Then the file has changed since opening
OC_JSON::error(); OC_JSON::error();
OC_Log::write('files_texteditor',"File: ".$path." modified since opening.",OC_Log::ERROR); OCP\Util::writeLog('files_texteditor',"File: ".$path." modified since opening.",OCP\Util::ERROR);
} }
else else
{ {
@ -59,10 +59,10 @@ if($path != '' && $mtime != '')
{ {
// Not writeable! // Not writeable!
OC_JSON::error(array('data' => array( 'message' => 'Insufficient permissions'))); OC_JSON::error(array('data' => array( 'message' => 'Insufficient permissions')));
OC_Log::write('files_texteditor',"User does not have permission to write to file: ".$path,OC_Log::ERROR); OCP\Util::writeLog('files_texteditor',"User does not have permission to write to file: ".$path,OCP\Util::ERROR);
} }
} }
} else { } else {
OC_JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied'))); OC_JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied')));
OC_Log::write('files_texteditor',"Invalid path supplied:".$path,OC_Log::ERROR); OCP\Util::writeLog('files_texteditor',"Invalid path supplied:".$path,OCP\Util::ERROR);
} }

4
apps/gallery/lib/hooks_handlers.php Normal file → Executable file
View File

@ -52,7 +52,7 @@ class OC_Gallery_Hooks_Handlers {
if ($new_album_name == '') if ($new_album_name == '')
$new_album_name = 'main'; $new_album_name = 'main';
OCP\Util::writeLog(self::$APP_TAG, 'Creating new album '.$new_album_name, OC_Log::DEBUG); OCP\Util::writeLog(self::$APP_TAG, 'Creating new album '.$new_album_name, OCP\Util::DEBUG);
OC_Gallery_Album::create(OC_User::getUser(), $new_album_name, $path); OC_Gallery_Album::create(OC_User::getUser(), $new_album_name, $path);
return OC_Gallery_Album::find(OC_User::getUser(), null, $path); return OC_Gallery_Album::find(OC_User::getUser(), null, $path);
@ -110,7 +110,7 @@ class OC_Gallery_Hooks_Handlers {
if ($olddir == '') $olddir = '/'; if ($olddir == '') $olddir = '/';
if ($newdir == '') $newdir = '/'; if ($newdir == '') $newdir = '/';
if (!self::isPhoto($newpath)) return; if (!self::isPhoto($newpath)) return;
OCP\Util::writeLog(self::$APP_TAG, 'Moving photo from '.$oldpath.' to '.$newpath, OC_Log::DEBUG); OCP\Util::writeLog(self::$APP_TAG, 'Moving photo from '.$oldpath.' to '.$newpath, OCP\Util::DEBUG);
$album; $album;
$newAlbumId; $newAlbumId;
$oldAlbumId; $oldAlbumId;

8
apps/media/lib_scanner.php Normal file → Executable file
View File

@ -72,23 +72,23 @@ class OC_MEDIA_SCANNER{
$data=@self::$getID3->analyze($file); $data=@self::$getID3->analyze($file);
getid3_lib::CopyTagsToComments($data); getid3_lib::CopyTagsToComments($data);
if(!isset($data['comments'])){ if(!isset($data['comments'])){
OCP\Util::writeLog('media',"error reading id3 tags in '$file'",OC_Log::WARN); OCP\Util::writeLog('media',"error reading id3 tags in '$file'",OCP\Util::WARN);
return; return;
} }
if(!isset($data['comments']['artist'])){ if(!isset($data['comments']['artist'])){
OCP\Util::writeLog('media',"error reading artist tag in '$file'",OC_Log::WARN); OCP\Util::writeLog('media',"error reading artist tag in '$file'",OCP\Util::WARN);
$artist='unknown'; $artist='unknown';
}else{ }else{
$artist=stripslashes($data['comments']['artist'][0]); $artist=stripslashes($data['comments']['artist'][0]);
} }
if(!isset($data['comments']['album'])){ if(!isset($data['comments']['album'])){
OCP\Util::writeLog('media',"error reading album tag in '$file'",OC_Log::WARN); OCP\Util::writeLog('media',"error reading album tag in '$file'",OCP\Util::WARN);
$album='unknown'; $album='unknown';
}else{ }else{
$album=stripslashes($data['comments']['album'][0]); $album=stripslashes($data['comments']['album'][0]);
} }
if(!isset($data['comments']['title'])){ if(!isset($data['comments']['title'])){
OCP\Util::writeLog('media',"error reading title tag in '$file'",OC_Log::WARN); OCP\Util::writeLog('media',"error reading title tag in '$file'",OCP\Util::WARN);
$title='unknown'; $title='unknown';
}else{ }else{
$title=stripslashes($data['comments']['title'][0]); $title=stripslashes($data['comments']['title'][0]);

2
apps/media/server/xml.server.php Normal file → Executable file
View File

@ -37,7 +37,7 @@ foreach($arguments as &$argument){
} }
@ob_clean(); @ob_clean();
if(isset($arguments['action'])){ if(isset($arguments['action'])){
OCP\Util::writeLog('media','ampache '.$arguments['action'].' request', OC_Log::DEBUG); OCP\Util::writeLog('media','ampache '.$arguments['action'].' request', OCP\Util::DEBUG);
switch($arguments['action']){ switch($arguments['action']){
case 'songs': case 'songs':
OC_MEDIA_AMPACHE::songs($arguments); OC_MEDIA_AMPACHE::songs($arguments);

2
apps/user_ldap/lib_ldap.php Normal file → Executable file
View File

@ -529,7 +529,7 @@ class OC_LDAP {
self::init(); self::init();
} }
if(is_null(self::$ldapConnectionRes)) { if(is_null(self::$ldapConnectionRes)) {
OCP\Util::writeLog('ldap', 'Connection could not be established', OC_Log::INFO); OCP\Util::writeLog('ldap', 'Connection could not be established', OCP\Util::INFO);
} }
return self::$ldapConnectionRes; return self::$ldapConnectionRes;
} }

2
apps/user_migrate/admin.php Normal file → Executable file
View File

@ -37,7 +37,7 @@ if (isset($_POST['user_import'])) {
$to = get_temp_dir().'/'.$importname.'.zip'; $to = get_temp_dir().'/'.$importname.'.zip';
if( !move_uploaded_file( $from, $to ) ){ if( !move_uploaded_file( $from, $to ) ){
$error = array('error'=>'Failed to move the uploaded file','hint'=>'Try checking the permissions of the '.get_temp_dir().' dir.'); $error = array('error'=>'Failed to move the uploaded file','hint'=>'Try checking the permissions of the '.get_temp_dir().' dir.');
OCP\Util::writeLog( 'user_migrate', "Failed to copy the uploaded file", OC_Log::ERROR ); OCP\Util::writeLog( 'user_migrate', "Failed to copy the uploaded file", OCP\Util::ERROR );
$tmpl = new OC_Template('user_migrate', 'admin'); $tmpl = new OC_Template('user_migrate', 'admin');
$tmpl->assign('error',$error); $tmpl->assign('error',$error);
return $tmpl->fetchPage(); return $tmpl->fetchPage();

14
apps/user_openid/appinfo/app.php Normal file → Executable file
View File

@ -26,14 +26,14 @@ OC_User::useBackend('openid');
//check for results from openid requests //check for results from openid requests
if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){ if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
OCP\Util::writeLog('user_openid','openid retured',OC_Log::DEBUG); OCP\Util::writeLog('user_openid','openid retured',OCP\Util::DEBUG);
$openid = new SimpleOpenID; $openid = new SimpleOpenID;
$openid->SetIdentity($_GET['openid_identity']); $openid->SetIdentity($_GET['openid_identity']);
$openid_validation_result = $openid->ValidateWithServer(); $openid_validation_result = $openid->ValidateWithServer();
if ($openid_validation_result == true){ // OK HERE KEY IS VALID if ($openid_validation_result == true){ // OK HERE KEY IS VALID
OCP\Util::writeLog('user_openid','auth sucessfull',OC_Log::DEBUG); OCP\Util::writeLog('user_openid','auth sucessfull',OCP\Util::DEBUG);
$identity=$openid->GetIdentity(); $identity=$openid->GetIdentity();
OCP\Util::writeLog('user_openid','auth as '.$identity,OC_Log::DEBUG); OCP\Util::writeLog('user_openid','auth as '.$identity,OCP\Util::DEBUG);
$user=OC_USER_OPENID::findUserForIdentity($identity); $user=OC_USER_OPENID::findUserForIdentity($identity);
if($user){ if($user){
$_SESSION['user_id']=$user; $_SESSION['user_id']=$user;
@ -41,13 +41,13 @@ if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
} }
}else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR }else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR
$error = $openid->GetError(); $error = $openid->GetError();
OCP\Util::writeLog('user_openid','ERROR CODE: '. $error['code'],OC_Log::ERROR); OCP\Util::writeLog('user_openid','ERROR CODE: '. $error['code'],OCP\Util::ERROR);
OCP\Util::writeLog('user_openid','ERROR DESCRIPTION: '. $error['description'],OC_Log::ERROR); OCP\Util::writeLog('user_openid','ERROR DESCRIPTION: '. $error['description'],OCP\Util::ERROR);
}else{ // Signature Verification Failed }else{ // Signature Verification Failed
OCP\Util::writeLog('user_openid','INVALID AUTHORIZATION',OC_Log::ERROR); OCP\Util::writeLog('user_openid','INVALID AUTHORIZATION',OCP\Util::ERROR);
} }
}else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request }else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request
OCP\Util::writeLog('user_openid','USER CANCELED REQUEST',OC_Log::DEBUG); OCP\Util::writeLog('user_openid','USER CANCELED REQUEST',OCP\Util::DEBUG);
return false; return false;
} }

2
apps/user_openid/user.php Normal file → Executable file
View File

@ -40,7 +40,7 @@ require_once '../../lib/base.php';
OC_Util::checkAppEnabled('user_openid'); OC_Util::checkAppEnabled('user_openid');
if(!OC_User::userExists($USERNAME)){ if(!OC_User::userExists($USERNAME)){
OCP\Util::writeLog('user_openid',$USERNAME.' doesn\'t exist',OC_Log::WARN); OCP\Util::writeLog('user_openid',$USERNAME.' doesn\'t exist',OCP\Util::WARN);
$USERNAME=''; $USERNAME='';
} }
$IDENTITY=OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$USERNAME; $IDENTITY=OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$USERNAME;

View File

@ -32,6 +32,13 @@ namespace OCP;
class Util { class Util {
// consts for Logging
const DEBUG=0;
const INFO=1;
const WARN=2;
const ERROR=3;
const FATAL=4;
/** /**
* send an email * send an email
* *
@ -57,7 +64,7 @@ class Util {
* @param string $message * @param string $message
* @param int level * @param int level
*/ */
public static function writelog($app, $message, $level) { public static function writeLog($app, $message, $level) {
// call the internal log class // call the internal log class
\OC_LOG::write($app, $message, $level); \OC_LOG::write($app, $message, $level);