public static function initGlobalData($db, $config) { $cache = Dase_Cache::get($config); //refreshed once per hour -- expunge when necessary! $serialized_app_data = $cache->getData('app_data', 3600); if (!$serialized_app_data) { $c = new Dase_DBO_Collection($db); $colls = array(); $acl = array(); foreach ($c->find() as $coll) { $colls[$coll->ascii_id] = $coll->collection_name; $acl[$coll->ascii_id] = $coll->visibility; //compat $acl[$coll->ascii_id . '_collection'] = $coll->visibility; } $app_data['collections'] = $colls; $app_data['media_acl'] = $acl; $cache->setData('app_data', serialize($app_data)); } else { $app_data = unserialize($serialized_app_data); } return $app_data; }
<?php include 'config.php'; //this script rebuilds search indexes $coll_ascii_id = 'what_jane_saw'; $coll_ascii_id = 'cola_images'; $coll = new Dase_DBO_Collection($db); $coll->orderBy('item_count ASC'); if ($coll_ascii_id) { $coll->ascii_id = $coll_ascii_id; } foreach ($coll->find() as $c) { $start = Dase_Util::getTime(); print "working on " . $c->collection_name . "(" . $c->item_count . " items)\n"; $c->buildSearchIndex(''); $end = Dase_Util::getTime(); $total = $end - $start; print $total . " seconds\n"; }
<?php include 'config.php'; $comms = new Dase_DBO_Comment($db); foreach ($comms->find() as $c) { $item = new Dase_DBO_Item($db); $item->load($c->item_id); $item->comments_updated = $c->updated; $item->comments_count = $item->comment_count + 1; $item; $item->update(); } $cs = new Dase_DBO_Collection($db); $i = 0; foreach ($cs->find() as $c) { print "\nworking on {$c->collection_name}\n\n"; foreach ($c->getItems() as $item) { $i++; $item = clone $item; if (!$item->collection_name) { $item->collection_name = $c->collection_name; $type = $item->getItemType(); $item->item_type_ascii_id = $type->ascii_id; $item->item_type_name = $type->name; $item->update(); } print "\n{$i}"; } }
static function getLookupArray($db) { $hash = array(); $c = new Dase_DBO_Collection($db); foreach ($c->find() as $coll) { $iter = $coll->getIterator(); foreach ($iter as $field => $value) { $coll_hash[$field] = $value; } $hash[$coll->id] = $coll_hash; } return $hash; }
public function getTools($r) { $tpl = new Dase_Template($r); $colls = new Dase_DBO_Collection($this->db); $colls->orderBy('collection_name'); $tpl->assign('collections', $colls->find()); $r->renderResponse($tpl->fetch('admin/tools.tpl')); }
public function getCollections($app_root) { $cm = new Dase_DBO_CollectionManager($this->db); $cm->dase_user_eid = $this->eid; $special_colls = array(); $user_colls = array(); foreach ($cm->find() as $managed) { $special_colls[$managed->collection_ascii_id] = $managed->auth_level; } $coll = new Dase_DBO_Collection($this->db); $coll->orderBy('collection_name'); foreach ($coll->find() as $c) { if (!$c->item_count) { $c->item_count = 0; } if (1 == $c->is_public || in_array($c->ascii_id, array_keys($special_colls))) { if (isset($special_colls[$c->ascii_id])) { $auth_level = $special_colls[$c->ascii_id]; } else { $auth_level = ''; } $user_colls[$c->ascii_id] = array('id' => $c->getUrl($app_root), 'collection_name' => $c->collection_name, 'ascii_id' => $c->ascii_id, 'is_public' => $c->is_public, 'item_count' => $c->item_count, 'auth_level' => $auth_level, 'links' => array('self' => $c->getUrl($app_root), 'media' => $c->getMediaUrl($app_root))); } } return $user_colls; }