phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: sitemgr/inc class.Outline_UI.inc.php,NONE,1.3.2.


From: Michael Totschnig <address@hidden>
Subject: [Phpgroupware-cvs] CVS: sitemgr/inc class.Outline_UI.inc.php,NONE,1.3.2.1 class.Sites_BO.inc.php,NONE,1.7.2.1class.Sites_SO.inc.php,NONE,1.2.2.1 class.Sites_UI.inc.php,NONE,1.6.2.1hook_sidebox_menu.inc.php,NONE,1.1.2.1 class.ACL_BO.inc.php,1.2,1.2.2.1 class.Block_SO.inc.php,1.3,1.3.2.1 class.Categories_BO.inc.php,1.6,1.6.2.1 class.Categories_SO.inc.php,1.13,1.13.2.1 class.Categories_UI.inc.php,1.1,1.1.2.1 class.Common_BO.inc.php,1.1.2.1,1.1.2.2 class.Common_UI.inc.php,1.8.2.2,1.8.2.3 class.Content_BO.inc.php,1.2,1.2.2.1class.Content_SO.inc.php,1.6,1.6.2.1 class.Content_UI.inc.php,1.3.2.1,1.3.2.2 class.Modules_BO.inc.php,1.2,1.2.2.1 class.Modules_UI.inc.php,1.2.2.1,1.2.2.2class.Page_SO.inc.php,1.5,1.5.2.1 class.Pages_BO.inc.php,1.5,1.5.2.1class.Pages_SO.inc.php,1.12,1.12.2.1 class.Pages_UI.inc.php,1.1,1.1.2.1class.Theme_BO.inc.php,1.4,1.4.2.1 class.Translations_UI.inc.php,1.3,1.3.2.1class.module.inc.php,1.8,1.8.2.1 class.xslt_transform.inc.php,1.1,1.1.2.1 hook_admin.inc.php,1.2,1.2.2.1 hook_preferences.inc.php,1.2,1.2.2.1 class.MainMenu_UI.inc.php,1.6,NONE class.SiteContent_UI.inc.php,1.1.2.1,NONE class.headerFooter_BO.inc.php,1.2,NONE class.sitePreference_SO.inc.php,1.3,NONE
Date: Mon, 23 Jun 2003 16:31:24 -0400

Update of /cvsroot/phpgroupware/sitemgr/inc
In directory subversions:/tmp/cvs-serv14915/inc

Modified Files:
      Tag: Version-0_9_16-branch
        class.ACL_BO.inc.php class.Block_SO.inc.php 
        class.Categories_BO.inc.php class.Categories_SO.inc.php 
        class.Categories_UI.inc.php class.Common_BO.inc.php 
        class.Common_UI.inc.php class.Content_BO.inc.php 
        class.Content_SO.inc.php class.Content_UI.inc.php 
        class.Modules_BO.inc.php class.Modules_UI.inc.php 
        class.Page_SO.inc.php class.Pages_BO.inc.php 
        class.Pages_SO.inc.php class.Pages_UI.inc.php 
        class.Theme_BO.inc.php class.Translations_UI.inc.php 
        class.module.inc.php class.xslt_transform.inc.php 
        hook_admin.inc.php hook_preferences.inc.php 
Added Files:
      Tag: Version-0_9_16-branch
        class.Outline_UI.inc.php class.Sites_BO.inc.php 
        class.Sites_SO.inc.php class.Sites_UI.inc.php 
        hook_sidebox_menu.inc.php 
Removed Files:
      Tag: Version-0_9_16-branch
        class.MainMenu_UI.inc.php class.SiteContent_UI.inc.php 
        class.headerFooter_BO.inc.php class.sitePreference_SO.inc.php 
Log Message:
sync up with HEAD


***** Error reading new file: [Errno 2] No such file or directory: 
'class.Outline_UI.inc.php'
***** Error reading new file: [Errno 2] No such file or directory: 
'class.Sites_BO.inc.php'
--- NEW FILE ---
<?php
        class Sites_SO
        {
                var $db;
                
                function Sites_SO()
                {
                        $this->db = $GLOBALS['phpgw']->db;
                }

                function list_siteids()
                {
                        $result = array();
                        $sql = "SELECT site_id FROM phpgw_sitemgr_sites";
                        $this->db->query($sql,__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {
                                $result[] = $this->db->f('site_id');
                        }
                        return $result;
                }

                function getWebsites($limit,$start,$sort,$order,$query,&$total)
                {
                        if ($limit)
                        {
                                if (!$sort)
                                {
                                        $sort = 'DESC';
                                }
                                if ($query)
                                {
                                        $whereclause = "WHERE site_name LIKE 
'%$query%'"
                                                . "OR site_url LIKE '%$query%'"
                                                . "OR site_dir LIKE '%$query%'";
                                }
                                if ($order)
                                {
                                        $orderclause = 'ORDER BY ' . $order . ' 
' . $sort;
                                }
                                else
                                {
                                        $orderclause = 'ORDER BY site_name ASC';
                                }
                                $sql = "SELECT site_id,site_name,site_url from 
phpgw_sitemgr_sites $whereclause $orderclause";  
                                $this->db->query($sql,__LINE__,__FILE__);
                                $total = $this->db->num_rows();
                                
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
                        }
                        else
                        {
                                $sql = "SELECT site_id,site_name,site_url from 
phpgw_sitemgr_sites";
                                $this->db->query($sql,__LINE__,__FILE__);
                        }
                        while ($this->db->next_record())
                        {
                                foreach(array('site_id', 'site_name', 
'site_url') as $col)
                                {
                                        $site[$col] = $this->db->f($col);
                                }
                                $result[$site['site_id']] = $site;
                        }
                        return $result;
                }

                function getnumberofsites()
                {
                        $sql = "SELECT COUNT(*) FROM phpgw_sitemgr_sites";
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->next_record();
                        return $this->db->f(0);
                }

                function urltoid($url)
                {
                        $sql = "SELECT site_id FROM phpgw_sitemgr_sites WHERE 
site_url = '$url'";
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->next_record();
                        return $this->db->f('site_id');
                }

                function read($id)
                {
                        $sql = "SELECT * from phpgw_sitemgr_sites WHERE site_id 
= $id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
                        {
                                foreach(
                                        array(
                                                'site_id', 'site_name', 
'site_url', 'site_dir', 'themesel', 
                                                'site_languages', 
'home_page_id', 'anonymous_user','anonymous_passwd'
                                        ) as $col
                                )
                                {
                                        $site[$col] = $this->db->f($col);
                                }
                                return $site;
                        }
                        else
                        {
                                return false;
                        }
                }

                function read2($id)
                {
                        $sql = "SELECT site_url,site_dir from 
phpgw_sitemgr_sites WHERE site_id = $id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
                        {
                                foreach(
                                        array(
                                                'site_url', 'site_dir'
                                        ) as $col
                                )
                                {
                                        $site[$col] = $this->db->f($col);
                                }
                                return $site;
                        }
                        else
                        {
                                return false;
                        }
                }

                function add($site)
                {
                        $cats = 
CreateObject('phpgwapi.categories',-1,'sitemgr');
                                $data = array
                        (
                                'name'          => $site['name'],
                                'descr'         => '',
                                'access'        => 'public',
                                'parent'        => 0,
                                'old_parent' => 0
                        );
                        $site_id =  $cats->add($data);
                        $sql = "INSERT INTO phpgw_sitemgr_sites 
(site_id,site_name,site_url,site_dir,anonymous_user,anonymous_passwd) VALUES 
($site_id,'" . 
                                $site['name'] . "','" . $site['url'] . "','" . 
$site['dir'] . "','" . $site['anonuser'] . "','" . $site['anonpasswd'] .
                                "')";
                        $this->db->query($sql,__LINE__,__FILE__);
                        return $site_id;
                }

                function update($id,$site)
                {
                        $sql = "UPDATE phpgw_sitemgr_sites SET site_name = '" . 
$site['name'] . "', site_url = '" . $site['url'] . "', site_dir = '" . 
                                $site['dir'] . "', anonymous_user = '" . 
$site['anonuser'] . "', anonymous_passwd = '" . $site['anonpasswd'] . 
                                "' WHERE site_id = $id";
                         $this->db->query($sql,__LINE__,__FILE__);
                }

                function delete($id)
                {
                        $sql = "DELETE FROM phpgw_sitemgr_sites WHERE site_id = 
$id";
                        $this->db->query($sql,__LINE__,__FILE__);
                }

                function saveprefs($prefs)
                {
                        $sql = "UPDATE phpgw_sitemgr_sites SET themesel = '" . 
$prefs['themesel'] . "', site_languages = '" . $prefs['site_languages'] .
                                "', home_page_id = " . $prefs['home_page_id'] . 
" WHERE site_id = " . CURRENT_SITE_ID;
                        $this->db->query($sql,__LINE__,__FILE__);
                }
        }
***** Error reading new file: [Errno 2] No such file or directory: 
'class.Sites_UI.inc.php'
***** Error reading new file: [Errno 2] No such file or directory: 
'hook_sidebox_menu.inc.php'
Index: class.ACL_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.ACL_BO.inc.php,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** class.ACL_BO.inc.php        17 Jan 2003 03:37:52 -0000      1.2
--- class.ACL_BO.inc.php        23 Jun 2003 20:31:20 -0000      1.2.2.1
***************
*** 10,19 ****
        
\***************************************************************************/
  
        class ACL_BO
        {
-               var $acct;
                var $acl;
                var $acl_so;
-               var $pages_so;
                var $logged_in_user;
  
--- 10,19 ----
        
\***************************************************************************/
  
+ define('SITEMGR_ACL_IS_ADMIN',1);
+ 
        class ACL_BO
        {
                var $acl;
                var $acl_so;
                var $logged_in_user;
  
***************
*** 21,66 ****
                {
                        $this->logged_in_user = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->acct = 
CreateObject('phpgwapi.accounts',$this->logged_in_user);
                        $this->acl = 
CreateObject('phpgwapi.acl',$this->logged_in_user);
-                       $this->pages_so = CreateObject('sitemgr.Pages_SO');
                        $this->acl_so = CreateObject('sitemgr.ACL_SO');
                }
  
!               function can_read_page($page_id)
                {
!                       /*!
!                       $acl->check_specific calls $acl->get_specific_rights 
which is for this->account_id
!                       */
!                       $page = $this->pages_so->getPage($page_id);
!                       if ($page)
!                       {
!                               if ($this->is_admin())
!                               {
!                                       return true;
!                               }
!                               $category_id = $page->cat_id;
!                               //$this->acl = 
CreateObject('phpgwapi.acl',$this->logged_in_user);
!                               //return 
($this->acl->get_rights('L'.$category_id,'sitemgr') & PHPGW_ACL_READ);
!                               return 
($this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_READ);
!                       }
!                       else
                        {
!                               return false;
                        }
                }
  
!               function is_admin()
                {
!                       if($GLOBALS['phpgw']->acl->check('run',1,'admin'))
!                       {
!                               define('HAS_ADMIN_RIGHTS',1);
!                       }
!                       if(HAS_ADMIN_RIGHTS == 1)
                        {
!                               return True;
!                       }
!                       else
!                       {
!                               return False;
                        }
                }
--- 21,43 ----
                {
                        $this->logged_in_user = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->acl = 
CreateObject('phpgwapi.acl',$this->logged_in_user);
                        $this->acl_so = CreateObject('sitemgr.ACL_SO');
                }
  
!               function is_admin($site_id=False)
                {
!                       if (!$site_id)
                        {
!                               $site_id = CURRENT_SITE_ID;
                        }
+                       return $this->acl_so->get_permission('L'.$site_id) & 
SITEMGR_ACL_IS_ADMIN;
                }
  
!               function set_adminlist($site_id,$account_list)
                {
!                       $this->remove_location($site_id);
!                       while (list($null,$account_id) = @each($account_list))
                        {
!                               
$this->acl->add_repository('sitemgr','L'.$site_id,$account_id,SITEMGR_ACL_IS_ADMIN);
                        }
                }
***************
*** 90,94 ****
                        }
  
-                       $this->acl = CreateObject('phpgwapi.acl',$user);
                        if ($rights == 0)
                        {
--- 67,70 ----
***************
*** 118,122 ****
                           and get_specific_rights and other lookup functions 
DON'T WORK.
                        */
!                       $users = $this->acct->get_list($acct_type);
  
                        $permissions = Array();
--- 94,98 ----
                           and get_specific_rights and other lookup functions 
DON'T WORK.
                        */
!                       $users = 
$GLOBALS['phpgw']->accounts->get_list($acct_type);
  
                        $permissions = Array();
***************
*** 130,141 ****
                                //$rights = 
$this->acl->get_specific_rights('L'.$category_id,'sitemgr');
                                $rights = 
$this->acl_so->get_rights($account_id, 'L'.$category_id);
!                               $permissions[] = 
array('account_id'=>$account_id, 'rights'=>$rights);
                        }
                        return $permissions;
                }
  
                function can_read_category($category_id)
                {
!                       if ($this->is_admin())
                        {
                                return true;
--- 106,119 ----
                                //$rights = 
$this->acl->get_specific_rights('L'.$category_id,'sitemgr');
                                $rights = 
$this->acl_so->get_rights($account_id, 'L'.$category_id);
!                               $permissions[$account_id] = $rights;
                        }
                        return $permissions;
                }
  
+               //at this moment there are only implicit permissions for the 
toplevel site_category, is this a problem?
+               //everybody can read it, only admins can write it. 
                function can_read_category($category_id)
                {
!                       if ($this->is_admin() || ($category_id == 
CURRENT_SITE_ID))
                        {
                                return true;
***************
*** 155,166 ****
                                return true;
                        }
!                       else
                        {
                                //$this->acl = 
CreateObject('phpgwapi.acl',$this->logged_in_user);
                                //return 
($this->acl->get_rights($account_id,'L'.$category_id) & PHPGW_ACL_ADD);
                                // if category_id = 0, we are in site-wide 
scope, and only admin can add content
!                               return $category_id ? 
!                                       
($this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_ADD) :
!                                       $this->is_admin();
                        }
                }
--- 133,146 ----
                                return true;
                        }
!                       elseif ($category_id != CURRENT_SITE_ID)
                        {
                                //$this->acl = 
CreateObject('phpgwapi.acl',$this->logged_in_user);
                                //return 
($this->acl->get_rights($account_id,'L'.$category_id) & PHPGW_ACL_ADD);
                                // if category_id = 0, we are in site-wide 
scope, and only admin can add content
!                               return 
$this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_ADD;
!                       }
!                       else
!                       {
!                               return False;
                        }
                }

Index: class.Block_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Block_SO.inc.php,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** class.Block_SO.inc.php      4 Mar 2003 17:26:43 -0000       1.3
--- class.Block_SO.inc.php      23 Jun 2003 20:31:20 -0000      1.3.2.1
***************
*** 12,19 ****
                var $title;
                var $view;
!               var $actif;
                
                function Block_SO()
                {
                }
        }
--- 12,27 ----
                var $title;
                var $view;
!               var $state;
!               var $version;
                
                function Block_SO()
                {
+               }
+ 
+               function set_version($version)
+               {
+                       $this->arguments = $version['arguments'];
+                       $this->state = $version['state'];
+                       $this->version = $version['id'];
                }
        }

