W.I.P. collab editor

This commit is contained in:
Hadi Nategh 2016-08-11 12:39:10 +02:00
parent 598dbca2c3
commit 1a714166da

View File

@ -115,7 +115,7 @@ class filemanager_collab_bo
$date = new DateTime(); $date = new DateTime();
$op = array( $op = array(
'optype' => 'AddMember', 'optype' => 'AddMember',
'memberid' => (string) $member_id, 'member' => (string) $member_id,
'timestamp' => $date->getTimestamp(), 'timestamp' => $date->getTimestamp(),
'setProperties' => array( 'setProperties' => array(
'fullName' => $full_name, 'fullName' => $full_name,
@ -127,6 +127,32 @@ class filemanager_collab_bo
$this->OP_add2Db($op, $es_id); $this->OP_add2Db($op, $es_id);
} }
/**
* Function to get top head seq for a given session
*
* @param string $es_id
*
* @return string returns head seq or '' if none exists
* @throws Exception throws exception if no session is given
*/
protected function OP_getHeadSeq($es_id)
{
if (!$es_id) throw new Exception ('Session id must be given, none given!');
$headSeq = $this->db->select(
self::OP_TABLE,
'collab_seq',
array('collab_es_id' => $es_id),
__LINE__,
__FILE__,
FALSE,
'ORDER BY collab_seq DESC LIMIT 1',
'filemanager'
);
return $headSeq->fields? $headSeq->fields['collab_seq']: '';
}
/** /**
* Insert op data into OP table in database * Insert op data into OP table in database
* *
@ -137,7 +163,7 @@ class filemanager_collab_bo
{ {
$data = array ( $data = array (
'collab_es_id' => $es_id, 'collab_es_id' => $es_id,
'collab_member' => $op['member_id'], 'collab_member' => $op['member'],
'collab_optype' => $op['optype'], 'collab_optype' => $op['optype'],
'collab_opspec' => json_encode($op) 'collab_opspec' => json_encode($op)
); );
@ -161,6 +187,28 @@ class filemanager_collab_bo
$this->db->insert(self::MEMBER_TABLE, $data,false,__LINE__, __FILE__,'filemanager'); $this->db->insert(self::MEMBER_TABLE, $data,false,__LINE__, __FILE__,'filemanager');
} }
/**
* Function to get member record of specific member id
*
* @param string $member_id member id
*
* @return array returns an array consist of member record
* @throws Exception throws exception if no member id is given
*/
protected function MEMBER_getMember ($member_id)
{
if (!$member_id) throw new Exception ('Member id must be given, none given!');
$member = $this->db->select(
self::MEMBER_TABLE,
'*',
array('collab_member_id' => $member_id),
__LINE__,
__FILE__
);
return $member->fields? self::db2id($member->fileds): [];
}
/** /**
* Utility function to map DB fields to ids * Utility function to map DB fields to ids
* *
@ -182,7 +230,16 @@ class filemanager_collab_bo
*/ */
protected function MEMBER_getLastMember() protected function MEMBER_getLastMember()
{ {
$last_row = $this->db->select(self::MEMBER_TABLE, 'collab_member_id','',__LINE__,__FILE__,false,"ORDER BY `collab_member_id` DESC LIMIT 1;"); $last_row = $this->db->select(
self::MEMBER_TABLE,
'collab_member_id',
'',
__LINE__,
__FILE__,
false,
"ORDER BY `collab_member_id` DESC LIMIT 1;"
);
return $last_row->fields? $last_row->fields['collab_member_id']: 0; return $last_row->fields? $last_row->fields['collab_member_id']: 0;
} }
} }