richdocuments/lib/session.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2013-07-19 18:52:52 +03:00
<?php
namespace OCA\Office;
class Session {
2013-07-19 20:44:18 +03:00
public static function getSession($id){
$query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session` WHERE `es_id`= ?');
$result = $query->execute(array($id));
return $result->fetchRow();
}
2013-08-07 02:22:21 +03:00
public static function getSessionByUrl($url){
$query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session` WHERE `genesis_url`= ?');
$result = $query->execute(array($url));
return $result->fetchRow();
}
public static function addSession($genesis){
2013-07-19 20:44:18 +03:00
$query = \OCP\DB::prepare('INSERT INTO `*PREFIX*office_session` (`es_id`, `genesis_url`, `genesis_hash`, `owner`) VALUES (?, ?, ?, ?) ');
2013-08-07 02:22:21 +03:00
$data = array(
self::getSessionId(),
$genesis,
self::getHash($genesis),
2013-07-19 20:44:18 +03:00
\OCP\User::getUser()
2013-08-07 02:22:21 +03:00
);
$result = $query->execute($data);
if ($result){
return $data;
}
return false;
}
public static function setMockSession(){
2013-08-07 10:38:00 +02:00
//self::addSession('/welcome.odt');
2013-08-07 02:22:21 +03:00
}
protected static function getSessionId(){
2013-08-07 10:38:00 +02:00
return (string) time();
2013-08-07 02:22:21 +03:00
}
protected static function getHash($genesis){
return '0xdeadbeef';
2013-07-19 20:44:18 +03:00
}
2013-07-19 18:52:52 +03:00
}