[20976] Improvement: Better Users and Group handling - added per app admin - 4512:4565

Sigurd Nes <[email protected]> Fri, 22 Jan 2010 09:47:52 +0000
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20976
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20976
Author:   sigurdne
Date:     2010-01-22 09:47:52 +0000 (Fri, 22 Jan 2010)
Log Message:
-----------
Improvement: Better Users and Group handling - added per app admin - 4512:4565

Modified Paths:
--------------
    people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php
    people/sigurdne/modules/phpgwapi/trunk/inc/class.applications.inc.php
    people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php
    people/sigurdne/modules/phpgwapi/trunk/setup/setup.inc.php
    people/sigurdne/modules/phpgwapi/trunk/setup/tables_update.inc.php

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php	2010-01-22 09:46:44 UTC (rev 20975)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php	2010-01-22 09:47:52 UTC (rev 20976)
@@ -692,6 +692,15 @@
 
 			$aclobj =& $GLOBALS['phpgw']->acl;
 			$aclobj->set_account_id($user->id, true);
+			foreach ($GLOBALS['phpgw_info']['apps'] as $app => $dummy)
+			{
+				if($app == 'phpgwapi')
+				{
+					continue;
+				}
+				$aclobj->delete_repository($app, 'admin', $user->id);			
+			}
+
 			$aclobj->delete_repository('preferences', 'changepassword', $user->id);
 			$aclobj->delete_repository('phpgwapi', 'anonymous', $user->id);
 			$aclobj->set_account_id($user->id, true); //reread the current repository

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/class.applications.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/class.applications.inc.php	2010-01-22 09:46:44 UTC (rev 20975)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/class.applications.inc.php	2010-01-22 09:47:52 UTC (rev 20976)
@@ -144,6 +144,16 @@
 			}
 
 			$apps = $GLOBALS['phpgw']->acl->get_user_applications($this->account_id);
+			$apps_admin = $GLOBALS['phpgw']->acl->get_app_list_for_id('admin', phpgwapi_acl::ADD, $this->account_id);
+			if($apps_admin)
+			{
+				$apps['admin'] = true;
+			}
+			foreach($apps_admin as $app_admin)
+			{
+				$apps[$app_admin] = true;
+			}
+
 			foreach ( $GLOBALS['phpgw_info']['apps'] as $app )
 			{
 				if ( isset($apps[$app['name']]) )

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php	2010-01-22 09:46:44 UTC (rev 20975)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/class.setup.inc.php	2010-01-22 09:47:52 UTC (rev 20976)
@@ -383,6 +383,7 @@
 			// hack to make phpgwapi_applications::name2id to work properly
 			unset($GLOBALS['phpgw_info']['apps']);
 			$GLOBALS['phpgw']->locations->add('run', "Automatically added on install - run {$appname}", $appname, false);
+			$GLOBALS['phpgw']->locations->add('admin', "Allow app admins - {$appname}", $appname, false);
 		}
 
 		/**

Modified: people/sigurdne/modules/phpgwapi/trunk/setup/setup.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/setup/setup.inc.php	2010-01-22 09:46:44 UTC (rev 20975)
+++ people/sigurdne/modules/phpgwapi/trunk/setup/setup.inc.php	2010-01-22 09:47:52 UTC (rev 20976)
@@ -12,7 +12,7 @@
 	// Basic information about this app
 	$setup_info['phpgwapi']['name']      = 'phpgwapi';
 	$setup_info['phpgwapi']['title']     = 'phpgwapi';
-	$setup_info['phpgwapi']['version']   = '0.9.17.524';
+	$setup_info['phpgwapi']['version']   = '0.9.17.525';
 	$setup_info['phpgwapi']['versions']['current_header'] = '1.30';
 	$setup_info['phpgwapi']['enable']    = 3;
 	$setup_info['phpgwapi']['app_order'] = 1;

Modified: people/sigurdne/modules/phpgwapi/trunk/setup/tables_update.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/setup/tables_update.inc.php	2010-01-22 09:46:44 UTC (rev 20975)
+++ people/sigurdne/modules/phpgwapi/trunk/setup/tables_update.inc.php	2010-01-22 09:47:52 UTC (rev 20976)
@@ -2605,3 +2605,32 @@
 			return $GLOBALS['setup_info']['phpgwapi']['currentver'];
 		}
 	}
+
+	$test[] = '0.9.17.524';
+	/**
+	* Restore support for anonymous sessions.
+	*
+	* @return string the new version number
+	*/
+	function phpgwapi_upgrade0_9_17_524()
+	{
+		$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+		$apps = array();
+		$GLOBALS['phpgw_setup']->oProc->m_odb->query('SELECT app_name FROM phpgw_applications', __LINE__, __FILE__);
+		while ( $GLOBALS['phpgw_setup']->oProc->next_record() )
+		{
+			$apps[] = $GLOBALS['phpgw_setup']->oProc->m_odb->f('app_name', true);
+		}
+
+		foreach ( $apps as $app )
+		{
+			$GLOBALS['phpgw']->locations->add('admin', "Allow app admins - {$app}", $app, false);
+		}
+
+		if ( $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit() )
+		{
+			$GLOBALS['setup_info']['phpgwapi']['currentver'] = '0.9.17.525';
+			return $GLOBALS['setup_info']['phpgwapi']['currentver'];
+		}
+	}