Exemplo n.º 1
0
 public function testDebugDump()
 {
     ob_end_flush();
     ob_start();
     debug_dump(false, true, 3, 5, 'this is a string');
     $out = trim(ob_get_contents());
     ob_clean();
     $this->assertEquals('5447a8b60d5bc9667e6be2040be3f5b786fcc99b', sha1($out));
 }
Exemplo n.º 2
0
 /**
  * Main processing to store the template.
  *
  * @param xmldata Parsed xmldata from xml2array object
  */
 protected function storeTemplate($xmldata)
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     $server = $this->getServer();
     foreach ($xmldata['query'] as $xml_key => $xml_value) {
         if (DEBUG_ENABLED) {
             debug_log('Foreach loop Key [%s] Value [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key, is_array($xml_value));
         }
         switch ($xml_key) {
             # Build our attribute list from the DN and Template.
             case 'attributes':
                 if (DEBUG_ENABLED) {
                     debug_log('Case [%s]', 4, 0, __FILE__, __LINE__, __METHOD__, $xml_key);
                 }
                 if (is_array($xmldata['query'][$xml_key])) {
                     foreach ($xmldata['query'][$xml_key] as $tattrs) {
                         foreach ($tattrs as $index => $details) {
                             if (DEBUG_ENABLED) {
                                 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.
                             if ($sattr = $server->getSchemaAttribute($index)) {
                                 if (is_null($attribute = $this->getAttribute($sattr->getName()))) {
                                     $attribute = $this->addAttribute($sattr->getName(false), array('values' => array()));
                                 }
                                 $attribute->show();
                                 $attribute->setXML($details);
                             }
                         }
                     }
                 }
                 break;
                 # Build our bases list from the DN and Template.
             # Build our bases list from the DN and Template.
             case 'bases':
                 if (isset($xmldata['query'][$xml_key]['base'])) {
                     if (is_array($xmldata['query'][$xml_key]['base'])) {
                         $this->base = $xmldata['query'][$xml_key]['base'];
                     } else {
                         $this->base = array($xmldata['query'][$xml_key]['base']);
                     }
                 } else {
                     error(sprintf(_('In the XML file (%s), [%s] contains an unknown key.'), $this->filename, $xml_key), 'error', 'index.php');
                 }
                 $this->base = array_unique($this->base);
                 break;
             default:
                 if (DEBUG_ENABLED) {
                     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('');
                 $storelower = array('');
                 $storearray = array('');
                 # Items that must be stored lowercase
                 if (in_array($xml_key, $storelower)) {
                     if (is_array($xml_value)) {
                         foreach ($xml_value as $index => $value) {
                             $xml_value[$index] = strtolower($value);
                         }
                     } else {
                         $xml_value = strtolower($xml_value);
                     }
                 }
                 # Items that must be stored as arrays
                 if (in_array($xml_key, $storearray) && !is_array($xml_value)) {
                     $xml_value = array($xml_value);
                 }
                 # Items that should not be an array
                 if (!in_array($xml_key, $allowed_arrays) && is_array($xml_value)) {
                     debug_dump(array(__METHOD__, 'key' => $xml_key, 'value' => $xml_value));
                     error(sprintf(_('In the XML file (%s), [%s] is an array, it must be a string.'), $this->filename, $xml_key), 'error');
                 }
                 $this->{$xml_key} = $xml_value;
         }
     }
     # Check we have some manditory items.
     foreach (array() as $key) {
         if (!isset($this->{$key}) || !is_array($this->{$key}) && !trim($this->{$key})) {
             $this->setInvalid(sprintf(_('Missing %s in the XML file.'), $key));
             break;
         }
     }
 }
Exemplo n.º 3
0
 public function setProperties($properties)
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     foreach ($properties as $index => $value) {
         if ($index == 'maxvalnb') {
             $this->setMaxValueCount($value);
             continue;
         } elseif ($index == 'minvalnb') {
             $this->setMinValueCount($value);
             continue;
         } elseif ($index == 'maxlength') {
             $this->setMinValueCount($value);
             continue;
         } elseif ($index == 'hidden') {
             $this->visible = $value;
             continue;
         } elseif (in_array($index, array('cols', 'rows'))) {
             # @todo To be implemented
             continue;
         }
         if (isset($this->{$index})) {
             $this->{$index} = $value;
         } else {
             debug_dump($this);
             debug_dump_backtrace(sprintf('Unknown property (%s) with value (%s) for (%s)', $index, $value, $this->getName()), 1);
         }
     }
 }
function debug_print($var)
{
    print debug_dump($var);
}
Exemplo n.º 5
0
 /**
  * Given a DN string and a path like syntax, this returns the parent container portion of the string.
  *
  * @param string The DN whose container string to return.
  * @param string Either '/', '.' or something like '../../<rdn>'
  * @return string The container
  */
 public function getContainerPath($dn, $path = '..')
 {
     if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) {
         debug_log('Entered (%%)', 17, 0, __FILE__, __LINE__, __METHOD__, $fargs);
     }
     $top = $this->getContainerTop($dn);
     if ($path[0] == '/') {
         $dn = $top;
         $path = substr($path, 1);
     } elseif ($path == '.') {
         return $dn;
     }
     $parenttree = explode('/', $path);
     foreach ($parenttree as $key => $value) {
         if ($value == '..') {
             if ($this->getContainer($dn)) {
                 $dn = $this->getContainer($dn);
             }
             if ($dn == $top) {
                 break;
             }
         } elseif ($value) {
             $dn = sprintf('%s,%s', $value, $dn);
         } else {
             break;
         }
     }
     if (!$dn) {
         debug_dump(array(__METHOD__, 'dn' => $dn, 'path' => $path));
         debug_dump_backtrace('Container is empty?', 1);
     }
     return $dn;
 }
