PHP User::RolesAsString Examples

PHP User::RolesAsString - 3 examples found. These are the top rated real world PHP examples of User::RolesAsString extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
    function edit()
    {
        $translator = new Translator();
        $user = new User();
        $data = $user->get(array('id' => array_shift($this->param)));
        foreach ($data as $key => $val) {
            $data[$key] = htmlspecialchars($val, ENT_QUOTES);
        }
        if ($data['subscribe'] == 't') {
            $subscribe = "checked";
        }
        if ($data['active'] == 't') {
            $active = "checked";
        }
        ${$data}['interface'] = 'selected';
        foreach ($user->roles as $key => $val) {
            if (($val & $data['role_id']) > 0) {
                $valname = 'role' . $val;
                ${$valname} = 'checked';
            }
        }
        echo <<<EOF
<div class="container">
<div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
    <form role="form" action="/admin_user/save/{$data[id]}" method="post">
\t<h2>{$translator->edit}</h2>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
                        <input type="text" name="first_name" id="first_name" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->First_Name}" tabindex="1" required value="{$data[first_name]}">
\t\t    </div>
\t\t</div>
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="last_name" id="last_name" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Last_Name}" tabindex="2" required value="{$data[last_name]}">
\t\t    </div>
\t\t</div>
\t    </div>
\t    <div class="form-group">
\t\t<input type="email" name="email" id="email" class="form-control input-lg" 
\t\tplaceholder="{$translator->Email_Address}" tabindex="3" required value="{$data[email]}">
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="password" id="password" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Password}" tabindex="4" required value="{$data[password]}">
\t\t    </div>
\t\t</div>
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="company" id="company" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Company}" tabindex="6" required value="{$data[company]}">
\t\t    </div>
\t\t</div>
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="position" id="position" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Position}" tabindex="7" required value="{$data[position]}">
\t\t    </div>
\t\t</div>
\t    </div>
    \t    <div class="form-group">
\t\t<input type="phone" name="phone" id="phone" class="form-control input-lg" 
\t\tplaceholder="{$translator->Phone}" tabindex="8" required value="{$data[phone]}">
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="country" id="country" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Country}" tabindex="9" required value="{$data[country]}">
\t\t    </div>
\t\t</div>
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="city" id="city" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->City}" tabindex="10" required value="{$data[city]}">
\t\t    </div>
\t\t</div>
\t    </div>

\t    <div class="form-group">
\t\t<label>{$translator->Interface_lan}: </label>
\t\t<select id="interface" name="interface" title="" data-size="3">
\t\t<option value="uk" {$uk}>Українська</option>
\t\t<option value="ru" {$ru}>Русский</option>
\t\t<option value="en" {$en}>English</option>
\t\t</select>
\t    </div>
\t    <div class="form-group">
\t\t<label>{$translator->Roles}: </label>
\t\t<div class="checkbox">

EOF;
        foreach ($user->roles as $key => $val) {
            $valname = 'role' . $val;
            echo "\t\t<label><input type=\"checkbox\" name=\"{$valname}\"  " . ${$valname} . " value=\"{$val}\"> " . User::RolesAsString($val) . "</label>" . NL;
        }
        echo <<<EOF
\t\t</div>
\t    </div>
\t    <div class="form-group">
\t\t    <span class="button-checkbox">
\t\t\t<input type="checkbox" name="subscribe" id="subscribe"  value="true" {$subscribe}>
\t\t\t{$translator->Subscribe}
\t\t    </span>
\t    </div>
\t    <div class="form-group">
\t\t    <span class="button-checkbox">
                        <input type="checkbox" name="active" id="active"  value="true" {$active}>
\t\t\t{$translator->Active}
\t\t    </span>
\t    </div>
\t    <div class="form-group">
\t    {$translator->Created}: {$data[created]}
\t    </div>
\t    <div class="form-group">
\t    {$translator->Last_in}: {$data[lastin]}
\t    </div>

\t    <div class="row">
\t\t<div class="col-xs-12 col-md-6"><input type="submit" value="{$translator->Save}" class="btn btn-primary" tabindex="13"></div>
\t    </div>
    </form>
</div>
</div> <!-- /container -->

EOF;
    }
