getKeywords(); $chosen_collections = get_input('collection'); $collection_name = get_input('collection_name'); $user_guid = $_SESSION['user']->getGUID(); $user_collections = get_entities("object", "collection", $user_guid); global $CONFIG; /* * * as,as1 * <_fulltext>sigrimigri * */ foreach ($user_collections as $collection) { $resources = $collection->resources; if (is_string($resources)) { $resources = array($resources); } if (in_array($collection->getGUID(), $chosen_collections)) { // if adding to this collection if (!in_array($rid, $resources)) { if (empty($resources)) { $resources = array($rid); } else { array_push($resources, $rid); } $collection->resources = $resources; // also add tags $tags = $collection->tags; if (!$tags) { $tags = array(); } else if (is_string($tags)) { $tags = array($tags); } $tags = array_merge($tags, $resource_tags); // remove duplicate values $tags = array_unique($tags); $collection->tags = $tags; $collection->save(); // update resource statistics table setResourceStat($rid, 'collection'); } } else { // remove from collection if necessary if (in_array($rid, $resources)) { foreach ($resources as $key => $res) { if ($rid == $res) { unset($resources[$key]); } } setResourceStat($rid, 'collection', '-'); $collection->resources = $resources; // remove tags //$waramu_resource = waramu_getResource('', $rid); //$resource_tags = $waramu_resource->getKeywords(); //foreach($resource_tags as $tag) { // foreach ($tags as $key => $res) { // if ($tag == $res) // unset($tags[$key]); // } //} //$collection->tags = $tags; $collection->save(); updateCollectionTags($collection); } } } if (in_array("new_collection", $chosen_collections)) { $tinyxml = '<'.'?'.'xml version="1.0" encoding="UTF-8"'.'?'.'>'; $doc = new DOMDocument("1.0", "UTF-8"); $doc->formatOutput = true; $data = $doc->createElementNS("http://trac.htk.tlu.ee/waramu/Collection", "data"); $doc->appendChild($data); $title_e = $doc->createElement("title"); $title_e->setAttribute("lang", get_current_language()); $title_e->appendChild($doc->createTextNode($collection_name)); $data->appendChild($title_e); $items_e = $doc->createElement("items"); $val1 = $doc->createElement("value"); $val1->setAttribute("position", "1"); $val1->appendChild($doc->createTextNode($rid)); $items_e->appendChild($val1); $data->appendChild($items_e); $tinyxml = $doc->saveXML(); $kk = $w->newResource($au, $tinyxml); /*TODO:remove below*/ $collection = new ElggObject(); $collection->subtype = "collection"; $collection->owner_guid = $_SESSION['user']->getGUID(); $collection->title = $collection_name; $collection->access_id = 2; $collection->save(); $collection->resources = array($rid); $collection->tags = $resource_tags; // update resource statistics table setResourceStat($rid, 'collection'); } forward($CONFIG->wwwroot.'pg/waramu/view/'.$rid); ?>