Example #1
0
 /** for archiving */
 public function getTagsXml($r)
 {
     //max once/hour
     $r->checkCache(3600);
     $prefix = $this->db->table_prefix;
     $sql = "\n\t\t\tSELECT t.eid, t.ascii_id, t.name, ti.p_serial_number, ti.p_collection_ascii_id, ti.annotation\n\t\t\tFROM {$prefix}tag t,{$prefix}tag_item ti \n\t\t\tWHERE t.id = ti.tag_id \n\t\t\tAND t.ascii_id != 'cart'\n\t\t\tORDER BY t.eid, t.ascii_id, ti.sort_order";
     $set = array();
     $dbh = $this->db->getDbh();
     $sth = $dbh->prepare($sql);
     $sth->execute();
     foreach ($sth->fetchAll() as $row) {
         if (!isset($set[$row['eid']][$row['ascii_id']])) {
             $set[$row['eid']][$row['ascii_id']] = array();
         }
         $set_data['unique'] = $row['p_collection_ascii_id'] . '/' . $row['p_serial_number'];
         $set_data['annotation'] = Dase_Util::stripInvalidXmlChars(htmlspecialchars($row['annotation']));
         $set[$row['eid']][$row['ascii_id']][] = $set_data;
     }
     $set_xml = "<result>\n";
     foreach ($set as $eid => $eid_set) {
         $set_xml .= "<user_sets eid=\"{$eid}\">\n";
         foreach ($eid_set as $ascii_id => $item_unique_array) {
             $set_xml .= "<set ascii_id=\"{$ascii_id}\">\n";
             foreach ($item_unique_array as $data) {
                 if ($data['annotation']) {
                     $set_xml .= "<item id=\"" . $data['unique'] . "\">\n";
                     $set_xml .= "<annotation>" . $data['annotation'] . "</annotation>\n";
                     $set_xml .= "</item>\n";
                 } else {
                     $set_xml .= "<item id=\"" . $data['unique'] . "\"/>\n";
                 }
             }
             $set_xml .= "</set>\n";
         }
         $set_xml .= "</user_sets>\n";
     }
     $set_xml .= "</result>\n";
     $r->renderResponse($set_xml);
 }
Example #2
0
 public function putAnnotation($r)
 {
     $u = $r->getUser();
     $tag = $this->tag;
     if (!$u->can('write', $tag)) {
         $r->renderError(401);
     }
     $tag_item = new Dase_DBO_TagItem($this->db);
     $tag_item->load($r->get('tag_item_id'));
     $tag_item->annotation = Dase_Util::stripInvalidXmlChars($r->getBody());
     $tag_item->updated = date(DATE_ATOM);
     $tag_item->update();
     $r->renderResponse($tag_item->annotation);
 }