Exemplo n.º 6
0
 * Main command page for phpLDAPadmin
 * All pages are rendered through this script.
 *
 * @package phpLDAPadmin
 * @subpackage Page
 */
/**
 */
require_once './common.php';
$www = array();
$www['cmd'] = get_request('cmd', 'REQUEST');
$www['meth'] = get_request('meth', 'REQUEST');
ob_start();
switch ($www['cmd']) {
    case '_debug':
        debug_dump($_REQUEST, 1);
        break;
    default:
        if (defined('HOOKSDIR') && file_exists(HOOKSDIR . $www['cmd'] . '.php')) {
            $app['script_cmd'] = HOOKSDIR . $www['cmd'] . '.php';
        } elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR . $www['cmd'] . '.php')) {
            $app['script_cmd'] = HTDOCDIR . $www['cmd'] . '.php';
        } elseif (file_exists('welcome.php')) {
            $app['script_cmd'] = 'welcome.php';
        } else {
            $app['script_cmd'] = null;
        }
}
if (DEBUG_ENABLED) {
    debug_log('Ready to render page for command [%s,%s].', 128, 0, __FILE__, __LINE__, __METHOD__, $www['cmd'], $app['script_cmd']);
}
Exemplo n.º 7
0
/**
 * Record a system message.
 * This function can be used as an alternative to generate a system message, if page hasnt yet been defined.
 */
