Tadashi Okoshi
slash****@users*****
2005年 11月 20日 (日) 21:19:52 JST
Index: affelio/lib/Affelio/Managing/ApplicationManager.pm
diff -u affelio/lib/Affelio/Managing/ApplicationManager.pm:1.10 affelio/lib/Affelio/Managing/ApplicationManager.pm:1.11
--- affelio/lib/Affelio/Managing/ApplicationManager.pm:1.10 Tue Nov 8 14:16:29 2005
+++ affelio/lib/Affelio/Managing/ApplicationManager.pm Sun Nov 20 21:19:52 2005
@@ -14,7 +14,7 @@
# 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.10 2005/11/08 05:16:29 slash5234 Exp $
+# $Id: ApplicationManager.pm,v 1.11 2005/11/20 12:19:52 slash5234 Exp $
package Affelio::Managing::ApplicationManager;
{
@@ -43,12 +43,145 @@
bless $self, $class;
+ #########################
+ #Load applications
load_applications($self);
debug_print("ApplicationManager::new: end.");
return $self;
}
+ ######################################################################
+ #install_app
+ ######################################################################
+ sub install_app{
+ my $self = shift;
+ my $af = $self->{af};
+ my $install_name = shift;
+ my $install_title = shift;
+
+ #############################
+ #Read .cfg file
+ #############################
+ my $cfg = Config::Tiny->new();
+ $cfg = Config::Tiny->read("$af->{top_dir}/apps/$install_name/AF_app.cfg");
+ if(!$cfg){
+ throw Affelio::exception::("Could not open /apps/$install_name/AF_app.cfg");
+ }
+
+ #############################
+ #prep data
+ #############################
+ #install_name
+ #install_title
+ my $app_URI = $cfg->{application}->{app_URI};
+ my $app_name = $cfg->{application}->{app_name};
+ my $app_version = $cfg->{application}->{app_version};
+ my $app_desc = $cfg->{application}->{app_desc};
+ my $app_author = $cfg->{application}->{app_author};
+ my $guest_index = $cfg->{application}->{guest_index};
+ my $owner_index = $cfg->{application}->{owner_index};
+ my $action_types = $cfg->{application}->{action_types};
+ my $action_types_desc = $cfg->{application}->{action_types_desc};
+
+ #############################
+ #DB access
+ #############################
+ my $query = "insert into AFuser_CORE_apps(install_name, install_title, app_URI, app_name, app_version, app_desc, app_author, guest_index, owner_index, action_types, action_types_desc) values (?,?,?,?,?,?,?,?,?,?,?)";
+
+ my $sth;
+ eval{
+ $sth = $af->getDB->prepare($query);
+ $sth->execute($install_name, $install_title,
+ $app_URI, $app_name, $app_version,
+ $app_desc, $app_author,
+ $guest_index, $owner_index,
+ $action_types, $action_types_desc);
+ };
+ if($@){
+ throw Affelio::exception::DBException($af->getDB->errstr);
+ }
+
+ #############################
+ #prep app_perm_table
+ #############################
+ $af->getAM->prepare_app_perm_table($install_name);
+ }
+
+
+ ######################################################################
+ #load_applications
+ ######################################################################
+ sub load_applications{
+ my $self = shift;
+ my $af = $self->{af};
+
+ ##############################
+ #Access apps DB
+ ##############################
+ my $query = "select appid, install_name, install_title, app_URI, app_name, app_version, app_desc, app_author, guest_index, owner_index, action_types, action_types_desc FROM AFuser_CORE_apps";
+ my $sth;
+ eval{
+ $sth = $af->getDB->prepare($query);
+ $sth->execute;
+ };
+ if($@){
+ throw Affelio::exception::DBException($af->getDB->errstr);
+ }
+
+ ##################################
+ #For each application in DB...
+ ##################################
+ my @row = ();
+ while(my ($t_appid, $t_inst_name, $t_inst_title, $t_app_URI,
+ $t_app_name, $t_app_version, $t_app_desc, $t_app_author,
+ $t_guest_index, $t_owner_index,
+ $t_action_types, $t_action_types_desc)
+ = $sth->fetchrow_array){
+
+ ##################################
+ #Add two default actions
+ ##################################
+ my @this_app_action_types =();
+ @this_app_action_types =split(',\s', $t_action_types);
+ unshift(@this_app_action_types, "DF_access");
+ unshift(@this_app_action_types, "DF_visibility");
+
+ my @this_app_action_types_desc =();
+ @this_app_action_types_desc =split(',', $t_action_types_desc);
+ unshift(@this_app_action_types_desc, '<AF_M text="DF_access">');
+ unshift(@this_app_action_types_desc, '<AF_M text="DF_visibility">');
+
+ ##################################
+ #Store into Affelio's hash
+ ##################################
+ $self->{apps}->{$t_inst_name}
+ = {'app_id' => $t_appid,
+ 'app_URI' => $t_app_URI,
+ 'app_name' => $t_app_name,
+ 'app_desc' => $t_app_desc,
+ 'app_version' => $t_app_version,
+ 'app_author' => $t_app_author,
+ 'guest_index' => $t_guest_index,
+ 'owner_index' => $t_owner_index,
+ #
+ 'action_types' => \@this_app_action_types,
+ 'action_types_desc' => \@this_app_action_types_desc,
+ #
+ 'install_name' => $t_inst_name,
+ 'install_title' => $t_inst_title
+ };
+
+ debug_print("ApplicationManager::load:");
+ debug_print("\tapp_id=$self->{apps}->{$t_inst_name}->{app_id}\n");
+ debug_print("\tapp_URI=$self->{apps}->{$t_inst_name}->{app_URI}\n");
+ debug_print("\tapp_name=$self->{apps}->{$t_inst_name}->{app_name}\n");
+ debug_print("\tapp_version=$self->{apps}->{$t_inst_name}->{app_version}\n");
+ debug_print("\tinst_name=$self->{apps}->{$t_inst_name}->{install_name}\n");
+ debug_print("\tinst_title=$self->{apps}->{$t_inst_name}->{install_title}\n");
+ }#while
+ }
+
########################################################################
#get_permission
@@ -79,8 +212,6 @@
return($sth);
}
-
-
#####################################################################
#get_summed_app_perm
#####################################################################
@@ -352,11 +483,10 @@
#debug_print("AppManager::update_permission end.");
}
-
######################################################################
- #load_applications
+ #xxx
######################################################################
- sub load_applications{
+ sub xxx{
my $self = shift;
my $af = $self->{af};
@@ -451,11 +581,5 @@
}#while
}
-
-
-
-
-
-
}
1;