[Affelio-cvs 203] CVS update: affelio/lib/Affelio/App/Admin

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 6月 28日 (火) 00:29:19 JST


Index: affelio/lib/Affelio/App/Admin/Messaging.pm
diff -u affelio/lib/Affelio/App/Admin/Messaging.pm:1.3 affelio/lib/Affelio/App/Admin/Messaging.pm:1.4
--- affelio/lib/Affelio/App/Admin/Messaging.pm:1.3	Sat Jun 25 21:14:06 2005
+++ affelio/lib/Affelio/App/Admin/Messaging.pm	Tue Jun 28 00:29:19 2005
@@ -4,24 +4,101 @@
 #    http://affelio.jp/ (Japan)
 #    http://affelio.jp/ (USA and other area)
 #
-# $Id: Messaging.pm,v 1.3 2005/06/25 12:14:06 slash5234 Exp $
+# $Id: Messaging.pm,v 1.4 2005/06/27 15:29:19 slash5234 Exp $
 
 package Affelio::App::Admin::Messaging;
 {
     use strict;
 
     use lib("../../../../extlib/");
+    use Error qw(:try);
     use lib("../../../");
     use Affelio;
     use Affelio::misc::CGIError;
     use Affelio::misc::Debug qw(debug_print);
     use Affelio::misc::Encoding qw(db_encode db_decode);
-    use Affelio::misc::Time qw(timestamp2string);
+    use Affelio::misc::Time qw(timestamp2string get_timestamp);
     use Affelio::misc::WebInput;
+    use Affelio::SNS::Handshaker_c;
+    use Affelio::exception::CommunicationException;
 
     use Exporter;
     @Affelio::App::Admin::Messaging::ISA = "Exporter";
-    @Affelio::App::Admin::Messaging::EXPORT = qw (show_message_list show_message mark_as_read get_new);
+    @Affelio::App::Admin::Messaging::EXPORT = qw (show_message_list show_message mark_as_read get_new compose send_message);
+
+    #######################################################################
+    #compose
+    #######################################################################    
+    sub send_message{
+	my $af = shift;
+	my $cgi = shift;
+
+	debug_print("Mesg::send: start.");
+
+	my $msg_to = $cgi->param("msg_to");
+	my $msg_title = $cgi->param("msg_title");
+	my $msg_body = $cgi->param("msg_body");
+	
+	debug_print("Mesg::send: $msg_to $msg_title $msg_body");
+
+	my $passAB = $af->{fm}->get_attribute_by_afid($msg_to, "password");
+	if(!defined($passAB) || $passAB eq ""){
+	    #Exception!
+	    exit(1);
+	}
+	debug_print("Mesg::send: passAB=[$passAB]");
+
+	my $ret="";
+	try{
+	    $ret = post_Message(proto_ver => "1",             
+				dest_uri =>  "$msg_to/bin/xml-rpc-serv.cgi",
+				src => $af->{site__web_root},
+				password => $passAB,
+				msg_from => $af->{site__web_root},
+				msg_from_nickname => $af->{user__nickname},
+				msg_to => $msg_to,
+				msg_timestamp => get_timestamp(),
+				msg_title => $msg_title,
+				msg_body => $msg_body);
+	}catch Affelio::exception::IOException with{
+	    my $E = shift;
+	    throw Affelio::exception::CommunicationException("Send failure");
+
+	}catch Affelio::exception::Exception with{
+	    my $E = shift;
+	    error($cgi, "<PRE>Exception: " . $E .  "</PRE>");
+	};
+	if($ret->{flerror} != 0){
+	    #XML-RPC communication was successful. 
+	    #But the peer returned error. denyetc...
+	    error($cgi, "<PRE>XML-RPC peer denied RPC.</PRE>");
+	}
+    }
+
+
+    #######################################################################
+    #compose
+    #######################################################################    
+    sub compose{
+	my $af = shift;
+	my $output_ref = shift;
+    	my $wi = new Affelio::misc::WebInput;
+
+	debug_print("Messaging::compose: start.");
+	my @friends_list=();
+	my $result = $af->{fm}->get_all_friend_list();
+
+	while( my @row = $result->fetchrow_array ){
+	    
+	    push(@friends_list, {nickname => $row[2],
+				 afid     => $row[1]});
+	    debug_print("Messaging::\t$row[2]");
+
+	}
+
+	$output_ref->{"friends"} = \@friends_list;
+	debug_print("Messaging::compose: end.");
+    }
 
     #######################################################################
     #mark_as_read


Affelio-cvs メーリングリストの案内
Back to archive index