Пример #1
0
function userPerm($id)
{
    $array = [];
    $bind = [":id" => $id];
    $q = DB::inst()->query("SELECT permission FROM user_perms WHERE userID = :id", $bind);
    foreach ($q as $r) {
        $array[] = $r;
    }
    $personPerm = Hooks::maybe_unserialize($r['permission']);
    /** 
     * Select the role(s) of the person who's 
     * personID = $id
     */
    $array1 = [];
    $bind1 = [":id" => $id];
    $q1 = DB::inst()->query("SELECT roleID from user_roles WHERE userID = :id", $bind1);
    foreach ($q1 as $r1) {
        $array1[] = $r1;
    }
    /**
     * Select all the permissions from the role(s)
     * that are connected to the selected person.
     */
    $array2 = [];
    $bind2 = [":id" => _h($r1['roleID'])];
    $q2 = DB::inst()->query("SELECT permission from role WHERE ID = :id", $bind2);
    foreach ($q2 as $r2) {
        $array2[] = $r2;
    }
    $perm = Hooks::maybe_unserialize($r2['permission']);
    $sql = DB::inst()->query("SELECT * FROM permission");
    foreach ($sql as $r) {
        echo '
                <tr>
                    <td>' . $r['permName'] . '</td>
                    <td class="text-center">
                <input type="checkbox" name="permission[]" value="' . $r['permKey'] . '" ';
        if (in_array($r['permKey'], $perm)) {
            echo 'checked="checked" disabled="disabled"';
        } elseif ($personPerm != '' && in_array($r['permKey'], $personPerm)) {
            echo 'checked="checked"';
        }
        echo '/>
                    </td>
                </tr>';
    }
}
Пример #2
0
 /**
  * Reads a cache file if it exists and prints it out 
  * to the screen.
  * 
  * @access public
  * @since 4.3
  * @param string (required) $filename Full path to the requested cache file
  * @return mixed
  */
 public function getCache($fileName)
 {
     $this->_cachefile = $this->_cachepath . $fileName . $this->_extension;
     if (file_exists($this->_cachefile)) {
         $cache = fopen($this->_cachefile, 'rb');
         $output = fread($cache, filesize($this->_cachefile));
         fclose($cache);
         return Hooks::maybe_unserialize($output);
     } else {
         return $this->addLog('Could not find filename: ' . $fileName);
     }
 }