本文整理汇总了PHP中Permission::Check方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::Check方法的具体用法?PHP Permission::Check怎么用?PHP Permission::Check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::Check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUsers
function getUsers($station_id)
{
Debug::Text('Getting Users for Station ID: ' . $station_id, __FILE__, __LINE__, __METHOD__, 10);
if ($station_id == '') {
return FALSE;
}
$permission = new Permission();
//Gets all users allowed to punch in/out from this station
$slf = new StationListFactory();
$slf->getByStationID($station_id);
if ($slf->getRecordCount() > 0) {
Debug::Text('Found Station!!', __FILE__, __LINE__, __METHOD__, 10);
$s_obj = $slf->getCurrent();
$company_id = $s_obj->getCompany();
if ($company_id != FALSE) {
Debug::Text('Found Company: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
$ulf = new UserListFactory();
$ulf->getByCompanyId($company_id);
if ($ulf->getRecordCount() > 0) {
Debug::Text('Found Users ' . $ulf->getRecordCount() . ' for Company: ' . $company_id, __FILE__, __LINE__, __METHOD__, 10);
$x = 0;
foreach ($ulf as $u_obj) {
//Debug::Text('User ID: '. $u_obj->getId() .' iButton ID: '. $u_obj->getiButtonId() , __FILE__, __LINE__, __METHOD__,10);
$enable_job_tracking = $permission->Check('job', 'enabled', $u_obj->getId(), $u_obj->getCompany());
//Debug::Text('Enable Job Tracking for User: '. $u_obj->getUserName() .' Result: '. (int)$enable_job_tracking, __FILE__, __LINE__, __METHOD__,10);
if (version_compare($this->getClientVersion(), '2.7.0', '<')) {
//In offline punch mode, we use the system local time
//as we assume it is in the proper timezone for the user.
/*
$u_obj_prefs = $u_obj->getUserPreferenceObject();
if ( is_object( $u_obj_prefs ) ) {
$time_zone = $u_obj_prefs->getTimeZone();
$language = $u_obj_prefs->getLanguage();
} else {
$time_zone = NULL;
$language = NULL;
}
*/
$ibutton = FALSE;
$finger_print_1 = FALSE;
$finger_print_2 = FALSE;
$finger_print_3 = FALSE;
$finger_print_4 = FALSE;
//Get User identification rows for ibutton and fingerprints.
$uilf = new UserIdentificationListFactory();
$uilf->getByUserIdAndTypeId($u_obj->getId(), array(10, 20));
//iButton and Griaule Fingerprints.
//Debug::Text('User Identication Records: '. $uilf->getRecordCount(), __FILE__, __LINE__, __METHOD__,10);
if ($uilf->getRecordCount() > 0) {
foreach ($uilf as $ui_obj) {
if ($ui_obj->getType() == 10) {
Debug::Text('Found iButton... User: ' . $u_obj->getID() . ' Number: ' . $ui_obj->getNumber(), __FILE__, __LINE__, __METHOD__, 10);
$ibutton = $ui_obj->getValue();
} elseif ($ui_obj->getType() == 20) {
Debug::Text('Found Griaule FingerPrint... User: ' . $u_obj->getID() . ' Number: ' . $ui_obj->getNumber(), __FILE__, __LINE__, __METHOD__, 10);
switch ($ui_obj->getNumber()) {
case 10:
$finger_print_1 = $ui_obj->getValue();
break;
case 20:
$finger_print_2 = $ui_obj->getValue();
break;
case 30:
$finger_print_3 = $ui_obj->getValue();
break;
case 40:
$finger_print_4 = $ui_obj->getValue();
break;
}
}
}
}
$user_list["'{$x}'"] = array('id' => (int) $u_obj->getId(), 'ibutton_id' => $ibutton, 'employee_number' => $u_obj->getEmployeeNumber(), 'user_name' => $u_obj->getUserName(), 'full_name' => $u_obj->getFullName(), 'default_branch_id' => (int) $u_obj->getDefaultBranch(), 'default_department_id' => (int) $u_obj->getDefaultDepartment(), 'finger_print_1' => $finger_print_1, 'finger_print_2' => $finger_print_2, 'finger_print_3' => $finger_print_3, 'finger_print_4' => $finger_print_4, 'enable_job_tracking' => $enable_job_tracking);
} else {
$user_list["'{$x}'"] = array('id' => (int) $u_obj->getId(), 'employee_number' => $u_obj->getEmployeeNumber(), 'user_name' => $u_obj->getUserName(), 'full_name' => $u_obj->getFullName(), 'default_branch_id' => (int) $u_obj->getDefaultBranch(), 'default_department_id' => (int) $u_obj->getDefaultDepartment(), 'enable_job_tracking' => $enable_job_tracking);
}
unset($enable_job_tracking, $time_zone, $language);
$x++;
}
if (isset($user_list)) {
Debug::Text('Returning User List!', __FILE__, __LINE__, __METHOD__, 10);
return $user_list;
}
}
}
}
Debug::Text('Returning FALSE!', __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
示例2: elseif
//9hrs
} elseif (isset($config_vars['other']['web_session_timeout']) and $config_vars['other']['web_session_timeout'] != '') {
$authentication->setIdle((int) $config_vars['other']['web_session_timeout']);
}
if ($authentication->Check() === TRUE) {
/*
* Get default interface data here. Things like User info, Company info etc...
*/
$current_user = $authentication->getObject();
Debug::text('User Authenticated: ' . $current_user->getUserName() . ' Created Date: ' . $authentication->getCreatedDate(), __FILE__, __LINE__, __METHOD__, 10);
$clf = new CompanyListFactory();
$current_company = $clf->getByID($current_user->getCompany())->getCurrent();
unset($clf);
//Check to make sure the logged in user's information is all up to date.
//Make sure they also have permissions to edit information, otherwise don't redirect them.
if ($current_user->isInformationComplete() == FALSE and (!stristr($_SERVER['SCRIPT_NAME'], 'permissiondenied') and !stristr($_SERVER['SCRIPT_NAME'], 'logout') and !stristr($_SERVER['SCRIPT_NAME'], 'about') and !stristr($_SERVER['SCRIPT_NAME'], 'punch.php') and !stristr($_SERVER['SCRIPT_NAME'], 'ajax_server') and !stristr($_SERVER['SCRIPT_NAME'], 'global.js') and !stristr($_SERVER['SCRIPT_NAME'], 'menu.js') and !stristr($_SERVER['SCRIPT_NAME'], 'embeddeddocument')) and !isset($_GET['incomplete']) and !isset($_POST['incomplete']) and ($permission->Check('user', 'enabled') and ($permission->Check('user', 'edit') or $permission->Check('user', 'edit_own') or $permission->Check('user', 'edit_child')))) {
Redirect::Page(URLBuilder::getURL(array('id' => $current_user->getID(), 'incomplete' => 1), Environment::GetBaseURL() . 'users/EditUser.php'));
}
$db_time_zone_error = FALSE;
$current_user_prefs = $current_user->getUserPreferenceObject();
//If user doesnt have any preferences set, we need to bootstrap the preference object.
if ($current_user_prefs->getUser() == '') {
$current_user_prefs->setUser($current_user->getId());
}
if ($current_user_prefs->setDateTimePreferences() == FALSE) {
//Setting timezone failed, alert user to this fact.
$db_time_zone_error = TRUE;
}
/*
* Check locale cookie, if it varies from UserPreference Language,
* change user preferences to match. This could cause some unexpected behavior
示例3: dirname
/*
* $Revision: 1396 $
* $Id: AuthorizationNotify.php 1396 2007-11-07 16:49:35Z ipso $
* $Date: 2007-11-07 08:49:35 -0800 (Wed, 07 Nov 2007) $
*/
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'global.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'CLI.inc.php';
$permission = new Permission();
$hlf = new HierarchyListFactory();
$hotlf = new HierarchyObjectTypeListFactory();
//Get all users
$ulf = new UserListFactory();
$ulf->getByStatus(10, NULL, array('company_id' => 'asc'));
foreach ($ulf as $user) {
//Check authorize permissions for eact object type.
if ($permission->Check('default_schedule', 'authorize', $user->getId(), $user->getCompany())) {
//Get Hierarchy Control ID
$default_schedule_hierarchy_id = $hotlf->getByCompanyIdAndObjectTypeId($user->getCompany(), 10)->getCurrent()->getHierarchyControl();
Debug::Text('Default Schedule Hierarchy ID: ' . $default_schedule_hierarchy_id, __FILE__, __LINE__, __METHOD__, 10);
//Get all levels below us.
$default_schedule_levels = $hlf->getLevelsByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $user->getId());
Debug::Arr($default_schedule_levels, 'Default Schedule Levels', __FILE__, __LINE__, __METHOD__, 10);
$default_schedule_user_id = $user->getId();
$default_schedule_node_data = $hlf->getByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id);
//Get current level IDs
$default_schedule_current_level_user_ids = $hlf->getCurrentLevelIdArrayByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id);
Debug::Arr($default_schedule_current_level_user_ids, 'Default Schedule Current Level Ids', __FILE__, __LINE__, __METHOD__, 10);
//Get Parents
$default_schedule_parent_level_user_ids = $hlf->getParentLevelIdArrayByHierarchyControlIdAndUserId($default_schedule_hierarchy_id, $default_schedule_user_id);
Debug::Arr($default_schedule_parent_level_user_ids, 'Default Schedule Parent Level Ids', __FILE__, __LINE__, __METHOD__, 10);
//Get Children