[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/phpgacl/ -> gacl_api.php (summary)

phpGACL - Generic Access Control List Copyright (C) 2002,2003 Mike Benoit This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

File Size: 3949 lines (123 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

gacl_api:: (45 methods):
  showarray()
  count_all()
  get_version()
  get_schema_version()
  consolidated_edit_acl()
  search_acl()
  append_acl()
  shift_acl()
  get_acl()
  is_conflicting_acl()
  add_acl()
  edit_acl()
  del_acl()
  sort_groups()
  format_groups()
  get_group_id()
  get_group_children()
  get_group_data()
  get_group_parent_id()
  get_root_group_id()
  add_group()
  get_group_objects()
  add_group_object()
  del_group_object()
  edit_group()
  rebuild_tree()
  _rebuild_tree()
  del_group()
  get_object()
  get_ungrouped_objects()
  get_objects()
  get_object_data()
  get_object_id()
  get_object_section_value()
  get_object_groups()
  add_object()
  edit_object()
  del_object()
  get_object_section_section_id()
  add_object_section()
  edit_object_section()
  del_object_section()
  get_section_data()
  clear_database()
  _defaultGenID()


Class: gacl_api  - X-Ref

gacl_api Extended API Class

Class gacl_api should be used for applications that must interface directly with
phpGACL's data structures, objects, and rules.

showarray($array)   X-Ref
showarray()

Dump all contents of an array in HTML (kinda)

param: array

count_all($arg = NULL)   X-Ref
count_all()

Recursively counts elements in an array and sub-arrays.

This is different from count($arg, COUNT_RECURSIVE)
in PHP >= 4.2.0, which includes sub-arrays in the count.

param: array Array to count
return: int The returned count is a count of all scalar elements found.

get_version()   X-Ref
get_version()

Grabs phpGACL version from the database.

return: string Version of phpGACL

get_schema_version()   X-Ref
get_schema_version()

Grabs phpGACL schema version from the database.

return: string Schema Version

consolidated_edit_acl($aco_section_value, $aco_value, $aro_section_value, $aro_value, $return_value)   X-Ref
consolidated_edit_acl()

Add's an ACL but checks to see if it can consolidate it with another one first.

This ONLY works with ACO's and ARO's. Groups, and AXO are excluded.
As well this function is designed for handling ACLs with return values,
and consolidating on the return_value, in hopes of keeping the ACL count to a minimum.

A return value of false must _always_ be handled outside this function.
As this function will remove AROs from ACLs and return false, in most cases
you will need to a create a completely new ACL on a false return.

param: string ACO Section Value
param: string ACO Value
param: string ARO Section Value
param: string ARO Value
param: string Return Value of ACL
return: bool Special boolean return value. See note.

search_acl($aco_section_value=NULL, $aco_value=NULL, $aro_section_value=NULL, $aro_value=NULL, $aro_group_name=NULL, $axo_section_value=NULL, $axo_value=NULL, $axo_group_name=NULL, $return_value=NULL)   X-Ref
search_acl()

Searches for ACL's with specified objects mapped to them.

NULL values are included in the search, if you want to ignore
for instance aro_groups use FALSE instead of NULL.

param: string ACO Section Value
param: string ACO Value
param: string ARO Section Value
param: string ARO Value
param: string ARO Group Name
param: string AXO Section Value
param: string AXO Value
param: string AXO Group Name
param: string Return Value
return: array containing ACL IDs if search is successful

append_acl($acl_id, $aro_array=NULL, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $aco_array=NULL)   X-Ref
append_acl()

Appends objects on to a specific ACL.

param: int ACL ID #
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
return: bool TRUE if successful, FALSE otherwise.

shift_acl($acl_id, $aro_array=NULL, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $aco_array=NULL)   X-Ref
shift_acl()

Opposite of append_acl(). Removes objects from a specific ACL. (named after PHP's array_shift())

param: int ACL ID #
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
return: bool TRUE if successful, FALSE otherwise.

get_acl($acl_id)   X-Ref
get_acl()

Grabs ACL data.

param: int ACL ID #
return: mixed    bool FALSE if not found, or Associative Array with the following items:

is_conflicting_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $ignore_acl_ids=NULL)   X-Ref
is_conflicting_acl()

Checks for conflicts when adding a specific ACL.

param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Array of ACL IDs to ignore from the result set.
return: bool Returns true if conflict is found.

add_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL, $section_value=NULL, $acl_id=FALSE )   X-Ref
add_acl()

Add's an ACL. ACO_IDS, ARO_IDS, GROUP_IDS must all be arrays.

param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: int Allow flag
param: int Enabled flag
param: string Return Value
param: string Note
param: string ACL Section Value
param: int ACL ID # Specific Request
return: bool Return ACL ID of new ACL if successful, FALSE otherewise.

edit_acl($acl_id, $aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL, $section_value=NULL)   X-Ref
edit_acl()

Edit's an ACL, ACO_IDS, ARO_IDS, GROUP_IDS must all be arrays.

param: int ACL ID # to edit
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
param: array Array of Group IDs
param: int Allow flag
param: int Enabled flag
param: string Return Value
param: string Note
param: string ACL Section Value
return: bool Return TRUE if successful, FALSE otherewise.

del_acl($acl_id)   X-Ref
del_acl()

Deletes a given ACL

param: int ACL ID # to delete
return: bool Returns TRUE if successful, FALSE otherwise.

sort_groups($group_type='ARO')   X-Ref
sort_groups()

Grabs all the groups from the database doing preliminary grouping by parent

param: string Group Type, either 'ARO' or 'AXO'
return: array Returns 2-Dimensional array: $array[<parent_id>][<group_id>] = <group_name>

format_groups($sorted_groups, $type='TEXT', $root_id=0, $level=0, $formatted_groups=NULL)   X-Ref
format_groups()

Takes the array returned by sort_groups() and formats for human
consumption. Recursively calls itself to produce the desired output.

param: array Output from gacl_api->sorted_groups($group_type)
param: array Output type desired, either 'TEXT', 'TEXT_ASSOC', 'HTML', 'ARRAY' or 'ASSOC'
param: int Root of tree to produce
param: int Current level of depth
param: array Pass the current formatted groups object for appending via recursion.
return: array Array of formatted text, ordered by group id, formatted according to $type

get_group_id($value = NULL, $name = NULL, $group_type = 'ARO')   X-Ref
get_group_id()

Gets the group_id given the name or value.

Will only return one group id, so if there are duplicate names, it will return false.

param: string Group Value
param: string Group Name
param: string Group Type, either 'ARO' or 'AXO'
return: int Returns Group ID if found and Group ID is unique in database, otherwise, returns FALSE

get_group_children($group_id, $group_type = 'ARO', $recurse = 'NO_RECURSE')   X-Ref
get_group_children()

Gets a groups child IDs

param: int Group ID #
param: int Group Type, either 'ARO' or 'AXO'
param: string Either 'RECURSE' or 'NO_RECURSE', to recurse while fetching group children.
return: array Array of Child ID's of the referenced group

get_group_data($group_id, $group_type = 'ARO')   X-Ref
get_group_data()

Gets the group data given the GROUP_ID.

param: int Group ID #
param: string Group Type, either 'ARO' or 'AXO'
return: array Returns numerically indexed array with the following columns:

get_group_parent_id($id, $group_type='ARO')   X-Ref
get_group_parent_id()

Grabs the parent_id of a given group

param: int Group ID #
param: string Group Type, either 'ARO' or 'AXO'
return: int Parent ID of the Group

get_root_group_id($group_type='ARO')   X-Ref
get_root_group_id ()

Grabs the id of the root group for the specified tree

param: string Group Type, either 'ARO' or 'AXO'
return: int Root Group ID #

add_group($value, $name, $parent_id=0, $group_type='ARO')   X-Ref
No description

get_group_objects($group_id, $group_type='ARO', $option='NO_RECURSE')   X-Ref
get_group_objects()

Gets all objects assigned to a group.

If $option == 'RECURSE' it will get all objects in child groups as well.
defaults to omit child groups.

param: int Group ID #
param: string Group Type, either 'ARO' or 'AXO'
param: string Option, either 'RECURSE' or 'NO_RECURSE'
return: array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]

