Пример #1
0
 public function testImportedVcardWithSameCharsetIsNotTranslated()
 {
     $filename = dirname(__FILE__) . "/UTF8SampleFile.vcf";
     $module = "vCardMockModule";
     $vcard = new vCard();
     $record = $vcard->importVCard($filename, $module);
     $bean = new vCardMockModule();
     $bean = $bean->retrieve($record);
     $this->assertEquals('Hans Müster', $bean->first_name . ' ' . $bean->last_name);
 }
Пример #2
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     if (isset($_FILES['vcard']['tmp_name']) && isset($_FILES['vcard']['size']) > 0) {
         $vcard = new vCard();
         $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         SugarApplication::redirect("index.php?action=Importvcard&module={$_REQUEST['module']}");
     }
 }
Пример #3
0
 /**
  * @dataProvider dataProvider
  * @group bug60613
  */
 public function testImportVCard($contents, $module, $allRequiredPresent)
 {
     file_put_contents($this->filename, $contents);
     $vcard = new vCard();
     $beanId = $vcard->importVCard($this->filename, $module);
     if ($allRequiredPresent) {
         $this->createdContacts[] = $beanId;
         $this->assertNotEmpty($beanId);
     } else {
         $this->assertEmpty($beanId);
     }
 }
Пример #4
0
 /**
  * @group bug40629
  */
 public function testImportedVcardAccountLink()
 {
     $filename = dirname(__FILE__) . "/SimpleVCard.vcf";
     $vcard = new vCard();
     $contact_id = $vcard->importVCard($filename, 'Contacts');
     $contact_record = new Contact();
     $contact_record->retrieve($contact_id);
     $this->assertFalse(empty($contact_record->account_id), "Contact should have an account record associated");
     $GLOBALS['db']->query("delete from contacts where id = '{$contact_id}'");
     $vcard = new vCard();
     $lead_id = $vcard->importVCard($filename, 'Leads');
     $lead_record = new Lead();
     $lead_record->retrieve($lead_id);
     $this->assertTrue(empty($lead_record->account_id), "Lead should not have an account record associated");
     $GLOBALS['db']->query("delete from leads where id = '{$lead_id}'");
 }
Пример #5
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $redirect = "index.php?action=Importvcard&module={$_REQUEST['module']}";
     if (!empty($_FILES['vcard']) && $_FILES['vcard']['error'] == 0) {
         $vcard = new vCard();
         $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         if (empty($record)) {
             SugarApplication::redirect($redirect . '&error=vcardErrorRequired');
         }
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         switch ($_FILES['vcard']['error']) {
             case UPLOAD_ERR_FORM_SIZE:
                 $redirect .= "&error=vcardErrorFilesize";
                 break;
             default:
                 $redirect .= "&error=vcardErrorDefault";
                 $GLOBALS['log']->error('Upload error code: ' . $_FILES['vcard']['error'] . '. Please refer to the error codes http://php.net/manual/en/features.file-upload.errors.php');
                 break;
         }
         SugarApplication::redirect($redirect);
     }
 }
Пример #6
0
 /**
  * vCardImport
  *
  * @param $api  ServiceBase The API class of the request, used in cases where the API changes how the fields are pulled from the args array.
  * @param $args array The arguments array passed in from the API
  *
  * @return String
  */
 public function vCardImport($api, $args)
 {
     $this->requireArgs($args, array('module'));
     $bean = BeanFactory::getBean($args['module']);
     if (!$bean->ACLAccess('save') || !$bean->ACLAccess('import')) {
         throw new SugarApiExceptionNotAuthorized('EXCEPTION_NOT_AUTHORIZED');
     }
     $this->checkPostRequestBody();
     if (isset($_FILES) && count($_FILES) === 1) {
         reset($_FILES);
         $first_key = key($_FILES);
         if (isset($_FILES[$first_key]['tmp_name']) && $this->isUploadedFile($_FILES[$first_key]['tmp_name']) && isset($_FILES[$first_key]['size']) && isset($_FILES[$first_key]['size']) > 0) {
             $vcard = new vCard();
             try {
                 $recordId = $vcard->importVCard($_FILES[$first_key]['tmp_name'], $args['module']);
             } catch (Exception $e) {
                 throw new SugarApiExceptionRequestMethodFailure('ERR_VCARD_FILE_PARSE');
             }
             $results = array($first_key => $recordId);
             return $results;
         }
     }
 }
Пример #7
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $redirect = "index.php?action=Importvcard&module={$_REQUEST['module']}";
     if (!empty($_FILES['vcard']) && is_uploaded_file($_FILES['vcard']['tmp_name']) && $_FILES['vcard']['error'] == 0) {
         $vcard = new vCard();
         try {
             $record = $vcard->importVCard($_FILES['vcard']['tmp_name'], $_REQUEST['module']);
         } catch (Exception $e) {
             SugarApplication::redirect($redirect . '&error=vcardErrorRequired');
         }
         SugarApplication::redirect("index.php?action=DetailView&module={$_REQUEST['module']}&record={$record}");
     } else {
         switch ($_FILES['vcard']['error']) {
             case UPLOAD_ERR_FORM_SIZE:
                 $redirect .= "&error=vcardErrorFilesize";
                 break;
             default:
                 $redirect .= "&error=vcardErrorDefault";
                 $GLOBALS['log']->info('Upload error code: ' . $_FILES['vcard']['error'] . '.');
                 break;
         }
         SugarApplication::redirect($redirect);
     }
 }
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
/*********************************************************************************
 * Description:  
 ********************************************************************************/
if (isset($_FILES['vcard']['tmp_name']) && isset($_FILES['vcard']['size']) > 0) {
    require_once 'include/vCard.php';
    $vcard = new vCard();
    $record = $vcard->importVCard($_FILES['vcard']['tmp_name']);
    header("Location: index.php?action=DetailView&module=Contacts&record={$record}");
    exit;
} else {
    echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_IMPORT_VCARD'], true);
    global $theme;
    $error_msg = '';
    global $app_strings;
    global $app_list_strings;
    global $current_language;
    $mod_strings = return_module_language($current_language, 'Contacts');
    $xtpl = new XTemplate('modules/Contacts/ImportVCard.html');
    $xtpl->assign("MOD", $mod_strings);
    $xtpl->assign("APP", $app_strings);
    $xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
    $xtpl->assign("ERROR_TEXT", $mod_strings['LBL_EMPTY_VCARD']);