Skip to content

Commit

Permalink
tag fixes, aws bucket fixes, 0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
voitto committed Nov 11, 2008
1 parent 80fd1aa commit 07a71c1
Show file tree
Hide file tree
Showing 7 changed files with 958 additions and 210 deletions.
1 change: 1 addition & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ env:
- twitter
- identica
- photos
- auction

plugins:
- sessions
Expand Down
14 changes: 9 additions & 5 deletions app/plugins/omb.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,13 @@ function wp_set_post_fields( &$model, &$rec ) {
$request->set_param( array( 'post', 'parent_id' ), 0 );

$Category =& $db->model('Category');

$Category->set_limit(100);
$Category->find();

$tags = split( ' ', $_POST['tags'] );
if (strstr( $_POST['tags'], "," ))
$tags = split( ',', $_POST['tags'] );
else
$tags = split( ' ', $_POST['tags'] );

$cats = array();

Expand All @@ -241,9 +244,10 @@ function wp_set_post_fields( &$model, &$rec ) {
$newcount = count($cats);

foreach ( $tags as $t ) {
$t = strtolower( trim( $t ));
if (array_key_exists( $t, $cats )) {
$request->set_param( "category".$cats[$t], $t );
$t = trim($t);
$tl = strtolower( $t );
if (array_key_exists( $tl, $cats )) {
$request->set_param( "category".$cats[$tl], $tl );
} else {
$request->set_param( "category".$newcount, $t );
$newcount++;
Expand Down
8 changes: 2 additions & 6 deletions app/plugins/omb_notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,12 @@ function broadcast_omb_notice( &$model, &$rec ) {
} else {
parse_str( $result->body, $return );
if ( is_array($return) && $return['omb_version'] == OMB_VERSION ) {
//break;
$sent_to[] = $url;
} else {
if (strpos($request->base, 'openmicroblogger') !== false)
send_email( 'brian@megapump.com', 'failed to post', "\n\n".$url."\n\n".$result->body."\n\n".$notice_content, environment('email_from'), environment('email_name'), false );
admin_alert('failed to post'."\n\n".$url."\n\n".$result->body."\n\n".$notice_content);
}
}
//if (strpos($request->base, 'openmicroblogger') !== false)
// send_email( 'brian@megapump.com', 'retrying post', $notice_content, environment('email_from'), environment('email_name'), false );
//sleep(2);

//}


Expand Down
25 changes: 21 additions & 4 deletions db/library/dbscript/_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,10 @@ function redirect_to( $param, $altparam = NULL ) {

global $request;

// check for qooxdoo "POST" and bail before redirect
if (strstr($request->uri,"&method="))
if (is_ajax())
echo "OK";

$request->redirect_to( $param, $altparam );
else
$request->redirect_to( $param, $altparam );

}

Expand Down Expand Up @@ -1516,6 +1515,24 @@ function can_edit( $post ) {
return (($pid == $e->person_id) || $m->can_superuser($post->table));
}

function entry_for( &$obj ) {

global $db;

if (isset($obj->entry_id)) {

// it's a Record with metadata

$Entry =& $db->model('Entry');

return $Entry->find($obj->entry_id);

}

return false;

}

function owner_of( &$obj ) {

global $db;
Expand Down
54 changes: 34 additions & 20 deletions db/library/dbscript/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,35 +235,35 @@ function insert_from_post( &$req ) {
$req->id = $rec->id;
$Category =& $db->model('Category');
$Entry =& $db->model('Entry');
for ($i = 0; $i < count($req->params); $i++ ) {
$cname = "category".$i;
$added = array();
if (isset($req->$cname) && !(in_array($req->$cname, $added))) {
$join =& $db->get_table($Entry->join_table_for('categories', 'entries'));
$j = $join->base();
$j->set_value('entry_id',$atomentry->id);
$c = $Category->find_by('name',$req->$cname);
if ($c) {
$j->set_value('category_id',$c->id);
$j->save_changes();
$added[] = $req->$cname;
} elseif (!empty($req->$cname)) {
if (isset_admin_email()) {
$c = $Category->base();
$c->set_value( 'name', ucwords($req->$cname));
$c->set_value( 'term', strtolower($req->$cname));
$c->save();
foreach($req->params as $cname=>$catval) {
if (substr($cname,0,8) == 'category') {
$added = array();
if (!in_array($req->$cname, $added)) {
$join =& $db->get_table($Entry->join_table_for('categories', 'entries'));
$j = $join->base();
$j->set_value('entry_id',$atomentry->id);
$c = $Category->find_by('term',$req->$cname);
if ($c) {
$j->set_value('category_id',$c->id);
$j->save_changes();
$added[] = $req->$cname;
admin_alert( "created a new category: ".$req->$cname." at ".$req->base );
} elseif (!empty($req->$cname)) {
if (isset_admin_email()) {
$c = $Category->base();
$c->set_value( 'name', $req->$cname);
$c->set_value( 'term', strtolower($req->$cname));
$c->save();
$j->set_value('category_id',$c->id);
$j->save_changes();
$added[] = $req->$cname;
admin_alert( "created a new category: ".$req->$cname." at ".$req->base );
}
}
}
}
}
}
}

}

trigger_after( 'insert_from_post', $this, $rec );
Expand Down Expand Up @@ -403,6 +403,20 @@ function delete_from_post( &$req ) {
trigger_error( "Sorry, your id does not match the owner of the database entry", E_USER_ERROR );
}

$coll = environment('collection_cache');

if ($this->has_metadata && isset($coll[$req->resource]) && $coll[$req->resource]['location'] == 'aws') {
$ext = extension_for($atomentry->content_type);
$pkname = $rec->primary_key;
$aws_file = $rec->table . $rec->$pkname . "." . $ext;
lib_include( 'S3' );
$s3 = new S3( environment('awsAccessKey'), environment('awsSecretKey') );
if (!$s3)
trigger_error( 'Sorry, there was a problem connecting to Amazon Web Services', E_USER_ERROR );
if (!($s3->deleteObject(environment('awsBucket'), urlencode($aws_file))))
trigger_error( 'Sorry, there was a problem deleting the file from Amazon Web Services', E_USER_ERROR );
}

$result = $db->delete_record($rec);

trigger_after( 'delete_from_post', $this, $req );
Expand Down

0 comments on commit 07a71c1

Please sign in to comment.