Index: class.Categories_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_BO.inc.php,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -r1.6 -r1.6.2.1
*** class.Categories_BO.inc.php 17 Jan 2003 03:37:52 -0000      1.6
--- class.Categories_BO.inc.php 23 Jun 2003 20:31:20 -0000      1.6.2.1
***************
*** 3,7 ****
        {
                var $so;
!               
                function Categories_BO()
                {
--- 3,8 ----
        {
                var $so;
!               var $currentcats;
! 
                function Categories_BO()
                {
***************
*** 10,21 ****
                }
  
                function getCategoryOptionList()
                {
                        $retval[] = array('value'=>0,'display'=>'[No Parent]');
!                       $list = $this->getPermittedCatWriteNested();
                        foreach($list as $cat_id)
                        {
                                $cat = $this->getCategory($cat_id);
!                               $padding = str_pad('',12*$cat->depth,'&nbsp;');
                                $retval[] = array('value'=>$cat->id, 
'display'=>$padding.$cat->name);
                        }
--- 11,30 ----
                }
  
+               //since we need this information several times we store it once,
+               //this function is called by Sites_BO after the current site is 
defined
+               function setcurrentcats()
+               {
+                       $this->currentcats = 
$this->getpermittedcats(CURRENT_SITE_ID,'active',True);
+                       $this->readablecats = $this->getpermittedcatsRead();
+               }
+ 
                function getCategoryOptionList()
                {
                        $retval[] = array('value'=>0,'display'=>'[No Parent]');
!                       $list = $this->getpermittedcatsWrite();
                        foreach($list as $cat_id)
                        {
                                $cat = $this->getCategory($cat_id);
!                               $padding = 
str_pad('',12*($cat->depth-1),'&nbsp;');
                                $retval[] = array('value'=>$cat->id, 
'display'=>$padding.$cat->name);
                        }
***************
*** 23,93 ****
                }
  
!               function getPermittedCatReadNested($cat_id=0)
                {
!                       return $this->getPermittedCatNested($cat_id,'read');
                }
!               function getPermittedCatWriteNested($cat_id=0)
                {
!                       return $this->getPermittedCatNested($cat_id,'write');
                }
  
!               // Don't call this function directly.  Use above funcs.
!               function getPermittedCatNested($cat_id=0,$check='')
                {
!                       if (!$check)
!                       {
!                               // You should use the getPermittedCatReadNested 
and WriteNested funcs
!                               die("Whatcha doin callin this function, 
Willis?");
!                       }
  
                        $root_list = $this->so->getChildrenIDList($cat_id);
                        $permitted_list=array();
!                       if (is_array($root_list))
                        {
!                               foreach($root_list as $root_cat)
                                {
!                                       if ($check=='read')
!                                       {
!                                               $permitted = 
$GLOBALS['Common_BO']->acl->can_read_category($root_cat);
!                                       }
!                                       elseif ($check=='write')
!                                       {
!                                               $permitted = 
$GLOBALS['Common_BO']->acl->can_write_category($root_cat);
!                                       }
!                                       else
!                                       {
!                                               die("What'd I tell you about 
calling this function?");
!                                       }
! 
!                                       if ($permitted)
!                                       {
!                                               $permitted_list[]=$root_cat;
!                                       }
!                                       //subcategories can be 
readable/writeable even when parent is not
!                                       $sub_list = 
$this->getPermittedCatNested($root_cat,$check);
!                                       if (is_array($sub_list) && 
count($sub_list)>0)
!                                       {
!                                               //array_push($permitted_list, 
$sub_list);
!                                               
$permitted_list=array_merge($permitted_list, $sub_list);
!                                       }
                                }
-                       }
- //print_r($permitted_list);
-                       return $permitted_list;
-               }
- 
-               //the next two functions do not recurse!
-               function getPermittedCategoryIDWriteList($cat_id=0)
-               {
-                       $full_list = $this->so->getChildrenIDList($cat_id);
  
!                       $permitted_list=array();
!                       if (is_array($full_list))
!                       {
!                               foreach($full_list as $item)
                                {
!                                       if 
($GLOBALS['Common_BO']->acl->can_write_category($item))
                                        {
!                                               $permitted_list[]=$item;
                                        }
                                }
--- 32,115 ----
                }
  
!               function getpermittedcatsRead($cat_id=False,$recurse=true)
                {
!                       if (!$cat_id)
!                       {
!                               $cat_id = CURRENT_SITE_ID;
!                       }
!                       if ($cat_id != CURRENT_SITE_ID)
!                       {
!                               $this->check($cat_id);
!                       }
!                       return $this->getpermittedcats($cat_id,'read',$recurse);
                }
!               function getpermittedcatsWrite($cat_id=False,$recurse=true)
                {
!                       if (!$cat_id)
!                       {
!                               $cat_id = CURRENT_SITE_ID;
!                       }       
!                       if ($cat_id != CURRENT_SITE_ID)
!                       {
!                               $this->check($cat_id);
!                       }
!                       return 
$this->getpermittedcats($cat_id,'write',$recurse);
!               }
!               function getpermittedcatsCommitable()
!               {
!                       return 
$this->getpermittedcats(CURRENT_SITE_ID,'commitable',true);
                }
  
!               function getpermittedcatsArchived()
                {
!                       return 
$this->getpermittedcats(CURRENT_SITE_ID,'archived',true);
!               }
  
+               function getpermittedcats($cat_id,$check,$recurse)
+               {
                        $root_list = $this->so->getChildrenIDList($cat_id);
                        $permitted_list=array();
!                       while(list(,$root_cat) = @each($root_list))
                        {
!                               switch ($check)
                                {
!                                       case 'commitable':
!                                               $permitted = (
!                                                       
$this->so->isactive($root_cat,$GLOBALS['Common_BO']->getstates('Commit')) &&
!                                                       
$GLOBALS['Common_BO']->acl->is_admin()
!                                               );
!                                               break;
!                                       case 'archived':
!                                               $permitted = (
!                                                       
$this->so->isactive($root_cat,$GLOBALS['Common_BO']->getstates('Archive')) &&
!                                                       
$GLOBALS['Common_BO']->acl->is_admin()
!                                               );
!                                               break;
!                                       case 'active':
!                                               $permitted = 
$this->so->isactive($root_cat);
!                                               break;
!                                       case 'read':
!                                               $permitted = 
(in_array($root_cat,$this->currentcats) && 
$GLOBALS['Common_BO']->acl->can_read_category($root_cat));
!                                               break;
!                                       case 'write':
!                                               $permitted = 
(in_array($root_cat,$this->currentcats) && 
$GLOBALS['Common_BO']->acl->can_write_category($root_cat));
                                }
  
!                               if ($permitted)
!                               {
!                                       $permitted_list[]=$root_cat;
!                               }
!                               //subcategories can be readable/writeable even 
when parent is not, but when parent is inactive subcats are too.
!                               elseif ($check == 'active')
                                {
!                                       continue;
!                               }
!                               if ($recurse)
!                               {
!                                       $sub_list = 
$this->getpermittedcats($root_cat,$check,true);
!                                       if (count($sub_list)>0)
                                        {
!                                               //array_push($permitted_list, 
$sub_list);
!                                               
$permitted_list=array_merge($permitted_list, $sub_list);
                                        }
                                }
***************
*** 96,123 ****
                }
  
!               function getPermittedCategoryIDReadList($cat_id=0)
                {
!                       $full_list = $this->so->getChildrenIDList($cat_id);
!                       
!                       $permitted_list=array();
!                       if (is_array($full_list))
                        {
!                               reset($full_list);
!                               foreach($full_list as $item)
!                               {
!                                       if 
($GLOBALS['Common_BO']->acl->can_read_category($item))
!                                       {
!                                               $permitted_list[]=$item;
!                                       }
!                               }
                        }
-                       return $permitted_list;
-               }
  
-               function addCategory($name, $description, $parent=0)            
-               {
                        if ($GLOBALS['Common_BO']->acl->is_admin())
                        {
!                               return $this->so->addCategory($name, 
$description, $parent);
                        }
                        else
--- 118,133 ----
                }
  
!               function addCategory($name, $description, $parent=False)        
        
                {
!                       if (!$parent)
                        {
!                               $parent = CURRENT_SITE_ID;
                        }
  
                        if ($GLOBALS['Common_BO']->acl->is_admin())
                        {
!                               $cat_id = $this->so->addCategory($name, 
$description, $parent);
!                               $this->currentcats[] = $cat_id;
!                               return $cat_id;
                        }
                        else
***************
*** 127,149 ****
                }
  
!               function removeCategory($cat_id)
                {
!                       if ($GLOBALS['Common_BO']->acl->is_admin())
                        {
!                               /********************************************\
!                               * We have to remove the category, all the    *
!                               * associated pages, and all the associated   *
!                               * acl stuff too.  not to forget blocks       *
!                               \********************************************/
!                               $this->so->removeCategory($cat_id);
!                               
$GLOBALS['Common_BO']->acl->remove_location($cat_id);
!                               
$GLOBALS['Common_BO']->pages->removePagesInCat($cat_id);
!                               
$GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,0);
!                               return True;
                        }
                }
  
!               function saveCategoryInfo($cat_id, $cat_name, $cat_description, 
$lang, $sort_order=0, $parent=0, $old_parent=0)
                {
                        $cat_info = CreateObject('sitemgr.Category_SO', True);
                        $cat_info->id = $cat_id;
--- 137,180 ----
                }
  
!               //$force for use by Sites_BO, since when we are editing the 
files list, the concept of admin of a current site does not apply
!               //$frecurse also removes subcats
!               function removeCategory($cat_id,$force=False,$recurse=False)
                {
!                       if (!$force)
                        {
!                               $this->check($cat_id);
! 
!                               if (!$GLOBALS['Common_BO']->acl->is_admin())
!                               {
!                                       return False;
!                               }
                        }
+                       if ($recurse)
+                       {
+                               $children = 
$this->so->getChildrenIDList($cat_id);
+                               while (list($null,$subcat) = @each($children))
+                               {
+                                       
$this->removeCategory($subcat,True,True);
+                               }
+                       }
+                       /********************************************\
+                       * We have to remove the category, all the    *
+                       * associated pages, and all the associated   *
+                       * acl stuff too.  not to forget blocks       *
+                       \********************************************/
+                       
$GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,0,True);
+                       
$GLOBALS['Common_BO']->pages->removePagesInCat($cat_id,True);
+                       $this->so->removeCategory($cat_id);
+                       $GLOBALS['Common_BO']->acl->remove_location($cat_id);
+                       
+                       return True;
                }
  
!               function saveCategoryInfo($cat_id, $cat_name, $cat_description, 
$lang, $sort_order=0, $state, $parent=False, $old_parent=False)
                {
+                       if (!$parent)
+                       {
+                               $parent = CURRENT_SITE_ID;
+                       }
                        $cat_info = CreateObject('sitemgr.Category_SO', True);
                        $cat_info->id = $cat_id;
***************
*** 151,194 ****
                        $cat_info->description = $cat_description;
                        $cat_info->sort_order = $sort_order;
                        $cat_info->parent = $parent;
!                       if ($old_parent!='')
!                       {
!                               $cat_info->old_parent = $old_parent;
!                       }
!                       else
!                       {
!                               $cat_info->old_parent = $parent;
!                       }
  
                        if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
-                       {       
-                         if ($this->so->saveCategory($cat_info));
-                         {
-                           if ($this->so->saveCategoryLang($cat_id, $cat_name, 
$cat_description, $lang))
-                             {
-                               return True;
-                             }
-                           return false;
-                         }
-                         return false;
-                       }
-                       else
                        {
!                               return false;
                        }
                }
  
                function saveCategoryLang($cat_id, $cat_name, $cat_description, 
$lang)
!                 {
!                   if ($this->so->saveCategoryLang($cat_id, $cat_name, 
$cat_description, $lang))
!                     {
!                       return True;
!                     }
!                   return false;
!                 }
                
!               function getCategory($cat_id,$lang=False)
                {
!                       if 
($GLOBALS['Common_BO']->acl->can_read_category($cat_id))
                        {
                                return $this->so->getCategory($cat_id,$lang);
--- 182,218 ----
                        $cat_info->description = $cat_description;
                        $cat_info->sort_order = $sort_order;
+                       $cat_info->state = $state;
                        $cat_info->parent = $parent;
!                       $cat_info->old_parent = $old_parent ? $old_parent : 
$parent;
  
                        if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
                        {
!                               if ($this->so->saveCategory($cat_info));
!                               {
!                                       if 
($this->so->saveCategoryLang($cat_id, $cat_name, $cat_description, $lang))
!                                       {
!                                               //reflect changes
!                                               $this->setcurrentcats();
!                                               return true;
!                                       }
!                               }
                        }
+                       return false;
                }
  
                function saveCategoryLang($cat_id, $cat_name, $cat_description, 
$lang)
!               {
!                       if ($this->so->saveCategoryLang($cat_id, $cat_name, 
$cat_description, $lang))
!                       {
!                               return true;
!                       }
!                       return false;
!               }
                
!               //$force is for bypassing ACL when we called from Sites_UI for 
building up the info for the currentsite
!               //and for getting at archived categories that are not listed in 
current nor readablecats
!               function getCategory($cat_id,$lang=False,$force=False)
                {
!                       if ($force || ($this->check($cat_id) && 
in_array($cat_id,$this->readablecats)))
                        {
                                return $this->so->getCategory($cat_id,$lang);
***************
*** 202,209 ****
                function getCategoryancestorids($cat_id,$permittedonly=False)
                {
                        $result = array();
!                       while ($cat_id != 0)
                        {
!                               if (!$permittedonly || 
$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
                                {
                                        $result[] = $cat_id;
--- 226,241 ----
                function getCategoryancestorids($cat_id,$permittedonly=False)
                {
+                       if (!$cat_id)
+                       {
+                               $cat_id = CURRENT_SITE_ID;
+                       }
+                       if ($cat_id != CURRENT_SITE_ID)
+                       {
+                               $this->check($cat_id);
+                       }
                        $result = array();
!                       while ($cat_id != CURRENT_SITE_ID)
                        {
!                               if (!$permittedonly || 
in_array($cat_id,$this->readablecats))
                                {
                                        $result[] = $cat_id;
***************
*** 216,222 ****
  
                function getlangarrayforcategory($cat_id)
!                 {
!                   return $this->so->getlangarrayforcategory($cat_id);
!                 }
  
                function saveCategoryPerms($cat_id, $group_access, $user_access)
--- 248,254 ----
  
                function getlangarrayforcategory($cat_id)
!               {
!                       return $this->so->getlangarrayforcategory($cat_id);
!               }
  
                function saveCategoryPerms($cat_id, $group_access, $user_access)
***************
*** 260,263 ****
--- 292,297 ----
                                                                        break;
                                                                case 'write':
+                                                                       //write 
access implies read access, otherwise editing blocks would not work
+                                                                       
$can_read = true;
                                                                        
$can_write = true;
                                                                        break;
***************
*** 288,292 ****
                function applyCategoryPermstosubs($cat_id)
                {
!                       $sublist = $this->getPermittedCatWriteNested($cat_id);
  
                        while (list(,$sub) = @each($sublist))
--- 322,326 ----
                function applyCategoryPermstosubs($cat_id)
                {
!                       $sublist = $this->getpermittedcatsWrite($cat_id);
  
                        while (list(,$sub) = @each($sublist))
***************
*** 304,307 ****
--- 338,373 ----
                {
                        $this->so->migratealllang($oldlang,$newlang);
+               }
+ 
+               //make sure cat_id belongs to current site
+               function check($cat_id)
+               {
+                       if (in_array($cat_id,$this->currentcats))
+                       {
+                               return True;
+                       }
+                       else
+                       {
+ print_r($this->currentcats);
+ var_dump(debug_backtrace());
+                               echo '<p><center><b>'.lang('Attempt to access 
information outside current website').'</b></center>';
+                               $GLOBALS['phpgw']->common->phpgw_exit(True);
+                       }
+               }
+ 
+               function commit($cat_id)
+               {
+                       if ($GLOBALS['Common_BO']->acl->is_admin())
+                       {
+                               $this->so->commit($cat_id);
+                       }
+               }
+ 
+               function reactivate($cat_id)
+               {
+                       if ($GLOBALS['Common_BO']->acl->is_admin())
+                       {
+                               $this->so->reactivate($cat_id);
+                       }
                }
        }

Index: class.Categories_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_SO.inc.php,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -C2 -r1.13 -r1.13.2.1
*** class.Categories_SO.inc.php 28 Jan 2003 20:00:00 -0000      1.13
--- class.Categories_SO.inc.php 23 Jun 2003 20:31:20 -0000      1.13.2.1
***************
*** 4,46 ****
                var $cats;
                var $db;
                
                function Categories_SO()
                {
                        $this->cats = 
CreateObject('phpgwapi.categories',-1,'sitemgr');
!                       $this->db = $GLOBALS['phpgw']->db;
                }
  
!               function getChildrenIDList($parent=0)
                {
!                       if ($parent)
                        {
!                               $cats = 
$this->cats->return_array('all','',False,'','','',False,$parent);
                        }
!                       else
!                       {
!                               $cats = 
$this->cats->return_array('mains','',False,'','','',False, 0);
!                       }
!                       while (list(,$subs) = @each($cats))
!                       {
!                               if ($subs['parent']==$parent)
!                               {
!                                       $subs_id_list[] = $subs['id'];
!                               }
!                       }
!                       return $subs_id_list;
                }
  
!               function getFullCategoryIDList()
                {
!                       $cats = 
$this->cats->return_array('all','',False,'','','',False);
  
!                       while (list(,$cat) = @each($cats))
                        {
!                               $cat_id_list[] = $cat['id'];
                        }
!                       return $cat_id_list;
                }
  
!               function addCategory($name, $description, $parent = '')
                {
                        $data = array
--- 4,41 ----
                var $cats;
                var $db;
+               var $site_id;
                
                function Categories_SO()
                {
                        $this->cats = 
CreateObject('phpgwapi.categories',-1,'sitemgr');
!                       $this->db = $GLOBALS['phpgw']->db;                      
 
                }
  
!               function isactive($cat_id,$states=false)
                {
!                       if (!$states)
                        {
!                               $states = $GLOBALS['Common_BO']->visiblestates;
                        }
!                       $sql = "SELECT cat_id from 
phpgw_sitemgr_categories_state WHERE cat_id = $cat_id AND state IN (" . 
implode(',',$states) . ")";
! 
!                       $this->db->query($sql,__LINE__,__FILE__);
!                       return $this->db->next_record();
                }
  
!               function getChildrenIDList($parent)
                {
!                       //TODO add a return_id_array function to the API 
category class
!                       $cats = 
$this->cats->return_array('all','',False,'','','',False,$parent);
!                       $result = array();
  
!                       while (list(,$subs) = @each($cats))
                        {
!                               $subs_id_list[] = $subs['id'];
                        }
!                       return $subs_id_list;
                }
  
!               function addCategory($name, $description, $parent = False)
                {
                        $data = array
***************
*** 52,57 ****
                                'old_parent' => $parent
                        );
! 
!                       return $this->cats->add($data);
                }
  
--- 47,54 ----
                                'old_parent' => $parent
                        );
!                       $cat_id =  $this->cats->add($data);
!                       $sql = "INSERT INTO phpgw_sitemgr_categories_state 
(cat_id) VALUES ($cat_id)";
!                       $this->db->query($sql, __LINE__,__FILE__);
!                       return $cat_id;
                }
  
***************
*** 59,62 ****
--- 56,63 ----
                {
                        $this->cats->delete($cat_id,False,True);
+                       $sql = "DELETE FROM phpgw_sitemgr_categories_lang WHERE 
cat_id = $cat_id";
+                       $this->db->query($sql, __LINE__,__FILE__);
+                       $sql = "DELETE FROM phpgw_sitemgr_categories_state 
WHERE cat_id = $cat_id";
+                       $this->db->query($sql, __LINE__,__FILE__);
                        return True;
                }
***************
*** 74,93 ****
                                'old_parent' => $cat_info->old_parent
                        );
- 
                        $this->cats->edit($data);
                }
  
                function saveCategoryLang($cat_id, $cat_name, $cat_description, 
$lang)
!                 {
!                   $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id' and lang='$lang'", 
__LINE__,__FILE__);
!                   if ($this->db->next_record())
!                     {
!                       $this->db->query("UPDATE phpgw_sitemgr_categories_lang 
SET name='$cat_name', description='$cat_description' WHERE cat_id='$cat_id' and 
lang='$lang'", __LINE__,__FILE__);
!                     }
!                   else
!                     {
!                       $this->db->query("INSERT INTO 
phpgw_sitemgr_categories_lang (cat_id,lang,name,description) VALUES 
('$cat_id','$lang','$cat_name','$cat_description')", __LINE__,__FILE__);
!                     }
!                 }
  
                function getlangarrayforcategory($cat_id)
--- 75,95 ----
                                'old_parent' => $cat_info->old_parent
                        );
                        $this->cats->edit($data);
+                       $sql = "UPDATE phpgw_sitemgr_categories_state SET state 
= " . $cat_info->state . " WHERE cat_id = " . $cat_info->id;
+                       $this->db->query($sql, __LINE__,__FILE__);
                }
  
                function saveCategoryLang($cat_id, $cat_name, $cat_description, 
$lang)
!               {
!                       $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id' and lang='$lang'", 
__LINE__,__FILE__);
!                       if ($this->db->next_record())
!                       {
!                               $this->db->query("UPDATE 
phpgw_sitemgr_categories_lang SET name='$cat_name', 
description='$cat_description' WHERE cat_id='$cat_id' and lang='$lang'", 
__LINE__,__FILE__);
!                       }
!                       else
!                       {
!                               $this->db->query("INSERT INTO 
phpgw_sitemgr_categories_lang (cat_id,lang,name,description) VALUES 
('$cat_id','$lang','$cat_name','$cat_description')", __LINE__,__FILE__);
!                       }
!               }
  
                function getlangarrayforcategory($cat_id)
***************
*** 116,150 ****
                                $cat_info->depth                = 
$cat[0]['level'];
                                $cat_info->root                 = 
$cat[0]['main'];
!                               
                                if ($lang)
!                                 {
!                                   $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id' and lang='$lang'");
!                                   if ($this->db->next_record())
!                                     {
!                                       $cat_info->name        = 
$this->db->f('name');
!                                       $cat_info->description = 
$this->db->f('description');
!                                     }
!                                   else
!                                     {
!                                       //return False;
!                                       $cat_info->name        = lang("not yet 
translated");
!                                     }
!                                 }
  
                                //if there is no lang argument we return the 
content in whatever languages turns up first
                                else
!                                 {
!                                   $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
!                                   if ($this->db->next_record())
!                                     {
!                                       $cat_info->name        = 
$this->db->f('name');
!                                       $cat_info->description = 
$this->db->f('description');
!                                       $cat_info->lang = $this->db->f('lang');
!                                     }
!                                   else
!                                     {
!                                       $cat_info->name = "This category has no 
data in any langugage: this should not happen";
!                                     }
!                                 }
                                
                                return $cat_info;
--- 118,155 ----
                                $cat_info->depth                = 
$cat[0]['level'];
                                $cat_info->root                 = 
$cat[0]['main'];
! 
!                               $this->db->query("SELECT state FROM 
phpgw_sitemgr_categories_state WHERE cat_id=$cat_id");
!                               $cat_info->state = $this->db->next_record() ? 
$this->db->f('state') : 0;
! 
                                if ($lang)
!                               {
!                                       $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id=$cat_id and lang='$lang'");
!                                       if ($this->db->next_record())
!                                       {
!                                               $cat_info->name = 
$this->db->f('name');
!                                               $cat_info->description = 
$this->db->f('description');
!                                       }
! //                                    else
! //                                    {
! //                                            //return False;
! //                                            $cat_info->name = lang("not yet 
translated");
! //                                    }
!                               }
  
                                //if there is no lang argument we return the 
content in whatever languages turns up first
                                else
!                               {
!                                       $this->db->query("SELECT * FROM 
phpgw_sitemgr_categories_lang WHERE cat_id='$cat_id'");
!                                       if ($this->db->next_record())
!                                       {
!                                               $cat_info->name = 
$this->db->f('name');
!                                               $cat_info->description = 
$this->db->f('description');
!                                               $cat_info->lang = 
$this->db->f('lang');
!                                       }
!                                       else
!                                       {
!                                               $cat_info->name = "This 
category has no data in any langugage: this should not happen";
!                                       }
!                               }
                                
                                return $cat_info;
***************
*** 165,168 ****
--- 170,187 ----
                {
                        $sql = "UPDATE phpgw_sitemgr_categories_lang SET 
lang='$newlang' WHERE lang='$oldlang'";
+                       $this->db->query($sql, __LINE__,__FILE__);
+               }
+ 
+               function commit($cat_id)
+               {
+                       $sql = "UPDATE phpgw_sitemgr_categories_state SET state 
= " . SITEMGR_STATE_PUBLISH . " WHERE state = " . SITEMGR_STATE_PREPUBLISH . " 
AND cat_id = $cat_id";
+                       $this->db->query($sql, __LINE__,__FILE__);
+                       $sql = "UPDATE phpgw_sitemgr_categories_state SET state 
= " . SITEMGR_STATE_ARCHIVE . " WHERE state = " . SITEMGR_STATE_PREUNPUBLISH . 
" AND cat_id = $cat_id";;
+                       $this->db->query($sql, __LINE__,__FILE__);
+               }
+ 
+               function reactivate($cat_id)
+               {
+                       $sql = "UPDATE phpgw_sitemgr_categories_state SET state 
= " . SITEMGR_STATE_DRAFT . " WHERE state = " . SITEMGR_STATE_ARCHIVE . " AND 
cat_id = $cat_id";
                        $this->db->query($sql, __LINE__,__FILE__);
                }

Index: class.Categories_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Categories_UI.inc.php,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -r1.1 -r1.1.2.1
*** class.Categories_UI.inc.php 17 Jan 2003 03:37:52 -0000      1.1
--- class.Categories_UI.inc.php 23 Jun 2003 20:31:20 -0000      1.1.2.1
***************
*** 13,18 ****
        {
                var $common_ui;
-               var $cat;
-               var $cat_list;
                var $cat_bo;
                var $acl;
--- 13,16 ----
***************
*** 23,29 ****
                var $public_functions = array
                (
!                       '_manageCategories' => True,
!                       '_editCategory' => True,
!                       '_deleteCategory' => True
                );
                        
--- 21,26 ----
                var $public_functions = array
                (
!                       'edit' => True,
!                       'delete' => True
                );
                        
***************
*** 36,187 ****
                        $this->acl = $GLOBALS['Common_BO']->acl;
                        $this->isadmin = $this->acl->is_admin();
!                       $preferenceso = 
CreateObject('sitemgr.sitePreference_SO', true);
!                       $this->sitelanguages = 
explode(',',$preferenceso->getPreference('sitelanguages'));
                }
  
!               function _manageCategories()
!               {
!                       $this->common_ui->DisplayHeader();
! 
!                       $this->t->set_var(Array('category_manager' => 
lang('Category Manager'),
!                               'lang_catname' => lang('Category Name'),
!                               'lang_goto' => lang('Go to Page Manager')));    
                
!                       $this->t->set_file('ManageCategories', 
'manage_categories.tpl');
!                       $this->t->set_block('ManageCategories', 
'CategoryBlock', 'CBlock');
! 
!                       $this->cat_list = 
$this->cat_bo->getPermittedCatWriteNested();
!                       if($this->cat_list)
!                       {
!                               for($i = 0; $i < sizeof($this->cat_list); $i++)
!                               {
!                                       $this->cat = 
$this->cat_bo->getCategory($this->cat_list[$i],$this->sitelanguages[0]);
!                                       if ($this->cat->depth)
!                                       {
!                                               $buffer = '-';
!                                       }
!                                       else
!                                       {
!                                               $buffer = '';
!                                       }
!                                       $buffer = 
str_pad('',$this->cat->depth*18,
!                                               '&nbsp;',STR_PAD_LEFT).$buffer;
!                                       $cat_id = $this->cat_list[$i];
!                                       $this->t->set_var('buffer', $buffer);
!                                       $this->t->set_var('category', 
sprintf('%s : %d',$this->cat->name,$cat_id));
! 
! 
!                                       $link_data['page_id'] = 0;
!                                       $link_data['cat_id'] = $cat_id;
!                                       if ($this->isadmin)
!                                       {
!                                               $this->t->set_var('edit', 
!                                                       '<form action="'.
!                                                       
$GLOBALS['phpgw']->link('/index.php',
!                                                       
'menuaction=sitemgr.Categories_UI._editCategory').
!                                                       '" method="POST"><input 
type="submit" value="' . lang('Edit') .'"><input type="hidden" name="cat_id" 
value="'.$cat_id.'">
!                                                       </form>');
!                                       
!                                               $this->t->set_var('remove',
!                                                       '<form action="'.
!                                                       
$GLOBALS['phpgw']->link('/index.php',
!                                                       
'menuaction=sitemgr.Categories_UI._deleteCategory').
!                                                       '" method="POST">
!                                                       <input type="submit" 
value="' . lang('Delete') .'">
!                                                       <input type="hidden" 
name="cat_id" value="'. $cat_id  .'">
!                                                       </form>');
! 
!                                               $link_data['menuaction'] = 
"sitemgr.Modules_UI._manageModules";
!                                               
$this->t->set_var('moduleconfig',
!                                                       '<form action="'.
!                                                       
$GLOBALS['phpgw']->link('/index.php',$link_data).
!                                                       '" method="POST">
!                                                       <input type="submit" 
value="' . lang('Manage Modules') .'"></form>');
!                                       }
! 
!                                       $link_data['menuaction'] = 
"sitemgr.Content_UI._manageContent";
!                                       $this->t->set_var('content',
!                                               '<form action="'.
!                                               
$GLOBALS['phpgw']->link('/index.php',$link_data).
!                                               '" method="POST">
!                                               <input type="submit" value="' . 
lang('Manage Content') .'"></form>');
! 
!                                       $this->t->parse('CBlock', 
'CategoryBlock', True);
!                               }
!                       }
!                       else
!                       {
!                               $this->t->set_var('category','No category is 
available');
!                       }
! 
!                       $this->t->set_var('add', 
!                               '<form action="'.
!                               $GLOBALS['phpgw']->link('/index.php',
!                               
'menuaction=sitemgr.Categories_UI._editCategory').
!                               '" method="POST">
!                               <input type=submit value = "' . lang('Add a 
category') .'">
!                               </form>'
!                       );
!                       
$this->t->set_var('managepageslink',$GLOBALS['phpgw']->link(
!                               '/index.php',
!                               'menuaction=sitemgr.Pages_UI._managePage')
!                       );
!                       $this->t->pfp('out', 'ManageCategories');       
! 
!                       $this->common_ui->DisplayFooter();
!               }
! 
!               function _editCategory()
                {
                        if (!$this->isadmin)
                        {
!                               $this->_manageCategories();
                                return False;
                        }
  
!                       
$GLOBALS['Common_BO']->globalize(array('btnSave','catname','catdesc','cat_id','sort_order','parent','parent_old','groupaccessread','groupaccesswrite','individualaccessread','individualaccesswrite','savelanguage','inputgetparentpermissions','inputapplypermissionstosubs'));
  
!                       global $btnSave, 
$cat_id,$catname,$catdesc,$sort_order,$parent,$parent_old;
!                       global $groupaccessread, $groupaccesswrite, 
$individualaccessread, $individualaccesswrite;
                        global $savelanguage, 
$inputgetparentpermissions,$inputapplypermissionstosubs;
  
!                       if ($btnSave && $catname && $catdesc)
                        {
!                               if (!$cat_id)
                                {
!                                       
$cat_id=$this->cat_bo->addCategory('','');
!                               }
!                               $groupaccess = 
array_merge_recursive($groupaccessread, $groupaccesswrite);
!                               $individualaccess = 
array_merge_recursive($individualaccessread, $individualaccesswrite);
!                               $savelanguage = $savelanguage ? $savelanguage : 
$this->sitelanguages[0];
!                               $this->cat_bo->saveCategoryInfo($cat_id, 
$catname, $catdesc, $savelanguage, $sort_order, $parent, $parent_old);
!                               if ($inputgetparentpermissions)
!                               {
!                                       
$this->cat_bo->saveCategoryPermsfromparent($cat_id);
                                }
                                else
                                {
!                                       
$this->cat_bo->saveCategoryPerms($cat_id, $groupaccess, $individualaccess);
!                               }
!                               if ($inputapplypermissionstosubs)
!                               {
!                                       
$this->cat_bo->applyCategoryPermstosubs($cat_id);
                                }
-                               $this->_manageCategories();
-                               return;
                        }
  
-                       $this->common_ui->DisplayHeader();
- 
                        if ($cat_id)
                        {
!                               $this->cat = 
$this->cat_bo->getCategory($cat_id,$this->sitelanguages[0]); 
!                       }
! 
!                       //if the user tried to save, but catname or catdesc 
were empty, we remember the modified values
!                       if ($btnSave)
!                       {
!                               $this->t->set_var('error_msg',lang('You failed 
to fill in one or more required fields.'));
!                               $this->cat->name = $catname;
!                               $this->cat->description = $catdesc;
                        }
  
--- 33,93 ----
                        $this->acl = $GLOBALS['Common_BO']->acl;
                        $this->isadmin = $this->acl->is_admin();
!                       $this->sitelanguages = 
$GLOBALS['Common_BO']->sites->current_site['sitelanguages'];
                }
  
!               function edit()
                {
                        if (!$this->isadmin)
                        {
!                               
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
                                return False;
                        }
  
!                       $GLOBALS['Common_BO']->globalize(array(
!                               
'btnSave','inputcatname','inputcatdesc','inputcatid','inputsortorder','inputparent','inputstate',
!                               
'inputparentold','savelanguage','inputgetparentpermissions','inputapplypermissionstosubs',
!                               
'inputgroupaccessread','inputgroupaccesswrite','inputindividualaccessread','individualaccesswrite'
!                       ));
  
!                       global $btnSave, 
$inputcatid,$inputcatname,$inputcatdesc,$inputsortorder,$inputparent,$inputparentold,$inputstate;
!                       global $inputgroupaccessread, $inputgroupaccesswrite, 
$inputindividualaccessread, $inputindividualaccesswrite;
                        global $savelanguage, 
$inputgetparentpermissions,$inputapplypermissionstosubs;
+                       $cat_id = $inputcatid ? $inputcatid : $_GET['cat_id'];
  
!                       if ($btnSave && $inputcatname && $inputcatdesc)
                        {
!                               if ($inputcatname == '' || $inputcatdesc == '')
                                {
!                                       $error = lang('You failed to fill in 
one or more required fields.');
!                                       $this->t->set_var('message',$error);
                                }
                                else
                                {
!                                       $cat_id =  $cat_id ? $cat_id : 
$this->cat_bo->addCategory('','');
! 
!                                       $groupaccess = 
array_merge_recursive($inputgroupaccessread, $inputgroupaccesswrite);
!                                       $individualaccess = 
array_merge_recursive($inputindividualaccessread, $inputindividualaccesswrite);
!                                       $savelanguage = $savelanguage ? 
$savelanguage : $this->sitelanguages[0];
!                                       
$this->cat_bo->saveCategoryInfo($cat_id, $inputcatname, $inputcatdesc, 
$savelanguage, $inputsortorder, $inputstate, $inputparent, $inputparentold);
!                                       if ($inputgetparentpermissions)
!                                       {
!                                               
$this->cat_bo->saveCategoryPermsfromparent($cat_id);
!                                       }
!                                       else
!                                       {
!                                               
$this->cat_bo->saveCategoryPerms($cat_id, $groupaccess, $individualaccess);
!                                       }
!                                       if ($inputapplypermissionstosubs)
!                                       {
!                                               
$this->cat_bo->applyCategoryPermstosubs($cat_id);
!                                       }
!                                       
$this->t->set_var('message',lang('Category saved'));
                                }
                        }
  
                        if ($cat_id)
                        {
!                               //we use force here since we might edit an 
archive category
!                               $cat = 
$this->cat_bo->getCategory($cat_id,$this->sitelanguages[0],True);
                        }
  
***************
*** 203,211 ****
                                'add_edit' => ($cat_id ? lang('Edit Category') 
: lang('Add Category')),
                                'cat_id' => $cat_id,
!                               'catname' => $this->cat->name,
!                               'catdesc' => $this->cat->description,
!                               'sort_order' => $this->cat->sort_order,
!                               'parent_dropdown' => 
$this->getParentOptions($this->cat->parent,$cat_id),
!                               'old_parent' => $this->cat->parent,
                                'lang_basic' => lang('Basic Settings'),
                                'lang_catname' => lang('Category Name'),
--- 109,118 ----
                                'add_edit' => ($cat_id ? lang('Edit Category') 
: lang('Add Category')),
                                'cat_id' => $cat_id,
!                               'catname' => $cat->name,
!                               'catdesc' => $cat->description,
!                               'sort_order' => $cat->sort_order,
!                               'parent_dropdown' => 
$this->getParentOptions($cat->parent,$cat_id),
!                               'stateselect' => 
$GLOBALS['Common_BO']->inputstateselect($cat->state),
!                               'old_parent' => $cat->parent,
                                'lang_basic' => lang('Basic Settings'),
                                'lang_catname' => lang('Category Name'),
***************
*** 217,226 ****
                                'lang_readperm' => lang('Read Permission'),
                                'lang_writeperm' => lang('Write Permission'),
!                               'lang_useraccess' => lang('Individual Access 
Permission'),
                                'lang_username' => lang('User Name'),
                                'lang_reset' => lang('Reset'),
                                'lang_save' => lang('Save'),
                                'lang_getparentpermissions' => lang('Fill in 
permissions from parent category? If you check this, below values will be 
ignored'),
!                               'lang_applypermissionstosubs' => lang('Apply 
permissions also to subcategories?')
                        ));
                
--- 124,136 ----
                                'lang_readperm' => lang('Read Permission'),
                                'lang_writeperm' => lang('Write Permission'),
!                               'lang_implies' => lang('implies read 
permission'),
!                               'lang_useraccess' => lang('Individual Access 
Permissions'),
                                'lang_username' => lang('User Name'),
                                'lang_reset' => lang('Reset'),
                                'lang_save' => lang('Save'),
+                               'lang_state' => lang('State'),
+                               'lang_done' => lang('Done'),
                                'lang_getparentpermissions' => lang('Fill in 
permissions from parent category? If you check this, below values will be 
ignored'),
!                               'lang_applypermissionstosubs' => lang('Apply 
permissions also to subcategories?'),
                        ));
                
***************
*** 235,242 ****
                                        
//$this->t->set_var('group_id',$permissionlist[$i]['account_id']);
                                        $account_name = 
$grouplist[$i]['account_lid'];
!                                       
$this->t->set_var('group_id',$grouplist[$i]['account_id']);
                                        if ($cat_id)
                                        {
!                                               $permission_id = 
$permissionlist[$i]['rights'];
                                        }
                                        else
--- 145,153 ----
                                        
//$this->t->set_var('group_id',$permissionlist[$i]['account_id']);
                                        $account_name = 
$grouplist[$i]['account_lid'];
!                                       $account_id = 
$grouplist[$i]['account_id'];
!                                       
$this->t->set_var('group_id',$account_id);
                                        if ($cat_id)
                                        {
!                                               $permission_id = 
$permissionlist[$account_id];
                                        }
                                        else
***************
*** 246,253 ****
  
                                        $this->t->set_var('groupname', 
$account_name);
-                                       if ($permission_id == PHPGW_ACL_ADD)
-                                       {
-                                               $permission_id = PHPGW_ACL_ADD 
| PHPGW_ACL_READ;
-                                       }
                                        if ($permission_id & PHPGW_ACL_READ)  
                                        {
--- 157,160 ----
***************
*** 284,290 ****
                                {
                                        $user_name = 
$userlist[$i]['account_lid'];
                                        if ($cat_id)
                                        {
!                                               $user_permission_id = 
$userpermissionlist[$i]['rights'];
                                        }
                                        else
--- 191,198 ----
                                {
                                        $user_name = 
$userlist[$i]['account_lid'];
+                                       $user_id = $userlist[$i]['account_id'];
                                        if ($cat_id)
                                        {
!                                               $user_permission_id = 
$userpermissionlist[$user_id];
                                        }
                                        else
***************
*** 292,302 ****
                                                $user_permission_id = 0;
                                        }
!                                       $this->t->set_var('user_id', 
$userlist[$i]['account_id']);
                                        
                                        $this->t->set_var('username', 
$user_name);
-                                       if ($user_permission_id == 
PHPGW_ACL_ADD)
-                                       {
-                                               $user_permission_id = 
PHPGW_ACL_ADD | PHPGW_ACL_READ;
-                                       }
                                        if ($user_permission_id & 
PHPGW_ACL_READ )
                                        {
--- 200,206 ----
                                                $user_permission_id = 0;
                                        }
!                                       $this->t->set_var('user_id', $user_id);
                                        
                                        $this->t->set_var('username', 
$user_name);
                                        if ($user_permission_id & 
PHPGW_ACL_READ )
                                        {
***************
*** 339,343 ****
                                $skip_id = -1;
                        }
!                       $retval="\n".'<SELECT NAME="parent">'."\n";
                        foreach($option_list as $option)
                        {
--- 243,247 ----
                                $skip_id = -1;
                        }
!                       $retval="\n".'<SELECT NAME="inputparent">'."\n";
                        foreach($option_list as $option)
                        {
***************
*** 357,379 ****
                }
  
!               function _deleteCategory()
                {
                        if (!$this->isadmin)
                        {
!                               $this->_manageCategories();
                                return;
                        }
  
!                       
$GLOBALS['Common_BO']->globalize(array('cat_id','btnDelete','btnCancel'));
!                       global $cat_id,$btnDelete,$btnCancel;
                        if ($btnDelete)
                        {
                                $this->cat_bo->removeCategory($cat_id);
!                               $this->_manageCategories();
                                return;
                        }
                        if ($btnCancel)
                        {
!                               $this->_manageCategories();
                                return;
                        }
--- 261,285 ----
                }
  
!               function delete()
                {
                        if (!$this->isadmin)
                        {
!                               
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
                                return;
                        }
  
!                       
$GLOBALS['Common_BO']->globalize(array('btnDelete','btnCancel'));
!                       global $btnDelete,$btnCancel;
!                       $cat_id = $_GET['cat_id'];
! 
                        if ($btnDelete)
                        {
                                $this->cat_bo->removeCategory($cat_id);
!                               
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
                                return;
                        }
                        if ($btnCancel)
                        {
!                               
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
                                return;
                        }
***************
*** 388,393 ****
                        $this->t->set_var('lang_no',lang('Cancel the delete'));
                        $this->t->pfp('out','ConfirmDelete');
- 
-                       $this->common_ui->DisplayFooter();
                }
        }
--- 294,297 ----

Index: class.Common_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Common_BO.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** class.Common_BO.inc.php     4 Apr 2003 18:37:45 -0000       1.1.2.1
--- class.Common_BO.inc.php     23 Jun 2003 20:31:21 -0000      1.1.2.2
***************
*** 3,10 ****
        class Common_BO
        {
!               var $acl,$theme,$pages,$cats,$content,$modules,$headerfooter;
! 
                function Common_BO()
                {
                        $this->acl = CreateObject('sitemgr.ACL_BO',True);
                        $this->theme = CreateObject('sitemgr.Theme_BO',True);
--- 3,12 ----
        class Common_BO
        {
!               var $sites,$acl,$theme,$pages,$cats,$content,$modules;
!               var $state,$visiblestates;
!               var $sitemenu,$othermenu;
                function Common_BO()
                {
+                       $this->sites = CreateObject('sitemgr.Sites_BO',True);
                        $this->acl = CreateObject('sitemgr.ACL_BO',True);
                        $this->theme = CreateObject('sitemgr.Theme_BO',True);
***************
*** 13,17 ****
                        $this->content = 
CreateObject('sitemgr.Content_BO',True);
                        $this->modules = 
CreateObject('sitemgr.Modules_BO',True);
!                       $this->headerfooter = 
CreateObject('sitemgr.headerFooter_BO', True);
                }
  
--- 15,48 ----
                        $this->content = 
CreateObject('sitemgr.Content_BO',True);
                        $this->modules = 
CreateObject('sitemgr.Modules_BO',True);
!                       $this->state = array(
!                               SITEMGR_STATE_DRAFT => lang('draft'),
!                               SITEMGR_STATE_PREPUBLISH => 
lang('prepublished'),
!                               SITEMGR_STATE_PUBLISH => lang('published'),
!                               SITEMGR_STATE_PREUNPUBLISH => 
lang('preunpublished'),
!                               SITEMGR_STATE_ARCHIVE => lang('archived'),
!                       );
!               }
! 
!               function setvisiblestates($mode)
!               {
!                       $this->visiblestates = $this->getstates($mode);
!               }
! 
!               function getstates($mode)
!               {
!                       switch ($mode)
!                       {
!                               case 'Administration' :
!                                       return 
array(SITEMGR_STATE_DRAFT,SITEMGR_STATE_PREPUBLISH,SITEMGR_STATE_PUBLISH,SITEMGR_STATE_PREUNPUBLISH);
!                               case 'Production' :
!                                       return 
array(SITEMGR_STATE_PUBLISH,SITEMGR_STATE_PREUNPUBLISH);
!                               case 'Draft' :
!                               case 'Edit' :
!                                       return 
array(SITEMGR_STATE_PREPUBLISH,SITEMGR_STATE_PUBLISH);
!                               case 'Commit' :
!                                       return 
array(SITEMGR_STATE_PREPUBLISH,SITEMGR_STATE_PREUNPUBLISH);
!                               case 'Archive' :
!                                       return array(SITEMGR_STATE_ARCHIVE);
!                       }
                }
  
***************
*** 32,40 ****
  
                function getlangname($lang)
!                 {
!                   $GLOBALS['phpgw']->db->query("select lang_name from 
phpgw_languages where lang_id = '$lang'",__LINE__,__FILE__);
!                   $GLOBALS['phpgw']->db->next_record();
!                   return $GLOBALS['phpgw']->db->f('lang_name');
!                 }
        }
  ?>
--- 63,143 ----
  
                function getlangname($lang)
!               {
!                       $GLOBALS['phpgw']->db->query("select lang_name from 
phpgw_languages where lang_id = '$lang'",__LINE__,__FILE__);
!                       $GLOBALS['phpgw']->db->next_record();
!                       return $GLOBALS['phpgw']->db->f('lang_name');
!               }
! 
!               function inputstateselect($default)
!               {
!                       $returnValue = '';
!                       foreach($this->state as $value => $display)
!                       {
!                               $selected = ($default == $value) ? $selected = 
'selected="selected" ' : '';
!                               $returnValue.='<option 
'.$selected.'value="'.$value.'">'.
!                                       $display.'</option>'."\n";
!                       }
!                       return $returnValue;
!               }
! 
!               function set_menus()
!               {
!                       $this->sitemenu = $this->get_sitemenu();
!                       $this->othermenu = $this->get_othermenu();
!               }
! 
!               function get_sitemenu()
!               {
!                       if ($GLOBALS['Common_BO']->acl->is_admin())
!                       {
!                               $file['Configure Website'] = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs');
!                               $link_data['cat_id'] = CURRENT_SITE_ID;
!                               $link_data['menuaction'] = 
"sitemgr.Modules_UI.manage";
!                               $file['Manage site-wide module properties'] = 
$GLOBALS['phpgw']->link('/index.php',$link_data);
!                               $link_data['page_id'] = 0;
!                               $link_data['menuaction'] = 
"sitemgr.Content_UI.manage";
!                               $file['Manage site-wide content'] = 
$GLOBALS['phpgw']->link('/index.php',$link_data);
!                       }
!                       $file['Manage Categories and pages'] = 
$GLOBALS['phpgw']->link('/index.php', 'menuaction=sitemgr.Outline_UI.manage');
!                       $file['Manage Translations'] = 
$GLOBALS['phpgw']->link('/index.php', 
'menuaction=sitemgr.Translations_UI.manage');
!                       $file['Commit Changes'] = 
$GLOBALS['phpgw']->link('/index.php', 'menuaction=sitemgr.Content_UI.commit');
!                       $file['Manage archived content'] = 
$GLOBALS['phpgw']->link('/index.php', 'menuaction=sitemgr.Content_UI.archive');
!                       $file['_NewLine_'] ='';
!                       $file['View Generated Site'] = 
$GLOBALS['phpgw']->link('/sitemgr-link/');
!                       return $file;
!               }
! 
!               function get_othermenu()
!               {
!                       $numberofsites = 
$GLOBALS['Common_BO']->sites->getnumberofsites();
!                       $isadmin = 
$GLOBALS['phpgw']->acl->check('run',1,'admin');
!                       if ($numberofsites < 2 && !$isadmin)
!                       {
!                               return false;
!                       }
!                       $menu_title = lang('Other websites');
!                       if ($numberofsites > 1)
!                       {
!                               $link_data['menuaction'] = 
'sitemgr.Common_UI.DisplayMenu';
!                               $sites = 
$GLOBALS['Common_BO']->sites->list_sites(False);
!                               while(list($site_id,$site) = @each($sites))
!                               {
!                                       if ($site_id != CURRENT_SITE_ID)
!                                       {
!                                               $link_data['siteswitch'] = 
$site_id;
!                                               $file[$site['site_name']] = 
$GLOBALS['phpgw']->link('/index.php',$link_data);
!                                       }
!                               }
!                       }
!                       if ($numberofsites > 1 && $isadmin)
!                       {
!                               $file['_NewLine_'] ='';
!                       }
!                       if ($isadmin)
!                       {
!                               $file['Define websites'] = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Sites_UI.list_sites');
!                       }
!                       return $file;
!               }                       
        }
  ?>

Index: class.Common_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Common_UI.inc.php,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -C2 -r1.8.2.2 -r1.8.2.3
*** class.Common_UI.inc.php     17 Jun 2003 21:41:13 -0000      1.8.2.2
--- class.Common_UI.inc.php     23 Jun 2003 20:31:21 -0000      1.8.2.3
***************
*** 12,19 ****
        class Common_UI
        {
!               var $t, $acl, $theme, $prefs_so;
                var $public_functions = array
                (
!                       'DisplayPrefs' => True
                );
  
--- 12,20 ----
        class Common_UI
        {
!               var $t, $acl, $theme, $do_sites_exist, $menu;
                var $public_functions = array
                (
!                       'DisplayPrefs' => True,
!                       'DisplayMenu' => True
                );
  
***************
*** 21,33 ****
                {
                        global $Common_BO;
!                       $Common_BO = CreateObject('sitemgr.Common_BO',True);
                        $this->t = $GLOBALS['phpgw']->template;
                        $this->acl = &$Common_BO->acl;
                        $this->theme = &$Common_BO->theme;
-                       $this->prefs_so = 
CreateObject('sitemgr.sitePreference_SO', True);
                        $this->pages_bo = &$Common_BO->pages;
                        $this->cat_bo = &$Common_BO->cats;
                }
  
                function DisplayPrefs()
                {
--- 22,77 ----
                {
                        global $Common_BO;
!                       $Common_BO = CreateObject('sitemgr.Common_BO');
!                       $this->do_sites_exist = 
$Common_BO->sites->set_currentsite(False,'Administration');
                        $this->t = $GLOBALS['phpgw']->template;
                        $this->acl = &$Common_BO->acl;
                        $this->theme = &$Common_BO->theme;
                        $this->pages_bo = &$Common_BO->pages;
                        $this->cat_bo = &$Common_BO->cats;
+                       $Common_BO->set_menus();
                }
  
+ 
+               function DisplayMenu()
+               {
+                       $this->DisplayHeader();
+                       $this->t->set_file('MainMenu','mainmenu.tpl');
+                       $this->t->set_block('MainMenu','switch','switchhandle');
+                       $this->t->set_block('MainMenu','menuentry','entry');
+                       $this->t->set_var('lang_sitemenu',lang('Website') . ' ' 
. $GLOBALS['Common_BO']->sites->current_site['site_name']);
+                       reset($GLOBALS['Common_BO']->sitemenu);
+                       while (list($display,$value) = 
@each($GLOBALS['Common_BO']->sitemenu))
+                       {
+                               if ($display == '_NewLine_')
+                               {
+                                       continue;
+                               }
+                               
$this->t->set_var(array('value'=>$value,'display'=>lang($display)));
+                               $this->t->parse('sitemenu','menuentry', true);
+                       }
+                       if ($GLOBALS['Common_BO']->othermenu)
+                       {
+                               $this->t->set_var('lang_othermenu',lang('Other 
websites'));
+                               reset($GLOBALS['Common_BO']->othermenu);
+                               while (list($display,$value) = 
@each($GLOBALS['Common_BO']->othermenu))
+                               {
+                                       if ($display == '_NewLine_')
+                                       {
+                                               continue;
+                                       }
+                                       
$this->t->set_var(array('value'=>$value,'display'=>lang($display)));
+                                       
$this->t->parse('othermenu','menuentry', true);
+                               }
+                               $this->t->parse('switchhandle','switch');
+                       }
+                       else
+                       {
+                               
$this->t->set_var('switchhandle','testtesttest');
+                       }
+                       $this->t->pfp('out','MainMenu');
+                       $this->DisplayFooter();
+               }
+ 
+ 
                function DisplayPrefs()
                {
***************
*** 51,55 ****
                                                                        
$GLOBALS['Common_BO']->getlangname($oldlang),
                                                                        
$GLOBALS['Common_BO']->getlangname($newlang)) . 
!                                                         '</b><br>';
                                                        
$this->pages_bo->migratealllang($oldlang,$newlang);
                                                        
$this->cat_bo->migratealllang($oldlang,$newlang);
--- 95,99 ----
                                                                        
$GLOBALS['Common_BO']->getlangname($oldlang),
                                                                        
$GLOBALS['Common_BO']->getlangname($newlang)) . 
!                                                       '</b><br>';
                                                        
$this->pages_bo->migratealllang($oldlang,$newlang);
                                                        
$this->cat_bo->migratealllang($oldlang,$newlang);
***************
*** 61,73 ****
                                if ($_POST['btnSave'])
                                {
!                                       $preferences = array(
!                                               
'sitemgr-site-url','sitemgr-site-dir','home-page-id',
!                                               
'anonymous-user','anonymous-passwd','themesel','sitelanguages');
  
!                                       $oldsitelanguages = 
$this->prefs_so->getPreference('sitelanguages');
!                                       if ($oldsitelanguages && 
($oldsitelanguages != $_POST['sitelanguages']))
                                        {
                                                $oldsitelanguages = 
explode(',',$oldsitelanguages);
!                                               $newsitelanguages = 
explode(',',$_POST['sitelanguages']);
                                                $replacedlang = 
array_diff($oldsitelanguages,$newsitelanguages);
                                                $addedlang = 
array_diff($newsitelanguages,$oldsitelanguages);
--- 105,114 ----
                                if ($_POST['btnSave'])
                                {
!                                       $oldsitelanguages = 
$GLOBALS['Common_BO']->sites->current_site['site_languages'];
  
!                                       if ($oldsitelanguages && 
($oldsitelanguages != $_POST['pref']['site_languages']))
                                        {
                                                $oldsitelanguages = 
explode(',',$oldsitelanguages);
!                                               $newsitelanguages = 
explode(',',$_POST['pref']['site_languages']);
                                                $replacedlang = 
array_diff($oldsitelanguages,$newsitelanguages);
                                                $addedlang = 
array_diff($newsitelanguages,$oldsitelanguages);
***************
*** 75,79 ****
                                                {
                                                        echo lang('You removed 
one ore more languages from your site languages.') . '<br>' .
!                                                         lang('What do you 
want to do with existing translations of categories and pages for this 
language?') . '<br>';
                                                        if ($addedlang)
                                                        {
--- 116,120 ----
                                                {
                                                        echo lang('You removed 
one ore more languages from your site languages.') . '<br>' .
!                                                       lang('What do you want 
to do with existing translations of categories and pages for this language?') . 
'<br>';
                                                        if ($addedlang)
                                                        {
***************
*** 85,90 ****
                                                        }
                                                        echo '<form action="' . 
!                                                         
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs')
 .
!                                                         '" 
method="post"><table>';
                                                        foreach ($replacedlang 
as $oldlang)
                                                        {
--- 126,131 ----
                                                        }
                                                        echo '<form action="' . 
!                                                       
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs')
 .
!                                                       '" 
method="post"><table>';
                                                        foreach ($replacedlang 
as $oldlang)
                                                        {
***************
*** 96,101 ****
                                                                        {
                                                                                
echo '<td><input type="radio" name="change[' . $oldlang . 
!                                                                               
  ']" value="' . $newlang . '"> Migrate to ' . 
!                                                                               
  $GLOBALS['Common_BO']->getlangname($newlang) . "</td>";
                                                                        }
                                                                }
--- 137,142 ----
                                                                        {
                                                                                
echo '<td><input type="radio" name="change[' . $oldlang . 
!                                                                               
']" value="' . $newlang . '"> Migrate to ' . 
!                                                                               
$GLOBALS['Common_BO']->getlangname($newlang) . "</td>";
                                                                        }
                                                                }
***************
*** 103,145 ****
                                                        }
                                                        echo '<tr><td><input 
type="submit" name="btnlangchange" value="' . 
!                                                         lang('Submit') . 
'"></td></tr></table></form>';
                                                }
                                        }
  
                                        $oldsitelanguages = $oldsitelanguages ? 
explode(',',$oldsitelanguages) : array("en");
-                                       foreach ($oldsitelanguages as $lang)
-                                       {
-                                               
array_push($preferences,'sitemgr-site-name-' . $lang);
-                                       }
  
!                                       foreach ($preferences as $name)
!                                       {
!                                               
$this->prefs_so->setPreference($name,$_POST[$name]);
!                                       }
                                        echo '<p><b>' . lang('Changes Saved.') 
. '</b></p>';
-                                       unset($preferences);
                                }
!                               
!                               $sitelanguages = 
explode(',',$this->prefs_so->getPreference('sitelanguages'));
!                               $sitelanguages = $sitelanguages ? 
$sitelanguages : array("en");
!                               
!                               foreach ($sitelanguages as $lang)
!                                 {
!                                   $preferences['sitemgr-site-name-' . $lang] 
= array(
!                                       'title'=>lang('Site name'). ' ' . 
$GLOBALS['Common_BO']->getlangname($lang),
!                                       'note'=>lang('This is used chiefly for 
meta data and the title bar. If you change the site languages below you have to 
save before being able to set this preference for a new language.'),
!                                       'default'=>lang('New sitemgr site')
!                                   );
!                                 }
! 
!                               $preferences['sitemgr-site-url']=array(
!                                       'title'=>lang('URL to sitemgr-site'),
!                                       'note'=>lang('The URL can be relative 
or absolute.  Name must end in a slash.')
!                               );
!                               $preferences['sitemgr-site-dir']=array(
!                                       'title'=>lang('Filesystem path to 
sitemgr-site directory'),
!                                       'note'=>lang('This must be an absolute 
directory location.  <b>No trailing slash</b>.')
!                               );
!                               $preferences['home-page-id'] = array(
                                        'title'=>lang('Default home page ID 
number'),
                                        'note'=>lang('This should be a page 
that is readable by everyone. If you leave this blank, the site index will be 
shown by default.'),
--- 144,174 ----
                                                        }
                                                        echo '<tr><td><input 
type="submit" name="btnlangchange" value="' . 
!                                                       lang('Submit') . 
'"></td></tr></table></form>';
                                                }
                                        }
  
                                        $oldsitelanguages = $oldsitelanguages ? 
explode(',',$oldsitelanguages) : array("en");
  
!                                       
$GLOBALS['Common_BO']->sites->saveprefs($_POST['pref']);
! 
                                        echo '<p><b>' . lang('Changes Saved.') 
. '</b></p>';
                                }
! 
!                               foreach 
($GLOBALS['Common_BO']->sites->current_site['sitelanguages'] as $lang)
!                               {
!                                       $langname = 
$GLOBALS['Common_BO']->getlangname($lang);
!                                       $preferences['site_name_' . $lang] = 
array(
!                                               'title'=>lang('Site name'). ' ' 
. $langname,
!                                               'note'=>lang('This is used 
chiefly for meta data and the title bar. If you change the site languages below 
you have to save before being able to set this preference for a new language.'),
!                                               'default'=>lang('New sitemgr 
site')
!                                       );
!                                        $preferences['site_desc_' . $lang] = 
array(
!                                               'title'=>lang('Site 
description'). ' ' . $langname,
!                                               'note'=>lang('This is used 
chiefly for meta data. If you change the site languages below you have to save 
before being able to set this preference for a new language.'),
!                                               'input'=>'textarea'
!                                       );
!                               }
! 
!                               $preferences['home_page_id'] = array(
                                        'title'=>lang('Default home page ID 
number'),
                                        'note'=>lang('This should be a page 
that is readable by everyone. If you leave this blank, the site index will be 
shown by default.'),
***************
*** 147,166 ****
                                        
'options'=>$this->pages_bo->getPageOptionList()
                                );
- // this does not seem to be used anywhere
- //                            $preferences['login-domain'] = array(
- //                                    'title'=>lang('Anonymous user login 
domain'),
- //                                    'note'=>'If you\'re not sure, enter 
Default.',
- //                                    'default'=>'Default'
- //                            );
-                               $preferences['anonymous-user'] = array(
-                                       'title'=>lang('Anonymous user\'s 
username'),
-                                       'note'=>lang('If you haven\'t done so 
already, create a user that will be used for public viewing of the site.  
Recommended name: anonymous.'),
-                                       'default'=>'anonymous'
-                               );
-                               $preferences['anonymous-passwd'] = array(
-                                       'title'=>lang('Anonymous user\'s 
password'),
-                                       'note'=>lang('Password that you 
assigned for the anonymous user account.'),
-                                       'default'=>'anonymous'
-                               );
                                $preferences['themesel'] = array(
                                        'title'=>lang('Template select'),
--- 176,179 ----
***************
*** 170,174 ****
                                        'default'=>'NukeNews'
                                );
!                               $preferences['sitelanguages'] = array(
                                        'title'=>lang('Languages the site user 
can choose from'),
                                        'note'=>lang('This should be a 
comma-separated list of language-codes.'),
--- 183,187 ----
                                        'default'=>'NukeNews'
                                );
!                               $preferences['site_languages'] = array(
                                        'title'=>lang('Languages the site user 
can choose from'),
                                        'note'=>lang('This should be a 
comma-separated list of language-codes.'),
***************
*** 187,191 ****
                                                        'lang_edit_config_inc}' 
=> lang('The config.inc.php file needs to be edited to point to the 
phpGroupWare directory. Copy the config.inc.php.template file to config.inc.php 
and then edit it.')
                                ));
!                                                      
                                
$this->t->set_block('sitemgr_prefs','PrefBlock','PBlock');
                                reset($preferences);
--- 200,204 ----
                                                        'lang_edit_config_inc}' 
=> lang('The config.inc.php file needs to be edited to point to the 
phpGroupWare directory. Copy the config.inc.php.template file to config.inc.php 
and then edit it.')
                                ));
! 
                                
$this->t->set_block('sitemgr_prefs','PrefBlock','PBlock');
                                reset($preferences);
***************
*** 195,198 ****
--- 208,214 ----
                                        switch($details['input'])
                                        {
+                                               case 'textarea':
+                                                       $inputbox = 
$this->inputtextarea($name);
+                                                       break;
                                                case 'checkbox':
                                                        $inputbox = 
$this->inputCheck($name);
***************
*** 227,231 ****
                                $size=40;
                        }
!                       $val = $this->prefs_so->getPreference($name);
                        if (!$val)
                        {
--- 243,247 ----
                                $size=40;
                        }
!                       $val = 
$GLOBALS['Common_BO']->sites->current_site[$name];
                        if (!$val)
                        {
***************
*** 234,243 ****
  
                        return '<input type="text" size="'.$size.
!                               '" name="'.$name.'" value="'.$val.'">';
                }
  
                function inputCheck($name = '')
                {
!                       $val = $this->prefs_so->getPreference($name);
                        if ($val)
                        {
--- 250,271 ----
  
                        return '<input type="text" size="'.$size.
!                               '" name="pref['.$name.']" value="'.$val.'">';
!               }
! 
!               function inputtextarea($name='',$cols=40,$rows=5,$default='')
!               {
!                       $val = 
$GLOBALS['Common_BO']->sites->current_site[$name];
!                       if (!$val)
!                       {
!                               $val = $default;
!                       }
! 
!                       return '<textarea cols="' . $cols . '" rows="' . $rows 
. 
!                               '" name="pref['.$name.']">'. 
$GLOBALS['phpgw']->strip_html($val).'</textarea>';
                }
  
                function inputCheck($name = '')
                {
!                       $val = 
$GLOBALS['Common_BO']->sites->current_site[$name];
                        if ($val)
                        {
***************
*** 250,254 ****
                                $checked_no = ' CHECKED';
                        }
!                       return '<INPUT TYPE="radio" NAME="'.$name.'" VALUE="1"'.
                                $checked_yes.'>Yes</INPUT>'."\n".
                                '<INPUT TYPE="radio" NAME="'.$name.'" 
VALUE="0"'.
--- 278,282 ----
                                $checked_no = ' CHECKED';
                        }
!                       return '<INPUT TYPE="radio" NAME="pref['.$name.']" 
VALUE="1"'.
                                $checked_yes.'>Yes</INPUT>'."\n".
                                '<INPUT TYPE="radio" NAME="'.$name.'" 
VALUE="0"'.
***************
*** 263,272 ****
                                return lang('No options available.');
                        }
!                       $val = $this->prefs_so->getPreference($name);
                        if(!$val)
                        {
                                $val = $default;
                        }
!                       $returnValue = '<SELECT NAME="'.$name.'">'."\n";
                        
                        foreach($options as $option)
--- 291,300 ----
                                return lang('No options available.');
                        }
!                       $val = 
$GLOBALS['Common_BO']->sites->current_site[$name];
                        if(!$val)
                        {
                                $val = $default;
                        }
!                       $returnValue = '<SELECT NAME="pref['.$name.']">'."\n";
                        
                        foreach($options as $option)
***************
*** 295,311 ****
                function DisplayHeader()
                {
!                       $GLOBALS['phpgw']->common->phpgw_header();
!                       echo parse_navbar();
!                       
$this->t->set_file('sitemgr_header','sitemgr_header.tpl');
!                       $this->t->set_var('mainmenu',
!                               $GLOBALS['phpgw']->link('/index.php',
!                               'menuaction=sitemgr.MainMenu_UI.DisplayMenu')
!                       );
!                       $this->t->set_var('sitemgr-site', 
$GLOBALS['phpgw']->link('/sitemgr-link/'));
!                       $this->t->set_var(Array('sitemgr_administration' => 
lang('Web Content Manager Administration'),
!                                               'view_menu' => lang('View 
Administrative Menu'),
!                                               'view_site' => lang('View 
Generated Site')
!                       ));
!                       $this->t->pfp('out','sitemgr_header');
                }
  
--- 323,358 ----
                function DisplayHeader()
                {
!                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
$GLOBALS['phpgw_info']['apps']['sitemgr']['title'];
! 
!                       if ($this->do_sites_exist)
!                       {
!                               if 
($GLOBALS['phpgw_info']['server']['template_set'] == 'idots')
!                               {
!                                       
$GLOBALS['phpgw']->common->phpgw_header();
!                                       echo parse_navbar();
!                                       return;
!                               }
!                               
$this->t->set_file('sitemgr_header','sitemgr_header.tpl');
!                               
$this->t->set_block('sitemgr_header','switch','switchhandle');
!                               
$this->t->set_var('menulist',$this->menuselectlist());
!                               if ($GLOBALS['Common_BO']->othermenu)
!                               {
!                                       
$this->t->set_var('sitelist',$this->siteselectlist());
!                                       
$this->t->parse('switchhandle','switch');
!                               }
!                               else
!                               {
!                                       $this->t->set_var('switchhandle','');
!                               }
!                               $GLOBALS['phpgw_info']['flags']['app_header'] 
.= $this->t->parse('out','sitemgr_header');
!                               $GLOBALS['phpgw']->common->phpgw_header();
!                               echo parse_navbar();
!                       }
!                       else
!                       {
!                               $GLOBALS['phpgw']->common->phpgw_header();
!                               echo lang('No websites defined');
!                               $GLOBALS['phpgw']->common->phpgw_exit(True);
!                       }
                }
  
***************
*** 314,317 ****
--- 361,396 ----
                        
$this->t->set_file('sitemgr_footer','sitemgr_footer.tpl');
                        $this->t->pfp('out','sitemgr_footer');
+               }
+ 
+               function siteselectlist()
+               {
+                       $selectlist= '<option>' . lang('Other websites') . 
'</option>';
+                       while(list($display,$value) = 
@each($GLOBALS['Common_BO']->othermenu))
+                       {
+                               if ($display == '_NewLine_')
+                               {
+                                       continue;
+                               }
+                               else
+                               {
+                                       $selectlist .= '<option 
onClick="location.href=this.value" value="' . $value . '">' . lang($display) . 
'</option>' . "\n";
+                               }
+                       }
+                       return $selectlist;
+               }
+ 
+               function menuselectlist()
+               {
+                       reset($GLOBALS['Common_BO']->sitemenu);
+                       $selectlist= '<option>' . lang('Website') . ' ' . 
$GLOBALS['Common_BO']->sites->current_site['site_name'] . '</option>';
+                       while(list($display,$value) = 
@each($GLOBALS['Common_BO']->sitemenu))
+                       {
+                               if ($display == '_NewLine_')
+                               {
+                                       continue;
+                               }
+                               $selectlist .= '<option 
onClick="location.href=this.value" value="' . $value . '">' . lang($display) . 
'</option>' . "\n";
+                       }
+                       return $selectlist;
                }
        }       

Index: class.Content_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Content_BO.inc.php,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** class.Content_BO.inc.php    4 Mar 2003 17:26:43 -0000       1.2
--- class.Content_BO.inc.php    23 Jun 2003 20:31:21 -0000      1.2.2.1
***************
*** 3,6 ****
--- 3,16 ----
  require_once(PHPGW_INCLUDE_ROOT . SEP . 'sitemgr' . SEP . 'inc' . SEP . 
'class.module.inc.php');
  
+ define('SITEMGR_STATE_DRAFT',0);
+ define('SITEMGR_STATE_PREPUBLISH',1);
+ define('SITEMGR_STATE_PUBLISH',2);
+ define('SITEMGR_STATE_PREUNPUBLISH',3);
+ define('SITEMGR_STATE_ARCHIVE',4);
+ 
+ define('SITEMGR_VIEWABLE_EVERBODY',0);
+ define('SITEMGR_VIEWABLE_USER',1);
+ define('SITEMGR_VIEWABLE_ADMIN',2);
+ define('SITEMGR_VIEWABLE_ANONYMOUS',3);
        class Content_BO
        {
***************
*** 10,24 ****
                {
                        $this->so = CreateObject('sitemgr.Content_SO', true);
-                       $prefs_so = CreateObject('sitemgr.sitePreference_SO', 
True);
-                       $sitemgr_dir = 
$prefs_so->getPreference('sitemgr-site-dir');
-                       $themesel = $prefs_so->getPreference('themesel');
-                       $this->templatefile = $sitemgr_dir . SEP . 'templates' 
. SEP . $themesel . SEP . 'main.tpl';
                }
  
                function getContentAreas()
                {
!                       $str = implode('', @file($this->templatefile));
!                       preg_match_all("/\{contentarea:([^{ 
]+)\}/",$str,$matches);
!                       return $matches[1];
                }
  
--- 20,46 ----
                {
                        $this->so = CreateObject('sitemgr.Content_SO', true);
                }
  
                function getContentAreas()
                {
!                       $templatefile =  
$GLOBALS['Common_BO']->sites->current_site['site_dir'] .  SEP . 'templates' . 
!                               SEP . 
$GLOBALS['Common_BO']->sites->current_site['themesel'] . SEP . 'main.tpl';
! 
!                       if (file_exists($templatefile))
!                       {
!                               $str = implode('', @file($templatefile));
!                               if (preg_match_all("/\{contentarea:([^{ 
]+)\}/",$str,$matches))
!                               {
!                                       return $matches[1];
!                               }
!                               else
!                               {
!                                       return lang('No content areas found in 
selected template');
!                               }
!                       }
!                       else
!                       {
!                               return lang('No template file found.');
!                       }
                }
  
***************
*** 41,98 ****
                }
  
!               function removeBlocksInPageOrCat($cat_id,$page_id)
                {
                        $blocks = 
$this->so->getblocksforscope($cat_id,$page_id);
                        while(list($blockid,) = each($blocks))
                        {
!                               $this->removeblock($blockid);
                        }
                }
  
!               function removeblock($blockid)
                {
!                       $block = $this->so->getblockdef($blockid);
!                       if 
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id))
                        {
!                               return $this->so->removeblock($blockid);
                        }
!                       else
                        {
!                               return false;
                        }
                }
  
!               //the next two functions retrieves all blocks for a certain 
area, if cat_id and page_id are 0, only site-wide blocks are retrieved.
!               //if cat_id is non zero and page_id is 0, site-wide blocks and 
all blocks for the category and all its ancestor categories are retrieved.
                //if page_id is non zero, cat_id should be the page's category. 
Page blocks + category blocks + site blocks are retrieved.
!               function getvisibleblockdefsforarea($area,$cat_id,$page_id)
                {
!                       $cat_ancestorlist = $cat_id ? 
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id,True) : False;
!                       if ($page_id && 
!$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
!                       {
!                          $page_id = False;
!                       }
!                       return 
$this->so->getvisibleblockdefsforarea($area,$cat_ancestorlist,$page_id,$visibleonly);
                }
  
                function getallblocksforarea($area,$cat_id,$page_id,$lang)
                {
!                       $cat_ancestorlist = $cat_id ? 
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id,True) : False;
!                       if ($page_id && 
!$GLOBALS['Common_BO']->acl->can_read_category($cat_id))
!                       {
!                          $page_id = False;
!                       }
                        return 
$this->so->getallblocksforarea($area,$cat_ancestorlist,$page_id,$lang);
                }
  
!               function getblock($block_id,$lang)
                {
                        //do we need ACL here, since we have ACL when getting 
the block lists, we could do without it here?
!                       return $this->so->getblock($block_id,$lang);
                }
  
!               function getlangarrayforblock($block_id)
                {
!                       return $this->so->getlangarrayforblock($block_id);
                }
  
--- 63,178 ----
                }
  
!               function createversion($blockid)
!               {
!                       return $this->so->createversion($blockid);
!               }
! 
!               function deleteversion($versionid,$force=False)
!               {
!                       if (!$force)
!                       {
!                               $blockid = 
$this->so->getblockidforversion($versionid);
!                               if (!$blockid)
!                               {
!                                       return false;
!                               }
!                               $block = $this->so->getblockdef($blockid);
!                               if (!($block && 
$GLOBALS['Common_BO']->acl->can_write_category($block->cat_id)))
!                               {
!                                       return false;
!                               }
!                       }
!                       return $this->so->deleteversion($versionid);
!               }
! 
!               function removeBlocksInPageOrCat($cat_id,$page_id,$force=False)
                {
+                       if (!($force || 
$GLOBALS['Common_BO']->acl->can_write_category($cat_id)))
+                       {
+                               return false;
+                       }
                        $blocks = 
$this->so->getblocksforscope($cat_id,$page_id);
                        while(list($blockid,) = each($blocks))
                        {
!                               $this->removeblock($blockid,True);
                        }
                }
  
!               function removeblock($blockid,$force=False)
                {
!                       if (!$force)
                        {
!                               $block = $this->so->getblockdef($blockid);
!                               if (!($block && 
$GLOBALS['Common_BO']->acl->can_write_category($block->cat_id)))
!                               {
!                                       return false;
!                               }
                        }
!                       if ($this->so->removeblock($blockid))
                        {
!                               $versions = 
$this->so->getversionidsforblock($blockid);
!                               while(list(,$versionid) = @each($versions))
!                               {
!                                       //since we already did the ACL we force
!                                       $this->deleteversion($versionid,True);
!                               }
!                               return true;
                        }
+                       return false;
                }
  
!               //the next two functions retrieves all blocks for a certain 
area, if (cat_id = $site_id and page_id = 0), only site-wide blocks are 
retrieved.
!               //if (cat_id != $site_id and page_id is 0), site-wide blocks 
and all blocks for the category and all its ancestor categories are retrieved.
                //if page_id is non zero, cat_id should be the page's category. 
Page blocks + category blocks + site blocks are retrieved.
!               //there is no ACL, since these functions are called in a 
context where getcategory and getpage have been called before and would have 
intercepted a breach
!               function 
getvisibleblockdefsforarea($area,$cat_id,$page_id,$isadmin,$isuser)
                {
!                       $cat_ancestorlist = ($cat_id != CURRENT_SITE_ID) ? 
!                               
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id,True) : 
!                               False;
!                       return 
$this->so->getvisibleblockdefsforarea($area,$cat_ancestorlist,$page_id,$isadmin,$isuser);
                }
  
                function getallblocksforarea($area,$cat_id,$page_id,$lang)
                {
!                       $cat_ancestorlist = ($cat_id != CURRENT_SITE_ID) ? 
!                               
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id,True) : 
!                               False;
                        return 
$this->so->getallblocksforarea($area,$cat_ancestorlist,$page_id,$lang);
                }
  
!               function getcommitableblocks()
!               {
!                       return 
$this->so->getallblocks($GLOBALS['Common_BO']->cats->getpermittedcatsWrite(),$GLOBALS['Common_BO']->getstates('Commit'));
!               }
! 
!               function getarchivedblocks()
!               {
!                       return 
$this->so->getallblocks($GLOBALS['Common_BO']->cats->getpermittedcatsWrite(),$GLOBALS['Common_BO']->getstates('Archive'));
!               }
!               function getallversionsforblock($blockid,$lang)
!               {
!                       return 
$this->so->getallversionsforblock($blockid,$lang);
!               }
! 
!               function getblock($id,$lang)
                {
                        //do we need ACL here, since we have ACL when getting 
the block lists, we could do without it here?
!                       return $this->so->getblock($id,$lang);
!               }
! 
!               function getlangblocktitle($block_id,$lang=false)
!               {
!                               return 
$this->so->getlangblocktitle($block_id,$lang);
                }
  
!               function getlangarrayforblocktitle($block_id)
                {
!                       return $this->so->getlangarrayforblocktitle($block_id);
!               }
! 
!               function getlangarrayforversion($version_id)
!               {
!                       return $this->so->getlangarrayforversion($version_id);
                }
  
***************
*** 111,132 ****
                }
  
!               function getlangblockdata($blockid,$lang)
                {
!                       //TODO: add ACL
!                       return $this->so->getlangblockdata($blockid,$lang);
                }
!               function saveblockdata($block,$data,$lang)
                {
                        $oldblock = $this->so->getblockdef($block->id);
!                       if 
($GLOBALS['Common_BO']->acl->can_write_category($oldblock->cat_id))
                        {
!                               
$this->so->saveblockdatalang($block,$data['i18n'],$lang);
!                               unset($data['i18n']);
!                               return $this->so->saveblockdata($block,$data);
                        }
!                       else
!                       {
!                               return false;
                        }
                }
  
--- 191,230 ----
                }
  
!               function getversion($version_id,$lang=False)
                {
!                       //TODO: add ACL ?
!                       return $this->so->getversion($version_id,$lang);
                }
! 
!               function saveblockdata($block,$data,$state,$lang)
                {
                        $oldblock = $this->so->getblockdef($block->id);
!                       if (!($oldblock && 
$GLOBALS['Common_BO']->acl->can_write_category($oldblock->cat_id)))
                        {
!                               return lang("You are not entitled to edit block 
%1",$block->id);
                        }
!                       $this->so->saveblockdata($block);
!                       
$this->so->saveblockdatalang($block->id,$block->title,$lang);
!                       if (!$this->saveversionstate($block->id,$state))
!                       {
!                               $validationerrors[] = lang('There can only be 
one version in (pre(un))published state, with the one exeption that one 
prepublished version can coexist with one preunpublished version');
!                       }
!                       $moduleobject = $this->getblockmodule($block->id);
!                       while (list($versionid,$versiondata) = @each($data))
!                       {
!                               if ($moduleobject->validate($versiondata))
!                               {
!                                       if 
($this->saveversiondatalang($block->id,$versionid,$versiondata['i18n'],$lang))
!                                       {
!                                               unset($versiondata['i18n']);
!                                               
$this->so->saveversiondata($block->id,$versionid,$versiondata);
!                                       }
!                               }
!                               if ($moduleobject->validation_error)
!                               {
!                                       $validationerrors[] = 
$moduleobject->validation_error;
!                               }
                        }
+                       return $validationerrors ? $validationerrors : True;
                }
  
***************
*** 134,140 ****
                {
                        $oldblock = $this->so->getblockdef($block->id);
!                       if 
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id))
                        {
!                               return 
$this->so->saveblockdatalang($block,$data['i18n'],$lang);
                        }
                        else
--- 232,272 ----
                {
                        $oldblock = $this->so->getblockdef($block->id);
!                       if (!($oldblock && 
$GLOBALS['Common_BO']->acl->can_write_category($oldblock->cat_id)))
                        {
!                               return lang("You are not entitled to edit block 
%1",$block->id);
!                       }
!                       
$this->so->saveblockdatalang($block->id,$block->title,$lang);
!                       $moduleobject = $this->getblockmodule($block->id);
!                       while (list($versionid,$versiondata) = @@each($data))
!                       //TODO: check if version really belongs to block
!                       {
!                               if ($moduleobject->validate($versiondata))
!                               {
!                                       
$this->saveversiondatalang($block->id,$versionid,$versiondata['i18n'],$lang);
!                               }
!                               else
!                               {
!                                       $validationerrors[] = 
$moduleobject->validation_error;
!                               }
!                       }
!                       return $validationerrors ? $validationerrors : True;
!               }
! 
!               //takes the array (version_id => version_state) posted from the 
UI as argument
!               //and checks if there is only one in (pre(un))published state 
!               //(exeption one prepublished, and one preunpublished can 
coexsit)
!               function saveversionstate($block_id,$state)
!               {
!                       $count_array = array_count_values($state);
!                       $active_versions = 
$count_array[SITEMGR_STATE_PREPUBLISH] + 
!                               $count_array[SITEMGR_STATE_PUBLISH] + 
!                               $count_array[SITEMGR_STATE_PREUNPUBLISH];
!                       if (($active_versions < 2) || (($active_versions == 2) 
&& ($count_array[SITEMGR_STATE_PUBLISH] == 0)))
!                       {
!                               while (list($versionid,$versionstate) = 
each($state))
!                               {
!                                       
$this->so->saveversionstate($block_id,$versionid,$versionstate);
!                               }
!                               return true;
                        }
                        else
***************
*** 144,151 ****
--- 276,316 ----
                }
  
+               function saveversiondatalang($block_id,$version_id,$data,$lang)
+               {
+                       return ($this->so->getblockidforversion($version_id) == 
$block_id) ?
+                               
$this->so->saveversiondatalang($version_id,$data,$lang) :
+                               false;
+               }
+ 
+               //this function can be called from a block's get_content 
function. It stores modification to the 
+               //blocks arguments in the database
+               function savepublicdata(&$block)
+               {
+                       //TODO: check if argument is public, disentangle 
session data from arguments
+                       
$this->so->saveversiondata($block->id,$block->version,$block->arguments);
+               }
+ 
                function getblockmodule($blockid)
                {
                        $block = $this->so->getblockdef($blockid);
                        return 
$GLOBALS['Common_BO']->modules->createmodule($block->module_name);
+               }
+ 
+               function commit($block_id)
+               {
+                       $block = $this->so->getblockdef($block_id);
+                       if 
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id))
+                       {
+                               $this->so->commit($block_id);
+                       }
+               }
+ 
+               function reactivate($block_id)
+               {
+                       $block = $this->so->getblockdef($block_id);
+                       if 
($GLOBALS['Common_BO']->acl->can_write_category($block->cat_id))
+                       {
+                               $this->so->reactivate($block_id);
+                       }
                }
        }

Index: class.Content_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Content_SO.inc.php,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -r1.6 -r1.6.2.1
*** class.Content_SO.inc.php    10 Mar 2003 07:00:41 -0000      1.6
--- class.Content_SO.inc.php    23 Jun 2003 20:31:21 -0000      1.6.2.1
***************
*** 20,36 ****
                                $block->page__id = 0;
                        }
!                       $sql = "INSERT INTO phpgw_sitemgr_content 
(area,module_id,page_id,cat_id,sort_order,viewable,actif) VALUES ('" .
!                               $block->area . "'," . $block->module_id . "," . 
$block->page_id . "," . $block->cat_id . ",0,0,0)";
                        return $this->db->query($sql,__LINE__,__FILE__);
                }
  
!               function removeblock($blockid)
                {
!                       $sql = "DELETE FROM phpgw_sitemgr_content WHERE 
block_id = $blockid";
                        if ($this->db->query($sql,__LINE__,__FILE__))
!                       {
!                               $sql = "DELETE FROM phpgw_sitemgr_content_lang 
WHERE block_id = $blockid";
                                return $this->db->query($sql,__LINE__,__FILE__);
                        }
                        else
                        {
--- 20,64 ----
                                $block->page__id = 0;
                        }
!                       $sql = "INSERT INTO phpgw_sitemgr_blocks 
(area,module_id,page_id,cat_id,sort_order,viewable) VALUES ('" .
!                               $block->area . "'," . $block->module_id . "," . 
$block->page_id . "," . $block->cat_id . ",0,0)";
!                       $this->db->query($sql,__LINE__,__FILE__);
!                       return 
$this->db->get_last_insert_id('phpgw_sitemgr_blocks','block_id');
!               }
! 
!               function createversion($blockid)
!               {
!                       $sql = "INSERT INTO phpgw_sitemgr_content 
(block_id,state) VALUES ($blockid," . SITEMGR_STATE_DRAFT  . ")";
                        return $this->db->query($sql,__LINE__,__FILE__);
                }
  
!               function deleteversion($id)
                {
!                       $sql = "DELETE FROM phpgw_sitemgr_content WHERE 
version_id = $id";
                        if ($this->db->query($sql,__LINE__,__FILE__))
!                       {
!                               $sql = "DELETE FROM phpgw_sitemgr_content_lang 
WHERE version_id = $id";
                                return $this->db->query($sql,__LINE__,__FILE__);
+                       }
+                       else
+                       {
+                               return false;
                        }
+               }
+ 
+               function getblockidforversion($versionid)
+               {
+                       $sql = "SELECT block_id FROM phpgw_sitemgr_content 
WHERE version_id = $versionid";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       return $this->db->next_record() ? 
$this->db->f('block_id') : false;
+               }
+ 
+               function removeblock($id)
+               {
+                       $sql = "DELETE FROM phpgw_sitemgr_blocks WHERE block_id 
= $id";
+                       if ($this->db->query($sql,__LINE__,__FILE__))
+                       {
+                               $sql = "DELETE FROM phpgw_sitemgr_blocks_lang 
WHERE block_id = $id";
+                               return $this->db->query($sql,__LINE__,__FILE__);
+                       }
                        else
                        {
***************
*** 41,46 ****
                function getblocksforscope($cat_id,$page_id)
                {
!                       $sql = "SELECT 
t1.block_id,t1.module_id,module_name,area FROM phpgw_sitemgr_content AS 
t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND cat_id = 
$cat_id AND page_id = $page_id ORDER by sort_order";
                        $block = CreateObject('sitemgr.Block_SO',True);
                        $result = array();
                        $this->db->query($sql,__LINE__,__FILE__);
--- 69,75 ----
                function getblocksforscope($cat_id,$page_id)
                {
!                       $sql = "SELECT 
t1.block_id,t1.module_id,module_name,area FROM phpgw_sitemgr_blocks AS 
t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND cat_id = 
$cat_id AND page_id = $page_id ORDER by sort_order";
                        $block = CreateObject('sitemgr.Block_SO',True);
+ 
                        $result = array();
                        $this->db->query($sql,__LINE__,__FILE__);
***************
*** 60,68 ****
                function getallblocksforarea($area,$cat_list,$page_id,$lang)
                {
!                       $sql = "SELECT t1.block_id, area, cat_id, page_id, 
t1.module_id, module_name, arguments, arguments_lang, sort_order, title, 
viewable, actif"
!                               . " FROM phpgw_sitemgr_content AS t1 LEFT JOIN "
!                               . " phpgw_sitemgr_modules AS t2 on 
t1.module_id=t2.module_id LEFT JOIN "
!                               . " phpgw_sitemgr_content_lang as t3 ON 
(t1.block_id=t3.block_id AND lang='$lang') "
!                               . " WHERE area = '$area' AND ((page_id = 0 and 
cat_id = 0)";
                        if ($cat_list)
                        {
--- 89,97 ----
                function getallblocksforarea($area,$cat_list,$page_id,$lang)
                {
!                       $sql = "SELECT t1.block_id, area, cat_id, page_id, 
t1.module_id, module_name, sort_order, title, viewable"
!                               . " FROM phpgw_sitemgr_blocks AS t1 LEFT JOIN "
!                               . " phpgw_sitemgr_modules AS t2 ON 
t1.module_id=t2.module_id LEFT JOIN "
!                               . " phpgw_sitemgr_blocks_lang AS t3 ON 
(t1.block_id=t3.block_id AND lang='$lang') "
!                               . " WHERE area = '$area' AND ((page_id = 0 and 
cat_id = ". CURRENT_SITE_ID  . ")";
                        if ($cat_list)
                        {
***************
*** 88,99 ****
                                $block->module_id = $this->db->f('module_id');
                                $block->module_name = 
$this->db->f('module_name');
-                               $block->arguments = array_merge(
-                                       
unserialize(stripslashes($this->db->f('arguments'))),
-                                       
unserialize(stripslashes($this->db->f('arguments_lang')))
-                               );
                                $block->sort_order = $this->db->f('sort_order');
                                $block->title = 
stripslashes($this->db->f('title'));
                                $block->view = $this->db->f('viewable');
-                               $block->actif = $this->db->f('actif');
                                $result[$id] = $block;
                        }
--- 117,123 ----
***************
*** 101,107 ****
                }
  
!               function getvisibleblockdefsforarea($area,$cat_list,$page_id)
                {
!                       $sql = "SELECT 
t1.block_id,area,cat_id,page_id,t1.module_id,module_name,viewable FROM 
phpgw_sitemgr_content AS t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = 
t2.module_id AND area = '$area' AND  ((page_id = 0 and cat_id = 0)";
                        if ($cat_list)
                        {
--- 125,205 ----
                }
  
!               function getversionidsforblock($blockid)
!               {
!                       $sql = "SELECT version_id FROM phpgw_sitemgr_content 
WHERE block_id = $blockid";
!                       $result = array();
!                       $this->db->query($sql,__LINE__,__FILE__);
! 
!                       while ($this->db->next_record())
!                       {
!                               $result[] = $this->db->f('version_id');
!                       }
!                       return $result;
!               }
! 
! 
!               function getallversionsforblock($blockid,$lang)
!               {
!                       $sql = "SELECT t1.version_id, 
arguments,arguments_lang,state FROM phpgw_sitemgr_content AS t1 LEFT JOIN "
!                               . "phpgw_sitemgr_content_lang AS t2 ON 
(t1.version_id=t2.version_id AND lang = '$lang') WHERE block_id = $blockid ";
!                       $result = array();
!                       $this->db->query($sql,__LINE__,__FILE__);
! 
!                       while ($this->db->next_record())
!                       {
!                               $id = $this->db->f('version_id');
!                               $version['arguments'] = array_merge(
!                                       
unserialize(stripslashes($this->db->f('arguments'))),
!                                       
unserialize(stripslashes($this->db->f('arguments_lang')))
!                               );
!                               $version['state'] = $this->db->f('state');
!                               $version['id'] = $id;
!                               $result[$id] = $version;
!                       }
!                       return $result;
!               }
! 
!               //selects all blocks from a given cat_list + site-wide blocks 
that are in given states
!               function getallblocks($cat_list,$states)
                {
!                       $cat_list[] = CURRENT_SITE_ID;
!                       $sql = "SELECT COUNT(state) AS 
cnt,t1.block_id,area,cat_id,page_id,viewable,state FROM phpgw_sitemgr_blocks AS 
t1,phpgw_sitemgr_content as t2 WHERE t1.block_id=t2.block_id AND cat_id IN (" . 
implode(',',$cat_list) . ")";
!                       $sql .= " AND state IN (" . implode(',',$states) .") 
GROUP BY t1.block_id,area,cat_id,page_id,viewable";
! 
!                       $block = CreateObject('sitemgr.Block_SO',True);
!                       $result = array();
! 
!                       $this->db->query($sql,__LINE__,__FILE__);
! 
!                       while ($this->db->next_record())
!                       {
!                               $id = $this->db->f('block_id');
!                               $block->id = $id;
!                               $block->area = $this->db->f('area');
!                               $block->cat_id = $this->db->f('cat_id');
!                               $block->page_id = $this->db->f('page_id');
! //                            $block->module_id = $this->db->f('module_id');
! //                            $block->module_name = 
$this->db->f('module_name');
!                               $block->view = $this->db->f('viewable');
!                               $block->state = $this->db->f('state');
!                               //in cnt we retrieve the numbers of versions 
that are commitable for a block,
!                               //i.e. if there are more than one, it should 
normally be a prepublished version 
!                               //that will replace a preunpublished version
!                               $block->cnt =  $this->db->f('cnt');
!                               $result[$id] = $block;
!                       }
!                       return $result;
!               }
! 
!               function 
getvisibleblockdefsforarea($area,$cat_list,$page_id,$isadmin,$isuser)
!               {
!                       $viewable = SITEMGR_VIEWABLE_EVERBODY  . ',';
!                       $viewable .= $isuser ? SITEMGR_VIEWABLE_USER : 
SITEMGR_VIEWABLE_ANONYMOUS;
!                       $viewable .= $isadmin ? (',' . SITEMGR_VIEWABLE_ADMIN) 
: '';
! 
!                       $sql = "SELECT 
t1.block_id,area,cat_id,page_id,t1.module_id,module_name,state,version_id " . 
!                               "FROM phpgw_sitemgr_blocks AS 
t1,phpgw_sitemgr_modules AS t2,phpgw_sitemgr_content AS t3 " . 
!                               "WHERE t1.module_id = t2.module_id AND 
t1.block_id=t3.block_id AND area = '$area' " . 
!                               "AND  ((page_id = 0 and cat_id = ". 
CURRENT_SITE_ID  . ")";
                        if ($cat_list)
                        {
***************
*** 112,119 ****
                                $sql .= " OR (page_id = $page_id) ";
                        }
!                       $sql .= ") AND actif = 1 ORDER by sort_order";
!       
                        $block = CreateObject('sitemgr.Block_SO',True);
                        $result = array();
                        $this->db->query($sql,__LINE__,__FILE__);
  
--- 210,217 ----
                                $sql .= " OR (page_id = $page_id) ";
                        }
!                       $sql .= ") AND viewable IN (" . $viewable . ") AND 
state IN (" . implode(',',$GLOBALS['Common_BO']->visiblestates) . ") ORDER by 
sort_order";
                        $block = CreateObject('sitemgr.Block_SO',True);
                        $result = array();
+ 
                        $this->db->query($sql,__LINE__,__FILE__);
  
***************
*** 128,131 ****
--- 226,231 ----
                                $block->module_name = 
$this->db->f('module_name');
                                $block->view = $this->db->f('viewable');
+                               $block->state = $this->db->f('state');
+                               $block->version = $this->db->f('version_id');
                                $result[$id] = $block;
                        }
***************
*** 133,140 ****
                }
  
!               function getlangarrayforblock($block_id)
                {
                        $retval = array();
!                       $this->db->query("SELECT lang FROM 
phpgw_sitemgr_content_lang WHERE block_id = $block_id",__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {
--- 233,252 ----
                }
  
!               function getlangarrayforblocktitle($block_id)
!               {
!                       $retval = array();
!                       $this->db->query("SELECT lang FROM 
phpgw_sitemgr_blocks_lang WHERE block_id = $block_id",__LINE__,__FILE__);
!                       while ($this->db->next_record())
!                       {
!                               $retval[] = $this->db->f('lang');
!                       }
!                       return $retval;
!               }
! 
!               //find out in what languages this block has data and return 
!               function getlangarrayforversion($version_id)
                {
                        $retval = array();
!                       $this->db->query("SELECT lang FROM 
phpgw_sitemgr_content_lang WHERE version_id = $version_id",__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {
***************
*** 144,160 ****
                }
  
!               function getlangblockdata($blockid,$lang)
                {
!                       $sql = "SELECT title, arguments, arguments_lang FROM 
phpgw_sitemgr_content AS t1 LEFT JOIN phpgw_sitemgr_content_lang AS t2 ON 
(t1.block_id=t2.block_id AND lang='$lang') WHERE t1.block_id = $blockid";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
                        {
!                               $block = CreateObject('sitemgr.Block_SO',True);
!                               $block->arguments = array_merge(
!                                       
unserialize(stripslashes($this->db->f('arguments'))),
!                                       
unserialize(stripslashes($this->db->f('arguments_lang')))
!                               );
!                               $block->title = 
stripslashes($this->db->f('title'));
!                               return $block;
                        }
                        else
--- 256,275 ----
                }
  
!               //returns the versions arguments array
!               function getversion($version_id,$lang=false)
                {
!                       $fields = "arguments" . ($lang ? ', arguments_lang' : 
'');
!                       $lang_join = $lang ? "LEFT JOIN 
phpgw_sitemgr_content_lang AS t2 ON (t1.version_id = t2.version_id AND 
lang='$lang')" : '';
!                       $sql = "SELECT $fields FROM phpgw_sitemgr_content AS t1 
$lang_join WHERE t1.version_id = $version_id";
! 
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
                        {
!                                return $lang ? 
!                                       array_merge(
!                                               
unserialize(stripslashes($this->db->f('arguments'))),
!                                               
unserialize(stripslashes($this->db->f('arguments_lang'))) 
!                                       ) : 
!                                       
unserialize(stripslashes($this->db->f('arguments')));
                        }
                        else
***************
*** 166,170 ****
                function getblock($block_id,$lang)
                {
!                       $sql = "SELECT 
t1.block_id,cat_id,page_id,area,t1.module_id,module_name,arguments,arguments_lang,sort_order,title,viewable,actif
 FROM phpgw_sitemgr_modules AS t2, phpgw_sitemgr_content AS t1 LEFT JOIN 
phpgw_sitemgr_content_lang as t3 ON (t1.block_id=t3.block_id AND lang='$lang') 
WHERE t1.module_id = t2.module_id AND t1.block_id = $block_id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
--- 281,288 ----
                function getblock($block_id,$lang)
                {
!                       $sql = "SELECT 
area,cat_id,page_id,area,t1.module_id,module_name,sort_order,title,viewable"
!                               . " FROM phpgw_sitemgr_blocks AS t1 LEFT JOIN "
!                               . " phpgw_sitemgr_modules as t2 ON 
t1.module_id=t2.module_id LEFT JOIN "
!                               . " phpgw_sitemgr_blocks_lang AS t3 ON 
(t1.block_id=t3.block_id AND lang='$lang') WHERE t1.block_id = $block_id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
***************
*** 177,188 ****
                                $block->module_id = $this->db->f('module_id');
                                $block->module_name = 
$this->db->f('module_name');
-                               $block->arguments = array_merge(
-                                       
unserialize(stripslashes($this->db->f('arguments'))),
-                                       
unserialize(stripslashes($this->db->f('arguments_lang')))
-                               );
                                $block->sort_order = $this->db->f('sort_order');
                                $block->title = 
stripslashes($this->db->f('title'));
                                $block->view = $this->db->f('viewable');
-                               $block->actif = $this->db->f('actif');
                                return $block;
                        }
--- 295,301 ----
***************
*** 196,200 ****
                function getblockdef($block_id)
                {
!                       $sql = "SELECT 
cat_id,page_id,area,t1.module_id,module_name FROM phpgw_sitemgr_content AS 
t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND 
t1.block_id = $block_id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
--- 309,313 ----
                function getblockdef($block_id)
                {
!                       $sql = "SELECT 
cat_id,page_id,area,t1.module_id,module_name FROM phpgw_sitemgr_blocks AS 
t1,phpgw_sitemgr_modules AS t2 WHERE t1.module_id = t2.module_id AND 
t1.block_id = $block_id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
***************
*** 215,219 ****
                }
  
!               function saveblockdata($block,$data)
                {
                        //this is necessary because double slashed data breaks 
while serialized
--- 328,363 ----
                }
  
!               function getlangblocktitle($id,$lang)
!               {
!                       if ($lang)
!                       {
!                               $sql = "SELECT title FROM 
phpgw_sitemgr_blocks_lang WHERE block_id = $id AND lang = '$lang'";
!                               $this->db->query($sql,__LINE__,__FILE__);
!                               return $this->db->next_record() ? 
$this->db->f('title') : false;
!                       }
!                       else
!                       {
!                               $sql = "SELECT title FROM 
phpgw_sitemgr_blocks_lang WHERE block_id = $id";
!                               $this->db->query($sql,__LINE__,__FILE__);
!                               return $this->db->next_record() ? 
$this->db->f('title') : false;
!                       }
!               }
! 
!               function saveblockdata($block)
!               {
!                       $sql = "UPDATE phpgw_sitemgr_blocks SET sort_order = " 
. (int)$block->sort_order . 
!                               ", viewable = " . $block->view . " WHERE 
block_id = " . $block->id;
!                       return $this->db->query($sql,__LINE__,__FILE__);
!               }
! 
!               function saveblockdatalang($id,$title,$lang)
!               {
!                       $sql = "DELETE FROM phpgw_sitemgr_blocks_lang WHERE 
block_id = $id AND lang = '$lang'";
!                       $this->db->query($sql,__LINE__,__FILE__);
!                       $sql = "INSERT INTO phpgw_sitemgr_blocks_lang 
(block_id,title,lang) VALUES ($id,'$title','$lang')";
!                       return $this->db->query($sql,__LINE__,__FILE__);
!               }
! 
!               function saveversiondata($block_id,$version_id,$data)
                {
                        //this is necessary because double slashed data breaks 
while serialized
***************
*** 223,232 ****
                        }
                        $s = $this->db->db_addslashes(serialize($data));
!                       $sql = "UPDATE phpgw_sitemgr_content SET arguments = 
'$s', sort_order = " . (int)$block->sort_order . 
!                               ", viewable = " . $block->view . ", actif = " . 
$block->actif . " WHERE block_id = " . $block->id;
                        return $this->db->query($sql,__LINE__,__FILE__);
                }
  
!               function saveblockdatalang($block,$data,$lang)
                {
                        //this is necessary because double slashed data breaks 
while serialized
--- 367,382 ----
                        }
                        $s = $this->db->db_addslashes(serialize($data));
!                       //by requiring block_id, we make sur that we only touch 
versions that really belong to the block
!                       $sql = "UPDATE phpgw_sitemgr_content SET arguments = 
'$s' WHERE version_id = $version_id AND block_id = $block_id";
!                       return $this->db->query($sql,__LINE__,__FILE__);
!               }
! 
!               function saveversionstate($block_id,$version_id,$state)
!               {
!                       $sql = "UPDATE phpgw_sitemgr_content SET state = $state 
 WHERE version_id = $version_id AND block_id = $block_id";
                        return $this->db->query($sql,__LINE__,__FILE__);
                }
  
!               function saveversiondatalang($id,$data,$lang)
                {
                        //this is necessary because double slashed data breaks 
while serialized
***************
*** 236,244 ****
                        }
                        $s = $this->db->db_addslashes(serialize($data));
-                       $title = $this->db->db_addslashes($block->title);
                        $blockid = $block->id;
!                       $sql = "DELETE FROM phpgw_sitemgr_content_lang WHERE 
block_id = $blockid AND lang = '$lang'";
                        $this->db->query($sql,__LINE__,__FILE__);
!                       $sql = "INSERT INTO phpgw_sitemgr_content_lang 
(block_id,lang,arguments_lang,title) VALUES ($blockid,'$lang','$s','$title')";
                        return $this->db->query($sql,__LINE__,__FILE__);
                }
--- 386,393 ----
                        }
                        $s = $this->db->db_addslashes(serialize($data));
                        $blockid = $block->id;
!                       $sql = "DELETE FROM phpgw_sitemgr_content_lang WHERE 
version_id = $id AND lang = '$lang'";
                        $this->db->query($sql,__LINE__,__FILE__);
!                       $sql = "INSERT INTO phpgw_sitemgr_content_lang 
(version_id,lang,arguments_lang) VALUES ($id,'$lang','$s')";
                        return $this->db->query($sql,__LINE__,__FILE__);
                }
***************
*** 258,261 ****
--- 407,424 ----
                                $data = stripslashes($data);
                        }
+               }
+ 
+               function commit($block_id)
+               {
+                       $sql = "UPDATE phpgw_sitemgr_content SET state = " . 
SITEMGR_STATE_PUBLISH . " WHERE state = " . SITEMGR_STATE_PREPUBLISH . " AND 
block_id = $block_id";
+                       $this->db->query($sql, __LINE__,__FILE__);
+                       $sql = "UPDATE phpgw_sitemgr_content SET state = " . 
SITEMGR_STATE_ARCHIVE . " WHERE state = " . SITEMGR_STATE_PREUNPUBLISH . " AND 
block_id = $block_id";;
+                       $this->db->query($sql, __LINE__,__FILE__);
+               }
+ 
+               function reactivate($block_id)
+               {
+                               $sql = "UPDATE phpgw_sitemgr_content SET state 
= " . SITEMGR_STATE_DRAFT . " WHERE state = " . SITEMGR_STATE_ARCHIVE . " AND 
block_id = $block_id";;
+                       $this->db->query($sql, __LINE__,__FILE__);
                }
        }

Index: class.Content_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Content_UI.inc.php,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -r1.3.2.1 -r1.3.2.2
*** class.Content_UI.inc.php    3 May 2003 21:10:40 -0000       1.3.2.1
--- class.Content_UI.inc.php    23 Jun 2003 20:31:21 -0000      1.3.2.2
***************
*** 12,19 ****
                var $worklanguage;
                var $errormsg;
  
                var $public_functions = array
                (
!                       '_manageContent' => True
                );
  
--- 12,22 ----
                var $worklanguage;
                var $errormsg;
+               var $langselect;
  
                var $public_functions = array
                (
!                       'manage' => True,
!                       'commit' => True,
!                       'archive' => True
                );
  
***************
*** 26,66 ****
                        $this->modulebo = &$GLOBALS['Common_BO']->modules;
                        $this->viewable = array(
!                               '0' => lang('everybody'),
!                               '1' => lang('phpgw users'),
!                               '2' => lang('administrators'),
!                               '3' => lang('anonymous')
                        );
!                       $preferenceso = 
CreateObject('sitemgr.sitePreference_SO', true);
!                       $this->sitelanguages = 
explode(',',$preferenceso->getPreference('sitelanguages'));
!                       $sessionlang = 
$GLOBALS['phpgw']->session->appsession('worklanguage','sitemgr');
!                       $this->worklanguage = $sessionlang ? $sessionlang : 
$this->sitelanguages[0];
                        $this->errormsg = array();
                }
  
!               function _manageContent()
                {
!                       $this->common_ui->DisplayHeader();
  
!                       
$GLOBALS['Common_BO']->globalize(array('blockid','blocktitle','blocksort','blockview','blockactif','btnSaveBlock','btnDeleteBlock','module_id','area','btnAddBlock','element','savelanguage'));
!                       global $blockid, $blocktitle, 
$blocksort,$blockview,$blockactif,$btnSaveBlock,$btnDeleteBlock, $module_id, 
$area, $btnAddBlock, $element, $savelanguage;
                        $page_id = $_GET['page_id'];
                        $cat_id = $_GET['cat_id'];
!                       $scopename = $page_id ? lang('Page') : ($cat_id ? 
lang('Category') : lang('Site'));
  
!                       if ($page_id)
                        {
                                $page = 
$GLOBALS['Common_BO']->pages->getPage($page_id);
                                $page_or_cat_name = $page->name;
                                $cat_id = $page->cat_id;
-                               $managelink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage');
                                $goto = lang('Page manager');
                                $scopename = lang('Page');
                        }
!                       elseif ($cat_id)
                        {
                                $cat = 
$GLOBALS['Common_BO']->cats->getCategory($cat_id);
                                $page_or_cat_name = $cat->name;
                                $page_id = 0;
-                               $managelink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories');
                                $goto = lang('Category manager');
                                $scopename = lang('Category');
--- 29,110 ----
                        $this->modulebo = &$GLOBALS['Common_BO']->modules;
                        $this->viewable = array(
!                               SITEMGR_VIEWABLE_EVERBODY => lang('everybody'),
!                               SITEMGR_VIEWABLE_USER => lang('phpgw users'),
!                               SITEMGR_VIEWABLE_ADMIN => 
lang('administrators'),
!                               SITEMGR_VIEWABLE_ANONYMOUS => lang('anonymous')
                        );
! 
!                       $this->sitelanguages = 
$GLOBALS['Common_BO']->sites->current_site['sitelanguages'];
!                       $savelanguage = $_POST['savelanguage'];
!                       if ($savelanguage)
!                       {
!                               //we save the language the user chooses as 
session variable
!                               $this->worklanguage = $savelanguage;
!                               
$GLOBALS['phpgw']->session->appsession('worklanguage','sitemgr',$savelanguage);
!                       }
!                       else
!                       {
!                               $sessionlang = 
$GLOBALS['phpgw']->session->appsession('worklanguage','sitemgr');
!                               $this->worklanguage = $sessionlang ? 
$sessionlang : $this->sitelanguages[0];
!                       }
                        $this->errormsg = array();
+ 
+                       if (count($this->sitelanguages) > 1)
+                       {
+                               $this->langselect = lang('as') . ' <select 
name="savelanguage">';
+                               foreach ($this->sitelanguages as $lang)
+                               {
+                                       $selected= '';
+                                       if ($lang == $this->worklanguage)
+                                       {
+                                               $selected = 
'selected="selected" ';
+                                       }
+                                       $this->langselect .= '<option ' . 
$selected .'value="' . $lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) 
. '</option>';
+                               }
+                               $this->langselect .= '</select> ';
+                       }
                }
  
!               function manage()
                {
!                       $GLOBALS['Common_BO']->globalize(array(
!                               
'inputblockid','inputblocktitle','inputblocksort','inputblockview',
!                               
'inputstate','btnSaveBlock','btnDeleteBlock','btnCreateVersion',
!                               
'btnDeleteVersion','inputmoduleid','inputarea','btnAddBlock','element'
!                       ));
!                       global $inputblockid, $inputblocktitle, 
$inputblocksort,$inputblockview;
!                       global 
$inputstate,$btnSaveBlock,$btnDeleteBlock,$btnCreateVersion;
!                       global $inputmoduleid, $inputarea, $btnAddBlock, 
$btnDeleteVersion, $element;
  
!                       global $page_id,$cat_id;
                        $page_id = $_GET['page_id'];
                        $cat_id = $_GET['cat_id'];
!                       $block_id = $_GET['block_id'];
  
!                       if ($block_id)
!                       {}
!                       elseif ($page_id)
                        {
                                $page = 
$GLOBALS['Common_BO']->pages->getPage($page_id);
+                               if 
(!$GLOBALS['Common_BO']->acl->can_write_category($page->cat_id))
+                               {
+                                       
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
+                                       return;
+                               }
                                $page_or_cat_name = $page->name;
                                $cat_id = $page->cat_id;
                                $goto = lang('Page manager');
                                $scopename = lang('Page');
                        }
!                       elseif ($cat_id != CURRENT_SITE_ID)
                        {
                                $cat = 
$GLOBALS['Common_BO']->cats->getCategory($cat_id);
+                               if 
(!$GLOBALS['Common_BO']->acl->can_write_category($cat_id))
+                               {
+                                       
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
+                                       return;
+                               }
                                $page_or_cat_name = $cat->name;
                                $page_id = 0;
                                $goto = lang('Category manager');
                                $scopename = lang('Category');
***************
*** 68,103 ****
                        else
                        {
-                               $cat_id = 0;
                                $page_id = 0;
                        }
  
-                       $this->t->set_file('Managecontent', 
'manage_content.tpl');
-                       
$this->t->set_block('Managecontent','Contentarea','CBlock');
-                       $this->t->set_block('Contentarea','Module','MBlock');
-                       $this->t->set_block('Module','Moduleeditor','MeBlock');
-                       $this->t->set_block('Module','Moduleview','MvBlock');
-                       
$this->t->set_block('Moduleeditor','EditorElement','EeBlock');
-                       
$this->t->set_block('Moduleview','ViewElement','VeBlock');
-                       $this->t->set_var(Array(
-                               'lang_reset' => lang('Reset'),
-                               'lang_save' => lang('Save'),
-                               'content_manager' => lang('%1 content manager', 
$scopename),
-                               'page_or_cat_name' => ($page_or_cat_name ? (' - 
' . $page_or_cat_name) : ''),
-                               'managelink' => ($managelink ? ('<a href="' . 
$managelink . '">&lt; ' . lang('Go to') . ' ' . $goto . ' &gt;</a>') : '')
-                               ));
- 
                        if ($btnAddBlock)
                        {
!                               if ($module_id)
                                {
                                        $block = 
CreateObject('sitemgr.Block_SO',True);
!                                       $block->module_id = $module_id;
!                                       $block->area = $area;
                                        $block->page_id = $page_id;
                                        $block->cat_id = $cat_id;
  
!                                       if (!$this->bo->addblock($block))
                                        {
!                                               $this->errormsg[] = lang("You 
are not entitled to create module %1 on this scope",$module_id);
                                        }
                                }
--- 112,137 ----
                        else
                        {
                                $page_id = 0;
+                               $scopename = lang('Site');
                        }
  
                        if ($btnAddBlock)
                        {
!                               if ($inputmoduleid)
                                {
                                        $block = 
CreateObject('sitemgr.Block_SO',True);
!                                       $block->module_id = $inputmoduleid;
!                                       $block->area = $inputarea;
                                        $block->page_id = $page_id;
                                        $block->cat_id = $cat_id;
  
!                                       $newblock = $this->bo->addblock($block);
!                                       if ($newblock)
!                                       {
!                                               
$this->bo->createversion($newblock);
!                                       }
!                                       else
                                        {
!                                               $this->errormsg[] = lang("You 
are not entitled to create module %1 on this scope",$inputmoduleid);
                                        }
                                }
***************
*** 109,151 ****
                        elseif ($btnSaveBlock)
                        {
!                               $moduleobject = 
$this->bo->getblockmodule($blockid);
! 
!                               if ($moduleobject->validate($element))
                                {
!                                       if ($savelanguage)
!                                       {
!                                               //we save the language the user 
chooses as session variable
!                                               $this->worklanguage = 
$savelanguage;
!                                               
$GLOBALS['phpgw']->session->appsession('worklanguage','sitemgr',$savelanguage);
!                                       }
! 
!                                       $block = 
CreateObject('sitemgr.Block_SO',True);
!                                       $block->id = $blockid;
!                                       $block->title = $blocktitle;
!                                       $block->sort_order = $blocksort;
!                                       $block->view = $blockview;
!                                       $block->actif = $blockactif ? 1 : 0;
!                                       if 
(!$this->bo->saveblockdata($block,$element,$this->worklanguage))
!                                       {
!                                               $this->errormsg[] = lang("You 
are not entitled to edit block %1",$blockid);
!                                       }
                                }
!                               if ($moduleobject->validation_error)
                                {
!                                       $this->errormsg[] = 
$moduleobject->validation_error;
                                }
                        }
!                       elseif ($btnDeleteBlock)
                        {
!                               if (!$this->bo->removeblock($blockid))
                                {
!                                       $this->errormsg[] =  lang("You are not 
entitled to edit block %1",$blockid);
                                }
                        }
  
                        $contentareas = $this->bo->getContentAreas();
!                       if ($contentareas)
                        {
!                               $this->t->set_var('help', lang('You can 
override each content blocks default title. Be aware that not in all content 
areas the block title will be visible.'));
  
                                foreach ($contentareas as $contentarea)
--- 143,238 ----
                        elseif ($btnSaveBlock)
                        {
!                               $block = CreateObject('sitemgr.Block_SO',True);
!                               $block->id = $inputblockid;
!                               $block->title = $inputblocktitle;
!                               $block->sort_order = $inputblocksort;
!                               $block->view = $inputblockview;
!                               $result = 
$this->bo->saveblockdata($block,$element,$inputstate,$this->worklanguage);
!                               if ($result !== True)
                                {
!                                       //result should be an array of 
validationerrors
!                                       $this->errormsg = $result;
!                               }
!                       }
!                       elseif ($btnDeleteBlock)
!                       {
!                               if (!$this->bo->removeblock($inputblockid))
!                               {
!                                       $this->errormsg[] =  lang("You are not 
entitled to edit block %1",$inputblockid);
                                }
!                               //if we delete a block we were editing, there 
is nothing left to do
!                               if ($block_id)
                                {
!                                       echo '<html><head></head><body 
onload="opener.location.reload();self.close()"></body></html>';
                                }
                        }
!                       elseif ($btnCreateVersion)
!                       {
!                               $this->bo->createversion($inputblockid);
!                       }
!                       elseif ($btnDeleteVersion)
!                       {
!                               $version_id = array_keys($btnDeleteVersion);
!                               $this->bo->deleteversion($version_id[0]);
!                       }
! 
!                       //if we are called with a block_id GET parameter, it is 
from sitemgr-site edit mode or from archiv/commit
!                       //we are shown in a separate edit window, without 
navbar. 
!                       if ($block_id)
                        {
!                               $block = 
$this->bo->getblock($block_id,$this->worklanguage);
!                               if (!($block && 
$GLOBALS['Common_BO']->acl->can_write_category($block->cat_id)))
                                {
!                                       echo '<p><center><b>'.lang('Attempt to 
edit non-editable block').'</b></center>';
!                                       
$GLOBALS['phpgw']->common->phpgw_exit(True);
                                }
+                               $this->t->set_file('Blocks', 'edit_block.tpl');
+                               $this->t->set_block('Blocks','Block');
+                               
$this->t->set_block('Block','Moduleeditor','MeBlock');
+                               
$this->t->set_block('Block','Moduleview','MvBlock');
+                               
$this->t->set_block('Moduleeditor','Version','EvBlock');
+                               
$this->t->set_block('Blocks','EditorElement','EeBlock');
+                               
$this->t->set_block('Moduleview','ViewElement','VeBlock');
+ 
+                               $this->t->set_var(array(
+                                       'savebutton' => lang('Save block'),
+                                       'deletebutton' => lang('Delete block'),
+                                       'contentarea' => lang('Contentarea'),
+                                       'createbutton' => lang('Create new 
version'),
+                                       'standalone' => 
"<html><head></head><body>",
+                                       'donebutton' => '<input type="reset" 
onclick="opener.location.reload();self.close()" value="' . lang('Done') . '"  
/>'
+                               ));
+                               $this->showblock($block,True,True);
+                               $this->t->pfp('out','Block');
+                               return;
                        }
  
+                       $this->common_ui->DisplayHeader();
+ 
+                       $this->t->set_file('Managecontent', 
'manage_content.tpl');
+                       $this->t->set_file('Blocks','edit_block.tpl');
+                       
$this->t->set_block('Managecontent','Contentarea','CBlock');
+                       $this->t->set_block('Blocks','Block');
+                       $this->t->set_block('Block','Moduleeditor','MeBlock');
+                       $this->t->set_block('Block','Moduleview','MvBlock');
+                       $this->t->set_block('Moduleeditor','Version','EvBlock');
+                       $this->t->set_block('Blocks','EditorElement','EeBlock');
+                       
$this->t->set_block('Moduleview','ViewElement','VeBlock');
+                       $this->t->set_var(Array(
+                               'content_manager' => lang('%1 content manager', 
$scopename),
+                               'page_or_cat_name' => ($page_or_cat_name ? (' - 
' . $page_or_cat_name) : '')
+                               ));
+ 
+ 
                        $contentareas = $this->bo->getContentAreas();
!                       if (is_array($contentareas))
                        {
!                               $this->t->set_var(array(
!                                       'help' => lang('You can override each 
content blocks default title. Be aware that not in all content areas the block 
title will be visible.'),
!                                       'savebutton' => lang('Save block'),
!                                       'deletebutton' => lang('Delete block'),
!                                       'contentarea' => lang('Contentarea'),
!                                       'createbutton' => lang('Create new 
version'),
!                               ));
  
                                foreach ($contentareas as $contentarea)
***************
*** 157,162 ****
                                                'addblockform' => 
                                                        ($permittedmodules ?
!                                                               ('<form 
method="POST"><input type="hidden" value="' . $contentarea . '" name="area" />' 
.
!                                                                       
'<select style="vertical-align:middle" size="10" name="module_id">' .
                                                                        
$this->inputmoduleselect($permittedmodules) .
                                                                        
'</select><input type="submit" name="btnAddBlock" value="' .
--- 244,249 ----
                                                'addblockform' => 
                                                        ($permittedmodules ?
!                                                               ('<form 
method="POST"><input type="hidden" value="' . $contentarea . '" 
name="inputarea" />' .
!                                                                       
'<select style="vertical-align:middle" size="10" name="inputmoduleid">' .
                                                                        
$this->inputmoduleselect($permittedmodules) .
                                                                        
'</select><input type="submit" name="btnAddBlock" value="' .
***************
*** 165,169 ****
                                                                lang('No 
modules permitted for this content area/category')
                                                        ),
!                                               'error' => ($contentarea == 
$area && $this->errormsg) ? join('<br>',$this->errormsg) : '',
                                        ));
  
--- 252,256 ----
                                                                lang('No 
modules permitted for this content area/category')
                                                        ),
!                                               'error' => (($contentarea == 
$inputarea) && $this->errormsg) ? join('<br>',$this->errormsg) : '',
                                        ));
  
***************
*** 173,307 ****
                                        $blocks = 
$this->bo->getallblocksforarea($contentarea,$cat_id,$page_id,$this->worklanguage);
  
!                                       $this->t->set_var('MBlock','');
  
                                        if ($blocks)
                                        {
!                                               if (count($this->sitelanguages) 
> 1)
                                                {
-                                                       $select = lang('as') . 
' <select name="savelanguage">';
- 
-                                                       foreach 
($this->sitelanguages as $lang)
-                                                       {
-                                                               $selected= '';
-                                                               if ($lang == 
$this->worklanguage)
-                                                               {
-                                                                       
$selected = 'selected="selected" ';
-                                                               }
-                                                                       $select 
.= '<option ' . $selected .'value="' . $lang . '">'. 
$GLOBALS['Common_BO']->getlangname($lang) . '</option>';
-                                                               }
-                                                               $select .= 
'</select> ';
-                                                               
$this->t->set_var('savelang',$select);
-                                               }
-                                               while (list($id,$block) = 
each($blocks))
-                                               {
-                                                       //TODO: wrap a module 
storage around createmodule as in template3, 
-                                                       //TODO: so that we do 
not create the same module object twice
-                                                       $moduleobject = 
$this->modulebo->createmodule($block->module_name);
-                                                       $this->t->set_var(array(
-                                                               'moduleinfo' => 
($block->module_name),
-                                                               'description' 
=> $moduleobject->description,
-                                                       ));
- 
                                                        //if the block is in 
our scope and we are entitled we edit it
!                                                       if ($block->page_id == 
$page_id && 
!                                                               $block->cat_id 
== $cat_id)
!                                                       {
!                                                               
$editorstandardelements = array(
!                                                                       
array('label' => lang('Title'),
!                                                                               
  'form' => ('<input type="text" name="blocktitle" value="' . 
!                                                                               
        ($block->title ? $block->title : $moduleobject->title) . '" />')
!                                                                       ),
!                                                                       
array('label' => lang('Actif'),
!                                                                               
  'form' => ('<input type="checkbox" name="blockactif"' .
!                                                                               
         ($block->actif ? 'checked="checked"' : '') . '">')
!                                                                       ),
!                                                                       
array('label' => lang('Seen by'),
!                                                                               
  'form' => ('<select name="blockview">' .
!                                                                               
        $this->inputviewselect((int)$block->view) . '</select>')
!                                                                       ),
!                                                                       
array('label' => lang('Sort order'),
!                                                                               
  'form' => ('<input type="text" name="blocksort" size="2" value="' .
!                                                                               
        (int)$block->sort_order . '">')
!                                                                       )
!                                                               );
!                                                               
$moduleobject->set_block($block);
!                                                               
$editormoduleelements = $moduleobject->get_user_interface();
!                                                               $interface = 
array_merge($editorstandardelements,$editormoduleelements);
!                                                               
$this->t->set_var(Array(
!                                                                       
'blockid' => $id,
!                                                                       
'savebutton' => lang('Save'),
!                                                                       
'deletebutton' => lang('Delete'),
!                                                                       
'contentarea' => lang('Contentarea'),
!                                                                       
'validationerror' => ($id == $blockid && $this->errormsg) ? 
join('<br>',$this->errormsg) : '',
!                                                               ));
!                                                               
$this->t->set_var('EeBlock','');
!                                                               while 
(list(,$element) = each($interface))
!                                                               {
!                                                                       
$this->t->set_var(Array(
!                                                                               
'label' => $element['label'],
!                                                                               
'form' => $element['form']
!                                                                       ));
!                                                                       
$this->t->parse('EeBlock','EditorElement', true);
!                                                               }
!                                                               
$this->t->parse('MeBlock','Moduleeditor');
!                                                               
$this->t->set_var('MvBlock','');
!                                                       }
!                                                       //otherwise we only 
show it
!                                                       else
!                                                       {
!                                                               if 
($block->page_id)
!                                                               {
!                                                                       
$blockscope = lang('Page');
!                                                               }
!                                                               elseif 
($block->cat_id)
!                                                               {
!                                                                       $cat = 
$GLOBALS['Common_BO']->cats->getCategory($block->cat_id);
!                                                                       
$blockscope =  lang('Category') . ' - ' . $cat->name;
!                                                               }
!                                                               else
!                                                               {
!                                                                       
$blockscope =  lang('Site');
!                                                               }
! 
!                                                               
$viewstandardelements = array(
!                                                                       
array('label' => lang('Scope'),
!                                                                               
  'value' => $blockscope
!                                                                       ),
!                                                                       
array('label' => lang('Title'),
!                                                                               
  'value' => ($block->title ? $block->title : $moduleobject->title)
!                                                                       ),
!                                                                       
array('label' => lang('Actif'),
!                                                                               
  'value' => ($block->actif ? lang('Yes') : lang('No'))
!                                                                       ),
!                                                                       
array('label' => lang('Seen by'),
!                                                                               
  'value' => $this->viewable[(int)$block->view]
!                                                                       ),
!                                                                       
array('label' => lang('Sort order'),
!                                                                               
  'value' => (int)$block->sort_order
!                                                                       )
!                                                               );
!                                                               
$viewmoduleelements = array();
!                                                               while 
(list($argument,$argdef) = @each($moduleobject->arguments))
!                                                               {
!                                                                       $value 
= $block->arguments[$argument];
!                                                                       
$viewmoduleelements[] = array(
!                                                                               
'label' => $argdef['label'],
!                                                                               
'value' => $GLOBALS['phpgw']->strip_html($value)
!                                                                       );
!                                                               }
!                                                               $interface = 
array_merge($viewstandardelements,$viewmoduleelements);
!                                                               
$this->t->set_var('VeBlock','');
!                                                               while 
(list(,$element) = each($interface))
!                                                               {
!                                                                       
$this->t->set_var(Array(
!                                                                               
'label' => $element['label'],
!                                                                               
'value' => $element['value'])
!                                                                       );
!                                                                       
$this->t->parse('VeBlock','ViewElement', true);
!                                                               }
!                                                               
$this->t->parse('MvBlock','Moduleview');
!                                                               
$this->t->set_var('MeBlock','');
!                                                       }
!                                               
$this->t->parse('MBlock','Module', true);
                                                }
                                        }
--- 260,273 ----
                                        $blocks = 
$this->bo->getallblocksforarea($contentarea,$cat_id,$page_id,$this->worklanguage);
  
!                                       $this->t->set_var('blocks','');
  
                                        if ($blocks)
                                        {
!                                               while (list(,$block) = 
each($blocks))
                                                {
                                                        //if the block is in 
our scope and we are entitled we edit it
!                                                       $editable = 
($block->page_id == $page_id && $block->cat_id == $cat_id);
!                                                       
$this->showblock($block,$editable);
!                                                       
$this->t->parse('blocks','Block', true);
                                                }
                                        }
***************
*** 311,318 ****
                        else
                        {
!                               $this->t->set_var('CBlock',lang('No content 
areas found in selected template'));
                        }
                        $this->t->pfp('out', 'Managecontent');
!                       $this->common_ui->DisplayFooter();      
                }
  
--- 277,459 ----
                        else
                        {
!                               $this->t->set_var('CBlock',$contentareas);
                        }
                        $this->t->pfp('out', 'Managecontent');
!                       $this->common_ui->DisplayFooter();
!               }
! 
!               function commit()
!               {
!                       if ($_POST['btnCommit'])
!                       {
!                               while(list($cat_id,) = @each($_POST['cat']))
!                               {
!                                       
$GLOBALS['Common_BO']->cats->commit($cat_id);
!                               }
!                               while(list($page_id,) = @each($_POST['page']))
!                               {
!                                       
$GLOBALS['Common_BO']->pages->commit($page_id);
!                               }
!                               while(list($block_id,) = @each($_POST['block']))
!                               {
!                                       $this->bo->commit($block_id);
!                               }
!                       }
!                       $this->common_ui->DisplayHeader();
! 
!                       $this->t->set_file('Commit','commit.tpl');
!                       $this->t->set_block('Commit','Category','Cblock');
!                       $this->t->set_block('Commit','Page','Pblock');
!                       $this->t->set_block('Commit','Block','Bblock');
!                       $this->t->set_var(array(
!                               'commit_manager' => lang('Commit changes'),
!                               'lang_categories' => lang('Categories'),
!                               'lang_pages' => lang('Pages'),
!                               'lang_blocks' => lang('Content blocks'),
!                               'lang_commit' => lang('Commit changes')
!                       ));
! 
!                       //Categories
!                       $cats = 
$GLOBALS['Common_BO']->cats->getpermittedcatsCommitable();
!                       while (list(,$cat_id) = @each($cats))
!                       {
!                               $cat = 
$GLOBALS['Common_BO']->cats->getCategory($cat_id,$this->sitelanguages[0]);
!                               $this->t->set_var(array(
!                                       'category' => $cat->name,
!                                       'catid' => $cat_id,
!                                       'addedorremoved' => ($cat->state == 
SITEMGR_STATE_PREPUBLISH) ? 'added' : 'removed',
!                                       'edit' => 
$GLOBALS['phpgw']->link('/index.php',array(
!                                               'cat_id' => $cat_id,
!                                               'menuaction' => 
'sitemgr.Categories_UI.edit'
!                                       ))
!                               ));
!                               $this->t->parse('Cblock','Category',True);
!                       }
! 
!                       //Pages
!                       $pages = 
$GLOBALS['Common_BO']->pages->getpageIDListCommitable();
! 
!                       while (list(,$page_id) = @each($pages))
!                       {
!                               $page = 
$GLOBALS['Common_BO']->pages->getPage($page_id);
!                               $this->t->set_var(array(
!                                       'page' => $page->name,
!                                       'pageid' => $page_id,
!                                       'addedorremoved' => ($page->state == 
SITEMGR_STATE_PREPUBLISH) ? 'added' : 'removed',
!                                       'edit' => 
$GLOBALS['phpgw']->link('/index.php',array(
!                                               'page_id' => $page_id,
!                                               'menuaction' => 
'sitemgr.Pages_UI.edit'
!                                       ))
!                               ));
!                               $this->t->parse('Pblock','Page',True);
!                       }
! 
!                       //Content Blocks
!                       $blocks = $this->bo->getcommitableblocks();
!                       while (list($block_id,$block) = @each($blocks))
!                       {
!                               $this->t->set_var(array(
!                                       'block' => 
$this->bo->getlangblocktitle($block_id,$this->sitelanguages[0]),
!                                       'blockid' => $block_id,
!                                       'scope' => 
$this->blockscope($block->cat_id,$block->page_id),
!                                       'addedorremovedorreplaced' => 
($block->cnt == 2) ? 'replaced' : 
!                                               (($block->state == 
SITEMGR_STATE_PREPUBLISH) ? 'added' : 'removed'),
!                                       'edit' =>  
$GLOBALS['phpgw']->link('/index.php',array(
!                                               'block_id' => $block_id,
!                                               'menuaction' => 
'sitemgr.Content_UI.manage'
!                                       ))
!                               ));
!                               $this->t->parse('Bblock','Block',True);
!                       }
! 
!                       $this->t->pfp('out', 'Commit');
!                       $this->common_ui->DisplayFooter();
!               }
! 
!               function archive()
!               {
!                       if ($_POST['btnReactivate'])
!                       {
!                               while(list($cat_id,) = @each($_POST['cat']))
!                               {
!                                       
$GLOBALS['Common_BO']->cats->reactivate($cat_id);
!                               }
!                               while(list($page_id,) = @each($_POST['page']))
!                               {
!                                       
$GLOBALS['Common_BO']->pages->reactivate($page_id);
!                               }
!                               while(list($block_id,) = @each($_POST['block']))
!                               {
!                                       $this->bo->reactivate($block_id);
!                               }
!                       }
! 
!                       $this->common_ui->DisplayHeader();
! 
!                       $this->t->set_file('Commit','archive.tpl');
!                       $this->t->set_block('Commit','Category','Cblock');
!                       $this->t->set_block('Commit','Page','Pblock');
!                       $this->t->set_block('Commit','Block','Bblock');
!                       $this->t->set_var(array(
!                               'commit_manager' => lang('Archived content'),
!                               'lang_categories' => lang('Categories'),
!                               'lang_pages' => lang('Pages'),
!                               'lang_blocks' => lang('Content blocks'),
!                               'lang_reactivate' => lang('Reactivate content')
!                       ));
! 
!                       //Categories
!                       $cats = 
$GLOBALS['Common_BO']->cats->getpermittedcatsArchived();
!                       //we have to append the archived cats to the 
currentcats, in order to be able to access them later
!                       $GLOBALS['Common_BO']->cats->currentcats = 
array_merge($GLOBALS['Common_BO']->cats->currentcats,$cats);
!                       while (list(,$cat_id) = @each($cats))
!                       {
!                               $cat = 
$GLOBALS['Common_BO']->cats->getCategory($cat_id,$this->sitelanguages[0],True);
!                               $this->t->set_var(array(
!                                       'category' => $cat->name,
!                                       'catid' => $cat_id,
!                                       'edit' => 
$GLOBALS['phpgw']->link('/index.php',array(
!                                               'cat_id' => $cat_id,
!                                               'menuaction' => 
'sitemgr.Categories_UI.edit'
!                                       ))
!                               ));
!                               $this->t->parse('Cblock','Category',True);
!                       }
! 
!                       //Pages
!                       $pages = 
$GLOBALS['Common_BO']->pages->getpageIDListArchived();
! 
!                       while (list(,$page_id) = @each($pages))
!                       {
!                               $page = 
$GLOBALS['Common_BO']->pages->getPage($page_id);
!                               $this->t->set_var(array(
!                                       'page' => $page->name,
!                                       'pageid' => $page_id,
!                                       'edit' => 
$GLOBALS['phpgw']->link('/index.php',array(
!                                               'page_id' => $page_id,
!                                               'menuaction' => 
'sitemgr.Pages_UI.edit'
!                                       ))
!                               ));
!                               $this->t->parse('Pblock','Page',True);
!                       }
! 
!                       //Content Blocks
!                       $blocks = $this->bo->getarchivedblocks();
!                       while (list($block_id,$block) = @each($blocks))
!                       {
!                               $this->t->set_var(array(
!                                       'block' => 
$this->bo->getlangblocktitle($block_id,$this->sitelanguages[0]),
!                                       'blockid' => $block_id,
!                                       'scope' => 
$this->blockscope($block->cat_id,$block->page_id),
!                                       'edit' =>  
$GLOBALS['phpgw']->link('/index.php',array(
!                                               'block_id' => $block_id,
!                                               'menuaction' => 
'sitemgr.Content_UI.manage'
!                                       ))
!                               ));
!                               $this->t->parse('Bblock','Block',True);
!                       }
! 
!                       $this->t->pfp('out', 'Commit');
!                       $this->common_ui->DisplayFooter();
                }
  
***************
*** 338,341 ****
--- 479,639 ----
                        }
                        return $returnValue;
+               }
+ 
+               function blockscope($cat_id,$page_id)
+               {
+                       if ($cat_id == CURRENT_SITE_ID)
+                       {
+                               $scope = lang('Site wide');
+                       }
+                       else
+                       {
+                               $cat = 
$GLOBALS['Common_BO']->cats->getCategory($cat_id);
+                               $scope = lang('Category') . ' ' . $cat->name;
+                               if ($page_id)
+                               {
+                                       $page = 
$GLOBALS['Common_BO']->pages->getPage($page_id);
+                                       $scope .= ' - ' . lang('Page') . ' ' . 
$page->name;
+                               }
+                       }
+                       return $scope;
+               }
+ 
+               //if the block is shown on its own ($standalone), we add 
information about its,scope 
+               function showblock($block,$editable,$standalone=False)
+               {
+                       global $page_id,$cat_id, $inputblockid;
+                       //TODO: wrap a module storage around createmodule as in 
template3, 
+                       //TODO: so that we do not create the same module object 
twice
+                       $moduleobject = 
$this->modulebo->createmodule($block->module_name);
+                       $this->t->set_var(array(
+                               'moduleinfo' => ($block->module_name),
+                               'description' => $moduleobject->description,
+                               'savelang' => $this->langselect
+                       ));
+ 
+                       //if the block is in our scope and we are entitled we 
edit it
+                       if ($editable)
+                       {
+                               $editorstandardelements = array(
+                                       array('label' => lang('Title'),
+                                                 'form' => ('<input 
type="text" name="inputblocktitle" value="' . 
+                                                       ($block->title ? 
$block->title : $moduleobject->title) . '" />')
+                                       ),
+                                       array('label' => lang('Seen by'),
+                                                 'form' => ('<select 
name="inputblockview">' .
+                                                       
$this->inputviewselect((int)$block->view) . '</select>')
+                                       ),
+                                       array('label' => lang('Sort order'),
+                                                 'form' => ('<input 
type="text" name="inputblocksort" size="2" value="' .
+                                                       (int)$block->sort_order 
. '">')
+                                       )
+                               );
+                               if ($standalone)
+                               {
+                                       $editorstandardelements[] = array(
+                                               'label' => lang('Scope'),
+                                               'form' => 
$this->blockscope($block->cat_id,$block->page_id)
+                                       );
+                               }
+ 
+                               $moduleobject->set_block($block);
+ 
+                               $this->t->set_var(Array(
+                                       'blockid' => $block->id,
+                                       'validationerror' => (($block->id == 
$inputblockid) && $this->errormsg) ? join('<br>',$this->errormsg) : '',
+                               ));
+                               $this->t->set_var('standardelements','');
+                               while (list(,$element) = 
each($editorstandardelements))
+                               {
+                                       $this->t->set_var(Array(
+                                               'label' => $element['label'],
+                                               'form' => $element['form']
+                                       ));
+                                       
$this->t->parse('standardelements','EditorElement', true);
+                               }
+ 
+                               $versions = 
$this->bo->getallversionsforblock($block->id,$this->worklanguage);
+                               $this->t->set_var('EvBlock','');
+                               while (list($version_id,$version) = 
each($versions))
+                               {
+                                       //set the version of the block which is 
referenced by the moduleobject, 
+                                       //so that we retrieve a interface with 
the current version's arguments 
+                                       $block->set_version($version);
+                                       $editormoduleelements = 
$moduleobject->get_user_interface();
+                                       $this->t->set_var(array(
+                                               'version_id' => $version_id,
+                                               'state' => 
$GLOBALS['Common_BO']->inputstateselect($version['state']),
+                                               'deleteversion' => lang('Delete 
Version'),
+                                               'versionelements' => ''
+                                       ));
+                                       while (list(,$element) = 
each($editormoduleelements))
+                                       {
+                                               $this->t->set_var(Array(
+                                                       'label' => 
$element['label'],
+                                                       'form' => 
$element['form']
+                                               ));
+                                               
$this->t->parse('versionelements','EditorElement', true);
+                                       }
+                                       $this->t->parse('EvBlock','Version', 
true);
+                               }
+ 
+                               $this->t->parse('MeBlock','Moduleeditor');
+                               $this->t->set_var('MvBlock','');
+                       }
+                       //otherwise we only show it
+                       else
+                       {
+                               if ($block->page_id)
+                               {
+                                       $blockscope = lang('Page');
+                               }
+                               elseif ($block->cat_id != CURRENT_SITE_ID)
+                               {
+                                       $cat = 
$GLOBALS['Common_BO']->cats->getCategory($block->cat_id);
+                                       $blockscope =  lang('Category') . ' - ' 
. $cat->name;
+                               }
+                               else
+                               {
+                                       $blockscope =  lang('Site');
+                               }
+ 
+                               $viewstandardelements = array(
+                                       array('label' => lang('Scope'),
+                                                 'value' => $blockscope
+                                       ),
+                                       array('label' => lang('Title'),
+                                                 'value' => ($block->title ? 
$block->title : $moduleobject->title)
+                                       ),
+                                       array('label' => lang('Seen by'),
+                                                 'value' => 
$this->viewable[(int)$block->view]
+                                       ),
+                                       array('label' => lang('Sort order'),
+                                                 'value' => 
(int)$block->sort_order
+                                       )
+                               );
+ //                                                            
$viewmoduleelements = array();
+ //                                                            while 
(list($argument,$argdef) = @each($moduleobject->arguments))
+ //                                                            {
+ //                                                                    $value 
= $block->arguments[$argument];
+ //                                                                    
$viewmoduleelements[] = array(
+ //                                                                            
'label' => $argdef['label'],
+ //                                                                            
'value' => $GLOBALS['phpgw']->strip_html($value)
+ //                                                                    );
+ //                                                            }
+ //                                                            $interface = 
array_merge($viewstandardelements,$viewmoduleelements);
+ $interface = $viewstandardelements;
+                               $this->t->set_var('VeBlock','');
+                               while (list(,$element) = each($interface))
+                               {
+                                       $this->t->set_var(Array(
+                                               'label' => $element['label'],
+                                               'value' => $element['value'])
+                                       );
+                                       
$this->t->parse('VeBlock','ViewElement', true);
+                               }
+                               $this->t->parse('MvBlock','Moduleview');
+                               $this->t->set_var('MeBlock','');
+                       }
                }
        }

Index: class.Modules_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Modules_BO.inc.php,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** class.Modules_BO.inc.php    4 Mar 2003 17:26:43 -0000       1.2
--- class.Modules_BO.inc.php    23 Jun 2003 20:31:21 -0000      1.2.2.1
***************
*** 25,29 ****
                function 
savemoduleproperties($module_id,$element,$contentarea,$cat_id)
                {
!                       
$this->so->savemoduleproperties($module_id,$element,$contentarea,$cat_id);
                }
  
--- 25,34 ----
                function 
savemoduleproperties($module_id,$element,$contentarea,$cat_id)
                {
!                       $module = $this->getmodule($module_id);
!                       $moduleobject = 
$this->createmodule($module['module_name']);
!                       if ($moduleobject->validate_properties($element))
!                       {
!                               
$this->so->savemoduleproperties($module_id,$element,$contentarea,$cat_id);
!                       }
                }
  
***************
*** 145,150 ****
                function getcascadingmodulepermissions($contentarea,$cat_id)
                {
!                       $cat_ancestorlist = 
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id);
!                       $cat_ancestorlist[] = 0;
  
                        $cat_ancestorlist_temp = $cat_ancestorlist;
--- 150,155 ----
                function getcascadingmodulepermissions($contentarea,$cat_id)
                {
!                       $cat_ancestorlist = ($cat_id !=  CURRENT_SITE_ID) ? 
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id) : array();
!                       $cat_ancestorlist[] = CURRENT_SITE_ID;
  
                        $cat_ancestorlist_temp = $cat_ancestorlist;
***************
*** 173,178 ****
                function 
getcascadingmoduleproperties($module_id,$contentarea,$cat_id,$modulename=False)
                {
!                       $cat_ancestorlist = 
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id);
!                       $cat_ancestorlist[] = 0;
  
                        $cat_ancestorlist_temp = $cat_ancestorlist;
--- 178,183 ----
                function 
getcascadingmoduleproperties($module_id,$contentarea,$cat_id,$modulename=False)
                {
!                       $cat_ancestorlist = ($cat_id !=  CURRENT_SITE_ID) ? 
$GLOBALS['Common_BO']->cats->getCategoryancestorids($cat_id) : array();
!                       $cat_ancestorlist[] = CURRENT_SITE_ID;
  
                        $cat_ancestorlist_temp = $cat_ancestorlist;

Index: class.Modules_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Modules_UI.inc.php,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -r1.2.2.1 -r1.2.2.2
*** class.Modules_UI.inc.php    3 May 2003 21:10:40 -0000       1.2.2.1
--- class.Modules_UI.inc.php    23 Jun 2003 20:31:21 -0000      1.2.2.2
***************
*** 12,18 ****
                var $public_functions = array
                (
!                       '_manageModules' => True,
                        'findmodules' => True,
!                       '_configureModule' => True
                );
  
--- 12,18 ----
                var $public_functions = array
                (
!                       'manage' => True,
                        'findmodules' => True,
!                       'configure' => True
                );
  
***************
*** 23,29 ****
                        $this->bo = &$GLOBALS['Common_BO']->modules;
                        $this->acl = &$GLOBALS['Common_BO']->acl;
                }
  
!               function _manageModules()
                {
                        $this->common_ui->DisplayHeader();
--- 23,30 ----
                        $this->bo = &$GLOBALS['Common_BO']->modules;
                        $this->acl = &$GLOBALS['Common_BO']->acl;
+                       $this->catbo = &$GLOBALS['Common_BO']->cats;
                }
  
!               function manage()
                {
                        $this->common_ui->DisplayHeader();
***************
*** 34,48 ****
                                global $btnselect,$inputmodules,$inputarea;
                                $cat_id = $_GET['cat_id'];
-                               $scopename = lang(($cat_id) ? 'Category' : 
'Site');
  
                                $this->modules = $this->bo->getallmodules();
  
!                               if ($cat_id)
                                {
!                                               $catbo = 
CreateObject('sitemgr.Categories_BO');
!                                               $cat = 
$catbo->getCategory($cat_id);
                                                $cat_name = $cat->name;
!                                               $managelink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories');
                                                $goto = lang('Category 
manager');
                                }
  
--- 35,52 ----
                                global $btnselect,$inputmodules,$inputarea;
                                $cat_id = $_GET['cat_id'];
  
                                $this->modules = $this->bo->getallmodules();
  
!                               if ($cat_id != CURRENT_SITE_ID)
                                {
!                                               $cat = 
$this->catbo->getCategory($cat_id);
                                                $cat_name = $cat->name;
!                                               $managelink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI.manage');
                                                $goto = lang('Category 
manager');
+                                               $scopename = lang('Category');
+                               }
+                               else
+                               {
+                                       $scopename = lang('Site');
                                }
  
***************
*** 50,54 ****
                                
$this->t->set_block('Managemodules','Contentarea','CBlock');
                                $this->t->set_var(array(
!                                       'module_manager' => lang('Module 
manager'),
                                        'lang_help_module_manager' => lang('You 
can choose the modules that can be used on the site. The first list is a sort 
of master list, that is consulted if you do not configure lists specific to 
contentareas or (sub)categories. Then you can choose lists specific to each 
content area. In the category manager these lists can be overriden for each 
(sub)category.'),
                                        'lang_findmodules' => lang('Register 
new modules'),
--- 54,58 ----
                                
$this->t->set_block('Managemodules','Contentarea','CBlock');
                                $this->t->set_var(array(
!                                       'module_manager' => lang('%1 module 
manager', $scopename),
                                        'lang_help_module_manager' => lang('You 
can choose the modules that can be used on the site. The first list is a sort 
of master list, that is consulted if you do not configure lists specific to 
contentareas or (sub)categories. Then you can choose lists specific to each 
content area. In the category manager these lists can be overriden for each 
(sub)category.'),
                                        'lang_findmodules' => lang('Register 
new modules'),
***************
*** 61,67 ****
                                $link_data['menuaction'] = 
"sitemgr.Modules_UI.findmodules";
                                $this->t->set_var('findmodules', 
$GLOBALS['phpgw']->link('/index.php',$link_data));
!                               $link_data['menuaction'] = 
"sitemgr.Modules_UI._configureModule";
                                $this->t->set_var('configureurl', 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                                $contentareas = 
$GLOBALS['Common_BO']->content->getContentAreas();
                                array_unshift($contentareas,'__PAGE__');
  
--- 65,75 ----
                                $link_data['menuaction'] = 
"sitemgr.Modules_UI.findmodules";
                                $this->t->set_var('findmodules', 
$GLOBALS['phpgw']->link('/index.php',$link_data));
!                               $link_data['menuaction'] = 
"sitemgr.Modules_UI.configure";
                                $this->t->set_var('configureurl', 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                                $contentareas = 
$GLOBALS['Common_BO']->content->getContentAreas();
+                               if (!is_array($contentareas))
+                               {
+                                       $contentareas = array();
+                               }
                                array_unshift($contentareas,'__PAGE__');
  
***************
*** 99,106 ****
                {
                        $this->bo->findmodules();
!                       $this->_manageModules();
                }
  
!               function _configureModule()
                {
                        if ($this->acl->is_admin())
--- 107,114 ----
                {
                        $this->bo->findmodules();
!                       $this->manage();
                }
  
!               function configure()
                {
                        if ($this->acl->is_admin())
***************
*** 112,126 ****
                                {
                                        $this->errormsg = lang("You did not 
choose a module.");
!                                       $this->_manageModules();
                                        return;
                                }
                                $cat_id = $_GET['cat_id'];
-                               $scopename = lang(($cat_id) ? 'Category' : 
'Site');
- 
  
                                if ($btnSaveProperties)
                                {
                                        
$this->bo->savemoduleproperties($inputmodule_id,$element,$inputarea,$cat_id);
!                                       $this->_manageModules();
                                        return;
                                }
--- 120,132 ----
                                {
                                        $this->errormsg = lang("You did not 
choose a module.");
!                                       $this->manage();
                                        return;
                                }
                                $cat_id = $_GET['cat_id'];
  
                                if ($btnSaveProperties)
                                {
                                        
$this->bo->savemoduleproperties($inputmodule_id,$element,$inputarea,$cat_id);
!                                       $this->manage();
                                        return;
                                }
***************
*** 128,132 ****
                                {
                                        
$this->bo->deletemoduleproperties($inputmodule_id,$inputarea,$cat_id);
!                                       $this->_manageModules();
                                        return;
                                }
--- 134,138 ----
                                {
                                        
$this->bo->deletemoduleproperties($inputmodule_id,$inputarea,$cat_id);
!                                       $this->manage();
                                        return;
                                }
***************
*** 134,141 ****
                                $this->common_ui->DisplayHeader();
                                
!                               if ($cat_id)
                                {
!                                               $catbo = 
CreateObject('sitemgr.Categories_BO');
!                                               $cat = 
$catbo->getCategory($cat_id);
                                                $cat_name = $cat->name;
                                }
--- 140,146 ----
                                $this->common_ui->DisplayHeader();
                                
!                               if ($cat_id != CURRENT_SITE_ID)
                                {
!                                               $cat = 
$this->catbo->getCategory($cat_id);
                                                $cat_name = $cat->name;
                                }
***************
*** 172,176 ****
                                                $module['module_name'],
                                                ($inputarea == '__PAGE__' ? 
lang('the whole page') : (lang('Contentarea') . $inputarea)),
!                                               ($cat_id ? ('category ' . 
$cat_name) : ' the whole site')
                                        ),
                                        'module_id' => $inputmodule_id,
--- 177,181 ----
                                                $module['module_name'],
                                                ($inputarea == '__PAGE__' ? 
lang('the whole page') : (lang('Contentarea') . $inputarea)),
!                                               (($cat_id != CURRENT_SITE_ID) ? 
('category ' . $cat_name) : ' the whole site')
                                        ),
                                        'module_id' => $inputmodule_id,
***************
*** 184,188 ****
                                );
                                $link_data['cat_id'] = $cat_id;
!                               $link_data['menuaction'] = 
"sitemgr.Modules_UI._manageModules";
                                $this->t->set_var('backlink',
                                        '<a href="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data) . 
--- 189,193 ----
                                );
                                $link_data['cat_id'] = $cat_id;
!                               $link_data['menuaction'] = 
"sitemgr.Modules_UI.manage";
                                $this->t->set_var('backlink',
                                        '<a href="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data) . 

Index: class.Page_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Page_SO.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -r1.5 -r1.5.2.1
*** class.Page_SO.inc.php       17 Jan 2003 03:37:52 -0000      1.5
--- class.Page_SO.inc.php       23 Jun 2003 20:31:21 -0000      1.5.2.1
***************
*** 11,15 ****
                var $lang;
                var $block;
!               
                function Page_SO()
                {
--- 11,16 ----
                var $lang;
                var $block;
!               var $state;
! 
                function Page_SO()
                {

Index: class.Pages_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_BO.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C2 -r1.5 -r1.5.2.1
*** class.Pages_BO.inc.php      18 Jan 2003 04:30:34 -0000      1.5
--- class.Pages_BO.inc.php      23 Jun 2003 20:31:21 -0000      1.5.2.1
***************
*** 2,19 ****
        class Pages_BO
        {
!               var $pageso;
  
                function Pages_BO()
                {
!                       $this->pageso = CreateObject('sitemgr.Pages_SO',True);
                }
  
                function getPageOptionList()
                {
!                       $pagelist = $this->pageso->getPageIDList();
!                       $retval[]=array('value'=>'','display'=>'[' .lang('Show 
Site Index') . ']');
                        foreach($pagelist as $page_id)
                        {
!                               $page = $this->pageso->getPage($page_id);
                                
$retval[]=array('value'=>$page_id,'display'=>$page->name);
                        }
--- 2,19 ----
        class Pages_BO
        {
!               var $so;
  
                function Pages_BO()
                {
!                       $this->so = CreateObject('sitemgr.Pages_SO',True);
                }
  
                function getPageOptionList()
                {
!                       $pagelist = 
$this->so->getPageIDList(0,$GLOBALS['Common_BO']->getstates('Production'));
!                       $retval[]=array('value'=>0,'display'=>'[' .lang('Show 
Site Index') . ']');
                        foreach($pagelist as $page_id)
                        {
!                               $page = $this->so->getPage($page_id);
                                
$retval[]=array('value'=>$page_id,'display'=>$page->name);
                        }
***************
*** 21,34 ****
                }
  
!               function getPageIDList($cat_id=0)
                {
!                       if 
($GLOBALS['Common_BO']->acl->can_read_category($cat_id))
!                       {
!                               return $this->pageso->getPageIDList($cat_id);   
!                       }
!                       else
!                       {
!                               return false;
!                       }
                }
  
--- 21,39 ----
                }
  
!               function getpageIDListCommitable()
                {
!                       //only retrieve commitable pages from writeable 
categories
!                       return 
$this->so->getPageIDList($GLOBALS['Common_BO']->cats->getpermittedcatsWrite(),$GLOBALS['Common_BO']->getstates('Commit'));
!               }
! 
!               function getpageIDListArchived()
!               {
!                       //only retrieve archived pages from writeable categories
!                       return 
$this->so->getPageIDList($GLOBALS['Common_BO']->cats->getpermittedcatsWrite(),$GLOBALS['Common_BO']->getstates('Archive'));
!               }
! 
!               function getPageIDList($cat_id=0,$states=false)
!               {
!                       return $this->so->getPageIDList($cat_id,$states);       
                }
  
***************
*** 37,41 ****
                        if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
                        {
!                               return $this->pageso->addPage($cat_id);
                        }
                        else
--- 42,46 ----
                        if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
                        {
!                               return $this->so->addPage($cat_id);
                        }
                        else
***************
*** 45,75 ****
                }
  
!               function removePagesInCat($cat_id)
                {
!                       $pages = $this->pageso->getPageIDList($cat_id);
                        while(list(,$page_id) = each($pages))
                        {
!                               $this->removePage($cat_id,$page_id);
                        }
                }
  
!               function removePage($cat_id, $page_id)
                {
!                       if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
!                       {
!                               $this->pageso->removePage($page_id);
!                               
$GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,$page_id);
!                       }
!                       else
                        {
!                               return false;
                        }
                }
  
                function getPage($page_id,$lang=False)
                {
!                       if ($GLOBALS['Common_BO']->acl->can_read_page($page_id))
                        {
!                               return $this->pageso->getPage($page_id,$lang);
                        }
                        else
--- 50,95 ----
                }
  
!               function removePagesInCat($cat_id,$force=False)
                {
!                       if (!($force || 
$GLOBALS['Common_BO']->acl->can_write_category($cat_id)))
!                       {
!                               return false;
!                       }
!                       $pages = $this->so->getPageIDList($cat_id);
                        while(list(,$page_id) = each($pages))
                        {
!                               $this->removePage($page_id,True);
                        }
                }
  
!               function removePage($page_id,$force=False)
                {
!                       $cat_id = $this->so->getcatidforpage($page_id);
!                       if (!$force)
                        {
!                               if 
(!$GLOBALS['Common_BO']->acl->can_write_category($cat_id))
!                               {
!                                       return false;
!                               }
                        }
+                       $this->so->removePage($page_id);
+                       //since we already did the ACL we force
+                       
$GLOBALS['Common_BO']->content->removeBlocksInPageOrCat($cat_id,$page_id,True);
                }
  
                function getPage($page_id,$lang=False)
                {
!                       $page = $this->so->getPage($page_id,$lang);
!                       if ($page && 
in_array($page->cat_id,$GLOBALS['Common_BO']->cats->readablecats))
                        {
!                               //if the page is not in published status we 
maintain its name so that switching from edit to prodcution mode works
!                               if 
(!in_array($page->state,$GLOBALS['Common_BO']->visiblestates))
!                               {
!                                       $page->title = lang('Error accessing 
page');
!                                       $page->subtitle = '';
!                                       $page->id = 0;
!                                       $page->cat_id = 0;
!                               }
!                               return $page;
                        }
                        else
***************
*** 86,95 ****
                function getlangarrayforpage($page_id)
                {
!                       return $this->pageso->getlangarrayforpage($page_id);
                }
  
                function savePageInfo($page_Info,$lang)
                {
!                       if 
(!$GLOBALS['Common_BO']->acl->can_write_category($page_Info->cat_id))
                        {
                                return lang("You don't have permission to write 
to that category.");
--- 106,120 ----
                function getlangarrayforpage($page_id)
                {
!                       return $this->so->getlangarrayforpage($page_id);
                }
  
                function savePageInfo($page_Info,$lang)
                {
!                       $oldpage = $this->getpage($page_Info->id);
! 
!                       if(
!                               
!($GLOBALS['Common_BO']->acl->can_write_category($page_Info->cat_id) && 
!                               
$GLOBALS['Common_BO']->acl->can_write_category($oldpage->cat_id))
!                       )
                        {
                                return lang("You don't have permission to write 
to that category.");
***************
*** 99,156 ****
                        if ($fixed_name != $page_Info->name)
                        {
-                               $fixed_name = strtr($page_Info->name, 
'address@hidden&*()-_=+   /?><,.\\\'":;|`~{}[]','                       ');
-                               $fixed_name = str_replace(' ', '', $fixed_name);
-                               if ($fixed_name != $page_Info->name)
-                               {
-                                       $page_Info->name = $fixed_name;
-                                       $this->pageso->savePageInfo($page_Info);
-                                       
$this->pageso->savePageLang($page_Info,$lang);
-                                       return lang('The Name field cannot 
contain punctuation or spaces (field modified).');
-                               }
-                               if ($this->pageso->savePageInfo($page_Info))
-                               {
-                                       
$this->pageso->savePageLang($page_Info,$lang);
-                                       return lang('The page was successfully 
saved.');
-                               }
-                               else
-                               {
-                                       return lang('There was an error writing 
to the database.');
-                               }
-                               //MT: are the following three lines ever 
executed?
                                $page_Info->name = $fixed_name;
!                               $this->pageso->savePageInfo($page_Info);
                                return lang('The Name field cannot contain 
punctuation or spaces (field modified).');
                        }
!                       if 
($this->pageso->pageExists($page_Info->name,$page_Info->id))
                        {
                                $page_Info->name .= '--FIX-DUPLICATE-NAME';
!                               $this->pageso->savePageInfo($page_Info);
!                               $this->pageso->savePageLang($page_Info,$lang);
                                return lang('The page name must be unique.');
                        }
!                       if ($this->pageso->savePageInfo($page_Info))
!                       {
!                               $this->pageso->savePageLang($page_Info,$lang);
!                               return True;
!                       } 
!                       else
!                       {
!                               return lang('There was an error writing to the 
database.');
!                       }
                }
  
                function savePageLang($page_Info,$lang)
!                 {
!                   $this->pageso->savePageLang($page_Info,$lang);
!                 }
  
                function removealllang($lang)
                {
!                       $this->pageso->removealllang($lang);
                }
  
                function migratealllang($oldlang,$newlang)
                {
!                       $this->pageso->migratealllang($oldlang,$newlang);
                }
        }
--- 124,175 ----
                        if ($fixed_name != $page_Info->name)
                        {
                                $page_Info->name = $fixed_name;
!                               $this->so->savePageInfo($page_Info);
!                               $this->so->savePageLang($page_Info,$lang);
                                return lang('The Name field cannot contain 
punctuation or spaces (field modified).');
                        }
!                       if 
($this->so->pageExists($page_Info->name,$page_Info->id))
                        {
                                $page_Info->name .= '--FIX-DUPLICATE-NAME';
!                               $this->so->savePageInfo($page_Info);
!                               $this->so->savePageLang($page_Info,$lang);
                                return lang('The page name must be unique.');
                        }
!                       $this->so->savePageInfo($page_Info);
!                       $this->so->savePageLang($page_Info,$lang);
!                       return True;
                }
  
                function savePageLang($page_Info,$lang)
!               {
!                   $this->so->savePageLang($page_Info,$lang);
!               }
  
                function removealllang($lang)
                {
!                       $this->so->removealllang($lang);
                }
  
                function migratealllang($oldlang,$newlang)
                {
!                       $this->so->migratealllang($oldlang,$newlang);
!               }
! 
!               function commit($page_id)
!               {
!                       $cat_id = $this->so->getcatidforpage($page_id);
!                       if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
!                       {
!                               $this->so->commit($page_id);
!                       }
!               }
! 
!               function reactivate($page_id)
!               {
!                       $cat_id = $this->so->getcatidforpage($page_id);
!                       if 
($GLOBALS['Common_BO']->acl->can_write_category($cat_id))
!                       {
!                               $this->so->reactivate($page_id);
!                       }
                }
        }

Index: class.Pages_SO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_SO.inc.php,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C2 -r1.12 -r1.12.2.1
*** class.Pages_SO.inc.php      28 Jan 2003 20:00:00 -0000      1.12
--- class.Pages_SO.inc.php      23 Jun 2003 20:31:21 -0000      1.12.2.1
***************
*** 9,30 ****
                }
  
!               function getPageIDList($cat_id=0)
                {
!                       if (!$cat_id)
!                       {
!                               $sql = 'SELECT page_id FROM phpgw_sitemgr_pages 
WHERE 1=1 ORDER BY cat_id, sort_order ASC';
!                       }
!                       else
!                       {
!                               $sql = 'SELECT page_id FROM phpgw_sitemgr_pages 
WHERE cat_id=\'' . $cat_id . '\' ORDER BY sort_order';
!                       }
!                       $this->db->query($sql,__LINE__,__FILE__);
!                       while ($this->db->next_record())
                        {
!                               $page_id_list[] = $this->db->f('page_id');
                        }
!                       if (!is_array($page_id_list))
                        {
!                               $page_id_list = array();
                        }
                        return $page_id_list;
--- 9,41 ----
                }
  
!               
!               //if $cats is an array, pages from this list are retrieved,
!               //is $cats is an int, pages from this cat are retrieved,
!               //if $cats is 0 or false, pages from currentcats are retrieved
!               function getPageIDList($cats=False,$states=false)
                {
!                       if (!$states)
                        {
!                               $states = $GLOBALS['Common_BO']->visiblestates;
                        }
! 
!                       $page_id_list = array();
!                       $cat_list = is_array($cats) ? implode(',',$cats) :
!                               ($cats ? $cats : 
!                                       
($GLOBALS['Common_BO']->cats->currentcats ? 
implode(',',$GLOBALS['Common_BO']->cats->currentcats) : false)
!                               );
!                       if ($cat_list)
                        {
!                               $sql = "SELECT page_id FROM phpgw_sitemgr_pages 
WHERE cat_id IN ($cat_list) ";
!                               if ($states)
!                               {
!                                       $sql .= 'AND state in ('. 
implode(',',$states)  . ')';
!                               }
!                               $sql .=' ORDER BY cat_id, sort_order ASC'; 
!                               $this->db->query($sql,__LINE__,__FILE__);
!                               while ($this->db->next_record())
!                               {
!                                       $page_id_list[] = 
$this->db->f('page_id');
!                               }
                        }
                        return $page_id_list;
***************
*** 90,96 ****
                }
  
                function getPage($page_id,$lang=False)
                {
!                       $sql = 'SELECT * FROM phpgw_sitemgr_pages WHERE 
page_id=\'' . $page_id . '\'';
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
--- 101,121 ----
                }
  
+               function getcatidforpage($page_id)
+               {
+                       $sql = "SELECT cat_id FROM phpgw_sitemgr_pages WHERE 
page_id = $page_id";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       if ($this->db->next_record())
+                       {
+                               return $this->db->f('cat_id');
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+ 
                function getPage($page_id,$lang=False)
                {
!                       $sql = "SELECT * FROM phpgw_sitemgr_pages WHERE 
page_id= $page_id";
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
***************
*** 102,109 ****
                                $page->name = 
stripslashes($this->db->f('name'));
                                $page->hidden = $this->db->f('hide_page');
                                
                                if ($lang)
                                {
!                                       $sql = "SELECT * FROM 
phpgw_sitemgr_pages_lang WHERE page_id='$page_id' and lang='$lang'";
                                        
$this->db->query($sql,__LINE__,__FILE__);
                                
--- 127,135 ----
                                $page->name = 
stripslashes($this->db->f('name'));
                                $page->hidden = $this->db->f('hide_page');
+                               $page->state = $this->db->f('state');
                                
                                if ($lang)
                                {
!                                       $sql = "SELECT * FROM 
phpgw_sitemgr_pages_lang WHERE page_id=$page_id AND lang='$lang'";
                                        
$this->db->query($sql,__LINE__,__FILE__);
                                
***************
*** 152,156 ****
                                'name=\'' . 
$this->db->db_addslashes($pageInfo->name) . '\',' .
                                'sort_order=\'' . (int) $pageInfo->sort_order . 
'\',' .
!                               'hide_page=\'' . $pageInfo->hidden . '\' ' .
                                'WHERE page_id=\'' . $pageInfo->id . '\'';
                        $this->db->query($sql, __LINE__,__FILE__);
--- 178,183 ----
                                'name=\'' . 
$this->db->db_addslashes($pageInfo->name) . '\',' .
                                'sort_order=\'' . (int) $pageInfo->sort_order . 
'\',' .
!                               'hide_page=\'' . $pageInfo->hidden . '\',' .
!                               'state=\'' . $pageInfo->state . '\' ' .
                                'WHERE page_id=\'' . $pageInfo->id . '\'';
                        $this->db->query($sql, __LINE__,__FILE__);
***************
*** 189,192 ****
--- 216,233 ----
                {
                        $sql = "UPDATE phpgw_sitemgr_pages_lang SET 
lang='$newlang' WHERE lang='$oldlang'";
+                       $this->db->query($sql, __LINE__,__FILE__);
+               }
+ 
+               function commit($page_id)
+               {
+                       $sql = "UPDATE phpgw_sitemgr_pages SET state = " . 
SITEMGR_STATE_PUBLISH . " WHERE state = " . SITEMGR_STATE_PREPUBLISH . " AND 
page_id = $page_id";
+                       $this->db->query($sql, __LINE__,__FILE__);
+                       $sql = "UPDATE phpgw_sitemgr_pages SET state = " . 
SITEMGR_STATE_ARCHIVE . " WHERE state = " . SITEMGR_STATE_PREUNPUBLISH . " AND 
page_id = $page_id";;
+                       $this->db->query($sql, __LINE__,__FILE__);
+               }
+ 
+               function reactivate($page_id)
+               {
+                       $sql = "UPDATE phpgw_sitemgr_pages SET state = " . 
SITEMGR_STATE_DRAFT . " WHERE state = " . SITEMGR_STATE_ARCHIVE . " AND page_id 
= $page_id";
                        $this->db->query($sql, __LINE__,__FILE__);
                }

Index: class.Pages_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Pages_UI.inc.php,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -r1.1 -r1.1.2.1
*** class.Pages_UI.inc.php      17 Jan 2003 03:37:52 -0000      1.1
--- class.Pages_UI.inc.php      23 Jun 2003 20:31:21 -0000      1.1.2.1
***************
*** 13,30 ****
        {
                var $common_ui;
-               var $cat_id;
-               var $page_id;
                var $t;
                var $pagebo;
                var $categorybo;
                var $pageso; // page class
-               var $category;
-               var $cat_list;
-               var $page_list;
                var $sitelanguages;
                
                var $public_functions=array
                (
!                       '_managePage' => True
                );
                
--- 13,26 ----
        {
                var $common_ui;
                var $t;
                var $pagebo;
                var $categorybo;
                var $pageso; // page class
                var $sitelanguages;
                
                var $public_functions=array
                (
!                       'edit' => True,
!                       'delete' => True
                );
                
***************
*** 35,337 ****
                        $this->pagebo = &$GLOBALS['Common_BO']->pages;
                        $this->categorybo = &$GLOBALS['Common_BO']->cats;
!                       $preferenceso = 
CreateObject('sitemgr.sitePreference_SO', true);
!                       $this->sitelanguages = 
explode(',',$preferenceso->getPreference('sitelanguages'));
!               }
!               
!               function _addPage($category_id)
!               {
!                       $this->_editPage($category_id, 0);
                }
        
!               function _deletePage($category_id, $page_id)
                {
!                       $this->pagebo->removePage($category_id, $page_id);
                }
  
!               function _editPage($category_id, 
$page_id,$cname='',$ctitle='',$csubtitle='')
                {
!                       
$GLOBALS['Common_BO']->globalize(array('title','name','subtitle','sort_order','parent','hidden','btnEditPage','savelanguage'));
!                       global $title;
!                       global $name;
!                       global $subtitle;
!                       global $sort_order;
!                       global $parent;
!                       global $hidden;
!                       global $btnEditPage;
                        global $savelanguage;
!               
!                       $this->t->set_file('EditPage', 'page_editor.tpl');
!                       if($page_id)
!                       {
!                               $this->page = 
$this->pagebo->getPage($page_id,$this->sitelanguages[0]);
!                               if ($cname)
!                               {
!                                       $this->page->name=$cname;
!                               }
!                               if ($ctitle)
!                               {
!                                       $this->page->title=$ctitle;
!                               }
!                               if ($csubtitle)
!                               {
!                                       $this->page->subtitle=$csubtitle;
!                               }
!                               $this->t->set_var('add_edit',lang('Edit Page'));
!                               
$this->t->set_var('move_to',$this->getParentOptions($this->page->cat_id));
!                       }
!                       else
!                       {
!                               $this->page->title = $title;
!                               $this->page->subtitle = $subtitle;
!                               $this->page->name = $name;
!                               $this->page->sort_order = $sort_order;
!                               $this->page->cat_id = $category_id;
!                               $this->t->set_var('add_edit',lang('Add Page'));
!                               $move_msg = lang('Cannot move page until it has 
been saved.');
!                               $move_msg .= '<INPUT TYPE="hidden" 
name="parent" value="'.
!                                       $category_id.'">';
!                               $this->t->set_var('move_to',$move_msg);
!                       }
!                       
!                       $trans = array('{' => '&#123;', '}' => '&#125;');
!                       if($this->page->hidden)
!                         {
!                                 $this->t->set_var('hidden', 'CHECKED');
!                         }
!                         else
!                         {   
!                                 $this->t->set_var('hidden', '');
!                         }
!                       
!                       if (count($this->sitelanguages) > 1)
!                         {
!                           $select = lang('as') . ' <select 
name="savelanguage">';
!                           
!                           foreach ($this->sitelanguages as $lang)
!                             {
!                               $selected= '';
!                               if ($lang == $page->lang)
!                                 {
!                                   $selected = 'selected="selected" ';
!                                 }
!                               $select .= '<option ' . $selected .'value="' . 
$lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) . '</option>';
!                             }
!                           $select .= '</select> ';
!                           $this->t->set_var('savelang',$select);
!                         }
!                       
!                       $this->t->set_var(array(
!                               'title' =>$this->page->title,
!                               'subtitle' => $this->page->subtitle,
! //                            
'main'=>strtr($GLOBALS['phpgw']->strip_html($this->page->content),$trans),
!                               'name'=>$this->page->name,
!                               'sort_order'=>$this->page->sort_order,
!                               'pageid'=>$page_id,
!                               'category_id' => $category_id,
!                               'lang_name' => lang('Name'),
!                               'lang_title' => lang('Title'),
!                               'lang_subtitle' => lang('Subtitle'),
!                               'lang_sort' => lang('Sort order'),
!                               'lang_move' => lang('Move to'),
!                               'lang_hide' => lang('Check to hide from 
condensed site index.'),
!                               'lang_required' => lang('Required Fields'),
!                               'lang_goback' => lang('Go back to Page 
Manager'),
!                               'lang_reset' => lang('Reset'),
!                               'lang_save' => lang('Save')
!                       ));
  
!                       
!                       
!                       $this->t->set_var('actionurl', 
$GLOBALS['phpgw']->link('/index.php',
!                               'menuaction=sitemgr.Pages_UI._managePage'));
!                       $this->t->set_var('goback', 
$GLOBALS['phpgw']->link('/index.php',
!                                 'menuaction=sitemgr.Pages_UI._managePage'));
!                       $this->t->pfp('out','EditPage');
!               
!               }
!               
!               function _managePage()
!               {
!                       
$GLOBALS['Common_BO']->globalize(array('hidden','btnAddPage','btnDelete','btnEditPage','btnPrev','pageid','btnSave','category_id','sort_order','parent','title','name','subtitle','error','savelanguage'));
!                       global $hidden;
!                       global $btnAddPage, $btnDelete, $btnEditPage;
!                       global $btnPrev;
!                       global $btnSave;
!                       global $pageid;
!                       global $category_id;
!                       global $sort_order;
!                       global $parent;
!                       global $title;
!                       global $name;
!                       global $subtitle;
!                       global $error;
!                       global $savelanguage;
  
!                       $this->common_ui->DisplayHeader();
!                       
!                       if($btnSave && !$error)
                        {
!                               if ($name == '' || $title == '')
                                {
!                                       $this->t->set_var('message',lang('You 
failed to fill in one or more required fields.'));
!                                       
$this->_editPage($category_id,$pageid,$name,$title,$subtitle);
!                                       exit;
!                               }
!                               if($pageid)
!                               {
!                                       $this->page->id = $pageid;
                                }
                                else
-                               {               
-                                       $this->page->id = 
$this->pagebo->addPage($category_id);
-                                       $pageid = $this->page->id;
-                                       if(!$this->page->id)
-                                       {
-                                               $save_msg = lang("You don't 
have permission to write in the category");
-                                       }
-                               }
- 
-                               if (!$save_msg)
                                {
!                                       $this->page->title = $title;
!                                       $this->page->name = $name;
!                                       $this->page->subtitle = $subtitle;
!                                       $this->page->sort_order = $sort_order;
!                                       $this->page->cat_id = $parent;
! 
!                                       if($hidden)
                                        {
!                                               $this->page->hidden = 1;
                                        }
                                        else
                                        {
!                                               $this->page->hidden = 0;
                                        }
-                                       $savelanguage = $savelanguage ? 
$savelanguage : $this->sitelanguages[0];
-                                       $save_msg = 
$this->pagebo->savePageInfo($this->page,$savelanguage);
-                               }
-                               if (!is_string($save_msg))
-                               {
-                                       echo('<p><b><font color="red">' . 
lang('Page saved.') . '</font></b></p>');
                                }
-                               else
-                               {
-                                       $this->t->set_var('message',$save_msg);
-                                       
$this->_editPage($category_id,$this->page->id); 
//,$name,$title,$subtitle,$main);
-                                       exit;
-                               }
-                               $btnEditPage = False;
-                               $btnSave = False;
                        }
!                       if($btnPrev)
!                       {
!                               echo lang('Go back to the category manager.');
!                               $btnEditPage = False;
!                               $btnPrev = False;
!                       }
!                       if($btnAddPage)
!                       {
!                               $this->_addPage($category_id);
!                       }
!                       else if($btnEditPage)
                        {
!                               $this->_editPage($category_id, $pageid);
                        }
                        else
                        {
!                               if($btnDelete)
!                               {
!                                       $this->_deletePage($category_id, 
$pageid);
!                               }
!                               
!                               
$this->t->set_file('ManagePage','page_manager.tpl');
!                               $this->t->set_block('ManagePage', 'PageBlock', 
'PBlock');
!                               $this->t->set_block('ManagePage', 
'CategoryBlock', 'CBlock');
!                               $this->t->set_var('page_manager', lang('Page 
Manager'));
!                               $this->cat_list = 
$this->categorybo->getPermittedCatWriteNested();
  
!                               if($this->cat_list)
                                {
!                                       for ($i=0; $i<sizeof($this->cat_list); 
$i++)
                                        {
!                                               $this->category = 
$this->categorybo->getCategory($this->cat_list[$i]);                            
      
!                                               $this->t->set_var('PBlock', '');
!                                               $this->page_list = 
$this->pagebo->getPageIDList($this->cat_list[$i]);
!                                               $this->cat_id = 
$this->cat_list[$i];
!                                               if($this->page_list && 
sizeof($this->page_list)>0)
!                                               {
!                                                       for($j = 0; $j < 
sizeof($this->page_list); $j++)
!                                                       {
!                                                               $this->page_id 
=$this->page_list[$j];
!                                                               $this->page = 
$this->pagebo->getPage($this->page_id,$this->sitelanguages[0]);
!                                                               
$page_description = sprintf(
!                                                                       
'<b>%s</b>: %s &nbsp;&nbsp;<b>ID</b>: %s<br><b>%s</b>: %s',
!                                                                       
lang('Name'),
!                                                                       
$this->page->name,
!                                                                       
$this->page_id,
!                                                                       
lang('Title'),
!                                                                       
$this->page->title
!                                                               );
!                                                               
$this->t->set_var('page', $page_description);
!                                                               
$this->t->set_var('edit',
!                                                                       '<form 
action="'.
!                                                                       
$GLOBALS['phpgw']->link('/index.php',
!                                                                               
'menuaction=sitemgr.Pages_UI._managePage').
!                                                                               
'" method="POST">
!                                                                       <input 
type="submit" name="btnEditPage" value="' . lang('Edit') .'">
!                                                                       <input 
type="hidden" name="category_id" value="'.
!                                                                               
$this->cat_id.'">
!                                                                       <input 
type="hidden" name="parent" value="'.
!                                                                               
$this->cat_id.'">
!                                                                       <input 
type="hidden" name="pageid" value="'. 
!                                                                               
$this->page_id .'">
!                                                                       
</form>');
!                                                               
$this->t->set_var('msg','');
!                                                               
$link_data['menuaction'] = "sitemgr.Content_UI._manageContent";
!                                                               
$link_data['page_id'] = $this->page_id;
!                                                               
$this->t->set_var('manage',
!                                                                       '<form 
action="'.
!                                                                       
$GLOBALS['phpgw']->link('/index.php',$link_data).
!                                                                       '" 
method="POST">
!                                                                       <input 
type="submit" value="' . lang('Manage Content') .'"></form>');
!                                                               
$this->t->set_var('remove', 
!                                                                       '<form 
action="'.$GLOBALS['phpgw']->link('/index.php',
!                                                                       
'menuaction=sitemgr.Pages_UI._managePage').
!                                                                               
'" method="POST">
!                                                                       <input 
type="submit" name="btnDelete" value="' . lang('Delete') .'">
!                                                                       <input 
type="hidden" name="pageid" value="'.$this->page_id.'">
!                                                                       <input 
type="hidden" name="category_id" value="'.
!                                                                               
$this->cat_id.'">
!                                                                       <input 
type="hidden" name="parent" value="'.
!                                                                               
$this->cat_id.'">
!                                                                       
</form>');
!                                                               
$this->t->parse('PBlock', 'PageBlock', true);
!                                                       }
!                                               }
!                                               else
!                                               {
!                                                       $this->t->set_var('msg' 
, lang('This category has no pages.'));
!                                               }
!                                               $this->t->set_var('indent', 
$this->category->depth * 5);
!                                               
$this->t->set_var('category',$this->category->name); 
!                                               $this->t->set_var('add', 
!                                                       '<form action="'.
!                                                       
$GLOBALS['phpgw']->link('/index.php',
!                                                       
'menuaction=sitemgr.Pages_UI._managePage').
!                                                       '" method="POST">
!                                                       <input type=submit 
name="btnAddPage" value="' . lang('Add new page to this category') . '">
!                                                       <input type=hidden 
name="category_id" value ="'.$this->cat_id .'">
!                                                       </form>');
!                                       
!                                               $this->t->parse('CBlock', 
'CategoryBlock', true); 
                                        }
!                                       $this->t->pfp('out','ManagePage');
!                               }
!                               else
!                               {
!                                       echo lang("I'm sorry, you do not have 
write permissions for any site categories.") . '<br><br>';
                                }
                        }
!                       $this->common_ui->DisplayFooter();
                }
  
--- 31,162 ----
                        $this->pagebo = &$GLOBALS['Common_BO']->pages;
                        $this->categorybo = &$GLOBALS['Common_BO']->cats;
!                       $this->sitelanguages = 
$GLOBALS['Common_BO']->sites->current_site['sitelanguages'];
                }
        
!               function delete()
                {
!                       $page_id = $_GET['page_id'];
!                       $this->pagebo->removePage($page_id);
!                       
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
!                       return;
                }
  
!               function edit()
                {
!                       $GLOBALS['Common_BO']->globalize(array(
!                               
'inputhidden','btnAddPage','btnDelete','btnEditPage','btnSave','inputsort','inputstate',
!                               
'inputtitle','inputname','inputsubtitle','savelanguage','inputpageid','inputcategoryid'));
! 
!                       global $inputpageid,$inputcategoryid, $inputhidden, 
$inputstate;
!                       global $btnAddPage, $btnDelete, $btnEditPage, $btnSave;
!                       global $inputsort,$inputtitle, $inputname, 
$inputsubtitle;
                        global $savelanguage;
!                       $page_id = $inputpageid ? $inputpageid : 
$_GET['page_id'];
!                       $category_id = $inputcategoryid ? $inputcategoryid : 
$_GET['cat_id'];
  
!                       $this->t->set_file('EditPage', 'edit_page.tpl');
  
!                       if($btnSave)
                        {
!                               if ($inputname == '' || $inputtitle == '')
                                {
!                                       $error = lang('You failed to fill in 
one or more required fields.');
!                                       $this->t->set_var('message',$error);
                                }
                                else
                                {
!                                       if(!$page_id)
!                                       {               
!                                               $page_id = 
$this->pagebo->addPage($inputcategoryid);
!                                               if(!$page_id)
!                                               {
!       //                                              echo lang("You don't 
have permission to write in the category");
!                                                       
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
!                                                       return;
!                                               }
!                                       }
!                                       $page->id = $page_id;
!                                       $page->title = $inputtitle;
!                                       $page->name = $inputname;
!                                       $page->subtitle = $inputsubtitle;
!                                       $page->sort_order = $inputsort;
!                                       $page->cat_id = $category_id;
!                                       $page->hidden = $inputhidden ? 1: 0;
!                                       $page->state = $inputstate;
!                                       $savelanguage = $savelanguage ? 
$savelanguage : $this->sitelanguages[0];
!                                       $save_msg = 
$this->pagebo->savePageInfo($page,$savelanguage);
!                                       if (!is_string($save_msg))
                                        {
!                                               
$this->t->set_var('message',lang('Page saved'));
                                        }
                                        else
                                        {
!                                               
$this->t->set_var('message',$save_msg);
                                        }
                                }
                        }
! 
!                       if($page_id)
                        {
!                               $page = 
$this->pagebo->getPage($page_id,$this->sitelanguages[0]);
!                               if 
(!$GLOBALS['Common_BO']->acl->can_write_category($page->cat_id))
!                               {
!                                       
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Outline_UI.manage'));
!                                       return;
!                               }
!                               $this->t->set_var(array(
!                                       'add_edit' => lang('Edit Page'),
!                                       'catselect' => 
$this->getParentOptions($page->cat_id)
!                       ));
                        }
                        else
                        {
!                               $this->t->set_var(array(
!                                       'add_edit' => lang('Add Page'),
!                                       'catselect' => 
$this->getParentOptions($category_id)
!                               ));
!                       }
  
!                       if (count($this->sitelanguages) > 1)
!                       {
!                               $select = lang('as') . ' <select 
name="savelanguage">';
!                       
!                               foreach ($this->sitelanguages as $lang)
                                {
!                                       $selected= '';
!                                       if ($lang == $page->lang)
                                        {
!                                               $selected = 
'selected="selected" ';
                                        }
!                                       $select .= '<option ' . $selected 
.'value="' . $lang . '">'. $GLOBALS['Common_BO']->getlangname($lang) . 
'</option>';
                                }
+                               $select .= '</select> ';
+                               $this->t->set_var('savelang',$select);
                        }
! 
!                       $link_data['page_id'] = $page_id;
!                       $link_data['category_id'] = $inputcategoryid;
!                       $this->t->set_var(array(
!                               'title' =>$page->title,
!                               'subtitle' => $page->subtitle,
!                               'name'=>$page->name,
!                               'sort_order'=>$page->sort_order,
!                               'page_id'=>$page_id,
!                               'hidden' => $page->hidden ? 'CHECKED' : '',
!                               'stateselect' => 
$GLOBALS['Common_BO']->inputstateselect($page->state),
!                               'lang_name' => lang('Name'),
!                               'lang_title' => lang('Title'),
!                               'lang_subtitle' => lang('Subtitle'),
!                               'lang_sort' => lang('Sort order'),
!                               'lang_category' => lang('Category'),
!                               'lang_hide' => lang('Check to hide from 
condensed site index.'),
!                               'lang_required' => lang('Required Fields'),
!                               'lang_done' => lang('Done'),
!                               'lang_reset' => lang('Reset'),
!                               'lang_save' => lang('Save'),
!                               'lang_state' => lang('State'),
!                       ));
!                       
!                       $this->t->pfp('out','EditPage');
                }
  
***************
*** 342,349 ****
                        {
                                $selected=' SELECTED'; 
!                       }       
!                       $retval="\n".'<SELECT NAME="parent">'."\n";
                        foreach($option_list as $option)
!                       {   
                                if ((int) $option['value']!=0)
                                {
--- 167,174 ----
                        {
                                $selected=' SELECTED'; 
!                       }
!                       $retval="\n".'<SELECT NAME="inputcategoryid">'."\n";
                        foreach($option_list as $option)
!                       {
                                if ((int) $option['value']!=0)
                                {
***************
*** 356,360 ****
                                        $option['display'].'</OPTION>'."\n";
                                }
!                       }       
                        $retval.='</SELECT>';
                        return $retval;
--- 181,185 ----
                                        $option['display'].'</OPTION>'."\n";
                                }
!                       }
                        $retval.='</SELECT>';
                        return $retval;

Index: class.Theme_BO.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Theme_BO.inc.php,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -r1.4 -r1.4.2.1
*** class.Theme_BO.inc.php      17 Jan 2003 03:37:52 -0000      1.4
--- class.Theme_BO.inc.php      23 Jun 2003 20:31:21 -0000      1.4.2.1
***************
*** 6,25 ****
                function Theme_BO()
                {
-                       $this->preferenceso = 
CreateObject('sitemgr.sitePreference_SO', True);
-               }
- 
-               function setTheme($theme)
-               {
-                       $this->preferenceso->setPreference('themesel',$theme);
-               }
-               
-               function getTheme()
-               {
-                       return $this->preferenceso->getPreference('themesel');
                }
  
                function getAvailableThemes()
                {
!                       $sitemgr_dir = 
$this->preferenceso->getPreference('sitemgr-site-dir');
                        $dirname = $sitemgr_dir . SEP . 'templates' . SEP;
                        $result_array=array();
--- 6,14 ----
                function Theme_BO()
                {
                }
  
                function getAvailableThemes()
                {
!                       $sitemgr_dir = 
$GLOBALS['Common_BO']->sites->current_site['site_dir'];
                        $dirname = $sitemgr_dir . SEP . 'templates' . SEP;
                        $result_array=array();

Index: class.Translations_UI.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.Translations_UI.inc.php,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -r1.3 -r1.3.2.1
*** class.Translations_UI.inc.php       4 Mar 2003 17:26:43 -0000       1.3
--- class.Translations_UI.inc.php       23 Jun 2003 20:31:21 -0000      1.3.2.1
***************
*** 15,19 ****
                var $cat_bo;
                var $acl;
-               var $preferenceso;
                var $sitelanguages;
                var $common_ui;
--- 15,18 ----
***************
*** 24,31 ****
                var $public_functions = array
                (
!                       '_manageTranslations' => True,
!                       '_translateCategory' => True,
!                       '_translatePage' => True,
!                       '_translateSitecontent' => True,
                );
  
--- 23,30 ----
                var $public_functions = array
                (
!                       'manage' => True,
!                       'translateCategory' => True,
!                       'translatePage' => True,
!                       'translateSitecontent' => True,
                );
  
***************
*** 36,41 ****
                        $this->cat_bo = &$GLOBALS['Common_BO']->cats;
                        $this->acl = &$GLOBALS['Common_BO']->acl;
!                       $this->preferenceso = 
CreateObject('sitemgr.sitePreference_SO', true);
!                       $this->sitelanguages = 
explode(',',$this->preferenceso->getPreference('sitelanguages'));
                        $this->pagebo = &$GLOBALS['Common_BO']->pages;
                        $this->contentbo = &$GLOBALS['Common_BO']->content;
--- 35,39 ----
                        $this->cat_bo = &$GLOBALS['Common_BO']->cats;
                        $this->acl = &$GLOBALS['Common_BO']->acl;
!                       $this->sitelanguages = 
$GLOBALS['Common_BO']->sites->current_site['sitelanguages'];
                        $this->pagebo = &$GLOBALS['Common_BO']->pages;
                        $this->contentbo = &$GLOBALS['Common_BO']->content;
***************
*** 43,47 ****
                }
  
!               function _manageTranslations()
                {
                        $this->common_ui->DisplayHeader();
--- 41,45 ----
                }
  
!               function manage()
                {
                        $this->common_ui->DisplayHeader();
***************
*** 59,78 ****
                                $this->t->parse('slBlock', 'sitelanguages', 
true);
                        }
! 
                        $this->t->set_var(Array(
                                'translation_manager' => lang('Translation 
Manager'),
                                'lang_catname' => lang('Category Name'),
!                               'translate_site_content' => 
$GLOBALS['phpgw']->link('/index.php', 
'menuaction=sitemgr.Translations_UI._translateSitecontent'),
                                'lang_site_content' => lang('Translate 
site-wide content blocks'),
                                'colspan' => (count($this->sitelanguages) + 2)
                        ));
!                       $this->cat_list = 
$this->cat_bo->getPermittedCatWriteNested();
!                       if($this->cat_list)
                        {
!                               for($i = 0; $i < sizeof($this->cat_list); $i++)
                                {                       
                                        //setup entry in categorblock for 
translations of categories
!                                       $this->cat = 
$this->cat_bo->getCategory($this->cat_list[$i]);
!                                       if ($this->cat->depth)
                                        {
                                                $buffer = '-';
--- 57,76 ----
                                $this->t->parse('slBlock', 'sitelanguages', 
true);
                        }
!                       $link_data['menuaction'] = 
"sitemgr.Translations_UI.translateSitecontent";
                        $this->t->set_var(Array(
                                'translation_manager' => lang('Translation 
Manager'),
                                'lang_catname' => lang('Category Name'),
!                               'translate_site_content' => 
$GLOBALS['phpgw']->link('/index.php', $link_data),
                                'lang_site_content' => lang('Translate 
site-wide content blocks'),
                                'colspan' => (count($this->sitelanguages) + 2)
                        ));
!                       $cat_list = $this->cat_bo->getpermittedcatsWrite();
!                       if($cat_list)
                        {
!                               for($i = 0; $i < sizeof($cat_list); $i++)
                                {                       
                                        //setup entry in categorblock for 
translations of categories
!                                       $cat = 
$this->cat_bo->getCategory($cat_list[$i]);
!                                       if ($cat->depth)
                                        {
                                                $buffer = '-';
***************
*** 82,92 ****
                                                $buffer = '';
                                        }
!                                       $buffer = 
str_pad('',$this->cat->depth*18,
                                                '&nbsp;',STR_PAD_LEFT).$buffer;
                                        $this->t->set_var('buffer', $buffer);
!                                       $this->t->set_var('category', 
$this->cat->name);
!                                       $category_id = $this->cat_list[$i];
  
!                                       $availablelangsforcat = 
$this->cat_bo->getlangarrayforcategory($category_id);
                                        $this->t->set_var('langcatBlock','');
                                        foreach ($this->sitelanguages as $lang)
--- 80,90 ----
                                                $buffer = '';
                                        }
!                                       $buffer = str_pad('',$cat->depth*18,
                                                '&nbsp;',STR_PAD_LEFT).$buffer;
                                        $this->t->set_var('buffer', $buffer);
!                                       $this->t->set_var('category', 
$cat->name);
!                                       $category_id = $cat_list[$i];
  
!                                       $availablelangsforcat = 
$this->cat_bo->getlangarrayforcategory($cat_list[$i]);
                                        $this->t->set_var('langcatBlock','');
                                        foreach ($this->sitelanguages as $lang)
***************
*** 95,118 ****
                                                $this->t->parse('langcatBlock', 
'langexistcat', true);
                                        }
!                               
                                        $this->t->set_var('translatecat', 
!                                               '<form action="'.
!                                               
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Translations_UI._translateCategory').
!                                               '" method="POST"><input 
type="submit" name="btnTranslateCategory" value="' . lang('Translate') .'">'.
!                                               '<input type="hidden" 
name="category_id" value="'.$category_id.'"></form>');
  
                                        //setup page list
                                        $this->t->set_var('PBlock', '');
!                                       $this->page_list = 
$this->pagebo->getPageIDList($this->cat_list[$i]);
!                                       if($this->page_list && 
sizeof($this->page_list)>0)
                                        {
!                                               for($j = 0; $j < 
sizeof($this->page_list); $j++)
                                                {
!                                                       $this->page_id 
=$this->page_list[$j];
!                                                       $this->page = 
$this->pagebo->getPage($this->page_id,$this->sitelanguages[0]);
!                                                       $page_description = 
'<i>' . lang('Page') . ': </i>'.$this->page->name.'<br><i>' . lang('Title') . 
': </i>'.$this->page->title;
                                                        
$this->t->set_var('page', $page_description);
  
!                                                       $availablelangsforpage 
= $this->pagebo->getlangarrayforpage($this->page_id);
                                                        
$this->t->set_var('langpageBlock','');
                                                        foreach 
($this->sitelanguages as $lang)
--- 93,115 ----
                                                $this->t->parse('langcatBlock', 
'langexistcat', true);
                                        }
! 
!                                       $link_data['menuaction'] = 
'sitemgr.Translations_UI.translateCategory';
!                                       $link_data['category_id'] = 
$cat_list[$i];
                                        $this->t->set_var('translatecat', 
!                                               '<form action="' . 
$GLOBALS['phpgw']->link('/index.php',$link_data) .
!                                               '" method="POST"><input 
type="submit" name="btnTranslateCategory" value="' . lang('Translate') 
.'"></form>');
  
                                        //setup page list
                                        $this->t->set_var('PBlock', '');
!                                       $page_list = 
$this->pagebo->getPageIDList($cat_list[$i]);
!                                       if($page_list && sizeof($page_list)>0)
                                        {
!                                               for($j = 0; $j < 
sizeof($page_list); $j++)
                                                {
!                                                       $page = 
$this->pagebo->getPage($page_list[$j],$this->sitelanguages[0]);
!                                                       $page_description = 
'<i>' . lang('Page') . ': </i>'.$page->name.'<br><i>' . lang('Title') . ': 
</i>'.$page->title;
                                                        
$this->t->set_var('page', $page_description);
  
!                                                       $availablelangsforpage 
= $this->pagebo->getlangarrayforpage($page_list[$j]);
                                                        
$this->t->set_var('langpageBlock','');
                                                        foreach 
($this->sitelanguages as $lang)
***************
*** 122,130 ****
                                                        }
  
                                                        
$this->t->set_var('translatepage', 
!                                                               '<form 
action="'.
!                                                               
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Translations_UI._translatePage').
!                                                               '" 
method="POST"><input type="submit" name="btnTranslatePage" value="' . 
lang('Translate') .'">'.
!                                                               '<input 
type="hidden" name="page_id" value="'.$this->page_id.'"></form>');
                                                        
$this->t->parse('PBlock', 'PageBlock', true);
                                                }
--- 119,127 ----
                                                        }
  
+                                                       $link_data['page_id'] = 
$page_list[$j];
+                                                       
$link_data['menuaction'] = 'sitemgr.Translations_UI.translatePage';
                                                        
$this->t->set_var('translatepage', 
!                                                               '<form 
action="' . $GLOBALS['phpgw']->link('/index.php',$link_data) .
!                                                               '" 
method="POST"><input type="submit" name="btnTranslatePage" value="' . 
lang('Translate') .'"></form>');
                                                        
$this->t->parse('PBlock', 'PageBlock', true);
                                                }
***************
*** 143,156 ****
                }
  
!               function _translateCategory()
                {
!                       
$GLOBALS['Common_BO']->globalize(array('category_id','changelanguage','showlanguage','savelanguage','btnSaveCategory','savecatname','savecatdesc','btnSaveBlock','element','blockid','blocktitle'));
!                       global $category_id, $changelanguage, $showlanguage, 
$savelanguage, $btnSaveCategory, $savecatname, $savecatdesc,$btnSaveBlock;
  
                        if ($btnSaveCategory)
                        {
                                $this->cat_bo->saveCategoryLang($category_id, 
$savecatname, $savecatdesc, $savelanguage);
-                               $this->_manageTranslations();
-                               return;
                        }
                        elseif ($btnSaveBlock)
--- 140,152 ----
                }
  
!               function translateCategory()
                {
!                       
$GLOBALS['Common_BO']->globalize(array('changelanguage','showlanguage','savelanguage','btnSaveCategory','savecatname','savecatdesc','btnSaveBlock','element','blockid','blocktitle'));
!                       global $changelanguage, $showlanguage, $savelanguage, 
$btnSaveCategory, $savecatname, $savecatdesc,$btnSaveBlock;
!                       $category_id = $_GET['category_id'];
  
                        if ($btnSaveCategory)
                        {
                                $this->cat_bo->saveCategoryLang($category_id, 
$savecatname, $savecatdesc, $savelanguage);
                        }
                        elseif ($btnSaveBlock)
***************
*** 161,176 ****
                        $this->common_ui->DisplayHeader();
                        $this->t->set_file('TranslateCategory', 
'translate_category.tpl');
!                       
$this->t->set_block('TranslateCategory','Blocktranslator','Tblock');
!                       
$this->t->set_block('Blocktranslator','EditorElement','Eblock');
                        
                        if($error)
                        {
                                $this->t->set_var('error_msg',lang('You failed 
to fill in one or more required fields.'));
!                               $this->cat->name = $savecatname;
!                               $this->cat->description = $savecatdesc;
                        }
                        else
                        {
!                               $this->cat = 
$this->cat_bo->getCategory($category_id);
                                $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
                                $showlangdata = 
$this->cat_bo->getCategory($category_id,$showlanguage);
--- 157,174 ----
                        $this->common_ui->DisplayHeader();
                        $this->t->set_file('TranslateCategory', 
'translate_category.tpl');
!                       $this->t->set_file('Blocks','translate_block.tpl');
!                       $this->t->set_block('Blocks','Blocktranslator');
!                       
$this->t->set_block('Blocktranslator','Version','Vblock');
!                       $this->t->set_block('Blocks','EditorElement','Eblock');
                        
                        if($error)
                        {
                                $this->t->set_var('error_msg',lang('You failed 
to fill in one or more required fields.'));
!                               $cat->name = $savecatname;
!                               $cat->description = $savecatdesc;
                        }
                        else
                        {
!                               $cat = $this->cat_bo->getCategory($category_id);
                                $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
                                $showlangdata = 
$this->cat_bo->getCategory($category_id,$showlanguage);
***************
*** 197,213 ****
                }
  
!               function _translatePage()
                {
!                       
$GLOBALS['Common_BO']->globalize(array('page_id','changelanguage','showlanguage','savelanguage','btnSavePage','savepagetitle','savepagesubtitle','btnSaveBlock','element','blockid','blocktitle'));
!                       global $page_id, $changelanguage, $showlanguage, 
$savelanguage, $btnSavePage, $savepagetitle, $savepagesubtitle,$btnSaveBlock;
                        
                        if ($btnSavePage)
                        {
!                               $this->page->id = $page_id;
!                               $this->page->title = $savepagetitle;
!                               $this->page->subtitle = $savepagesubtitle;
!                               $this->pagebo->savePageLang($this->page, 
$savelanguage);
!                               $this->_manageTranslations();
!                               return;
                        }
                        elseif ($btnSaveBlock)
--- 195,210 ----
                }
  
!               function translatePage()
                {
!                       
$GLOBALS['Common_BO']->globalize(array('changelanguage','showlanguage','savelanguage','btnSavePage','savepagetitle','savepagesubtitle','btnSaveBlock','element','blockid','blocktitle'));
!                       global $changelanguage, $showlanguage, $savelanguage, 
$btnSavePage, $savepagetitle, $savepagesubtitle,$btnSaveBlock;
!                       $page_id = $_GET['page_id'];
                        
                        if ($btnSavePage)
                        {
!                               $page->id = $page_id;
!                               $page->title = $savepagetitle;
!                               $page->subtitle = $savepagesubtitle;
!                               $this->pagebo->savePageLang($page, 
$savelanguage);
                        }
                        elseif ($btnSaveBlock)
***************
*** 218,223 ****
  
                        $this->t->set_file('TranslatePage', 
'translate_page.tpl');
!                       
$this->t->set_block('TranslatePage','Blocktranslator','Tblock');
!                       
$this->t->set_block('Blocktranslator','EditorElement','Eblock');
  
                        //TODO: error handling seems not correct
--- 215,222 ----
  
                        $this->t->set_file('TranslatePage', 
'translate_page.tpl');
!                       $this->t->set_file('Blocks','translate_block.tpl');
!                       $this->t->set_block('Blocks','Blocktranslator');
!                       
$this->t->set_block('Blocktranslator','Version','Vblock');
!                       $this->t->set_block('Blocks','EditorElement','Eblock');
  
                        //TODO: error handling seems not correct
***************
*** 225,234 ****
                        {
                                $this->t->set_var('error_msg',lang('You failed 
to fill in one or more required fields.'));
!                               $this->page->title = $savepagetitle;
!                               $this->page->subtitle = $savepagesubtitle;
                        }
                        else
                        {
!                               $this->page = $this->pagebo->getPage($page_id);
                                $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
                                $showlangdata = 
$this->pagebo->getPage($page_id,$showlanguage);
--- 224,233 ----
                        {
                                $this->t->set_var('error_msg',lang('You failed 
to fill in one or more required fields.'));
!                               $page->title = $savepagetitle;
!                               $page->subtitle = $savepagesubtitle;
                        }
                        else
                        {
!                               $page = $this->pagebo->getPage($page_id);
                                $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
                                $showlangdata = 
$this->pagebo->getPage($page_id,$showlanguage);
***************
*** 241,245 ****
                                        'pageid' => $page_id,
                                        'lang_pagename' => lang('Page Name'),
!                                       'pagename' => $this->page->name,
                                        'lang_pagetitle' => lang('Page Title'),
                                        'showpagetitle' => $showlangdata->title,
--- 240,244 ----
                                        'pageid' => $page_id,
                                        'lang_pagename' => lang('Page Name'),
!                                       'pagename' => $page->name,
                                        'lang_pagetitle' => lang('Page Title'),
                                        'showpagetitle' => $showlangdata->title,
***************
*** 251,255 ****
  
                                //Content blocks
!                               
$this->process_blocks($this->contentbo->getblocksforscope($this->page->cat_id,$page_id));
                                $this->t->pfp('out','TranslatePage');
                        }
--- 250,254 ----
  
                                //Content blocks
!                               
$this->process_blocks($this->contentbo->getblocksforscope($page->cat_id,$page_id));
                                $this->t->pfp('out','TranslatePage');
                        }
***************
*** 257,261 ****
                }
  
!               function _translateSitecontent()
                {
                        
$GLOBALS['Common_BO']->globalize(array('changelanguage','showlanguage','savelanguage','btnSaveBlock','element','blockid','blocktitle'));
--- 256,260 ----
                }
  
!               function translateSitecontent()
                {
                        
$GLOBALS['Common_BO']->globalize(array('changelanguage','showlanguage','savelanguage','btnSaveBlock','element','blockid','blocktitle'));
***************
*** 269,274 ****
                        $this->common_ui->DisplayHeader();
                        $this->t->set_file('TranslateSitecontent', 
'translate_sitecontent.tpl');
!                       
$this->t->set_block('TranslateSitecontent','Blocktranslator','Tblock');
!                       
$this->t->set_block('Blocktranslator','EditorElement','Eblock');
  
                        $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
--- 268,275 ----
                        $this->common_ui->DisplayHeader();
                        $this->t->set_file('TranslateSitecontent', 
'translate_sitecontent.tpl');
!                       $this->t->set_file('Blocks','translate_block.tpl');
!                       $this->t->set_block('Blocks','Blocktranslator');
!                       
$this->t->set_block('Blocktranslator','Version','Vblock');
!                       $this->t->set_block('Blocks','EditorElement','Eblock');
  
                        $showlanguage = $showlanguage ? $showlanguage : 
$this->sitelanguages[0];
***************
*** 277,281 ****
                        $this->templatehelper();
  
!                       
$this->process_blocks($this->contentbo->getblocksforscope(0,0));
                        $this->t->pfp('out','TranslateSitecontent');
                }
--- 278,282 ----
                        $this->templatehelper();
  
!                       
$this->process_blocks($this->contentbo->getblocksforscope(CURRENT_SITE_ID,0));
                        $this->t->pfp('out','TranslateSitecontent');
                }
***************
*** 290,312 ****
                                
$this->t->set_var('moduleinfo',($block->module_name));
  
!                               $savelangdata = 
$this->contentbo->getlangblockdata($id,$savelanguage);
!                               $showlangdata = 
$this->contentbo->getlangblockdata($id,$showlanguage);
                                $translatorstandardelements = array(
                                        array('label' => lang('Title'),
!                                                 'value' => 
($showlangdata->title ? $showlangdata->title : $moduleobject->title),
                                                  'form' => ('<input 
type="text" name="blocktitle" value="' . 
!                                                       ($savelangdata->title ? 
$savelangdata->title : $moduleobject->title) . '" />')
                                        )
                                );
-                               $block->arguments = $showlangdata->arguments;
                                $moduleobject->set_block($block);
                                $saveblock = $block;
!                               $saveblock->arguments = 
$savelangdata->arguments;
!                               $translatormoduleelements = 
$moduleobject->get_translation_interface($block,$saveblock);
  
!                               $interface = 
array_merge($translatorstandardelements,$translatormoduleelements);
  
!                               $this->t->set_var('Eblock','');
!                               while (list(,$element) = each($interface))
                                {
                                        $this->t->set_var(Array(
--- 291,313 ----
                                
$this->t->set_var('moduleinfo',($block->module_name));
  
!                               $savelangtitle = 
$this->contentbo->getlangblocktitle($id,$savelanguage);
!                               $showlangtitle = 
$this->contentbo->getlangblocktitle($id,$showlanguage);
!                               $savelangversions = 
$this->contentbo->getallversionsforblock($id,$savelanguage);
!                               $showlangversions = 
$this->contentbo->getallversionsforblock($id,$showlanguage);
                                $translatorstandardelements = array(
                                        array('label' => lang('Title'),
!                                                 'value' => ($showlangtitle ? 
$showlangtitle : $moduleobject->title),
                                                  'form' => ('<input 
type="text" name="blocktitle" value="' . 
!                                                       ($savelangtitle ? 
$savelangtitle : $moduleobject->title) . '" />')
                                        )
                                );
                                $moduleobject->set_block($block);
                                $saveblock = $block;
! //                            $translatormoduleelements = 
$moduleobject->get_translation_interface($block,$saveblock);
  
! //                            $interface = 
array_merge($translatorstandardelements,$translatormoduleelements);
  
!                               $this->t->set_var('standardelements','');
!                               while (list(,$element) = 
each($translatorstandardelements))
                                {
                                        $this->t->set_var(Array(
***************
*** 315,324 ****
                                                'form' => $element['form']
                                        ));
!                                       
$this->t->parse('Eblock','EditorElement', true);
                                }
                                $this->t->set_var(Array(
                                        'blockid' => $id,
                                ));
!                               $this->t->parse('Tblock','Blocktranslator', 
true);
                        }
                }
--- 316,349 ----
                                                'form' => $element['form']
                                        ));
!                                       
$this->t->parse('standardelements','EditorElement', true);
!                               }
!                               $this->t->set_var('Vblock','');
!                               while (list($version_id,$version) = 
each($showlangversions))
!                               {
!                                       //set the version of the block which is 
referenced by the moduleobject, 
!                                       //so that we retrieve a interface with 
the current version's arguments 
!                                       $block->set_version($version);
!                                       
$saveblock->set_version($savelangversions[$version_id]);
!                                       $translatormoduleelements = 
$moduleobject->get_translation_interface($block,$saveblock);
!                                               $this->t->set_var(array(
!                                               'version_id' => $version_id,
!                                               'version_state' => 
$GLOBALS['Common_BO']->state[$version['state']],
!                                               'versionelements' => ''
!                                       ));
!                                       while (list(,$element) = 
each($translatormoduleelements))
!                                       {
!                                               $this->t->set_var(Array(
!                                                       'label' => 
$element['label'],
!                                                       'value' => 
$element['value'],
!                                                       'form' => 
$element['form']
!                                               ));
!                                               
$this->t->parse('versionelements','EditorElement', true);
!                                       }
!                                       $this->t->parse('Vblock','Version', 
true);
                                }
                                $this->t->set_var(Array(
                                        'blockid' => $id,
                                ));
!                               $this->t->parse('blocks','Blocktranslator', 
true);
                        }
                }
***************
*** 328,346 ****
                        global $blockid, $element,$blocktitle,$savelanguage;
  
!                       $moduleobject = 
$this->contentbo->getblockmodule($blockid);
! 
!                       if ($moduleobject->validate($element))
!                       {
!                               $block = CreateObject('sitemgr.Block_SO',True);
!                               $block->id = $blockid;
!                               $block->title = $blocktitle;
!                               if 
(!$this->contentbo->saveblockdatalang($block,$element,$savelanguage))
!                               {
!                                       $this->t->set_var('validationerror', 
lang("You are not entitled to edit block %1",$blockid));;
!                               }
!                       }
!                       else
                        {
!                               $this->t->set_var('validationerror', 
$module->get_validationerror());
                        }
                }
--- 353,363 ----
                        global $blockid, $element,$blocktitle,$savelanguage;
  
!                       $block = CreateObject('sitemgr.Block_SO',True);
!                       $block->id = $blockid;
!                       $block->title = $blocktitle;
!                       $result = 
$this->contentbo->saveblockdatalang($block,$element,$savelanguage);
!                       if ($result !== True)
                        {
!                               $this->t->set_var('validationerror', $result);
                        }
                }

Index: class.module.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.module.inc.php,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -r1.8 -r1.8.2.1
*** class.module.inc.php        10 Mar 2003 07:02:06 -0000      1.8
--- class.module.inc.php        23 Jun 2003 20:31:21 -0000      1.8.2.1
***************
*** 19,22 ****
--- 19,23 ----
  class Module 
  {
+       var $i18n; //flag a module must use if it wants its content to be 
translatable
        var $validation_error;
        var $transformer_chain;
***************
*** 35,41 ****
        }
  
!       function add_transformer($transformer)
        {
!               $this->transformer_chain[] = $transformer;
        }
  
--- 36,42 ----
        }
  
!       function add_transformer(&$transformer)
        {
!               $this->transformer_chain[] =& $transformer;
        }
  
***************
*** 46,50 ****
        //that depends on the blocks arguments
        //the produce argument is set when content is generated, so we can do 
some stuff we do not need when editing the block
!       function set_block($block,$produce=False)
        {
                if ($produce)
--- 47,51 ----
        //that depends on the blocks arguments
        //the produce argument is set when content is generated, so we can do 
some stuff we do not need when editing the block
!       function set_block(&$block,$produce=False)
        {
                if ($produce)
***************
*** 52,56 ****
                        if ($this->session)
                        {
!                               $sessionarguments = 
$GLOBALS['phpgw']->session->appsession($block->module_name,'sitemgr-site');
                                while (list(,$argument) = @each($this->session))
                                {
--- 53,57 ----
                        if ($this->session)
                        {
!                               $sessionarguments = 
$GLOBALS['phpgw']->session->appsession('block[' . $block->id . ']', 
'sitemgr-site');
                                while (list(,$argument) = @each($this->session))
                                {
***************
*** 63,69 ****
                        while (list(,$argument) = @each($this->get))
                        {
!                               if 
(isset($_GET[$block->module_name][$argument]))
                                {
!                                       $block->arguments[$argument] = 
$_GET[$block->module_name][$argument];
                                }
                        }
--- 64,70 ----
                        while (list(,$argument) = @each($this->get))
                        {
!                               if 
(isset($_GET['block'][$block->id][$argument]))
                                {
!                                       $block->arguments[$argument] = 
$_GET['block'][$block->id][$argument];
                                }
                        }
***************
*** 72,89 ****
                        while (list($argument,) = @each($this->post))
                        {
!                               if 
(isset($_POST[$block->module_name][$argument]))
                                {
!                                       $block->arguments[$argument] = 
$_POST[$block->module_name][$argument];
                                }
                        }
                        while (list(,$argument) = @each($this->cookie))
                        {
!                               if 
(isset($_COOKIE[$block->module_name][$argument]))
                                {
!                                       $block->arguments[$argument] = 
$_COOKIE[$block->module_name][$argument];
                                }
                        }
                }
!               $this->block = $block;
        }
  
--- 73,90 ----
                        while (list($argument,) = @each($this->post))
                        {
!                               if 
(isset($_POST['block'][$block->id][$argument]))
                                {
!                                       $block->arguments[$argument] = 
$_POST['block'][$block->id][$argument];
                                }
                        }
                        while (list(,$argument) = @each($this->cookie))
                        {
!                               if 
(isset($_COOKIE['block'][$block->id][$argument]))
                                {
!                                       $block->arguments[$argument] = 
$_COOKIE['block'][$block->id][$argument];
                                }
                        }
                }
!               $this->block =& $block;
        }
  
***************
*** 92,96 ****
                while (list($key,$value) = @each($modulevars))
                {
!                       $extravars[$this->block->module_name.'['.$key.']'] = 
$value;
                }
                if ($GLOBALS['page']->name)
--- 93,98 ----
                while (list($key,$value) = @each($modulevars))
                {
!                       //%5B and %5D are urlencoded [ and ]
!                       $extravars['block' . '%5B'. $this->block->id  .'%5D%5B' 
. $key . '%5D'] = $value;
                }
                if ($GLOBALS['page']->name)
***************
*** 115,119 ****
        function find_template_dir()
        {
!               $templaterootformat = 
$GLOBALS['sitemgr_info']['sitemgr-site-dir']. SEP . 'templates' . SEP . '%s' . 
SEP . 'modules' . SEP . $this->block->module_name;
                $themetemplatedir = 
sprintf($templaterootformat,$GLOBALS['sitemgr_info']['themesel']);
                if (is_dir($themetemplatedir))
--- 117,121 ----
        function find_template_dir()
        {
!               $templaterootformat = $GLOBALS['sitemgr_info']['site_dir']. SEP 
. 'templates' . SEP . '%s' . SEP . 'modules' . SEP . $this->block->module_name;
                $themetemplatedir = 
sprintf($templaterootformat,$GLOBALS['sitemgr_info']['themesel']);
                if (is_dir($themetemplatedir))
***************
*** 129,148 ****
        function get_properties($cascading=True)
        {
!               if ($cascading)
                {
!                       return 
$GLOBALS['Common_BO']->modules->getcascadingmoduleproperties(
!                               $this->block->module_id,
!                               $this->block->area,
!                               $this->block->cat_id,
!                               $this->block->module_name
!                       );
                }
                else
                {
!                       return 
$GLOBALS['Common_BO']->modules->getmoduleproperties(
!                               $this->block->module_id,
!                               $this->block->area,
!                               $this->block->cat_id
!                       );
                }
        }
--- 131,157 ----
        function get_properties($cascading=True)
        {
!               if ($this->properties)
                {
!                       if ($cascading)
!                       {
!                               return 
$GLOBALS['Common_BO']->modules->getcascadingmoduleproperties(
!                                       $this->block->module_id,
!                                       $this->block->area,
!                                       $this->block->cat_id,
!                                       $this->block->module_name
!                               );
!                       }
!                       else
!                       {
!                               return 
$GLOBALS['Common_BO']->modules->getmoduleproperties(
!                                       $this->block->module_id,
!                                       $this->block->area,
!                                       $this->block->cat_id
!                               );
!                       }
                }
                else
                {
!                       return False;
                }
        }
***************
*** 156,160 ****
                while (list($key,$input) = @each($this->arguments))
                {
!                       $elementname = ($input['i18n'] ? ('element[i18n][' 
.$key . ']') : ('element[' .$key . ']'));
                        //arrays of input elements are only implemented for the 
user interface
                        if ($input['type'] == 'array')
--- 165,170 ----
                while (list($key,$input) = @each($this->arguments))
                {
!                       $elementname = 'element[' . $this->block->version . ']';
!                       $elementname .= ($input['i18n'] ? ('[i18n][' .$key . 
']') : ('[' .$key . ']'));
                        //arrays of input elements are only implemented for the 
user interface
                        if ($input['type'] == 'array')
***************
*** 190,194 ****
                        if ($input['i18n'])
                        {
!                               $elementname = 'element[i18n][' .$key . ']';
                                //arrays of input elements are only implemented 
for the user interface
                                if ($input['type'] == 'array')
--- 200,204 ----
                        if ($input['i18n'])
                        {
!                               $elementname = 'element[' . 
$this->block->version . '][i18n][' .$key . ']';
                                //arrays of input elements are only implemented 
for the user interface
                                if ($input['type'] == 'array')
***************
*** 220,227 ****
        {
                $properties = $this->get_properties(False);
-               $elementname = 'element[' .$key . ']';
                $interface = array();
                while (list($key,$input) = @each($this->properties))
                {
                        $element['label'] = $input['label'];
                        $element['form'] = 
$this->build_input_element($input,$properties[$key],$elementname);
--- 230,237 ----
        {
                $properties = $this->get_properties(False);
                $interface = array();
                while (list($key,$input) = @each($this->properties))
                {
+                       $elementname = 'element[' .$key . ']';
                        $element['label'] = $input['label'];
                        $element['form'] = 
$this->build_input_element($input,$properties[$key],$elementname);
***************
*** 236,240 ****
                        $this->post[$key],
                        ($default !== False) ? $default : 
$this->block->arguments[$key],
!                       ($this->block->module_name . '[' . $key . ']')
                );
        }
--- 246,250 ----
                        $this->post[$key],
                        ($default !== False) ? $default : 
$this->block->arguments[$key],
!                       ('block[' . $this->block->id  . '][' . $key . ']')
                );
        }
***************
*** 308,311 ****
--- 318,326 ----
        }
  
+       function validate_properties(&$data)
+       {
+               return true;
+       }
+ 
        //never call get_content directly, get_output takes care of passing it 
the right arguments
        function get_content(&$arguments,$properties)
***************
*** 327,336 ****
                else
                {
!                       if ($this->transformer_chain)
                        {
!                               foreach ($this->transformer_chain as 
$transformer)
!                               {
!                                       $content = 
$transformer->apply_transform($this->block->title,$content);
!                               }
                        }
                        //store session variables
--- 342,348 ----
                else
                {
!                       for ( $i = 0; $i < count( $this->transformer_chain ); 
++$i )
                        {
!                               $content = 
$this->transformer_chain[$i]->apply_transform($this->block->title,$content);
                        }
                        //store session variables
***************
*** 345,349 ****
                                        }
                                }
!                               
$GLOBALS['phpgw']->session->appsession($this->block->module_name,'sitemgr-site',$sessionarguments);
                        }
                        return $content;
--- 357,361 ----
                                        }
                                }
!                               $GLOBALS['phpgw']->session->appsession('block[' 
. $block->id . ']','sitemgr-site',$sessionarguments);
                        }
                        return $content;

Index: class.xslt_transform.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/class.xslt_transform.inc.php,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -r1.1 -r1.1.2.1
*** class.xslt_transform.inc.php        17 Jan 2003 03:37:52 -0000      1.1
--- class.xslt_transform.inc.php        23 Jun 2003 20:31:21 -0000      1.1.2.1
***************
*** 5,11 ****
        var $arguments;
  
!       function xslt_transform($xsltfile)
        {
                $this->xsltfile = $xsltfile;
        }
  
--- 5,12 ----
        var $arguments;
  
!       function xslt_transform($xsltfile,$xsltparameters=NULL)
        {
                $this->xsltfile = $xsltfile;
+               $this->xsltparameters = $xsltparameters;
        }
  
***************
*** 14,18 ****
                $xh = xslt_create();
                $xsltarguments = array('/_xml' => $content);
!               $result = xslt_process($xh, 'arg:/_xml', $this->xsltfile, NULL, 
$xsltarguments);
                xslt_free($xh);
                return $result;
--- 15,19 ----
                $xh = xslt_create();
                $xsltarguments = array('/_xml' => $content);
!               $result = xslt_process($xh, 'arg:/_xml', $this->xsltfile, NULL, 
$xsltarguments,$this->xsltparameters);
                xslt_free($xh);
                return $result;

Index: hook_admin.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/hook_admin.inc.php,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** hook_admin.inc.php  17 Jan 2003 03:37:52 -0000      1.2
--- hook_admin.inc.php  23 Jun 2003 20:31:21 -0000      1.2.2.1
***************
*** 12,28 ****
  
        {
! // Only Modify the $file and $title variables.....
  
-               $title = 'Web Content Manager';
                $file = Array
                (
!                       'Site Setup'     => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Common_UI.DisplayPrefs'),
!                       'Edit Categories and Permissions'    => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories'),
!                       'Edit Site Header and Footer' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.SiteContent_UI._editHeaderAndFooter'),
!                       'Edit Individual Pages' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage')
                );
  
  //Do not modify below this line
                display_section($appname,$title,$file);
        }
  ?>
--- 12,31 ----
  
        {
! // Only Modify the $file variable.....
  
                $file = Array
                (
!                       'Define Websites' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Sites_UI.list_sites'),
                );
  
  //Do not modify below this line
+               if 
((int)substr($GLOBALS['phpgw_info']['server']['versions']['phpgwapi'],4)>14)
+               {
+               $GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
+               }
+               else
+               {
                display_section($appname,$title,$file);
+               }
        }
  ?>

Index: hook_preferences.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/sitemgr/inc/hook_preferences.inc.php,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** hook_preferences.inc.php    17 Jan 2003 03:37:52 -0000      1.2
--- hook_preferences.inc.php    23 Jun 2003 20:31:21 -0000      1.2.2.1
***************
*** 17,22 ****
                $file = Array
                (
!                       'Manage Categories'    => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI._manageCategories'),
!                       'Manage Pages' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI._managePage')
                );
  
--- 17,22 ----
                $file = Array
                (
!                       'Manage Categories'    => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Categories_UI.manage'),
!                       'Manage Pages' => 
$GLOBALS['phpgw']->link('/index.php','menuaction=sitemgr.Pages_UI.manage')
                );
  

--- class.MainMenu_UI.inc.php DELETED ---

--- class.SiteContent_UI.inc.php DELETED ---

--- class.headerFooter_BO.inc.php DELETED ---

--- class.sitePreference_SO.inc.php DELETED ---





reply via email to

[Prev in Thread] Current Thread [Next in Thread]