function system_message($msg, $redirect = null)
{
    if (!is_array($msg)) {
        return null;
    }
    if (!isset($msg['title']) && !isset($msg['body'])) {
        return null;
    }
    if (!isset($msg['type'])) {
        $msg['type'] = 'info';
    }
    if (!isset($_SESSION['sysmsg']) || !is_array($_SESSION['sysmsg'])) {
        $_SESSION['sysmsg'] = array();
    }
    # Try and detect if we are in a redirect loop
    if (get_request('redirect', 'GET') && $msg['type'] != 'debug') {
        foreach ($_SESSION['sysmsg'] as $detail) {
            if ($msg == $detail && !isset($detail['special'])) {
                debug_dump(array('Incoming MSG' => $msg, 'existing' => $_SESSION['sysmsg']));
                debug_dump_backtrace('Redirect Loop Detected', true);
            }
        }
    }
    array_push($_SESSION['sysmsg'], $msg);
    if ($redirect) {
        if (preg_match('/\\?/', $redirect)) {
            $redirect .= '&';
        } else {
            $redirect .= '?';
        }
        $redirect .= 'redirect=true';
        # Check if we were an ajax request, and only render the ajax message
        if (get_request('meth', 'REQUEST') == 'ajax') {
            $redirect .= '&meth=ajax';
        }
        header("Location: {$redirect}");
        die;
    }
}
Exemplo n.º 8
0
 /**
  * makeQuery method
  * @param string $query (default value null)
  * @return Database object
  * */
 public function query($query = null)
 {
     $this->query = !is_null($query) ? $query : $this->select . $this->insert . $this->update . $this->delete . $this->create . $this->from . $this->join . $this->where . $this->group . $this->having . $this->order . $this->limit;
     try {
         $this->query = $this->db->prepare($this->query);
         $this->query->execute();
         $this->rowCount = $this->query->rowCount();
         $this->setLastID();
     } catch (\PDOException $ex) {
         debug_dump($ex->getMessage(), true);
     }
     return $this;
 }
Exemplo n.º 9
0
 public function drawFormEnd()
 {
     if (DEBUGTMP) {
         printf('<font size=-2>%s</font><br />', __METHOD__);
     }
     # Include the RDN details to support creating the base
     if (get_request('create_base')) {
         if (get_request('rdn')) {
             $rdn = explode('=', get_request('rdn'));
             echo '<div>';
             printf('<input type="hidden" name="new_values[%s][]" value="%s" />', $rdn[0], $rdn[1]);
             printf('<input type="hidden" name="rdn_attribute[]" value="%s" />', $rdn[0]);
             echo '</div>';
         }
     }
     echo '</form>';
     # Javascript
     $this->drawJavascript();
     # For debugging, show the template object.
     if (!$_SESSION[APPCONFIG]->getValue('appearance', 'hide_debug_info') && get_request('debug', 'GET')) {
         echo "\n\n";
         printf('<img src="%s/plus.png" alt="Plus" onclick="if (document.getElementById(\'DEBUGtemplate\').style.display == \'none\') { document.getElementById(\'DEBUGtemplate\').style.display = \'block\' } else { document.getElementById(\'DEBUGtemplate\').style.display = \'none\' };"/>', IMGDIR);
         echo '<div id="DEBUGtemplate" style="display: none">';
         echo '<fieldset>';
         printf('<legend>DEBUG: %s</legend>', $this->template->getDescription());
         echo '<textarea cols="120" rows="20">';
         debug_dump($this);
         echo '</textarea>';
         echo '</fieldset>';
         echo '</div>';
     }
 }
