Esempio n. 1
0
 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'));
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 /**
  * @ticket 23900
  */
 public function testAddStatusMulti()
 {
     $mass = new MassUpdate();
     $options = array('10' => 'ten', '20' => 'twenty', '30' => 'thirty');
     $result = $mass->addStatusMulti('test_dom', 'test_dom', $options);
     preg_match_all('/value=[\'\\"].*?[\'\\"]/si', $result, $matches);
     $this->assertTrue(isset($matches));
     $this->assertTrue($matches[0][0] == "value=''");
     $this->assertTrue($matches[0][1] == "value='10'");
     $this->assertTrue($matches[0][3] == "value='30'");
 }
Esempio n. 4
0
 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');
 }
Esempio n. 5
0
    /**
     * 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']}&nbsp;<img src='{$moreDetailImage}' border='0' />
</a>
EOHTML;
    }
Esempio n. 6
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();
         }
     }
 }
Esempio n. 7
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");
     }
 }
Esempio n. 8
0
 /**
  * The collector method for modules.  Gets metadata for all of the module specific data
  *
  * @param $moduleName The name of the module to collect metadata about.
  * @param MetaDataContextInterface|null $context Metadata context
  * @return array An array of hashes containing the metadata.  Empty arrays are
  * returned in the case of no metadata.
  */
 public function getModuleData($moduleName, MetaDataContextInterface $context = null)
 {
     require_once 'include/SugarSearchEngine/SugarSearchEngineMetadataHelper.php';
     $vardefs = $this->getVarDef($moduleName);
     if (!empty($vardefs['fields']) && is_array($vardefs['fields'])) {
         require_once 'include/MassUpdate.php';
         $vardefs['fields'] = MassUpdate::setMassUpdateFielddefs($vardefs['fields'], $moduleName);
     }
     $data['fields'] = isset($vardefs['fields']) ? $vardefs['fields'] : array();
     // Add the _hash for the fields array
     $data['fields']['_hash'] = md5(serialize($data['fields']));
     $data['nameFormat'] = isset($vardefs['name_format_map']) ? $vardefs['name_format_map'] : null;
     $data['views'] = $this->getModuleViews($moduleName, $context);
     $data['datas'] = $this->getModuleDatas($moduleName);
     $data['layouts'] = $this->getModuleLayouts($moduleName);
     $data['fieldTemplates'] = $this->getModuleFields($moduleName);
     $data['menu'] = $this->getModuleMenu($moduleName);
     $data['config'] = $this->getModuleConfig($moduleName);
     $data['filters'] = $this->getModuleFilters($moduleName);
     // Indicate whether Module Has duplicate checking enabled --- Rules must exist and Enabled flag must be set
     $data['dupCheckEnabled'] = isset($vardefs['duplicate_check']) && isset($vardefs['duplicate_check']['enabled']) && $vardefs['duplicate_check']['enabled'] === true;
     // Indicate whether a Module has activity stream enabled
     $data['activityStreamEnabled'] = ActivityQueueManager::isEnabledForModule($moduleName);
     $data['ftsEnabled'] = SugarSearchEngineMetadataHelper::isModuleFtsEnabled($moduleName);
     // TODO we need to have this kind of information on the module itself not hacked around on globals
     $data['isBwcEnabled'] = in_array($moduleName, $GLOBALS['bwcModules']);
     $seed = BeanFactory::newBean($moduleName);
     $data['globalSearchEnabled'] = $this->getGlobalSearchEnabled($seed, $vardefs, $this->platforms[0]);
     if (!empty($seed)) {
         $favoritesEnabled = $seed->isFavoritesEnabled() !== false ? true : false;
         $data['favoritesEnabled'] = $favoritesEnabled;
     }
     // Currently no way to disable following
     // But this flag is here in case we add that feature in the future
     $data['followingEnabled'] = true;
     $data["_hash"] = $this->hashChunk($data);
     return $data;
 }
