Exemple #1
0
 /**
  * @brief Cleanup session data on removing the document
  * @param array
  *
  * This function is connected to the delete signal of OC_Filesystem
  * to delete the related info from database
  */
 public static function onDelete($params)
 {
     $info = \OC\Files\Filesystem::getFileInfo($params['path']);
     $fileId = @$info['fileid'];
     if (!$fileId) {
         return;
     }
     $session = new Db\Session();
     $session->loadBy('file_id', $fileId);
     if (!$session->getEsId()) {
         return;
     }
     $member = new Db\Member();
     $sessionMembers = $member->getCollectionBy('es_id', $session->getEsId());
     foreach ($sessionMembers as $memberData) {
         if (intval($memberData['status']) === Db\Member::MEMBER_STATUS_ACTIVE) {
             return;
         }
     }
     Db\Session::cleanUp($session->getEsId());
 }
Exemple #2
0
if (isset($_GET['t'])) {
    $token = $_GET['t'];
    $tmpl = new \OCP\Template('documents', 'public', 'guest');
    try {
        $file = File::getByShareToken($token);
        if ($file->isPasswordProtected() && !$file->checkPassword(@$_POST['password'])) {
            if (isset($_POST['password'])) {
                $tmpl->assign('wrongpw', true);
            }
            $tmpl->assign('hasPassword', true);
        } else {
            \OCP\Util::addStyle('documents', '3rdparty/webodf/dojo-app');
            \OCP\Util::addScript('documents', 'documents');
            if ($file->getFileId()) {
                $session = new Db\Session();
                $session->loadBy('file_id', $file->getFileId());
                if ($session->getEsId()) {
                    $member = new Db\Member();
                    $members = $member->getCollectionBy('es_id', $session->getEsId());
                } else {
                    $members = 0;
                }
                $tmpl->assign('total', count($members) + 1);
            } else {
                $tmpl->assign('total', 1);
            }
            $tmpl->assign('document', $token);
        }
    } catch (\Exception $e) {
        $tmpl->assign('notFound', true);
    }