Exemplo n.º 10
0
 			foreach( $urlreplace as $search => $replace )
 			{
 				$post_content = str_replace( $urlsearch, $urlreplace, $post_content );
 			}
 			if( $post_content != $old_content )
 			{
 				echo '<p style="color:darkblue;border:1px dashed orange;">'.htmlspecialchars($old_content).'</p>
 				converted img-links to: <p style="color:darkblue;border:1px dashed orange;">'.htmlspecialchars($post_content).'</p>';
 			}
 		}*/
 debug_dump($post_catids, 'post_extracats');
 $post_category = array_shift($post_catids);
 debug_dump($post_category, 'post_category');
 debug_dump($post_categories, 'post_categories');
 debug_dump($post_author, 'post_author');
 debug_dump(isset($item_Author->ID) ? $item_Author->ID : 'NULL (simulating)', 'item_Author->ID');
 if (!$simulate) {
     $edited_Item = new Item();
     $edited_Item->set_creator_User($item_Author);
     $edited_Item->set('title', $post_title);
     $edited_Item->set('content', $post_content);
     $edited_Item->set('datestart', $post_date);
     $edited_Item->set('main_cat_ID', $post_category);
     $edited_Item->set('extra_cat_IDs', $post_catids);
     $edited_Item->set('status', $post_status);
     $edited_Item->set('locale', $post_locale);
     $edited_Item->set('notifications_status', 'finished');
     $edited_Item->set('comment_status', $comment_status);
     $edited_Item->set_renderers($post_renderers);
     $edited_Item->dbinsert();
     $post_ID = $edited_Item->ID;
Exemplo n.º 11
0
 public function call($uri, $cmd = array(), &$data = null, $flags = array())
 {
     $call_start = microtime(true);
     $url = $this->makeURL($uri);
     //inject auth params
     if (!is_callable(array($this->auth_handler, 'requestParams'))) {
         throw new Exception('Auth handler doesnt support requests');
     }
     $cmd = array_merge($cmd, call_user_func($this->auth_handler . '::requestParams'));
     //print some info
     $this->log->add('Setting up call to: ' . $url);
     $this->log->add('Command Params: ' . print_r($cmd, true));
     $this->log->add('Flags Present: ' . print_r($flags, true), Log::DEBUG);
     if (!is_null($data)) {
         $this->log->add('Data present (' . strlen($data) . '): ' . substr($data, 0, 50) . '...', Log::DEBUG);
     }
     //encode cmd params
     $request = $this->encode($cmd);
     $this->log->add('Request Encoded: ' . $request, Log::DEBUG);
     //start curl if needed
     if (!$this->ch) {
         $this->initCURL();
     }
     //set the url to hit
     curl_setopt($this->ch, CURLOPT_URL, $url);
     //add the payload to the stream
     $this->stream->setPayload($request);
     //setup curl post
     $post_query = http_build_query(array('request' => $this->stream->encode(), 'data' => $data));
     curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_query);
     //if noexec is passed we simple pass the prepared curl handle back
     if (in_array(self::CALL_NOEXEC, $flags)) {
         return $this->ch;
     }
     //try the actual call
     $tries = 1;
     //TODO: tunables that need to be in the config
     $max_tries = 10;
     //the retry sleep gets multiplied by the number of tries
     //	thus the first call waits X ms and the last call waits X * $max_tries ms
     $retry_sleep = 300;
     //in ms
     //anything not defined here will trickle down and throw an exception
     $http_status_retry = array(5);
     $http_status_complete = array(2, 3);
     do {
         //execute the call
         $result = curl_exec($this->ch);
         if ($result === false) {
             throw new Exception('Call failed to ' . $url . ' ' . curl_error($this->ch));
         }
         //check the response status
         $http_status = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
         $http_status_class = floor($http_status / 100);
         if (in_array($http_status_class, $http_status_retry)) {
             $sleep_time = $retry_sleep * $tries;
             $this->log->add("Request failed with response code: " . $http_status . " retrying " . ($max_tries - $tries) . " more times waiting " . $sleep_time . "ms" . " until next try" . " req(" . $url . ")", Log::WARN);
             usleep($sleep_time * 1000);
             continue;
         }
         if (in_array($http_status_class, $http_status_complete)) {
             //exit the loop on success and continue
             break;
         }
         throw new Exception("Unrecognized HTTP RESPONSE CODE: " . $http_status);
     } while (++$tries < $max_tries);
     //separate channels
     parse_str($result, $response);
     unset($result);
     if (isset($response['data'])) {
         $data = $response['data'];
     }
     if (isset($response['debug']) && trim($response['debug']) != '') {
         debug_dump($response['debug']);
     }
     if (!isset($response['response'])) {
         throw new Exception('No response received with request: ' . print_r($response, true));
     }
     $response = $response['response'];
     //decode return payload
     $response = Stream::receive($response, $this->stream->getCrypt())->decode();
     $this->log->add('Response Raw (' . strlen($response) . '): ' . substr($response, 0, 50) . '...', Log::DEBUG);
     //decode the response
     $encoding = $this->decode($response);
     //log response
     if ($encoding != self::ENC_RAW) {
         // $response = array_shift($response);
         $this->log->add('Response received: ' . print_r($response, true), Log::DEBUG);
         //pass to error handler
         $this->errorHandler($response);
     }
     $this->log->add('Request took ' . number_format(microtime(true) - $call_start, 5) . ' seconds', Log::DEBUG);
     //if we got here there were no errors
     return $response;
 }
