13 include_once (
"FDL/Class.SearchDoc.php");
 
   14 include_once (
"DATA/Class.Collection.php");
 
   15 include_once (
"OFFLINE/Class.ExceptionCode.php");
 
   23     private $domain = null;
 
   26         $this->domain = $domain;
 
   28     private static function setError($err)
 
   30         throw new Exception($err);
 
   38         include_once (
"OFFLINE/Class.DomainManager.php");
 
   39         $col = 
new Fdl_Collection();
 
   41         $col->setContentOnlyValue(
true);
 
   42         $col->setContentCompleteProperties(
false);
 
   43         $out = $col->getContent();
 
   57             $uid = $this->domain->getSystemUserId();
 
   58             $out->userMode = $this->domain->getUserMode($uid);
 
   60             $this->setError(_(
"domain not set"));
 
   73             $docid = $config->docid;
 
   75             $doc = new_doc($this->dbaccess, $docid, 
true);
 
   76             $err = $doc->CanLockFile();
 
   77             if (!$err) $err = $this->domain->insertUserDocument($docid, $this->domain->getSystemUserId(), 
true);
 
   78             if ($err) $this->setError($err);
 
   79             $fdoc = 
new Fdl_Document($docid);
 
   80             $out = $fdoc->getDocument(
true, 
false);
 
   83             $this->setError(_(
"domain not set"));
 
   96             $docid = $config->docid;
 
   97             $err = $this->domain->setReservation($docid, 0);
 
   98             if ($err) $this->setError($err);
 
   99             $fdoc = 
