From 7356dcfae3077ed6c15215492ad4941f046b3d0a Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 4 Aug 2014 20:51:50 +0300 Subject: [PATCH] Db_Session -> Db\Session --- ajax/documentController.php | 4 ++-- ajax/otpoll.php | 2 +- ajax/sessionController.php | 12 ++++++------ appinfo/app.php | 1 - appinfo/update.php | 2 +- lib/db/session.php | 26 +++++++++++++------------- lib/storage.php | 4 ++-- public.php | 2 +- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/ajax/documentController.php b/ajax/documentController.php index dd3d6edc..34d73eeb 100644 --- a/ajax/documentController.php +++ b/ajax/documentController.php @@ -51,7 +51,7 @@ class DocumentController extends Controller{ * @param array $args - array containing session id as an element with a key es_id */ public static function serve($args){ - $session = new Db_Session(); + $session = new Db\Session(); $session->load(@$args['es_id']); self::preDispatchGuest(); @@ -108,7 +108,7 @@ class DocumentController extends Controller{ return @$b['mtime']-@$a['mtime']; }); - $session = new Db_Session(); + $session = new Db\Session(); $sessions = $session->getCollectionBy('file_id', $fileIds); $members = array(); diff --git a/ajax/otpoll.php b/ajax/otpoll.php index e06e2682..f7fd940a 100644 --- a/ajax/otpoll.php +++ b/ajax/otpoll.php @@ -31,7 +31,7 @@ try{ $request = new Request(); $esId = $request->getParam('args/es_id'); - $session = new Db_Session(); + $session = new Db\Session(); $session->load($esId); $memberId = $request->getParam('args/member_id'); diff --git a/ajax/sessionController.php b/ajax/sessionController.php index fbee3c9c..ab5b9d40 100644 --- a/ajax/sessionController.php +++ b/ajax/sessionController.php @@ -23,7 +23,7 @@ class SessionController extends Controller{ try { $token = Helper::getArrayValueByKey($args, 'token'); $file = File::getByShareToken($token); - $session = Db_Session::start($uid, $file, true); + $session = Db\Session::start($uid, $file, true); \OCP\JSON::success($session); } catch (\Exception $e){ Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage()); @@ -42,7 +42,7 @@ class SessionController extends Controller{ if ($view->isUpdatable($path)) { $file = new File($fileId); - $session = Db_Session::start($uid, $file); + $session = Db\Session::start($uid, $file); \OCP\JSON::success($session); } else { $info = $view->getFileInfo(); @@ -93,7 +93,7 @@ class SessionController extends Controller{ } $content = stream_get_contents($stream); - $session = new Db_Session(); + $session = new Db\Session(); $session->load($esId); if (!$session->getEsId()){ @@ -157,7 +157,7 @@ class SessionController extends Controller{ $session->updateGenesisHash($esId, sha1($data['content'])); } else { // Last user. Kill session data - Db_Session::cleanUp($esId); + Db\Session::cleanUp($esId); } $view->touch($path); @@ -177,7 +177,7 @@ class SessionController extends Controller{ $info = array(); if (is_array($items)){ - $session = new Db_Session(); + $session = new Db\Session(); $info = $session->getInfoByFileId($items); } @@ -188,7 +188,7 @@ class SessionController extends Controller{ public static function listAll(){ self::preDispatch(); - $session = new Db_Session(); + $session = new Db\Session(); $sessions = $session->getCollection(); $preparedSessions = array_map( diff --git a/appinfo/app.php b/appinfo/app.php index fc20cb43..80a11026 100755 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -40,7 +40,6 @@ OC::$CLASSPATH['OCA\Documents\SessionController'] = 'documents/ajax/sessionContr OC::$CLASSPATH['OCA\Documents\UserController'] = 'documents/ajax/userController.php'; OC::$CLASSPATH['OCA\Documents\Download_Simple'] = 'documents/lib/download/simple.php'; OC::$CLASSPATH['OCA\Documents\Download_Range'] = 'documents/lib/download/range.php'; -OC::$CLASSPATH['OCA\Documents\Db_Session'] = 'documents/lib/db/session.php'; OC::$CLASSPATH['OCA\Documents\Db_Member'] = 'documents/lib/db/member.php'; OC::$CLASSPATH['OCA\Documents\Db_Op'] = 'documents/lib/db/op.php'; OC::$CLASSPATH['OCA\Documents\Filter_Office'] = 'documents/lib/filter/office.php'; diff --git a/appinfo/update.php b/appinfo/update.php index 7a5274fb..a5a75ecb 100644 --- a/appinfo/update.php +++ b/appinfo/update.php @@ -16,7 +16,7 @@ $cleanup->execute(); if (version_compare($installedVersion, '0.7', '<=')) { \OCP\Config::setAppValue('documents', 'unstable', 'false'); - $session = new \OCA\Documents\Db_Session(); + $session = new \OCA\Documents\Db\Session(); $query = \OC_DB::prepare('UPDATE `*PREFIX*documents_session` SET `genesis_url`=? WHERE `es_id`=?'); diff --git a/lib/db/session.php b/lib/db/session.php index 65f3ba15..53ad6b42 100644 --- a/lib/db/session.php +++ b/lib/db/session.php @@ -10,7 +10,7 @@ * later. */ -namespace OCA\Documents; +namespace OCA\Documents\Db; /** * Session management @@ -22,7 +22,7 @@ namespace OCA\Documents; * @method string getGenesisHash() * */ -class Db_Session extends \OCA\Documents\Db { +class Session extends \OCA\Documents\Db { /** * DB table @@ -44,15 +44,15 @@ class Db_Session extends \OCA\Documents\Db { */ public static function start($uid, $file){ // Create a directory to store genesis - $genesis = new Genesis($file); + $genesis = new \OCA\Documents\Genesis($file); list($ownerView, $path) = $file->getOwnerViewAndPath(); - $oldSession = new Db_Session(); + $oldSession = new Session(); $oldSession->loadBy('file_id', $file->getFileId()); //If there is no existing session we need to start a new one if (!$oldSession->hasData()){ - $newSession = new Db_Session(array( + $newSession = new Session(array( $genesis->getPath(), $genesis->getHash(), $file->getOwner(), @@ -69,8 +69,8 @@ class Db_Session extends \OCA\Documents\Db { ->getData() ; - $memberColor = Helper::getMemberColor($uid); - $member = new Db_Member(array( + $memberColor = \OCA\Documents\Helper::getMemberColor($uid); + $member = new \OCA\Documents\Db_Member(array( $sessionData['es_id'], $uid, $memberColor, @@ -87,10 +87,10 @@ class Db_Session extends \OCA\Documents\Db { $imageUrl = $uid; } - $displayName = $file->isPublicShare() ? $uid . ' ' . Db_Member::getGuestPostfix() : \OCP\User::getDisplayName($uid); + $displayName = $file->isPublicShare() ? $uid . ' ' . \OCA\Documents\Db_Member::getGuestPostfix() : \OCP\User::getDisplayName($uid); $sessionData['member_id'] = (string) $member->getLastInsertId(); - $op = new Db_Op(); + $op = new \OCA\Documents\Db_Op(); $op->addMember( $sessionData['es_id'], $sessionData['member_id'], @@ -109,13 +109,13 @@ class Db_Session extends \OCA\Documents\Db { } public static function cleanUp($esId){ - $session = new Db_Session(); + $session = new Session(); $session->deleteBy('es_id', $esId); - $member = new Db_Member(); + $member = new \OCA\Documents\Db_Member(); $member->deleteBy('es_id', $esId); - $op= new Db_Op(); + $op= new \OCA\Documents\Db_Op(); $op->deleteBy('es_id', $esId); } @@ -182,7 +182,7 @@ class Db_Session extends \OCA\Documents\Db { } protected function getUniqueSessionId(){ - $testSession = new Db_Session(); + $testSession = new Session(); do{ $id = \OC_Util::generateRandomBytes(30); } while ($testSession->load($id)->hasData()); diff --git a/lib/storage.php b/lib/storage.php index e8ca5a1c..20c968fd 100644 --- a/lib/storage.php +++ b/lib/storage.php @@ -71,7 +71,7 @@ class Storage { return; } - $session = new Db_Session(); + $session = new Session(); $session->loadBy('file_id', $fileId); if (!$session->getEsId()){ @@ -86,7 +86,7 @@ class Storage { } } - Db_Session::cleanUp($session->getEsId()); + Db\Session::cleanUp($session->getEsId()); } protected static function searchDocuments(){ diff --git a/public.php b/public.php index 22938b9e..bdfbea8f 100644 --- a/public.php +++ b/public.php @@ -39,7 +39,7 @@ if (isset($_GET['t'])) { \OCP\Util::addStyle( 'documents', '3rdparty/webodf/editor' ); \OCP\Util::addScript('documents', 'documents'); if ($file->getFileId()){ - $session = new Db_Session(); + $session = new Db\Session(); $session->loadBy('file_id', $file->getFileId()); if ($session->getEsId()){