Make sure that cursor/member exists before removal
This commit is contained in:
parent
bc06816833
commit
40182b061c
@ -84,9 +84,11 @@ class Db_Op extends Db {
|
||||
}
|
||||
|
||||
public function removeCursor($esId, $memberId){
|
||||
if ($this->hasAddCursor($esId, $memberId)){
|
||||
$op = '{"optype":"RemoveCursor","memberid":"'. $memberId .'","reason":"server-idle","timestamp":'. time() .'}';
|
||||
$this->insertOp($esId, $op);
|
||||
}
|
||||
}
|
||||
|
||||
public function addMember($esId, $memberId, $fullName, $color, $imageUrl){
|
||||
$op = '{"optype":"AddMember","memberid":"'. $memberId .'","timestamp":"'. time() .'", "setProperties":{"fullName":"'. $fullName .'","color":"'. $color .'","imageUrl":"'. $imageUrl .'"}}';
|
||||
@ -94,9 +96,11 @@ class Db_Op extends Db {
|
||||
}
|
||||
|
||||
public function removeMember($esId, $memberId){
|
||||
if ($this->hasAddMember($esId, $memberId)){
|
||||
$op ='{"optype":"RemoveMember","memberid":"'. $memberId .'","timestamp":'. time() .'}';
|
||||
$this->insertOp($esId, $op);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateMember($esId, $memberId, $fullName, $color, $imageUrl){
|
||||
//TODO: Follow the spec https://github.com/kogmbh/WebODF/blob/master/webodf/lib/ops/OpUpdateMember.js#L95
|
||||
@ -114,4 +118,22 @@ class Db_Op extends Db {
|
||||
$op->insert();
|
||||
}
|
||||
|
||||
protected function hasAddMember($esId, $memberId){
|
||||
$ops = $this->execute(
|
||||
'SELECT * FROM ' . $this->tableName . ' WHERE `es_id`=? AND `opspec` LIKE \'%"AddMember","memberid":"' . $memberId .'"%\'',
|
||||
array($esId)
|
||||
);
|
||||
$result = $ops->fetchAll();
|
||||
return is_array($result) && count($result)>0;
|
||||
}
|
||||
|
||||
protected function hasAddCursor($esId, $memberId){
|
||||
$ops = $this->execute(
|
||||
'SELECT * FROM ' . $this->tableName . ' WHERE `es_id`=? AND `opspec` LIKE \'%"AddCursor","memberid":"' . $memberId .'"%\'',
|
||||
array($esId)
|
||||
);
|
||||
$result = $ops->fetchAll();
|
||||
return is_array($result) && count($result)>0;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user