本文整理汇总了PHP中ACLRole类的典型用法代码示例。如果您正苦于以下问题:PHP ACLRole类的具体用法?PHP ACLRole怎么用?PHP ACLRole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACLRole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display()
{
require_once 'modules/ACLRoles/ACLRole.php';
//Get the current user's role
$objACLRole = new ACLRole();
$roles = $objACLRole->getUserRoles($GLOBALS['current_user']->id);
//check if they are in the Admin or Admin Manager's role
if (in_array('Admin', $roles) || in_array('Branch Manager - Delhi', $roles)) {
$this->ev->ss->assign('ReadOnly', '');
} else {
//If not pass in a variable with the value readonly
$this->ev->ss->assign('ReadOnly', 'readonly');
}
//Call the parent display function
parent::display();
}
示例2: _displaySubPanels
/**
* Override - Called from process(). This method will display subpanels.
* include/MVC/View/SugarView.php
*/
protected function _displaySubPanels()
{
if (isset($this->bean) && !empty($this->bean->id) && (file_exists("modules/" . $this->module . "/metadata/subpaneldefs.php") || file_exists("custom/modules/" . $this->module . "/Ext/Layoutdefs/layoutdefs.ext.php"))) {
$GLOBALS["focus"] = $this->bean;
require_once 'include/SubPanel/SubPanelTiles.php';
$subpanel = new SubPanelTiles($this->bean, $this->module);
//Dependent Logic
global $current_user;
require_once 'modules/ACLRoles/ACLRole.php';
$role = new ACLRole();
$user_id = $current_user->id;
$roles = $role->getUserRoleNames($user_id);
if (in_array("Technical support", $roles)) {
//Subpanels to hide
$hide_subpanels = array("bugs");
if (isset($subpanel->subpanel_definitions->layout_defs['subpanel_setup']["bugs"])) {
unset($subpanel->subpanel_definitions->layout_defs['subpanel_setup']["bugs"]);
}
}
echo $subpanel->display();
}
}
示例3: rebuild_dropdown_filters
/**
* Rebuilds cache files for dropdown filters extension
*/
protected function rebuild_dropdown_filters()
{
$roles = ACLRole::getAllRoles();
foreach ($roles as $role) {
$this->rebuild_role_dropdown_filters($role->id);
}
}
示例4: getRoleUsers
private function getRoleUsers($roleId)
{
require_once 'modules/ACLRoles/ACLRole.php';
$role = new ACLRole();
$role->retrieve($roleId);
$role_users = $role->get_linked_beans('users', 'User');
$r_users = array();
foreach ($role_users as $role_user) {
$r_users[$role_user->id] = $role_user->name;
}
return $r_users;
}
示例5: _create_seed_user
/**
* Create a user in the seed data.
*/
function _create_seed_user($id, $last_name, $first_name, $user_name, $title, $is_admin, $reports_to, $reports_to_name, $email)
{
$u = new User();
$u->id = $id;
$u->new_with_id = true;
$u->last_name = $last_name;
$u->first_name = $first_name;
$u->user_name = $user_name;
$u->title = $title;
$u->status = 'Active';
$u->employee_status = 'Active';
$u->is_admin = $is_admin;
$u->is_group = 0;
//$u->user_password = $u->encrypt_password($user_name);
$u->user_hash = User::getPasswordHash($user_name);
$u->reports_to_id = $reports_to;
$u->reports_to_name = $reports_to_name;
//$u->email1 = $email;
$u->emailAddress->addAddress($email, true);
$u->emailAddress->addAddress("reply." . $email, false, true);
$u->emailAddress->addAddress("alias." . $email);
// bug 15371 tyoung set a user preference so that Users/DetailView.php can find something without repeatedly querying the db in vain
$u->setPreference('max_tabs', '7');
$u->savePreferencesToDB();
$u->picture = $this->_copy_user_image($id);
$u->save();
if ($id == "seed_jim_id") {
// add to Sales Administrator Role
$acl_roles = new ACLRole();
$arrRoles = $acl_roles->getAllRoles(true);
foreach ($arrRoles as $role) {
if ($role['name'] == "Sales Administrator") {
$u->load_relationship('aclroles');
$u->aclroles->add($role['id']);
// re-save user manually. otherwise the relation to role set will not be saved
// because One2MBeanRelationship::add() doesn't call SugarRelationship::addToResaveList()
// in workflow and during installation
$u->save();
break;
}
}
}
}
示例6: getRoles
/**
* Returns object storage containing available roles as keys
* and flags indicating if there is role specific metadata as value
*
* @param callable $callback Callback that checks if there is role specific metadata
* @return SplObjectStorage
*/
public static function getRoles($callback = null)
{
global $current_user;
$roles = new SplObjectStorage();
//Only super user should have access to all roles
$allRoles = $current_user->isAdmin() ? ACLRole::getAllRoles() : ACLRole::getUserRoles($current_user->id, false);
foreach ($allRoles as $role) {
if (in_array($role->name, static::$hiddenRoles)) {
continue;
}
$roles[$role] = $callback ? $callback(array('role' => $role->id)) : null;
}
return $roles;
}
示例7: Sugar_Smarty
global $dictionary;
$sugar_smarty = new Sugar_Smarty();
$sugar_smarty->assign('MOD', $mod_strings);
$sugar_smarty->assign('APP', $app_strings);
//nsingh bug: 21669. Messes up localization
/*foreach($modInvisList as $modinvisname){
if(empty($app_list_strings['moduleList'][$modinvisname])){
$app_list_strings['moduleList'][$modinvisname] = $modinvisname;
}
}*/
$sugar_smarty->assign('APP_LIST', $app_list_strings);
/*foreach($modInvisList as $modinvisname){
unset($app_list_strings['moduleList'][$modinvisname]);
}*/
$role = BeanFactory::getBean('ACLRoles', $_REQUEST['record']);
$categories = ACLRole::getRoleActions($_REQUEST['record']);
$names = ACLAction::setupCategoriesMatrix($categories);
// Skipping modules that have 'hidden_to_role_assignment' property
foreach ($categories as $name => $category) {
if (isset($dictionary[$name]) && isset($dictionary[$name]['hidden_to_role_assignment']) && $dictionary[$name]['hidden_to_role_assignment']) {
unset($categories[$name]);
}
}
$categories2 = array();
$categories2 = $categories;
$hidden_categories = array("KBDocuments", "Campaigns", "Forecasts", "Emails", "EmailTemplates", "EmailMarketing", "Reports", "PdfManager");
foreach ($hidden_categories as $v) {
if (isset($categories2[$v])) {
unset($categories2[$v]);
}
}
示例8: getEmailsFromParams
private function getEmailsFromParams(SugarBean $bean, $params)
{
$emails = array();
//backward compatible
if (isset($params['email_target_type']) && !is_array($params['email_target_type'])) {
$email = '';
switch ($params['email_target_type']) {
case 'Email Address':
$params['email'] = array($params['email']);
break;
case 'Specify User':
$params['email'] = array($params['email_user_id']);
break;
case 'Related Field':
$params['email'] = array($params['email_target']);
break;
}
$params['email_target_type'] = array($params['email_target_type']);
$params['email_to_type'] = array('to');
}
//end backward compatible
if (isset($params['email_target_type'])) {
foreach ($params['email_target_type'] as $key => $field) {
switch ($field) {
case 'Email Address':
if (trim($params['email'][$key]) != '') {
$emails[$params['email_to_type'][$key]][] = $params['email'][$key];
}
break;
case 'Specify User':
$user = new User();
$user->retrieve($params['email'][$key]);
$user_email = $user->emailAddress->getPrimaryAddress($user);
if (trim($user_email) != '') {
$emails[$params['email_to_type'][$key]][] = $user_email;
$emails['template_override'][$user_email] = array('Users' => $user->id);
}
break;
case 'Users':
$users = array();
switch ($params['email'][$key][0]) {
case 'security_group':
if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
$security_group = new SecurityGroup();
$security_group->retrieve($params['email'][$key][1]);
$users = $security_group->get_linked_beans('users', 'User');
$r_users = array();
if ($params['email'][$key][2] != '') {
require_once 'modules/ACLRoles/ACLRole.php';
$role = new ACLRole();
$role->retrieve($params['email'][$key][2]);
$role_users = $role->get_linked_beans('users', 'User');
foreach ($role_users as $role_user) {
$r_users[$role_user->id] = $role_user->name;
}
}
foreach ($users as $user_id => $user) {
if ($params['email'][$key][2] != '' && !isset($r_users[$user->id])) {
unset($users[$user_id]);
}
}
break;
}
//No Security Group module found - fall through.
//No Security Group module found - fall through.
case 'role':
require_once 'modules/ACLRoles/ACLRole.php';
$role = new ACLRole();
$role->retrieve($params['email'][$key][2]);
$users = $role->get_linked_beans('users', 'User');
break;
case 'all':
default:
global $db;
$sql = "SELECT id from users WHERE status='Active' AND portal_only=0 ";
$result = $db->query($sql);
while ($row = $db->fetchByAssoc($result)) {
$user = new User();
$user->retrieve($row['id']);
$users[$user->id] = $user;
}
break;
}
foreach ($users as $user) {
$user_email = $user->emailAddress->getPrimaryAddress($user);
if (trim($user_email) != '') {
$emails[$params['email_to_type'][$key]][] = $user_email;
$emails['template_override'][$user_email] = array('Users' => $user->id);
}
}
break;
case 'Related Field':
$emailTarget = $params['email'][$key];
$relatedFields = array_merge($bean->get_related_fields(), $bean->get_linked_fields());
$field = $relatedFields[$emailTarget];
if ($field['type'] == 'relate') {
$linkedBeans = array();
$idName = $field['id_name'];
$id = $bean->{$idName};
//.........这里部分代码省略.........
示例9: foreach
$aclrole->setAction($aclrole->id, $action['id'], ACL_ALLOW_NONE);
}
echo 'Only owner Peon user should have editaccess to contacts<br>';
$aclrole->setAction($aclrole->id, $action_results['Contacts']['edit']['id'], ACL_ALLOW_OWNER);
echo 'Some one made a mistake and added delete access on Contacts<br>';
$aclrole->setAction($aclrole->id, $action_results['Contacts']['delete']['id'], ACL_ALLOW_ALL);
$action_results = ACLAction::getUserActions('will_id', true);
echo 'Actions Peon role for will<br>';
foreach ($action_results as $category_name => $category) {
foreach ($category as $action_name => $action) {
_pp($category_name . ':' . $action_name . ':' . acl_translate($action['access']));
}
}
echo 'Will is a bad peon user<br>';
echo 'Create a role for Bad Peon Users<br>';
$aclrole = new ACLRole();
$aclrole->name = 'Bad Peon User';
$aclrole->description = 'The Bad Peon Role For All Bad Peons';
$aclrole->user_id = 'will_id';
$aclrole->save();
echo 'No Bad Peon user should have access to contacts <br>';
foreach ($action_results['Contacts'] as $action) {
$aclrole->setAction($aclrole->id, $action['id'], ACL_ALLOW_NONE);
}
$action_results = ACLAction::getUserActions('will_id', true);
echo 'Actions Peon role for will<br>';
foreach ($action_results as $category_name => $category) {
foreach ($category as $action_name => $action) {
_pp($category_name . ':' . $action_name . ':' . acl_translate($action['access']));
}
}
示例10: setCookie
//set cookies
if (isset($_SESSION['authenticated_user_id'])) {
setCookie('ck_login_id_20', $_SESSION['authenticated_user_id'], time() + 86400 * 90);
}
if (isset($_SESSION['authenticated_user_theme'])) {
setCookie('ck_login_theme_20', $_SESSION['authenticated_user_theme'], time() + 86400 * 90);
}
if (isset($_SESSION['authenticated_user_theme_color'])) {
setCookie('ck_login_theme_color_20', $_SESSION['authenticated_user_theme_color'], time() + 86400 * 90);
}
if (isset($_SESSION['authenticated_user_theme_font'])) {
setCookie('ck_login_theme_font_20', $_SESSION['authenticated_user_theme_font'], time() + 86400 * 90);
}
if (isset($_SESSION['authenticated_user_language'])) {
setCookie('ck_login_language_20', $_SESSION['authenticated_user_language'], time() + 86400 * 90);
}
require_once 'modules/ACLRoles/ACLRole.php';
$objACLRole = new ACLRole();
$roles = $objACLRole->getUserRoles($GLOBALS['current_user']->id);
if (in_array('Lawyer', $roles)) {
print "<h2>You do not have permissions to access this function.</h2>";
exit;
}
chdir($current_directory);
$_POST = $post;
$_GET = $get;
/*foreach(array_keys($GLOBALS) as $key) {
if (!in_array($key, array('_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_REQUEST', 'GLOBALS'))) {
unset($GLOBALS[$key]);
}
}*/
示例11: quick_edit_case_updates
/**
* The Quick edit for case updates which appears under update stream
* Also includes the javascript for AJAX update
*
* @return string - the html to be displayed and javascript
*/
function quick_edit_case_updates()
{
//current record id
$record = $_GET['record'];
//Get Users roles
require_once 'modules/ACLRoles/ACLRole.php';
$user = $GLOBALS['current_user'];
$id = $user->id;
$acl = new ACLRole();
$roles = $acl->getUserRoles($id);
//Return if user cannot edit cases
if (in_array("no edit cases", $roles) || $roles === "no edit cases") {
return;
}
//Javascript for Asynchronous update
$javascript = <<<A
<script>
function caseUpdates(){
loadingMessgPanl = new YAHOO.widget.SimpleDialog('loading', {
width: '200px',
close: true,
modal: true,
visible: true,
fixedcenter: true,
constraintoviewport: true,
draggable: false
});
loadingMessgPanl.setHeader(SUGAR.language.get('app_strings', 'LBL_EMAIL_PERFORMING_TASK'));
loadingMessgPanl.setBody(SUGAR.language.get('app_strings', 'LBL_EMAIL_ONE_MOMENT'));
loadingMessgPanl.render(document.body);
loadingMessgPanl.show();
var update_data = document.getElementById('update_text').value;
var checkbox = document.getElementById('internal').checked;
var internal = "";
if(checkbox){
internal=1;
}
//Post parameters
var params =
"record={$record}&module=Cases&return_module=Cases&action=Save&return_id={$record}&return_action=DetailView&relate_to=Cases&relate_id={$record}&offset=1&update_text="
+ update_data + "&internal=" + internal;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "index.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
//When button is clicked
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
showSubPanel('history', null, true);
//Reload the case updates stream and history panels
\t\t \$("#LBL_AOP_CASE_UPDATES").load("index.php?module=Cases&action=DetailView&record={$record}" + " #LBL_AOP_CASE_UPDATES", function(){
//Collapse all except newest update
\$('.caseUpdateImage').attr("src",showUpdateImage);
\$('.caseUpdate').slideUp('fast');
var id = \$('.caseUpdate').last().attr('id');
if(id){
toggleCaseUpdate(id.replace('caseUpdate',''));
}
loadingMessgPanl.hide();
}
);
\t}
}
xmlhttp.send(params);
}
</script>
A;
$html = <<<EOD
<form id='case_updates' enctype="multipart/form-data">
<textarea id="update_text" name="update_text" cols="80" rows="4"></textarea>
//.........这里部分代码省略.........
示例12: Sugar_Smarty
* "Powered by SugarCRM".
********************************************************************************/
global $app_list_strings;
// $modInvisList
$sugar_smarty = new Sugar_Smarty();
$sugar_smarty->assign('MOD', $mod_strings);
$sugar_smarty->assign('APP', $app_strings);
//mass localization
/*foreach($modInvisList as $modinvisname){
$app_list_strings['moduleList'][$modinvisname] = $modinvisname;
}*/
$sugar_smarty->assign('APP_LIST', $app_list_strings);
/*foreach($modInvisList as $modinvisname){
unset($app_list_strings['moduleList'][$modinvisname]);
}*/
$role = new ACLRole();
$role_name = '';
$return = array('module' => 'ACLRoles', 'action' => 'index', 'record' => '');
if (!empty($_REQUEST['record'])) {
$role->retrieve($_REQUEST['record']);
$categories = ACLRole::getRoleActions($_REQUEST['record']);
$role_name = $role->name;
if (!empty($_REQUEST['isDuplicate'])) {
//role id is stripped here in duplicate so anything using role id after this will not have it
$role->id = '';
} else {
$return['record'] = $role->id;
$return['action'] = 'DetailView';
}
} else {
$categories = ACLRole::getRoleActions('');
示例13: addDefaultRoles
function addDefaultRoles($defaultRoles = array())
{
global $db;
foreach ($defaultRoles as $roleName => $role) {
$ACLField = new ACLField();
$role1 = new ACLRole();
$role1->name = $roleName;
$role1->description = $roleName . " Role";
$role1_id = $role1->save();
foreach ($role as $category => $actions) {
foreach ($actions as $name => $access_override) {
if ($name == 'fields') {
foreach ($access_override as $field_id => $access) {
$ACLField->setAccessControl($category, $role1_id, $field_id, $access);
}
} else {
$queryACL = "SELECT id FROM acl_actions where category='{$category}' and name='{$name}'";
$result = $db->query($queryACL);
$actionId = $db->fetchByAssoc($result);
if (isset($actionId['id']) && !empty($actionId['id'])) {
$role1->setAction($role1_id, $actionId['id'], $access_override);
}
}
}
}
}
}
示例14: set_record
function set_record(SugarBean $record, SugarBean $bean, $params = array(), $in_save = false)
{
global $app_list_strings, $timedate;
$record_vardefs = $record->getFieldDefinitions();
if (isset($params['field'])) {
foreach ($params['field'] as $key => $field) {
if ($field == '') {
continue;
}
switch ($params['value_type'][$key]) {
case 'Field':
if ($params['value'][$key] == '') {
continue;
}
$data = $bean->field_defs[$params['value'][$key]];
if ($data['type'] == 'relate' && isset($data['id_name'])) {
$params['value'][$key] = $data['id_name'];
}
$value = $bean->{$params}['value'][$key];
break;
case 'Date':
$dformat = 'Y-m-d H:i:s';
if ($record_vardefs[$field]['type'] == 'date') {
$dformat = 'Y-m-d';
}
switch ($params['value'][$key][3]) {
case 'business_hours':
if (file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) {
require_once 'modules/AOBH_BusinessHours/AOBH_BusinessHours.php';
$businessHours = new AOBH_BusinessHours();
$dateToUse = $params['value'][$key][0];
$sign = $params['value'][$key][1];
$amount = $params['value'][$key][2];
if ($sign != "plus") {
$amount = 0 - $amount;
}
if ($dateToUse == "now") {
$value = $businessHours->addBusinessHours($amount);
} else {
if ($dateToUse == "field") {
$dateToUse = $params['field'][$key];
$value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->{$dateToUse}));
} else {
$value = $businessHours->addBusinessHours($amount, $timedate->fromDb($bean->{$dateToUse}));
}
}
$value = $timedate->asDb($value);
break;
}
$params['value'][$key][3] = 'hours';
//No business hours module found - fall through.
//No business hours module found - fall through.
default:
if ($params['value'][$key][0] == 'now') {
$date = gmdate($dformat);
} else {
if ($params['value'][$key][0] == 'field') {
$date = $record->fetched_row[$params['field'][$key]];
} else {
$date = $bean->fetched_row[$params['value'][$key][0]];
}
}
if ($params['value'][$key][1] != 'now') {
$value = date($dformat, strtotime($date . ' ' . $app_list_strings['aow_date_operator'][$params['value'][$key][1]] . $params['value'][$key][2] . ' ' . $params['value'][$key][3]));
} else {
$value = date($dformat, strtotime($date));
}
break;
}
break;
case 'Round_Robin':
case 'Least_Busy':
case 'Random':
switch ($params['value'][$key][0]) {
case 'security_group':
if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
$security_group = new SecurityGroup();
$security_group->retrieve($params['value'][$key][1]);
$group_users = $security_group->get_linked_beans('users', 'User');
$users = array();
$r_users = array();
if ($params['value'][$key][2] != '') {
require_once 'modules/ACLRoles/ACLRole.php';
$role = new ACLRole();
$role->retrieve($params['value'][$key][2]);
$role_users = $role->get_linked_beans('users', 'User');
foreach ($role_users as $role_user) {
$r_users[$role_user->id] = $role_user->name;
}
}
foreach ($group_users as $group_user) {
if ($params['value'][$key][2] != '' && !isset($r_users[$group_user->id])) {
continue;
}
$users[$group_user->id] = $group_user->name;
}
break;
}
//No Security Group module found - fall through.
//.........这里部分代码省略.........
示例15: NotifySalesManagers
function NotifySalesManagers($bean)
{
global $sugar_config;
$amount_limit = 1000;
if ($bean->sales_stage === "Negotiation/Review" && $bean->fetched_row['sales_stage'] === "Proposal/Price Quote" && $bean->amount >= $amount_limit) {
SugarApplication::appendErrorMessage('You have changed the opportunity ' . $bean->name . ' (greater than ' . $amount_limit . ') to Negotiation/Review.');
$emailsTo = array();
$emailSubject = "Opportunity Alert";
$emailBody = "The Opportunity " . $bean->name . " has changed to Negotiation/Review<br />\n\t\t\tYou can see the opportunity here:<br />\n\t\t\t<a href=\"" . $sugar_config['site_url'] . "/index.php?module=Opportunities&action=DetailView&record=" . $bean->id . "\">" . $bean->name . "</a>";
$role_id = "<sales-manager-role-id>";
$aclrole = new ACLRole();
if (!is_null($aclrole->retrieve($role_id))) {
$users = $aclrole->get_linked_beans('users', 'User');
foreach ($users as $user) {
$emailsTo[] = $user->email1;
}
}
$this->SendEmail($emailsTo, $emailSubject, $emailBody);
}
}