Example #2
0
    function displayBody()
    {
        parent::displayBody();
        $translator = new Translator();
        $user = new User();
        $page = $_GET['page'];
        $offset = intval($page) * ITEMS_IN_PAGE;
        if (isset($_GET['search'])) {
            unset($_GET['search']);
            unset($_GET['page']);
            $search = $_GET;
        } else {
            $search = null;
        }
        $cnt = $user->getCount($search);
        if (sizeof($_GET) > 0) {
            foreach ($_GET as $key => $val) {
                $values[$key] = htmlspecialchars($val, ENT_QUOTES);
            }
            foreach ($user->roles as $key => $val) {
                if (($_GET['role_id'] & $val) > 0) {
                    $valname = 'role' . $val;
                    ${$valname} = 'checked';
                }
            }
            if ($_GET['role_id'] == 0) {
                $role0 = 'checked';
                $values['role_id'] = 0;
            }
        }
        if ($cnt > ITEMS_IN_PAGE) {
            $pagination = $this->addPaginator($cnt, $page);
        }
        echo <<<EOF
<h2  class="page-header">{$translator->Users_header} <span class="badge">{$cnt}</span></h2>
    <div class="row">
\t<div class="col-md-1">
\t<button class="btn btn-sm btn-default"  data-toggle="collapse" data-target="#filter">
\t    <span class="glyphicon glyphicon-filter"></span> {$translator->Filter}</button>
\t</div>
    </div>
    <div class="row">
        <div class="col-md-5 collapse" id="filter">
\t    <form role="form" class="form-horizontal" action="?" method="get">
\t\t<div class="form-group">
\t\t    <div class="form-group">
\t\t    <label for="name" class="control-label col-sm-3">{$translator->Name}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="name" name="name" value="{$values[name]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="email" class="control-label col-sm-3">{$translator->Email}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="email" name="email" value="{$values[email]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="company" class="control-label col-sm-3">{$translator->Company}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="company" name="company" value="{$values[company]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="phone" class="control-label col-sm-3">{$translator->Phone}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="phone" name="phone"  value="{$values[phone]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="country" class="control-label col-sm-3">{$translator->Country}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="country" name="country" value="{$values[country]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="city" class="control-label col-sm-3">{$translator->City}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="city" name="city" value="{$values[city]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="col-sm-offset-3">

EOF;
        foreach ($user->roles as $key => $val) {
            $valname = 'role' . $val;
            echo "\t\t    <input type=\"checkbox\" class=\"role_id\" id=\"{$valname}\" value=\"{$val}\" " . ${$valname} . ">\n\t\t    <label for=\"{$valname}\">" . User::RolesAsString($val) . "</label>" . NL;
        }
        echo <<<EOF
\t\t    <input class="sr-only" id="role_id" name="role_id" value="{$values[role_id]}">
\t\t    <input class="sr-only" name="search" value="1">
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <div class="col-sm-offset-3 col-md-10">
\t\t    <button type="submit" class="btn btn-sm btn-default">{$translator->Apply}</button>
\t\t    </div>
\t\t    </div>
\t\t</div>
\t    </form>
\t</div>
    </div>
{$pagination}
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>#</th>
                  <th>{$translator->Name}</th>
                  <th>{$translator->Roles}</th>
                  <th>{$translator->Email}</th>
                  <th>{$translator->Phone}</th>
                  <th>{$translator->Company}</th>
                  <th>{$translator->Place}</th>
                </tr>
              </thead>
              <tbody>

EOF;
        $enum = $user->enumerate($search, $offset, ITEMS_IN_PAGE, 'users.last_name,users.first_name');
        if (is_object($enum)) {
            $i = 1 + $offset;
            foreach ($enum as $key => $data) {
                if ($data['active'] == 'f') {
                    $active = " class=\"not-active\"";
                } else {
                    $active = "";
                }
                echo "                <tr>\n                  <td>{$i}</td>\n                  <td" . $active . ">{$data[name]}</td>\n                  <td>" . User::RolesAsString($data['role_id']) . "</td>\n                  <td>{$data[email]}</td>\n                  <td>{$data[phone]}</td>\n                  <td>{$data[company]} <small>{$data[position]}</small></td>\n                  <td>{$data[country]} <small>{$data[city]}</small></td>\n                  <td><a href=\"/admin_user/edit/{$data[id]}\" title=\"{$translator->edit}\"><span class=\"glyphicon glyphicon-user\"></span></a></td>\n                  <td><a href=\"/admin_user/delete/{$data[id]}\" title=\"{$translator->del}\" onClick=\"return confirm('{$translator->AreYouSure}');\"><span class=\"glyphicon glyphicon-trash\"></span></a></td>\n                </tr>\n";
                $i++;
            }
        }
        echo <<<EOF
\t    </table>
\t</div>

EOF;
    }
Example #3
0
    function edit()
    {
        $translator = new Translator();
        $user = new User();
        $data = $user->get(array('id' => $_SESSION['user_id']));
        foreach ($data as $key => $val) {
            $data[$key] = htmlspecialchars($val, ENT_QUOTES);
        }
        if ($data['subscribe']) {
            $subscribe = "checked";
        }
        ${$data}['interface'] = 'selected';
        $roles = User::RolesAsString($_SESSION['role_id']);
        echo <<<EOF
<div class="container">
<div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
    <form role="form" action="/profile/save/{$data[id]}" method="post">
\t<h2>{$translator->edit}</h2>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
                        <input type="text" name="first_name" id="first_name" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->First_Name}" tabindex="1" required value="{$data[first_name]}">
\t\t    </div>
\t\t</div>
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="last_name" id="last_name" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Last_Name}" tabindex="2" required value="{$data[last_name]}">
\t\t    </div>
\t\t</div>
\t    </div>
\t    <div class="form-group">
\t\t<input type="email" name="email" id="email" class="form-control input-lg"  disabled
\t\tplaceholder="{$translator->Email_Address}" tabindex="3" required value="{$data[email]}">
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="password" name="password" id="password" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Password}" tabindex="4" required value="{$data[password]}">
\t\t    </div>
\t\t</div>
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="company" id="company" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Company}" tabindex="6" required value="{$data[company]}">
\t\t    </div>
\t\t</div>
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="position" id="position" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Position}" tabindex="7" required value="{$data[position]}">
\t\t    </div>
\t\t</div>
\t    </div>
    \t    <div class="form-group">
