예제 #1
0
 public static function purge($libraryID)
 {
     $sql = "SELECT subject FROM relations " . "WHERE libraryID=? AND predicate!=? " . "UNION " . "SELECT object FROM relations " . "WHERE libraryID=? AND predicate!=?";
     $uris = Zotero . DB . columnQuery($sql, array($libraryID, self::$deletedItemPredicate, $libraryID, self::$deletedItemPredicate), Zotero_Shards::getByLibraryID($libraryID));
     if ($uris) {
         $prefix = Zotero_URI::getBaseURI();
         Zotero_DB::beginTransaction();
         foreach ($uris as $uri) {
             // Skip URIs that don't begin with the default prefix,
             // since they don't correspond to local items
             if (strpos($uri, $prefix) === false) {
                 continue;
             }
             if (preg_match('/\\/items\\//', $uri) && !Zotero_URI::getURIItem($uri)) {
                 self::eraseByURI($uri);
             }
             if (preg_match('/\\/collections\\//', $uri) && !Zotero_URI::getURICollection($uri)) {
                 self::eraseByURI($uri);
             }
         }
         Zotero_DB::commit();
     }
 }