Exemplo n.º 1
0
    function mass_assign($event, $arguments)
    {
        $action = $_REQUEST['action'];
        $module = $_REQUEST['module'];
        $no_mass_assign_list = array("Emails" => "Emails", "ACLRoles" => "ACLRoles");
        //,"Users"=>"Users");
        //check if security suite enabled
        $action = strtolower($action);
        if (isset($module) && ($action == "list" || $action == "index" || $action == "listview") && (!isset($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] != true) && !array_key_exists($module, $no_mass_assign_list)) {
            global $current_user;
            if (is_admin($current_user) || ACLAction::getUserAccessLevel($current_user->id, "SecurityGroups", 'access') == ACL_ALLOW_ENABLED) {
                require_once 'modules/SecurityGroups/SecurityGroup.php';
                $groupFocus = new SecurityGroup();
                $security_modules = $groupFocus->getSecurityModules();
                //if(in_array($module,$security_modules)) {
                if (in_array($module, array_keys($security_modules))) {
                    global $app_strings;
                    global $current_language;
                    $current_module_strings = return_module_language($current_language, 'SecurityGroups');
                    $form_header = get_form_header($current_module_strings['LBL_MASS_ASSIGN'], '', false);
                    $groups = $groupFocus->get_list("name", "", 0, -99, -99);
                    $options = array("" => "");
                    foreach ($groups['list'] as $group) {
                        $options[$group->id] = $group->name;
                    }
                    $group_options = get_select_options_with_id($options, "");
                    $mass_assign = <<<EOQ

<script type="text/javascript" language="javascript">
function confirm_massassign(del,start_string, end_string) {
\tif (del == 1) {
\t\treturn confirm( start_string + sugarListView.get_num_selected()  + end_string);
\t}
\telse {
\t\treturn confirm( start_string + sugarListView.get_num_selected()  + end_string);
\t}
}

function send_massassign(mode, no_record_txt, start_string, end_string, del) {

\tif(!sugarListView.confirm_action(del, start_string, end_string))
\t\treturn false;

\tif(document.MassAssign_SecurityGroups.massassign_group.selectedIndex == 0) {
\t\talert("Please select a group and try again.");
\t\treturn false;\t
\t}
\t 
\tif (document.MassUpdate.select_entire_list &&
\t\tdocument.MassUpdate.select_entire_list.value == 1)
\t\tmode = 'entire';
\telse if (document.MassUpdate.massall.checked == true)
\t\tmode = 'page';
\telse
\t\tmode = 'selected';

\tvar ar = new Array();
\tif(del == 1) {
\t\tvar deleteInput = document.createElement('input');
\t\tdeleteInput.name = 'Delete';
\t\tdeleteInput.type = 'hidden';
\t\tdeleteInput.value = true;
\t\tdocument.MassAssign_SecurityGroups.appendChild(deleteInput);
\t}

\tswitch(mode) {
\t\tcase 'page':
\t\t\tdocument.MassAssign_SecurityGroups.uid.value = '';
\t\t\tfor(wp = 0; wp < document.MassUpdate.elements.length; wp++) {
\t\t\t\tif(typeof document.MassUpdate.elements[wp].name != 'undefined'
\t\t\t\t\t&& document.MassUpdate.elements[wp].name == 'mass[]' && document.MassUpdate.elements[wp].checked) {
\t\t\t\t\t\t\tar.push(document.MassUpdate.elements[wp].value);
\t\t\t\t}
\t\t\t}
\t\t\tdocument.MassAssign_SecurityGroups.uid.value = ar.join(',');
\t\t\tif(document.MassAssign_SecurityGroups.uid.value == '') {
\t\t\t\talert(no_record_txt);
\t\t\t\treturn false;
\t\t\t}
\t\t\tbreak;
\t\tcase 'selected':
\t\t\tfor(wp = 0; wp < document.MassUpdate.elements.length; wp++) {
\t\t\t\tif(typeof document.MassUpdate.elements[wp].name != 'undefined'
\t\t\t\t\t&& document.MassUpdate.elements[wp].name == 'mass[]'
\t\t\t\t\t\t&& document.MassUpdate.elements[wp].checked) {
\t\t\t\t\t\t\tar.push(document.MassUpdate.elements[wp].value);
\t\t\t\t}
\t\t\t}
\t\t\tif(document.MassAssign_SecurityGroups.uid.value != '') document.MassAssign_SecurityGroups.uid.value += ',';
\t\t\tdocument.MassAssign_SecurityGroups.uid.value += ar.join(',');
\t\t\tif(document.MassAssign_SecurityGroups.uid.value == '') {
\t\t\t\talert(no_record_txt);
\t\t\t\treturn false;
\t\t\t}
\t\t\tbreak;
\t\tcase 'entire':
\t\t\tvar entireInput = document.createElement('input');
\t\t\tentireInput.name = 'entire';
\t\t\tentireInput.type = 'hidden';
\t\t\tentireInput.value = 'index';
\t\t\tdocument.MassAssign_SecurityGroups.appendChild(entireInput);
\t\t\t//confirm(no_record_txt);
\t\t\tbreak;
\t}

\tdocument.MassAssign_SecurityGroups.submit();
\treturn false;
}

</script>

\t\t<form action='index.php' method='post' name='MassAssign_SecurityGroups'  id='MassAssign_SecurityGroups'>
\t\t\t<input type='hidden' name='action' value='MassAssign' />
\t\t\t<input type='hidden' name='module' value='SecurityGroups' />
\t\t\t<input type='hidden' name='return_action' value='{$action}' />
\t\t\t<input type='hidden' name='return_module' value='{$module}' />
\t\t\t<textarea style='display: none' name='uid'></textarea>


\t\t<div id='massassign_form'>{$form_header}
\t\t<table cellpadding='0' cellspacing='0' border='0' width='100%'>
\t\t<tr>
\t\t<td style='padding-bottom: 2px;' class='listViewButtons'>
\t\t<input type='submit' name='Assign' value='{$current_module_strings['LBL_ASSIGN']}' onclick="return send_massassign('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}','{$current_module_strings['LBL_ASSIGN_CONFIRM']}','{$current_module_strings['LBL_CONFIRM_END']}',0);" class='button'>
\t\t<input type='submit' name='Remove' value='{$current_module_strings['LBL_REMOVE']}' onclick="return send_massassign('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}','{$current_module_strings['LBL_REMOVE_CONFIRM']}','{$current_module_strings['LBL_CONFIRM_END']}',1);" class='button'>


\t\t</td></tr></table>
\t\t<table cellpadding='0' cellspacing='0' border='0' width='100%' class='tabForm' id='mass_update_table'>
\t\t<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'>
\t\t<tr>
\t\t<td>{$current_module_strings['LBL_GROUP']}</td>
\t\t<td><select name='massassign_group' id="massassign_group" tabindex='1'>{$group_options}</select></td>
\t\t</tr>
\t\t</table></td></tr></table></div>\t\t\t
\t\t</form>\t\t
EOQ;
                    echo $mass_assign;
                }
            }
        }
        //if after a save...
        if (!empty($_SESSION['securitysuite_error'])) {
            $lbl_securitysuite_error = $_SESSION['securitysuite_error'];
            unset($_SESSION['securitysuite_error']);
            echo <<<EOQ
<script>
\t\t\t\t

var oNewP = document.createElement("div");
oNewP.className = 'error';

var oText = document.createTextNode("{$lbl_securitysuite_error}");
oNewP.appendChild(oText);

var beforeMe = document.getElementsByTagName("div")[0];
document.body.insertBefore(oNewP, beforeMe);
</script>
EOQ;
        }
    }
