/** used by Dase_Handler_Tag::putEdit() */ function update($db, $r) { $user = $r->getUser(); $atom_author = $this->getAuthorName(); //should be exception?? if (!$atom_author || $atom_author != $user->eid) { $r->renderError(401, 'users do not match'); } $ascii_id = $this->getAsciiId(); $set = Dase_DBO_Tag::get($db, $ascii_id, $user->eid); if (!$set) { return; } $cats = $this->getCategoriesByScheme('http://daseproject.org/category/visibility'); if (count($cats)) { $vis = $cats[0]['term']; } $set->visibility = $vis; if ('public' == $vis) { $set->is_public = 1; } if ('private' == $vis) { $set->is_public = 0; } $set->updated = date(DATE_ATOM); $set->update(); //note that ONLY mutable categories will be affected $set->deleteCategories(); foreach ($this->getCategories() as $category) { //Dase_DBO_Category::add($db,$set,$category['scheme'],$category['term'],$category['label']); /******* newly refactored*************/ $tag_cat = new Dase_DBO_TagCategory($db); $tag_cat->tag_id = $set->id; $tag_cat->category_id = 0; $tag_cat->term = $category['term']; $tag_cat->label = $category['label']; $scheme = str_replace('http://daseproject.org/category/', '', $category['scheme']); $tag_cat->scheme = $scheme; if ('utexas/courses' == $scheme) { if (!$tag_cat->findOne()) { $tag_cat->insert(); } } } return $set; }
public function postToSetCopier($r) { $user = $r->getUser('http'); $content_type = $r->getContentType(); if ('text/uri-list' == $content_type) { $url = $r->getBody(); $parts = explode('/', $url); $tag_ascii = array_pop($parts); $tag_eid = array_pop($parts); $tag = Dase_DBO_Tag::get($this->db, $tag_ascii, $tag_eid); if (!$user->can('read', $tag)) { $r->renderError(401, $user->eid . ' is not authorized to read this resource.'); } $r->renderResponse($tag->name); } $r->renderError(418, 'wrong media type'); }