mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-09 15:38:27 +01:00
went full blown with app assignments via ACL. Still need to do teh admin pages tho
This commit is contained in:
parent
786bffc4c5
commit
14399c60c4
@ -39,7 +39,7 @@
|
||||
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
|
||||
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
|
||||
$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
|
||||
@ -73,23 +73,6 @@
|
||||
. $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)
|
||||
{
|
||||
global $phpgw_info;
|
||||
|
@ -88,14 +88,17 @@
|
||||
}
|
||||
|
||||
function delete($app, $location, $id, $id_type){
|
||||
$sql = "delete from phpgw_acl where acl_appname='".$app."'";
|
||||
$sql .= " and acl_location ='".$location."' and ";
|
||||
$sql = "delete from phpgw_acl where acl_appname like '".$app."'";
|
||||
$sql .= " and acl_location like '".$location."' and ";
|
||||
$sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id;
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
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){
|
||||
@ -129,7 +132,6 @@
|
||||
return $apps;
|
||||
}
|
||||
|
||||
|
||||
function get_app_list_for_id($location, $required, $id_type = "", $id = ""){
|
||||
global $phpgw, $phpgw_info;
|
||||
if ($id == ""){ $id = $phpgw_info["user"]["account_id"]; }
|
||||
@ -163,40 +165,27 @@
|
||||
return $apps;
|
||||
}
|
||||
|
||||
function view_location_list($app, $required, $id_type = "both", $id = ""){
|
||||
function get_location_list($app, $required){
|
||||
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
|
||||
$sql .= "((acl_account_type = 'u' and acl_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"){
|
||||
$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"]."')";
|
||||
|
||||
// Group piece
|
||||
$sql .= " or (acl_account_type='g' and acl_account in (0"; // group 0 covers all users
|
||||
$memberships = $phpgw->accounts->read_group_names();
|
||||
if (is_array($memberships) && count($memberships) > 0){
|
||||
for ($idx = 0; $idx < count($memberships); ++$idx){
|
||||
$sql .= ",".$memberships[$idx][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($id_type == "both"){
|
||||
$sql .= ")))";
|
||||
}elseif ($id_type == "u"){
|
||||
$sql .= ")";
|
||||
}elseif ($id_type == "g"){
|
||||
$sql .= "))";
|
||||
}
|
||||
|
||||
$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_location") == 0){ return False; }
|
||||
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");
|
||||
@ -207,18 +196,38 @@
|
||||
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;
|
||||
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."'";
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
if ($id_type == ""){ $id_type = "u"; }
|
||||
$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__);
|
||||
$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
|
||||
?>
|
||||
|
@ -25,58 +25,16 @@
|
||||
class applications
|
||||
{
|
||||
var $account_id;
|
||||
var $enabled = Array();
|
||||
var $status = Array();
|
||||
var $user_apps = Array();
|
||||
var $group_apps = Array(Array());
|
||||
var $app_perms = Array(Array());
|
||||
var $apps_loaded = False;
|
||||
var $group_apps = Array();
|
||||
|
||||
function applications($lid=0)
|
||||
{
|
||||
global $phpgw;
|
||||
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;
|
||||
function applications($var = ""){
|
||||
if ($var != ""){
|
||||
$this->users_enabled_apps();
|
||||
}
|
||||
}
|
||||
if($owner_found) {
|
||||
$this->account_id = $owner_id;
|
||||
|
||||
function users_enabled_apps(){
|
||||
global $phpgw, $phpgw_info;
|
||||
$acl_apps = $phpgw->acl->get_app_list('run', 1);
|
||||
if ($acl_apps != False){
|
||||
reset ($acl_apps);
|
||||
@ -84,276 +42,160 @@
|
||||
$apps[] = $value;
|
||||
}
|
||||
}
|
||||
if(gettype($phpgw_info["apps"]) != "array") {
|
||||
$this->read_installed_apps();
|
||||
}
|
||||
asort ($phpgw_info["apps"]);
|
||||
if(count($apps)) {
|
||||
for ($i=0;$i<count($apps);$i++) {
|
||||
if ($this->enabled[$apps[$i]] == 1) {
|
||||
$this->enabled[$apps[$i]] = 2;
|
||||
$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();
|
||||
if ($phpgw_info["apps"][$apps[$i]]["enabled"] == True) {
|
||||
$phpgw_info["user"]["apps"][$apps[$i]] = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function set_var($var,$value="",$index="")
|
||||
{
|
||||
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)
|
||||
{
|
||||
function read_installed_apps(){
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
$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;
|
||||
$phpgw->db->lock(array("applications"));
|
||||
$phpgw->db->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
|
||||
if($phpgw->db->num_rows()) {
|
||||
while ($phpgw->db->next_record()) {
|
||||
$name = $phpgw->db->f("app_name");
|
||||
$title = $phpgw->db->f("app_title");
|
||||
$status = $phpgw->db->f("app_enabled");
|
||||
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
|
||||
}
|
||||
} elseif ($this->is_type($lid,"integer")) {
|
||||
$account_id = $lid;
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
$phpgw->db->unlock();
|
||||
}
|
||||
|
||||
$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){
|
||||
reset ($acl_apps);
|
||||
while (list(,$value) = each($acl_apps)){
|
||||
$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($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Account Permissions - ".$db2->f("aaccount_permissions")." -->\n";
|
||||
for ($i=0; $i<count($apps); $i++) {
|
||||
//if($lid <> $phpgw_info["user"]["account_id"]) echo "<!-- applications: Reading user app - ".$apps[$i]." -->\n";
|
||||
if ($this->enabled[$apps[$i]] == 1) {
|
||||
$this->user_apps[$apps[$i]] = $apps[$i];
|
||||
$this->enabled[$apps[$i]] = 2;
|
||||
$this->app_perms[] = $apps[$i];
|
||||
if ($phpgw_info["apps"][$apps[$i]]["enabled"] == True) {
|
||||
$this->user_apps[$owner_id][] = $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;
|
||||
}
|
||||
|
||||
$groups = $phpgw->accounts->read_groups($account_id);
|
||||
|
||||
if($groups) {
|
||||
while ($group = each($groups)) {
|
||||
$this->read_group_apps($group[0]);
|
||||
}
|
||||
function read_group_apps($group_id) {
|
||||
global $phpgw, $phpgw_info;
|
||||
if(gettype($group_id) == "integer") {
|
||||
$group_found = True;
|
||||
} 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)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$db2 = $phpgw->db;
|
||||
|
||||
if($group_found) {
|
||||
$acl_apps = $phpgw->acl->get_app_list_for_id('run', 1, 'g', $group_id);
|
||||
if ($acl_apps != False){
|
||||
reset ($acl_apps);
|
||||
while (list(,$value) = each($acl_apps)){
|
||||
$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)) {
|
||||
for ($i=0;$i<count($apps);$i++) {
|
||||
if ($this->enabled[$apps[$i]] == 1) {
|
||||
$this->group_apps[$group_id][$apps[$i]] = $apps[$i];
|
||||
$this->enabled[$apps[$i]] = 2;
|
||||
$this->app_perms[] = $apps[$i];
|
||||
if ($phpgw_info["apps"][$apps[$i]]["enabled"] == True) {
|
||||
$this->group_apps[$group_id][] = $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];
|
||||
}
|
||||
|
||||
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).":";
|
||||
return False;
|
||||
}
|
||||
|
||||
function user_app_string()
|
||||
{
|
||||
reset($this->user_apps);
|
||||
while($app = each($this->user_apps)) {
|
||||
$user_apps[] = $app[1];
|
||||
function is_system_enabled($appname){
|
||||
if(gettype($phpgw_info["apps"]) != "array") {
|
||||
$this->read_installed_apps();
|
||||
}
|
||||
if ($phpgw_info["apps"][$appname]["enabled"] == True) {
|
||||
return True;
|
||||
}else{
|
||||
return False;
|
||||
}
|
||||
return ":".implode(":",$user_apps).":";
|
||||
}
|
||||
|
||||
function is_group($group_id,$appname)
|
||||
{
|
||||
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")) {
|
||||
function add_group_app($apps, $group_id) {
|
||||
if(gettype($appname) == "array") {
|
||||
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($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)) {
|
||||
} elseif(gettype($appname) == "string") {
|
||||
$this->group_apps[$group_id][] = $appname;
|
||||
$this->enabled[$appname] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
function add_user($appname)
|
||||
{
|
||||
if($this->is_type($appname,"array")) {
|
||||
function add_user_app($appname, $user_id = "") {
|
||||
global $phpgw, $phpgw_info;
|
||||
if ($user_id == ""){$user_id = $phpgw_info["user"]["account_id"];}
|
||||
if(gettype($appname) == "array") {
|
||||
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($this->is_type($appname,"string")) {
|
||||
$this->add_user_app($group_id,$appname);
|
||||
return $this->user_app_string($group_id);
|
||||
} elseif(gettype($appname) == "string") {
|
||||
$this->user_apps[$user_id][] = $appname;
|
||||
}
|
||||
}
|
||||
|
||||
function add_user_app($appname)
|
||||
{
|
||||
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)) {
|
||||
function delete_group_app($appname, $group_id) {
|
||||
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)
|
||||
{
|
||||
if($this->is_user($appname)) {
|
||||
unset($this->user_apps[$appname]);
|
||||
}
|
||||
}
|
||||
|
||||
function save_group($group_id)
|
||||
{
|
||||
global $phpgw;
|
||||
function save_group_apps($group_id){
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
if($group_id) {
|
||||
$db2 = $phpgw->db;
|
||||
$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);
|
||||
$phpgw->acl->delete("%", "run", "g", $group_id);
|
||||
reset($this->group_apps[$group_id]);
|
||||
while($app = each($this->group_apps[$group_id])) {
|
||||
$phpgw->acl->add($app[1],'run',$group_id,'g',1);
|
||||
@ -361,17 +203,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function save_user()
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
if($this->account_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");
|
||||
function save_user_apps($user_id = ""){
|
||||
global $phpgw, $phpgw_info;
|
||||
if ($user_id == ""){$user_id = $phpgw_info["user"]["account_id"];}
|
||||
if($user_id) {
|
||||
$phpgw->acl->delete("%", "run", "u", $user_id);
|
||||
reset($this->user_apps);
|
||||
while($app = each($this->user_apps)) {
|
||||
$phpgw->acl->add($app[1],'run',$this->account_id,'u',1);
|
||||
while($app = each($this->user_apps[$user_id])) {
|
||||
$phpgw->acl->add($app[1],'run',$user_id,'u',1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -600,8 +600,9 @@
|
||||
$completed_hooks[$appname] = True;
|
||||
}
|
||||
/* Then add the rest */
|
||||
reset ($phpgw_info["user"]["app_perms"]);
|
||||
while (list (, $appname) = each ($phpgw_info["user"]["app_perms"])){
|
||||
reset ($phpgw_info["user"]["apps"]);
|
||||
asort ($phpgw_info["user"]["apps"]);
|
||||
while (list (, $appname) = each ($phpgw_info["user"]["apps"])){
|
||||
if (gettype($appname) != "array" && $appname != "" && $completed_hooks[$appname] != True){
|
||||
$f = $phpgw_info["server"]["server_root"] . "/" . $appname . "/inc/hook_".$phpgw_info["flags"]["currentapp"];
|
||||
if ($location != ""){$f .= "_".$location.".inc.php";}else{$f .= ".inc.php"; }
|
||||
|
@ -794,6 +794,43 @@
|
||||
$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);
|
||||
while (list ($key, $value) = each ($test)){
|
||||
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {
|
||||
|
@ -819,6 +819,44 @@
|
||||
$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);
|
||||
while (list ($key, $value) = each ($test)){
|
||||
if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) {
|
||||
|
@ -11,5 +11,5 @@
|
||||
|
||||
/* $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";
|
||||
|
Loading…
Reference in New Issue
Block a user