Tadashi Okoshi
slash****@users*****
2005年 11月 8日 (火) 14:16:29 JST
Index: affelio/lib/Affelio/Managing/ApplicationManager.pm
diff -u affelio/lib/Affelio/Managing/ApplicationManager.pm:1.9 affelio/lib/Affelio/Managing/ApplicationManager.pm:1.10
--- affelio/lib/Affelio/Managing/ApplicationManager.pm:1.9 Thu Oct 27 20:15:01 2005
+++ affelio/lib/Affelio/Managing/ApplicationManager.pm Tue Nov 8 14:16:29 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.9 2005/10/27 11:15:01 slash5234 Exp $
+# $Id: ApplicationManager.pm,v 1.10 2005/11/08 05:16:29 slash5234 Exp $
package Affelio::Managing::ApplicationManager;
{
@@ -49,6 +49,38 @@
return $self;
}
+
+ ########################################################################
+ #get_permission
+ ########################################################################
+ sub get_permission{ #return SQL_result
+ my $self = shift;
+ my $af = $self->{af};
+ my $type = shift; #arg(1) IN char* type
+ my $id = shift; #arg(2) IN char* target_id
+ my $app_name =shift; #arg(3) application install_name
+
+ debug_print("AppMan::get_permission type[$type] id[$id]");
+
+ my $query = "select * FROM AFuser_" . $app_name
+ ."_permission where type = '$type' and target_id = '$id'";
+ debug_print("AppMan::get_permission end: q=[$query]");
+
+ my $sth;
+ eval{
+ $sth = $af->getDB->prepare($query);
+ $sth->execute;
+ };
+ if($@){
+ throw Affelio::exception::DBException($af->getDB->errstr);
+ }
+
+ debug_print("AppMan::get_permission end.");
+ return($sth);
+ }
+
+
+
#####################################################################
#get_summed_app_perm
#####################################################################
@@ -155,7 +187,7 @@
my $self = shift;
my $app_name = shift; #arg(1) app install_name
- debug_print("get_all_premission: start");
+ debug_print("AppMan::get_all_premission: start");
my $af = $self->{af};
##############################
@@ -170,7 +202,7 @@
throw Affelio::exception::DBException($af->getDB()->errstr);
}
- debug_print("get_all_premission: end");
+ debug_print("AppMan::get_all_premission: end");
return($sth);
}
@@ -195,8 +227,8 @@
#############################################
#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 $create_table_SQL="CREATE TABLE $my_table_name (pid INTEGER, type TEXT, target_id TEXT, ";
+ my $new_rec_SQL="insert into $my_table_name(pid, type, target_id,";
my $num_action_types
= @{ $self->{apps}->{$caller}->{action_types} };
@@ -232,8 +264,9 @@
my $CORE_perm_tbl = $af->getPERM->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++){
+ my $SQL = $new_rec_SQL . " values ('$pid','$type','$target',";
+ $SQL .= "1,1,";
+ for($i=2; $i < $num_action_types; $i++){
$SQL .= "0,";
}
chop($SQL);
@@ -259,15 +292,52 @@
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]");
+ my $app_name = shift; #arg(1)
+ my $gid = shift; #arg(2)
+ my $pid = shift; #arg(3)
+ my $hash_ref= shift; #arg(4)
+
+ ############################
+ #check permission existence
+ ############################
+ my $query = 'SELECT count(*) FROM AFuser_'
+ . $app_name . '_permission where pid =' . $pid;
+ my $sth;
+ eval{
+ $sth = $af->getDB->prepare($query);
+ $sth->execute();
+ };
+ if($@){
+ throw Affelio::exception::DBException($af->getDB->errstr);
+ }
+ my @row = $sth->fetchrow_array;
+ my $retval= $row[0];
+
+ ############################
+ #INSERT or UPDATE?
+ ############################
+ if($retval == 0){
+ debug_print("AppManager::update_permission record does not exist");
+ debug_print("AppManager::update_permission We will make it.");
+ $query = "insert into AFuser_" . $app_name . "_permission(";
+ my $total_col="pid, type, target_id,";
+ my $total_val="$pid, 'g', $gid,";
+ while (my ($action_type, $value) = each(%{$hash_ref}) ) {
+ $total_col .= "$action_type,";
+ $total_val .= "$value,";
+ }
+ chop($total_col);
+ chop($total_val);
+ $query = $query . $total_col . ") values (" . $total_val . ")";
+ }else{
+ $query = "update AFuser_" . $app_name . "_permission set ";
+ while (my ($action_type, $value) = each(%{$hash_ref}) ) {
+ $query .= "$action_type=$value,";
+ }
+ chop($query);
+ $query .= " where pid=$pid";
+ }
+ debug_print("AppManager::update_permission q=[$query]");
#access DB
my $sth;
@@ -333,9 +403,14 @@
}
my @this_app_action_types =();
- my @this_app_action_types_desc =();
@this_app_action_types =split(',\s', $this_app{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(',', $this_app{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">');
##################################
#Read installation-specific parameters
Index: affelio/lib/Affelio/Managing/GroupManager.pm
diff -u affelio/lib/Affelio/Managing/GroupManager.pm:1.7 affelio/lib/Affelio/Managing/GroupManager.pm:1.8
--- affelio/lib/Affelio/Managing/GroupManager.pm:1.7 Thu Oct 27 20:15:01 2005
+++ affelio/lib/Affelio/Managing/GroupManager.pm Tue Nov 8 14:16:29 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: GroupManager.pm,v 1.7 2005/10/27 11:15:01 slash5234 Exp $
+# $Id: GroupManager.pm,v 1.8 2005/11/08 05:16:29 slash5234 Exp $
package Affelio::Managing::GroupManager;
{
@@ -53,7 +53,7 @@
my $self = shift;
my $group_name = shift; #arg(1) group_name (string)
- debug_print("add_group: $group_name");
+ debug_print("add_group: [$group_name]");
my $af = $self->{af};