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 } }
public function testoverride_value_to_string() { //execute the method and test if it returns expected values $expected = "\$array_name['value_name'] = 'value';"; $actual = override_value_to_string('array_name', 'value_name', 'value'); $this->assertSame($actual, $expected); }
public function test_overide_value_to_string() { $name = 'name'; $value_name = 1; $value = 4; $expected = '$name[1] = 4;'; $this->assertEquals($expected, override_value_to_string($name, $value_name, $value)); }
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 } }
function update_override($entry, $strings, $array_name) { global $start_dir, $base_dir; $new_buffer = ''; $override = 'custom' . substr($entry, 1); if (file_exists($override)) { echo 'Updating Format:<br>'; include $override; if (isset(${$array_name})) { $new_strings = ${$array_name}; if (is_array($strings) && is_array($new_strings)) { foreach ($strings as $name => $value) { if (isset($new_strings[$name])) { //only if they aren't the same do we write if ($new_strings[$name] != $strings[$name]) { echo "Updating: {$name}<br>"; echo "Your Value:" . $new_strings[$name] . '<br>'; echo "Original Value:" . $strings[$name] . '<br>'; $keep = override_value_to_string($array_name, $name, $new_strings[$name]) . "\n"; $new_buffer .= $keep; echo $keep . '<br><br>'; } } } foreach ($new_strings as $name => $value) { if (!isset($strings[$name])) { //only if they aren't the same do we write echo "Adding Custom Array: {$name}<br>"; $keep = override_value_to_string($array_name, $name, $new_strings[$name]) . "\n"; $new_buffer .= $keep; echo $keep . '<br><br>'; } } } } } if (!empty($new_buffer)) { echo 'Writing new custom file:<br>'; $fp = fopen($override, 'w'); fwrite($fp, "<?php\n" . $new_buffer . "?>"); } }
function saveSubPanelDefOverride($panel, $subsection, $override) { global $layout_defs, $beanList; //save the new subpanel $name = "subpanel_layout['list_fields']"; //bugfix: load looks for moduleName/metadata/subpanels, not moduleName/subpanels $path = 'custom/modules/' . $panel->_instance_properties['module'] . '/metadata/subpanels'; //bug# 40171: "Custom subpanels not working as expected" //each custom subpanel needs to have a unique custom def file $filename = $panel->parent_bean->object_name . "_subpanel_" . $panel->name; //bug 42262 (filename with $panel->_instance_properties['get_subpanel_data'] can create problem if had word "function" in it) $oldName1 = '_override' . $panel->parent_bean->object_name . $panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name']; $oldName2 = '_override' . $panel->parent_bean->object_name . $panel->_instance_properties['get_subpanel_data']; if (file_exists('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName1}.php")) { unlink('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName1}.php"); } if (file_exists('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName2}.php")) { unlink('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$oldName2}.php"); } $extname = '_override' . $filename; //end of bug# 40171 mkdir_recursive($path, true); write_array_to_file($name, $override, $path . '/' . $filename . '.php'); //save the override for the layoutdef //tyoung 10.12.07 pushed panel->name to lowercase to match case in subpaneldefs.php files - //gave error on bad index 'module' as this override key didn't match the key in the subpaneldefs $name = "layout_defs['" . $panel->parent_bean->module_dir . "']['subpanel_setup']['" . strtolower($panel->name) . "']"; // $GLOBALS['log']->debug('SubPanel.php->saveSubPanelDefOverride(): '.$name); $newValue = override_value_to_string($name, 'override_subpanel_name', $filename); mkdir_recursive('custom/Extension/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true); $fp = sugar_fopen('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$extname}.php", 'w'); fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n{$newValue}\n?>"); fclose($fp); require_once 'ModuleInstall/ModuleInstaller.php'; $moduleInstaller = new ModuleInstaller(); $moduleInstaller->silent = true; // make sure that the ModuleInstaller->log() function doesn't echo while rebuilding the layoutdefs $moduleInstaller->rebuild_layoutdefs(); if (file_exists('modules/' . $panel->parent_bean->module_dir . '/layout_defs.php')) { include 'modules/' . $panel->parent_bean->module_dir . '/layout_defs.php'; } if (file_exists('custom/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php')) { include 'custom/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'; } }
function replaceOverride($array_name, $key, $value) { $GLOBALS[$array_name][$key] = $value; $this->overrideClearDuplicates($array_name, $key); $new_entry = '/***CONFIGURATOR***/' . override_value_to_string($array_name, $key, $value); $this->override = str_replace('?>', "{$new_entry}\n?>", $this->override); }
protected function saveSubpanelDefinitions($basepath, $installDefPrefix, $relationshipName, $subpanelDefinitions) { mkdir_recursive("{$basepath}/layoutdefs/"); foreach ($subpanelDefinitions as $moduleName => $definitions) { $filename = "{$basepath}/layoutdefs/{$relationshipName}_{$moduleName}.php"; $subpanelVarname = 'layout_defs["' . $moduleName . '"]["subpanel_setup"]'; $out = ""; foreach ($definitions as $definition) { $GLOBALS['log']->debug(get_class($this) . "->saveSubpanelDefinitions(): saving the following to {$filename}" . print_r($definition, true)); if (empty($definition['get_subpanel_data']) || $definition['subpanel_name'] == 'history' || $definition['subpanel_name'] == 'activities') { $definition['get_subpanel_data'] = $definition['subpanel_name']; } $out .= override_value_to_string($subpanelVarname, strtolower($definition['get_subpanel_data']), $definition) . "\n"; } if (!empty($out)) { $out = "<?php\n // created: " . date('Y-m-d H:i:s') . "\n" . $out; sugar_file_put_contents($filename, $out); } $installDefs[$moduleName] = array('from' => "{$installDefPrefix}/relationships/layoutdefs/{$relationshipName}_{$moduleName}.php", 'to_module' => $moduleName); } return $installDefs; }
private function copyCustomDropdownValuesForModules($modules, $path) { if (file_exists("custom/include/language")) { if (mkdir_recursive("{$path}/SugarModules/include")) { global $app_list_strings; $backStrings = $app_list_strings; foreach (scandir("custom/include/language") as $langFile) { $app_list_strings = array(); if (strcasecmp(substr($langFile, -4), ".php") != 0) { continue; } include "custom/include/language/{$langFile}"; $out = "<?php \n"; $lang = substr($langFile, 0, -9); $options = $this->getCustomDropDownStringsForModules($modules, $app_list_strings); foreach ($options as $name => $arr) { $out .= override_value_to_string('app_list_strings', $name, $arr); } mkdir_recursive("{$path}/SugarModules/include/language/"); sugar_file_put_contents("{$path}/SugarModules/include/language/{$lang}.{$this->name}.php", $out); } $app_list_strings = $backStrings; } } }
function replace_app_string($name, $value, &$file_contents) { $new_contents = $file_contents; if (!empty($name) && is_string($value) && !empty($file_contents)) { $pattern = '/\\$app_strings\\[\'' . $name . '\'\\][\\ ]*=[\\ ]*\'[^\']*\'[\\ ]*;/'; $replacement = override_value_to_string('app_strings', $name, $value); $new_contents = preg_replace($pattern, $replacement, $file_contents, 1); } return $new_contents; }
function exportCustom($modules, $export = true, $clean = true) { $path = $this->getBuildDir(); if ($clean && file_exists($path)) { rmdir_recursive($path); } foreach ($modules as $mod) { $pathmod = "{$path}/SugarModules/modules/{$mod}"; if (mkdir_recursive($pathmod)) { if (file_exists("custom/modules/{$mod}")) { copy_recursive("custom/modules/{$mod}", "{$pathmod}"); } else { print "ERROR: One module is not a custom module.\n"; return false; } } //Convert modstring files to extension compatible arrays if (is_dir("{$pathmod}/language")) { $modLangDir = opendir("{$pathmod}/language"); while (false !== ($langFile = readdir($modLangDir))) { $mod_strings = array(); if (strcasecmp(substr($langFile, -4), ".php") != 0) { continue; } include "{$pathmod}/language/{$langFile}"; $out = "<?php \n // created: " . date('Y-m-d H:i:s') . "\n"; foreach ($mod_strings as $lbl_key => $lbl_val) { $out .= override_value_to_string("mod_strings", $lbl_key, $lbl_val) . "\n"; } $out .= "\n?>\n"; $fp = sugar_fopen("{$pathmod}/language/{$langFile}", 'w'); fwrite($fp, $out); fclose($fp); } } } if (file_exists("custom/include/language")) { if (mkdir_recursive("{$path}/SugarModules/include")) { global $app_list_strings; $backStrings = $app_list_strings; $includeDir = opendir("custom/include/language"); while (false !== ($langFile = readdir($includeDir))) { $app_list_strings = array(); if (strcasecmp(substr($langFile, -4), ".php") != 0) { continue; } include "custom/include/language/{$langFile}"; $out = "<?php \n"; $lang = substr($langFile, 0, -9); $options = $this->getCustomDropDownStringsForModules($modules, $app_list_strings); foreach ($options as $name => $arr) { $out .= override_value_to_string('app_list_strings', $name, $arr); } mkdir_recursive("{$path}/SugarModules/include/language/"); $fp = sugar_fopen("{$path}/SugarModules/include/language/{$lang}.{$this->name}.php", 'w'); fwrite($fp, $out); fclose($fp); } $app_list_strings = $backStrings; } } if (file_exists($path)) { $manifest = $this->getManifest(true) . $this->customBuildInstall($modules, $path); $fp = sugar_fopen($path . '/manifest.php', 'w'); fwrite($fp, $manifest); fclose($fp); } if (file_exists('modules/ModuleBuilder/MB/LICENSE.txt')) { copy('modules/ModuleBuilder/MB/LICENSE.txt', $path . '/LICENSE.txt'); } else { if (file_exists('LICENSE.txt')) { copy('LICENSE.txt', $path . '/LICENSE.txt'); } } require_once 'include/utils/zip_utils.php'; $date = date('Y_m_d_His'); $zipDir = $this->getZipDir(); if (!file_exists($zipDir)) { mkdir_recursive($zipDir); } $cwd = getcwd(); chdir($this->getBuildDir()); zip_dir('.', $cwd . '/' . $zipDir . '/' . $this->name . $date . '.zip'); chdir($cwd); if ($clean && file_exists($this->getBuildDir())) { rmdir_recursive($this->getBuildDir()); } if ($export) { header('Location:' . $zipDir . '/' . $this->name . $date . '.zip'); } return $zipDir . '/' . $this->name . $date . '.zip'; }
/** * Saves a sidecar layout extension to use the new view override for this subpanel */ protected function saveSidecarSubpanelDefOverride() { $client = $this->getViewClient(); $layoutPath = "custom/Extension/modules/{$this->loadedModule}/Ext/clients/{$client}/layouts/subpanels"; $layoutDefsName = "viewdefs['{$this->loadedModule}']['{$client}']['layout']['subpanels']['components'][]"; $viewName = $filename = $this->sidecarSubpanelName; $overrideName = 'override_subpanel_list_view'; $this->removeOldOverideExtension($layoutPath, $client); $overrideValue = array("link" => $this->linkName, "view" => $viewName); $newValue = override_value_to_string($layoutDefsName, $overrideName, $overrideValue); mkdir_recursive($layoutPath, true); $extname = '_override' . $filename; sugar_file_put_contents("{$layoutPath}/{$extname}.php", "<?php\n//auto-generated file DO NOT EDIT\n{$newValue}\n"); }
private function copyCustomIncludesForModules($modules, $path) { foreach (self::$appExtensions as $spec) { $varName = $spec['varName']; $it = $this->getDirectoryIterator('custom/' . $spec['dir']); foreach ($it as $file) { ${$varName} = array(); include $file; $values = $this->getCustomOptionsForModules($modules, ${$varName}); if (count($values) > 0) { $contents = "<?php \n"; foreach ($values as $name => $arr) { $contents .= override_value_to_string($varName, $name, $arr); } $subPathName = $it->getSubPathname(); $subPathName = str_replace('.lang', '', $subPathName); $subPathName = substr($subPathName, 0, -4) . '.' . $this->name . substr($subPathName, -4); $destination = $path . '/SugarModules/' . $spec['dir'] . '/' . $subPathName; mkdir_recursive(dirname($destination)); sugar_file_put_contents($destination, $contents); } } } }
function saveSubPanelDefOverride($panel, $subsection, $override) { global $layout_defs, $beanList; //save the new subpanel $name = "subpanel_layout['list_fields']"; $path = 'custom/modules/' . $panel->_instance_properties['module'] . '/subpanels'; $filename = $panel->parent_bean->object_name . $panel->_instance_properties['subpanel_name']; $extname = $panel->parent_bean->object_name . $panel->_instance_properties['module'] . $panel->_instance_properties['subpanel_name']; mkdir_recursive('custom/modules/' . $panel->_instance_properties['module'] . '/subpanels', true); write_array_to_file($name, $override, $path . '/' . $filename . '.php'); //save the override for the layoutdef $name = "layout_defs['" . $panel->parent_bean->module_dir . "']['subpanel_setup']['" . $panel->name . "']"; $newValue = override_value_to_string($name, 'override_subpanel_name', $filename); mkdir_recursive('custom/Extension/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs', true); $fp = fopen('custom/Extension/modules/' . $panel->parent_bean->module_dir . "/Ext/Layoutdefs/{$extname}.php", 'w'); fwrite($fp, "<?php\n//auto-generated file DO NOT EDIT\n{$newValue}\n?>"); fclose($fp); require_once 'ModuleInstall/ModuleInstaller.php'; $moduleInstaller = new ModuleInstaller(); $moduleInstaller->rebuild_layoutdefs(); include 'modules/' . $panel->parent_bean->module_dir . '/layout_defs.php'; include 'custom/modules/' . $panel->parent_bean->module_dir . '/Ext/Layoutdefs/layoutdefs.ext.php'; }
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); $entry_point_registry['AsteriskCallDownload'] = array('file' => 'custom/modules/Asterisk/include/callDownload.php', 'auth' => true); $entry_point_registry['AsteriskFakeCall'] = array('file' => 'custom/modules/Asterisk/include/tests/fake_dialer/test_ui.php', 'auth' => true); $entry_point_registry['AsteriskFakeDialerActions'] = array('file' => 'custom/modules/Asterisk/include/tests/fake_dialer/test_actions.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); $onClickLocation = "window.location=index.php?module=Configurator&action=asterisk_configurator"; if ($_REQUEST['mode'] == 'Install') { ?> <br /><br /> <img src="https://gitimg.com/blak3r/yaai-stats/install-3.6.10-community/track"> <img src="custom/modules/Asterisk/include/images/logo.png" alt="Callinize Logo" style="margin-right:-5px"><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.4em;"><strong> NOTE: If you just did an upgrade install, <u>RUN QUICK REPAIR AND REBUILD</u> References to custom user fields added need to be refreshed. </strong> </span> <BR> <BR> <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"> <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script> <!-- @@@@ BEGIN CALLINIZE COMMUNITY ONLY @@@@ --> <table style="margin-bottom:-30px;"> <tr> <TD width="2%"> </td> <td width="40%" valign="top"> <div class="know-whos-calling"> <div class="item"> <div class="left"> <h2>Upgrade Today</h2> <p>Upgrade from the community edition and get awesome features like:<P> <UL> <LI> Mobile App - Log/Create/Track from Anywhere! </LI> <LI> Support for Leads and custom phone fields. </LI> <LI> Call Recording / Playback in Sugar</LI> <LI> Operator Panel - Web switchboard for Asterisk </LI> <LI> Customer Support </LI> </UL> <a href="http://www.callinize.com/features.html" target="_blank"><button class="btn btn-primary">Learn More</button></a> </div> </div> </div> <TD width="75px"> </td> <TD width="50%"> <div id="myCarousel" class="carousel slide animate" style="width:375px; "> <ol class="carousel-indicators dark"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1" class=""></li> <li data-target="#myCarousel" data-slide-to="2" class=""></li> </ol> <div class="carousel-inner"> <div class="item active"> <img src="custom/modules/Asterisk/include/images/banner_mobile_cropped.jpg" alt="" style="width: 375px; height: 275px; max-height:400px;"> <div class="carousel-caption"> <p><strong>Mobile App:</strong> Finally! Your CRM Telephony integration will not require users to be tied down to their desk. </div> </div> <div class="item"> <img src="custom/modules/Asterisk/include/images/banner_fop2.jpg" alt="" style="width: 375px; height: 275px; max-height:400px;"> <div class="carousel-caption"> <P><strong>Operator Panel</strong> See presence of your coworkers, attended transfer, manage call queues, park calls, etc. -- all from right inside sugar.</P> </div> </div> <div class="item"> <img src="custom/modules/Asterisk/include/images/banner_callrecording.jpg" alt="" style="width: 375px; height: 275px; max-height:400px;"> <div class="carousel-caption"> <p><strong>Call Recordings</strong> Listen to phone call recordings inside SugarCRM automatically related to the Call. </div> </div> </div> </div> </td> </tr> </table> <!-- @@@@ END CALLINIZE COMMUNITY ONLY @@@@ --> <input title="Continue" class="button primary" onclick="javascript:window.location='index.php?module=Configurator&action=asterisk_configurator';" type="button" name="button" value=" Continue on to Module Configuration --> "> <br/> <br/> <?php } }