Tadashi Okoshi
slash****@users*****
2005年 10月 25日 (火) 04:20:54 JST
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/AccessLogManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/AccessLogManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/AccessLogManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/AccessLogManager.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/AccessLogManager.pm Tue Oct 25 04:20:54 2005
@@ -1,206 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id: AccessLogManager.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::Managing::AccessLogManager;
-{
- use strict;
- use lib("../../../extlib");
- use DBI;
- use Jcode;
- use lib("../../");
- use Affelio::misc::CGIError;
- use Affelio::misc::Time qw(get_timestamp get_today);
- use Affelio::misc::Encoding qw(db_encode db_decode);
- use Affelio::misc::Debug qw(debug_print);
- use Affelio::NetLib::Email qw(send_email);
- use Affelio::exception::DBException;
-
- #######################################################################
- #Constructor
- #######################################################################
- sub new{
- my $class = shift;
- my $af = shift;
-
- debug_print("AccessLogManager::new: start.");
-
- my $self = {af => $af
- };
-
- bless $self, $class;
-
- debug_print("AccessLogManager::new: end.");
- return $self;
- }
-
- #######################################################################
- #save_log
- #######################################################################
- sub save_log{
- my $self=shift;
- my $afid = shift;
- my $nickname = shift;
- my $type=shift;
-
- #AFuser_CORE_accesslog
- # id id2 timestamp INT, nickname TEXT, afid TEXT, type TEXT
-
- my $af=$self->{af};
- my $cur_time = get_timestamp();
- my $startoftheday = get_today();
-
- ################################
- #Check the table
- ################################
- my $create_tbl_cmd = "CREATE TABLE AFuser_CORE_accesslog(id INTEGER PRIMARY KEY, id2 INTEGER, timestamp BIGINT, nickname TEXT, afid TEXT, type TEXT)";
- eval{
- $af->{db}->do($create_tbl_cmd);
- };
- if($@){
- }else{
- debug_print("AccessLog:save: Table created.");
- }
-
- ################################
- #check today's past access of this user
- ################################
- my $query1; my $sth1; $@="";
- my @row1=();
- $query1 = "SELECT * FROM AFuser_CORE_accesslog WHERE timestamp >= $startoftheday AND afid = '$afid'";
- debug_print("AccessLog:save: q=[$query1]");
- eval{
- $sth1 = $af->{db}->prepare($query1);
- $sth1->execute();
- @row1 = $sth1->fetchrow_array;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- if(@row1 == () ){
- debug_print("AccessLog:save: This is your 1st access today. proceed.");
- my $newid=0; my $maxid=0;
-
- ##############################
- #Get existing max ID
- my $query2 = 'SELECT max(id) FROM AFuser_CORE_accesslog';
- my $sth2;
- eval{
- $sth2 = $af->{db}->prepare($query2);
- $sth2->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row2 = $sth2->fetchrow_array;
- $maxid = $row2[0];
- debug_print("AccessLog:save: maxid=[$maxid]");
-
- if(defined($row2[0])){
- $maxid = $row2[0];
- }else{
- $maxid = 0;
- }
- $newid = $maxid+1;
-
- ##############################
- #Get existing max ID2
- my $newid2=0; my $maxid2=0;
- if($afid =~ /http/){
- $query2 = 'SELECT max(id2) FROM AFuser_CORE_accesslog';
- eval{
- $sth2 = $af->{db}->prepare($query2);
- $sth2->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- @row2 = $sth2->fetchrow_array;
- $maxid2 = $row2[0];
- debug_print("AccessLog:save: maxid2=[$maxid2]");
- if(defined($row2[0])){
- $maxid2 = $row2[0];
- }else{
- $maxid2 = 0;
- }
- $newid2 = $maxid2+1;
- }
-
- ################################
- #Add this access
- ################################
- my $query3; my $sth3;
- $query3 = "insert into AFuser_CORE_accesslog(id, id2, timestamp, nickname, afid, type) values ($newid, $newid2, $cur_time, '$nickname', '$afid', '$type')";
- eval{
- $sth3 = $af->{db}->prepare($query3);
- $sth3->execute();
- };
- debug_print("AccessLog:save: inserted [$query3]");
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("AccessLog:save: recorded!");
- }else{
- debug_print("AccessLog:save: You are a repeater. ignore you.");
- }
- }
-
- #######################################################################
- #get_log
- #######################################################################
- sub get_log{
- my $self=shift;
- my $from=shift;
- my $to=shift;
- my $af = $self->{af};
-
- debug_print("AccessLog::get_log: $from -> $to");
-
- ################################
- #Check the table
- ################################
- my $create_tbl_cmd = "CREATE TABLE AFuser_CORE_accesslog(id INTEGER PRIMARY KEY, id2 INTEGER, timestamp INTEGER, nickname TEXT, afid TEXT, type TEXT)";
- eval{
- $af->{db}->do($create_tbl_cmd);
- };
- if($@){
- }else{
- debug_print("AccessLog:save: Table created.");
- }
-
- ##############################
- #retrieve all friend records from DB
- my $query = "SELECT * FROM AFuser_CORE_accesslog WHERE timestamp > $from AND timestamp < $to order by id desc";
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- return($sth);
- }
-
-}#package
-1;
-
-
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ApplicationManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ApplicationManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ApplicationManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ApplicationManager.pm:1.1.1.1 Tue Oct 25 04:14:39 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ApplicationManager.pm Tue Oct 25 04:20:54 2005
@@ -1,386 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id: ApplicationManager.pm,v 1.1.1.1 2005/10/24 19:14:39 slash5234 Exp $
-
-package Affelio::Managing::ApplicationManager;
-{
- use strict;
- use lib("../../../extlib");
- use DBI;
- use Jcode;
- use lib("../../");
- use Affelio::misc::CGIError;
- use Affelio::misc::Encoding qw(db_encode db_decode);
- use Affelio::misc::Debug qw(debug_print);
- use Affelio::exception::DBException;
-
- #######################################################################
- #Constructor
- #######################################################################
- sub new{
- my $class = shift;
- my $af = shift;
- my %apps=();
-
- debug_print("ApplicationManager::new: start.");
- my $self = {af => $af,
- apps => %apps
- };
-
- bless $self, $class;
-
- load_applications($self);
-
- debug_print("ApplicationManager::new: end.");
- return $self;
- }
-
- #####################################################################
- #get_summed_app_perm
- #####################################################################
- sub get_summed_app_perm{
- my $self = shift;
- my $af = $self->{af};
- my $visitor_id = shift; #arg(1) visitor_ID
- my $visitor_mode = shift; #arg(2) visitor_mode
- my $app_name =shift; #arg(3) application install_name
- my $action_type =shift; #arg(4) action_type
-
- my @ret_list=();
-
- debug_print("AppManager::get_summed_app_perm: start.");
- debug_print("AppManager::get_summed_app_perm: visitor_id = $visitor_id");
- debug_print("AppManager::get_summed_app_perm: visitor_mode= $visitor_mode");
- debug_print("AppManager::get_summed_app_perm: app_name = $app_name");
- debug_print("AppManager::get_summed_app_perm: action_type = $action_type");
-
- if($visitor_mode eq "f2" || $visitor_mode eq "pb"){
- ####################
- # f2 or PB
- ####################
-
- my $query = "select $action_type from AFuser_" . $app_name
- ."_permission where type = 'f' and target_id = '$visitor_mode'";
-
- debug_print("AppManager::get_summed_app_perm: q=[$query]");
-
- my $sth = $af->{db}->prepare($query) or
- throw Affelio::exception::DBException("cannot insert");
- $sth->execute() or
- throw Affelio::exception::DBException("cannot insert");
-
- my @row = $sth->fetchrow_array;
-
- debug_print("AppManager::get_summed_app_perm: end [$row[0]]");
- return($row[0]);
-
- }elsif($visitor_mode eq "self"){
-
- return(1);
-
- }else{
- ####################
- # f1
- ####################
- #We will make
- # perm(f1) OR Vx(perm(G))
-
- #################
- #(1) as a friend
- my $query = "select $action_type from AFuser_" . $app_name
- ."_permission where type = 'f' and target_id = '$visitor_mode'";
- my $sth = $af->{db}->prepare($query) or
- throw Affelio::exception::DBException("cannot insert");
- $sth->execute() or
- throw Affelio::exception::DBException("cannot insert");
- my @row = $sth->fetchrow_array;
- if($row[0] == 1){
- return(1);
- }
-
- #################
- #(2) as a member of each group
-
- #Get the visitor's UID
- my ($t_uid, $t_afid, $t_nickname, $t_time,
- $t_pass, $t_intro, $t_pid, $t_lastupdated, $t_f2list)
- = $af->{fm}->get_friend_by_afid($visitor_id);
-
- #Get the visitor's groups
- my $SQL_result = $af->{gm}->get_groups_by_uid($t_uid);
-
- #For each group...
- my @g_data=();
- my $flag=0;
- while(@g_data = $SQL_result->fetchrow_array) {
- my $gid = $g_data[0];
-
- my $query = "select $action_type from AFuser_" . $app_name
- ."_permission where type = 'g' and target_id = '$gid'";
- my $sth = $af->{db}->prepare($query) or
- throw Affelio::exception::DBException("cannot insert");
- $sth->execute() or
- throw Affelio::exception::DBException("cannot insert");
- my @row = $sth->fetchrow_array;
-
- if($row[0] ==1){
- $flag=1;
- }
- }
-
- return($flag);
-
- }
-
- }
-
- ######################################################################
- #get_all_permission
- ######################################################################
- sub get_all_permission{
- my $self = shift;
- my $app_name = shift; #arg(1) app install_name
-
- debug_print("get_all_premission: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all permission records from DB
- my $query = 'SELECT * FROM AFuser_' . $app_name . '_permission';
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("get_all_premission: end");
- return($sth);
- }
-
- ######################################################################
- #prepare_app_perm_table Check Appliation Permission Table
- ######################################################################
- sub prepare_app_perm_table{
- my $self = shift;
- my $af = $self->{af};
- my $caller = shift; #application install name
-
- #Does my application's permission table already exist?
- my $my_table_name = "AFuser_" . $caller . "_permission";
- debug_print("AppManager::check_table: table = [".$my_table_name."]");
-
- my $query = "SELECT * FROM " . $my_table_name;
- eval{
- my $sth = $af->{db}->prepare($query);
- my @dummy = $sth->execute();
- };
- if($@){
- #############################################
- #Table of this application does not exist!
- #Thus, we will make the table
- my $create_table_SQL="CREATE TABLE $my_table_name (pid INTEGER, type TEXT, target_id TEXT, DF_visibility INTEGER, DF_access INTEGER, ";
- my $new_rec_SQL="insert into $my_table_name(pid, type, target_id, DF_visibility, DF_access, ";
-
- my $num_action_types
- = @{ $self->{apps}->{$caller}->{action_types} };
- my $i;
- for($i=0; $i < $num_action_types; $i++){
- $create_table_SQL .=
- ${ $self->{apps}->{$caller}->{action_types} }[$i];
- $create_table_SQL .= " INTEGER,";
-
- $new_rec_SQL .=
- ${ $self->{apps}->{$caller}->{action_types} }[$i];
- $new_rec_SQL .= ",";
-
- }
- chop($create_table_SQL); #Delete "," at the end.
- $create_table_SQL .= ") ";
- chop($new_rec_SQL); #Delete "," at the end.
- $new_rec_SQL .= ")";
-
- debug_print("AppManager::check_table: create_SQL = [".$create_table_SQL."]");
-
- my $sth = $af->{db}->prepare($create_table_SQL) or
- throw Affelio::exception::DBException("cannot create table");
- $sth->execute() or
- throw Affelio::exception::DBException("cannot create table");
-
- debug_print("AppManager::check_table: created the table!");
-
- #############################################
- #Synchronized the table
- # Find all records from AFuser_CORE_permission and
- # prepare 0-filled records into my table
- my $CORE_perm_tbl = $af->{perm}->get_all_permission();
- while( my($pid, $type, $target, $dummy) = $CORE_perm_tbl->fetchrow_array ){
-
- my $SQL = $new_rec_SQL . " values ('$pid','$type','$target',1,0,";
- for($i=0; $i < $num_action_types; $i++){
- $SQL .= "0,";
- }
- chop($SQL);
- $SQL .= ")";
-
- debug_print("AppManager::check_table: insert_SQL = [".$SQL."]");
- my $sth = $af->{db}->prepare($SQL) or
- throw Affelio::exception::DBException("cannot insert");
- $sth->execute() or
- throw Affelio::exception::DBException("cannot insert");
-
- }
-
-
- }
- debug_print("AppManager::check_table: end.");
- }
-
- ######################################################################
- #update_permission
- ######################################################################
- sub update_permission{
- my $self = shift;
- my $af = $self->{af};
-
- my $app_name = shift;
- my $pid = shift;
- my $action_type = shift;
- my $value = shift;
-
- #prepare SQL query
- my $query = "update AFuser_" . $app_name . "_permission set "
- . "$action_type = $value where pid=$pid";
- #debug_print("AppManager::update_permission q=[$query]");
-
- #access DB
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- #debug_print("AppManager::update_permission end.");
- }
-
-
- ######################################################################
- #load_applications
- ######################################################################
- sub load_applications{
- my $self = shift;
- my $af = $self->{af};
-
- my $app_dir;
- opendir(DIR, "$af->{top_dir}/apps");
- while (defined($app_dir = readdir(DIR))) {
- if( ($app_dir ne '.')
- && ($app_dir ne '..')
- && ($app_dir ne 'index.html')
- && ($app_dir ne 'sampleapp')
- && ($app_dir ne 'CVS')
- ){
-
- ##################################
- #For each found application...
- ##################################
- debug_print("Affelio::load_apps: [$app_dir]");
-
- ##################################
- #Open a config file
- ##################################
- my $cfg = new Config::IniFiles( -file => "$af->{top_dir}/apps/$app_dir/AF_app.cfg" );
- if(!$cfg){ next; }
-
- my %this_app=();
- my $err_flag=0;
- ##################################
- #Read application-specific parameters
- ##################################
- my @read_parameter_list=
- ("app_name", "app_version", "app_author",
- "guest_index", "owner_index",
- "action_types", "action_types_desc");
-
- foreach my $param (@read_parameter_list){
- my $data = $cfg->val('application', $param);
- if ($data){
- debug_print("Affelio::load_apps: \t$param = $data");
- $this_app{$param} = $data;
- }else{
- debug_print("Affelio::load_apps: \t$param not found.");
- $err_flag=1;
- }
- }
-
- my @this_app_action_types =();
- my @this_app_action_types_desc =();
- @this_app_action_types =split(',\s', $this_app{action_types});
- @this_app_action_types_desc =split(',', $this_app{action_types_desc});
-
- ##################################
- #Read installation-specific parameters
- ##################################
- my @inst_parameter_list= ("title");
-
- foreach my $param (@inst_parameter_list){
- my $data = $cfg->val('this_installation', $param);
- if ($data){
- debug_print("Affelio::load_apps: \t$param = $data");
- $this_app{"install_" . $param} = $data;
- }else{
- debug_print("Affelio::load_apps: \t$param not found.");
- $err_flag=1;
- }
- }
-
- ##################################
- #Store into Affelio's hash
- ##################################
- if(!$err_flag){
- $self->{apps}->{$app_dir}
- = {'app_name' => $this_app{'app_name'},
- 'app_version' => $this_app{'app_version'},
- 'app_author' => $this_app{'app_author'},
- 'guest_index' => $this_app{'guest_index'},
- 'owner_index' => $this_app{'owner_index'},
- #
- 'action_types' => \@this_app_action_types,
- 'action_types_desc' => \@this_app_action_types_desc,
- #
- 'install_name' => $app_dir,
- 'install_title' => $this_app{'install_title'}
- };
- }
-
- }#if
- }#while
-
- }
-
-
-
-
-
-
-}
-1;
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/GroupManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/GroupManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/GroupManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/GroupManager.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/GroupManager.pm Tue Oct 25 04:20:54 2005
@@ -1,476 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-# $Id: GroupManager.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::Managing::GroupManager;
-{
- use strict;
-
- use lib("../../../extlib");
- use DBI;
-
- use lib("../../");
- use Affelio;
- use Affelio::misc::CGIError;
- use Affelio::misc::Debug qw(debug_print);
- use Affelio::misc::DBroutines qw(db_value_replace);
-
- ########################################################################
- #Constructor
- ########################################################################
- sub new{
- my $class = shift;
- my $af = shift;
-
- debug_print("GroupManager::new: start.");
-
- my $self = {af => $af
- };
- bless $self, $class;
-
- debug_print("GroupManager::new: end.");
- return $self;
- }
-
- ########################################################################
- #add_group
- ########################################################################
- sub add_group{ #returns gid (int)
- my $self = shift;
- my $group_name = shift; #arg(1) group_name (string)
-
- debug_print("add_group: $group_name");
-
- my $af = $self->{af};
-
- ##############################
- #Get existing max ID
- my $query = 'SELECT max(gid) FROM AFuser_CORE_group';
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row = $sth->fetchrow_array;
- my $maxid = $row[0];
- if(defined($row[0])){
- $maxid = $row[0];
- }else{
- $maxid = 0;
- }
- debug_print("add_group: maxgid = $maxid");
-
- ##############################
- #Insert a new record
- $query = 'insert into AFuser_CORE_group(gid, group_name, members, option_pid) values (?,?,?,?)';
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($maxid+1, $group_name, ",", -1);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("add_group: end.");
- return($maxid+1);
- }
-
- ########################################################################
- #remove_group
- ########################################################################
- sub remove_group{ #void
- my $self = shift;
- my $gid = shift; #arg(1) gid
-
- debug_print("remove_group: g[$gid]");
- my $af = $self->{af};
-
- my $query1 = 'SELECT option_pid FROM AFuser_CORE_group WHERE gid = ?';
- my $sth1;
- eval{
- $sth1 = $af->{db}->prepare($query1);
- $sth1->execute($gid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row1 = $sth1->fetchrow_array;
- my $perm_id = $row1[0];
-
- my $query2 = 'DELETE FROM AFuser_CORE_group WHERE gid = ?';
- my $sth2;
- eval{
- $sth2 = $af->{db}->prepare($query2);
- $sth2->execute($gid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- use Affelio::Managing::PermissionManager;
- $af->{perm}->remove_permission_by_pid($perm_id);
-
- debug_print("remove_group: end.");
- }
-
- ########################################################################
- #rename_group
- ########################################################################
- sub rename_group{
- my $self = shift;
- my $gid = shift; #arg(1) gid
- my $new_name = shift; #arg(2) new_name
-
- debug_print("rename_group: g[$gid] -> [$new_name]");
- my $af = $self->{af};
-
- ##############################
- #Update DB
- my $query = "update AFuser_CORE_group set group_name = '$new_name' where gid = $gid";
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("rename_group: end.");
- }
-
-
- ########################################################################
- #get_member
- ########################################################################
- sub get_member{ #returns int[] uids
- my $self = shift;
- my $gid = shift; #arg(1) gid
-
- debug_print("get_member: g[$gid]");
- my $af = $self->{af};
-
- my $query = 'SELECT members FROM AFuser_CORE_group WHERE gid = ?';
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($gid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row = $sth->fetchrow_array;
-
- if(!@row){
- debug_print("get_member: Error: No such group.");
- return;
- }
-
- my @member_array = split(",", $row[0]);
- return(@member_array);
- }
-
-
- ########################################################################
- #add_member
- ########################################################################
- sub add_member{ #void
- my $self = shift;
- my $gid = shift; #arg(1) gid
- my $uid = shift; #arg(2) uid
-
- debug_print("add_member: g[$gid] <- u[$uid]");
- my $af = $self->{af};
-
- ##############################
- #retrieve a friend record from DB
- my $query = 'SELECT * FROM AFuser_CORE_group WHERE gid = ?';
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($gid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- my @row = $sth->fetchrow_array;
-
- if(!@row){
- debug_print("add_member: Error: No such group.");
- return;
- }
-
- ##############################
- #Check existing member
- my $current_mem = $row[2];
- if($current_mem =~ /,$uid,/){
- debug_print("add_member: Error: u[$uid] is already in g[$gid]");
- return;
- }
-
- ##############################
- #Add the new user
- debug_print("add_member: Member($gid) = ($current_mem) (before)");
- my $new_mem = $current_mem . $uid . ",";
- debug_print("add_member: Member($gid) = ($new_mem) (after)");
-
- ##############################
- #Update DB
- $query = "update AFuser_CORE_group set members = '$new_mem' where gid = $gid";
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("add_member: end.");
- }
-
-
- ########################################################################
- #remove_person_from_all
- ########################################################################
- sub remove_person_from_all{
- my $self = shift;
- my $uid = shift; #arg(1) uid
-
- my $af=$self->{af};
-
- db_value_replace($af->{db},
- "AFuser_CORE_group",
- "gid",
- "members",
- ",$uid," ,
- ",," ,
- );
- }
-
-
- ########################################################################
- #remove_member
- ########################################################################
- sub remove_member{ #void
- my $self = shift;
- my $gid = shift; #arg(1) gid
- my $uid = shift; #arg(2) uid
-
- debug_print("remove_member: g[$gid] u[$uid]");
- my $af = $self->{af};
-
- my $query = 'SELECT members FROM AFuser_CORE_group WHERE gid = ?';
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($gid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- my @row = $sth->fetchrow_array;
-
- if(!@row){
- debug_print("remove_member: Error: No such group.");
- return;
- }
-
- debug_print("remove_member: Member($gid) = ($row[0]) (before)");
- $row[0] =~ s/,$uid,/,/;
- debug_print("remove_member: Member($gid) = ($row[0]) (after)");
-
- my $query2 = "update AFuser_CORE_group set members = '$row[0]' where gid = $gid";
- my $sth2;
- eval{
- $sth2= $af->{db}->prepare($query2);
- $sth2->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("remove_member: end.");
- return;
- }
-
- ########################################################################
- #get_groups_by_uid
- ########################################################################
- #sub SQL_result get_groups_by_uid(uid)
- #SQL_result (gid, group_name, members, option_pid)
- sub get_groups_by_uid{ #returns SQL result
- my $self = shift;
- my $uid = shift; #arg(1) uid
-
- debug_print("get_groups_by_uid: u[$uid]");
- my $af = $self->{af};
-
- my $query =
- "SELECT * FROM AFuser_CORE_group WHERE members like '%,$uid,%'";
- debug_print("get_groups_by_uid: q=[$query]");
-
- ##############################
- #retrieve a friend record from DB
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute();
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- return($sth);
- }
-
- ########################################################################
- #get_unsubscribing_groups_by_uid
- ########################################################################
- #sub SQL_result get_unsubscribing_groups_by_uid
- #SQL_result (gid, group_name, members, option_pid)
- sub get_unsubscribing_groups_by_uid{ #returns SQL result
- my $self = shift;
- my $uid = shift; #arg(1) uid
-
- debug_print("get_unsubscribing_groups_by_uid: u[$uid]");
- my $af = $self->{af};
-
- my $query = "SELECT * FROM AFuser_CORE_group WHERE members NOT like "
- ."'%,$uid,%'";
-
- debug_print("get_unsubscribing_groups_by_uid: q=[$query]");
-
- ##############################
- #retrieve a friend record from DB
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute();
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- return($sth);
- }
-
- ########################################################################
- #get_all_group_list
- ########################################################################
- #sub SQL_result get_all_group_list
- #result (gid, group_name, members, option_pid)
- sub get_all_group_list{ #returns SQL result
- my $self = shift;
-
- debug_print("get_all_group_list: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all friend records from DB
- my $query = 'SELECT * FROM AFuser_CORE_group';
- my $sth;
- eval{
- $sth= $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- return($sth);
- }
-
- ########################################################################
- #set_member_by_intarray
- ########################################################################
- sub set_member_by_intarray{ #void
- my $self = shift;
- my $gid = shift; #arg(1) gid
- my $uids_ref = shift; #arg(2) * uid_array_ref
- my @uids = @$uids_ref;
-
- debug_print("set_member_by_intarray: g[$gid] uids[@uids]");
-
- my $uids_str=",";
- while(my $member = pop(@uids)){
- $uids_str .= $member . ",";
- }
-
- set_member_by_string($self,$gid, $uids_str);
- debug_print("set_member_by_intarray: end.");
- }
-
- ########################################################################
- #set_member_by_string
- ########################################################################
- sub set_member_by_string{ #void
- my $self = shift;
- my $gid = shift; #arg(1) gid
- my $uids_str = shift; #arg(2) uids_str ex. ",0,1,2,3...20,"
-
- my $af = $self->{af};
- debug_print("set_member_by_string: g[$gid] uids[$uids_str]");
-
- ##############################
- #Update DB
- my $query = "update AFuser_CORE_group set members = '$uids_str' where gid = $gid";
- my $sth;
- eval{
- $sth= $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("set_member_by_string: end.");
- }
-
- ########################################################################
- #set_pid
- ########################################################################
- sub set_pid{ #void
- my $self = shift;
- my $gid = shift; #arg(1) gid
- my $pid = shift; #arg(2) pid
-
- my $af = $self->{af};
- debug_print("set_pid: g[$gid] p[$pid]");
-
- ##############################
- #Update DB
- my $query = "update AFuser_CORE_group set option_pid = $pid where gid = $gid";
- my $sth;
- eval{
- $sth= $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("set_pid: end.");
- }
-
- ########################################################################
-
-}#package
-1;
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/MessageManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/MessageManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/MessageManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/MessageManager.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/MessageManager.pm Tue Oct 25 04:20:54 2005
@@ -1,241 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id: MessageManager.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::Managing::MessageManager;
-{
- use strict;
- use lib("../../../extlib");
- use DBI;
- use Jcode;
- use lib("../../");
- use Affelio::misc::CGIError;
- use Affelio::misc::Time qw(get_timestamp);
- use Affelio::misc::Encoding qw(db_encode db_decode);
- use Affelio::misc::Debug qw(debug_print);
- use Affelio::NetLib::Email qw(send_email);
- use Affelio::exception::DBException;
-
- #######################################################################
- #Constructor
- #######################################################################
- sub new{
- my $class = shift;
- my $af = shift;
-
- debug_print("MessageManager::new: start.");
-
- my $self = {af => $af
- };
-
- bless $self, $class;
-
- debug_print("MessageManager::new: end.");
- return $self;
- }
-
- #MessageManager looks up each application directory
- #to get the whole list of message types.
-
- ########################################################################
- #get_unread_message_num
- ########################################################################
- sub get_unread_message_num{
- my $self = shift;
-
- debug_print("MM::get_unread_message_num: start");
- my $af = $self->{af};
-
- my $sth;
- eval{
- $sth = $af->{db}->prepare(q{SELECT * FROM AFuser_CORE_message where readflag=0});
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- return("");
- }
-
- my $count=0;
- while(my @row = $sth->fetchrow_array){
- $count++;
- }
-
- debug_print("MM::get_unread_message_num: end");
- return($count);
- }
-
-
- ########################################################################
- #mark_as_read
- ########################################################################
- sub mark_as_read{
- my $self = shift;
- my $mid =shift;
-
- my $af = $self->{af};
-
- my $query = "update AFuser_CORE_message set readflag = 1 where mid = $mid";
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("MM::retrieve_all: end");
- return();
- }
-
-
- ########################################################################
- #retrieve_all_messages
- ########################################################################
- #sub SQL_result get_all_group_list
- # result (mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag)
- sub retrieve_all_messages{
- my $self = shift;
-
- debug_print("MM::retrieve_all: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all friend records from DB
- my $sth;
- eval{
- $sth = $af->{db}->prepare(q{SELECT * FROM AFuser_CORE_message order by timestamp desc});
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("MM::retrieve_all: end");
- return($sth);
- }
-
- ########################################################################
- #retrieve_message
- ########################################################################
- #sub SQL_result get_all_group_list
- # result (mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag)
- sub retrieve_message{
- my $self = shift;
- my $mid = shift;
-
- debug_print("MM::retrieve: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all friend records from DB
- my $sth;
- eval{
- $sth = $af->{db}->prepare("SELECT * FROM AFuser_CORE_message where mid = $mid");
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row = $sth->fetchrow_array;
-
- if(!@row){
- debug_print("MM::retrieve Error: No such group.");
- return;
- }
-
- debug_print("MM::retrieve: end");
- return(@row);
- }
-
- #######################################################################
- #post_message
- # arg1 SenderName: (app_name)
- # arg2 Title: (UTF-8)
- # arg3 Type: (Ascii)
- # arg4 Body: (free text including URL)
- #######################################################################
- sub post_message{
- my $self = shift;
- my $from = shift; #1
- my $title = shift; #2
- my $type = shift; #3
- my $body = shift; #4
-
- my $af = $self->{af};
-
- Affelio::misc::Debug::debug_print("MM::post_message: start.");
-
- #DB
- #mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag
-
- ##############################
- #Get existing max ID
- my $sth;
- eval{
- $sth = $af->{db}->prepare(q{SELECT max(mid) FROM AFuser_CORE_message});
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row = $sth->fetchrow_array;
- my $maxid = $row[0];
- if(defined($row[0])){
- $maxid = $row[0];
- }else{
- $maxid = 0;
- }
- my $newid = $maxid+1;
- Affelio::misc::Debug::debug_print("MM::post_message: newid = $newid");
-
- my $cur_time = Affelio::misc::Time::get_timestamp();
-
- Affelio::misc::Debug::debug_print("MM::post_message: Writing to DB...");
- Affelio::misc::Debug::debug_print("MM::post_message: [$body]");
-
- Affelio::misc::Debug::debug_print("size [" . length($body) ."]");
-
- ##############################
- #Insert a new record
- my $str10 = "insert into AFuser_CORE_message(msgbody, mid, timestamp, msgtitle, msgtype, msgfrom, readflag) values ('$body', $newid, '$cur_time', '$title', '$type', '$from', 0)";
- eval{
- $sth = $af->{db}->prepare($str10);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- undef($sth);
-
- ##############################
- #Email notification if needed
- if($af->{userpref__mesging__emailflg} eq "yes"){
- my $abs_URL = $af->{site__web_root} . "/admin.cgi?mode=messages&action=show&mid=$newid";
- Affelio::NetLib::Email::send_email($af, "Your Affelio <$af->{user__email1}>", $af->{user__email1}, "New message to your Affelio", $abs_URL);
- Affelio::misc::Debug::debug_print("MM::post_message: Email sent!");
- }
-
- Affelio::misc::Debug::debug_print("MM::post_message: end.");
- return("");
- }
-
-}#package
-1;
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/PermissionManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/PermissionManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/PermissionManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/PermissionManager.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/PermissionManager.pm Tue Oct 25 04:20:54 2005
@@ -1,285 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id: PermissionManager.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::Managing::PermissionManager;
-{
- use strict;
-
- use lib("../../../extlib");
- use DBI;
- use lib("../../");
- use Affelio;
- use Affelio::misc::CGIError;
- use Affelio::misc::Debug qw(debug_print);
- use Affelio::exception::DBException;
-
- ########################################################################
- #Constructor
- ########################################################################
- sub new{
- my $class = shift;
- my $af = shift;
-
- debug_print("PermissionManager::new: start.");
-
- my $self = {af => $af
- };
-
- bless $self, $class;
-
- debug_print("PermissionManager::new: end.");
- return $self;
- }
-
- ########################################################################
- #(1)add_permission
- ########################################################################
- sub add_permission{ #return int pid
- my $self = shift;
- my $type = shift; #arg(1) IN char* type
- my $id = shift; #arg(2) IN char* target_id
- my $flag_array_ref = shift; #arg(3) IN * flag_array_ref
-
- my @flag_array = @$flag_array_ref;
- my $flag_size = @flag_array;
-
- debug_print("add_permission type[$type] id[$id] size(flag)=$flag_size");
- my $af = $self->{af};
-
- #add more elements upto 63
- for(my $i=$flag_size; $i<=63; $i++){
- push(@flag_array, "-1");
- }
- $flag_size = @flag_array;
-
- debug_print("add_permission (increased) size(flag)=$flag_size");
-
- #Decide $newid
- my $query = 'SELECT max(pid) FROM AFuser_CORE_permission';
- my $sth;
- eval{
- $sth= $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @row = $sth->fetchrow_array;
- my $maxid = $row[0];
- if(defined($row[0])){
- $maxid = $row[0];
- }else{
- $maxid = 0;
- }
- my $newid = $maxid + 1;
-
- #generate an SQL query
- $query = "insert into AFuser_CORE_permission(pid, type, target_id";
- for(my $j=0; $j<=63; $j++){
- $query .= ", attr$j";
- }
- $query .= ") values (?,?,?";
- for(my $k=0; $k<=63; $k++){
- $query .= "," . $flag_array[$k];
- }
- $query .= ")";
- debug_print("add_permission q=[$query]");
-
- #DB access
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($newid, $type, $id);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("add_permission DB access done.");
-
- #Set new_id into Friend table or Group table
- if($type eq "f"){
- }
- if($type eq "p"){
- #Set this new pid into Friend table record.
- try{
- $af->{fm}->set_attribute_by_id($id, "option_pid", $newid);
- }catch Affelio::exception::DBException with {
- my $e = shift;
- throw $e;
- };
- }
- if($type eq "g"){
- #Set this new pid into Group table record.
- $af->{gm}->set_pid($id, $newid);
- }
-
- debug_print("add_permission end.");
- return($newid);
- }
-
-
- ########################################################################
- #(2)update_permission
- ########################################################################
- sub update_permission{ #void
- my $self = shift;
- my $pid = shift; #arg(1) IN int pid
- my $flag_array_ref = shift; #arg(2) IN * flag_array_ref
-
- my @flag_array = @$flag_array_ref;
-
- debug_print("update_permission pid[$pid]");
- my $af = $self->{af};
-
- #add more elements upto 63
- my $flag_size = @flag_array;
- for(my $i=$flag_size; $i<=63; $i++){
- push(@flag_array, "-1");
- }
-
- #prepare SQL query
- my $query = "update AFuser_CORE_permission set ";
- for(my $k=0; $k<=63; $k++){
- $query .= " attr$k = '" . $flag_array[$k] . "'," ;
- }
- chop($query);
- $query .= " where pid='$pid'";
- debug_print("update_permission q=[$query]");
-
- #access DB
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("PermissionManager::update_permission end.");
- }
-
- ########################################################################
- #(3)get_permission
- ########################################################################
- sub get_permission{ #return SQL_result
- my $self = shift;
- my $type = shift; #arg(1) IN char* type
- my $id = shift; #arg(2) IN char* target_id
-
- debug_print("get_permission type[$type] id[$id]");
- my $af = $self->{af};
-
- my $query = "SELECT * FROM AFuser_CORE_permission where type='$type' and target_id='$id'";
- debug_print("get_permission end: q=[$query]");
-
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("get_permission end.");
- return($sth);
- }
-
-
- ########################################################################
- #(4)get_permission_by_pid
- ########################################################################
- sub get_permission_by_pid{ #return SQL_result
- my $self = shift;
- my $pid = shift; #arg(1) IN int pid
-
- debug_print("get_permission_by_pid pid[$pid]");
- my $af = $self->{af};
-
- my $query = 'SELECT * FROM AFuser_CORE_permission WHERE pid = ?';
-
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($pid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("get_permission_by_pid end.");
- return($sth);
- }
-
- ########################################################################
- #(5)remove_permission_by_pid
- ########################################################################
- sub remove_permission_by_pid{
- my $self = shift;
- my $pid = shift; #arg(1) IN int pid
-
- debug_print("remove_permission_by_pid pid[$pid]");
- my $af = $self->{af};
-
- my $query = 'DELETE FROM AFuser_CORE_permission WHERE pid = ?';
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute($pid);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("remove_permission_by_pid end.");
- }
-
- ########################################################################
- #(6)get_all_permission
- #sub SQL_result get_all_permission
- #result (pid, type, target, a, b, c, d .....)
- ########################################################################
- sub get_all_permission{
- my $self = shift;
-
- debug_print("get_all_premission: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all permission records from DB
- my $query = 'SELECT * FROM AFuser_CORE_permission';
-
- my $sth;
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- debug_print("get_all_premission: end");
- return($sth);
- }
-
-
-}#package
-1;
-
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ProfileManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ProfileManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ProfileManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ProfileManager.pm:1.1.1.1 Tue Oct 25 04:14:40 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/ProfileManager.pm Tue Oct 25 04:20:54 2005
@@ -1,207 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-# $Id: ProfileManager.pm,v 1.1.1.1 2005/10/24 19:14:40 slash5234 Exp $
-
-package Affelio::Managing::ProfileManager;
-{
- use strict;
- use lib("../../../extlib");
- use DBI;
- use Jcode;
- use Error qw(:try);
- use lib("../../");
- use Affelio::misc::CGIError;
- use Affelio::misc::Debug qw(debug_print);
- use Affelio::exception::DBException;
-
- #######################################################################
- #Constructor
- #######################################################################
- sub new{
- my $class = shift;
- my $af = shift;
- my $mode = shift;
-
- debug_print("ProfileManager::new: start.");
-
- my $self = {af => $af,
- mode => $mode
- };
-
- bless $self, $class;
-
- #Load profile
- if($mode ne "init"){
- $self->load_profile();
- }
-
- debug_print("ProfileManager::new: end.");
- return $self;
- }
-
-
- #######################################################################
- #save_profile
- #######################################################################
- sub save_profile{
- my $self = shift;
- my $af = $self->{af};
-
- #Write down user__* variables
- foreach my $key (sort keys %$af){
- if($key =~ /user__/){
- my $key2 = $key;
- $key2 =~ s/user__//g;
- debug_print("ProfileManager::save_profile: $key2 = $af->{$key}");
- if($af->{$key} ne ""){
- try{
- save_profile_value($self, $key2, $af->{$key});
- }catch Affelio::exception::DBException with {
- my $e = shift;
- throw $e;
- };
- }
- }
- }
-
- return("");
- }
-
- sub save_profile_value{
- my $self = shift;
- my $af = $self->{af};
- my $attribute = shift;
- my $value = shift;
-
- debug_print("ProfileManager::save_profile_value: ($attribute) = ($value)");
-
- my $query = "SELECT * FROM AFuser_CORE_prof where attribute = '$attribute'";
- my $sth1;
- eval{
- $sth1 = $af->{db}->prepare($query);
- $sth1->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- my @result= $sth1->fetchrow_array();
- if(@result==()){
- my $query2 = 'insert into AFuser_CORE_prof(attribute, value) values (?,?)';
- my $sth2;
- eval{
- $sth2 = $af->{db}->prepare($query2);
- $sth2->execute($attribute, $value);
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
-
- }else{
- my $query3 = "update AFuser_CORE_prof set value = '$value' where attribute = '$attribute'";
-
- my $sth3;
- eval{
- $sth3 = $af->{db}->prepare($query3);
- $sth3->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- }
- }
- }
-
-
- #######################################################################
- #load_profile
- #######################################################################
- sub load_profile{
- my $self = shift;
- my $af = $self->{af};
-
- debug_print("ProfileManager::load_profile: start.");
-
- my $SQL_profattr;
-
- try{
- $SQL_profattr = load_profile_table($self);
- }catch Affelio::exception::DBException with {
- my $e = shift;
- throw $e;
- };
-
- my $attribute=""; my $value="";
- while( ($attribute, $value) = $SQL_profattr->fetchrow_array){
- $af->{"user__$attribute"} = $value;
- debug_print("ProfileManager::load_profile: user__$attribute = "
- . $af->{"user__$attribute"});
- }
-
- debug_print("ProfileManager::load_profile: end.");
- return("");
- }
-
- ########################################################################
- #load_profile_table
- # returns SQL_result (attribute, value) x records
- ########################################################################
- sub load_profile_table{
- my $self = shift;
- my $af = $self->{af};
-
- my $sth;
- my $query = 'SELECT * FROM AFuser_CORE_prof';
-
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute();
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- };
-
- return($sth);
- }
-
- ########################################################################
- #get_attribute_table
- # returns SQL_result (aid, name, type) x records
- ########################################################################
- sub get_attribute_table{
- my $self = shift;
- my $af = $self->{af};
-
- ##############################
- #retrieve all friend records from DB
- my $query = 'SELECT * FROM AFuser_CORE_prof_attr';
- my $sth;
-
- eval{
- $sth = $af->{db}->prepare($query);
- $sth->execute;
- };
- if($@){
- throw Affelio::exception::DBException($af->{db}->errstr);
- };
-
- return($sth);
- }
-
-
-
-}#package
-1;
Index: affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/WhatsNewManager.pm
diff -u affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/WhatsNewManager.pm:1.1.1.1 affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/WhatsNewManager.pm:removed
--- affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/WhatsNewManager.pm:1.1.1.1 Tue Oct 25 04:14:39 2005
+++ affelio_farm/admin/skelton/affelio/lib/Affelio/Managing/WhatsNewManager.pm Tue Oct 25 04:20:54 2005
@@ -1,127 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id: WhatsNewManager.pm,v 1.1.1.1 2005/10/24 19:14:39 slash5234 Exp $
-
-package Affelio::Managing::WhatsNewManager;
-{
- use strict;
- use lib("../../../extlib");
- use DBI;
- use Jcode;
- use lib("../../");
- use Affelio::misc::CGIError;
- use Affelio::misc::Time qw(get_timestamp);
- use Affelio::misc::Encoding qw(db_encode db_decode);
- use Affelio::misc::Debug qw(debug_print);
-
- #######################################################################
- #Constructor
- #######################################################################
- sub new{
- my $class = shift;
- my $af = shift;
-
- debug_print("WhatsNewManager::new: start.");
-
- my $self = {af => $af
- };
-
- bless $self, $class;
-
- debug_print("WhatsNewManager::new: end.");
- return $self;
- }
-
- #WhatsNewManager looks up each application directory
- #to get the whole list of message types.
-
- ########################################################################
- #retrieve_message
- ########################################################################
- #sub SQL_result get_all_group_list
- # result (mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag)
- sub retrieve_all_messages{
- my $self = shift;
-
- debug_print("MM::retrieve: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all friend records from DB
- my $sth = $af->{db}->prepare(q{SELECT * FROM AFuser_CORE_message}) or die $af->{db}->errstr;
- $sth->execute;
-
- debug_print("MM::retrieve: end");
- return($sth);
- }
-
- #######################################################################
- #post_message
- # arg1 SenderName: (app_name)
- # arg2 Title: (UTF-8)
- # arg3 Type: (Ascii)
- # arg4 Body: (free text including URL)
- #######################################################################
- sub post_message{
- my $self = shift;
- my $from = shift; #1
- my $title = shift; #2
- my $type = shift; #3
- my $body = shift; #4
-
- my $af = $self->{af};
-
- Affelio::misc::Debug::debug_print("MM::post_message: start.");
-
-# $body = Affelio::misc::Encoding::db_encode($body);
-# $title = Affelio::misc::Encoding::db_encode($title);
-# $from = Affelio::misc::Encoding::db_encode($from);
-
- #mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag
-
- ##############################
- #Get existing max ID
- my $sth = $af->{db}->prepare(q{SELECT max(mid) FROM AFuser_CORE_message}) or die $af->{db}->errstr;
- $sth->execute;
- my @row = $sth->fetchrow_array;
- my $maxid = $row[0];
- if(defined($row[0])){
- $maxid = $row[0];
- }else{
- $maxid = 0;
- }
- my $newid = $maxid+1;
- Affelio::misc::Debug::debug_print("MM::post_message: newid = $newid");
-
- my $cur_time = Affelio::misc::Time::get_timestamp();
-
- Affelio::misc::Debug::debug_print("MM::post_message: Writing to DB...");
- Affelio::misc::Debug::debug_print("MM::post_message: [$body]");
-
- ##############################
- #Insert a new record
- my $str1 = "insert into AFuser_CORE_message(mid, timestamp, msgtitle, msgtype, msgfrom, msgbody, readflag) values ($newid, '$cur_time', '$title', '$type', '$from', '$body', 0)";
- $sth = $af->{db}->prepare($str1) or die $af->{db}->errstr;
- $sth->execute or die $af->{db}->errstr;
-
- Affelio::misc::Debug::debug_print("MM::post_message: end.");
-
- return("");
- }
-
-}#package
-1;