common::getAdminstratorName PHP Method

getAdminstratorName() public method

Returns the name associated to the specified administrator login.
public getAdminstratorName ( $login )
    function getAdminstratorName($login)
    {
        require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "settings.class.php";
        $settings = new settings();
        if ($settings::db_driver == "xml") {
            // XML
            $administrators = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "administrators.xml");
            foreach ($administrators as $administrator) {
                if ($administrator->login = $login) {
                    return $administrator->name;
                }
            }
        } else {
            // PDO
            $dbh = $this->pdoOpen();
            $sql = "SELECT * FROM " . $settings::db_prefix . "administrators WHERE login = :login";
            $sth = $dbh->prepare($sql);
            $sth->bindParam(':login', $login, PDO::PARAM_STR, 25);
            $sth->execute();
            $row = $sth->fetch();
            $sth = NULL;
            $dbh = NULL;
            return $row['name'];
        }
    }

Usage Example

Exemplo n.º 1
0
////////////////
// BEGIN HTML
require_once '../includes/header.inc.php';
?>
            <h1>Blog Management</h1>
            <hr />
            <h2>Delete Blog Post</h2>
            <h3><?php 
echo $post['title'];
?>
</h3>
            <p>Posted <strong><?php 
echo date_format(date_create($post['date']), "F jS, Y");
?>
</strong> by <strong><?php 
echo $common->getAdminstratorName($post['author']);
?>
</strong>.</p>
            <div class="alert alert-danger" role="alert">
                <p>
                    <strong>Confirm Delete</strong><br />
                    Are you sure you want to delete this blog post?
                </p>
            </div>
            <form id="delete-blog-post" method="post" action="delete.php?title=<?php 
echo urlencode($post['title']);
?>
">
                <input type="submit" class="btn btn-default" value="Delete Post">
                <a href="/admin/blog/" class="btn btn-info" role="button">Cancel</a>
            </form>
All Usage Examples Of common::getAdminstratorName