Exemplo n.º 1
0
 /**
  * this method will be called
  * w/ an http delete to '/login' *or* '/login/{eid}'
  *
  */
 public function deleteLogin($r)
 {
     $r->clearCookies();
     //	$r->renderRedirect('login/form');
     $logout_url = $r->app_root . '/logini/form';
     $json = Dase_Json::get(array('location' => $logout_url));
     $r->response_mime_type = 'application/json';
     $r->renderResponse($json);
 }
Exemplo n.º 2
0
 /**
  * this method will be called
  * w/ an http delete to '/login' *or* '/login/{eid}'
  *
  */
 public function deleteLogin($r)
 {
     $r->clearCookies();
     //$return_to = $r->app_root . '/login';
     //$logout_url = 'http://www.google.com/accounts/Logout?continue='.$return_to;
     $logout_url = 'http://www.google.com/accounts/Logout';
     $r->response_mime_type = 'application/json';
     $json = Dase_Json::get(array('location' => $logout_url));
     $r->renderResponse($json);
 }
Exemplo n.º 3
0
 public function getItemsJson($r)
 {
     $items = new Dase_DBO_Item($this->db);
     $items->orderBy('updated DESC');
     $set = array();
     foreach ($items->find() as $item) {
         $item = clone $item;
         $set[] = $item->asArray($r);
     }
     $r->renderResponse(Dase_Json::get($set));
 }
Exemplo n.º 4
0
 public function asJson()
 {
     $set = array();
     $set['name'] = $this->name;
     $set['timestamp'] = $this->timestamp;
     $set['uniq_id'] = $this->uniq_id;
     $set['items'] = array();
     foreach ($this->getItems() as $item) {
         $set['items'][] = $item->text;
     }
     return Dase_Json::get($set);
 }
Exemplo n.º 5
0
 /**
  * this method will be called
  * w/ an http delete to '/login' *or* '/login/{eid}'
  *
  */
 public function deleteLogin($r)
 {
     setcookie('DOC', '', time() - 86400, '/', '.utexas.edu');
     setcookie('FC', '', time() - 86400, '/', '.utexas.edu');
     setcookie('SC', '', time() - 86400, '/', '.utexas.edu');
     setcookie('TF', '', time() - 86400, '/', '.utexas.edu');
     $r->clearCookies();
     $logout_url = $r->app_root . '/login/form';
     $json = Dase_Json::get(array('location' => $logout_url));
     $r->response_mime_type = 'application/json';
     $r->renderResponse($json);
 }
Exemplo n.º 6
0
 public function getManagerJson($r)
 {
     $coll = $r->get('collection_ascii_id');
     $eid = $r->get('eid');
     $cm = Dase_DBO_CollectionManager::get($this->db, $coll, $eid);
     $result = array();
     if ($cm) {
         $result['eid'] = $eid;
         $result['collection_ascii_id'] = $coll;
         $result['auth_level'] = $cm->auth_level;
         $r->renderResponse(Dase_Json::get($result));
     } else {
         $r->renderError(404);
     }
 }
Exemplo n.º 7
0
 /** implicit 1000 limit */
 public function getAttributeValuesJson($r)
 {
     $attr = Dase_DBO_Attribute::get($this->db, $r->get('collection_ascii_id'), $r->get('att_ascii_id'));
     if (!$attr) {
         $r->renderError('404');
     }
     if (0 == $attr->collection_id) {
         //since it is admin att we need to be able to limit to items in this coll
         $values_array = $attr->getDisplayValues($this->collection->ascii_id, $r->get('limit'));
     } else {
         $values_array = $attr->getDisplayValues(null, $r->get('limit'));
     }
     $result['att_name'] = $attr->attribute_name;
     $result['att_ascii'] = $attr->ascii_id;
     $result['coll'] = $r->get('collection_ascii_id');
     $result['values'] = $values_array;
     $json_result = Dase_Json::get($result);
     if ($r->get('callback')) {
         $r->renderResponse($r->get('callback') . '(' . $json_result . ');');
     } else {
         $r->renderResponse($json_result);
     }
 }
