Пример #1
0
 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);
 }
Пример #2
0
 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();
         }
     }
 }
Пример #3
0
 /**
  * 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");
     }
 }
Пример #4
0
 /**
  * Verifies that objects are found and updated by name of custom related
  * object
  *
  * @return void
  */
 public function testSearchAndUpdate()
 {
     $contact = new Contact();
     require_once 'include/MassUpdate.php';
     $mass_update = new MassUpdate();
     $mass_update->sugarbean = $contact;
     // search for contacts related to Bug51596Test_Account1 (e.g. Contact1)
     $current_query_by_page = array('searchFormTab' => 'basic_search', $this->field_name . '_basic' => 'Bug51596Test_Account1');
     // perform mass update
     $current_query_by_page = base64_encode(serialize($current_query_by_page));
     $mass_update->generateSearchWhere('Contacts', $current_query_by_page);
     $mass_update->handleMassUpdate();
     // ensure that "do_not_call" attribute of Contact1 has been changed
     $contact->retrieve($this->contact1->id);
     $this->assertEquals(1, $contact->do_not_call);
     // ensure that "do_not_call" attribute of Contact2 has not been changed
     $contact->retrieve($this->contact2->id);
     $this->assertEquals(0, $contact->do_not_call);
 }