remove explicit class registration, minor whitespace fixes

This commit is contained in:
Jörn Friedrich Dreyer 2013-10-30 16:09:34 +01:00
Родитель 669eecb3df
Коммит 34bd22d254
7 изменённых файлов: 49 добавлений и 62 удалений

Просмотреть файл

@ -21,15 +21,6 @@
*
*/
// register the path of the libraries
OC::$CLASSPATH['OCA\Activity\Consumer'] = 'activity/lib/lib_consumer.php';
OC::$CLASSPATH['OCA\Activity\Data'] = 'activity/lib/lib_activity.php';
OC::$CLASSPATH['OCA\Activity\Hook'] = 'activity/lib/lib_hooks.php';
OC::$CLASSPATH['OCA\Activity\OCS'] = 'activity/lib/lib_ocs.php';
OC::$CLASSPATH['OCA\Activity\Search'] = 'activity/lib/lib_search.php';
// add an navigation entry
$l=OC_L10N::get('activity');
OCP\App::addNavigationEntry(array(
@ -40,7 +31,7 @@ OCP\App::addNavigationEntry(array(
'name' => $l->t('Activity')));
// register the hooks for filesystem operations. All other events from other apps has to be send via the public api
OCA\Activity\Hook::register();
OCA\Activity\Hooks::register();
OC_Search::registerProvider('\OCA\Activity\Search');

Просмотреть файл

@ -40,6 +40,6 @@ class Consumer implements IConsumer
* @return mixed
*/
function receive($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority) {
\OCA\Activity\Data::send($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority);
Data::send($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority);
}
}

Просмотреть файл

@ -45,7 +45,7 @@ class Data
* @param string $link A link where this event is associated with (optional)
* @return boolean
*/
public static function send($app, $subject, $subjectparams = array(), $message = '', $messageparams = array(), $file = '', $link = '', $affecteduser = '', $type = 0, $prio = \OCA\Activity\Data::PRIORITY_MEDIUM)
public static function send($app, $subject, $subjectparams = array(), $message = '', $messageparams = array(), $file = '', $link = '', $affecteduser = '', $type = 0, $prio = Data::PRIORITY_MEDIUM)
{
$timestamp = time();
@ -63,7 +63,7 @@ class Data
// call the expire function only every 1000x time to preserve performance.
if (rand(0, 1000) == 0) {
\OCA\Activity\Data::expire();
Data::expire();
}
// fire a hook so that other apps like notification systems can connect
@ -105,8 +105,8 @@ class Data
$activity = array();
while ($row = $result->fetchRow()) {
$row['subject'] = \OCA\Activity\Data::translation($row['app'],$row['subject'],unserialize($row['subjectparams']));
$row['message'] = \OCA\Activity\Data::translation($row['app'],$row['message'],unserialize($row['messageparams']));
$row['subject'] = Data::translation($row['app'],$row['subject'],unserialize($row['subjectparams']));
$row['message'] = Data::translation($row['app'],$row['message'],unserialize($row['messageparams']));
$activity[] = $row;
}
return $activity;
@ -131,8 +131,8 @@ class Data
$activity = array();
while ($row = $result->fetchRow()) {
$row['subject'] = \OCA\Activity\Data::translation($row['app'],$row['subject'],unserialize($row['subjectparams']));
$row['message'] = \OCA\Activity\Data::translation($row['app'],$row['message'],unserialize($row['messageparams']));
$row['subject'] = Data::translation($row['app'],$row['subject'],unserialize($row['subjectparams']));
$row['message'] = Data::translation($row['app'],$row['message'],unserialize($row['messageparams']));
$activity[] = $row;
}
return $activity;

Просмотреть файл

@ -27,7 +27,7 @@ namespace OCA\Activity;
/**
* @brief The class to handle the filesystem hooks
*/
class Hook {
class Hooks {
public static $createhookfired = false;
public static $createhookfile = '';
@ -39,23 +39,23 @@ class Hook {
public static function register() {
//Listen to create file signal
\OCP\Util::connectHook('OC_Filesystem', 'post_create', "OCA\Activity\Hook", "file_create");
\OCP\Util::connectHook('OC_Filesystem', 'post_create', "OCA\Activity\Hooks", "file_create");
//Listen to delete file signal
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Activity\Hook", "file_delete");
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Activity\Hooks", "file_delete");
//Listen to write file signal
\OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA\Activity\Hook", "file_write");
\OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA\Activity\Hooks", "file_write");
//Listen to share signal
\OCP\Util::connectHook('OCP\Share', 'post_shared', "OCA\Activity\Hook", "share");
\OCP\Util::connectHook('OCP\Share', 'post_shared', "OCA\Activity\Hooks", "share");
// hooking up the activity manager
if (property_exists('OC', 'server')) {
if (method_exists(\OC::$server, 'getActivityManager')) {
$am = \OC::$server->getActivityManager();
$am->registerConsumer(function() {
return new \OCA\Activity\Consumer();
return new Consumer();
});
}
}
@ -67,35 +67,35 @@ class Hook {
*/
public static function file_write($params) {
if( HOOK::$createhookfired ) {
$params['path'] = HOOK::$createhookfile;
if( self::$createhookfired ) {
$params['path'] = self::$createhookfile;
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($params['path'])));
$subject = '%s created';
\OCA\Activity\Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 3);
Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 3);
if(substr($params['path'],0,8)=='/Shared/') {
$uidOwner = \OC\Files\Filesystem::getOwner($params['path']);
$realfile=substr($params['path'],7);
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($realfile)));
$subject = '%s created by %s';
\OCA\Activity\Data::send('files', $subject, array($realfile,\OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 8,\OCA\Activity\Data::PRIORITY_HIGH);
Data::send('files', $subject, array($realfile,\OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 8, Data::PRIORITY_HIGH);
}
HOOK::$createhookfired = false;
HOOK::$createhookfile = '';
self::$createhookfired = false;
self::$createhookfile = '';
} else {
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($params['path'])));
$subject = '%s changed';
\OCA\Activity\Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 1);
Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 1);
if(substr($params['path'],0,8)=='/Shared/') {
$uidOwner = \OC\Files\Filesystem::getOwner($params['path']);
$realfile=substr($params['path'],7);
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($realfile)));
$subject = '%s changed by %s';
\OCA\Activity\Data::send('files', $subject, array($realfile,\OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 6,\OCA\Activity\Data::PRIORITY_HIGH);
Data::send('files', $subject, array($realfile,\OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 6, Data::PRIORITY_HIGH);
}
}
@ -109,14 +109,14 @@ class Hook {
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($params['path'])));
$subject = '%s deleted';
\OCA\Activity\Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 2);
Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 2);
if(substr($params['path'],0,8)=='/Shared/') {
$uidOwner = \OC\Files\Filesystem::getOwner($params['path']);
$realfile=substr($params['path'],7);
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($realfile)));
$subject = '%s deleted by %s';
\OCA\Activity\Data::send('files', $subject, array($realfile,\OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 7,\OCA\Activity\Data::PRIORITY_HIGH);
Data::send('files', $subject, array($realfile,\OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 7, Data::PRIORITY_HIGH);
}
}
@ -128,8 +128,8 @@ class Hook {
public static function file_create($params) {
// remember the create event for later consumption
HOOK::$createhookfired = true;
HOOK::$createhookfile = $params['path'];
self::$createhookfired = true;
self::$createhookfile = $params['path'];
}
@ -149,13 +149,13 @@ class Hook {
if(!empty($shareWith)) {
$subject = 'You shared %s with %s';
\OCA\Activity\Data::send('files', $subject, array(substr($params['fileTarget'], 1), $shareWith), '', array(), $params['fileTarget'], $link, \OCP\User::getUser(), 4, \OCA\Activity\Data::PRIORITY_MEDIUM );
Data::send('files', $subject, array(substr($params['fileTarget'], 1), $shareWith), '', array(), $params['fileTarget'], $link, \OCP\User::getUser(), 4, Data::PRIORITY_MEDIUM );
$subject = '%s shared %s with you';
\OCA\Activity\Data::send('files', $subject, array($sharedFrom, substr('/Shared'.$params['fileTarget'], 1)), '', array(), '/Shared/'.$params['fileTarget'], $link2, $shareWith, 5, \OCA\Activity\Data::PRIORITY_MEDIUM);
Data::send('files', $subject, array($sharedFrom, substr('/Shared'.$params['fileTarget'], 1)), '', array(), '/Shared/'.$params['fileTarget'], $link2, $shareWith, 5, Data::PRIORITY_MEDIUM);
} else {
$subject = 'You shared %s';
\OCA\Activity\Data::send('files', $subject, array(substr($params['fileTarget'], 1)), '', array(), $params['fileTarget'], $link, \OCP\User::getUser(), 4, \OCA\Activity\Data::PRIORITY_MEDIUM );
Data::send('files', $subject, array(substr($params['fileTarget'], 1)), '', array(), $params['fileTarget'], $link, \OCP\User::getUser(), 4, Data::PRIORITY_MEDIUM );
}
}

Просмотреть файл

@ -38,20 +38,20 @@ class OCS {
$start = isset($_GET['start']) ? $_GET['start'] : 0;
$count = isset($_GET['count']) ? $_GET['count'] : 30;
$data=\OCA\Activity\Data::read($start,$count);
$activities=array();
$data = Data::read($start,$count);
$activities = array();
foreach($data as $d) {
$activity=array();
$activity['id']=$d['activity_id'];
$activity['subject']=$d['subject'];
$activity['message']=$d['message'];
$activity['file']=$d['file'];
$activity['link']=$d['link'];
$activity['date']=date('c',$d['timestamp']);
$activities[]=$activity;
$activity = array();
$activity['id'] = $d['activity_id'];
$activity['subject'] = $d['subject'];
$activity['message'] = $d['message'];
$activity['file'] = $d['file'];
$activity['link'] = $d['link'];
$activity['date'] = date('c', $d['timestamp']);
$activities[] = $activity;
}
return new OC_OCS_Result($activities);
@ -60,4 +60,3 @@ class OCS {
}

Просмотреть файл

@ -36,20 +36,19 @@ class Search extends \OC_Search_Provider{
* @return search results
*/
function search($query){
$data=\OCA\Activity\Data::search($query,100);
$results=array();
$data = Data::search($query, 100);
$results = array();
foreach($data as $d){
$file=$d['file'];
$results[]=new \OC_Search_Result(
$file = $d['file'];
$results[] = new \OC_Search_Result(
basename($file),
$d['subject'].' ('.\OCP\Util::formatDate($d['timestamp']).')',
\OC_Helper::linkTo( 'activity', 'index.php' ),'Activity');
\OC_Helper::linkTo( 'activity', 'index.php' ), 'Activity');
}
return $results;
}
}

Просмотреть файл

@ -102,5 +102,3 @@ if (count($eventsInGroup) > 0){
}
echo('</div>'); // boxcontainer
echo('</div>'); // group
?>