Exemplo n.º 8
0
 function asJson($app_root)
 {
     $coll_array = array();
     $coll_array['id'] = $app_root . '/collection/' . $this->ascii_id;
     foreach ($this as $k => $v) {
         $coll_array[$k] = $v;
     }
     $coll_array['links'] = array('alternate' => $app_root . '/collection/' . $this->ascii_id);
     $coll_array['title'] = $this->collection_name;
     return Dase_Json::get($coll_array);
 }
Exemplo n.º 9
0
 function asJson()
 {
     return Dase_Json::get($this->asArray());
 }
Exemplo n.º 10
0
Arquivo: DBO.php Projeto: hillct/lists
 public function asJson()
 {
     Dase_Json::get($this->asArray());
 }
Exemplo n.º 11
0
 public function postToCreateAdmin($r)
 {
     $resp = array();
     $superusers = $r->superusers;
     $u = clone $r->getUser('none');
     $u->eid = array_shift(array_keys($superusers));
     if ($u->findOne()) {
         $resp['msg'] = "Admin user \"{$u->eid}\" already exists";
         $resp['ok'] = 1;
         $r->renderResponse(Dase_Json::get($resp));
     }
     $u->name = $u->eid;
     if ($u->insert()) {
         $resp['msg'] = "Admin user \"{$u->eid}\" created. (See local_config.php for password)";
         $resp['ok'] = 1;
     } else {
         $resp['msg'] = "There was a problem creating admin user \"{$u->eid}\".";
         $resp['ok'] = 0;
     }
     $r->renderResponse(Dase_Json::get($resp));
 }
Exemplo n.º 12
0
 public function getAttributeDefinedValuesJson($r)
 {
     $att = Dase_DBO_Attribute::get($this->db, $this->collection->ascii_id, $r->get('att_ascii_id'));
     $response = array();
     $def_value_array = $att->getDefinedValues();
     $response['count'] = count($def_value_array);
     $response['input'] = $att->html_input_type;
     $response['defined'] = $def_value_array;
     $r->response_mime_type = 'application/json';
     $r->renderResponse(Dase_Json::get($response));
 }
Exemplo n.º 13
0
 public function getAdminAttributeTalliesJson($r)
 {
     $prefix = $this->db->table_prefix;
     $c = $this->collection;
     $dbh = $this->db->getDbh();
     $sql = "\n\t\t\tSELECT id, ascii_id\n\t\t\tFROM {$prefix}attribute a\n\t\t\tWHERE a.collection_id = 0\n\t\t\t";
     $sth1 = $dbh->prepare($sql);
     $sth1->execute();
     $sql = "\n\t\t\tSELECT count(DISTINCT value_text) \n\t\t\tFROM {$prefix}value v, {$prefix}item i\n\t\t\tWHERE v.attribute_id = ?\n\t\t\tAND v.item_id = i.id\n\t\t\tAND i.collection_id = ? \n\t\t\t";
     $sth2 = $dbh->prepare($sql);
     $tallies = array();
     while ($row = $sth1->fetch()) {
         $sth2->execute(array($row['id'], $c->id));
         $tallies[$row['ascii_id']] = $sth2->fetchColumn();
     }
     $result['tallies'] = $tallies;
     $result['is_admin'] = 1;
     $r->renderResponse(Dase_Json::get($result));
 }
Exemplo n.º 14
0
 public function asJson($r)
 {
     return Dase_Json::get($this->asArray($r));
 }
Exemplo n.º 15
0
 public function getRecentUploadsJson($r)
 {
     //todo: implement http authorization!
     $coll = $r->get('collection_ascii_id');
     $items = new Dase_DBO_Item($this->db);
     $items->created_by_eid = $this->user->eid;
     $items->collection_id = Dase_DBO_Collection::get($this->db, $coll)->id;
     $items->orderBy('created DESC');
     if ($r->has('limit')) {
         $limit = $r->get('limit');
     } else {
         $limit = 50;
     }
     $items->setLimit($limit);
     $recent = array();
     foreach ($items->find() as $item) {
         $item = clone $item;
         $recent['a' . $item->serial_number]['title'] = $item->getTitle();
         $recent['a' . $item->serial_number]['thumbnail_href'] = $item->getMediaUrl('thumbnail', $r->app_root);
         $recent['a' . $item->serial_number]['item_record_href'] = $item->getUrl($r->app_root);
     }
     $r->renderResponse(Dase_Json::get($recent));
 }
