示例#1
0
	/**
	 * Updates the collections an item is in
	 *
	 * @param array $newCollections Array of new collection keys to set
	 */
	public function setCollections($collectionKeys=[]) {
		if (!$this->loaded['collections']) {
			$this->loadCollections();
		}
		
		if ((!$this->collections && !$collectionKeys) ||
				(!Zotero_Utilities::arrayDiffFast($this->collections, $collectionKeys) &&
				!Zotero_Utilities::arrayDiffFast($collectionKeys, $this->collections))) {
			Z_Core::debug("Collections have not changed for item $this->id");
			return;
		}
		
		$this->storePreviousData('collections');
		$this->collections = array_unique($collectionKeys);
		$this->changed['collections'] = true;
	}