Exemplo n.º 2
0
$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();
//$moduleList = array_keys($dh->modules);
$security_modules = $groupFocus->getSecurityModules();
$security_modules["All"] = $mod_strings["LBL_ALL_MODULES"];
//rost fix
ksort($security_modules);
$xtpl->assign("MODULE_OPTIONS", get_select_options_with_id($security_modules, "All"));
Exemplo n.º 3
0
 function display()
 {
     $this->fromModuleBuilder = isset($_REQUEST['MB']) || !empty($_REQUEST['view_package']) && $_REQUEST['view_package'] != 'studio';
     if ($this->fromModuleBuilder) {
         return;
         //no support for MB
     }
     global $current_user;
     global $mod_strings;
     $smarty = new Sugar_Smarty();
     $smarty->assign('title', $mod_strings['LBL_DEVELOPER_TOOLS']);
     $smarty->assign('question', $mod_strings['LBL_QUESTION_ADD_LAYOUT']);
     $smarty->assign('mod_strings', $mod_strings);
     $module_name = $_REQUEST['view_module'];
     //$securitygroups = array ( "Support" => "Support" , "Sales" => "Sales" ) ;
     //$copy_layouts = array ( "Default" => "Default", "Support" => "Support" , "Sales" => "Sales" ) ;
     //get security groups that do not have a layout for this module yet
     require_once 'modules/SecurityGroups/SecurityGroup.php';
     $securitygroups = array();
     $copy_layouts = array("Default" => translate('LBL_DEFAULT', 'ModuleBuilder'));
     $groupFocus = new SecurityGroup();
     $groups = $groupFocus->get_list("name", "", 0, 0, 999);
     $custDirectory = "custom/modules/" . $module_name . "/metadata/";
     foreach ($groups['list'] as $group) {
         if (is_dir($custDirectory . $group->id)) {
             $copy_layouts[$group->id] = $group->name;
         } else {
             $securitygroups[$group->id] = $group->name;
         }
     }
     if (empty($securitygroups)) {
         $securitygroups["-1"] = "[Create a Group First]";
     }
     /**
      
              // assign fields and layout
              $smarty->assign ( 'available_fields', $parser->getAvailableFields () ) ;
              $smarty->assign ( 'layout', $parser->getLayout () ) ;
              $smarty->assign ( 'view_module', $this->editModule ) ;
              $smarty->assign ( 'view', $this->editLayout ) ;
              $smarty->assign ( 'maxColumns', $parser->getMaxColumns() ) ;
              $smarty->assign ( 'nextPanelId', $parser->getFirstNewPanelId() ) ;
              $smarty->assign ( 'fieldwidth', '150px' ) ;
             $smarty->assign ( 'translate', true ) ;
     */
     //$this->smarty->assign ( 'view_module', $_REQUEST['view_module'] ) ;
     //$this->smarty->assign ( 'rel', $relationship->getDefinition () ) ;
     //$this->smarty->assign ( 'mod_strings', $GLOBALS [ 'mod_strings' ] ) ;
     //$this->smarty->assign ( 'module_key', $relationship->lhs_module ) ;
     $smarty->assign('securitygroups', array_keys($securitygroups));
     $smarty->assign('translated_securitygroups', $securitygroups);
     $smarty->assign('copy_layouts', array_keys($copy_layouts));
     $smarty->assign('translated_copy_layouts', $copy_layouts);
     $smarty->assign('view_module', $module_name);
     // set up language files
     //$smarty->assign ( 'language', $parser->getLanguage() ) ; // for sugar_translate in the smarty template
     //$smarty->assign('from_mb',$this->fromModuleBuilder);
     $mb = new ModuleBuilder();
     if (!isset($_REQUEST['view_package'])) {
         $_REQUEST['view_package'] = 'studio';
     }
     $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
     $package = $mb->packages[$_REQUEST['view_package']];
     $package->loadModuleTitles();
     $ajax = new AjaxCompose();
     $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")');
     $ajax->addCrumb(translate($module_name), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $module_name . '")');
     $ajax->addCrumb(translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=addlayout&layouts=1&view_module=' . $module_name . '")');
     $ajax->addCrumb($mod_strings['LBL_ADD_LAYOUT'], '');
     //$ajax->addSection ( 'center', $moduleName . ' ' . translate('LBL_ADD_LAYOUT'),
     $ajax->addSection('center', $mod_strings['LBL_ADD_LAYOUT'], $smarty->fetch('modules/ModuleBuilder/tpls/addlayout.tpl'));
     echo $ajax->getJavascript();
 }