Exemplo n.º 16
0
 function asJson($app_root)
 {
     $collection_lookup = Dase_DBO_Collection::getLookupArray($this->db);
     $json_tag;
     $eid = $this->getUser()->eid;
     $json_tag['id'] = $this->getUrl($app_root);
     $json_tag['uri'] = $this->getUrl($app_root);
     $json_tag['links'] = array('self' => $this->getUrl($app_root));
     if ($this->created) {
         $json_tag['updated'] = $this->created;
     } else {
         $json_tag['updated'] = date(DATE_ATOM);
     }
     $json_tag['name'] = $this->name;
     $json_tag['description'] = $this->description;
     $json_tag['background'] = $this->background;
     $json_tag['is_public'] = $this->is_public;
     $json_tag['type'] = $this->type;
     $json_tag['eid'] = $eid;
     foreach ($this->getTagItems() as $tag_item) {
         $item = $tag_item->getItem();
         if (!$item) {
             Dase_Log::debug(LOG_FILE, 'tag_item missing item: ' . $tag_item->id);
             continue;
         }
         $json_item = array();
         $json_item['id'] = $app_root . '/tag/' . $eid . '/' . $this->ascii_id . '/' . $tag_item->id;
         $json_item['links'] = array();
         $json_item['links']['self'] = $app_root . '/tag/' . $eid . '/' . $this->ascii_id . '/' . $tag_item->id;
         $json_item['links']['related'] = $item->getUrl($app_root);
         $json_item['url'] = $app_root . '/tag/' . $eid . '/' . $this->ascii_id . '/' . $tag_item->id;
         $json_item['sort_order'] = $tag_item->sort_order;
         //make sure p_ values are always populated!
         $json_item['item_unique'] = $tag_item->p_collection_ascii_id . '/' . $tag_item->p_serial_number;
         $json_item['size'] = $tag_item->size;
         $json_item['updated'] = $tag_item->updated;
         $json_item['annotation'] = $tag_item->annotation;
         $json_item['title'] = $item->getTitle();
         $json_item['collection_name'] = $collection_lookup[$item->collection_id]['collection_name'];
         $json_item['media'] = array();
         foreach ($item->getMedia() as $m) {
             $json_item['media'][$m['size']] = $app_root . $m['url'];
         }
         $json_item['metadata'] = array();
         foreach ($item->getMetadata() as $meta) {
             $json_item['metadata'][$meta['attribute_name']] = $meta['value_text'];
         }
         $json_tag['items'][] = $json_item;
     }
     return Dase_Json::get($json_tag);
 }
Exemplo n.º 17
0
 public function getSearchJson($r)
 {
     $result = CFSearch::search($this->db, $r->get('q'));
     $r->renderResponse(Dase_Json::get($result));
 }
Exemplo n.º 18
0
 function asJson()
 {
     //todo: all the opensearch methods
     $feed_array = array('id' => $this->getId(), 'title' => $this->getTitle(), 'subtitle' => $this->getSubtitle(), 'updated' => $this->getUpdated(), 'feedtype' => $this->getFeedtype(), 'rights' => $this->getRights(), 'category' => $this->getCategories(), 'link' => $this->getLinks());
     foreach ($this->getEntries() as $entry) {
         $feed_array['entries'][] = $entry->asArray();
     }
     return Dase_Json::get($feed_array);
 }
Exemplo n.º 19
0
 public function getCartJson()
 {
     return Dase_Json::get($this->getCartArray());
 }
Exemplo n.º 20
0
 public function getCommentsJson($app_root, $eid = '')
 {
     $db = $this->db;
     $comments = new Dase_DBO_Comment($db);
     $comments->item_id = $this->id;
     $comments->updated_by_eid = $eid;
     $comments->orderBy('updated DESC');
     $com = array();
     foreach ($comments->find() as $c_obj) {
         $c['id'] = $c_obj->id;
         //$c['updated'] = $c_obj->updated;
         $c['updated'] = date('D M j, Y \\a\\t g:ia', strtotime($c_obj->updated));
         $c['eid'] = $c_obj->updated_by_eid;
         $c['text'] = $c_obj->text;
         $c['url'] = $this->getUrl($app_root) . '/comments/' . $c_obj->id;
         $com[] = $c;
     }
     return Dase_Json::get($com);
 }
