mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
W.I.P. collab editor:
- Implement check last active member
This commit is contained in:
parent
043c079f80
commit
21700cde7a
@ -78,6 +78,7 @@ class filemanager_collab extends filemanager_collab_bo {
|
||||
function leave_session ($es_id, $member_id)
|
||||
{
|
||||
if (!$this->is_sessionValid($es_id) || !$this->is_memberValid($es_id, $member_id)) throw new Exception ('Session is not valid!');
|
||||
$this->MEMBER_UpdateActiveMember($es_id, $member_id, 0);
|
||||
return array (
|
||||
'session_id' => $es_id,
|
||||
'memberid' => $member_id,
|
||||
@ -247,24 +248,28 @@ class filemanager_collab extends filemanager_collab_bo {
|
||||
* Ajax function to handle actions called by client-side
|
||||
* types: save, delete, discard
|
||||
*
|
||||
* @param type $es_id
|
||||
* @param type $action
|
||||
* @param string $file_path
|
||||
* @param array $params
|
||||
* @param string $action
|
||||
*/
|
||||
function ajax_actions ($es_id, $action, $file_path)
|
||||
function ajax_actions ($params, $action)
|
||||
{
|
||||
$response = Api\Json\Response::get();
|
||||
switch ($action)
|
||||
{
|
||||
case 'save':
|
||||
$this->SESSION_Save($es_id);
|
||||
$this->SESSION_Save($params['es_id']);
|
||||
//update genesis file after save happened
|
||||
if ($file_path) self::generateGenesis ($file_path, $es_id);
|
||||
if ($params['file_path']) self::generateGenesis ($params['file_path'], $params['es_id']);
|
||||
break;
|
||||
case 'delete':
|
||||
$this->SESSION_cleanup($es_id);
|
||||
$this->SESSION_cleanup($params['es_id']);
|
||||
break;
|
||||
case 'discard':
|
||||
$this->OP_Discard($es_id);
|
||||
$this->OP_Discard($params['es_id']);
|
||||
break;
|
||||
case 'checkLastMember':
|
||||
$activeMembers = $this->MEMBER_getActiveMembers($params['es_id']);
|
||||
$response->data(is_array($activeMembers) && count($activeMembers) > 1?false:true);
|
||||
break;
|
||||
default:
|
||||
//
|
||||
|
@ -250,7 +250,7 @@ class filemanager_collab_bo
|
||||
{
|
||||
$this->db->update(
|
||||
self::MEMBER_TABLE,
|
||||
array('collab_status' => 0),
|
||||
array('collab_status' => 0, 'collab_is_active' => 0),
|
||||
array('collab_es_id' => $es_id),
|
||||
__LINE__,
|
||||
__FILE__,
|
||||
@ -385,20 +385,66 @@ class filemanager_collab_bo
|
||||
/**
|
||||
* Add member data into member table in database
|
||||
*
|
||||
* @param type $es_id session id
|
||||
* @param type $user_id user id
|
||||
* @param type $color user color code
|
||||
* @param string $es_id session id
|
||||
* @param int $user_id user id
|
||||
* @param string $color user color code
|
||||
*/
|
||||
protected function MEMBER_add2Db ($es_id, $user_id, $color)
|
||||
{
|
||||
$data = array (
|
||||
'collab_es_id' => $es_id,
|
||||
'collab_uid' => $user_id,
|
||||
'collab_color' => $color
|
||||
'collab_color' => $color,
|
||||
'collab_is_active' => 1
|
||||
);
|
||||
$this->db->insert(self::MEMBER_TABLE, $data,false,__LINE__, __FILE__,'filemanager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update is_active field in member table
|
||||
*
|
||||
* @param string $es_id session id
|
||||
* @param string $member_id member id
|
||||
* @param int $is_active = 0 flag to show if member is active or not
|
||||
*
|
||||
* @throws Exception throws exception if no es_id or member id is given
|
||||
*/
|
||||
protected function MEMBER_UpdateActiveMember ($es_id, $member_id, $is_active = 0)
|
||||
{
|
||||
if (!$es_id || !$member_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
|
||||
$this->db->update(
|
||||
self::MEMBER_TABLE,
|
||||
array('collab_is_active' => $is_active),
|
||||
'collab_es_id ="'.$es_id.'" AND collab_member_id="'.$member_id.'"',
|
||||
__LINE__,
|
||||
__FILE__,
|
||||
'filemanager'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get active members
|
||||
*
|
||||
* @param string $es_id session id
|
||||
*
|
||||
* @return array returns array of members records
|
||||
* @throws Exception throws exception if no es_id is given
|
||||
*/
|
||||
protected function MEMBER_getActiveMembers ($es_id)
|
||||
{
|
||||
if (!$es_id) throw new Exception (self::EXCEPTION_MESSAGE_NO_SESSION);
|
||||
$query = $this->db->select(
|
||||
self::MEMBER_TABLE,
|
||||
'*',
|
||||
array('collab_es_id' => $es_id, 'collab_is_active' => 1),
|
||||
__LINE__,
|
||||
__FILE__,
|
||||
'filemanager'
|
||||
);
|
||||
$members = $query->getRows();
|
||||
return is_array($members)?self::db2id($members):true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get member record of specific member id
|
||||
*
|
||||
|
@ -18,7 +18,7 @@ $phpgw_baseline = array(
|
||||
'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Related editing session id'),
|
||||
'collab_uid' => array('type' => 'varchar','precision' => '64'),
|
||||
'collab_color' => array('type' => 'varchar','precision' => '32'),
|
||||
'collab_last_activity' => array('type' => 'int','precision' => '4'),
|
||||
'collab_is_active' => array('type' => 'int','precision' => '2', 'default'=>'0','nullable' => False),
|
||||
'collab_is_guest' => array('type' => 'int','precision' => '2','default' => '0','nullable' => False),
|
||||
'collab_token' => array('type' => 'varchar','precision' => '32'),
|
||||
'collab_status' => array('type' => 'int','precision' => '2','default' => '1','nullable' => False)
|
||||
|
@ -21,7 +21,7 @@ function filemanager_upgrade16_1()
|
||||
'collab_es_id' => array('type' => 'varchar','precision' => '64','nullable' => False, 'comment' => 'Related editing session id'),
|
||||
'collab_uid' => array('type' => 'varchar','precision' => '64'),
|
||||
'collab_color' => array('type' => 'varchar','precision' => '32'),
|
||||
'collab_last_activity' => array('type' => 'int','precision' => '4'),
|
||||
'collab_is_active' => array('type' => 'int','precision' => '2', 'default'=>'0','nullable' => False),
|
||||
'collab_is_guest' => array('type' => 'int','precision' => '2','default' => '0','nullable' => False),
|
||||
'collab_token' => array('type' => 'varchar','precision' => '32'),
|
||||
'collab_status' => array('type' => 'int','precision' => '2','default' => '1','nullable' => False)
|
||||
|
Loading…
Reference in New Issue
Block a user