本文整理汇总了PHP中can函数的典型用法代码示例。如果您正苦于以下问题:PHP can函数的具体用法?PHP can怎么用?PHP can使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteMessage
public function deleteMessage($id)
{
can('message.delete');
flash('message deleted successfully', 'success');
$this->contact_repo->delete($id);
return redirect('/backend/message');
}
示例2: deny_unless_can
function deny_unless_can($action, $module, $record = null)
{
if (can($action, $module, $record)) {
return;
}
throw new SecurityException(__('error.cannot_do_action_on_that', array($action, $record ? $record : __("modules.{$module}.frontname"))));
}
示例3: deleteVolunteers
public function deleteVolunteers($id)
{
can('event.volunteer');
$this->volunteer_repo->delete(request()->record_id);
flash('volunteer deleted successfully', 'success');
return redirect("/event/volunteers/{$id}");
}
示例4: deleteDelete
public function deleteDelete($id)
{
can('blog.delete');
$this->blog_repo->delete($id);
flash('blog deleted successfully', 'success');
return redirect('blog');
}
示例5: deleteDelete
public function deleteDelete($id)
{
can('user.manage');
$user = $this->user_repo->delete($id);
flash('user deleted successfully', 'success');
return redirect('/user');
}
示例6: tree
public function tree($modules = null)
{
if (is_null($modules)) {
$modules = $this->getOption('modulesToList');
}
$officeConfig = PEAR::getStaticProperty('m_office', 'options');
$moduleconf = $officeConfig['modules'];
$diff = array_diff(array_keys($_GET), array('module'));
$o = array();
foreach ($modules as $id => $module) {
if (is_array($module)) {
if (!can('tab', $id)) {
continue;
}
$res = array('name' => $id, 'icon' => $moduleconf[$id]['icon']);
$res['submodules'] = $this->tree($module);
if (in_array($_REQUEST['module'], $module)) {
$res['expanded'] = true;
}
} else {
if (!can('tab', $module)) {
continue;
}
$res = array('name' => $module, 'icon' => $moduleconf[$module]['icon'], 'url' => M_Office::URL($module, array(), $diff));
if ($_REQUEST['module'] == $module || $_REQUEST['module'] == $module . 'helper') {
$res['active'] = true;
}
}
$o[] = $res;
}
return $o;
}
示例7: doExecManager
public function doExecManager()
{
$focus = $this->getFocus();
$this->assign('focus', $focus);
$this->assign('module', $_REQUEST['module']);
if (!can('update', $_REQUEST['module'], $focus)) {
$this->setTemplate('taghelper/viewer');
}
}
示例8: will
function will($permission, $object = NULL, $exit_url = '/', $message = 'Sorry, you do not have permission to access this page.')
{
if (!can($permission, $object)) {
if (current_user()) {
redirect($exit_url, $message);
} else {
redirect_to_login($_SERVER['REQUEST_URI'], "Please login to access this page.");
}
}
}
示例9: postUser
public function postUser($user_id)
{
can('user.manage');
$user = UserModel::find($user_id);
$role = RoleModel::find(request()->role_id);
if ($user->hasRole($role)) {
$user->revokeRole($role);
} else {
$user->assignRole($role);
}
return redirect('role/user/' . $user_id);
}
示例10: can
$startDate = $_GET['start'];
$endDate = $_GET['end'];
$terminated = "";
if (isset($_GET['terminated'])) {
$terminated = $_GET['terminated'];
}
if (isset($_GET['smID'])) {
$smID = $_GET['smID'];
//Used if Silent Monitor Log wants to load a specific silent monitor instance.
} else {
$smID = null;
//Set $smID to null per proper programming practices.
}
$admin = can("access", "033e3c00-4989-4895-a4d5-a059984f7997");
//employeePerformance resource
$adminSilentMonitor = can("read", "86755385-4a09-45ce-81b9-049b660210df");
//performanceSummary resource
if ($name == "") {
try {
$nameQuery = $db->prepare("SELECT firstName, lastName, netID FROM employee WHERE area=:area AND active='1' ORDER BY lastName");
$nameQuery->execute(array(':area' => $area));
} catch (PDOException $e) {
exit("error in query");
}
while ($curEmp = $nameQuery->fetch(PDO::FETCH_ASSOC)) {
echo "<h2>" . nameByNetId($curEmp['netID']) . "</h2>";
$name = $curEmp['netID'];
if ($_GET['type'] == 'terminated') {
echo getTerminatedLog($name);
}
if ($_GET['type'] == "absence") {
示例11: while
}
echo "<table class='imagetable'style='margin:auto;'><tr><th>Type Name</th><th>Color</th><th>Must Approve?</th></tr><tr>";
while ($right = $tagQuery->fetch(PDO::FETCH_ASSOC)) {
echo "<td><input maxlength='30' type='text' name='" . $right['typeId'] . "' style='width:200px' value='" . $right['typeName'] . "' /></td>";
echo "<td bgcolor='" . $right['color'] . "'><input maxlength='20' type='text' name='" . $right['typeId'] . "color' style='width:100px' value='" . $right['color'] . "' /></td>";
echo "<td style='text-align: center; vertical-align: middle;'><input type='checkbox' name='{$right['typeId']}mustApprove' " . ($right['mustApprove'] == '1' ? 'checked="checked"' : '') . " style='vertical-align: middle;' /></td>";
echo "</td></tr>";
}
echo "</table>";
}
function msgTypeSelect($area)
{
global $db;
try {
$tagQuery = $db->prepare("SELECT * FROM tag WHERE area = :area ORDER BY typeName ASC");
$tagQuery->execute(array(':area' => $area));
} catch (PDOException $e) {
exit("error in query");
}
while ($type = $tagQuery->fetch(PDO::FETCH_ASSOC)) {
echo "<option value='" . $type['typeId'] . "'/>" . $type['typeName'] . "</option>";
}
}
if (can("update", "6db1ee4f-4d80-424d-a062-97dc4cc22936")) {
pullMsgTypes($area);
echo "<br/>";
echo "<input type='button' class='button' name='deleteHour' value='Remove:' onclick='deleteType()' />";
echo "<select name='msgTypes' id='msgTypes'>";
msgTypeSelect($area);
echo "</select>";
}
示例12: bootNavigation
/**
* Create the dynamic navigation bars that come with this package
*
* @param string $base
* @return void
*/
protected function bootNavigation($base)
{
$navigation = $this->app['platform.navigation'];
$navigation->add(['title' => 'Pages', 'icon' => 'fa-file', 'url' => platform_route('pages.index'), 'shown' => can('update', 'Page'), 'active' => 'pages']);
$navigation->add(['title' => 'Menus', 'icon' => 'fa-link', 'url' => platform_route('menus.index'), 'shown' => can('update', 'Menu'), 'active' => 'menus']);
}
示例13: catch
<?php
//index for silent monitor
require '../includes/includeme.php';
include 'printSilentMonitor.php';
if (can("use", "8c2901f9-27f6-45a1-b0e9-bbe53a6af189")) {
$loadID = '';
$curEmployee = '';
$curDate = '';
$overallComments = '';
if (isset($_GET['id'])) {
$loadID = $_GET['id'];
try {
$silentMonitorQuery = $db->prepare("SELECT * FROM silentMonitor WHERE `index` = :id");
$silentMonitorQuery->execute(array(':id' => $loadID));
} catch (PDOException $e) {
exit("error in query");
}
$cur = $silentMonitorQuery->fetch(PDO::FETCH_ASSOC);
$curEmployee = $cur['netID'];
$overallComments = $cur['overallComment'];
}
?>
<script language="JavaScript" src="/includes/libs/tcal.js"></script>
<link rel="stylesheet" type="text/css" href="/includes/libs/tcal.css" />
<style type="text/css">
table,td,th{
white-space: pre-line;
vertical-align: middle;
}
.invisibleTable{
示例14: date
if ($numberOfDaysToReturn < 6) {
$numberOfDaysToReturn = 6;
}
$endDate = date("Y-m-d", strtotime($weekStart . "+{$numberOfDaysToReturn} days"));
$date = $weekStart;
$shiftArray = array();
if (!$areaInfo['postSchedulesByDefault']) {
//Check if the schedule has been posted.
try {
$postingQuery = $db->prepare("SELECT * FROM schedulePosting WHERE area = :area AND weekStart = :start");
$postingQuery->execute(array(':area' => $area, ':start' => $weekStart));
} catch (PDOException $e) {
exit("error in query");
}
if ($checkArray = $postingQuery->fetch(PDO::FETCH_ASSOC)) {
if ($checkArray['post'] == 0 && !can("update", "1689443f-8c4c-4874-8ee3-a3137db32d85")) {
echo json_encode($shiftArray);
return;
}
} else {
echo json_encode($shiftArray);
return;
}
}
while ($date <= $endDate) {
try {
$scheduleQuery = $db->prepare("SELECT * FROM `scheduleWeekly` WHERE employee = :employee AND startDate = :day AND `deleted`=0");
$scheduleQuery->execute(array(':employee' => $employee, ':day' => $date));
} catch (PDOException $e) {
exit("error in query");
}
示例15: can
<?php
//printList.php
require '../includes/includeMeBlank.php';
require 'routineTaskTable.php';
//echo "IM PRINTING";
$date = $_GET['date'];
//This file checks permissions and then calls the function to print out the routine task list
$permission = can("update", "f9244d83-d0fe-4205-a4eb-f0a1c9de8d88");
//routineTasks resource// this is where permissions will be checked
tableHeader($permission);
getMessages($netID, $permission, $date, $area);