Пример #1
0
 /**
  * Save a dictionary for a particular API to storage
  * @internal
  * @param string $apiType The api type for the dictionary you want to load ("Rest" or "Soap")
  * @param array $storageData The data that the API needs to store for it's dictionary.
  */
 protected function saveDictionaryToStorage($apiType, $storageData)
 {
     if (!is_dir($this->cacheDir)) {
         sugar_mkdir($this->cacheDir, null, true);
     }
     sugar_file_put_contents($this->cacheDir . 'ServiceDictionary.' . $apiType . '.php', '<' . "?php\n\$apiDictionary['" . $apiType . "'] = " . var_export($storageData, true) . ";\n");
 }
Пример #2
0
 public function testGetMetaDataFile()
 {
     // backup custom file if it already exists
     if (file_exists('custom/modules/Contacts/metadata/listviewdefs.php')) {
         copy('custom/modules/Contacts/metadata/listviewdefs.php', 'custom/modules/Contacts/metadata/listviewdefs.php.bak');
         unlink('custom/modules/Contacts/metadata/listviewdefs.php');
     }
     $this->_view->module = 'Contacts';
     $this->_view->type = 'list';
     $metaDataFile = $this->_view->getMetaDataFile();
     $this->assertEquals('modules/Contacts/metadata/listviewdefs.php', $metaDataFile, 'Did not load the correct metadata file');
     //test custom file
     if (!file_exists('custom/modules/Contacts/metadata/')) {
         sugar_mkdir('custom/modules/Contacts/metadata/', null, true);
     }
     $customFile = 'custom/modules/Contacts/metadata/listviewdefs.php';
     if (!file_exists($customFile)) {
         sugar_file_put_contents($customFile, array());
         $customMetaDataFile = $this->_view->getMetaDataFile();
         $this->assertEquals($customFile, $customMetaDataFile, 'Did not load the correct custom metadata file');
         unlink($customFile);
     }
     // Restore custom file if we backed it up
     if (file_exists('custom/modules/Contacts/metadata/listviewdefs.php.bak')) {
         rename('custom/modules/Contacts/metadata/listviewdefs.php.bak', 'custom/modules/Contacts/metadata/listviewdefs.php');
     }
 }
Пример #3
0
function post_install()
{
    // Include existing custom entry point registry array
    @(include_once 'custom/include/MVC/Controller/entry_point_registry.php');
    // Start building custom entry point PHP
    $the_string = "<?php\n" . '// created: ' . date('Y-m-d H:i:s') . "\n\n";
    // Define new entry point
    $entry_point_registry['AsteriskController'] = array('file' => 'custom/modules/Asterisk/include/controller.php', 'auth' => true);
    $entry_point_registry['AsteriskCallListener'] = array('file' => 'custom/modules/Asterisk/include/callListener.php', 'auth' => true);
    $entry_point_registry['AsteriskCallCreate'] = array('file' => 'custom/modules/Asterisk/include/callCreate.php', 'auth' => true);
    // For each custom entry point, add override value
    foreach ($entry_point_registry as $key => $value) {
        $the_string .= override_value_to_string('entry_point_registry', $key, $value) . "\n";
    }
    // Write the dir if needed
    if (!is_dir('custom/include/MVC/Controller')) {
        $result = sugar_mkdir('custom/include/MVC/Controller', NULL, true);
    }
    // Write the new custom entry point registry file
    $result = @sugar_file_put_contents('custom/include/MVC/Controller/entry_point_registry.php', $the_string);
    if ($_REQUEST['mode'] == 'Install') {
        ?>
<br /><br />
<span style="font-size: 2em;"><strong>Please review the documentation!  There are several additional steps that must be taken.</strong></span> 
<br /><span style="font-size: 1.3em;">The User Guide can be found on the Project website here: <a href="https://github.com/blak3r/yaai/wiki/User-Manual">https://github.com/blak3r/yaai/wiki/User-Manual</a></span>

<?php 
    }
}
Пример #4
0
 public function setUp()
 {
     $this->authclassname = 'TestAuthClass' . mt_rand();
     sugar_mkdir("custom/modules/Users/authentication/{$this->authclassname}/", null, true);
     sugar_file_put_contents("custom/modules/Users/authentication/{$this->authclassname}/{$this->authclassname}.php", "<?php\nrequire_once 'modules/Users/authentication/SugarAuthenticate/SugarAuthenticate.php';\nclass {$this->authclassname} extends SugarAuthenticate {\n    public \$userAuthenticateClass = '{$this->authclassname}User';\n    public \$authenticationDir = '{$this->authclassname}';\n\n    public function _construct(){\n\t    parent::SugarAuthenticate();\n\t}\n}");
     sugar_file_put_contents("custom/modules/Users/authentication/{$this->authclassname}/{$this->authclassname}User.php", "<?php\nrequire_once 'modules/Users/authentication/SugarAuthenticate/SugarAuthenticateUser.php';\nclass {$this->authclassname}User extends SugarAuthenticateUser {\n}");
 }