add_group_object($group_id, $object_section_value, $object_value, $group_type='ARO')   X-Ref
add_group_object()

Assigns an Object to a group

param: int Group ID #
param: string Object Section Value
param: string Object Value
param: string Group Type, either 'ARO' or 'AXO'
return: bool Returns TRUE if successful, FALSE otherwise.

del_group_object($group_id, $object_section_value, $object_value, $group_type='ARO')   X-Ref
del_group_object()

Removes an Object from a group.

param: int Group ID #
param: string Object Section Value
param: string Object Value
param: string Group Type, either 'ARO' or 'AXO'
return: bool Returns TRUE if successful, FALSE otherwise

edit_group($group_id, $value=NULL, $name=NULL, $parent_id=NULL, $group_type='ARO')   X-Ref
edit_group()

Edits a group

returns: bool Returns TRUE if successful, FALSE otherwise
param: int Group ID #
param: string Group Value
param: string Group Name
param: int Parent ID #
param: string Group Type, either 'ARO' or 'AXO'

rebuild_tree($group_type = 'ARO', $group_id = NULL, $left = 1)   X-Ref
rebuild_tree ()

rebuilds the group tree for the given type

param: string Group Type, either 'ARO' or 'AXO'
param: int Group ID #
param: int Left value of Group
return: bool Returns TRUE if successful, FALSE otherwise