Exemplo n.º 12
0
 */
require './common.php';
$request = array();
$request['key'] = get_request('key', 'REQUEST');
$request['index'] = get_request('index', 'REQUEST');
if (get_request('global', 'REQUEST')) {
    $request['dumpvar'] =& $GLOBALS;
} else {
    $request['dumpvar'] =& $_SESSION;
}
if (isset($request['index']) && isset($request['key'])) {
    list($request['server'], $request['x']) = explode(':', $request['index']);
    debug_dump($request['dumpvar'][$request['key']][$request['server']][$request['x']], 1);
}
if ($request['key']) {
    debug_dump($request['dumpvar'][$request['key']], 1);
}
if (!$_SESSION[APPCONFIG]->getValue('appearance', 'hide_debug_info')) {
    echo '<div style="font-size: 11px"><ul>';
    foreach (array_keys($request['dumpvar']) as $key) {
        if (in_array($key, array('cache')) && is_array($request['dumpvar'][$key])) {
            foreach (array_keys($request['dumpvar'][$key]) as $server) {
                foreach (array_keys($request['dumpvar'][$key][$server]) as $x) {
                    $index = sprintf('%s:%s', $server, $x);
                    printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'%s\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>', $key . $index, $key, $index, $key . '.' . $index, $key . $index, $key . $index);
                }
            }
        } else {
            printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>', $key, $key, $key, $key);
        }
    }
Exemplo n.º 13
0
 public function drawFormEnd()
 {
     if (DEBUGTMP) {
         printf('<font size=-2>%s</font><br />', __METHOD__);
     }
     echo '</form>';
     # Javascript
     $this->drawJavascript();
     # For debugging, show the template object.
     if (!$_SESSION[APPCONFIG]->getValue('appearance', 'hide_debug_info') && get_request('debug', 'GET')) {
         echo "\n\n";
         printf('<img src="%s/plus.png" alt="Plus" onClick="if (document.getElementById(\'DEBUGtemplate\').style.display == \'none\') { document.getElementById(\'DEBUGtemplate\').style.display = \'block\' } else { document.getElementById(\'DEBUGtemplate\').style.display = \'none\' };"/>', IMGDIR);
         echo '<div id="DEBUGtemplate" style="display: none">';
         echo '<fieldset>';
         printf('<legend>DEBUG: %s</legend>', $this->template->getDescription());
         echo '<textarea cols=120 rows=20>';
         debug_dump($this);
         echo '</textarea>';
         echo '</fieldset>';
         echo '</div>';
     }
 }
Exemplo n.º 14
0
 public function run($stmt, $params = array())
 {
     if (!is_array($params)) {
         $params = array($params);
     }
     if ($this->debug) {
         debug_dump($stmt, $params);
     }
     $query = $this->prepare($stmt);
     $query->execute($params);
     return $query;
 }