Пример #5
0
/**
 * @return bool
 * @param module string
 * @desc Creates the module's language directory under the custom directory.
 */
function create_module_lang_dir($module)
{
    if (!is_dir("custom/modules/{$module}/language")) {
        return sugar_mkdir("custom/modules/{$module}/language", null, true);
    }
    return true;
}
Пример #6
0
 public function setUp()
 {
     sugar_mkdir('tests/include/utils/ziptest/testarchive', null, true);
     sugar_touch('tests/include/utils/ziptest/testarchive/testfile1.txt');
     sugar_touch('tests/include/utils/ziptest/testarchive/testfile2.txt');
     sugar_touch('tests/include/utils/ziptest/testarchive/testfile3.txt');
     sugar_mkdir('tests/include/utils/ziptest/testarchiveoutput', null, true);
 }
Пример #7
0
 public function renameDisabled($files)
 {
     foreach ($files as $fileFrom => $fileTo) {
         sugar_mkdir(dirname($fileTo), null, true);
         sugar_rename($fileFrom, $fileTo);
         $this->log('Custom view ' . $fileFrom . ' should be disabled (moved to ' . $fileTo . ')');
     }
 }
Пример #8
0
 public function setUp()
 {
     $this->testdir = sugar_cached("tests/include/utils/ziptest");
     sugar_mkdir($this->testdir . '/testarchive', null, true);
     sugar_touch($this->testdir . '/testarchive/testfile1.txt');
     sugar_touch($this->testdir . '/testarchive/testfile2.txt');
     sugar_touch($this->testdir . '/testarchive/testfile3.txt');
     sugar_mkdir($this->testdir . '/testarchiveoutput', null, true);
 }
Пример #9
0
function mkdir_recursive($path, $check_is_parent_dir = false)
{
    if (sugar_is_dir($path, 'instance')) {
        return true;
    }
    if (sugar_is_file($path, 'instance')) {
        if (!empty($GLOBALS['log'])) {
            $GLOBALS['log']->fatal("ERROR: mkdir_recursive(): argument {$path} is already a file.");
        }
        return false;
    }
    //make variables with file paths
    $pathcmp = $path = rtrim(clean_path($path), '/');
    $basecmp = $base = rtrim(clean_path(getcwd()), '/');
    if (is_windows()) {
        //make path variable lower case for comparison in windows
        $pathcmp = strtolower($path);
        $basecmp = strtolower($base);
    }
    if ($basecmp == $pathcmp) {
        return true;
    }
    $base .= "/";
    if (strncmp($pathcmp, $basecmp, strlen($basecmp)) == 0) {
        /* strip current path prefix */
        $path = substr($path, strlen($base));
    }
    $thePath = '';
    $dirStructure = explode("/", $path);
    if ($dirStructure[0] == '') {
        // absolute path
        $base = '/';
        array_shift($dirStructure);
    }
    if (is_windows()) {
        if (strlen($dirStructure[0]) == 2 && $dirStructure[0][1] == ':') {
            /* C: prefix */
            $base = array_shift($dirStructure) . "\\";
        } elseif ($dirStructure[0][0] . $dirStructure[0][1] == "\\\\") {
            /* UNC absolute path */
            $base = array_shift($dirStructure) . "\\" . array_shift($dirStructure) . "\\";
            // we won't try to mkdir UNC share name
        }
    }
    foreach ($dirStructure as $dirPath) {
        $thePath .= $dirPath . "/";
        $mkPath = $base . $thePath;
        if (!is_dir($mkPath)) {
            if (!sugar_mkdir($mkPath)) {
                return false;
            }
        }
    }
    return true;
}
Пример #10
0
 public function testDisplayWithClassicCustomView()
 {
     $view = $this->getMock('ViewClassic', array('includeClassicFile'));
     $view->module = 'testmodule' . mt_rand();
     $view->action = 'testaction' . mt_rand();
     sugar_mkdir("custom/modules/{$view->module}", null, true);
     sugar_touch("custom/modules/{$view->module}/{$view->action}.php");
     $return = $view->display();
     rmdir_recursive("custom/modules/{$view->module}");
     $this->assertTrue($return);
 }