\t\t<input type="phone" name="phone" id="phone" class="form-control input-lg" 
\t\tplaceholder="{$translator->Phone}" tabindex="8" required value="{$data[phone]}">
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="country" id="country" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->Country}" tabindex="9" required value="{$data[country]}">
\t\t    </div>
\t\t</div>
\t\t<div class="col-xs-12 col-sm-6 col-md-6">
\t\t    <div class="form-group">
\t\t\t<input type="text" name="city" id="city" class="form-control input-lg" 
\t\t\tplaceholder="{$translator->City}" tabindex="10" required value="{$data[city]}">
\t\t    </div>
\t\t</div>
\t    </div>

\t    <div class="form-group">
\t\t<label>{$translator->Interface_lan}: </label>
\t\t<select id="interface" name="interface" title="" data-size="3">
\t\t<option value="uk" {$uk}>Українська</option>
\t\t<option value="ru" {$ru}>Русский</option>
\t\t<option value="en" {$en}>English</option>
\t\t</select>
\t    </div>
\t    <div class="form-group">
\t\t<label>{$translator->Roles}: </label>{$roles}
\t    </div>
\t    <div class="form-group">
\t\t    <span class="button-checkbox">
\t\t\t{$translator->Subscribe}
                        <input type="checkbox" name="subscribe" id="subscribe"  value="true" {$subscribe}>
\t\t    </span>
\t    </div>
\t    <div class="form-group">
\t    {$translator->Created}: {$data[created]}
\t    </div>
\t    <div class="row">
\t\t<div class="col-xs-12 col-md-6 btn-group">
\t\t    <input type="submit" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {$translator->Save}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" class="btn btn-primary" tabindex="13">
\t\t    <a href="/profile/delete" onClick="return confirm('{$translator->AreYouSure}');" class="btn btn-danger">{$translator->Delete}</a>
\t\t</div>
\t    </div>
    </form>
</div>
</div> <!-- /container -->

EOF;
    }