本文整理汇总了PHP中AuthUser::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthUser::hasPermission方法的具体用法?PHP AuthUser::hasPermission怎么用?PHP AuthUser::hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthUser
的用法示例。
在下文中一共展示了AuthUser::hasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deactivate_plugin
function deactivate_plugin($plugin)
{
if (!AuthUser::hasPermission('administrator')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
Plugin::deactivate($plugin);
}
示例2: _checkPermission
public static function _checkPermission()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::hasPermission('administrator,developer,editor')) {
// Flash::set('error', __('You do not have permission to access the requested page!'));
// redirect(get_url());
}
}
}
示例3: __construct
function __construct()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
}
if (!AuthUser::hasPermission('admin_view')) {
redirect(URL_PUBLIC);
}
$this->setLayout('backend');
$this->assignToLayout('sidebar', new View('../../plugins/funky_cache/views/sidebar'));
}
示例4: __construct
function __construct()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::hasPermission('administrator') && !AuthUser::hasPermission('developer')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
}
$this->setLayout('backend');
$this->assignToLayout('sidebar', new View('layout/sidebar'));
}
示例5: _checkPermission
/**
* Used to check generic permissions for entire the controller.
*/
private static final function _checkPermission()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::hasPermission('admin_edit')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
if (Setting::get('default_tab') === 'setting') {
redirect(get_url('page'));
} else {
redirect(get_url());
}
}
}
}
示例6: __construct
function __construct()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::hasPermission('layout_view')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
if (Setting::get('default_tab') === 'layout') {
redirect(get_url('page'));
} else {
redirect(get_url());
}
}
}
$this->setLayout('backend');
$this->assignToLayout('sidebar', new View('layout/sidebar'));
}
示例7: image_resize_try_resizing
/**
* Execute this function on page_not_found.
* If the request is for an image file,
* resize the image.
*/
function image_resize_try_resizing()
{
// Require that visitor be logged in and has
// permission to create files
if (!AuthUser::isLoggedIn()) {
AuthUser::load();
}
if (!AuthUser::hasPermission('administrator,developer,editor')) {
return false;
}
// Check that gd library is available
if (!ImageResize::gd_available()) {
return false;
}
if (preg_match('#\\.(jpe?g|gif|png|wbmp)$#i', CURRENT_URI)) {
// If requested file appears to be an accepted format, create the new image
if (image_resize_scale(CURRENT_URI) && !DEBUG) {
// If Frog isn't debugging, it writes to a file; redirect to it
header('Location: ' . URL_PUBLIC . "/" . CURRENT_URI);
// Exit here to prevent a page not found message
exit;
}
}
}
示例8: get_url
echo get_url('snippet/edit/' . $snippet->id);
?>
"><?php
echo $snippet->name;
?>
</a>
<img class="handle" src="<?php
echo PATH_PUBLIC;
?>
wolf/admin/images/drag.gif" alt="<?php
echo __('Drag and Drop');
?>
" align="middle" />
<div class="remove">
<?php
if (AuthUser::hasPermission('snippet_delete')) {
?>
<a class="remove" href="<?php
echo get_url('snippet/delete/' . $snippet->id);
?>
" onclick="return confirm('<?php
echo __('Are you sure you wish to delete?');
?>
<?php
echo $snippet->name;
?>
?');"><img src="<?php
echo PATH_PUBLIC;
?>
wolf/admin/images/icon-remove.gif" alt="<?php
示例9: __
echo __('on');
?>
<?php
echo date('D, j M Y', strtotime($snippet->updated_on));
?>
</small>
</p>
<?php
}
?>
</div>
</div>
</div>
<p class="buttons">
<?php
if ($action == 'edit' && AuthUser::hasPermission('snippet_edit') || $action == 'add' && AuthUser::hasPermission('snippet_add')) {
?>
<input class="button" name="commit" type="submit" accesskey="s" value="<?php
echo __('Save');
?>
" />
<input class="button" name="continue" type="submit" accesskey="e" value="<?php
echo __('Save and Continue Editing');
?>
" />
<?php
echo __('or');
?>
<?php
} else {
示例10: __checkPermission
private static function __checkPermission($permission='facts_view') {
AuthUser::load();
if ( ! AuthUser::isLoggedIn()) {
redirect(get_url('login'));
}
if ( ! AuthUser::hasPermission($permission) ) {
Flash::set('error', __('You do not have permission to access the requested page!'));
if (! AuthUser::hasPermission('facts_view') ) redirect(get_url());
else redirect(get_url('plugin/facts'));
}
}//*/
示例11: delete
/**
* Deletes a Snippet.
*
* @param string $id Snippet id
*/
public function delete($id)
{
if (!AuthUser::hasPermission('snippet_delete')) {
Flash::set('error', __('You do not have permission to delete snippets!'));
redirect(get_url('snippet'));
}
// find the user to delete
if ($snippet = Record::findByIdFrom('Snippet', $id)) {
if ($snippet->delete()) {
Flash::set('success', __('Snippet :name has been deleted!', array(':name' => $snippet->name)));
Observer::notify('snippet_after_delete', $snippet);
} else {
Flash::set('error', __('Snippet :name has not been deleted!', array(':name' => $snippet->name)));
}
} else {
Flash::set('error', __('Snippet not found!'));
}
redirect(get_url('snippet'));
}
示例12: get_url
<div class="modify">
<a href="<?php
echo get_url('page/add', $child->id);
?>
"><img src="<?php
echo URI_PUBLIC . CORE_FOLDER;
?>
/admin/images/plus.png" align="middle" title="<?php
echo __('Add child');
?>
" alt="<?php
echo __('Add child');
?>
" /></a>
<?php
if (!$child->is_protected || AuthUser::hasPermission('administrator') || AuthUser::hasPermission('developer')) {
?>
<a class="remove" href="<?php
echo get_url('page/delete/' . $child->id);
?>
" onclick="return confirm('<?php
echo __('Are you sure you wish to delete');
?>
<?php
echo $child->title;
?>
<?php
echo __('and its underlying pages');
?>
?');"><img src="<?php
echo URI_PUBLIC . CORE_FOLDER;
示例13: delete
public function delete($id)
{
if (!AuthUser::hasPermission('user_delete')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
// Sanity checks
use_helper('Validate');
if (!Validate::numeric($id)) {
Flash::set('error', __('Invalid input found!'));
redirect(get_url());
}
// CSRF checks
if (isset($_GET['csrf_token'])) {
$csrf_token = $_GET['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'user/delete/' . $id)) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('user'));
}
} else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('user'));
}
// security (dont delete the first admin)
if ($id > 1) {
// find the user to delete
if ($user = Record::findByIdFrom('User', $id)) {
if ($user->delete()) {
Flash::set('success', __('User <strong>:name</strong> has been deleted!', array(':name' => $user->name)));
Observer::notify('user_after_delete', $user->name);
} else {
Flash::set('error', __('User <strong>:name</strong> has not been deleted!', array(':name' => $user->name)));
}
} else {
Flash::set('error', __('User not found!'));
}
} else {
Flash::set('error', __('Action disabled!'));
}
redirect(get_url('user'));
}
示例14: __
if ($action == 'edit') {
echo __('Leave password blank for it to remain unchanged.');
}
?>
</td>
</tr>
<tr>
<td class="label"><label for="user_confirm"><?php
echo __('Confirm Password');
?>
</label></td>
<td class="field"><input class="textbox" id="user_confirm" maxlength="40" name="user[confirm]" size="40" type="password" value="" /></td>
</tr>
<?php
if (AuthUser::hasPermission('administrator')) {
?>
<tr>
<td class="label"><?php
echo __('Roles');
?>
</td>
<td class="field">
<?php
$user_permissions = $user instanceof User ? $user->getPermissions() : array('editor');
foreach ($permissions as $perm) {
?>
<span class="checkbox"><input<?php
if (in_array($perm->name, $user_permissions)) {
echo ' checked="checked"';
示例15: __
</table>
<?php
Observer::notify('user_edit_view_after_details', $user);
?>
<p class="buttons">
<input class="button" name="commit" type="submit" accesskey="s" value="<?php
echo __('Save');
?>
" />
<?php
echo __('or');
?>
<a href="<?php
echo AuthUser::hasPermission('administrator') ? get_url('user') : get_url();
?>
"><?php
echo __('Cancel');
?>
</a>
</p>
</form>
<script type="text/javascript">
// <![CDATA[
function setConfirmUnload(on, msg) {
window.onbeforeunload = (on) ? unloadMessage : null;
return true;
}