Пример #11
0
 public function setUp()
 {
     if (!is_dir(dirname(Bug44896PackageManger::$location))) {
         sugar_mkdir(dirname(Bug44896PackageManger::$location));
     }
     if (!is_dir(Bug44896PackageManger::$location)) {
         sugar_mkdir(Bug44896PackageManger::$location);
     }
     $manage = new Bug44896PackageManger();
     $manage->createTempModule();
 }
Пример #12
0
 public function setUp()
 {
     if (!class_exists('ZipArchive')) {
         $this->markTestSkipped('ZipArchive class not loaded');
     }
     $this->testdir = sugar_cached("tests/include/utils/ziptest");
     sugar_mkdir($this->testdir . '/testarchive', null, true);
     sugar_touch($this->testdir . '/testarchive/testfile1.txt');
     sugar_touch($this->testdir . '/testarchive/testfile2.txt');
     sugar_touch($this->testdir . '/testarchive/testfile3.txt');
     sugar_mkdir($this->testdir . '/testarchiveoutput', null, true);
 }
Пример #13
0
 public function run()
 {
     if (version_compare($this->from_version, 7, '<')) {
         $path = 'custom/Extension/application/Ext/Include/';
         sugar_mkdir($path . 'Disabled/', null, true);
         foreach ($this->modules as $module) {
             $file = $module . '.php';
             if (file_exists($path . $file)) {
                 sugar_rename($path . $file, $path . "Disabled/" . $file);
                 $this->log("Unsupported module {$module} disabled");
             }
         }
     }
 }
Пример #14
0
    public function setUp()
    {
        $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
        $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
        $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
        // Create a Custom editviewdefs.php
        sugar_mkdir("custom/modules/Leads/metadata/", null, true);
        if (is_dir("cache/modules/Leads")) {
            rmdir_recursive("cache/modules/Leads");
        }
        if (file_exists("custom/modules/Leads/metadata/editviewdefs.php")) {
            unlink("custom/modules/Leads/metadata/editviewdefs.php");
        }
        // Create a very simple custom EditView Layout
        if ($fh = @fopen("custom/modules/Leads/metadata/editviewdefs.php", 'w+')) {
            $string = <<<EOQ
<?php
\$viewdefs['Leads']['EditView'] = array('templateMeta' => array (
                                                                 'form' => array('buttons' => array ('SAVE', 'CANCEL'),
                                                                                 'hidden' => array ('<a>HiddenPlaceHolder</a>',
                                                                                                   ),
                                                                                ),
                                                                 'maxColumns' => '2', 
                                                                 'useTabs' => true,
                                                                 'widths' => array( array ('label' => '10', 'field' => '30'),
                                                                                    array ('label' => '10', 'field' => '30'),
                                                                                  ),
                                                                 'javascript' => array( array ('file' => 'custom/modules/Leads/javascript/LeadJS1.js'),
                                                                                        array ('file' => 'custom/modules/Leads/javascript/LeadJS2.js'),
                                                                                      ),
                                                                ),
                                        'panels' => array ('default' => array (0 => array (0 => array ('name' => 'first_name',
                                                                                                      ),
                                                                                           1 => array ('name' => 'last_name',
                                                                                                      ),
                                                                                          ),
                                                                               1 => array (0 => array ('name' => 'unknown_field',
                                                                                                       'customCode' => '<a href="#">Unknown Field Link</a>',
                                                                                                      ),
                                                                                          ),
                                                                              ),
                                                          ),  
                                       );
?>
EOQ;
            fputs($fh, $string);
            fclose($fh);
        }
    }