Esempio n. 9
0
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
/*
 ARGS:
$_REQUEST['module'] : the module associated with this Bean instance (will be used to get the class name)
 $_REQUEST['prospect_lists'] : the id of the prospect list
 $_REQUEST['uids'] : the ids of the records to be added to the prospect list, separated by ','
*/
require_once 'include/formbase.php';
$focus = BeanFactory::getBean($_REQUEST['module']);
$uids = array();
if ($_REQUEST['select_entire_list'] == '1') {
    require_once 'include/MassUpdate.php';
    $mass = new MassUpdate();
    $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
    $query = $focus->create_new_list_query('', $mass->where_clauses, $mass->searchFields);
    $result = $GLOBALS['db']->query($query, true);
    $uids = array();
    while ($val = $GLOBALS['db']->fetchByAssoc($result, false)) {
        array_push($uids, $val['id']);
    }
} else {
    $uids = explode(',', $_POST['uids']);
}
// find the relationship to use
$relationship = '';
foreach ($focus->get_linked_fields() as $field => $def) {
    if ($focus->load_relationship($field)) {
        if ($focus->{$field}->getRelatedModuleName() == 'ProspectLists') {
Esempio n. 10
0
 /**
  *  Update records.
  *
  * @param $data array of job data
  */
 public function runUpdate($data)
 {
     // Get the data down to just the list of fields
     $module = $data['module'];
     unset($data['module']);
     $action = $data['action'];
     unset($data['action']);
     $ids = is_array($data['uid']) ? $data['uid'] : array();
     unset($data['uid']);
     unset($data['filter']);
     unset($data['entire']);
     $prospectLists = isset($data['prospect_lists']) ? $data['prospect_lists'] : array();
     unset($data['prospect_lists']);
     $seed = BeanFactory::newBean($module);
     $fakeApi = new RestService();
     $fakeApi->user = $GLOBALS['current_user'];
     $helper = ApiHelper::getHelper($fakeApi, $seed);
     $failed = 0;
     foreach ($ids as $id) {
         // Doing a full retrieve because we are writing we may need dependent fields for workflow that we don't know about
         $bean = BeanFactory::retrieveBean($module, $id);
         if ($bean == null) {
             // Team permissions may have changed, or a deletion, we won't hold it against them
             continue;
         }
         if (!$bean->aclAccess($action)) {
             // ACL's might not let them modify this bean, but we should still do the rest
             continue;
         }
         if ($action == 'delete') {
             $bean->mark_deleted($id);
             continue;
         }
         try {
             $errors = $helper->populateFromApi($bean, $data, array('massUpdate' => true));
             $check_notify = $helper->checkNotify($bean);
             $bean->save($check_notify);
         } catch (SugarApiExceptionNotAuthorized $e) {
             // ACL's might not let them modify this bean, but we should still do the rest
             $failed++;
             continue;
         }
     }
     if (count($prospectLists) > 0) {
         $massupdate = new MassUpdate();
         foreach ($prospectLists as $listId) {
             if ($action == 'save') {
                 $success = $massupdate->add_prospects_to_prospect_list($module, $listId, $ids);
             } else {
                 $success = $massupdate->remove_prospects_from_prospect_list($module, $listId, $ids);
             }
         }
         if (!$success) {
             $GLOBALS['log']->error("Could not add prospects to prospect list, could not find a relationship to the ProspectLists module.");
         }
     }
     return array('failed' => $failed);
 }
    /**
     * 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']}&nbsp;<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;
    }
Esempio n. 12
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);
 }
Esempio n. 13
0
 * @author Salesagility Ltd <*****@*****.**>
 */
//ini_set('display_errors', '1');
require_once 'modules/AOS_PDF_Templates/PDF_Lib/mpdf.php';
require_once 'modules/AOS_PDF_Templates/templateParser.php';
require_once 'modules/AOS_PDF_Templates/AOS_PDF_Templates.php';
global $sugar_config;
$module_type = $_REQUEST['module'];
$module_type_create = rtrim($module_type, 's');
$module_type_low = strtolower($module_type);
$module = new $module_type_create();
$recordIds = array();
if (isset($_REQUEST['current_post']) && $_REQUEST['current_post'] != '') {
    $order_by = '';
    require_once 'include/MassUpdate.php';
    $mass = new MassUpdate();
    $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_post']);
    $ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $mass->searchFields, $mass->where_clauses);
    $query = $module->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
    $result = $GLOBALS['db']->query($query, true);
    $uids = array();
    while ($val = $GLOBALS['db']->fetchByAssoc($result, false)) {
        array_push($recordIds, $val['id']);
    }
} else {
    $recordIds = explode(',', $_REQUEST['uid']);
}
$template = new AOS_PDF_Templates();
$template->retrieve($_REQUEST['templateID']);
$pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed', $template->margin_left, $template->margin_right, $template->margin_top, $template->margin_bottom, $template->margin_header, $template->margin_footer);
foreach ($recordIds as $recordId) {