_rebuild_tree($table, $group_id, $left = 1)   X-Ref
_rebuild_tree ()

Utility recursive function called by rebuild_tree()

param: string Table name of group type
param: int Group ID #
param: int Left value of Group
return: int Returns right value of this node + 1

del_group($group_id, $reparent_children=TRUE, $group_type='ARO')   X-Ref
del_group()

deletes a given group

param: int Group ID #
param: bool If TRUE, child groups of this group will be reparented to the current group's parent.
param: string Group Type, either 'ARO' or 'AXO'
return: bool Returns TRUE if successful, FALSE otherwise.

get_object($section_value = null, $return_hidden=1, $object_type=NULL)   X-Ref
get_object()

Grabs all Objects's in the database, or specific to a section_value

param: string Filter to this section value
param: int Returns hidden objects if 1, leaves them out otherwise.
param: string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
return: ADORecordSet  Returns recordset directly, with object ID only selected:

get_ungrouped_objects($return_hidden=1, $object_type=NULL)   X-Ref
get_ungrouped_objects()

Grabs ID's of all Objects (ARO's and AXO's only) in the database not assigned to a Group.

This function is useful for applications that synchronize user databases with an outside source.
If syncrhonization doesn't automatically place users in an appropriate group, this function can
quickly identify them so that they can be assigned to the correct group.

param: int Returns hidden objects if 1, does not if 0.
param: string Object Type, either 'ARO' or 'AXO' (groupable types)
return: array Returns an array of object ID's

get_objects($section_value = NULL, $return_hidden = 1, $object_type = NULL)   X-Ref
get_objects ()

Grabs all Objects in the database, or specific to a section_value

param: string Filter for section value
param: int Returns hidden objects if 1, does not if 0
param: string Object Type, either 'ACO', 'ARO', 'AXO'
return: array Returns objects in format suitable for add_acl and is_conflicting_acl

get_object_data($object_id, $object_type=NULL)   X-Ref
get_object_data()

Gets all data pertaining to a specific Object.

param: int Object ID #
param: string Object Type, either 'ACO', 'ARO', 'AXO'
return: array Returns 2-Dimensional array of rows with columns = ( section_value, value, order_value, name, hidden )

get_object_id($section_value, $value, $object_type=NULL)   X-Ref
get_object_id()

Gets the object_id given the section_value AND value of the object.

