예제 #1
0
 public static function cleanUp($esId)
 {
     $session = new Session();
     $session->deleteBy('es_id', $esId);
     $member = new \OCA\Documents\Db\Member();
     $member->deleteBy('es_id', $esId);
     $op = new \OCA\Documents\Db\Op();
     $op->deleteBy('es_id', $esId);
 }
예제 #2
0
 public function syncOps($memberId, $currentHead, $clientHead, $clientOps)
 {
     $hasOps = count($clientOps) > 0;
     $op = new \OCA\Documents\Db\Op();
     // TODO handle the case ($currentHead == "") && ($seqHead != "")
     if ($clientHead == $currentHead) {
         // matching heads
         if ($hasOps) {
             // incoming ops without conflict
             // Add incoming ops, respond with a new head
             $newHead = \OCA\Documents\Db\Op::addOpsArray($this->getEsId(), $memberId, $clientOps);
             $result = array('result' => 'added', 'head_seq' => $newHead ? $newHead : $currentHead);
         } else {
             // no incoming ops (just checking for new ops...)
             $result = array('result' => 'new_ops', 'ops' => array(), 'head_seq' => $currentHead);
         }
     } else {
         // HEADs do not match
         $result = array('result' => $hasOps ? 'conflict' : 'new_ops', 'ops' => $op->getOpsAfterJson($this->getEsId(), $clientHead), 'head_seq' => $currentHead);
     }
     return $result;
 }
예제 #3
0
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
$installedVersion = \OCP\Config::getAppValue('documents', 'installed_version');
$cleanup = \OC_DB::prepare('DELETE FROM `*PREFIX*documents_member` WHERE `last_activity`=0 or `last_activity` is NULL');
$cleanup->execute();
if (version_compare($installedVersion, '0.7', '<=')) {
    \OCP\Config::setAppValue('documents', 'unstable', 'false');
    $session = new \OCA\Documents\Db\Session();
    $query = \OC_DB::prepare('UPDATE `*PREFIX*documents_session` SET `genesis_url`=? WHERE `es_id`=?');
    foreach ($session->getCollection() as $sessionData) {
        $sessionData['genesis_url'] = \OCA\Documents\Genesis::DOCUMENTS_DIRNAME . $sessionData['genesis_url'];
        $query->execute(array($sessionData['genesis_url'], $sessionData['es_id']));
    }
}
if (version_compare($installedVersion, '0.8', '<')) {
    $query = \OC_DB::prepare('UPDATE `*PREFIX*documents_member` SET `is_guest`=1 WHERE `uid` LIKE \'%(guest)\' ');
    $query->execute(array());
}
if (version_compare($installedVersion, '0.9', '<')) {
    $query = \OC_DB::prepare('UPDATE `*PREFIX*documents_op` SET `optype`=? WHERE `seq`=?');
    $ops = new \OCA\Documents\Db\Op();
    foreach ($ops->getCollection() as $opData) {
        $opSpec = json_decode($opData['opspec'], true);
        $query->execute(array($opSpec['optype'], $opData['seq']));
    }
}