[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: wcm/inc class.ACL_BO.inc.php,NONE,1.1 class.ACL_
From: |
Dan Kuykendall <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: wcm/inc class.ACL_BO.inc.php,NONE,1.1 class.ACL_SO.inc.php,NONE,1.1 class.Admin_ManageCategories_UI.inc.php,NONE,1.1 class.Categories_BO.inc.php,NONE,1.1 class.Categories_SO.inc.php,NONE,1.1 class.Category_SO.inc.php,NONE,1.1 class.Common_UI.inc.php,NONE,1.1 class.MainMenu_UI.inc.php,NONE,1.1 class.Page_SO.inc.php,NONE,1.1 class.Pages_BO.inc.php,NONE,1.1 class.Pages_SO.inc.php,NONE,1.1 class.Theme_BO.inc.php,NONE,1.1 class.admin_ManageSiteContent_UI.inc.php,NONE,1.1 class.contributor_ManagePage_UI.inc.php,NONE,1.1 class.headerFooter_BO.inc.php,NONE,1.1 class.sitePreference_SO.inc.php,NONE,1.1 hook_about.inc.php,NONE,1.1 hook_add_def_pref.inc.php,NONE,1.1 hook_admin.inc.php,NONE,1.1 hook_preferences.inc.php,NONE,1.1 |
Date: |
Tue, 27 Aug 2002 04:34:50 -0400 |
Update of /cvsroot/phpgroupware/wcm/inc
In directory subversions:/tmp/cvs-serv32185/inc
Added Files:
class.ACL_BO.inc.php class.ACL_SO.inc.php
class.Admin_ManageCategories_UI.inc.php
class.Categories_BO.inc.php class.Categories_SO.inc.php
class.Category_SO.inc.php class.Common_UI.inc.php
class.MainMenu_UI.inc.php class.Page_SO.inc.php
class.Pages_BO.inc.php class.Pages_SO.inc.php
class.Theme_BO.inc.php
class.admin_ManageSiteContent_UI.inc.php
class.contributor_ManagePage_UI.inc.php
class.headerFooter_BO.inc.php class.sitePreference_SO.inc.php
hook_about.inc.php hook_add_def_pref.inc.php
hook_admin.inc.php hook_preferences.inc.php
Log Message:
added new coded from patricks team
--- NEW FILE ---
<?php
/***************************************************************************\
* phpGroupWare - Web Content Manager
*
* http://www.phpgroupware.org
*
* -------------------------------------------------
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\***************************************************************************/
class ACL_BO
{
var $acct;
var $acl;
var $acl_so;
var $pages_so;
var $logged_in_user;
function ACL_BO()
{
$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('wcm.Pages_SO');
$this->acl_so = CreateObject('wcm.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,'wcm') & 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;
}
}
function remove_location($category_id)
{
// Used when a category_id is deleted
$this->acl_so->remove_location('L'.$category_id);
}
function grant_permissions($user, $category_id, $can_read,
$can_write)
{
$rights = 0;
if($can_read)
{
$rights = PHPGW_ACL_READ;
}
if($can_write)
{
$rights = ($rights | PHPGW_ACL_ADD);
}
$this->acl = CreateObject('phpgwapi.acl',$user);
if ($rights == 0)
{
return
$this->acl->delete_repository('wcm','L'.$category_id,$user);
}
else
{
return
$this->acl->add_repository('wcm','L'.$category_id,$user,$rights);
}
}
function get_user_permission_list($category_id)
{
return $this->get_permission_list($category_id,
'accounts');
}
function get_group_permission_list($category_id)
{
return $this->get_permission_list($category_id,
'groups');
}
function get_permission_list($category_id, $acct_type='')
{
/*
Though this is not the place for making database
lookups, particularly
ones that look for things in the phpgwapi tables,
the stupid get_rights
and get_specific_rights and other lookup functions
DON'T WORK.
*/
$users = $this->acct->get_list($acct_type);
$permissions = Array();
reset($users);
while(list($k,$v) = each($users))
{
$account_id = $v['account_id'];
//unset($this->acl);
//$this->acl =
CreateObject('phpgwapi.acl',$account_id);
//$rights =
$this->acl->get_specific_rights('L'.$category_id,'wcm');
$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;
}
else
{
//$this->acl =
CreateObject('phpgwapi.acl',$this->logged_in_user);
//return
($this->acl->get_rights('L'.$category_id,'wcm') & PHPGW_ACL_READ);
return
($this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_READ);
}
}
function can_write_category($category_id)
{
if ($this->is_admin())
{
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);
return
($this->acl_so->get_permission('L'.$category_id) & PHPGW_ACL_ADD);
}
}
function get_group_list()
{
return $this->acct->get_list('groups');
}
function get_simple_group_list()
{
return $this->get_simple_list('groups');
}
function get_simple_list($acct_type='')
{
$full_details = $this->acct->get_list($acct_type);
reset($full_details);
$group=array();
while(list($k,$v) = each($full_details))
{
$group['i'.$v['account_id']] = array();
}
return $group;
}
function get_simple_user_list()
{
return $this->get_simple_list('accounts');
}
function get_user_list()
{
return $this->acct->get_list('accounts');
}
}
?>
--- NEW FILE ---
<?php
class ACL_SO
{
var $db;
var $acl;
var $acct;
function ACL_SO()
{
$this->db = $GLOBALS['phpgw']->db;
$this->acl = CreateObject('phpgwapi.acl');
$this->acct = CreateObject('phpgwapi.accounts');
}
function get_permission($location)
{
$memberships =
$this->acct->membership($this->acl->logged_in_user);
$sql = 'SELECT acl_rights FROM phpgw_acl WHERE
acl_location="'.$location.
'" and acl_account in
('.$GLOBALS['phpgw_info']['user']['account_id'];
if (is_array($memberships))
{
foreach($memberships as $group)
{
$sql .= ','.$group['account_id'];
}
}
$sql .= ')';
$this->db->query($sql,__LINE__,__FILE__);
$permission = 0;
while ($this->db->next_record())
{
$permission = $permission | $this->db->f('acl_rights');
}
return $permission;
}
function get_rights($account_id, $location)
{
$sql = 'select acl_rights from phpgw_acl where
acl_appname="wcm" and acl_location="'.$location.'" and
acl_account="'.$account_id.'"';
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
return $this->db->f('acl_rights');
}
else
{
return 0;
}
}
function remove_location($location)
{
$sql = 'delete from phpgw_acl where acl_appname="wcm" and
acl_location="'.
$location.'"';
$this->db->query($sql,__LINE__,__FILE__);
}
}
?>
--- NEW FILE ---
<?php
/***************************************************************************\
* phpGroupWare - Web Content Manager
*
* http://www.phpgroupware.org
*
* -------------------------------------------------
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\***************************************************************************/
class Admin_ManageCategories_UI
{
var $cat;
var $cat_id;
var $cat_list;
var $cat_bo;
var $acl;
var $t;
var $public_functions = array
(
'_manageCategories' => True
);
function Admin_ManageCategories_UI()
{
$this->t = $GLOBALS['phpgw']->template;
$this->cat_bo = CreateObject('wcm.Categories_BO', True);
$this->acl = CreateObject('wcm.ACL_BO', True);
}
function _manageCategories()
{
global
$btnSaveCategory,$btnAddCategory,$btnEditCategory,$btnDelete,$btnPermission;
global $category_id,$catname,$catdesc,$catid;
global $groupaccessread, $groupaccesswrite,
$individualaccessread, $individualaccesswrite;
$common_ui = CreateObject('wcm.Common_UI',True);
$common_ui->DisplayHeader();
if (!$this->acl->is_admin())
{
echo "You must be an admin to edit categories.";
$common_ui->DisplayFooter();
}
else
{
if($btnAddCategory)
{
$this->_addCategory();
}
else if($btnEditCategory)
{
$this->_editCategory($category_id);
}
else if($btnSaveCategory && ($catname == '' ||
$catdesc == ''))
{
$this->_editCategory($catid,True,$catname,$catdesc);
}
else
{
if($btnDelete)
{
$this->_deleteCategory($category_id);
}
else if($btnSaveCategory)
{
if(!$catid)
{
$catid=$this->cat_bo->addCategory('','');
}
$groupaccess =
array_merge_recursive($groupaccessread, $groupaccesswrite);
$individualaccess =
array_merge_recursive($individualaccessread, $individualaccesswrite);
$this->cat_bo->saveCategoryInfo($catid, $catname, $catdesc);
$this->cat_bo->saveCategoryPerms($catid, $groupaccess, $individualaccess);
}
$this->t->set_var('category_manager','Category Manager');
$this->t->set_file('ManageCategories',
'manage_categories.tpl');
$this->t->set_block('ManageCategories',
'CategoryBlock', 'CBlock');
$this->cat_list =
$this->cat_bo->getPermittedCategoryIDReadList();
if($this->cat_list)
{
for($i = 0; $i <
sizeof($this->cat_list); $i++)
{
$this->cat =
$this->cat_bo->getCategory($this->cat_list[$i]);
$this->t->set_var('category', $this->cat->name);
$category_id =
$this->cat_list[$i];
$this->t->set_var('edit',
'<form
action="'.
$GLOBALS['phpgw']->link('/index.php',
'menuaction=wcm.Admin_ManageCategories_UI._manageCategories').
'"
method="POST">
<input
type="submit" name="btnEditCategory" value="Edit">
<input
type="hidden" name="category_id" value="'.$category_id.'">
</form>');
$this->t->set_var('remove',
'<form
action="'.
$GLOBALS['phpgw']->link('/index.php',
'menuaction=wcm.Admin_ManageCategories_UI._manageCategories').
'"
method="POST">
<input
type=submit name=btnDelete value = "Delete">
<input type=
hidden name = "category_id" value="'. $category_id .'">
</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=wcm.Admin_ManageCategories_UI._manageCategories').
'" method="POST">
<input type=submit
name=btnAddCategory value = "Add a category">
</form>');
$this->t->pfp('out',
'ManageCategories');
}
$common_ui->DisplayFooter();
}
}
function _addCategory()
{
$this->_editCategory(0);
}
function
_editCategory($cat_id,$error=False,$catname='',$catdesc='')
{
$this->t->set_file('EditCategory', 'edit_category.tpl');
$grouplist = $this->acl->get_group_list();
if($error)
{
$this->t->set_var('error_msg','You failed to
fill in one or more required fields');
$this->cat->name = $catname;
$this->cat->description = $catdesc;
}
else
{
if ($cat_id)
{
$this->cat =
$this->cat_bo->getCategory($cat_id);
$permissionlist =
$this->acl->get_group_permission_list($cat_id);
//print_r($permissionlist);
$this->t->set_var('add_edit','Edit
Category');
}
else
{
$this->cat->name = '';
$this->cat->description = '';
$this->t->set_var('add_edit','Add
Category');
$permissionlist = array();
}
}
$this->t->set_var(array(
'catid' => $cat_id,
'catname' => $this->cat->name,
'catdesc' => $this->cat->description,
'actionurl' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=wcm.Admin_ManageCategories_UI._manageCategories')
));
$this->t->set_file('EditCategory', 'edit_category.tpl');
$this->t->set_block('EditCategory','GroupBlock',
'GBlock');
$acct = CreateObject('phpgwapi.accounts');
if($grouplist)
{
for($i = 0; $i < count($grouplist); $i++ )
{
//$account_name =
$acct->id2name($permissionlist[$i]['account_id']);
//$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
{
$permission_id = 0;
}
$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)
{
$this->t->set_var('checkedgroupread','CHECKED');
}
else
{
$this->t->set_var('checkedgroupread','');
}
if ($permission_id & PHPGW_ACL_ADD)
{
$this->t->set_var('checkedgroupwrite','CHECKED');
}
else
{
$this->t->set_var('checkedgroupwrite','');
}
$this->t->parse('GBlock', 'GroupBlock',
True);
}
}
else
{
$this->t->set_var('groupname',"No groups
defined");
}
$this->t->set_block('EditCategory','UserBlock',
'UBlock');
$userlist = $this->acl->get_user_list();
$userpermissionlist =
$this->acl->get_user_permission_list($cat_id);
if($userlist)
{
for($i = 0; $i < count($userlist); $i++ )
{
$user_name =
$userlist[$i]['account_lid'];
if ($cat_id)
{
$user_permission_id =
$userpermissionlist[$i]['rights'];
}
else
{
$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 )
{
$this->t->set_var('checkeduserread','CHECKED');
}
else
{
$this->t->set_var('checkeduserread','');
}
if ($user_permission_id & PHPGW_ACL_ADD
)
{
$this->t->set_var('checkeduserwrite','CHECKED');
}
else
{
$this->t->set_var('checkeduserwrite','');
}
$this->t->parse('UBlock', 'UserBlock',
True);
}
}
else
{
$this->t->set_var('username',"No users
defined.");
}
$this->t->pfp('out','EditCategory');
}
function _deleteCategory($cat_id)
{
global $deleteconfirmed;
if ($deleteconfirmed==$cat_id)
{
$this->cat_bo->removeCategory($cat_id);
}
else
{
$cat = $this->cat_bo->getCategory($cat_id);
$this->t->set_file('ConfirmDelete','confirmdelete.tpl');
$this->t->set_var('category',$cat->name);
$this->t->set_var('category_id',$cat_id);
$this->t->set_var('actionurl',
$GLOBALS['phpgw']->link('/index.php',
'menuaction=wcm.Admin_ManageCategories_UI._manageCategories')
);
$this->t->pfp('out','ConfirmDelete');
}
}
}
?>
--- NEW FILE ---
<?php
class Categories_BO
{
var $so;
var $acl;
function Categories_BO()
{
$this->so = CreateObject('wcm.Categories_SO', True);
$this->acl = CreateObject('wcm.ACL_BO');
}
function getPermittedCategoryIDWriteList()
{
$full_list = $this->so->getFullcategoryIDList();
$permitted_list=array();
if (is_array($full_list))
{
reset($full_list);
foreach($full_list as $item)
{
if
($this->acl->can_write_category($item))
{
$permitted_list[]=$item;
}
}
}
return $permitted_list;
}
function getPermittedCategoryIDReadList()
{
$full_list = $this->so->getFullcategoryIDList();
$permitted_list=array();
if (is_array($full_list))
{
reset($full_list);
foreach($full_list as $item)
{
if
($this->acl->can_read_category($item))
{
$permitted_list[]=$item;
}
}
}
return $permitted_list;
}
function addCategory($name, $description)
{
if ($this->acl->is_admin())
{
return $this->so->addCategory($name,
$description);
}
else
{
return false;
}
}
function removeCategory($cat_id)
{
if ($this->acl->is_admin())
{
/********************************************\
* We have to remove the category, all the *
* associated pages, and all the associated *
* acl stuff too. *
\********************************************/
$this->so->removeCategory($cat_id);
$this->acl->remove_location($cat_id);
$pages_so = CreateObject('wcm.Pages_SO');
$pages_so->removePagesInCat($cat_id);
return True;
}
}
function saveCategoryInfo($cat_id, $cat_name, $cat_description)
{
$cat_info = CreateObject('wcm.Category_SO', True);
$cat_info->id = $cat_id;
$cat_info->name = $cat_name;
$cat_info->description = $cat_description;
if ($this->acl->can_read_category($cat_id))
{
if($this->so->saveCategory($cat_info))
{
return True;
}
return False;
}
else
{
return false;
}
}
function getCategory($cat_id)
{
if ($this->acl->can_read_category($cat_id))
{
return $this->so->getCategory($cat_id);
}
else
{
return false;
}
}
function saveCategoryPerms($cat_id, $group_access, $user_access)
{
if ($this->acl->is_admin())
{
$group_access=array_merge_recursive($this->acl->get_simple_group_list(),$group_access);
$user_access=array_merge_recursive($this->acl->get_simple_user_list(),$user_access);
$this->saveCatPermsGeneric($cat_id,
$group_access);
$this->saveCatPermsGeneric($cat_id,
$user_access);
return true;
}
else
{
return false;
}
}
function saveCatPermsGeneric($cat_id, $user_access)
{
if (is_array($user_access))
{
reset($user_access);
while (list($acctid, $perm_array) =
each($user_access))
{
if (substr($acctid,0,1))
{
$acctid = (int)
substr($acctid,1);
}
if (is_array($perm_array))
{
reset($perm_array);
$can_read = 0;
$can_write = 0;
while(list($permtype,
$permvalue) = each($perm_array))
{
switch($permtype)
{
case 'read':
$can_read = true;
break;
case 'write':
$can_write = true;
break;
default:
echo
'hmmmmmm: ' . $permtype . '<br>';
}
}
}
$this->acl->grant_permissions($acctid,
$cat_id, $can_read, $can_write);
}
}
else
{
echo 'wth!';
}
}
}
?>
--- NEW FILE ---
<?php
class Categories_SO
{
var $db;
function Categories_SO()
{
$this->db = $GLOBALS['phpgw']->db;
}
function getFullCategoryIDList()
{
$sql = 'SELECT cat_id FROM phpgw_wcm_categories ORDER
BY name';
$this->db->query($sql, __LINE__, __FILE__);
while ($this->db->next_record())
{
$cat_id_list[] = $this->db->f('cat_id');
}
return $cat_id_list;
}
function addCategory($name, $description)
{
//Create a section for categoriy and return the newly
added category id.
$sql = 'INSERT INTO phpgw_wcm_categories (name,
description) VALUES ("'
. $name . '","' . $description . '")';
$this->db->query($sql, __LINE__, __FILE__);
return
$this->db->get_last_insert_id('phpgw_wcm_categories','cat_id');
}
function removeCategory($cat_id)
{
$sql = 'DELETE FROM phpgw_wcm_categories WHERE
cat_id="' . $cat_id . '"';
$this->db->query($sql, __LINE__, __FILE__);
return true;
}
function saveCategory($cat_info)
{
$sql = 'UPDATE phpgw_wcm_categories SET name="' .
$cat_info->name . '", description="' .
$cat_info->description .
'" WHERE cat_id="' . $cat_info->id . '"';
$this->db->query($sql, __LINE__, __FILE__);
}
function getCategory($cat_id)
{
$sql = 'SELECT * FROM phpgw_wcm_categories WHERE
cat_id="' . $cat_id . '"';
$this->db->query($sql, __LINE__, __FILE__);
if ($this->db->next_record())
{
$cat_info = CreateObject('wcm.Category_SO',
True);
$cat_info->id = $cat_id;
$cat_info->name = $this->db->f('name');
$cat_info->description =
$this->db->f('description');
return $cat_info;
}
else
{
return false;
}
}
}
?>
--- NEW FILE ---
<?php
class Category_SO
{
var $id;
var $name;
var $description;
function Category_SO()
{
}
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'class.Common_UI.inc.php'
***** Error reading new file: [Errno 2] No such file or directory:
'class.MainMenu_UI.inc.php'
--- NEW FILE ---
<?php
class Page_SO
{
var $id;
var $cat_id;
var $name;
var $title;
var $subtitle;
var $content;
function Page_SO()
{
}
}
?>
--- NEW FILE ---
<?php
class Pages_BO
{
var $pageso;
var $acl;
function Pages_BO()
{
$this->pageso = CreateObject('wcm.Pages_SO',True);
$this->acl = CreateObject('wcm.ACL_BO');
}
function getPageIDList($cat_id)
{
if ($this->acl->can_read_category($cat_id))
{
return $this->pageso->getPageIDList($cat_id);
}
else
{
return false;
}
}
function addPage($cat_id)
{
if ($this->acl->can_write_category($cat_id))
{
return $this->pageso->addPage($cat_id);
}
else
{
return false;
}
}
function removePage($cat_id, $page_id)
{
if ($this->acl->can_write_category($cat_id))
{
return $this->pageso->removePage($page_id);
}
else
{
return false;
}
}
function getPage($page_id)
{
if ($this->acl->can_read_page($page_id))
{
return $this->pageso->getPage($page_id);
}
else
{
$page = CreateObject('wcm.Page_SO');
$page->name = 'Error';
$page->title = 'Error accessing page';
$page->subtitle = '';
$page->content = 'There was an error accessing
the requested page.
Either you do not have permission to
view this page, or the page does not exist.';
return $page;
}
}
function savePageInfo($cat_id, $page_Info)
{
$fixed_name = strtr($page_Info->name,
'address@hidden&*()-_=+ /?><,.\\\'":;|`~{}[]','
');
$fixed_name = str_replace(' ', '', $fixed_name);
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);
return 'The Name field cannot contain
punctuation or spaces (field modified).';
}
if ($this->pageso->savePageInfo($page_Info))
{
return 'The page was successfully
saved.';
}
else
{
return 'There was an error writing to
the database.';
}
$page_Info->name = $fixed_name;
$this->pageso->savePageInfo($page_Info);
return '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);
return 'The page name must be unique.';
}
if ($this->pageso->savePageInfo($page_Info))
{
return True;
}
else
{
return 'There was an error writing to the
database.';
}
}
}
?>
--- NEW FILE ---
<?php
class Pages_SO
{
var $db;
function Pages_SO()
{
$this->db = $GLOBALS['phpgw']->db;
}
function getPageIDList($cat_id)
{
$sql = 'SELECT page_id FROM phpgw_wcm_pages WHERE
cat_id="' . $cat_id . '" ORDER BY page_id DESC';
$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;
}
function addPage($cat_id)
{
$sql = 'INSERT INTO phpgw_wcm_pages (cat_id) VALUES ("'
. $cat_id . '")';
$this->db->query($sql, __LINE__,__FILE__);
return
$this->db->get_last_insert_id('phpgw_wcm_pages','page_id');
}
function removePagesInCat($cat_id)
{
$sql = 'DELETE FROM phpgw_wcm_pages WHERE
cat_id="'.$cat_id.'"';
$this->db->query($sql,__LINE__,__FILE__);
}
function removePage($page_id)
{
$sql = 'DELETE FROM phpgw_wcm_pages WHERE page_id="' .
$page_id . '"';
$this->db->query($sql, __LINE__,__FILE__);
}
function pageExists($page_name,$exclude_page_id)
{
$sql = 'SELECT page_id FROM phpgw_wcm_pages WHERE
name="' . $page_name . '"';
if ($exclude_page_id)
{
$sql .= ' and page_id!="'. $exclude_page_id .
'"';
}
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
return $this->db->f('page_id');
}
else
{
return false;
}
}
function getPageByName($page_name)
{
$sql = 'SELECT * FROM phpgw_wcm_pages WHERE name="' .
$page_name . '"';
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$page = CreateObject('wcm.Page_SO', True);
$page->id = $this->db->f('page_id');
$page->cat_id = $this->db->f('cat_id');
$page->name = $this->db->f('name');
$page->title= $this->db->f('title');
$page->subtitle = $this->db->f('subtitle');
$page->content = $this->db->f('content');
return $page;
}
else
{
return false;
}
}
function getPage($page_id)
{
$sql = 'SELECT * FROM phpgw_wcm_pages WHERE page_id="'
. $page_id . '"';
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$page = CreateObject('wcm.Page_SO', True);
$page->id = $page_id;
$page->cat_id = $this->db->f('cat_id');
$page->name = $this->db->f('name');
$page->title= $this->db->f('title');
$page->subtitle = $this->db->f('subtitle');
$page->content = $this->db->f('content');
return $page;
}
else
{
return false;
}
}
function savePageInfo($pageInfo)
{
$sql = 'UPDATE phpgw_wcm_pages SET ' .
'cat_id="' . $pageInfo->cat_id . '",' .
'name="' . $pageInfo->name . '",' .
'title="' . $pageInfo->title . '",' .
'subtitle="' . $pageInfo->subtitle . '",' .
'content="' . $pageInfo->content . '" ' .
'WHERE page_id="' . $pageInfo->id . '"';
$this->db->query($sql, __LINE__,__FILE__);
return true;
}
}
?>
--- NEW FILE ---
<?php
class Theme_BO
{
var $acl;
var $preferenceso;
var $theme;
function Theme_BO()
{
$this->acl = CreateObject('ACL', True);
$this->preferenceso =
CreateObject('wcm.sitePreferences_SO', True);
}
function setTheme($theme)
{
if ($this->preferenceso->setPreference($theme))
echo "theme set.";
else
echo "Error, theme not set.";
}
function getTheme($theme)
{
return $this->preferenceso->getPreference($theme);
}
function getAvailableTheme()
{
// TBD
}
}
?>
--- NEW FILE ---
<?php
class Admin_ManageSiteContent_UI
{
var $t;
var $headerfooterbo;
var $acl;
var $public_functions = array
(
'_editHeaderAndFooter' => True
);
function admin_ManageSiteContent_UI()
{
global $btnSave;
global $btnReset;
global $btnHome;
global $header;
global $footer;
$this->t = $GLOBALS["phpgw"]->template;
$this->headerfooterbo =
CreateObject('wcm.headerFooter_BO', True);
$this->acl = CreateObject('wcm.ACL_BO');
}
function _editHeaderAndFooter()
{
global $btnSave;
global $header;
global $footer;
$common_ui = CreateObject('wcm.Common_UI',True);
$common_ui->DisplayHeader();
if ($this->acl->is_admin())
{
$this->t->set_file('EditHeaderAndFooter',
'site_format_manager.tpl');
if ($btnSave)
{
$this->headerfooterbo->SetSiteHeader($header);
$this->headerfooterbo->SetSiteFooter($footer);
$this->t->set_var('message','<b>Saved.</b> <a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=wcm.MainMenu_UI.DisplayMenu').'">Return
to main menu.</a><br>');
//$this->headerfooterbo->SetTheme($this->theme);
}
$this->header =
$this->headerfooterbo->getSiteHeader();
$this->footer =
$this->headerfooterbo->getSiteFooter();
$this->t->set_var(array
(
'header' => $this->header,
'footer' => $this->footer
));
if ($btnReset)
{
$btnReset = false;
}
$this->t->set_var('actionurl',
$GLOBALS['phpgw']->link('/index.php',
'menuaction=wcm.admin_ManageSiteContent_UI._editHeaderAndFooter'));
$this->t->pfp('out', 'EditHeaderAndFooter');
}
else
{
echo "You must be an admin to edit the site
header and footer.<br><br>";
}
$common_ui->DisplayFooter();
}
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'class.contributor_ManagePage_UI.inc.php'
--- NEW FILE ---
<?php
class headerFooter_BO
{
var $acl;
var $preferenceso;
var $header;
var $footer;
function headerFooter_BO()
{
$this->preferenceso =
CreateObject('wcm.sitePreference_SO', true);
$this->acl = CreateObject('wcm.ACL_BO', True);
}
function getSiteHeader()
{
return $this->preferenceso->getPreference('siteheader');
}
function getSiteFooter()
{
return
$this->preferenceso->getPreference('sitefooter');
}
function setSiteHeader($header)
{
if ($this->acl->is_admin())
{
if($this->preferenceso->setPreference('siteheader',$header))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
function setSiteFooter($footer)
{
if ($this->acl->is_admin())
{
if($this->preferenceso->setPreference('sitefooter',$footer))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
}
?>
--- NEW FILE ---
<?php
class sitePreference_SO
{
var $db;
function sitePreference_SO()
{
$this->db = $GLOBALS['phpgw']->db;
}
function setPreference($name, $value)
{
$sql = 'SELECT pref_id FROM phpgw_wcm_preferences WHERE
name="' . $name . '"';
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$sql = 'UPDATE phpgw_wcm_preferences SET
value="' . $value .
'" WHERE pref_id="' .
$this->db->f('pref_id') . '"';
$this->db->query($sql,__LINE__,__FILE__);
return true;
}
else
{
$sql = 'INSERT INTO phpgw_wcm_preferences
(name, value) VALUES ' .
'("' . $name . '","' . $value . '")';
$this->db->query($sql,__LINE__,__FILE__);
}
}
function getPreference($name)
{
$sql = 'SELECT value FROM phpgw_wcm_preferences WHERE
name="' . $name . '"';
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
return $this->db->f('value');
}
else
{
return '';
}
}
}
?>
***** Error reading new file: [Errno 2] No such file or directory:
'hook_about.inc.php'
***** Error reading new file: [Errno 2] No such file or directory:
'hook_add_def_pref.inc.php'
***** Error reading new file: [Errno 2] No such file or directory:
'hook_admin.inc.php'
***** Error reading new file: [Errno 2] No such file or directory:
'hook_preferences.inc.php'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: wcm/inc class.ACL_BO.inc.php,NONE,1.1 class.ACL_SO.inc.php,NONE,1.1 class.Admin_ManageCategories_UI.inc.php,NONE,1.1 class.Categories_BO.inc.php,NONE,1.1 class.Categories_SO.inc.php,NONE,1.1 class.Category_SO.inc.php,NONE,1.1 class.Common_UI.inc.php,NONE,1.1 class.MainMenu_UI.inc.php,NONE,1.1 class.Page_SO.inc.php,NONE,1.1 class.Pages_BO.inc.php,NONE,1.1 class.Pages_SO.inc.php,NONE,1.1 class.Theme_BO.inc.php,NONE,1.1 class.admin_ManageSiteContent_UI.inc.php,NONE,1.1 class.contributor_ManagePage_UI.inc.php,NONE,1.1 class.headerFooter_BO.inc.php,NONE,1.1 class.sitePreference_SO.inc.php,NONE,1.1 hook_about.inc.php,NONE,1.1 hook_add_def_pref.inc.php,NONE,1.1 hook_admin.inc.php,NONE,1.1 hook_preferences.inc.php,NONE,1.1,
Dan Kuykendall <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: wcm/wcm-site/themes/NukeNews blocks.html,NONE,1.1 center_right.html,NONE,1.1 footer.html,NONE,1.1 header.html,NONE,1.1 left_center.html,NONE,1.1 story_home.html,NONE,1.1 story_page.html,NONE,1.1 tables.php,NONE,1.1 theme.php,NONE,1.1
- Next by Date:
[Phpgroupware-cvs] CVS: property - Imported sources
- Previous by thread:
[Phpgroupware-cvs] CVS: wcm/wcm-site/themes/NukeNews blocks.html,NONE,1.1 center_right.html,NONE,1.1 footer.html,NONE,1.1 header.html,NONE,1.1 left_center.html,NONE,1.1 story_home.html,NONE,1.1 story_page.html,NONE,1.1 tables.php,NONE,1.1 theme.php,NONE,1.1
- Next by thread:
[Phpgroupware-cvs] CVS: property - Imported sources
- Index(es):