param: string Object Section Value
param: string Object Value
param: string Object Type, either 'ACO', 'ARO', 'AXO'
return: int Object ID #

get_object_section_value($object_id, $object_type=NULL)   X-Ref
get_object_section_value()

Gets the object_section_value given object id

param: int Object ID #
param: string Object Type, either 'ACO', 'ARO', or 'AXO'
return: string Object Section Value

get_object_groups($object_id, $object_type = 'ARO', $option = 'NO_RECURSE')   X-Ref
get_object_groups()

Gets all groups an object is a member of.

If $option == 'RECURSE' it will get all ancestor groups.
defaults to only get direct parents.

param: int Object ID #
param: string Object Type, either 'ARO' or 'AXO'
param: string Option, either 'RECURSE', or 'NO_RECURSE'
return: array Array of Group ID #'s, or FALSE if Failed

add_object($section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL)   X-Ref
add_object()

Inserts a new object

param: string Object Section Value
param: string Object Name
param: string Object Value
param: int Display Order
param: int Hidden Flag, either 1 to hide, or 0 to show.
param: string Object Type, either 'ACO', 'ARO', or 'AXO'
return: int Returns the ID # of the new object if successful, FALSE otherwise

edit_object($object_id, $section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL)   X-Ref
edit_object()

Edits a given Object

param: int Object ID #
param: string Object Section Value
param: string Object Name
param: string Object Value
param: int Display Order
param: int Hidden Flag, either 1 to hide, or 0 to show
param: string Object Type, either 'ACO', 'ARO', or 'AXO'
return: bool Returns TRUE if successful, FALSE otherwise

del_object($object_id, $object_type=NULL, $erase=FALSE)   X-Ref
del_object()

Deletes a given Object and, if instructed to do so, erase all referencing objects

ERASE feature by: Martino Piccinato

param: int Object ID #
param: string Object Type, either 'ACO', 'ARO', or 'AXO'
param: bool Erases all referencing objects if TRUE, leaves them alone otherwise.
return: bool Returns TRUE if successful, FALSE otherwise.

get_object_section_section_id($name = NULL, $value = NULL, $object_type = NULL)   X-Ref
get_object_section_section_id()

Gets the object_section_id given the name AND/OR value of the section.

Will only return one section id, so if there are duplicate names it will return false.

param: string Object Name
param: string Object Value
param: string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
return: int Object Section ID if the object section is found AND is unique, or FALSE otherwise.

add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL)   X-Ref
add_object_section()

Inserts an object Section

param: string Object Name
param: string Object Value
param: int Display Order
param: int Hidden flag, hides section if 1, shows section if 0
param: string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
return: int Object Section ID of new section

edit_object_section($object_section_id, $name, $value=0, $order=0, $hidden=0, $object_type=NULL)   X-Ref
edit_object_section()

Edits a given Object Section

param: int Object Section ID #
param: string Object Section Name
param: string Object Section Value
param: int Display Order
param: int Hidden Flag, hide object section if 1, show if 0
param: string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
return: bool Returns TRUE if successful, FALSE otherwise

del_object_section($object_section_id, $object_type=NULL, $erase=FALSE)   X-Ref
del_object_section()

Deletes a given Object Section and, if explicitly asked, all the section objects

ERASE feature by: Martino Piccinato

param: int Object Section ID # to delete
param: string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
param: bool Erases all section objects assigned to the section
return: bool Returns TRUE if successful, FALSE otherwise

get_section_data($section_value, $object_type=NULL)   X-Ref
get_section_data()

Gets the section data given the Section Value

param: string Section Value
param: string Object Type, either 'ACO', 'ARO', or 'AXO'
return: array Returns numerically indexed array with the following columns:

clear_database()   X-Ref
clear_database()

Deletes all data from the phpGACL tables. USE WITH CAUTION.

return: bool Returns TRUE if successful, FALSE otherwise

_defaultGenID( $table )   X-Ref
Calculates the start number for a sequence table

param: string The name of the table
return: int The highest id plus one



Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1