public function testDateConversionMassUpdate() { $emailMan = new EmailMan(); $mass = new MassUpdate(); $mass->setSugarBean($emailMan); $pattern = '/07\\/22\\/2011 [0-9]{2}:[0-9]{2}/'; $this->assertRegExp($pattern, $mass->date_to_dateTime('send_date_time', '07/22/2011')); }
public function testhandleMassUpdateForDateFieldsInGMTPlusTimeZone() { global $current_user, $timedate; $_REQUEST = $_POST = array("module" => "Opportunities", "action" => "MassUpdate", "return_action" => "index", "delete" => "false", "massupdate" => "true", "lvso" => "asc", "uid" => $this->opportunities->id, "date_closed" => "2011-08-09"); $mass = new MassUpdate(); $mass->setSugarBean($this->opportunities); $mass->handleMassUpdate(); $expected_date = $_REQUEST['date_closed']; $actual_date = $this->opportunities->date_closed; $this->assertEquals($expected_date, $actual_date); }
public function testGetMassUpdateForm() { global $current_user, $timedate; $expected_dateformat = $timedate->get_cal_date_format(); $_REQUEST['module'] = 'Calls'; $mass = new MassUpdate(); $call = new Call(); $call->fieldDefs['date_start']['massupdate'] = true; $mass->setSugarBean($call); $form_results = $mass->getMassUpdateForm(); $found_match = false; if (preg_match('/daFormat\\s+?\\:\\s+\\"(.*?)\\"/', $form_results, $matches)) { $this->assertEquals($expected_dateformat, $matches[1], 'Assert that the daFormat set in Calendar widget is %Y/%m/%d'); $found_match = true; } $this->assertEquals($found_match, true, 'Assert that the daFormat value was set'); }
/** * Display the actions link * * @param string $id link id attribute, defaults to 'actions_link' * @return string HTML source */ protected function buildActionsLink($id = 'actions_link') { global $app_strings; $closeText = "<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif') . " />"; $moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png'); $menuItems = ''; // delete if (ACLController::checkAccess($this->seed->module_dir, 'delete', true) && $this->delete) { $menuItems .= $this->buildDeleteLink(); } // compose email if ($this->email) { $menuItems .= $this->buildComposeEmailLink($this->data['pageData']['offsets']['total']); } // mass update $mass = new MassUpdate(); $mass->setSugarBean($this->seed); if (ACLController::checkAccess($this->seed->module_dir, 'edit', true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus()) { $menuItems .= $this->buildMassUpdateLink(); } // merge if ($this->mailMerge) { $menuItems .= $this->buildMergeLink(); } if ($this->mergeduplicates) { $menuItems .= $this->buildMergeDuplicatesLink(); } // add to target list if ($this->targetList && ACLController::checkAccess('ProspectLists', 'edit', true)) { $menuItems .= $this->buildTargetList(); } // export if (ACLController::checkAccess($this->seed->module_dir, 'export', true) && $this->export) { $menuItems .= $this->buildExportLink(); } foreach ($this->actionsMenuExtraItems as $item) { $menuItems .= $item; } $menuItems = str_replace('"', '\\"', $menuItems); $menuItems = str_replace(array("\r", "\n"), '', $menuItems); if (empty($menuItems)) { return ''; } return <<<EOHTML <script type="text/javascript"> <!-- function actions_overlib() { return overlib("{$menuItems}", CENTER, '', STICKY, MOUSEOFF, 3000, CLOSETEXT, "{$closeText}", WIDTH, 150, CLOSETITLE, "{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}", CLOSECLICK, FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass'); } --> </script> <a id='{$id}' onclick='return actions_overlib();' href="#"> {$app_strings['LBL_LINK_ACTIONS']} <img src='{$moreDetailImage}' border='0' /> </a> EOHTML; }
function processListView($seed, $xTemplateSection, $html_varName) { global $sugar_config; $populateOnly = $this->ignorePopulateOnly ? FALSE : !empty($sugar_config['save_query']) && $sugar_config['save_query'] == 'populate_only'; if (isset($seed->module_dir) && $populateOnly) { if (empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI') && (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) { $_SESSION['last_search_mod'] = $_REQUEST['module']; return; } } if (strcmp(strtolower($_REQUEST['action']), 'popup') != 0) { $_SESSION['last_search_mod'] = $_REQUEST['module']; } //following session variable will track the detail view nvigation history. //needs to the reset after each search. $this->setLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY", false); require_once 'include/MassUpdate.php'; $mass = new MassUpdate(); $add_acl_javascript = false; if (!isset($_REQUEST['action'])) { $this->shouldProcess = false; } else { $this->shouldProcess = is_subclass_of($seed, "SugarBean") && ($_REQUEST['action'] == 'index' || 'ListView' == substr($_REQUEST['action'], 0, 8)) && $_REQUEST['module'] == $seed->module_dir; } //when processing a multi-select popup. if ($this->process_for_popups && $this->multi_select_popup) { $this->shouldProcess = true; } //mass update turned off? if (!$this->show_mass_update) { $this->shouldProcess = false; } if (is_subclass_of($seed, "SugarBean")) { if ($seed->bean_implements('ACL')) { if (!ACLController::checkAccess($seed->module_dir, 'list', true)) { if ($_REQUEST['module'] != 'Home') { ACLController::displayNoAccess(); } return; } if (!ACLController::checkAccess($seed->module_dir, 'export', true)) { $sugar_config['disable_export'] = true; } } } //force mass update form if requested. if ($this->force_mass_update) { $this->shouldProcess = true; } if ($this->shouldProcess) { echo $mass->getDisplayMassUpdateForm(true, $this->multi_select_popup); echo $mass->getMassUpdateFormHeader($this->multi_select_popup); $mass->setSugarBean($seed); //C.L. Fix for 10048, do not process handleMassUpdate for multi select popups if (!$this->multi_select_popup) { $mass->handleMassUpdate(); } } $this->processListViewTwo($seed, $xTemplateSection, $html_varName); if ($this->shouldProcess && empty($this->process_for_popups)) { //echo "<a href='javascript:sListView.clear_all(document.MassUpdate, \"mass[]\");'>".translate('LBL_CLEARALL')."</a>"; // cn: preserves current functionality, exception is InboundEmail if ($this->show_mass_update_form) { echo $mass->getMassUpdateForm(); } if (!$this->keep_mass_update_form_open) { echo $mass->endMassUpdateForm(); } } }
/** * Perform the actual massupdate. */ protected function action_massupdate() { if (!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))) { if (!empty($_REQUEST['Delete']) && $_REQUEST['Delete'] == 'true' && !$this->bean->ACLAccess('delete') || (empty($_REQUEST['Delete']) || $_REQUEST['Delete'] != 'true') && !$this->bean->ACLAccess('save')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } set_time_limit(0); //I'm wondering if we will set it never goes timeout here. // until we have more efficient way of handling MU, we have to disable the limit $GLOBALS['db']->setQueryLimit(0); require_once "include/MassUpdate.php"; require_once 'modules/MySettings/StoreQuery.php'; $seed = loadBean($_REQUEST['module']); $mass = new MassUpdate(); $mass->setSugarBean($seed); if (isset($_REQUEST['entire']) && empty($_POST['mass'])) { $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']); } $mass->handleMassUpdate(); $storeQuery = new StoreQuery(); //restore the current search. to solve bug 24722 for multi tabs massupdate. $temp_req = array('current_query_by_page' => $_REQUEST['current_query_by_page'], 'return_module' => $_REQUEST['return_module'], 'return_action' => $_REQUEST['return_action']); if ($_REQUEST['return_module'] == 'Emails') { if (!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) { $this->req_for_email = array('type' => $_REQUEST['type'], 'ie_assigned_user_id' => $_REQUEST['ie_assigned_user_id']); // Specifically for My Achieves } } $_REQUEST = array(); $_REQUEST = unserialize(base64_decode($temp_req['current_query_by_page'])); unset($_REQUEST[$seed->module_dir . '2_' . strtoupper($seed->object_name) . '_offset']); //after massupdate, the page should redirect to no offset page $storeQuery->saveFromRequest($_REQUEST['module']); $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action']); //for post_massupdate, to go back to original page. } else { sugar_die("You must massupdate at least one record"); } }
/** * Display the actions link * * @param string $id link id attribute, defaults to 'actions_link' * @return string HTML source */ protected function buildActionsLink($id = 'actions_link') { global $app_strings; $closeText = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']); $moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png'); $menuItems = ''; // delete if (ACLController::checkAccess($this->seed->module_dir, 'delete', true) && $this->delete) { $menuItems .= $this->buildDeleteLink(); } // compose email if ($this->email) { $menuItems .= $this->buildComposeEmailLink($this->data['pageData']['offsets']['total']); } // mass update $mass = new MassUpdate(); $mass->setSugarBean($this->seed); if (ACLController::checkAccess($this->seed->module_dir, 'edit', true) && ACLController::checkAccess($this->seed->module_dir, 'massupdate', true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus()) { $menuItems .= $this->buildMassUpdateLink(); } // merge if ($this->mailMerge) { $menuItems .= $this->buildMergeLink(); } if ($this->mergeduplicates) { $menuItems .= $this->buildMergeDuplicatesLink(); } // add to target list if ($this->targetList && ACLController::checkAccess('ProspectLists', 'edit', true)) { $menuItems .= $this->buildTargetList(); } // export if (ACLController::checkAccess($this->seed->module_dir, 'export', true) && $this->export) { $menuItems .= $this->buildExportLink(); } foreach ($this->actionsMenuExtraItems as $item) { $menuItems .= $item; } $menuItems = str_replace('"', '\\"', $menuItems); $menuItems = str_replace(array("\r", "\n"), '', $menuItems); if (empty($menuItems)) { return ''; } return <<<EOHTML <a id='{$id}' href="javascript:void(0)"> {$app_strings['LBL_LINK_ACTIONS']} <img src='{$moreDetailImage}' border='0' /> </a> <script type="text/javascript"> var actionLinkSelector = "#{$id}"; var userHoveredOverMenu = false; function actions_overlib(e) { overlib("{$menuItems}", CENTER, '', STICKY, MOUSEOFF, 3000, CLOSETEXT, '{$closeText}', WIDTH, 150, CLOSETITLE, "{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}", CLOSECLICK, FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass'); e.currentTarget.focus(); YUI().use('node', 'event-base', function(Y) { e.currentTarget.on('blur', actions_overlib_close); Y.all('#overDiv').on('mouseover', function(e) { userHoveredOverMenu = true; }); Y.all('#overDiv').on('mouseout', function(e) { userHoveredOverMenu = false; }); }); } function actions_overlib_close(e) { if (userHoveredOverMenu == false) { YUI().use('node', function(Y) { var overDiv = Y.one("#overDiv"); if (overDiv != null) overDiv.remove(); }); } } // event delegations YUI().use('node', 'event-base', function(Y) { if (typeof alClickEventHandler != 'undefined') { alClickEventHandler.detach(); } if (Y.one('div.listViewBody') != null) { var alClickEventHandler = Y.one('div.listViewBody').delegate('click', actions_overlib, actionLinkSelector); } }); </script> EOHTML; }