/**
  * Saves $data to the $name dropdown for the $role name
  *
  * @param $fieldName
  * @param $role
  * @param $data
  * @return boolean
  */
 public function handleSave($fieldName, $role, $data)
 {
     $path = $this->getFilePath($fieldName, $role);
     $dir = dirname($path);
     if (!SugarAutoLoader::ensureDir($dir)) {
         $GLOBALS['log']->error("ParserRoleDropDownFilter :: Cannot create directory {$dir}");
         return false;
     }
     $result = write_array_to_file("role_dropdown_filters['{$fieldName}']", $this->convertFormData($data), $path);
     if ($result) {
         $this->rebuildExtension($role);
         MetaDataManager::refreshSectionCache(MetaDataManager::MM_EDITDDFILTERS, array(), array('role' => $role));
     }
     return $result;
 }
Ejemplo n.º 2
0
    protected function toggleRevenueLineItemsLinkInWorkFlows($show = false)
    {
        // make sure all the links are visible in workflows
        /* @var $rli_bean = RevenueLineItem */
        $rli_bean = BeanFactory::getBean('RevenueLineItems');
        $rli_links = $rli_bean->get_linked_fields();
        $rnr_modules = array();
        foreach ($rli_links as $name => $link) {
            if ($rli_bean->load_relationship($name) && $rli_bean->{$name} instanceof Link2) {
                $bean = BeanFactory::getBean($rli_bean->{$name}->getRelatedModuleName());
                $rel_name = $rli_bean->{$name}->getRelatedModuleLinkName();
                // if for some reason we didn't find a rli_name on the other side of the link
                // we should just ignore it
                if (empty($rel_name)) {
                    continue;
                }
                $file = 'rli_link_workflow.php';
                $folder = "custom/Extension/modules/{$bean->module_dir}/Ext";
                SugarAutoLoader::ensureDir($folder . '/Vardefs');
                if ($show === true) {
                    $file_contents = <<<EOL
<?php
\$dictionary['{$bean->object_name}']['fields']['{$rel_name}']['workflow'] = true;
EOL;
                    sugar_file_put_contents($folder . '/Vardefs/' . $file, $file_contents);
                } else {
                    if (SugarAutoLoader::fileExists($folder . '/Vardefs/' . $file)) {
                        // since we don't what to show it, just remove the file as it defaults
                        // to false out of the box.
                        SugarAutoLoader::unlink($folder . '/Vardefs/' . $file);
                    }
                }
                $rnr_modules[] = $bean->module_name;
            }
        }
        return $rnr_modules;
    }
Ejemplo n.º 3
0
/**
 * @return bool
 * @param app_list_strings array
 * @desc Saves the app_list_strings to file in the 'custom' dir.
 */
function save_custom_app_list_strings(&$app_list_strings, $language)
{
    $dirname = 'custom/include/language';
    if (SugarAutoLoader::ensureDir($dirname)) {
        $filename = "{$dirname}/{$language}.lang.php";
        if (!write_array_to_file('app_list_strings', $app_list_strings, $filename)) {
            $GLOBALS['log']->fatal("Unable to write edited language pak to file: {$filename}");
        } else {
            $cache_key = 'app_list_strings.' . $language;
            sugar_cache_clear($cache_key);
            return true;
        }
    } else {
        $GLOBALS['log']->fatal("Unable to create dir: {$dirname}");
    }
    return false;
}
    /**
     * Enable and Show the RevenueLine Item Module
     *
     * - Add the file that shows the RLI Module
     * - Adds the `studio.php` file
     * - Puts  RLI module from the menu bar
     * - Adds the ACL Actions
     */
    protected function fixRevenueLineItemModule()
    {
        // lets make sure the dir is there
        SugarAutoLoader::ensureDir($this->rliModuleExtFolder . '/Vardefs');
        $file_contents = <<<EOL
<?php
\$dictionary['RevenueLineItem']['importable'] = true;
\$dictionary['RevenueLineItem']['unified_search'] = true;
EOL;
        sugar_file_put_contents($this->rliModuleExtFolder . '/Vardefs/' . $this->rliModuleExtVardefFile, $file_contents);
        SugarAutoLoader::ensureDir($this->appExtFolder . '/Include');
        // we need to run the code we are putting in the custom file
        $GLOBALS['moduleList'][] = 'RevenueLineItems';
        if (isset($GLOBALS['modInvisList']) && is_array($GLOBALS['modInvisList'])) {
            foreach ($GLOBALS['modInvisList'] as $key => $mod) {
                if ($mod === 'RevenueLineItems') {
                    unset($GLOBALS['modInvisList'][$key]);
                }
            }
        }
        $file_contents = <<<EOL
<?php
\$moduleList[] = 'RevenueLineItems';
if (isset(\$modInvisList) && is_array(\$modInvisList)) {
    foreach (\$modInvisList as \$key => \$mod) {
        if (\$mod === 'RevenueLineItems') {
            unset(\$modInvisList[\$key]);
        }
    }
}
EOL;
        sugar_file_put_contents($this->appExtFolder . '/Include/' . $this->rliModuleExtFile, $file_contents);
        // enable the ACLs on RevenueLineItems
        ACLAction::addActions('RevenueLineItems');
        // show the rli module in WorkFlows
        $affected_modules = $this->toggleRevenueLineItemsLinkInWorkFlows(true);
        // show the rli module in the mega menu
        $this->setRevenueLineItemModuleTab(true);
        // handle the parent_type_field
        $this->setRevenueLineItemInParentRelateDropDown(true);
        // enable the item in the quick create
        $this->toggleRevenueLineItemQuickCreate(true);
        // place the studio file
        sugar_touch($this->rliStudioFile);
        $affected_modules[] = 'RevenueLineItems';
        return $affected_modules;
    }
Ejemplo n.º 5
0
 protected function getExtensionFilePath($dropdownName, $lang)
 {
     $dirName = 'custom/Extension/application/Ext/Language';
     if (SugarAutoLoader::ensureDir($dirName)) {
         $fileName = "{$dirName}/{$lang}.sugar_{$dropdownName}.php";
         return $fileName;
     } else {
         $GLOBALS['log']->fatal("Unable to create dir: {$dirName}");
     }
     return false;
 }