went full blown with app assignments via ACL. Still need to do teh admin pages tho

This commit is contained in:
seek3r 2001-01-26 11:58:00 +00:00
parent 786bffc4c5
commit 14399c60c4
7 changed files with 288 additions and 381 deletions

View File

@ -39,7 +39,7 @@
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences(); $phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]); $this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
$apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"])); $apps = CreateObject('phpgwapi.applications',intval($phpgw_info["user"]["account_id"]));
$phpgw_info["user"]["apps"] = $apps->apps_enabled(); //$phpgw_info["user"]["apps"] = $apps->apps_enabled();
} }
// use this if you make any changes to phpgw_info, including preferences, config table changes, etc // use this if you make any changes to phpgw_info, including preferences, config table changes, etc
@ -73,23 +73,6 @@
. $phpgw_info["user"]["sessionid"] . "'",__LINE__,__FILE__); . $phpgw_info["user"]["sessionid"] . "'",__LINE__,__FILE__);
} }
function add_app($appname,$rebuild = False)
{
if (! $rebuild) {
if (gettype($appname) == "array") {
$t .= ":";
$t .= implode(":",$appname);
$this->temp_app_list .= $t;
} else {
$this->temp_app_list .= ":" . $appname;
}
} else {
$t = $this->temp_app_list . ":";
unset($this->temp_app_list);
return $t;
}
}
function sql_search($table,$owner=0) function sql_search($table,$owner=0)
{ {
global $phpgw_info; global $phpgw_info;

View File

@ -88,14 +88,17 @@
} }
function delete($app, $location, $id, $id_type){ function delete($app, $location, $id, $id_type){
$sql = "delete from phpgw_acl where acl_appname='".$app."'"; $sql = "delete from phpgw_acl where acl_appname like '".$app."'";
$sql .= " and acl_location ='".$location."' and "; $sql .= " and acl_location like '".$location."' and ";
$sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id; $sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id;
$this->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
return True; return True;
} }
function view($app, $location, $id, $id_type){ function replace($app, $location, $id, $id_type, $rights){
$this->delete($app, $location, $id, $id_type);
$this->add($app, $location, $id, $id_type, $rights);
return True;
} }
function get_app_list($location, $required){ function get_app_list($location, $required){
@ -129,7 +132,6 @@
return $apps; return $apps;
} }
function get_app_list_for_id($location, $required, $id_type = "", $id = ""){ function get_app_list_for_id($location, $required, $id_type = "", $id = ""){
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
if ($id == ""){ $id = $phpgw_info["user"]["account_id"]; } if ($id == ""){ $id = $phpgw_info["user"]["account_id"]; }
@ -163,40 +165,27 @@
return $apps; return $apps;
} }
function view_location_list($app, $required, $id_type = "both", $id = ""){ function get_location_list($app, $required){
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
if ($id == ""){$id = $phpgw_info["user"]["account_id"];}
$sql = "select acl_location, acl_rights from phpgw_acl where (acl_appname in ('$app','everywhere')) and ";
if ($id_type == "both" || $id_type == "u"){
// User piece // User piece
$sql .= "((acl_account_type = 'u' and acl_account = ".$id.")"; $sql = "select acl_location, acl_rights from phpgw_acl where acl_appname = '$app' ";
} $sql .= " and ((acl_account_type = 'u' and acl_account = '".$phpgw_info["user"]["account_id"]."')";
if ($id_type == "g"){
$sql .= "(acl_account_type='g' and acl_account in (0"; // group 0 covers all users
}elseif ($id_type == "both"){
$sql .= " or (acl_account_type='g' and acl_account in (0"; // group 0 covers all users
}
if ($id_type == "both" || $id_type == "g"){
// Group piece // Group piece
$sql .= " or (acl_account_type='g' and acl_account in (0"; // group 0 covers all users
$memberships = $phpgw->accounts->read_group_names(); $memberships = $phpgw->accounts->read_group_names();
if (is_array($memberships) && count($memberships) > 0){ if (is_array($memberships) && count($memberships) > 0){
for ($idx = 0; $idx < count($memberships); ++$idx){ for ($idx = 0; $idx < count($memberships); ++$idx){
$sql .= ",".$memberships[$idx][0]; $sql .= ",".$memberships[$idx][0];
} }
} }
}
if ($id_type == "both"){
$sql .= ")))"; $sql .= ")))";
}elseif ($id_type == "u"){
$sql .= ")";
}elseif ($id_type == "g"){
$sql .= "))";
}
$this->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
$rights = 0; $rights = 0;
if ($this->db->num_rows() == 0 ){ return False; } if ($this->db->num_rows() == 0 ){ return False; }
while ($this->db->next_record()) { while ($this->db->next_record()) {
if ($this->db->f("acl_location") == 0){ return False; } if ($this->db->f("acl_rights") == 0){ return False; }
$rights |= $this->db->f("acl_rights"); $rights |= $this->db->f("acl_rights");
if (!!($rights & $required) == True){ if (!!($rights & $required) == True){
$locations[] = $this->db->f("acl_location"); $locations[] = $this->db->f("acl_location");
@ -207,18 +196,38 @@
return $locations; return $locations;
} }
function remove_locations($location, $id_type = "u", $id = ""){ function get_location_list_for_id($app, $required, $id_type = "", $id = ""){
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
if ($id == ""){ $id = $phpgw_info["user"]["account_id"]; } if ($id == ""){ $id = $phpgw_info["user"]["account_id"]; }
$sql = "DELETE FROM phpgw_acl WHERE acl_location='".$location."' AND acl_account_type='".$id_type."' AND acl_account='".$id."'"; if ($id_type == ""){ $id_type = "u"; }
$this->db->query($sql ,__LINE__,__FILE__); $sql = "select acl_location, acl_rights from phpgw_acl where acl_appname = '$app' and ";
if ($id_type == "u"){
$sql .= "acl_account_type = 'u' and acl_account = ".$id;
}elseif($id_type == "g"){
$sql .= "acl_account_type='g' and acl_account in (0"; // group 0 covers all users
// Group piece
if (is_array($memberships) && count($memberships) > 0){
for ($idx = 0; $idx < count($memberships); ++$idx){
$sql .= ",".$memberships[$idx][0];
}
}
$sql .= ")";
} }
function remove_granted_rights($app, $location, $id="") {
global $phpgw, $phpgw_info;
if ($id == ""){$id = $phpgw_info["user"]["account_id"];}
$sql = "DELETE FROM phpgw_acl WHERE acl_appname='".$app."' AND acl_account_type = 'u' AND acl_location='".$location."' AND acl_account='".$id."'";
$this->db->query($sql ,__LINE__,__FILE__); $this->db->query($sql ,__LINE__,__FILE__);
$rights = 0;
if ($this->db->num_rows() == 0 ){ return False; }
while ($this->db->next_record()) {
if ($this->db->f("acl_rights") == 0){ return False; }
$rights |= $this->db->f("acl_rights");
if (!!($rights & $required) == True){
$locations[] = $this->db->f("acl_location");
}else{
return False;
} }
}
return $locations;
}
} //end of acl class } //end of acl class
?> ?>

View File

@ -25,58 +25,16 @@
class applications class applications
{ {
var $account_id; var $account_id;
var $enabled = Array();
var $status = Array();
var $user_apps = Array(); var $user_apps = Array();
var $group_apps = Array(Array()); var $group_apps = Array();
var $app_perms = Array(Array());
var $apps_loaded = False;
function applications($lid=0) function applications($var = ""){
{ if ($var != ""){
global $phpgw; $this->users_enabled_apps();
global $phpgw_info;
$db2 = $phpgw->db;
// $db3 = $phpgw->db;
if(($this->is_type($lid,"integer") && $lid == $phpgw_info["user"]["account_id"]) ||
($this->is_type($lid,"string") && $lid == $phpgw_info["user"]["user_id"])) {
$load_info = True;
}
if(!$this->apps_loaded) {
$this->apps_loaded = True;
$db2->lock(array("applications"));
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
$apps_enabled = False;
while ($db2->next_record()) {
if(!$apps_enabled) $apps_enabled = True;
$name = $db2->f("app_name");
if($load_info) {
$title = $db2->f("app_title");
$status = $db2->f("app_enabled");
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
}
$this->enabled[$name] = 1;
$this->status[$name] = $db2->f("app_status");
}
$db2->unlock();
}
if($apps_enabled && $lid) {
$owner_found = False;
if($this->is_type($lid,"integer")) {
$owner_id = $lid;
$owner_found = True;
} elseif($this->is_type($lid,"string")) {
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$lid."'",__LINE__,__FILE__);
if($db2->num_rows()) {
$db2->next_record();
$owner_id = $db2->f("account_id");
$owner_found = True;
} }
} }
if($owner_found) { function users_enabled_apps(){
$this->account_id = $owner_id; global $phpgw, $phpgw_info;
$acl_apps = $phpgw->acl->get_app_list('run', 1); $acl_apps = $phpgw->acl->get_app_list('run', 1);
if ($acl_apps != False){ if ($acl_apps != False){
reset ($acl_apps); reset ($acl_apps);
@ -84,276 +42,160 @@
$apps[] = $value; $apps[] = $value;
} }
} }
if(gettype($phpgw_info["apps"]) != "array") {
$this->read_installed_apps();
}
asort ($phpgw_info["apps"]);
if(count($apps)) { if(count($apps)) {
for ($i=0;$i<count($apps);$i++) { for ($i=0;$i<count($apps);$i++) {
if ($this->enabled[$apps[$i]] == 1) { if ($phpgw_info["apps"][$apps[$i]]["enabled"] == True) {
$this->enabled[$apps[$i]] = 2; $phpgw_info["user"]["apps"][$apps[$i]] = True;
$this->app_perms[] = $apps[$i];
}
}
}
// should be able to delete these two lines soon.
// This will breaks backward compatibility, so we need the setup upgrade script ready
$this->read_user_group_apps($this->account_id);
$this->read_user_apps($this->account_id);
if($load_info) {
$phpgw_info["user"]["apps"] = $this->apps_enabled();
} }
} }
} }
} }
function set_var($var,$value="",$index="") function read_installed_apps(){
{
if($index == "") {
$this->$var = $value;
} else {
$this->$var[$index] = $value;
}
}
function get_var($var,$index="")
{
if($index == "") {
if($this->$var) {
return $this->$var;
}
} elseif($this->$var[$index]) {
return $this->$var[$index];
}
return False;
}
function apps_enabled()
{
while ($sa = each($this->enabled)) {
if ($sa[1] == 2) {
$return_apps[$sa[0]] = True;
}
}
return $return_apps;
}
function is_type($variable,$type)
{
return (strtoupper(gettype($variable)) == strtoupper($type));
}
function read_user_apps($lid)
{
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
$phpgw->db->lock(array("applications"));
$db2 = $phpgw->db; $phpgw->db->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
if ($this->is_type($lid,"string")) { while ($phpgw->db->next_record()) {
$db2->query("select account_id from accounts where account_lid='$lid'",__LINE__,__FILE__); $name = $phpgw->db->f("app_name");
if($db2->num_rows()) { $title = $phpgw->db->f("app_title");
$db2->next_record(); $status = $phpgw->db->f("app_enabled");
$account_id = $db2->f("account_id"); $phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
} else {
return False;
} }
} elseif ($this->is_type($lid,"integer")) { }
$account_id = $lid; $phpgw->db->unlock();
} else {
return False;
} }
$acl_apps = $phpgw->acl->get_app_list_for_id('run', 1, 'u'); function read_user_apps($lid ="") {
global $phpgw, $phpgw_info;
if ($lid == ""){$lid = $phpgw_info["user"]["account_id"];}
$owner_found = False;
if(gettype($lid) == "string" && $lid == $phpgw_info["user"]["user_id"]) {
$owner_id = $phpgw_info["user"]["account_id"];
$owner_found = True;
}
if($owner_found == False && gettype($lid) == "integer") {
$owner_id = $lid;
$owner_found = True;
} elseif($owner_found == False && gettype($lid) == "string") {
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='".$lid."'",__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
$phpgw->db->next_record();
$owner_id = $phpgw->db->f("account_id");
$owner_found = True;
}
}
if($owner_found) {
$acl_apps = $phpgw->acl->get_app_list_for_id('run', 1, 'u', $lid);
if ($acl_apps != False){ if ($acl_apps != False){
reset ($acl_apps); reset ($acl_apps);
while (list(,$value) = each($acl_apps)){ while (list(,$value) = each($acl_apps)){
$apps[] = $value; $apps[] = $value;
} }
} else {
$db2->query("select account_permissions from accounts where account_id=$account_id",__LINE__,__FILE__);
$db2->next_record();
$apps_perms = explode(":",$db2->f("account_permissions"));
for($i=1;$i<count($apps_perms)-1;$i++) {
$apps[] = $apps_perms[$i];
} }
if(gettype($phpgw_info["apps"]) != "array") {
$this->read_installed_apps();
} }
if(count($apps)) { if(count($apps)) {
//if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Account Permissions - ".$db2->f("aaccount_permissions")." -->\n";
for ($i=0; $i<count($apps); $i++) { for ($i=0; $i<count($apps); $i++) {
//if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Reading user app - ".$apps[$i]." -->\n"; if ($phpgw_info["apps"][$apps[$i]]["enabled"] == True) {
if ($this->enabled[$apps[$i]] == 1) { $this->user_apps[$owner_id][] = $apps[$i];
$this->user_apps[$apps[$i]] = $apps[$i];
$this->enabled[$apps[$i]] = 2;
$this->app_perms[] = $apps[$i];
} }
} }
} }
return $this->user_apps[$owner_id];
} }
function read_user_group_apps($lid)
{
global $phpgw;
$db2 = $phpgw->db;
if ($this->is_type($lid,"string")) {
$db2->query("select account_id from accounts where account_lid='$lid'",__LINE__,__FILE__);
if($db2->num_rows()) {
$db2->next_record();
$account_id = $db2->f("account_id");
} else {
return False;
}
} elseif ($this->is_type($lid,"integer")) {
$account_id = $lid;
} else {
return False; return False;
} }
$groups = $phpgw->accounts->read_groups($account_id); function read_group_apps($group_id) {
global $phpgw, $phpgw_info;
if($groups) { if(gettype($group_id) == "integer") {
while ($group = each($groups)) { $group_found = True;
$this->read_group_apps($group[0]); } elseif(gettype($group_id) == "string") {
} $phpgw->db->query("SELECT group_id FROM groups WHERE group_name='".$group_id."'",__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
$phpgw->db->next_record();
$group_id = $phpgw->db->f("group_id");
$group_found = True;
} }
} }
function read_group_apps($group_id) if($group_found) {
{
global $phpgw;
$db2 = $phpgw->db;
$acl_apps = $phpgw->acl->get_app_list_for_id('run', 1, 'g', $group_id); $acl_apps = $phpgw->acl->get_app_list_for_id('run', 1, 'g', $group_id);
if ($acl_apps != False){ if ($acl_apps != False){
reset ($acl_apps); reset ($acl_apps);
while (list(,$value) = each($acl_apps)){ while (list(,$value) = each($acl_apps)){
$apps[] = $value; $apps[] = $value;
} }
} else {
$db2->query("select group_apps from groups where group_id=".$group_id,__LINE__,__FILE__);
$db2->next_record();
$apps_perms = explode(":",$db2->f("group_apps"));
for($i=1;$i<count($apps_perms)-1;$i++) {
$apps[] = $apps_perms[$i];
} }
if(gettype($phpgw_info["apps"]) != "array") {
$this->read_installed_apps();
} }
if(count($apps)) { if(count($apps)) {
for ($i=0;$i<count($apps);$i++) { for ($i=0;$i<count($apps);$i++) {
if ($this->enabled[$apps[$i]] == 1) { if ($phpgw_info["apps"][$apps[$i]]["enabled"] == True) {
$this->group_apps[$group_id][$apps[$i]] = $apps[$i]; $this->group_apps[$group_id][] = $apps[$i];
$this->enabled[$apps[$i]] = 2;
$this->app_perms[] = $apps[$i];
} }
} }
} }
}
function is_system_enabled($appname)
{
return $this->enabled[$appname] >= 1;
}
function is_user_enabled($appname)
{
return $this->enabled[$appname] == 2;
}
function get_group_array($group_id)
{
return $this->group_apps[$group_id]; return $this->group_apps[$group_id];
} }
return False;
function group_app_string($group_id)
{
reset($this->group_apps[$group_id]);
while($app = each($this->group_apps[$group_id])) {
$group_apps[] = $app[1];
}
return ":".implode(":",$group_apps).":";
} }
function user_app_string() function is_system_enabled($appname){
{ if(gettype($phpgw_info["apps"]) != "array") {
reset($this->user_apps); $this->read_installed_apps();
while($app = each($this->user_apps)) { }
$user_apps[] = $app[1]; if ($phpgw_info["apps"][$appname]["enabled"] == True) {
return True;
}else{
return False;
} }
return ":".implode(":",$user_apps).":";
} }
function is_group($group_id,$appname) function add_group_app($apps, $group_id) {
{ if(gettype($appname) == "array") {
return $this->group_apps[$group_id][$appname];
}
function is_user($appname)
{
return $this->user_apps[$appname];
}
function add_group($group_id,$appname)
{
if($this->is_type($appname,"array")) {
while($app = each($appname)) { while($app = each($appname)) {
$this->add_group_app($group_id,$app[0]); $this->group_apps[$group_id][] = $app[0];
} }
return $this->group_app_string($group_id); } elseif(gettype($appname) == "string") {
} elseif($this->is_type($appname,"string")) {
$this->add_group_app($group_id,$appname);
return $this->group_app_string($group_id);
}
}
function add_group_app($group_id,$appname)
{
if ($this->enabled[$appname] && !$this->is_group($group_id,$appname)) {
$this->group_apps[$group_id][] = $appname; $this->group_apps[$group_id][] = $appname;
$this->enabled[$appname] = 2;
} }
} }
function add_user($appname) function add_user_app($appname, $user_id = "") {
{ global $phpgw, $phpgw_info;
if($this->is_type($appname,"array")) { if ($user_id == ""){$user_id = $phpgw_info["user"]["account_id"];}
if(gettype($appname) == "array") {
while($app = each($appname)) { while($app = each($appname)) {
$this->add_user_app($app[0]); $this->user_apps[$user_id][] = $app[0];
} }
return $this->user_app_string($group_id); } elseif(gettype($appname) == "string") {
} elseif($this->is_type($appname,"string")) { $this->user_apps[$user_id][] = $appname;
$this->add_user_app($group_id,$appname);
return $this->user_app_string($group_id);
} }
} }
function add_user_app($appname) function delete_group_app($appname, $group_id) {
{
if ($this->enabled[$appname] && !$this->is_user($appname)) {
$this->user_apps[] =$appname;
$this->enabled[$appname] = 2;
}
}
function delete_group($group_id,$appname)
{
if($this->is_group($group_id,$appname)) {
unset($this->group_apps[$group_id][$appname]); unset($this->group_apps[$group_id][$appname]);
} }
function delete_user_app($appname, $user_id = ""){
global $phpgw, $phpgw_info;
if ($user_id == ""){$user_id = $phpgw_info["user"]["account_id"];}
unset($this->group_apps[$user_id][$appname]);
} }
function delete_user($appname) function save_group_apps($group_id){
{ global $phpgw, $phpgw_info;
if($this->is_user($appname)) {
unset($this->user_apps[$appname]);
}
}
function save_group($group_id)
{
global $phpgw;
if($group_id) { if($group_id) {
$db2 = $phpgw->db; $phpgw->acl->delete("%", "run", "g", $group_id);
$db2->query("UPDATE groups SET group_apps='".$this->group_app_string($group_id)."' WHERE group_id=".$group_id,__LINE__,__FILE__);
$phpgw->acl->remove_locations("run", "g", $group_id);
reset($this->group_apps[$group_id]); reset($this->group_apps[$group_id]);
while($app = each($this->group_apps[$group_id])) { while($app = each($this->group_apps[$group_id])) {
$phpgw->acl->add($app[1],'run',$group_id,'g',1); $phpgw->acl->add($app[1],'run',$group_id,'g',1);
@ -361,17 +203,14 @@
} }
} }
function save_user() function save_user_apps($user_id = ""){
{ global $phpgw, $phpgw_info;
global $phpgw; if ($user_id == ""){$user_id = $phpgw_info["user"]["account_id"];}
if($user_id) {
if($this->account_id) { $phpgw->acl->delete("%", "run", "u", $user_id);
$db2 = $phpgw->db;
$db2->query("UPDATE accounts SET account_permissions = '".$this->user_app_string()."' WHERE account_id=".$this->account_id,__LINE__,__FILE__);
$phpgw->acl->remove_locations("run");
reset($this->user_apps); reset($this->user_apps);
while($app = each($this->user_apps)) { while($app = each($this->user_apps[$user_id])) {
$phpgw->acl->add($app[1],'run',$this->account_id,'u',1); $phpgw->acl->add($app[1],'run',$user_id,'u',1);
} }
} }
} }

View File

@ -600,8 +600,9 @@
$completed_hooks[$appname] = True; $completed_hooks[$appname] = True;
} }
/* Then add the rest */ /* Then add the rest */
reset ($phpgw_info["user"]["app_perms"]); reset ($phpgw_info["user"]["apps"]);
while (list (, $appname) = each ($phpgw_info["user"]["app_perms"])){ asort ($phpgw_info["user"]["apps"]);
while (list (, $appname) = each ($phpgw_info["user"]["apps"])){
if (gettype($appname) != "array" && $appname != "" && $completed_hooks[$appname] != True){ if (gettype($appname) != "array" && $appname != "" && $completed_hooks[$appname] != True){
$f = $phpgw_info["server"]["server_root"] . "/" . $appname . "/inc/hook_".$phpgw_info["flags"]["currentapp"]; $f = $phpgw_info["server"]["server_root"] . "/" . $appname . "/inc/hook_".$phpgw_info["flags"]["currentapp"];
if ($location != ""){$f .= "_".$location.".inc.php";}else{$f .= ".inc.php"; } if ($location != ""){$f .= "_".$location.".inc.php";}else{$f .= ".inc.php"; }

View File

@ -794,6 +794,43 @@
$phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.9"; $phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.9";
} }
$test[] = "0.9.9";
function upgrade0_9_9(){
global $phpgw_info, $phpgw_setup;
$db2 = $phpgw_setup->db;
//convert user settings
$phpgw_setup->db->query("select account_id, account_permissions from accounts",__LINE__,__FILE__);
if($phpgw_setup->db->num_rows()) {
while($phpgw_setup->db->next_record()) {
$apps_perms = explode(":",$phpgw_setup->db->f("account_permissions"));
for($i=1;$i<count($apps_perms)-1;$i++) {
if ($apps_perms[$i] != ""){
$sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
$sql .= " values('".$apps_perms[$i]."', 'run', ".$phpgw_setup->db->f("account_id").", 'u', 1)";
$db2->query($sql ,__LINE__,__FILE__);
}
}
}
}
$phpgw_setup->db->query("update accounts set account_permissions = ''",__LINE__,__FILE__);
//convert group settings
$phpgw_setup->db->query("select group_id, group_apps from groups",__LINE__,__FILE__);
if($phpgw_setup->db->num_rows()) {
while($phpgw_setup->db->next_record()) {
$apps_perms = explode(":",$phpgw_setup->db->f("group_apps"));
for($i=1;$i<count($apps_perms)-1;$i++) {
if ($apps_perms[$i] != ""){
$sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
$sql .= " values('".$apps_perms[$i]."', 'run', ".$phpgw_setup->db->f("group_id").", 'g', 1)";
$db2->query($sql ,__LINE__,__FILE__);
}
}
}
}
$phpgw_setup->db->query("update groups set group_apps = ''",__LINE__,__FILE__);
$phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.10pre1";
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -819,6 +819,44 @@
$phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.9"; $phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.9";
} }
$test[] = "0.9.9";
function upgrade0_9_9(){
global $phpgw_info, $phpgw_setup;
$db2 = $phpgw_setup->db;
//convert user settings
$phpgw_setup->db->query("select account_id, account_permissions from accounts",__LINE__,__FILE__);
if($phpgw_setup->db->num_rows()) {
while($phpgw_setup->db->next_record()) {
$apps_perms = explode(":",$phpgw_setup->db->f("account_permissions"));
for($i=1;$i<count($apps_perms)-1;$i++) {
if ($apps_perms[$i] != ""){
$sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
$sql .= " values('".$apps_perms[$i]."', 'run', ".$phpgw_setup->db->f("account_id").", 'u', 1)";
$db2->query($sql ,__LINE__,__FILE__);
}
}
}
}
$phpgw_setup->db->query("update accounts set account_permissions = ''",__LINE__,__FILE__);
//convert group settings
$phpgw_setup->db->query("select group_id, group_apps from groups",__LINE__,__FILE__);
if($phpgw_setup->db->num_rows()) {
while($phpgw_setup->db->next_record()) {
$apps_perms = explode(":",$phpgw_setup->db->f("group_apps"));
for($i=1;$i<count($apps_perms)-1;$i++) {
if ($apps_perms[$i] != ""){
$sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
$sql .= " values('".$apps_perms[$i]."', 'run', ".$phpgw_setup->db->f("group_id").", 'g', 1)";
$db2->query($sql ,__LINE__,__FILE__);
}
}
}
}
$phpgw_setup->db->query("update groups set group_apps = ''",__LINE__,__FILE__);
$phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.10pre1";
}
reset ($test); reset ($test);
while (list ($key, $value) = each ($test)){ while (list ($key, $value) = each ($test)){
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {

View File

@ -11,5 +11,5 @@
/* $Id$ */ /* $Id$ */
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.9"; $phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre1";
$phpgw_info["server"]["versions"]["current_header"] = "1.10"; $phpgw_info["server"]["versions"]["current_header"] = "1.10";