Пример #15
0
 public function testGetMetaDataFile()
 {
     $this->_view->module = 'Contacts';
     $this->_view->type = 'list';
     $metaDataFile = $this->_view->getMetaDataFile();
     $this->assertEquals('modules/Contacts/metadata/listviewdefs.php', $metaDataFile, 'Did not load the correct metadata file');
     //test custom file
     sugar_mkdir('custom/modules/Contacts/metadata/', null, true);
     $customFile = 'custom/modules/Contacts/metadata/listviewdefs.php';
     if (!file_exists($customFile)) {
         sugar_file_put_contents($customFile, array());
         $customMetaDataFile = $this->_view->getMetaDataFile();
         $this->assertEquals($customFile, $customMetaDataFile, 'Did not load the correct custom metadata file');
         unlink($customFile);
     }
 }
Пример #16
0
 public static function setUpBeforeClass()
 {
     if (!file_exists(self::$directory)) {
         sugar_mkdir(self::$directory, 0777, true);
     }
     if (file_exists(self::$customConfigFile)) {
         rename(self::$customConfigFile, self::$customConfigFile . ".bak");
     }
     if (file_exists(self::$customDefaultConfigFile)) {
         rename(self::$customDefaultConfigFile, self::$customDefaultConfigFile . ".bak");
     }
     file_put_contents(self::$customConfigFile, "<?php\n\t\t\t\$buttonConfigs = array('default' => array('buttonConfig' =>'testcase',\n\t\t\t\t\t\t\t\t\t'buttonConfig2' => 'cut,copy,paste,pastetext,pasteword,selectall,separator,search,replace,separator,bullist,numlist,separator,outdent,\n\t                     \t\t\t\t\tindent,separator,ltr,rtl,separator,undo,redo,separator, link,unlink,anchor,image,separator,sub,sup,separator,charmap,\n\t                     \t\t\t\t\tvisualaid', \n\t                    \t\t\t'buttonConfig3' => 'tablecontrols,separator,advhr,hr,removeformat,separator,insertdate,inserttime,separator,preview'),\n\t\t\t\t\t\t\t\t\t'badkey1' => 'bad data1');\n\t\t\t?>");
     file_put_contents(self::$customDefaultConfigFile, "<?php\n\t\t\t\$defaultConfig = array('extended_valid_elements' => 'upload[testlength|ratio|initialtest|mintestsize|threads|maxchunksize|maxchunkcount],download[testlength|initialtest|mintestsize|threads|maximagesize]',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t 'badkey2' => 'bad data2');\n\t\t\t?>");
     $tinySugar = new SugarTinyMCE();
     self::$MCE = $tinySugar->getInstance();
 }
Пример #17
0
/**
 * @return bool
 * @param module string
 * @desc Creates the module's language directory under the custom directory.
 */
function create_module_lang_dir($module)
{
    $continue = true;
    if (!is_dir('custom/modules')) {
        $continue = sugar_mkdir('custom/modules');
    }
    if ($continue) {
        if (!is_dir("custom/modules/{$module}")) {
            $continue = sugar_mkdir("custom/modules/{$module}");
        }
    }
    if ($continue) {
        if (!is_dir("custom/modules/{$module}/language")) {
            $continue = sugar_mkdir("custom/modules/{$module}/language");
        }
    }
    return $continue;
}
Пример #18
0
 public function setUp()
 {
     //back up users popup if it exists
     if (is_file($this->customFilePath)) {
         include $this->customFilePath;
         $this->originalPopupMeta = $popupMeta;
         $this->newPopupMeta = $popupMeta;
     } else {
         //lets create the directory if it does not exist
         if (!is_dir($this->customFileDir)) {
             sugar_mkdir($this->customFileDir);
         }
     }
     //define and add the new elements
     $this->newPopupMeta['addToReserve'] = array('whereStatement', 'templateMeta');
     $this->newPopupMeta['whereStatement'] = 'select money from yourWallet where deposit = "myPocket"';
     $this->newPopupMeta['templateMeta'] = array('one', 'two');
     $this->newPopupMeta['disappear'] = 'this element was not defined and should be processed';
 }
