public function deleteMessage($id) { can('message.delete'); flash('message deleted successfully', 'success'); $this->contact_repo->delete($id); return redirect('/backend/message'); }
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")))); }
public function deleteVolunteers($id) { can('event.volunteer'); $this->volunteer_repo->delete(request()->record_id); flash('volunteer deleted successfully', 'success'); return redirect("/event/volunteers/{$id}"); }
public function deleteDelete($id) { can('blog.delete'); $this->blog_repo->delete($id); flash('blog deleted successfully', 'success'); return redirect('blog'); }
public function deleteDelete($id) { can('user.manage'); $user = $this->user_repo->delete($id); flash('user deleted successfully', 'success'); return redirect('/user'); }
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; }
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'); } }
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."); } } }
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); }
$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") {
} 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>"; }
/** * 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']); }
<?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{
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"); }
<?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);
<?php //editShiftTypes.php //Problems with pulling escaped characters from the Database see the function pullShiftTypes() to fix it. require '../includes/includeme.php'; $permission = can("update", "1689443f-8c4c-4874-8ee3-a3137db32d85"); //schedule resource if (!$permission) { echo "<h2>You do not have permission to view this page.</h2>"; require '../includes/includeAtEnd.php'; return; } try { $hourTypesQuery = $db->prepare("SELECT * FROM scheduleHourTypes WHERE area = :area AND `deleted` = 0 ORDER BY value ASC"); $hourTypesQuery->execute(array(':area' => $area)); } catch (PDOException $e) { exit("error in query"); } if (isset($_POST['submit'])) { while ($hourType = $hourTypesQuery->fetch(PDO::FETCH_ASSOC)) { if (isset($_POST[$hourType['ID'] . 'trade'])) { $trade = 1; } else { $trade = 0; } if (isset($_POST[$hourType['ID'] . 'view'])) { $view = 1; } else { $view = 0; } if (isset($_POST[$hourType['ID'] . 'ss'])) {
<?php //teamLeaders.php //application for displaying and editing teams and their leaders require '../includes/includeme.php'; require 'teamingFunctions.php'; if (!can("update", "28e60394-f719-4225-85ad-fa542ab6a8df")) { echo "<h2>You are not authorized to view this page. Contact your supervisor if you believe you reached this in error.</h2>"; require '../includes/includeAtEnd.php'; return; } try { $teamsQuery = $db->prepare("SELECT * FROM teams WHERE area = :area"); $teamsQuery->execute(array(':area' => $area)); } catch (PDOException $e) { exit("error in query"); } if (isset($_POST['submit'])) { while ($team = $teamsQuery->fetch(PDO::FETCH_ASSOC)) { try { $updateQuery = $db->prepare("UPDATE teams SET area=:area, name=:name, lead=:lead WHERE ID=:id"); $updateQuery->execute(array(':area' => $area, ':name' => $_POST[$team['ID'] . 'name'], ':lead' => $_POST[$team['ID'] . 'lead'], ':id' => $team['ID'])); } catch (PDOException $e) { exit("error in query"); } } } ?> <script type='text/javascript'> window.onload = function() {
<?php require "../includes/includeme.php"; /************************************************************************************** Pull user's posted information ***************************************************************************************/ if (can("update", "f49362ef-983b-4615-ac64-727b769a713f")) { $userorg = ''; $userar = ''; $userdept = ''; $username = ''; $userphone = ''; $useraddress = ''; $userposition = ''; $usermanagerFlag = 0; $userpriority = ''; $userid = ''; $new_priority = ''; $current_org = ''; $current_area = ''; $current_dept = ''; $add_contact = ''; $edit_contact = ''; $remove_contact = ''; if (isset($_POST['org'])) { $userorg = $_POST['org']; } if (isset($_POST['area'])) { $userar = $_POST['area']; } if (isset($_POST['dept'])) {
<?php //insertReason.php used to insert a new reason into the current area. require '../../includes/includeMeBlank.php'; if (can("access", "0551dfe7-cf9c-4747-829c-3299fbd455af")) { $employeeNetId = $_GET['employee']; //employee's net Id $date = $_GET['date']; //The date of the raise $raise = $_GET['raise']; //The raise amount $comments = $_GET['reason']; //The reason for the raise if ($raise == '') { //TODO Add check for non numeric values echo "Invalid Raise amount"; return; } //This is the logic for entering the raise into the database. *************** //A "Manual Edit" raise is just for updating our records, it never enters the pending state. if ($comments == "Manual Edit") { try { $wageQuery = $db->prepare("SELECT wage FROM employeeWages WHERE netID=:netId"); $wageQuery->execute(array(':netId' => $employeeNetId)); } catch (PDOException $e) { exit("error in query"); } $result = $wageQuery->fetch(PDO::FETCH_ASSOC); $newWage = $result['wage'] + $raise; if ($date == "") { //This accounts for the lack of a date given
<?php //silentMonitorLog.php require '../includes/includeme.php'; // Get current user's available areas $employeeAreas = getAreas(); $tempArea = $area; // Set the current area variable to be temporarily interpreted as the area the silent monitor was originally done in // This is undone at the bottom of this page if (isset($_GET['arg']) && in_array($_GET['arg'], $employeeAreas)) { $area = $_GET['arg']; } // Ensure user has permissions for the app in the current area. $admin = can("read", "86755385-4a09-45ce-81b9-049b660210df"); //performanceSummary resource if (isset($_GET['smID'])) { $smID = $_GET['smID']; try { $silentMonitorQuery = $db->prepare("SELECT * FROM `silentMonitor` WHERE `index` = :id"); $silentMonitorQuery->execute(array(':id' => $smID)); } catch (PDOException $e) { exit("error in query"); } $silentMonitor = $silentMonitorQuery->fetch(PDO::FETCH_ASSOC); $employee = $silentMonitor['netID']; $date = $silentMonitor['submitDate']; if ($admin || $netID == $employee) { echo '<script type="text/javascript"> function printLogFromEmail() { var page = "printLog.php?employee=' . $employee . '&start=' . $date . '&end=' . $date . '&type=silentMonitor&smID=' . $smID . '";
/*supervisorDashboard resource*/ ?> <div id="spinner" class="spinner" style="display:none;"> <p>Please wait while your report is sent.</p> <img id="img-spinner" src="supReportLoading.gif" alt="Loading"/> <?php } ?> </div> <div class="clearMe"></div> </div> <?php if (can("access", "2b7d6a3b-c9e9-4283-8275-3c632dfc20d9")) { ?> <div id="unscheduledRFC" class="unscheduledRFC" style="display:none;"> <table> <tr><th> Ticket/ RFC #: </th><td> <input type="text" id='ticketNumRFC' name="ticketNumRFC" maxlength=200 size=40 value=""/> </td></tr><tr><th> Engineer Name: </th><td> <input type="text" id='nameRFC' name="nameRFC" maxlength=200 size=40 value=""/> </td></tr><tr><th> Start Time - Date: </th><td> <input type="text" id='startTimeRFC' name="startTimeRFC" maxlength=200 size=15 value="<?php
<?php //absenceLog.php require '../includes/includeme.php'; $readPermission = can("read", "86755385-4a09-45ce-81b9-049b660210df"); //performanceSummary resource function printEmployees() { global $netID; global $readPermission; if ($readPermission) { echo "<select id='employees' name='employees' onchange>"; employeeFillCurrentArea(); echo "</select>"; } else { echo nameByNetId($netID); } } ?> <script type='text/javascript'> window.onload = function(){ $("#startDate").datepicker({dateFormat: "yy-mm-dd"}); $("#endDate").datepicker({dateFormat: "yy-mm-dd"}); } function printLog(){ <?php if ($readPermission) { echo 'var employee = document.getElementById("employees").value;'; } else { echo 'var employee = "' . $netID . '";';
/** * returns the array of single actions for $do (and optionally module) */ public static function getActionsFor($do, $moduleName = null) { if (is_null($moduleName)) { $moduleName = $do->tableName(); } if (!can('actions_whitelist', $moduleName) && !can('all_actions', $moduleName)) { return array(); } $singleMethods = method_exists($do, 'getSingleMethods') ? $do->getSingleMethods() : array(); if (can('all_actions', $moduleName)) { return $singleMethods; } $whitelist = User::getInstance('office')->getDBDO()->admintype()->get_array($moduleName, 'actions_whitelist'); foreach ($singleMethods as $meth => $info) { if (!in_array($meth, $whitelist)) { unset($singleMethods[$meth]); } } var_dump($singleMethods); return $singleMethods; }
<?php if ($e->sdate > $current_date || $e->sdate == $current_date && $e->stime > $current_time) { ?> <span class="submit" onclick="getUserToInvite(<?php echo $e->event_id; ?> ,'<?php echo base_url(); ?> ')">Invite</span> <?php } ?> <span class="submit" style="">Share</span> <?php if (can($e, $this->session->userdata('user_id'))) { ?> <span class="submit" id="edit-event" style="" onclick="edit-event(<?php echo $e->event_id; ?> ,'<?php echo base_url(); ?> ')">Edit</span> <?php } ?> </div> </div> </center>
} } function pullPermissions($area, $selected) { global $db; try { $hourTypesQuery = $db->prepare("SELECT * FROM scheduleHourTypes WHERE `ID`=:selected AND `deleted` = 0"); $hourTypesQuery->execute(array(':selected' => $selected)); } catch (PDOException $e) { exit("error in query"); } $cur = $hourTypesQuery->fetch(PDO::FETCH_ASSOC); $permissions = pullAllPermissionInfoCurrentArea(); echo "<option value=''></option>"; foreach ($permissions as $singlePerm) { if ($cur['permission'] == $singlePerm['index']) { echo "<option value='" . $singlePerm['index'] . "' selected>" . $singlePerm['longName'] . "</option>"; } else { echo "<option value='" . $singlePerm['index'] . "'>" . $singlePerm['longName'] . "</option>"; } } } if (can("update", "1689443f-8c4c-4874-8ee3-a3137db32d85")) { echo "<br/>"; pullShiftTypes($area); echo "<br/>"; echo "<input type='button' class='button' name='deleteHour' value='Remove:' onclick='deleteShift()' />"; echo "<select name='shiftTypes' id='shiftTypes'>"; shiftTypeSelect($area); echo "</select>"; }
/** * This function sends out a notification of the given type * with the specified message. * * @param $type string A notification type guid * @param $message string The message to send * @param $persons (object)array The netId, method, and email address of a specific person(s) to receive the message * usually the person to whom the message is referring (i.e. performance logs) */ function notify($type, $message, $persons = null) { global $areaGuid, $db; // Find permission needed to receive notification try { $stmt = $db->prepare("SELECT * FROM notificationTypes WHERE guid=:guid"); $stmt->execute(array(':guid' => $type)); } catch (PDOException $e) { exit("error in query"); } $notType = $stmt->fetch(); // Get notifications url $url = getEnv('NOTIFICATIONSURL'); // Get recipients try { $stmt = $db->prepare("SELECT notificationPreferences.*, employee.email FROM notificationPreferences JOIN employee\n\t\t\tON notificationPreferences.netId=employee.netID WHERE type=:type AND notificationPreferences.area=:area"); $stmt->execute(array(':type' => $type, ':area' => $areaGuid)); } catch (PDOException $e) { exit("error in query"); } // Make sure each recipient can recieve the notification // If not, remove them from the list and delete that preference $receivers = array(); if ($persons !== null) { $receivers = $persons; // If no permission is required, send to all } else { if ($notType->resource == null) { while ($recipient = $stmt->fetch()) { $receivers[] = (object) array("netId" => $recipient->netId, "method" => $recipient->method, "email" => $recipient->email); } // If user must be an admin to receive this notification } else { if ($notType->resource == "admin") { while ($recipient = $stmt->fetch()) { // Add to send list only if the user is an admin or can be superuser if (isAdmin($recipient->netId, $areaGuid) || canBeSuperuser($recipient->netId)) { $receivers[] = (object) array("netId" => $recipient->netId, "method" => $recipient->method, "email" => $recipient->email); } else { // User is not authorized to receive permission, remove entry from table try { $stmt2 = $db->prepare("DELETE FROM notificationPreferences WHERE netId=:netId AND type=:type AND area=:area"); $stmt2->execute(array(':netId' => $recipient->netId, ':type' => $type, ':area' => $areaGuid)); } catch (PDOException $e) { exit("error in query"); } } } // Normal permission check } else { while ($recipient = $stmt->fetch()) { // Add to send list only if the user is an admin or can be superuser if (can($notType->verb, $notType->resource, $recipient->netId) || canBeSuperuser($recipient->netId)) { $receivers[] = (object) array("netId" => $recipient->netId, "method" => $recipient->method, "email" => $recipient->email); } else { // User is not authorized to receive permission, remove entry from table try { $stmt2 = $db->prepare("DELETE FROM notificationPreferences WHERE netId=:netId AND type=:type AND area=:area"); $stmt2->execute(array(':netId' => $recipient->netId, ':type' => $type, ':area' => $areaGuid)); } catch (PDOException $e) { exit("error in query"); } } } } } } $guid = newGuid(); try { $stmt3 = $db->prepare("INSERT INTO notifications (message, type, area, guid) VALUES (:message, :type, :area, :guid)"); $stmt3->execute(array(":message" => $message, ":type" => $type, ":area" => $areaGuid, ":guid" => $guid)); } catch (PDOException $e) { exit("error in query"); } if (count($receivers) > 0) { sendAuthenticatedRequest("POST", "https://" . $url . "/notify", array("message" => $message, "receivers" => json_encode($receivers))); foreach ($receivers as $receiver) { if ($receiver->method == "onsite" || $receiver->method == "all") { try { $stmt4 = $db->prepare("INSERT INTO userNotifications (netId, notificationGuid) VALUES (:netId, :guid)"); $stmt4->execute(array(":netId" => $receiver->netId, ":guid" => $guid)); } catch (PDOException $e) { } // catch exceptions if they arise, but try to add as many as possible } } } }
<?php //index.php This is the supervisor report Log. It pulls in the info from submitted reports require '../includes/includeme.php'; //************************* //add permission check here if (!can("access", "c81d511e-6af0-4045-a53f-8e3c55ea3545")) { echo "<h2>You are not authorized to view this page. Contact your supervisor if you believe this is in error.</h2>"; require '../includes/includeAtEnd.php'; return; } //*********************** function printEmployees() { echo "<select id='employees' name='employees' onchange>"; employeeFillCurrentArea(); echo "</select>"; } ?> <script type='text/javascript' > window.onload = function(){ $( "input:text.datepicker" ).datepicker({dateFormat:"yy-mm-dd"}); }; function printLog(){ var employee = document.getElementById("employees").value; var start = document.getElementById("startDate").value; var end = document.getElementById("endDate").value; var outage = document.getElementById("outageSearch").value; var problem = document.getElementById("problemSearch").value; var misc = document.getElementById("miscSearch").value; var page = 'printLog.php?employee='+employee+'&start='+start+'&end='+end+'&outage='+outage+'&problem='+problem+'&misc='+misc;
public function getResult($survey_id, $user_id = 0) { can('event.survey'); if ($user_id) { global $survey_user_id; $survey_user_id = $user_id; $survey = $this->survey_repo->findWhere(['id' => $survey_id])->first(); $survey = $survey->whereHas('submissions', function ($query) { global $survey_user_id; $query->where('user_id', $survey_user_id); })->where('id', $survey_id)->first(); // SurveyQuestionAnswerModel::where('survey_id', $survey_id)->where('user_id', $user_id)->get(); } else { $survey = $this->survey_repo->find($survey_id); } if (!$survey) { return abort(404); } return view('survey/result')->with('survey', $survey); }
<?php //printLog.php This will print the Supervisor Report based on the given data require '../includes/includeMeBlank.php'; $start = $_GET['start']; $end = $_GET['end']; $admin = can("update", "7db1df8d-0a15-46ed-9c83-701393e9596c"); //reportInstructions resource $securityProblems = ''; $shiftProblems = ''; $misc = ''; $employee = ''; $params = array(); if (isset($_GET['employee']) && $_GET['employee'] != '') { $employee = " AND submitter = :submitter "; $params[':submitter'] = $_GET['employee']; } if (isset($_GET['securityProblems']) && $_GET['securityProblems'] != '') { $securityProblems = "AND securityProblems LIKE :problems "; $params[':problems'] = "%" . $_GET['securityProblems'] . "%"; } if (isset($_GET['shiftProblem']) && $_GET['shiftProblem'] != '') { $shiftProblems = "AND shiftProblems LIKE :shift "; $params[':shift'] = "%" . $_GET['shiftProblem'] . "%"; } if (isset($_GET['misc']) && $_GET['misc'] != '') { $misc = "AND misc LIKE :misc "; $params[':misc'] = "%" . $_GET['misc'] . "%"; } function printReport($employee, $start, $end, $securityProblems, $shiftProblems, $misc, $params) {
<?php function can(float $num, int $lvl) : float { $lvl = 1 / $lvl; $num = pow($num, $lvl); return $num; } echo can(27, 5);