Example #1
0
function add_prospects_to_prospect_list($query_panel, $parent_module, $parent_type, $parent_id, $child_id, $link_attribute, $link_type, $parent)
{
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $query_panel);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_module);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_type);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_id);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $child_id);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $link_attribute);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $link_type);
    require_once 'include/SubPanel/SubPanelTiles.php';
    if (!class_exists($parent_type)) {
        require_once 'modules/' . cleanDirName($parent_module) . '/' . cleanDirName($parent_type) . '.php';
    }
    $focus = new $parent_type();
    $focus->retrieve($parent_id);
    if (empty($focus->id)) {
        return false;
    }
    if (empty($parent)) {
        return false;
    }
    //if link_type is default then load relationship once and add all the child ids.
    $relationship_attribute = $link_attribute;
    //find all prospects based on the query
    $subpanel = new SubPanelTiles($parent, $parent->module_dir);
    $thisPanel = $subpanel->subpanel_definitions->load_subpanel($query_panel);
    if (empty($thisPanel)) {
        return false;
    }
    $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -1, -1, '', $thisPanel);
    if (!empty($result['list'])) {
        foreach ($result['list'] as $object) {
            if ($link_type != 'default') {
                $relationship_attribute = strtolower($object->{$link_attribute});
            }
            $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:' . $relationship_attribute);
            // load relationship for the first time or on change of relationship atribute.
            if (empty($focus->{$relationship_attribute})) {
                $focus->load_relationship($relationship_attribute);
            }
            //add
            $focus->{$relationship_attribute}->add($object->{$child_id});
        }
    }
}
Example #2
0
 /**
  * Writes caches to flat file in cache dir.
  * @param string $key Key to the main cache entry (not timestamp)
  * @param mixed $var Variable to be cached
  * @param string $ieId I-E focus ID
  * @param string $type Folder in cache
  * @param string $file Cache file name
  */
 function writeCacheFile($key, $var, $ieId, $type, $file)
 {
     global $sugar_config;
     $cleanIeId = cleanDirName($ieId);
     $cleanType = cleanDirName($type);
     $cleanFile = cleanFileName($file);
     $the_file = sugar_cached("modules/Emails/{$cleanIeId}/{$cleanType}/{$cleanFile}");
     $timestamp = strtotime('now');
     $array = array();
     $array['timestamp'] = $timestamp;
     $array[$key] = serialize($var);
     // serialized since varexport_helper() can't handle PHP objects
     return $this->_writeCacheFile($array, $the_file);
 }
 public function testCleanDirName()
 {
     $dir = "./../../../dir\\";
     $this->assertEquals(cleanDirName($dir), "dir");
 }
Example #4
0
function add_to_prospect_list($query_panel, $parent_module, $parent_type, $parent_id, $child_id, $link_attribute, $link_type, $parent)
{
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $query_panel);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_module);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_type);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $parent_id);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $child_id);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $link_attribute);
    $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:' . $link_type);
    require_once 'include/SubPanel/SubPanelTiles.php';
    if (!class_exists($parent_type)) {
        require_once 'modules/' . cleanDirName($parent_module) . '/' . cleanDirName($parent_type) . '.php';
    }
    $focus = new $parent_type();
    $focus->retrieve($parent_id);
    if (empty($focus->id)) {
        return false;
    }
    if (empty($parent)) {
        return false;
    }
    //if link_type is default then load relationship once and add all the child ids.
    $relationship_attribute = $link_attribute;
    //find all prospects based on the query
    $subpanel = new SubPanelTiles($parent, $parent->module_dir);
    $thisPanel = $subpanel->subpanel_definitions->load_subpanel($query_panel);
    if (empty($thisPanel)) {
        return false;
    }
    // bugfix #57850  filter prospect list based on marketing_id (if it's present)
    if (isset($_REQUEST['marketing_id']) && $_REQUEST['marketing_id'] != 'all') {
        $thisPanel->_instance_properties['function_parameters']['EMAIL_MARKETING_ID_VALUE'] = $_REQUEST['marketing_id'];
    }
    $result = SugarBean::get_union_related_list($parent, '', '', '', 0, -99, -99, '', $thisPanel);
    if (!empty($result['list'])) {
        foreach ($result['list'] as $object) {
            if ($link_type != 'default') {
                $relationship_attribute = strtolower($object->{$link_attribute});
            }
            $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:' . $relationship_attribute);
            // load relationship for the first time or on change of relationship atribute.
            if (empty($focus->{$relationship_attribute})) {
                $focus->load_relationship($relationship_attribute);
            }
            //add
            $focus->{$relationship_attribute}->add($object->{$child_id});
        }
    }
}
Example #5
0
 public function testcleanDirName()
 {
     //execute the method and test if it returns expected values
     $this->assertSame('testDir', cleanDirName('./testDir'));
     $this->assertSame('testDir', cleanDirName('..\\testDir'));
     $this->assertSame('testDir', cleanDirName('\\test/Dir/'));
 }
Example #6
0
     }
     break;
 case "uploadAttachment":
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: uploadAttachment");
     $metadata = $email->email2saveAttachment();
     if (!empty($metadata)) {
         $out = $json->encode($metadata);
         echo $out;
     }
     break;
 case "removeUploadedAttachment":
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: removeUploadedAttachment");
     $fileFromRequest = from_html($_REQUEST['file']);
     $fileGUID = substr($fileFromRequest, 0, 36);
     // Bug52727: sanitize fileGUID to remove path components: /\.
     $fileGUID = cleanDirName($fileGUID);
     $fileName = $email->et->userCacheDir . "/" . $fileGUID;
     $filePath = clean_path($fileName);
     unlink($filePath);
     break;
 case "fillComposeCache":
     // fills client-side compose email cache with signatures and email templates
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: fillComposeCache");
     $out = array();
     $email_templates_arr = $email->et->getEmailTemplatesArray();
     natcasesort($email_templates_arr);
     $out['emailTemplates'] = $email_templates_arr;
     $sigs = $current_user->getSignaturesArray();
     // clean "none"
     foreach ($sigs as $k => $v) {
         if ($k == "") {