Пример #19
0
 /**
  * DetailView constructor
  * This is the DetailView constructor responsible for processing the new
  * Meta-Data framework
  *
  * @param $module String value of module this detail view is for
  * @param $focus An empty sugarbean object of module
  * @param $id The record id to retrieve and populate data for
  * @param $metadataFile String value of file location to use in overriding default metadata file
  * @param tpl String value of file location to use in overriding default Smarty template
  */
 function setup($module, $focus, $metadataFile = null, $tpl = 'include/DetailView/DetailView.tpl')
 {
     global $sugar_config;
     $this->th = new TemplateHandler();
     $this->th->ss = $this->ss;
     //Check if inline editing is enabled for detail view.
     if ($sugar_config['enable_line_editing_detail']) {
         $this->ss->assign('inline_edit', true);
     }
     $this->focus = $focus;
     $this->tpl = $tpl;
     $this->module = $module;
     $this->metadataFile = $metadataFile;
     if (isset($GLOBALS['sugar_config']['disable_vcr'])) {
         $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr'];
     }
     if (!empty($this->metadataFile) && file_exists($this->metadataFile)) {
         require $this->metadataFile;
     } else {
         //If file doesn't exist we create a best guess
         if (!file_exists("modules/{$this->module}/metadata/detailviewdefs.php") && file_exists("modules/{$this->module}/DetailView.html")) {
             global $dictionary;
             $htmlFile = "modules/" . $this->module . "/DetailView.html";
             $parser = new DetailViewMetaParser();
             if (!file_exists('modules/' . $this->module . '/metadata')) {
                 sugar_mkdir('modules/' . $this->module . '/metadata');
             }
             $fp = sugar_fopen('modules/' . $this->module . '/metadata/detailviewdefs.php', 'w');
             fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module));
             fclose($fp);
         }
         //Flag an error... we couldn't create the best guess meta-data file
         if (!file_exists("modules/{$this->module}/metadata/detailviewdefs.php")) {
             global $app_strings;
             $error = str_replace("[file]", "modules/{$this->module}/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']);
             $GLOBALS['log']->fatal($error);
             echo $error;
             die;
         }
         require "modules/{$this->module}/metadata/detailviewdefs.php";
     }
     $this->defs = $viewdefs[$this->module][$this->view];
 }