new Fdl_Document($docid);
 
  100             $out = $fdoc->getDocument(
true, 
false);
 
  103             $this->setError(_(
"domain not set"));
 
  116             $docid = $config->docid;
 
  117             $doc = new_doc(getDbaccess(), $docid, 
true);
 
  118             if ($doc->isAlive()) {
 
  119                 include_once (
"FDL/Class.DocWaitManager.php");
 
  120                 $this->updateUnResolvedLocalLinks($doc);
 
  121                 $uid=$this->domain->getSystemUserId();
 
  122                 if ($doc->lockdomainid == $this->domain->id && $doc->locked==$uid) {
 
  123                     $wdoc=
new DocWait($this->domain->dbaccess, array($doc->initid, $uid));
 
  124                     if ($wdoc->isAffected()) $wdoc->resetWaitingDocument();
 
  126                   $err = DocWaitManager::clearWaitingDocs($this->domain->id, $uid, $doc->initid);
 
  129             if ($err) $this->setError($err);
 
  130             $fdoc = 
new Fdl_Document(0, null, $doc);
 
  131             $out = $fdoc->getDocument(
true, 
false);
 
  133                 $this->setError(sprintf(_(
"document %s not found"), $docid));
 
  136             $this->setError(_(
"domain not set"));
 
  141     private function updateUnResolvedLocalLinks(Doc &$doc) {
 
  142         $oas = $doc->getNormalAttributes();
 
  143            $unresolvedLinks=DocWaitManager::getUnresolvedLocalLinks($this->domain->id, $this->domain->getSystemUserId());
 
  144            $localIds=array_keys($unresolvedLinks);
 
  145            $serverIds=array_values($unresolvedLinks);
 
  146             foreach ( $oas as $aid => $oa ) {
 
  147                 if ($oa->type == 
"docid") {
 
  148                     $value = $doc->getValue($aid);
 
  150                         $nvalue = str_replace($serverIds, $localIds, $value);
 
  151                         if ($nvalue != $value) {
 
  167             $docid = $config->docid;
 
  169             $err = $this->domain->insertUserDocument($docid, $this->domain->getSystemUserId(), 
false);
 
  170             if ($err) $this->setError($err);
 
  171             $fdoc = 
new Fdl_Document($docid);
 
  172             $out = $fdoc->getDocument(
true, 
false);
 
  175             $this->setError(_(
"domain not set"));
 
  188             $docid = $config->docid;
 
  190             $err = $this->domain->removeUserDocument($docid, $this->domain->getSystemUserId());
 
  191             if ($err) $this->setError($err);
 
  192             $fdoc = 
new Fdl_Document($docid);
 
  193             $out = $fdoc->getDocument(
true, 
false);
 
  196             $this->setError(_(
"domain not set"));
 
  209             $docid = $config->docid;
 
  211             $err = $this->domain->insertSharedDocument($docid);
 
  212             if ($err) $this->setError($err);
 
  213             $fdoc = 
new Fdl_Document($docid);
 
  214             $out = $fdoc->getDocument(
true, 
false);
 
  217             $this->setError(_(
"domain not set"));
 
  230             $docid = $config->docid;
 
  232             $err = $this->domain->removeSharedDocument($docid, $this->domain->getSystemUserId());
 
  233             if ($err) $this->setError($err);
 
  234             $fdoc = 
new Fdl_Document($docid);
 
  235             $out = $fdoc->getDocument(
true, 
false);
 
  238             $this->setError(_(
"domain not set"));
 
  249         include_once (
"FDL/Class.DocumentList.php");
 
  252             $families = $this->domain->getFamilies();
 
  253             $list = 
new DocumentList();
 
  254             $list->addDocumentIdentificators($families);
 
  256             $domain = $this->domain;
 
  257             $callback = 
function (&$family) use($domain)
 
  259                 $maskId = $domain->getOfflineMask($family->id);
 
  261                     $family->applyMask($maskId, 
true);
 
  264             $list->listMap($callback); 
 
  265             $col = 
new Fdl_Collection();
 
  266             $col->useDocumentList($list);
 
  267             $col->setContentOnlyValue(
false);
 
  268             $col->setContentCompleteProperties(
false);
 
  269             $out = $col->getContent();
 
  272             $this->setError(_(
"domain not set"));
 
  284             $err = $this->domain->clearUserFolder($this->domain->getSystemUserId(), 
false);
 
  285             if ($err) $this->setError($err);
 
  288             $this->setError(_(
"domain not set"));
 
  300             $err = $this->domain->clearSharedFolder(
false);
 
  301             if ($err) $this->setError($err);
 
  304             $this->setError(_(
"domain not set"));
 
  316         $date = $config->until;
 
  318             $folder = $this->domain->getUserFolder();
 
  320                 $out = $this->getFolderDocuments($folder, $date, $callback);
 
  322                 $this->domain->disableEditControl();
 
  323                 $err = $this->domain->createSubDirectories();
 
  324                 $this->domain->enableEditControl();
 
  326                     $this->setError(_(
"user folder not found:").$err);
 
  328                     $folder = $this->domain->getUserFolder();
 
  330                         $out = $this->getFolderDocuments($folder, $date, $callback);
 
  332                         $this->setError(_(
"user folder not found"));
 
  337             $this->setError(_(
"domain not set"));
 
  349         $date = $config->until;
 
  351             $folder = $this->domain->getSharedFolder();
 
  353                 $out = $this->getFolderDocuments($folder, $date, $callback);
 
  355                 $this->setError(_(
"no share folder"));
 
  358             $this->setError(_(
"domain not set"));
 
  370     private function getFolderDocuments(Dir &$folder, $mdate = 
'', $callback = null)
 
  372         include_once (
"FDL/Class.DocumentList.php");
 
  375             $col = 
new Fdl_Collection(0, null, $folder);
 
  377             if ($callback) $col->setContentMap($callback);
 
  378             $col->setContentOnlyValue(
true);
 
  379             $col->setContentCompleteProperties(
false);
 
  381                 $umdate = stringDateToUnixTs($mdate);
 
  382                 $sqlDate = sprintf(
"revdate > %d", $umdate);
 
  383                 $col->setContentFilter($sqlDate);
 
  386             $out = $col->getContent();
 
  388             if ($out->totalCount > 0) $this->setReserveWaitingDocument($folder);
 
  391             $this->setError(_(
"domain not set"));
 
  400     private function setReserveWaitingDocument(Dir &$folder)
 
  402         include_once (
"FDL/Class.DocWaitManager.php");
 
  405             $s = 
new SearchDoc($this->dbaccess);
 
  406             $s->useCollection($folder->initid);
 
  407             $s->setObjectReturn();
 
  408             $uid = $folder->getSystemUserId();
 
  409             $s->addFilter(
"locked = %d", $uid);
 
  410             $s->addFilter(
"lockdomainid = %d", $this->domain->id);
 
  411             $dl = $s->search()->getDocumentList();
 
  412             $w = 
new DocWait($this->dbaccess);
 
  413             foreach ( $dl as $k => $v ) {
 
  414                 if (!$w->select(array(
 
  418                     DocWaitManager::saveWaitingDoc($v, $this->domain->id);
 
  430         include_once (
"FDL/Class.DocumentList.php");
 
  433             $ids = $this->domain->getReservedDocumentIds();
 
  435             $out->reservedDocumentIds = $ids;
 
  438             $this->setError(_(
"domain not set"));
 
  449         include_once (
"OFFLINE/Class.DomainSyncApi.php");
 
  459         include_once (
"OFFLINE/Class.DomainViewApi.php");
 
insertSharedDocument($config)
 
removeSharedDocument($config)
 
getSharedDocuments($config, $callback=null)
 
__construct(Dir &$domain=null)
 
getUserDocuments($config, $callback=null)
 
removeUserDocument($config)
 
insertUserDocument($config)