function flickr_photos_update_photo(&$photo, $update)
{
    $cache_key = "photo_{$photo['id']}";
    #
    $lookup = flickr_photos_lookup_photo($photo['id']);
    if (!$lookup) {
        return;
    }
    $user = users_get_by_id($lookup['user_id']);
    $cluster_id = $user['cluster_id'];
    $enc_id = AddSlashes($photo['id']);
    $where = "id={$enc_id}";
    # see also: git:parallel-flickr/solr/conf/schema.xml
    $solr_fields = array('perms', 'geoperms', 'geocontext', 'media', 'latitude', 'longitude', 'accuracy', 'woeid', 'datetaken', 'dateupload', 'title', 'description');
    $solr_update = 0;
    $hash = array();
    foreach ($update as $k => $v) {
        $hash[$k] = AddSlashes($v);
        if (in_array($k, $solr_fields)) {
            $solr_update++;
        }
    }
    $rsp = db_update_users($cluster_id, 'FlickrPhotos', $hash, $where);
    if (!$rsp['ok']) {
        return $rsp;
    }
    cache_unset($cache_key);
    if ($GLOBALS['cfg']['enable_feature_solr'] && $solr_update) {
        $photo = flickr_photos_get_by_id($photo['id']);
        # This is a quick hack that may become permanent. Basically
        # we need to refetch the data in flickr.photos.getInfo in
        # order to update the solr db. Normally the _index_photo pulls
        # this information from disk; the files having been written
        # by the bin/backup_photos.php script. As I write this the www
        # server does not have write permissions on the static photos
        # directory. If it did, this whole problem would go away and in
        # the end that may be the simplest possible solution. Until then
        # we'll fetch the (meta) data directly from the API and force
        # feed it to the search indexer. If you're wondering: Yes, it means
        # that the local solr db and the actual JSON dump of photos.getInfo
        # will be out of sync but that will sort itself out the next
        # time bin/backup_photos.php is run (20111231/straup)
        loadlib("flickr_photos_metadata");
        $meta = flickr_photos_metadata_fetch($photo, 'inflate');
        flickr_photos_search_index_photo($photo, $meta);
    }
    return $rsp;
}
function _set_latlon($row, $more = array())
{
    $user = users_get_by_id($row['user_id']);
    $venue_id = $row['venue_id'];
    $venue = foursquare_venues_get_by_venue_id($venue_id);
    if (!$venue) {
        $venue = foursquare_venues_archive_venue($venue_id);
    }
    if (!$venue) {
        echo "can not sort out venue data for '{$venue_id}'\n";
        return;
    }
    $lat = $venue['latitude'];
    $lon = $venue['longitude'];
    $update = array('latitude' => AddSlashes($lat), 'longitude' => AddSlashes($lon));
    $enc_id = $row['id'];
    $where = "id='{$enc_id}'";
    $cluster_id = $user['cluster_id'];
    $rsp = db_update_users($cluster_id, 'PrivatesquareCheckins', $update, $where);
    echo "{$venue_id} : {$lat}, {$lon} {$where}: {$rsp['ok']}\n";
}
function flickr_push_subscriptions_update(&$subscription, $update)
{
    $user = users_get_by_id($subscription['user_id']);
    $cluster_id = $user['cluster_id'];
    $hash = array();
    foreach ($update as $k => $v) {
        $hash[$k] = AddSlashes($v);
    }
    $enc_id = AddSlashes($subscription['id']);
    $where = "id='{$enc_id}'";
    $rsp = db_update_users($cluster_id, 'FlickrPushSubscriptions', $hash, $where);
    if ($rsp['ok']) {
        _flickr_push_subscriptions_purge_cache_keys($subscription);
    }
    return $rsp;
}
Пример #4
0
function sheets_update_sheet(&$sheet, $update)
{
    $user = users_get_by_id($sheet['user_id']);
    $enc_id = AddSlashes($sheet['id']);
    $where = "id='{$enc_id}'";
    foreach ($update as $k => $v) {
        $update[$k] = AddSlashes($v);
    }
    $update['last_modified'] = time();
    $rsp = db_update_users($user['cluster_id'], 'Sheets', $update, $where);
    if ($rsp['ok']) {
        $cache_keys = array("sheet_{$sheet['id']}");
        foreach ($cache_keys as $key) {
            cache_unset($key);
        }
        export_cache_purge_sheet($sheet);
    }
    return $rsp;
}
Пример #5
0
function dots_update_dot(&$dot, $update)
{
    $user = users_get_by_id($dot['user_id']);
    $enc_id = AddSlashes($dot['id']);
    $where = "id='{$enc_id}'";
    foreach ($update as $k => $v) {
        $update[$k] = AddSlashes($v);
    }
    $rsp = db_update_users($user['cluster_id'], 'Dots', $update, $where);
    if ($rsp['ok']) {
        $cache_key = "dot_{$dot['id']}";
        cache_unset($cache_key);
    }
    #
    # Update search: TODO
    #
    #
    # Update the lookup table?
    #
    $sheet = sheets_get_sheet($dot['sheet_id']);
    $count_rsp = sheets_update_dot_count_for_sheet($sheet);
    $lookup_update = array('last_modified' => $now);
    $lookup_rsp = dots_lookup_update($dot, $lookup_update);
    if (!$lookup_rsp['ok']) {
        # What?
    }
    # caching...
    # Happy!
    return $rsp;
}