本文整理汇总了PHP中SecurityGroup::retrieveDefaultGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityGroup::retrieveDefaultGroups方法的具体用法?PHP SecurityGroup::retrieveDefaultGroups怎么用?PHP SecurityGroup::retrieveDefaultGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityGroup
的用法示例。
在下文中一共展示了SecurityGroup::retrieveDefaultGroups方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SecurityGroup
$xtpl->assign('securitysuite_inherit_creator', $securitysuite_inherit_creator);
// securitysuite_inherit_parent
$securitysuite_inherit_parent = '';
if (isset($sugar_config['securitysuite_inherit_parent']) && $sugar_config['securitysuite_inherit_parent'] == true) {
$securitysuite_inherit_parent = 'CHECKED';
}
$xtpl->assign('securitysuite_inherit_parent', $securitysuite_inherit_parent);
// securitysuite_inherit_assigned
$securitysuite_inherit_assigned = '';
if (isset($sugar_config['securitysuite_inherit_assigned']) && $sugar_config['securitysuite_inherit_assigned'] == true) {
$securitysuite_inherit_assigned = 'CHECKED';
}
$xtpl->assign('securitysuite_inherit_assigned', $securitysuite_inherit_assigned);
//default security groups
$groupFocus = new SecurityGroup();
$defaultGroups = $groupFocus->retrieveDefaultGroups();
$defaultGroup_string = "";
foreach ($defaultGroups as $default_id => $defaultGroup) {
$defaultGroup_string .= "\n\t<tr>\n\t<td class='dataLabel' width='30%'>\n\t\t" . $mod_strings['LBL_GROUP'] . " " . $defaultGroup['group'] . "\n\t</td>\n\t<td class='dataField' width='30%'>\n\t\t" . $mod_strings['LBL_MODULE'] . " " . $defaultGroup['module'] . "\n\t</td>\n\t<td class='dataLabel' width='40%'>\n\t\t<input type='submit' tabindex='1' class='button' onclick=\"this.form.remove_default_id.value='" . $default_id . "'; this.form.action.value='SaveConfig'; this.form.return_module.value='SecurityGroups'; this.form.return_action.value='config';\" value='" . $mod_strings['LBL_REMOVE_BUTTON_LABEL'] . "'/>\n\t</td>\n\t</tr>";
}
$xtpl->assign("DEFAULT_GROUPS", $defaultGroup_string);
$groups = $groupFocus->get_list("name");
$options = array("" => "");
foreach ($groups['list'] as $group) {
$options[$group->id] = $group->name;
}
$xtpl->assign("SECURITY_GROUP_OPTIONS", get_select_options_with_id($options, ""));
//$moduleList = $app_list_strings['moduleList'];
//require_once('modules/Studio/DropDowns/DropDownHelper.php');
//$dh = new DropDownHelper();
//$dh->getDropDownModules();
示例2: SecurityGroup
static function assign_default_groups(&$focus,$isUpdate)
{
global $sugar_config;
global $current_user;
if(!$isUpdate) {
//inherit only for those that support Security Groups
$groupFocus = new SecurityGroup();
$security_modules = $groupFocus->getSecurityModules();
if(!in_array($focus->module_dir,array_keys($security_modules))) {
return;
}
$defaultGroups = $groupFocus->retrieveDefaultGroups();
foreach($defaultGroups as $default_id => $defaultGroup) {
if($defaultGroup['module'] == "All" || $defaultGroup['module'] == $focus->module_dir) {
if($focus->module_dir == "Users") {
$query = "insert into securitygroups_users(id,date_modified,deleted,securitygroup_id,user_id,noninheritable) "
."select distinct '".create_guid()."',".db_convert('','today').",0,g.id,'$focus->id',1 "
."from securitygroups g "
."left join securitygroups_users d on d.securitygroup_id = g.id and d.user_id = '$focus->id' and d.deleted = 0 "
."where d.id is null and g.id = '".$defaultGroup['securitygroup_id']."' and g.deleted = 0 ";
} else {
$query = "insert into securitygroups_records(id,securitygroup_id,record_id,module,date_modified,deleted) "
."select distinct '".create_guid()."',g.id,'$focus->id','$focus->module_dir',".db_convert('','today').",0 "
."from securitygroups g "
."left join securitygroups_records d on d.securitygroup_id = g.id and d.record_id = '$focus->id' and d.module = '$focus->module_dir' and d.deleted = 0 "
."where d.id is null and g.id = '".$defaultGroup['securitygroup_id']."' and g.deleted = 0 ";
}
$GLOBALS['log']->debug("SecuritySuite: Assign Default Groups: $query");
$focus->db->query($query,true);
}
} //end foreach default group
}
}
示例3: assign_default_groups
function assign_default_groups(&$focus, $isUpdate)
{
global $sugar_config;
global $current_user;
if (!$isUpdate) {
$defaultGroups = SecurityGroup::retrieveDefaultGroups();
foreach ($defaultGroups as $default_id => $defaultGroup) {
if ($defaultGroup['module'] == "All" || $defaultGroup['module'] == $focus->module_dir) {
if ($focus->module_dir == "Users") {
$query = "insert into securitygroups_users(id,date_modified,deleted,securitygroup_id,user_id,noninheritable) " . "select distinct '" . create_guid() . "'," . db_convert('', 'today') . ",0,g.id,'{$focus->id}',1 " . "from securitygroups g " . "left join securitygroups_users d on d.securitygroup_id = g.id and d.user_id = '{$focus->id}' and d.deleted = 0 " . "where d.id is null and g.id = '" . $defaultGroup['securitygroup_id'] . "' and g.deleted = 0 ";
} else {
$query = "insert into securitygroups_records(id,securitygroup_id,record_id,module,date_modified,deleted) " . "select distinct '" . create_guid() . "',g.id,'{$focus->id}','{$focus->module_dir}'," . db_convert('', 'today') . ",0 " . "from securitygroups g " . "left join securitygroups_records d on d.securitygroup_id = g.id and d.record_id = '{$focus->id}' and d.module = '{$focus->module_dir}' and d.deleted = 0 " . "where d.id is null and g.id = '" . $defaultGroup['securitygroup_id'] . "' and g.deleted = 0 ";
}
$GLOBALS['log']->debug("SecuritySuite: Assign Default Groups: {$query}");
$focus->db->query($query, true);
}
}
//end foreach default group
}
}
示例4: testSaveAndRetrieveAndRemoveDefaultGroups
public function testSaveAndRetrieveAndRemoveDefaultGroups()
{
//unset and reconnect Db to resolve mysqli fetch exeception
global $db;
unset($db->database);
$db->checkConnection();
$securityGroup = new SecurityGroup();
//create a security group first
$securityGroup->name = 'test';
$securityGroup->save();
//execute saveDefaultGroup method
$securityGroup->saveDefaultGroup($securityGroup->id, 'test_module');
//execute retrieveDefaultGroups method
$result = $securityGroup->retrieveDefaultGroups();
//verify that default group is created
$this->assertTrue(is_array($result));
$this->assertGreaterThan(0, count($result));
//execute removeDefaultGroup method for each default group
foreach ($result as $key => $value) {
$securityGroup->removeDefaultGroup($key);
}
//retrieve back and verify that default securith groups are deleted
$result = $securityGroup->retrieveDefaultGroups();
$this->assertEquals(0, count($result));
//delete the security group as well for cleanup
$securityGroup->mark_deleted($securityGroup->id);
}