Пример #20
0
function post_install()
{
    // Include existing custom entry point registry array
    @(include_once 'custom/include/MVC/Controller/entry_point_registry.php');
    // Start building custom entry point PHP
    $the_string = "<?php\n" . '// created: ' . date('Y-m-d H:i:s') . "\n\n";
    // Define new entry point
    $entry_point_registry['AsteriskController'] = array('file' => 'custom/modules/Asterisk/include/controller.php', 'auth' => true);
    $entry_point_registry['AsteriskCallListener'] = array('file' => 'custom/modules/Asterisk/include/callListener.php', 'auth' => true);
    $entry_point_registry['AsteriskCallCreate'] = array('file' => 'custom/modules/Asterisk/include/callCreate.php', 'auth' => true);
    // For each custom entry point, add override value
    foreach ($entry_point_registry as $key => $value) {
        $the_string .= override_value_to_string('entry_point_registry', $key, $value) . "\n";
    }
    // Write the dir if needed
    if (!is_dir('custom/include/MVC/Controller')) {
        $result = sugar_mkdir('custom/include/MVC/Controller', NULL, true);
    }
    // Write the new custom entry point registry file
    $result = @sugar_file_put_contents('custom/include/MVC/Controller/entry_point_registry.php', $the_string);
    if ($_REQUEST['mode'] == 'Install') {
        ?>
<br /><br />
<span style="font-size: 1.6em;"><strong>Please review the documentation!  There are several additional steps that must be taken.</strong></span>
<br /><span style="font-size: 1.3em;">The User Guide can be found on the Project website here: <a href="https://github.com/blak3r/yaai/wiki/User-Manual">https://github.com/blak3r/yaai/wiki/User-Manual</a>.  Please note the fairly comprehensive troubleshooting section at the end of the manual.</span>
<br>
<BR>
<span style="font-size: 1.6em;"><strong>Donate to YAAI</strong></span>
<br /><span style="font-size:1.3em;">Please consider making a donation to the project.  Your contribution allows me to spend more time improving/supporting.
We're also in great need of some help from developers.  Please see: <a href="https://github.com/blak3r/yaai/wiki/Project-TODO-List">https://github.com/blak3r/yaai/wiki/Project-TODO-List</a> for ways you can help.</span>
<P>
    <BR/>
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
      <input type="hidden" name="cmd" value="_s-xclick">
      <input type="hidden" name="hosted_button_id" value="FA36DGSYQ3NE6">
      <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
      <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
  </form>
</P>

<?php 
    }
}
 public function run()
 {
     $originalPath = 'custom/modules/Activities/clients';
     $newPath = 'custom/modules/ActivityStream/Activities/clients';
     if (!version_compare($this->from_version, '7.0.0', ">=")) {
         return;
     }
     if (!is_dir($originalPath) || is_dir($newPath)) {
         return;
     }
     if (!is_dir($newPath)) {
         sugar_mkdir($newPath, null, true);
     }
     $this->log("MoveActivityStreamCustomMetaData: Renaming {$originalPath}");
     rename($originalPath, $newPath);
     $this->log("MoveActivityStreamCustomMetaData: Renamed {$originalPath} to {$newPath}");
     $this->fileToDelete('modules/Activities/clients');
     $this->fileToDelete('custom/modules/Activities/clients');
 }
 public function handleSave()
 {
     if (empty($this->sidecarViewdefs)) {
         return true;
     }
     if ($this->isExt) {
         $newExtLocation = "custom/Extension/modules/{$this->module}/Ext/clients/base/menus/header/";
         if (!is_dir($newExtLocation)) {
             sugar_mkdir($newExtLocation, null, true);
         }
         $content = "<?php \n";
         foreach ($this->sidecarViewdefs as $menuItem) {
             $content .= "\${$this->menuName}[] = " . var_export($menuItem, true) . ";\n";
         }
         return sugar_file_put_contents($newExtLocation . "/" . $this->filename, $content);
     } elseif ($this->basename === 'globalControlLinks') {
         return $this->handleSaveArray($this->menuName, "custom/clients/base/views/profileactions/profileactions.php");
     } else {
         return $this->handleSaveArray($this->menuName, "custom/modules/{$this->module}/clients/base/menus/header/header.php");
     }
 }
Пример #23
0
function mkdir_recursive($path, $check_is_parent_dir = false)
{
    if (sugar_is_dir($path, 'instance')) {
        return true;
    }
    if (sugar_is_file($path, 'instance')) {
        print "ERROR: mkdir_recursive(): argument {$path} is already a file.\n";
        return false;
    }
    $path = clean_path($path);
    $path = str_replace(clean_path(getcwd()), '', $path);
    $thePath = '';
    $dirStructure = explode("/", $path);
    $status = true;
    foreach ($dirStructure as $dirPath) {
        $thePath .= '/' . $dirPath;
        $mkPath = getcwd() . '/' . $thePath;
        if (!is_dir($mkPath)) {
            $status = $status & sugar_mkdir($mkPath);
        }
    }
    return $status;
}
 public function testCanLoadCustomEnglishLanguageAppStringsWhenCurrentLanguageDoesNotExist()
 {
     $GLOBALS['current_language'] = 'FR_fr';
     sugar_mkdir("modules/{$this->_moduleName}/Dashlets/TestModuleDashlet/", null, true);
     sugar_file_put_contents("modules/{$this->_moduleName}/Dashlets/TestModuleDashlet/TestModuleDashlet.en_us.lang.php", '<?php $dashletStrings["TestModuleDashlet"]["foo"] = "bar"; ?>');
     create_custom_directory("modules/{$this->_moduleName}/Dashlets/TestModuleDashlet/");
     sugar_file_put_contents("custom/modules/{$this->_moduleName}/Dashlets/TestModuleDashlet/TestModuleDashlet.en_us.lang.php", '<?php $dashletStrings["TestModuleDashlet"]["foo"] = "barbarbar"; ?>');
     $dashlet = new Dashlet(0);
     $dashlet->loadLanguage('TestModuleDashlet', "modules/{$this->_moduleName}/Dashlets/");
     $this->assertEquals("barbarbar", $dashlet->dashletStrings["foo"]);
 }
