public function setUp()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->_goodFile = SugarTestImportUtilities::createFile(2000, 3);
     $this->_badFile = ImportCacheFiles::getImportDir() . '/thisfileisntthere' . date("YmdHis");
     $this->_whiteSpaceFile = SugarTestImportUtilities::createFileWithWhiteSpace();
 }
 public function setUp()
 {
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('current_user');
     $this->importdir = ImportCacheFiles::getImportDir();
 }
    public static function createFileWithWhiteSpace()
    {
        $filename = ImportCacheFiles::getImportDir() . 'testWhiteSpace' . date("YmdHis");
        $contents = <<<EOTEXT
account2,foo bar
EOTEXT;
        file_put_contents($filename, $contents);
        self::$_createdFiles[] = $filename;
        return $filename;
    }
Esempio n. 4
0
 /**
  * Once a user is authenticated on login this function will be called. Populate the session with what is needed and log anything that needs to be logged
  *
  */
 function postLoginAuthenticate()
 {
     global $reset_theme_on_default_user, $reset_language_on_default_user, $sugar_config;
     //THIS SECTION IS TO ENSURE VERSIONS ARE UPTODATE
     require_once 'modules/Versions/CheckVersions.php';
     $invalid_versions = get_invalid_versions();
     if (!empty($invalid_versions)) {
         if (isset($invalid_versions['Rebuild Relationships'])) {
             unset($invalid_versions['Rebuild Relationships']);
             // flag for pickup in DisplayWarnings.php
             $_SESSION['rebuild_relationships'] = true;
         }
         if (isset($invalid_versions['Rebuild Extensions'])) {
             unset($invalid_versions['Rebuild Extensions']);
             // flag for pickup in DisplayWarnings.php
             $_SESSION['rebuild_extensions'] = true;
         }
         $_SESSION['invalid_versions'] = $invalid_versions;
     }
     //just do a little house cleaning here
     unset($_SESSION['login_password']);
     unset($_SESSION['login_error']);
     unset($_SESSION['login_user_name']);
     unset($_SESSION['ACL']);
     //set the server unique key
     if (isset($sugar_config['unique_key'])) {
         $_SESSION['unique_key'] = $sugar_config['unique_key'];
     }
     //set user language
     if (isset($reset_language_on_default_user) && $reset_language_on_default_user && $GLOBALS['current_user']->user_name == $sugar_config['default_user_name']) {
         $authenticated_user_language = $sugar_config['default_language'];
     } else {
         $authenticated_user_language = isset($_REQUEST['login_language']) ? $_REQUEST['login_language'] : (isset($_REQUEST['ck_login_language_20']) ? $_REQUEST['ck_login_language_20'] : $sugar_config['default_language']);
     }
     $_SESSION['authenticated_user_language'] = $authenticated_user_language;
     $GLOBALS['log']->debug("authenticated_user_language is {$authenticated_user_language}");
     // Clear all uploaded import files for this user if it exists
     require_once 'modules/Import/ImportCacheFiles.php';
     $tmp_file_name = ImportCacheFiles::getImportDir() . "/IMPORT_" . $GLOBALS['current_user']->id;
     if (file_exists($tmp_file_name)) {
         unlink($tmp_file_name);
     }
     return true;
 }
Esempio n. 5
0
        $authenticated_user_language = $_REQUEST['login_language'];
    } elseif (isset($_REQUEST['ck_login_language_20'])) {
        $authenticated_user_language = $_REQUEST['ck_login_language_20'];
    } else {
        $authenticated_user_language = $sugar_config['default_language'];
    }
    // If this is the default user and the default user theme is set to reset, reset it to the default theme value on each login
    if ($reset_theme_on_default_user && $focus->user_name == $sugar_config['default_user_name']) {
        $authenticated_user_theme = $sugar_config['default_theme'];
    }
    if (isset($reset_language_on_default_user) && $reset_language_on_default_user && $focus->user_name == $sugar_config['default_user_name']) {
        $authenticated_user_language = $sugar_config['default_language'];
    }
    $_SESSION['authenticated_user_theme'] = $authenticated_user_theme;
    $_SESSION['authenticated_user_language'] = $authenticated_user_language;
    $GLOBALS['log']->debug("authenticated_user_theme is {$authenticated_user_theme}");
    $GLOBALS['log']->debug("authenticated_user_language is {$authenticated_user_language}");
    // Clear all uploaded import files for this user if it exists
    require_once 'modules/Import/ImportCacheFiles.php';
    $tmp_file_name = ImportCacheFiles::getImportDir() . "/IMPORT_" . $focus->id;
    if (file_exists($tmp_file_name)) {
        unlink($tmp_file_name);
    }
} else {
    $_SESSION['login_user_name'] = $focus->user_name;
    $_SESSION['login_password'] = $user_password;
    $_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
    // go back to the login screen.
    // create an error message for the user.
    header("Location: index.php");
}
 public function setUp()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->importdir = ImportCacheFiles::getImportDir();
 }
 public function testLoadEmptyFile()
 {
     $emptyFile = ImportCacheFiles::getImportDir() . '/empty' . date("YmdHis") . '.csv';
     file_put_contents($emptyFile, '');
     $this->unlink[] = $emptyFile;
     $importFile = new ImportFile($emptyFile, ',', '"', false);
     $this->assertFalse($importFile->getNextRow());
     $importFile = new ImportFile($emptyFile, ',', '', false);
     $this->assertFalse($importFile->getNextRow());
 }
 /**
  * Once a user is authenticated on login this function will be called. Populate the session with what is needed and log anything that needs to be logged
  *
  */
 function postLoginAuthenticate()
 {
     global $reset_language_on_default_user, $sugar_config;
     //just do a little house cleaning here
     unset($_SESSION['login_password']);
     unset($_SESSION['login_error']);
     unset($_SESSION['login_user_name']);
     unset($_SESSION['ACL']);
     //set the server unique key
     if (isset($sugar_config['unique_key'])) {
         $_SESSION['unique_key'] = $sugar_config['unique_key'];
     }
     //set user language
     if (isset($reset_language_on_default_user) && $reset_language_on_default_user && $GLOBALS['current_user']->user_name == $sugar_config['default_user_name']) {
         $authenticated_user_language = $sugar_config['default_language'];
     } else {
         $authenticated_user_language = isset($_REQUEST['login_language']) ? $_REQUEST['login_language'] : (isset($_REQUEST['ck_login_language_20']) ? $_REQUEST['ck_login_language_20'] : $sugar_config['default_language']);
     }
     $_SESSION['authenticated_user_language'] = $authenticated_user_language;
     $GLOBALS['log']->debug("authenticated_user_language is {$authenticated_user_language}");
     // Clear all uploaded import files for this user if it exists
     require_once 'modules/Import/ImportCacheFiles.php';
     $tmp_file_name = ImportCacheFiles::getImportDir() . "/IMPORT_" . $GLOBALS['current_user']->id;
     if (file_exists($tmp_file_name)) {
         unlink($tmp_file_name);
     }
     return true;
 }