Exemplo n.º 15
0
 /**
  * Main processing to store the template.
  *
  * @param xmldata Parsed xmldata from xml2array object
  */
 protected function storeTemplate($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, 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, 0, __FILE__, __LINE__, __METHOD__, $xml_key);
                 }
                 if (isset($xmldata['template'][$xml_key]['objectclass'])) {
                     if (is_array($xmldata['template'][$xml_key]['objectclass'])) {
                         foreach ($xmldata['template'][$xml_key]['objectclass'] as $index => $details) {
                             # XML files with only 1 objectClass dont have a numeric index.
                             $soc = $server->getSchemaObjectClass(strtolower($details));
                             # If we havent recorded this objectclass already, do so now.
                             if (is_object($soc) && !in_array($soc->getName(), $objectclasses)) {
                                 array_push($objectclasses, $soc->getName(false));
                             } elseif (!is_object($soc) && !$_SESSION[APPCONFIG]->getValue('appearance', 'hide_template_warning')) {
                                 system_message(array('title' => _('Automatically removed objectClass from template'), 'body' => sprintf('%s: <b>%s</b> %s', $this->getTitle(), $details, _('removed from template as it is not defined in the schema')), 'type' => 'warn'));
                             }
                         }
                     } else {
                         # XML files with only 1 objectClass dont have a numeric index.
                         $soc = $server->getSchemaObjectClass(strtolower($xmldata['template'][$xml_key]['objectclass']));
                         # If we havent recorded this objectclass already, do so now.
                         if (is_object($soc) && !in_array($soc->getName(), $objectclasses)) {
                             array_push($objectclasses, $soc->getName(false));
                         }
                     }
                 }
                 break;
                 # Build our attribute list from the DN and Template.
             # Build our attribute list from the DN and Template.
             case 'attributes':
                 if (DEBUG_ENABLED) {
                     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, 0, __FILE__, __LINE__, __METHOD__, $index, $details);
                             }
                             # If there is no schema definition for the attribute, it will be ignored.
                             if ($sattr = $server->getSchemaAttribute($index)) {
                                 if (is_null($this->getAttribute($sattr->getName()))) {
                                     $this->addAttribute($sattr->getName(), $details, 'XML');
                                 }
                             }
                         }
                     }
                     masort($this->attributes, 'order');
                 }
                 break;
             default:
                 if (DEBUG_ENABLED) {
                     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');
                 $storelower = array('rdn');
                 $storearray = array('rdn');
                 # Items that must be stored lowercase
                 if (in_array($xml_key, $storelower)) {
                     if (is_array($xml_value)) {
                         foreach ($xml_value as $index => $value) {
                             $xml_value[$index] = strtolower($value);
                         }
                     } else {
                         $xml_value = strtolower($xml_value);
                     }
                 }
                 # Items that must be stored as arrays
                 if (in_array($xml_key, $storearray) && !is_array($xml_value)) {
                     $xml_value = array($xml_value);
                 }
                 # Items that should not be an array
                 if (!in_array($xml_key, $allowed_arrays) && is_array($xml_value)) {
                     debug_dump(array(__METHOD__, 'key' => $xml_key, 'value' => $xml_value));
                     error(sprintf(_('In the XML file (%s), [%s] is an array, it must be a string.'), $this->filename, $xml_key), 'error');
                 }
                 $this->{$xml_key} = $xml_value;
                 if ($xml_key == 'invalid' && $xml_value) {
                     $this->setInvalid(_('Disabled by XML configuration'), true);
                 }
         }
     }
     if (!count($objectclasses)) {
         $this->setInvalid(_('ObjectClasses in XML dont exist in LDAP server.'));
         return;
     } else {
         $attribute = $this->addAttribute('objectClass', array('values' => $objectclasses), 'XML');
         $attribute->justModified();
         $attribute->setRequired();
         $attribute->hide();
     }
     $this->rebuildTemplateAttrs();
     # Check we have some manditory items.
     foreach (array('rdn', 'structural_oclass', 'visible') as $key) {
         if (!isset($this->{$key}) || !is_array($this->{$key}) && !trim($this->{$key})) {
             $this->setInvalid(sprintf(_('Missing %s in the XML file.'), $key));
             break;
         }
     }
     # Mark our RDN attributes as RDN
     $counter = 1;
     foreach ($this->rdn as $key) {
         if (is_null($attribute = $this->getAttribute($key)) && in_array_ignore_case('extensibleobject', $this->getObjectClasses())) {
             $attribute = $this->addAttribute($key, array('values' => array()));
             $attribute->show();
         }
         if (!is_null($attribute)) {
             $attribute->setRDN($counter++);
         } elseif ($this->isType('creation')) {
             $this->setInvalid(sprintf(_('Missing RDN attribute %s in the XML file.'), $key));
         }
     }
 }