Пример #25
0
 /**
  * function to save XML contents into a file
  *
  * @param 	string $xmlFilename location of the xml file
  *			string $xmlContents contents of the xml file
  * @return	string boolean denoting whether save has failed
  */
 function saveXMLFile($xmlFilename, $xmlContents)
 {
     global $app_strings;
     global $locale;
     $xmlContents = chr(255) . chr(254) . $GLOBALS['locale']->translateCharset($xmlContents, 'UTF-8', 'UTF-16LE');
     // Create dir if it doesn't exist
     $dir = dirname($xmlFilename);
     if (!sugar_is_dir($dir)) {
         sugar_mkdir($dir, null, true);
     }
     // open file
     if (!($fh = sugar_fopen($xmlFilename, 'w'))) {
         $GLOBALS['log']->debug("Cannot open file ({$xmlFilename})");
         return;
     }
     // write the contents to the file
     if (fwrite($fh, $xmlContents) === FALSE) {
         $GLOBALS['log']->debug("Cannot write to file ({$xmlFilename})");
         return false;
     }
     $GLOBALS['log']->debug("Success, wrote ({$xmlContents}) to file ({$xmlFilename})");
     fclose($fh);
     return true;
 }
        $current_user->retrieve($logged_user['id']);
    } else {
        echo "Not an admin user in users table. Please provide an admin user\n";
        exit(1);
    }
} else {
    echo "*******************************************************************************\n";
    echo "*** ERROR: 4th parameter must be a valid admin user.\n";
    echo $usage;
    echo "FAILURE\n";
    exit(1);
}
/////retrieve admin user
$unzip_dir = sugar_cached("upgrades/temp");
$install_file = $sugar_config['upload_dir'] . "/upgrades/patch/" . basename($argv[1]);
sugar_mkdir($sugar_config['upload_dir'] . "/upgrades/patch", 0775, true);
$_SESSION['unzip_dir'] = $unzip_dir;
$_SESSION['install_file'] = $install_file;
$_SESSION['zip_from_dir'] = $zip_from_dir;
mkdir_recursive($unzip_dir);
if (!is_dir($unzip_dir)) {
    fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n");
    exit(1);
}
unzip($argv[1], $unzip_dir);
// mimic standard UW by copy patch zip to appropriate dir
copy($argv[1], $install_file);
////	END UPGRADE PREP
///////////////////////////////////////////////////////////////////////////////
if (function_exists('set_upgrade_vars')) {
    set_upgrade_vars();
Пример #27
0
function create_writable_dir($dirname)
{
    if (is_dir($dirname) || @sugar_mkdir($dirname, 0755)) {
        $ok = make_writable($dirname);
    }
    if (empty($ok)) {
        installLog("ERROR: Cannot create writable dir {$dirname}");
    }
}
Пример #28
0
 public function setup()
 {
     $this->_moduleName = 'TestModuleForDashletLoadLanguageTest' . mt_rand();
     sugar_mkdir("custom/modules/{$this->_moduleName}/metadata/", null, true);
     sugar_file_put_contents("custom/modules/{$this->_moduleName}/metadata/dashletviewdefs.php", '<?php $dashletData[\'' . $this->_moduleName . 'Dashlet\'][\'searchFields\'] = array(); $dashletData[\'' . $this->_moduleName . 'Dashlet\'][\'columns\'] = array(\'Foo\'); ?>');
 }
 * 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:  TODO: To be written.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
require_once 'include/formbase.php';
global $mod_strings;
global $app_strings;
if (!empty($_REQUEST['body_html'])) {
    $dir_path = "{$GLOBALS['sugar_config']['cache_dir']}generated_forms/";
    if (!file_exists($dir_path)) {
        sugar_mkdir($dir_path, 0777);
    }
    $file = $dir_path . 'WebToLeadForm_' . time() . '.html';
    $fp = sugar_fopen($file, 'wb');
    fwrite($fp, from_html($_REQUEST['body_html']));
    fclose($fp);
}
$xtpl = new XTemplate('modules/Campaigns/WebToLeadDownloadForm.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
$webformlink = "<b>{$mod_strings['LBL_DOWNLOAD_TEXT_WEB_TO_LEAD_FORM']}</b></br>";
$webformlink .= "<a href={$GLOBALS['sugar_config']['cache_dir']}generated_forms/WebToLeadForm_" . time() . ".html>{$mod_strings['LBL_DOWNLOAD_WEB_TO_LEAD_FORM']}</a>";
$xtpl->assign("LINK_TO_WEB_FORM", $webformlink);
$xtpl->parse("main");
$xtpl->out("main");
Пример #30
0
function prepSystemForUpgrade()
{
    global $sugar_config;
    global $sugar_flavor;
    global $mod_strings;
    global $current_language;
    global $subdirs;
    global $base_upgrade_dir;
    global $base_tmp_upgrade_dir;
    list($p_base_upgrade_dir, $p_base_tmp_upgrade_dir) = getUWDirs();
    ///////////////////////////////////////////////////////////////////////////////
    ////	Make sure variables exist
    if (empty($base_upgrade_dir)) {
        $base_upgrade_dir = $p_base_upgrade_dir;
    }
    if (empty($base_tmp_upgrade_dir)) {
        $base_tmp_upgrade_dir = $p_base_tmp_upgrade_dir;
    }
    sugar_mkdir($base_tmp_upgrade_dir, 0775, true);
    if (!isset($subdirs) || empty($subdirs)) {
        $subdirs = array('full', 'langpack', 'module', 'patch', 'theme');
    }
    $upgrade_progress_dir = $base_tmp_upgrade_dir;
    $upgrade_progress_file = $upgrade_progress_dir . '/upgrade_progress.php';
    if (file_exists($upgrade_progress_file)) {
        if (function_exists('get_upgrade_progress') && function_exists('didThisStepRunBefore')) {
            if (didThisStepRunBefore('end')) {
                include $upgrade_progress_file;
                unset($upgrade_config);
                unlink($upgrade_progress_file);
            }
        }
    }
    // increase the cuttoff time to 1 hour
    ini_set("max_execution_time", "3600");
    // make sure dirs exist
    if ($subdirs != null) {
        foreach ($subdirs as $subdir) {
            sugar_mkdir("{$base_upgrade_dir}/{$subdir}", 0775, true);
        }
    }
    // array of special scripts that are executed during (un)installation-- key is type of script, value is filename
    if (!defined('SUGARCRM_PRE_INSTALL_FILE')) {
        define('SUGARCRM_PRE_INSTALL_FILE', 'scripts/pre_install.php');
        define('SUGARCRM_POST_INSTALL_FILE', 'scripts/post_install.php');
        define('SUGARCRM_PRE_UNINSTALL_FILE', 'scripts/pre_uninstall.php');
        define('SUGARCRM_POST_UNINSTALL_FILE', 'scripts/post_uninstall.php');
    }
    $script_files = array("pre-install" => constant('SUGARCRM_PRE_INSTALL_FILE'), "post-install" => constant('SUGARCRM_POST_INSTALL_FILE'), "pre-uninstall" => constant('SUGARCRM_PRE_UNINSTALL_FILE'), "post-uninstall" => constant('SUGARCRM_POST_UNINSTALL_FILE'));
    // check that the upload limit is set to 6M or greater
    define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024);
    // 6 Megabytes
    $upload_max_filesize = ini_get('upload_max_filesize');
    $upload_max_filesize_bytes = return_bytes($upload_max_filesize);
    if ($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
        $GLOBALS['log']->debug("detected upload_max_filesize: {$upload_max_filesize}");
        $admin_strings = return_module_language($current_language, 'Administration');
        echo '<p class="error">' . $admin_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'] . ' ' . get_cfg_var('cfg_file_path') . "</p>\n";
    }
}