Exemplo n.º 21
0
        $record['record_title'] = $entry->getTitle();
        $record['serial_number'] = $entry->getSerialNumber();
        $record['enclosure'] = $entry->getEnclosure();
        foreach ($entry->getMetadata() as $ascii => $meta) {
            if (!isset($att_count[$ascii])) {
                $att_count[$ascii] = 1;
            } else {
                $att_count[$ascii]++;
            }
            $record[$ascii] = $meta;
            foreach ($meta['values'] as $v) {
                $search_set .= " {$v}";
            }
        }
        $search[$record['serial_number']] = $search_set;
        $records['searches'][] = $search;
        $records['items'][$record['serial_number']] = $record;
    } else {
        $attribute['title'] = $entry->getTitle();
        $attribute['ascii_id'] = $entry->getAsciiId();
        $attributes[] = $attribute;
    }
}
foreach ($attributes as $a) {
    if (isset($att_count[$a['ascii_id']])) {
        $a['count'] = $att_count[$a['ascii_id']];
        $records['attributes'][] = $a;
    }
}
print Dase_Json::get($records);
Exemplo n.º 22
0
 public function getAttributesJson($collection_ascii_id, $app_root)
 {
     $atts = array();
     foreach ($this->getAttributes() as $att) {
         $a = $att->asArray();
         $a['att_ascii_id'] = $att->ascii_id;
         $a['item_type_ascii'] = $this->ascii_id;
         //$a['attribute_name'] = $att->attribute_name;
         $a['href'] = $att->getUrl($collection_ascii_id, $app_root);
         $atts[] = $a;
     }
     return Dase_Json::get($atts);
 }
Exemplo n.º 23
0
 public function getExerciseJson($r)
 {
     $exercise = new Dase_DBO_Exercise($this->db);
     $exercise->load($r->get('id'));
     $exercise->getCreator();
     $exercise->getQuestions();
     $json = array();
     $json['exercise'] = array();
     $json['exercise']['title'] = $exercise->title;
     $json['exercise']['media_file'] = $exercise->media_file;
     $json['exercise']['creator_eid'] = $exercise->creator_eid;
     $json['exercise']['course'] = $exercise->course;
     $json['exercise']['notes'] = $exercise->notes;
     $json['exercise']['ascii_id'] = $exercise->ascii_id;
     $json['exercise']['is_published'] = $exercise->is_published;
     $json['exercise']['questions'] = array();
     foreach ($exercise->questions as $question) {
         $set = array();
         $set['text'] = $question->text;
         $set['lines'] = array();
         $so = 0;
         foreach ($question->lines as $line) {
             $so += 1;
             $aset = array();
             $aset['text'] = $line->text;
             $aset['sort_order'] = $so;
             $aset['is_correct'] = $line->is_correct;
             $set['lines'][] = $aset;
         }
         $json['exercise']['questions'][] = $set;
     }
     $r->renderResponse(Dase_Json::get($json));
 }
Exemplo n.º 24
0
 function asJson()
 {
     $json = array();
     $json['fixed'] = $this->getFixed();
     $json['scheme'] = $this->getScheme();
     $json['categories'] = $this->getCategories(false);
     return Dase_Json::get($json);
 }
Exemplo n.º 25
0
 public function getCommonKeyvalsJson($r)
 {
     $set = array();
     $common = array();
     foreach ($this->tag->getTagItems() as $ti) {
         $item = $ti->getItem();
         if ($item) {
             if (!isset($set[$item->serial_number])) {
                 $set[$item->serial_number] = array();
             }
             $meta = $item->getMetadata();
             foreach ($meta as $m) {
                 $set[$item->serial_number][$m['attribute_name'] . ' : ' . $m['value_text']] = array($m['ascii_id'], $m['value_text']);
             }
             $last = $set[$item->serial_number];
         }
     }
     //foreach keyval in the last item
     foreach ($last as $ascii_plus_val => $keyval) {
         $common[$ascii_plus_val] = $keyval;
         //iterate through all items checking for same keyval
         foreach ($set as $sernum => $metas) {
             if (!isset($metas[$ascii_plus_val])) {
                 unset($common[$ascii_plus_val]);
             }
         }
     }
     $r->renderResponse(Dase_Json::get($common));
 }