Improvements to debug_log
This commit is contained in:
127
lib/Template.php
127
lib/Template.php
@@ -57,6 +57,9 @@ class Template extends xmlTemplate {
|
||||
private $rdn;
|
||||
|
||||
public function __clone() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# We need to clone our attributes, when passing back a template with getTemplate
|
||||
foreach ($this->attributes as $key => $value)
|
||||
$this->attributes[$key] = clone $value;
|
||||
@@ -68,21 +71,21 @@ class Template extends xmlTemplate {
|
||||
* @param xmldata Parsed xmldata from xml2array object
|
||||
*/
|
||||
protected function storeTemplate($xmldata) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',5,__FILE__,__LINE__,__METHOD__,$xmldata);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$server = $this->getServer();
|
||||
$objectclasses = array();
|
||||
|
||||
foreach ($xmldata['template'] as $xml_key => $xml_value) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Foreach loop Key [%s] Value [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key,is_array($xml_value));
|
||||
debug_log('Foreach loop Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key,is_array($xml_value));
|
||||
|
||||
switch ($xml_key) {
|
||||
# Build our object Classes from the DN and Template.
|
||||
case ('objectclasses'):
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key);
|
||||
debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key);
|
||||
|
||||
if (isset($xmldata['template'][$xml_key]['objectclass']))
|
||||
if (is_array($xmldata['template'][$xml_key]['objectclass'])) {
|
||||
@@ -116,13 +119,13 @@ class Template extends xmlTemplate {
|
||||
# Build our attribute list from the DN and Template.
|
||||
case ('attributes'):
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key);
|
||||
debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key);
|
||||
|
||||
if (is_array($xmldata['template'][$xml_key])) {
|
||||
foreach ($xmldata['template'][$xml_key] as $tattrs)
|
||||
foreach ($tattrs as $index => $details) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Foreach tattrs Key [%s] Value [%s]',4,__FILE__,__LINE__,__METHOD__,
|
||||
debug_log('Foreach tattrs Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__,
|
||||
$index,$details);
|
||||
|
||||
# If there is no schema definition for the attribute, it will be ignored.
|
||||
@@ -138,7 +141,7 @@ class Template extends xmlTemplate {
|
||||
|
||||
default:
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key);
|
||||
debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key);
|
||||
|
||||
# Some key definitions need to be an array, some must not be:
|
||||
$allowed_arrays = array('rdn');
|
||||
@@ -216,6 +219,9 @@ class Template extends xmlTemplate {
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasDefaultTemplate() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($_SESSION[APPCONFIG]->getValue('appearance','disable_default_template'))
|
||||
return false;
|
||||
else
|
||||
@@ -229,8 +235,8 @@ class Template extends xmlTemplate {
|
||||
* @return array - Array of templates of that type
|
||||
*/
|
||||
protected function readTemplates($type) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$template_xml = new Templates($this->server_id);
|
||||
return $template_xml->getTemplates($type);
|
||||
@@ -245,6 +251,9 @@ class Template extends xmlTemplate {
|
||||
* (OLD values are IGNORED, we will have got them when we build this object from the LDAP server DN.)
|
||||
*/
|
||||
public function accept($makeVisible=false) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$server = $this->getServer();
|
||||
|
||||
# If a DN is set, then query the LDAP server for the details.
|
||||
@@ -546,6 +555,9 @@ class Template extends xmlTemplate {
|
||||
* @param dn The DN of the entry
|
||||
*/
|
||||
public function setDN($dn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (isset($this->container))
|
||||
system_message(array(
|
||||
'title'=>__METHOD__,
|
||||
@@ -564,6 +576,9 @@ class Template extends xmlTemplate {
|
||||
* @return RDN attributes not processed
|
||||
*/
|
||||
public function setRDNAttributes($rdn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# Setup to work out our RDN.
|
||||
$rdnarray = rdn_explode($rdn);
|
||||
|
||||
@@ -588,6 +603,9 @@ class Template extends xmlTemplate {
|
||||
* @return dn
|
||||
*/
|
||||
public function getDN() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->dn);
|
||||
|
||||
if ($this->dn)
|
||||
return $this->dn;
|
||||
|
||||
@@ -603,6 +621,9 @@ class Template extends xmlTemplate {
|
||||
* @todo Trigger a query to the LDAP server and generate an error if the container doesnt exist
|
||||
*/
|
||||
public function setContainer($container) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (isset($this->dn))
|
||||
system_message(array(
|
||||
'title'=>__METHOD__,
|
||||
@@ -618,6 +639,9 @@ class Template extends xmlTemplate {
|
||||
* @return dn DN of the container
|
||||
*/
|
||||
public function getContainer() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->container);
|
||||
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
@@ -625,6 +649,9 @@ class Template extends xmlTemplate {
|
||||
* Copy a DN
|
||||
*/
|
||||
public function copy($template,$rdn) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$rdnarray = rdn_explode($rdn);
|
||||
|
||||
$counter = 1;
|
||||
@@ -683,6 +710,9 @@ class Template extends xmlTemplate {
|
||||
* @return array Array of attributes.
|
||||
*/
|
||||
function getAttrbyLdapType($type) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($this->attributes as $index => $attribute) {
|
||||
@@ -697,6 +727,9 @@ class Template extends xmlTemplate {
|
||||
* Return true if this is a MUST,MAY attribute
|
||||
*/
|
||||
function isAttrType($attr,$type) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (in_array(strtolower($attr),$this->getAttrbyLdapType($type)))
|
||||
return true;
|
||||
else
|
||||
@@ -709,6 +742,9 @@ class Template extends xmlTemplate {
|
||||
* @return array Array of RDN objects
|
||||
*/
|
||||
private function getRDNObjects() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach ($this->attributes as $attribute)
|
||||
@@ -725,6 +761,9 @@ class Template extends xmlTemplate {
|
||||
* @return array RDNs in order.
|
||||
*/
|
||||
public function getRDNAttrs() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$return = array();
|
||||
|
||||
foreach ($this->getRDNObjects() as $attribute) {
|
||||
@@ -751,6 +790,9 @@ class Template extends xmlTemplate {
|
||||
* @return rdn RDN for this template
|
||||
*/
|
||||
public function getRDN() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# If the DN is set, then the RDN will be calculated from it.
|
||||
if ($this->dn)
|
||||
return get_rdn($this->dn);
|
||||
@@ -776,6 +818,9 @@ class Template extends xmlTemplate {
|
||||
* Return the attribute name part of the RDN
|
||||
*/
|
||||
public function getRDNAttributeName() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attr = array();
|
||||
|
||||
if ($this->getDN()) {
|
||||
@@ -798,6 +843,9 @@ class Template extends xmlTemplate {
|
||||
* Determine the type of template this is
|
||||
*/
|
||||
public function getContext() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($this->getContainer())
|
||||
return 'create';
|
||||
elseif ($this->getDN())
|
||||
@@ -812,10 +860,16 @@ class Template extends xmlTemplate {
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVisible() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->visible);
|
||||
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
public function getRegExp() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->regexp);
|
||||
|
||||
return $this->regexp;
|
||||
}
|
||||
|
||||
@@ -823,6 +877,9 @@ class Template extends xmlTemplate {
|
||||
* Test if this template has been marked as a read-only template
|
||||
*/
|
||||
public function isReadOnly() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ((($this->getContext() == 'edit') && $this->readonly) || $this->getServer()->isReadOnly())
|
||||
return true;
|
||||
else
|
||||
@@ -836,6 +893,9 @@ class Template extends xmlTemplate {
|
||||
* @return array Array of attributes
|
||||
*/
|
||||
public function getAttributes($optional=false) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($optional)
|
||||
return $this->attributes;
|
||||
|
||||
@@ -854,6 +914,9 @@ class Template extends xmlTemplate {
|
||||
* Return a list of attributes that should be shown
|
||||
*/
|
||||
public function getAttributesShown() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($this->attributes as $attribute)
|
||||
@@ -867,6 +930,9 @@ class Template extends xmlTemplate {
|
||||
* Return a list of the internal attributes
|
||||
*/
|
||||
public function getAttributesInternal() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($this->attributes as $attribute)
|
||||
@@ -882,6 +948,9 @@ class Template extends xmlTemplate {
|
||||
* @return array Array of Objects
|
||||
*/
|
||||
public function getObjectClasses() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attribute = $this->getAttribute('objectclass');
|
||||
if ($attribute)
|
||||
return $attribute->getValues();
|
||||
@@ -893,6 +962,9 @@ class Template extends xmlTemplate {
|
||||
* Get template icon
|
||||
*/
|
||||
public function getIcon() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->icon);
|
||||
|
||||
return isset($this->icon) ? sprintf('%s/%s',IMGDIR,$this->icon) : '';
|
||||
}
|
||||
|
||||
@@ -902,6 +974,9 @@ class Template extends xmlTemplate {
|
||||
* @return string Description
|
||||
*/
|
||||
public function getDescription() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->description);
|
||||
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
@@ -911,6 +986,9 @@ class Template extends xmlTemplate {
|
||||
* @param string Message indicating the reason the template has been invalidated
|
||||
*/
|
||||
public function setInvalid($msg,$admin=false) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$this->invalid = true;
|
||||
$this->invalid_reason = $msg;
|
||||
$this->invalid_admin = $admin;
|
||||
@@ -922,6 +1000,9 @@ class Template extends xmlTemplate {
|
||||
* @return string Invalid reason, or false if not invalid
|
||||
*/
|
||||
public function isInValid() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($this->invalid)
|
||||
return $this->invalid_reason;
|
||||
else
|
||||
@@ -929,6 +1010,9 @@ class Template extends xmlTemplate {
|
||||
}
|
||||
|
||||
public function isAdminDisabled() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->invalid_admin);
|
||||
|
||||
return $this->invalid_admin;
|
||||
}
|
||||
|
||||
@@ -939,6 +1023,9 @@ class Template extends xmlTemplate {
|
||||
* @param int
|
||||
*/
|
||||
private function setMinValueCount($attr,$value) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attribute = $this->getAttribute($attr);
|
||||
|
||||
if (! is_null($attribute))
|
||||
@@ -952,6 +1039,9 @@ class Template extends xmlTemplate {
|
||||
* @param string (MUST,MAY,OPTIONAL)
|
||||
*/
|
||||
private function setAttrLDAPtype($attr,$value) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attribute = $this->getAttribute($attr);
|
||||
|
||||
if (is_null($attribute))
|
||||
@@ -964,8 +1054,8 @@ class Template extends xmlTemplate {
|
||||
* OnChangeAdd javascript processing
|
||||
*/
|
||||
public function OnChangeAdd($origin,$value) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s,%s)',5,__FILE__,__LINE__,__METHOD__,$origin,$value);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attribute = $this->getAttribute($origin);
|
||||
|
||||
@@ -1130,6 +1220,9 @@ class Template extends xmlTemplate {
|
||||
* STRUCTURAL - without one, creating an entry will just product an LDAP error.
|
||||
*/
|
||||
private function rebuildTemplateAttrs() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$server = $this->getServer();
|
||||
|
||||
# Collect our structural, MUST & MAY attributes.
|
||||
@@ -1241,6 +1334,9 @@ class Template extends xmlTemplate {
|
||||
* Attributes with empty values will be excluded.
|
||||
*/
|
||||
public function getLDAPadd($attrsOnly=false) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$return = array();
|
||||
$returnattrs = array();
|
||||
|
||||
@@ -1273,6 +1369,9 @@ class Template extends xmlTemplate {
|
||||
* @param boolean Return the attribute objects (useful for a confirmation process), or the modification array for ldap_modify()
|
||||
*/
|
||||
public function getLDAPmodify($attrsOnly=false,$index=0) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $return = array();
|
||||
static $returnattrs = array();
|
||||
|
||||
@@ -1351,6 +1450,9 @@ class Template extends xmlTemplate {
|
||||
* We'll cache this result in the event of multiple calls.
|
||||
*/
|
||||
public function getForceDeleteAttrs() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $result = array();
|
||||
|
||||
if (count($result))
|
||||
@@ -1367,6 +1469,9 @@ class Template extends xmlTemplate {
|
||||
* Get available attributes
|
||||
*/
|
||||
public function getAvailAttrs() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$attributes = array();
|
||||
$server = $this->getServer();
|
||||
|
||||
|
Reference in New Issue
Block a user