Db_Session -> Db\Session
This commit is contained in:
parent
dfe26c9289
commit
7356dcfae3
@ -51,7 +51,7 @@ class DocumentController extends Controller{
|
|||||||
* @param array $args - array containing session id as an element with a key es_id
|
* @param array $args - array containing session id as an element with a key es_id
|
||||||
*/
|
*/
|
||||||
public static function serve($args){
|
public static function serve($args){
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$session->load(@$args['es_id']);
|
$session->load(@$args['es_id']);
|
||||||
|
|
||||||
self::preDispatchGuest();
|
self::preDispatchGuest();
|
||||||
@ -108,7 +108,7 @@ class DocumentController extends Controller{
|
|||||||
return @$b['mtime']-@$a['mtime'];
|
return @$b['mtime']-@$a['mtime'];
|
||||||
});
|
});
|
||||||
|
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$sessions = $session->getCollectionBy('file_id', $fileIds);
|
$sessions = $session->getCollectionBy('file_id', $fileIds);
|
||||||
|
|
||||||
$members = array();
|
$members = array();
|
||||||
|
@ -31,7 +31,7 @@ try{
|
|||||||
$request = new Request();
|
$request = new Request();
|
||||||
$esId = $request->getParam('args/es_id');
|
$esId = $request->getParam('args/es_id');
|
||||||
|
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$session->load($esId);
|
$session->load($esId);
|
||||||
|
|
||||||
$memberId = $request->getParam('args/member_id');
|
$memberId = $request->getParam('args/member_id');
|
||||||
|
@ -23,7 +23,7 @@ class SessionController extends Controller{
|
|||||||
try {
|
try {
|
||||||
$token = Helper::getArrayValueByKey($args, 'token');
|
$token = Helper::getArrayValueByKey($args, 'token');
|
||||||
$file = File::getByShareToken($token);
|
$file = File::getByShareToken($token);
|
||||||
$session = Db_Session::start($uid, $file, true);
|
$session = Db\Session::start($uid, $file, true);
|
||||||
\OCP\JSON::success($session);
|
\OCP\JSON::success($session);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
|
Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
|
||||||
@ -42,7 +42,7 @@ class SessionController extends Controller{
|
|||||||
|
|
||||||
if ($view->isUpdatable($path)) {
|
if ($view->isUpdatable($path)) {
|
||||||
$file = new File($fileId);
|
$file = new File($fileId);
|
||||||
$session = Db_Session::start($uid, $file);
|
$session = Db\Session::start($uid, $file);
|
||||||
\OCP\JSON::success($session);
|
\OCP\JSON::success($session);
|
||||||
} else {
|
} else {
|
||||||
$info = $view->getFileInfo();
|
$info = $view->getFileInfo();
|
||||||
@ -93,7 +93,7 @@ class SessionController extends Controller{
|
|||||||
}
|
}
|
||||||
$content = stream_get_contents($stream);
|
$content = stream_get_contents($stream);
|
||||||
|
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$session->load($esId);
|
$session->load($esId);
|
||||||
|
|
||||||
if (!$session->getEsId()){
|
if (!$session->getEsId()){
|
||||||
@ -157,7 +157,7 @@ class SessionController extends Controller{
|
|||||||
$session->updateGenesisHash($esId, sha1($data['content']));
|
$session->updateGenesisHash($esId, sha1($data['content']));
|
||||||
} else {
|
} else {
|
||||||
// Last user. Kill session data
|
// Last user. Kill session data
|
||||||
Db_Session::cleanUp($esId);
|
Db\Session::cleanUp($esId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view->touch($path);
|
$view->touch($path);
|
||||||
@ -177,7 +177,7 @@ class SessionController extends Controller{
|
|||||||
$info = array();
|
$info = array();
|
||||||
|
|
||||||
if (is_array($items)){
|
if (is_array($items)){
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$info = $session->getInfoByFileId($items);
|
$info = $session->getInfoByFileId($items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ class SessionController extends Controller{
|
|||||||
|
|
||||||
public static function listAll(){
|
public static function listAll(){
|
||||||
self::preDispatch();
|
self::preDispatch();
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$sessions = $session->getCollection();
|
$sessions = $session->getCollection();
|
||||||
|
|
||||||
$preparedSessions = array_map(
|
$preparedSessions = array_map(
|
||||||
|
@ -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\UserController'] = 'documents/ajax/userController.php';
|
||||||
OC::$CLASSPATH['OCA\Documents\Download_Simple'] = 'documents/lib/download/simple.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\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_Member'] = 'documents/lib/db/member.php';
|
||||||
OC::$CLASSPATH['OCA\Documents\Db_Op'] = 'documents/lib/db/op.php';
|
OC::$CLASSPATH['OCA\Documents\Db_Op'] = 'documents/lib/db/op.php';
|
||||||
OC::$CLASSPATH['OCA\Documents\Filter_Office'] = 'documents/lib/filter/office.php';
|
OC::$CLASSPATH['OCA\Documents\Filter_Office'] = 'documents/lib/filter/office.php';
|
||||||
|
@ -16,7 +16,7 @@ $cleanup->execute();
|
|||||||
|
|
||||||
if (version_compare($installedVersion, '0.7', '<=')) {
|
if (version_compare($installedVersion, '0.7', '<=')) {
|
||||||
\OCP\Config::setAppValue('documents', 'unstable', 'false');
|
\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`=?');
|
$query = \OC_DB::prepare('UPDATE `*PREFIX*documents_session` SET `genesis_url`=? WHERE `es_id`=?');
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* later.
|
* later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OCA\Documents;
|
namespace OCA\Documents\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session management
|
* Session management
|
||||||
@ -22,7 +22,7 @@ namespace OCA\Documents;
|
|||||||
* @method string getGenesisHash()
|
* @method string getGenesisHash()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Db_Session extends \OCA\Documents\Db {
|
class Session extends \OCA\Documents\Db {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB table
|
* DB table
|
||||||
@ -44,15 +44,15 @@ class Db_Session extends \OCA\Documents\Db {
|
|||||||
*/
|
*/
|
||||||
public static function start($uid, $file){
|
public static function start($uid, $file){
|
||||||
// Create a directory to store genesis
|
// Create a directory to store genesis
|
||||||
$genesis = new Genesis($file);
|
$genesis = new \OCA\Documents\Genesis($file);
|
||||||
|
|
||||||
list($ownerView, $path) = $file->getOwnerViewAndPath();
|
list($ownerView, $path) = $file->getOwnerViewAndPath();
|
||||||
$oldSession = new Db_Session();
|
$oldSession = new Session();
|
||||||
$oldSession->loadBy('file_id', $file->getFileId());
|
$oldSession->loadBy('file_id', $file->getFileId());
|
||||||
|
|
||||||
//If there is no existing session we need to start a new one
|
//If there is no existing session we need to start a new one
|
||||||
if (!$oldSession->hasData()){
|
if (!$oldSession->hasData()){
|
||||||
$newSession = new Db_Session(array(
|
$newSession = new Session(array(
|
||||||
$genesis->getPath(),
|
$genesis->getPath(),
|
||||||
$genesis->getHash(),
|
$genesis->getHash(),
|
||||||
$file->getOwner(),
|
$file->getOwner(),
|
||||||
@ -69,8 +69,8 @@ class Db_Session extends \OCA\Documents\Db {
|
|||||||
->getData()
|
->getData()
|
||||||
;
|
;
|
||||||
|
|
||||||
$memberColor = Helper::getMemberColor($uid);
|
$memberColor = \OCA\Documents\Helper::getMemberColor($uid);
|
||||||
$member = new Db_Member(array(
|
$member = new \OCA\Documents\Db_Member(array(
|
||||||
$sessionData['es_id'],
|
$sessionData['es_id'],
|
||||||
$uid,
|
$uid,
|
||||||
$memberColor,
|
$memberColor,
|
||||||
@ -87,10 +87,10 @@ class Db_Session extends \OCA\Documents\Db {
|
|||||||
$imageUrl = $uid;
|
$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();
|
$sessionData['member_id'] = (string) $member->getLastInsertId();
|
||||||
$op = new Db_Op();
|
$op = new \OCA\Documents\Db_Op();
|
||||||
$op->addMember(
|
$op->addMember(
|
||||||
$sessionData['es_id'],
|
$sessionData['es_id'],
|
||||||
$sessionData['member_id'],
|
$sessionData['member_id'],
|
||||||
@ -109,13 +109,13 @@ class Db_Session extends \OCA\Documents\Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function cleanUp($esId){
|
public static function cleanUp($esId){
|
||||||
$session = new Db_Session();
|
$session = new Session();
|
||||||
$session->deleteBy('es_id', $esId);
|
$session->deleteBy('es_id', $esId);
|
||||||
|
|
||||||
$member = new Db_Member();
|
$member = new \OCA\Documents\Db_Member();
|
||||||
$member->deleteBy('es_id', $esId);
|
$member->deleteBy('es_id', $esId);
|
||||||
|
|
||||||
$op= new Db_Op();
|
$op= new \OCA\Documents\Db_Op();
|
||||||
$op->deleteBy('es_id', $esId);
|
$op->deleteBy('es_id', $esId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ class Db_Session extends \OCA\Documents\Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function getUniqueSessionId(){
|
protected function getUniqueSessionId(){
|
||||||
$testSession = new Db_Session();
|
$testSession = new Session();
|
||||||
do{
|
do{
|
||||||
$id = \OC_Util::generateRandomBytes(30);
|
$id = \OC_Util::generateRandomBytes(30);
|
||||||
} while ($testSession->load($id)->hasData());
|
} while ($testSession->load($id)->hasData());
|
||||||
|
@ -71,7 +71,7 @@ class Storage {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$session = new Db_Session();
|
$session = new Session();
|
||||||
$session->loadBy('file_id', $fileId);
|
$session->loadBy('file_id', $fileId);
|
||||||
|
|
||||||
if (!$session->getEsId()){
|
if (!$session->getEsId()){
|
||||||
@ -86,7 +86,7 @@ class Storage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Db_Session::cleanUp($session->getEsId());
|
Db\Session::cleanUp($session->getEsId());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function searchDocuments(){
|
protected static function searchDocuments(){
|
||||||
|
@ -39,7 +39,7 @@ if (isset($_GET['t'])) {
|
|||||||
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/editor' );
|
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/editor' );
|
||||||
\OCP\Util::addScript('documents', 'documents');
|
\OCP\Util::addScript('documents', 'documents');
|
||||||
if ($file->getFileId()){
|
if ($file->getFileId()){
|
||||||
$session = new Db_Session();
|
$session = new Db\Session();
|
||||||
$session->loadBy('file_id', $file->getFileId());
|
$session->loadBy('file_id', $file->getFileId());
|
||||||
|
|
||||||
if ($session->getEsId()){
|
if ($session->getEsId()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user