# Copyright 1997-2009 by Geeknet, Inc. See README
# and COPYING for more information, or see http://slashcode.com/.
-package Slash::DB::MySQL;
+#package Slash::DB::MySQL;
+package Newslash::Model::SlashDB;
+use base Newslash::Model::LegacyDB;
+#use Newslash::Model::Base -base;
-use strict;
+#use strict;
use Socket;
use Digest::MD5 'md5_hex';
use Storable qw(thaw nfreeze);
use URI ();
-use Slash::Utility;
-use Slash::Custom::ParUserAgent;
-use Slash::Constants ':messages';
+#use Slash::Utility;
+#use Slash::Custom::ParUserAgent;
+#use Slash::Constants ':messages';
-use vars qw($_proxy_port);
+#use vars qw($_proxy_port);
-use base 'Slash::DB';
-use base 'Slash::DB::Utility';
+#use base 'Slash::DB';
+#use base 'Slash::DB::Utility';
-our $VERSION = $Slash::Constants::VERSION;
+
+#our $VERSION = $Slash::Constants::VERSION;
# Fry: How can I live my life if I can't tell good from evil?
package Newslash::Model::Stories;
use Newslash::Model::Base -base;
+use Newslash::Model::SlashDB;
+
use Data::Dumper;
#========================================================================
my ($self, $params, $uid) = @_;
#createStory
+ #my $slash_db = $self->new_instance_of('Newslash::Model::SlashDB');
+ my $slash_db = Newslash::Model::SlashDB->new($self->{options});
+ #my $slash_db = $self->new_instance_of('SlashDB');
+ my $story = $slash_db->createStory($params);
+ return $story;
}
sub createSid {
return sprintf($sidformat, @lt[reverse 0..5]);
}
+=pod
+
sub grantStorySubmissionKarma {
my($self, $story) = @_;
#my $constants = getCurrentStatic();
subid => $story->{subid});
}
+
+=cut
+
########################################################
+
+=pod
+
sub createStory {
my($self, $story) = @_;
$self->grantStorySubmissionKarma($story);
}
- if (!$error) {
- if (! $self->sqlInsert('story_text', { stoid => $stoid })) {
- $error = "sqlInsert failed for story_text: " . $self->sqlError();
- }
- }
+ if (!$error) {
+ #if (! $self->sqlInsert('story_text', { stoid => $stoid })) {
+ if (! $db->sqlInsert('story_text', { stoid => $stoid })) {
+ $error = "sqlInsert failed for story_text: " . $self->sqlError();
+ }
+ }
- # Write the chosen topics into story_topics_chosen. We do this
- # here because it returns the primaryskid and we will write that
- # into the stories table with setStory in just a moment.
+ # Write the chosen topics into story_topics_chosen. We do this
+ # here because it returns the primaryskid and we will write that
+ # into the stories table with setStory in just a moment.
my($primaryskid, $tids);
if (!$error) {
my $success = $self->setStoryTopicsChosen($stoid, $story->{topics_chosen});
return $story->{sid};
}
-
sub editCreateStory {
my($self, $preview, $fhitem) = @_;
my $constants = getCurrentStatic();
-
+=cut
my $self = shift;
my %params = @_;
- my $subid = %params{subid};
- my $values = %params{params};
- if (!$subid || !params) {
+ my $subid = $params{subid};
+ my $values = $params{params};
+ if (!$subid || !%params) {
return;
}
EOSQL
my $sth = $dbh->prepare($sql);
- for my $k (keys $values) {
+ for my $k (keys %$values) {
my $rs = $sth->execute($subid, $k, $values->{$k}, $values->{$k});
if (!$rs) {
# TODO
my $self = shift;
my %params = @_;
- my $subid = %params{subid};
+ my $subid = $params{subid};
return if !$subid;
my $sql = "UPDATE submissions SET ? = ? WHERE subid = ?";
SKIP: {
skip "mode is not 'test'", 1 if ($t->app->mode ne 'test');
- my $comments = $t->app->model('comments');
- my $params = {};
- my $user = "";
- my $cid = $comments->create($params, $user);
- ok($cid);
+ #my $comments = $t->app->model('comments');
+ my $stories = $t->app->model('stories');
+ my $params = {
+ uid => 1,
+ title => "Test Story",
+ bodytext => '',
+ introtext => 'Test Story body',
+ topics_chosen => {},
+ commentstatus => '',
+ #subid => '',
+ };
+ my $uid = 1;
+ my $sid = $stories->create($params, $uid);
+ ok($sid);
}
done_testing();